Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

button.h

Go to the documentation of this file.
00001 /*
00002         ClanGUI, copyrights by various people. Have a look in the CREDITS file.
00003         
00004         This sourcecode is distributed using the Library GNU Public Licence,
00005         version 2 or (at your option) any later version. Please read LICENSE
00006         for details.
00007 */
00008 
00010 
00011 #ifndef header_button
00012 #define header_button
00013 
00014 #include "component.h"
00015 
00016 class CL_Surface;
00017 
00018 class CL_Button : public CL_Component
00019 //: Button component
00020 {
00022 public:
00023         CL_Button(
00024                 const CL_ComponentOptions &options,
00025                 CL_Component *parent,
00026                 CL_StyleManager *style = NULL);
00027 
00028         CL_Button(
00029                 const CL_Rect &pos,
00030                 const std::string &text,
00031                 CL_Component *parent,
00032                 CL_StyleManager *style = NULL);
00033 
00034         CL_Button(
00035                 const CL_Point &pos,
00036                 const std::string &text,
00037                 CL_Surface *surface_up,
00038                 CL_Surface *surface_down,
00039                 CL_Component *parent,
00040                 CL_StyleManager *style = NULL);
00041 
00042         CL_Button(
00043                 const CL_Point &pos,
00044                 const std::string &text,
00045                 CL_Surface *surface_up,
00046                 CL_Surface *surface_down,
00047                 CL_Surface *surface_disabled,
00048                 CL_Surface *surface_highlighted,
00049                 CL_Component *parent,
00050                 CL_StyleManager *style = NULL);
00051 
00052         virtual ~CL_Button();
00053 
00055 public:
00056         const std::string &get_text() const;
00057         //: Returns the button text.
00058 
00059         bool is_toggle_button() const;
00060         //: Returns true if the button is a toggle button.
00061 
00062         bool is_down() const;
00063         //: Returns true if the button pressed down, or false if it is standing up. 
00064 
00065         CL_Surface *get_surface_up() const;
00066         //: Returns the surface used when button is in the up-state.
00067 
00068         CL_Surface *get_surface_down() const;
00069         //: Returns the surface used when button is in the down-state.
00070 
00071         CL_Surface *get_surface_highlighted() const;
00072         //: Returns the surface used when button is highlighted.
00073 
00074         CL_Surface *get_surface_disabled() const;
00075         //: Returns the surface used when button is disabled.
00076 
00078 public:
00079         void set_text(const std::string &text);
00080         //: Sets the button text.
00081 
00082         void set_toggle_mode(bool toggle = true);
00083         //: If toggle is true, pressing the button toggles it between an On and and Off state. 
00084         // If toggle is false, pressing the button causes an action, then the button returns to the unpressed state. 
00085 
00086         void set_down(bool enable = true);
00087         //: Sets the state of the button to pressed down if enable is true or to standing up if enable is false. 
00088         // The pressed(), released() and toggled() signals are not emitted by this function. 
00089 
00090         void toggle();
00091         //: Toggle the button.
00092         //: The toggled() signal are emitted by this function.
00093 
00094         void set_surface_up(CL_Surface *surface);
00095         //: Sets the surface used when button is in the up-state.
00096 
00097         void set_surface_down(CL_Surface *surface);
00098         //: Set the surface used when button is in the down-state.
00099 
00100         void set_surface_highlighted(CL_Surface *surface);
00101         //: Sets the surface used when button is highlighted.
00102 
00103         void set_surface_disabled(CL_Surface *surface);
00104         //: Sets the surface used when button is disabled.
00105 
00107 public:
00108         CL_Signal_v1<bool> &sig_toggled();
00109         //: This signal is emitted whenever a toggle button changes status.
00111 
00112         CL_Signal_v0 &sig_clicked();
00113         //: This signal is emitted when the button is activated (i.e. first pressed down and then released when the mouse cursor is inside the button).
00114         
00115         CL_Signal_v0 &sig_pressed();
00116         //: This signal is emitted when the button is pressed down. 
00117 
00118         CL_Signal_v0 &sig_released();
00119         //: This signal is emitted when the button is released.
00120 
00122 private:
00123         CL_Button(const CL_Button &copy) : CL_Component(NULL, NULL) { return; } // disallow copy construction.
00124         class CL_Button_Generic *impl;
00125 };
00126 
00127 #endif

Generated at Wed Apr 4 19:53:59 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001