00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00033 #ifndef PG_SCROLLBAR_H
00034 #define PG_SCROLLBAR_H
00035
00036 #include "pgthemewidget.h"
00037 #include "pgbutton.h"
00038
00048 class DECLSPEC PG_ScrollBar : public PG_ThemeWidget {
00049
00050 protected:
00051
00052 #ifndef DOXYGEN_SKIP
00053 class ScrollButton : public PG_Button {
00054 public:
00055
00056 ScrollButton(PG_ScrollBar* parent, const PG_Rect& r = PG_Rect::null);
00057 virtual ~ScrollButton();
00058
00059 void SetTickMode(bool on);
00060
00061 protected:
00062
00064 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00066 bool eventMouseMotion(const SDL_MouseMotionEvent* motion);
00068 PG_ScrollBar* GetParent();
00070 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00072 int GetPosFromPoint(PG_Point p);
00073
00074 private:
00075
00077 PG_Point offset;
00078
00080 bool my_tickMode;
00081
00082 };
00083 #endif // DOXYGEN_SKIP
00084
00085
00086 public:
00087
00089 typedef enum {
00090 VERTICAL,
00091 HORIZONTAL
00092 } ScrollDirection;
00093
00095 enum {
00096 IDSCROLLBAR_UP = PG_WIDGETID_INTERNAL + 1,
00097 IDSCROLLBAR_DOWN = PG_WIDGETID_INTERNAL + 2,
00098 IDSCROLLBAR_LEFT = PG_WIDGETID_INTERNAL + 3,
00099 IDSCROLLBAR_RIGHT = PG_WIDGETID_INTERNAL + 4,
00100 IDSCROLLBAR_DRAG = PG_WIDGETID_INTERNAL + 5
00101 };
00102
00106 template<class datatype>
00107 class SignalScrollPos : public PG_Signal2<PG_ScrollBar*, datatype> {}
00108 ;
00109 template<class datatype>
00110 class SignalScrollTrack : public PG_Signal2<PG_ScrollBar*, datatype> {}
00111 ;
00112
00114 PG_ScrollBar(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, ScrollDirection direction = VERTICAL, int id = -1, const std::string& style="Scrollbar");
00115
00117 virtual ~PG_ScrollBar();
00118
00119 void LoadThemeStyle(const std::string& widgettype);
00120
00122 void SetPosition(int pos);
00123
00125 int GetPosition();
00126
00128 void SetRange(Uint32 min, Uint32 max);
00129
00131 int GetMinRange();
00132
00134 int GetMaxRange();
00135
00137 void SetLineSize(int ls);
00138 int GetLineSize();
00139
00141 void SetPageSize(int ps);
00142
00143
00144 SignalScrollPos<long> sigScrollPos;
00145 SignalScrollTrack<long> sigScrollTrack;
00146
00147 protected:
00148
00150 void eventSizeWidget(Uint16 w, Uint16 h);
00151
00153 bool eventMouseMotion(const SDL_MouseMotionEvent* motion);
00154
00156 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00157
00159 virtual bool handleButtonClick(PG_Button* button);
00160
00162 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00163
00164 int scroll_min;
00165
00166 int scroll_max;
00167
00168 int scroll_current;
00169
00170 int my_linesize;
00171
00172 int my_pagesize;
00173
00174 PG_Button* scrollbutton[2];
00175
00176 ScrollButton* dragbutton;
00177
00184 PG_Rect position[4];
00185
00186 ScrollDirection sb_direction;
00187
00188 virtual void RecalcPositions();
00189
00190 friend class ScrollButton;
00191
00192 private:
00193
00194 PG_ScrollBar(const PG_ScrollBar&);
00195
00196 PG_ScrollBar& operator=(PG_ScrollBar&);
00197
00198 };
00199
00200 #endif // PG_SCROLLBAR_H