libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YRadioButtonGroup.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YRadioButtonGroup_h 00026 #define YRadioButtonGroup_h 00027 00028 #include "YSingleChildContainerWidget.h" 00029 00030 class YRadioButton; 00031 class YRadioButtonGroupPrivate; 00032 00033 typedef std::list<YRadioButton *> YRadioButtonList; 00034 typedef YRadioButtonList::iterator YRadioButtonListIterator; 00035 typedef YRadioButtonList::const_iterator YRadioButtonListConstIterator; 00036 00037 00038 class YRadioButtonGroup : public YSingleChildContainerWidget 00039 { 00040 protected: 00041 /** 00042 * Constructor. 00043 **/ 00044 YRadioButtonGroup( YWidget * parent ); 00045 00046 public: 00047 /** 00048 * Destructor. 00049 **/ 00050 virtual ~YRadioButtonGroup(); 00051 00052 /** 00053 * Returns a descriptive name of this widget class for logging, 00054 * debugging etc. 00055 **/ 00056 virtual const char * widgetClass() const { return "YRadioButtonGroup"; } 00057 00058 /** 00059 * Find the currently selected button. 00060 **/ 00061 YRadioButton * currentButton() const; 00062 00063 /** 00064 * The same as currentButton() above for convenience. 00065 **/ 00066 YRadioButton * value() const { return currentButton(); } 00067 00068 /** 00069 * Add a RadioButton to this button group. RadioButtons are required to 00070 * call this in their constructor. 00071 * 00072 * Derived classes are free to overload this, but they should call this 00073 * base class function in the overloaded function. 00074 **/ 00075 virtual void addRadioButton( YRadioButton * radioButton ); 00076 00077 /** 00078 * Remove a RadioButton from this button group. RadioButtons are required 00079 * to call this in their destructor, but only if the button group is not 00080 * also in the process of being destroyed (otherwise there may be race 00081 * conditions with child widgets already destroyed): 00082 * 00083 * if ( ! buttonGroup()->beingDestroyed ) 00084 * buttonGroup()->removeRadioButton( this ); 00085 **/ 00086 virtual void removeRadioButton( YRadioButton * radioButton ); 00087 00088 /** 00089 * Unchecks all radio buttons except one. This method 00090 * can be used by a concrete UI (the Qt UI or the NCurses UI) 00091 * in the implementation of YRadioButton::setValue(). 00092 **/ 00093 void uncheckOtherButtons( YRadioButton * radioButton ); 00094 00095 /** 00096 * Set a property. 00097 * Reimplemented from YWidget. 00098 * 00099 * This method may throw exceptions, for example 00100 * - if there is no property with that name 00101 * - if the expected type and the type mismatch 00102 * - if the value is out of range 00103 * 00104 * This function returns 'true' if the value was successfully set and 00105 * 'false' if that value requires special handling (not in error cases: 00106 * those are covered by exceptions). 00107 **/ 00108 virtual bool setProperty( const std::string & propertyName, 00109 const YPropertyValue & val ); 00110 00111 /** 00112 * Get a property. 00113 * Reimplemented from YWidget. 00114 * 00115 * This method may throw exceptions, for example 00116 * - if there is no property with that name 00117 **/ 00118 virtual YPropertyValue getProperty( const std::string & propertyName ); 00119 00120 /** 00121 * Return this class's property set. 00122 * This also initializes the property set upon the first call. 00123 * 00124 * Reimplemented from YWidget. 00125 **/ 00126 virtual const YPropertySet & propertySet(); 00127 00128 protected: 00129 00130 /** 00131 * Return an iterator that points to the first RadioButton of this button 00132 * group. 00133 * 00134 * Note that RadioButtons in this group may be direct or indirect children 00135 * of the group, so don't confuse this with YWidget::widgetsBegin(). 00136 **/ 00137 YRadioButtonListConstIterator radioButtonsBegin() const; 00138 00139 /** 00140 * Return an iterator that points behind the last RadioButton of this 00141 * button group. 00142 **/ 00143 YRadioButtonListConstIterator radioButtonsEnd() const; 00144 00145 /** 00146 * Return the number of RadioButtons in this button group. 00147 **/ 00148 int radioButtonsCount() const; 00149 00150 00151 private: 00152 00153 ImplPtr<YRadioButtonGroupPrivate> priv; 00154 }; 00155 00156 00157 #endif // YRadioButtonGroup_h