Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

pgscrollbar.h

Go to the documentation of this file.
00001 /*
00002     ParaGUI - crossplatform widgetset
00003     Copyright (C) 2000,2001,2002  Alexander Pipelka
00004  
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009  
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014  
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  
00019     Alexander Pipelka
00020     pipelka@teleweb.at
00021  
00022     Last Update:      $Author: mbickel $
00023     Update Date:      $Date: 2007-04-13 16:15:57 $
00024     Source File:      $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/include/pgscrollbar.h,v $
00025     CVS/RCS Revision: $Revision: 1.2 $
00026     Status:           $State: Exp $
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

Generated on Tue Jun 24 01:27:49 2008 for Advanced Strategic Command by  doxygen 1.4.2