Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CEGUIMultiColumnListProperties.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIMultiColumnListProperties.cpp
00003         created:        11/7/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Implements multi-column list properties.
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #include "elements/CEGUIMultiColumnListProperties.h"
00027 #include "elements/CEGUIMultiColumnList.h"
00028 #include "CEGUIPropertyHelper.h"
00029 #include "CEGUILogger.h"
00030 
00031 // Start of CEGUI namespace section
00032 namespace CEGUI
00033 {
00034 
00035 // Start of MultiColumnListProperties namespace section
00036 namespace MultiColumnListProperties
00037 {
00038 String  ColumnsSizable::get(const PropertyReceiver* receiver) const
00039 {
00040         return PropertyHelper::boolToString(static_cast<const MultiColumnList*>(receiver)->isUserColumnSizingEnabled());
00041 }
00042 
00043 
00044 void    ColumnsSizable::set(PropertyReceiver* receiver, const String& value)
00045 {
00046         static_cast<MultiColumnList*>(receiver)->setUserColumnSizingEnabled(PropertyHelper::stringToBool(value));
00047 }
00048 
00049 
00050 String  ColumnsMovable::get(const PropertyReceiver* receiver) const
00051 {
00052         return PropertyHelper::boolToString(static_cast<const MultiColumnList*>(receiver)->isUserColumnDraggingEnabled());
00053 }
00054 
00055 
00056 void    ColumnsMovable::set(PropertyReceiver* receiver, const String& value)
00057 {
00058         static_cast<MultiColumnList*>(receiver)->setUserColumnDraggingEnabled(PropertyHelper::stringToBool(value));
00059 }
00060 
00061 
00062 String  SortSettingEnabled::get(const PropertyReceiver* receiver) const
00063 {
00064         return PropertyHelper::boolToString(static_cast<const MultiColumnList*>(receiver)->isUserSortControlEnabled());
00065 }
00066 
00067 
00068 void    SortSettingEnabled::set(PropertyReceiver* receiver, const String& value)
00069 {
00070         static_cast<MultiColumnList*>(receiver)->setUserSortControlEnabled(PropertyHelper::stringToBool(value));
00071 }
00072 
00073 
00074 String  SortColumnID::get(const PropertyReceiver* receiver) const
00075 {
00076         const MultiColumnList* mcl = static_cast<const MultiColumnList*>(receiver);
00077         return PropertyHelper::uintToString(mcl->getColumnID(mcl->getSortColumn()));
00078 }
00079 
00080 
00081 void    SortColumnID::set(PropertyReceiver* receiver, const String& value)
00082 {
00083         static_cast<MultiColumnList*>(receiver)->setSortColumnByID(PropertyHelper::stringToUint(value));
00084 }
00085 
00086 
00087 String  SortDirection::get(const PropertyReceiver* receiver) const
00088 {
00089         switch(static_cast<const MultiColumnList*>(receiver)->getSortDirection())
00090         {
00091         case ListHeaderSegment::Ascending:
00092                 return String((utf8*)"Ascending");
00093                 break;
00094 
00095         case ListHeaderSegment::Descending:
00096                 return String((utf8*)"Descending");
00097                 break;
00098 
00099         default:
00100                 return String((utf8*)"None");
00101                 break;
00102         }
00103 
00104 }
00105 
00106 
00107 void    SortDirection::set(PropertyReceiver* receiver, const String& value)
00108 {
00109         ListHeaderSegment::SortDirection dir;
00110 
00111         if (value == (utf8*)"Ascending")
00112         {
00113                 dir = ListHeaderSegment::Ascending;
00114         }
00115         else if (value == (utf8*)"Descending")
00116         {
00117                 dir = ListHeaderSegment::Descending;
00118         }
00119         else
00120         {
00121                 dir = ListHeaderSegment::None;
00122         }
00123 
00124         static_cast<MultiColumnList*>(receiver)->setSortDirection(dir);
00125 }
00126 
00127 
00128 String  NominatedSelectionColumnID::get(const PropertyReceiver* receiver) const
00129 {
00130         return PropertyHelper::uintToString(static_cast<const MultiColumnList*>(receiver)->getNominatedSelectionColumnID());
00131 }
00132 
00133 
00134 void    NominatedSelectionColumnID::set(PropertyReceiver* receiver, const String& value)
00135 {
00136         static_cast<MultiColumnList*>(receiver)->setNominatedSelectionColumn(PropertyHelper::stringToUint(value));
00137 }
00138 
00139 
00140 String  NominatedSelectionRow::get(const PropertyReceiver* receiver) const
00141 {
00142         return PropertyHelper::uintToString(static_cast<const MultiColumnList*>(receiver)->getNominatedSelectionRow());
00143 }
00144 
00145 
00146 void    NominatedSelectionRow::set(PropertyReceiver* receiver, const String& value)
00147 {
00148         static_cast<MultiColumnList*>(receiver)->setNominatedSelectionRow(PropertyHelper::stringToUint(value));
00149 }
00150 
00151 
00152 String  ForceVertScrollbar::get(const PropertyReceiver* receiver) const
00153 {
00154         return PropertyHelper::boolToString(static_cast<const MultiColumnList*>(receiver)->isVertScrollbarAlwaysShown());
00155 }
00156 
00157 
00158 void    ForceVertScrollbar::set(PropertyReceiver* receiver, const String& value)
00159 {
00160         static_cast<MultiColumnList*>(receiver)->setShowVertScrollbar(PropertyHelper::stringToBool(value));
00161 }
00162 
00163 
00164 String  ForceHorzScrollbar::get(const PropertyReceiver* receiver) const
00165 {
00166         return PropertyHelper::boolToString(static_cast<const MultiColumnList*>(receiver)->isHorzScrollbarAlwaysShown());
00167 }
00168 
00169 
00170 void    ForceHorzScrollbar::set(PropertyReceiver* receiver, const String& value)
00171 {
00172         static_cast<MultiColumnList*>(receiver)->setShowHorzScrollbar(PropertyHelper::stringToBool(value));
00173 }
00174 
00175 
00176 String  SelectionMode::get(const PropertyReceiver* receiver) const
00177 {
00178         switch(static_cast<const MultiColumnList*>(receiver)->getSelectionMode())
00179         {
00180         case MultiColumnList::RowMultiple:
00181                 return String((utf8*)"RowMultiple");
00182                 break;
00183 
00184         case MultiColumnList::ColumnSingle:
00185                 return String((utf8*)"ColumnSingle");
00186                 break;
00187 
00188         case MultiColumnList::ColumnMultiple:
00189                 return String((utf8*)"ColumnMultiple");
00190                 break;
00191 
00192         case MultiColumnList::CellSingle:
00193                 return String((utf8*)"CellSingle");
00194                 break;
00195 
00196         case MultiColumnList::CellMultiple:
00197                 return String((utf8*)"CellMultiple");
00198                 break;
00199 
00200         case MultiColumnList::NominatedColumnSingle:
00201                 return String((utf8*)"NominatedColumnSingle");
00202                 break;
00203 
00204         case MultiColumnList::NominatedColumnMultiple:
00205                 return String((utf8*)"NominatedColumnMultiple");
00206                 break;
00207 
00208         case MultiColumnList::NominatedRowSingle:
00209                 return String((utf8*)"NominatedRowSingle");
00210                 break;
00211 
00212         case MultiColumnList::NominatedRowMultiple:
00213                 return String((utf8*)"NominatedRowMultiple");
00214                 break;
00215 
00216         default:
00217                 return String((utf8*)"RowSingle");
00218                 break;
00219         }
00220 }
00221 
00222 
00223 void    SelectionMode::set(PropertyReceiver* receiver, const String& value)
00224 {
00225         MultiColumnList::SelectionMode mode;
00226 
00227         if (value == (utf8*)"RowMultiple")
00228         {
00229                 mode = MultiColumnList::RowMultiple;
00230         }
00231         else if (value == (utf8*)"ColumnSingle")
00232         {
00233                 mode = MultiColumnList::ColumnSingle;
00234         }
00235         else if (value == (utf8*)"ColumnMultiple")
00236         {
00237                 mode = MultiColumnList::ColumnMultiple;
00238         }
00239         else if (value == (utf8*)"CellSingle")
00240         {
00241                 mode = MultiColumnList::CellSingle;
00242         }
00243         else if (value == (utf8*)"CellMultiple")
00244         {
00245                 mode = MultiColumnList::CellMultiple;
00246         }
00247         else if (value == (utf8*)"NominatedColumnSingle")
00248         {
00249                 mode = MultiColumnList::NominatedColumnSingle;
00250         }
00251         else if (value == (utf8*)"NominatedColumnMultiple")
00252         {
00253                 mode = MultiColumnList::NominatedColumnMultiple;
00254         }
00255         else if (value == (utf8*)"NominatedRowSingle")
00256         {
00257                 mode = MultiColumnList::NominatedRowSingle;
00258         }
00259         else if (value == (utf8*)"NominatedRowMultiple")
00260         {
00261                 mode = MultiColumnList::NominatedRowMultiple;
00262         }
00263         else
00264         {
00265                 mode = MultiColumnList::RowSingle;
00266         }
00267 
00268         static_cast<MultiColumnList*>(receiver)->setSelectionMode(mode);
00269 }
00270 
00271 
00272 String ColumnHeader::get(const PropertyReceiver* receiver) const
00273 {
00274         return String("");
00275 }
00276 
00277 
00278 void ColumnHeader::set(PropertyReceiver* receiver, const String& value)
00279 {
00280         // extract data from the value string
00281 
00282         size_t wstart = value.find("width:");
00283         size_t idstart = value.find("id:");
00284 
00285         String caption(value.substr(0, wstart));
00286         caption = caption.substr(caption.find_first_of(":") + 1);
00287 
00288         String width(value.substr(wstart, idstart));
00289         width = width.substr(width.find_first_of(":") + 1);
00290 
00291         String id(value.substr(idstart));
00292         id = id.substr(id.find_first_of(":") + 1);
00293 
00294         static_cast<MultiColumnList*>(receiver)->addColumn(
00295                 caption, PropertyHelper::stringToUint(id), PropertyHelper::stringToFloat(width));
00296 }
00297 
00298 
00299 String RowCount::get(const PropertyReceiver* receiver) const
00300 {
00301         return PropertyHelper::uintToString(static_cast<const MultiColumnList*>(receiver)->getRowCount());
00302 }
00303 
00304 
00305 void RowCount::set(PropertyReceiver* receiver, const String& value)
00306 {
00307         // property is read only.
00308         Logger::getSingleton().logEvent(
00309                 "Attempt to set read only property 'RowCount' on MultiColumnListbox '" + 
00310                 static_cast<const MultiColumnList*>(receiver)->getName() + "'.", Errors);
00311 }
00312 
00313 
00314 } // End of  MultiColumnListProperties namespace section
00315 
00316 } // End of  CEGUI namespace section

Generated on Wed Sep 7 09:56:32 2005 for Crazy Eddies GUI System by  doxygen 1.4.3