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

button.cpp

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 
00009 #include "precomp.h"
00010 #include "API/GUI/button.h"
00011 #include "API/GUI/component_options.h"
00012 #include "API/GUI/stylemanager.h"
00013 #include "button_generic.h"
00014 
00016 // Construction:
00017 
00018 CL_Button::CL_Button(
00019         const CL_ComponentOptions &options,
00020         CL_Component *parent,
00021         CL_StyleManager *style)
00022 :
00023         CL_Component(options, parent, style),
00024         impl(NULL)
00025 {
00026         impl = new CL_Button_Generic(this, options, get_style_manager());
00027         get_style_manager()->connect_styles("button", options, this);
00028 }
00029 
00030 CL_Button::CL_Button(
00031         const CL_Rect &pos,
00032         const std::string &text,
00033         CL_Component *parent,
00034         CL_StyleManager *style)
00035 :
00036         CL_Component(
00037                 CL_Button_Generic::create_options(pos, text, false),
00038                 parent,
00039                 style),
00040         impl(NULL)
00041 {
00042         CL_ComponentOptions options = CL_Button_Generic::create_options(pos, text, false);
00043         impl = new CL_Button_Generic(this, options, get_style_manager());
00044         get_style_manager()->connect_styles("button", options, this);
00045 }
00046 
00047 CL_Button::CL_Button(
00048         const CL_Point &pos,
00049         const std::string &text,
00050         CL_Surface *surface_up,
00051         CL_Surface *surface_down,
00052         CL_Component *parent,
00053         CL_StyleManager *style)
00054 :
00055         CL_Component(
00056                 CL_Button_Generic::create_options(CL_Rect(pos.x, pos.y, 0, 0), text, false),
00057                 parent,
00058                 style),
00059         impl(NULL)
00060 {
00061         CL_ComponentOptions options = CL_Button_Generic::create_options(CL_Rect(pos.x, pos.y, 0, 0), text, false);
00062         impl = new CL_Button_Generic(this, options, get_style_manager());
00063         set_surface_up(surface_up);
00064         set_surface_down(surface_down);
00065         get_style_manager()->connect_styles("button", options, this);
00066 }
00067 
00068 CL_Button::CL_Button(
00069         const CL_Point &pos,
00070         const std::string &text,
00071         CL_Surface *surface_up,
00072         CL_Surface *surface_down,
00073         CL_Surface *surface_disabled,
00074         CL_Surface *surface_highlighted,
00075         CL_Component *parent,
00076         CL_StyleManager *style)
00077 :
00078         CL_Component(
00079                 CL_Button_Generic::create_options(CL_Rect(pos.x, pos.y, 0, 0), text, false),
00080                 parent,
00081                 style),
00082         impl(NULL)
00083 {
00084         CL_ComponentOptions options = CL_Button_Generic::create_options(CL_Rect(pos.x, pos.y, 0, 0), text, false);
00085         impl = new CL_Button_Generic(this, options, get_style_manager());
00086         set_surface_up(surface_up);
00087         set_surface_down(surface_down);
00088         set_surface_highlighted(surface_highlighted);
00089         set_surface_disabled(surface_disabled);
00090         get_style_manager()->connect_styles("button", options, this);
00091 }
00092 
00093 CL_Button::~CL_Button()
00094 {
00095         delete impl;
00096 }
00097 
00099 // Attributes:
00100 
00101 const std::string &CL_Button::get_text() const
00102 {
00103         return impl->text;
00104 }
00105 
00106 bool CL_Button::is_toggle_button() const
00107 {
00108         return impl->toggle_mode;
00109 }
00110 
00111 bool CL_Button::is_down() const
00112 {
00113         return impl->toggled;
00114 }
00115 
00116 CL_Surface *CL_Button::get_surface_up() const
00117 {
00118         return impl->surface_up;
00119 }
00120 
00121 CL_Surface *CL_Button::get_surface_down() const
00122 {
00123         return impl->surface_down;
00124 }
00125 
00126 CL_Surface *CL_Button::get_surface_highlighted() const
00127 {
00128         return impl->surface_highlighted;
00129 }
00130 
00131 CL_Surface *CL_Button::get_surface_disabled() const
00132 {
00133         return impl->surface_disabled;
00134 }
00135 
00137 // Operations:
00138 
00139 void CL_Button::set_text(const std::string &text)
00140 {
00141         impl->text = text;
00142 }
00143 
00144 void CL_Button::set_toggle_mode(bool toggle)
00145 {
00146         impl->toggle_mode = toggle;
00147 }
00148 
00149 void CL_Button::set_down(bool enable)
00150 {
00151         impl->toggled = enable;
00152 }
00153 
00154 void CL_Button::toggle()
00155 {
00156         impl->toggled = !impl->toggled;
00157         impl->sig_toggled(impl->toggled);
00158 }
00159 
00160 void CL_Button::set_surface_up(CL_Surface *surface)
00161 {
00162         impl->surface_up = surface;
00163 }
00164 
00165 void CL_Button::set_surface_down(CL_Surface *surface)
00166 {
00167         impl->surface_down = surface;
00168 }
00169 
00170 void CL_Button::set_surface_highlighted(CL_Surface *surface)
00171 {
00172         impl->surface_highlighted = surface;
00173 }
00174 
00175 void CL_Button::set_surface_disabled(CL_Surface *surface)
00176 {
00177         impl->surface_disabled = surface;
00178 }
00179 
00181 // Signals:
00182 
00183 CL_Signal_v1<bool> &CL_Button::sig_toggled()
00184 {
00185         return impl->sig_toggled;
00186 }
00187 
00188 CL_Signal_v0 &CL_Button::sig_clicked()
00189 {
00190         return impl->sig_clicked;
00191 }
00192 
00193 CL_Signal_v0 &CL_Button::sig_pressed()
00194 {
00195         return impl->sig_pressed;
00196 }
00197 
00198 CL_Signal_v0 &CL_Button::sig_released()
00199 {
00200         return impl->sig_released;
00201 }

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