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: YDumbTab.cc 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #define YUILogComponent "ui" 00027 #include "YUILog.h" 00028 00029 #include "YUISymbols.h" 00030 #include "YDumbTab.h" 00031 #include "YShortcut.h" 00032 00033 00034 struct YDumbTabPrivate 00035 { 00036 YDumbTabPrivate() 00037 {} 00038 00039 bool dummy; 00040 }; 00041 00042 00043 00044 00045 YDumbTab::YDumbTab( YWidget * parent ) 00046 : YSelectionWidget( parent, 00047 "", // label 00048 true ) // enforceSingleSelection 00049 , priv( new YDumbTabPrivate ) 00050 { 00051 YUI_CHECK_NEW( priv ); 00052 setChildrenManager( new YSingleWidgetChildManager( this ) ); 00053 00054 setDefaultStretchable( YD_HORIZ, true ); 00055 setDefaultStretchable( YD_VERT, true ); 00056 } 00057 00058 00059 YDumbTab::~YDumbTab() 00060 { 00061 // NOP 00062 } 00063 00064 00065 void 00066 YDumbTab::addItem( YItem * item ) 00067 { 00068 YSelectionWidget::addItem( item ); 00069 } 00070 00071 00072 bool 00073 YDumbTab::stretchable( YUIDimension dim ) const 00074 { 00075 if ( hasChildren() ) 00076 return firstChild()->stretchable( dim ); 00077 else 00078 return YWidget::stretchable( dim ); 00079 } 00080 00081 00082 std::string 00083 YDumbTab::debugLabel() const 00084 { 00085 std::string str = widgetClass(); 00086 00087 for ( YItemConstIterator it = itemsBegin(); 00088 it != itemsEnd(); 00089 ++it ) 00090 { 00091 str += " [" + (*it)->label() + "]"; 00092 } 00093 00094 return str; 00095 } 00096 00097 00098 00099 const YPropertySet & 00100 YDumbTab::propertySet() 00101 { 00102 static YPropertySet propSet; 00103 00104 if ( propSet.isEmpty() ) 00105 { 00106 /* 00107 * @property itemID Value The currently selected item (tab page) 00108 * @property itemID CurrentItem The currently selected item (tab page) 00109 * @property itemList Items All items (all tab pages) 00110 */ 00111 propSet.add( YProperty( YUIProperty_Value, YOtherProperty ) ); 00112 propSet.add( YProperty( YUIProperty_CurrentItem, YOtherProperty ) ); 00113 propSet.add( YProperty( YUIProperty_Items, YOtherProperty ) ); 00114 propSet.add( YWidget::propertySet() ); 00115 } 00116 00117 return propSet; 00118 } 00119 00120 00121 bool 00122 YDumbTab::setProperty( const std::string & propertyName, const YPropertyValue & val ) 00123 { 00124 propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch 00125 00126 if ( propertyName == YUIProperty_Value ) return false; // Needs special handling 00127 else if ( propertyName == YUIProperty_CurrentItem ) return false; // Needs special handling 00128 else if ( propertyName == YUIProperty_Items ) return false; // Needs special handling 00129 else 00130 { 00131 return YWidget::setProperty( propertyName, val ); 00132 } 00133 00134 return true; // success -- no special processing necessary 00135 } 00136 00137 00138 YPropertyValue 00139 YDumbTab::getProperty( const std::string & propertyName ) 00140 { 00141 propertySet().check( propertyName ); // throws exceptions if not found 00142 00143 if ( propertyName == YUIProperty_Value ) return YPropertyValue( YOtherProperty ); 00144 else if ( propertyName == YUIProperty_CurrentItem ) return YPropertyValue( YOtherProperty ); 00145 else if ( propertyName == YUIProperty_Items ) return YPropertyValue( YOtherProperty ); 00146 else 00147 { 00148 return YWidget::getProperty( propertyName ); 00149 } 00150 }