00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _uscrollbar_hpp_
00021 #define _uscrollbar_hpp_
00022
00023 #include <ubit/ubox.hpp>
00024 #include <ubit/uboxLayout.hpp>
00025 #include <ubit/uboxGeom.hpp>
00026 #include <ubit/ucolor.hpp>
00027 #include <ubit/ustyle.hpp>
00028 #include <ubit/uview.hpp>
00029 namespace ubit {
00030
00031
00036 class UScrollbar: public UBox {
00037 public:
00038 UBIT_ELEMENT_CLASS(UScrollbar, UBox)
00039
00040 UScrollbar(const UArgs& = UArgs::none);
00046 UScrollbar(UFloat& value, const UArgs& = UArgs::none);
00054 friend UScrollbar& uscrollbar(const UArgs& a = UArgs::none);
00056
00057 friend UScrollbar& uscrollbar(UFloat& value, const UArgs& a = UArgs::none);
00059
00060 friend UScrollbar& uhscrollbar(const UArgs& a = UArgs::none);
00062
00063 friend UScrollbar& uvscrollbar(const UArgs& a = UArgs::none);
00065
00066 virtual ~UScrollbar();
00067
00068
00069
00070 bool isVertical() const;
00071 bool isHorizontal() const;
00072
00073 UFloat& value() {return *pvalue;}
00074 virtual float getValue() const;
00076
00077 virtual void setValue(float percent);
00082 virtual int getUnitIncrement() const;
00083 virtual int getBlockIncrement() const;
00085
00086 virtual void setUnitIncrement(int);
00087 virtual void setBlockIncrement(int);
00089
00090 virtual void setTracking(bool);
00091 virtual bool isTracking() const;
00093
00094 virtual void setTransparent(bool state);
00095 virtual bool isTransparent() const;
00097
00098
00099
00100
00101 static UStyle* createStyle();
00102
00103 virtual UBox* getKnob() {return pknob;}
00104 virtual UBox* getRail() {return prail;}
00105 virtual UBox* getLessScroller() {return pless_btn;}
00106 virtual UBox* getMoreScroller() {return pmore_btn;}
00108
00109 virtual UBox* createKnob(bool vertical);
00110 virtual UBox* createRail(bool vertical);
00111 virtual UBox* createLessScroller(bool vertical);
00112 virtual UBox* createMoreScroller(bool vertical);
00113
00114
00115
00116
00117 virtual void setPane(UScrollpane*);
00118 UScrollpane* getPane() {return ppane;}
00120
00121 virtual void setValueImpl(float percent, bool update_pane);
00123
00124 virtual void pressScroller(int dir);
00126
00127 private:
00128 friend class UScrollbarView;
00129 friend class UScrollpane;
00130 uptr<UFloat> pvalue;
00131 uptr<UScrollpane> ppane;
00132 uptr<UBox> pless_btn, pmore_btn, pknob, prail;
00133 UPos knob_pos;
00134 int unit_increment, block_increment;
00135 int delta_mouse;
00136 bool press_rail_goto_pos;
00137 bool is_transparent, show_rail, tracking_mode;
00138
00139 void constructs();
00140
00141
00142 virtual void pressKnob(UMouseEvent&);
00143 virtual void releaseKnob(UMouseEvent&);
00144 virtual void dragKnob(UMouseEvent&);
00145 virtual void pressRail(UMouseEvent&);
00146 virtual void releaseRail(UMouseEvent&);
00147 virtual float getPercent(UMouseEvent&, UView* knob_view,
00148 UView* rail_view, int delta_mouse);
00149 virtual float getIncrementPercent(int increment);
00150 };
00151
00152
00157 class UScrollbarView : public UView {
00158 public:
00159 static UViewStyle style;
00160 virtual UViewStyle* getViewStyle() {return &style;}
00161
00162 UScrollbarView(UChild*, UView* parview, UHardWinImpl*);
00163 static UView* createView(UChild*, UView* parview, UHardWinImpl*);
00164
00165
00166
00167 #ifndef NO_DOC
00168 friend class UScrollbar;
00169 virtual void doUpdate(UContext&, URegion r, URegion clip, UViewUpdate&);
00170 #endif
00171 };
00172 }
00173 #endif
00174
00175
00176
00177