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/pgradiobutton.h,v $ 00025 CVS/RCS Revision: $Revision: 1.2 $ 00026 Status: $State: Exp $ 00027 */ 00028 00033 #ifndef PG_RADIOBUTTON_H 00034 #define PG_RADIOBUTTON_H 00035 00036 #include "pgthemewidget.h" 00037 #include "pglabel.h" 00038 00039 class PG_Button; 00040 00049 /* Perhaps radio buttons should have a special PG_RadioButtonGroup parent class 00050 * to make things more clear and eliminate all the group stuff within the radio 00051 * button itself? 00052 * 00053 * NO :) 00054 * I think this kind of implementation is simple and easy to understand. 00055 */ 00056 class DECLSPEC PG_RadioButton : public PG_ThemeWidget { 00057 public: 00058 00062 template<class datatype = PG_Pointer> 00063 class SignalButtonClick : public PG_Signal2<PG_RadioButton*, datatype> {} 00064 ; 00065 00067 PG_RadioButton(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, const std::string& text = PG_NULLSTR, PG_RadioButton* firstOfGroup = NULL, int id = -1, const std::string& style="RadioButton"); 00068 00070 ~PG_RadioButton(); 00071 00072 void LoadThemeStyle(const std::string& widgettype); 00073 00075 bool GetPressed(); 00076 00078 void SetPressed(); 00079 00081 void SetAlignment(PG_Label::TextAlign a); 00082 00084 void SetText(const std::string& text); 00085 00087 const PG_String& GetText(); 00088 00089 void SetFontColor(const PG_Color& Color); 00090 00091 void SetSizeByText(int Width = 0, int Height = 0, const std::string& Text = PG_NULLSTR); 00092 00094 void AddToGroup(PG_RadioButton* w); 00095 00097 PG_RadioButton* GetFirstOfGroup() { 00098 return my_groupFirst; 00099 } 00100 00101 00103 PG_RadioButton* GetNextOfGroup() { 00104 return my_groupNext; 00105 } 00106 00107 SignalButtonClick<bool> sigClick; 00108 00109 protected: 00110 00112 void ReleaseButton(); 00113 00115 void eventMouseEnter(); 00116 00118 void eventMouseLeave(); 00119 00121 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button); 00122 00124 virtual bool handleButtonClick(PG_Button* button); 00125 00126 PG_RadioButton* my_groupFirst; 00127 00128 PG_RadioButton* my_groupNext; 00129 00130 PG_Button* my_widgetButton; 00131 00132 PG_Label* my_widgetLabel; 00133 00134 bool my_isPressed; 00135 00136 private: 00137 00138 PG_RadioButton(const PG_RadioButton&); 00139 00140 PG_RadioButton& operator=(const PG_RadioButton&); 00141 00142 bool my_storeMarker; 00143 00144 Uint8 my_hoverTransparency; 00145 }; 00146 00147 #endif // PG_RADIOBUTTON_H
1.4.2