/* ParaGUI - crossplatform widgetset Copyright (C) 2000,2001,2002 Alexander Pipelka This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Alexander Pipelka pipelka@teleweb.at Last Update: $Author: braindead $ Update Date: $Date: 2003/06/29 17:09:49 $ Source File: $Source: /cvsroot/paragui/paragui/include/pgbutton.h,v $ CVS/RCS Revision: $Revision: 1.3.6.2 $ Status: $State: Exp $ */ /** \file pgbutton.h Header file for the PG_Button class. This include file defines the standard button ID's and the PG_Button class. */ #ifndef PG_BUTTON_H #define PG_BUTTON_H #ifdef SWIG %include "swigcommon.h" %module pgbutton %{ #include "pgbutton.h" %} #endif #include "pgwidget.h" #include /** @author Alexander Pipelka @short Button that uses themes. Several predefined button IDs exist. All of them are associated with default icons used automatically when the given ID is assigned to a button:
\p BTN_ID_OK OK Icon
\p BTN_ID_YES Yes Icon
\p BTN_ID_NO No Icon
\p BTN_ID_APPPLY Apply Icon
\p BTN_ID_CANCEL Cancel Icon
\p BTN_ID_CLOSE Close Icon
\p BTN_ID_HELP Help Icon
\anchor theme_PG_Button

Theme support

widget type: Button (default)
object name: Button

Parent theme:

\ref theme_PG_Widget "PG_Widget" theme

Theme sample:

\code \endcode

Code:

*/ struct PG_ButtonDataInternal; class DECLSPEC PG_Button : public PG_Widget { public: /** Constructor for the PG_Button class @param parent pointer to the parent widget or NULL @param id id of the button (can be used in callbacks) @param r screen position of the button @param text button label @param style themestyle of the button */ PG_Button(PG_Widget* parent, int id, const PG_Rect& r, const char* text = NULL, const char* style="Button"); /** */ virtual ~PG_Button(); /** */ void LoadThemeStyle(const char* widgettype); #ifndef SWIG /** */ void LoadThemeStyle(const char* widgettype, const char* objectname); #endif /** Set the gradient. @param state buttonstate to set @param gradient gradient to set This member function set's the buttons gradient for a specific state. */ void SetGradient(int state, PG_Gradient& gradient); /** Set the background. @param state buttonstate to set @param background pointer to background surface @param mode background tiling mode This member function set's the buttons background and tiling mode for a specific state. */ void SetBackground(int state, SDL_Surface* background, int mode = BKMODE_TILE); /** Set the color of the border @param b borderindex 0 = upper-left / 1 = lower-right @param color border color (e.g. 0xRRGGBB) */ void SetBorderColor(int b, Uint32 color); /** Set icons for the button @param filenameup icon for unpressed state @param filenamedown icon for pressed state @return true on success */ // new in 1.0.2 (file) bool SetIcon2(const char* filenameup, const char* filenamedown, const char* filenameover, Uint32 colorkey); bool SetIcon2(const char* filenameup, const char* filenamedown, const char* filenameover); // 1.0.1 versions (file) bool SetIcon(const char* filenameup, const char* filenamedown = NULL); bool SetIcon(const char* filenameup, const char* filenamedown, Uint32 colorkey); // new in 1.0.2 (surface) bool SetIcon(SDL_Surface* icon_up, SDL_Surface* icon_down = NULL, SDL_Surface* icon_over = NULL); // 1.0.1 versions (surface) #ifndef SWIG bool SetIcon(SDL_Surface* icon_up, SDL_Surface* icon_down = NULL); #endif SDL_Surface* GetIcon(Uint8 num); /** Set the bordersize of the button @param norm bordersize for unpressed state @param pressed bordersize for pressed state @param high bordersize for highlighted state */ void SetBorderSize(int norm, int pressed, int high); /** */ void SetToggle(bool bToggle); /** */ void SetPressed(bool pressed); /** */ void SetTransparency(int norm, int pressed, int high); /** * Set the moving distance of the image when we press on it */ void SetShift(int pixelshift); /** */ bool GetPressed(); /** Set the blend-level of gradient and background image @param blend blend-level @param mode one of BTN_STATE_NORMAL, BTN_STATE_PRESSED, BTN_STATE_HIGH This function sets the blend level of gradient and background image. If the blend-level is 0 only the background image is visible. At a level of 255 only the gradient is visible. */ void SetBlendLevel(int mode, Uint8 blend); /** Get the current blend level. @param mode button mode @return the current blend level */ Uint8 GetBlendLevel(int mode); protected: /** */ virtual void eventButtonSurface(SDL_Surface** surface, int newstate, Uint16 w, Uint16 h); /** */ void eventBlit(SDL_Surface* srf, const PG_Rect& src, const PG_Rect& dst); /** */ void eventSizeWidget(Uint16 w, Uint16 h); /** */ void eventMouseLeave(); /** */ void eventMouseEnter(); /** */ bool eventMouseButtonUp(const SDL_MouseButtonEvent* button); /** */ bool eventMouseButtonDown(const SDL_MouseButtonEvent* button); int my_bordersize[3]; int my_transparency[3]; int my_state; //int id; int my_pressShift; private: #ifndef SWIG PG_Button(const PG_Button&); PG_Button& operator=(const PG_Button&); #endif /** */ void FreeSurfaces(); /** */ void FreeIcons(); PG_ButtonDataInternal* my_internaldata; }; // Standard button IDs /** Standard button ID: OK. */ #define BTN_ID_OK 0x80000001 /** Standard button ID: YES. */ #define BTN_ID_YES 0x80000002 /** Standard button ID: NO. */ #define BTN_ID_NO 0x80000003 /** Standard button ID: APPLY. */ #define BTN_ID_APPLY 0x80000004 /** Standard button ID: CANCEL. */ #define BTN_ID_CANCEL 0x80000005 /** Standard button ID: CLOSE. */ #define BTN_ID_CLOSE 0x80000006 /** Standard button ID: HELP. */ #define BTN_ID_HELP 0x80000007 #endif // PG_BUTTON_H