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

pgbutton.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:56 $
00024     Source File:      $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/include/pgbutton.h,v $
00025     CVS/RCS Revision: $Revision: 1.2 $
00026     Status:           $State: Exp $
00027 */
00028 
00034 #ifndef PG_BUTTON_H
00035 #define PG_BUTTON_H
00036 
00037 #include "pgwidget.h"
00038 #include "pgsignals.h"
00039 #include "pgdraw.h"
00040 #include <string>
00041 
00042 
00043 class PG_ButtonDataInternal;
00044 
00045 
00125 class DECLSPEC PG_Button : public PG_Widget  {
00126 public:
00127 
00131         enum {
00132             OK = 0x80000001,
00133             YES = 0x80000002,
00134             NO = 0x80000003,
00135             APPLY = 0x80000004,
00136             CANCEL = 0x80000005,
00137             CLOSE = 0x80000006,
00138             HELP = 0x80000007
00139         };
00140 
00144         typedef enum {
00145             PRESSED,
00146             UNPRESSED,
00147             HIGHLITED
00148         } STATE;
00149 
00154         typedef enum {
00155             MSGCAPTURE      = 0x00000001,
00156             SIGNALONCLICK   = 0x00000002,
00157             SIGNALONRELEASE = 0x00000004
00158         } BEHAVIOUR;
00159 
00160 
00164         template<class datatype = PG_Pointer>
00165 class SignalButtonClick : public PG_Signal1<PG_Button*, datatype> {}
00166         ;
00167 
00176         PG_Button(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, const std::string& text = PG_NULLSTR, int id = -1, const std::string& style="Button");
00177 
00179         virtual ~PG_Button();
00180 
00182         void LoadThemeStyle(const std::string& widgettype);
00183 
00185         void LoadThemeStyle(const std::string& widgettype, const std::string& objectname);
00186 
00194         void SetGradient(STATE state, const PG_Gradient& gradient);
00195 
00204         void SetBackground(STATE state, SDL_Surface* background, PG_Draw::BkMode mode = PG_Draw::TILE);
00205 
00211         void SetBorderColor(int b, const PG_Color& color);
00212 
00220         bool SetIcon(const std::string& filenameup=PG_NULLSTR, const std::string& filenamedown=PG_NULLSTR, const std::string& filenameover = PG_NULLSTR);
00221 
00230         bool SetIcon(const std::string& filenameup, const std::string& filenamedown, const std::string& filenameover, const PG_Color& colorkey);
00231 
00242         bool SetIcon(SDL_Surface* icon_up, SDL_Surface* icon_down = NULL, SDL_Surface* icon_over = NULL, bool freeSurfaces = false );
00243 
00249         SDL_Surface* GetIcon(STATE num);
00250 
00255         void SetIconIndent(Uint16 indent);
00256 
00266         void SetBorderSize(int norm, int pressed, int high);
00267 
00275         void SetToggle(bool bToggle);
00276 
00281         void SetPressed(bool pressed);
00282 
00288         void SetTransparency(Uint8 t, bool bRecursive = false);
00289 
00296         void SetTransparency(Uint8 norm, Uint8 pressed, Uint8 high);
00297 
00302         void SetShift(int pixelshift);
00303 
00310         bool GetPressed();
00311 
00321         void SetBlendLevel(STATE mode, Uint8 blend);
00322 
00328         Uint8 GetBlendLevel(STATE mode);
00329 
00336         void SetSizeByText(int Width = 0, int Height = 0, const std::string& Text = PG_NULLSTR);
00337 
00342         void SetBehaviour( int behaviour );
00343 
00344    void SetText(const std::string& text);
00345 
00346    
00347         SignalButtonClick<> sigClick;
00348 
00349         static SignalButtonClick<> sigGlobalClick;
00350 
00351 protected:
00352 
00354         virtual void eventButtonSurface(SDL_Surface** surface, STATE newstate, Uint16 w, Uint16 h);
00355 
00357         void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& dst);
00358 
00360         void eventSizeWidget(Uint16 w, Uint16 h);
00361 
00363         void eventMouseLeave();
00364 
00366         void eventMouseEnter();
00367 
00369         bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00370 
00372         bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00373 
00375    bool eventKeyDown (const SDL_KeyboardEvent *key);
00376    
00377 private:
00378 
00379         PG_Button(const PG_Button&);
00380         PG_Button& operator=(const PG_Button&);
00381 
00383         DLLLOCAL void FreeSurfaces();
00384 
00386         DLLLOCAL void FreeIcons();
00387 
00388         PG_ButtonDataInternal* _mid;
00389 };
00390 
00391 #endif // PG_BUTTON_H

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