Crazy Eddies GUI System 0.7.6
|
00001 /*********************************************************************** 00002 filename: CEGUIItemEntry.h 00003 created: 31/3/2005 00004 author: Tomas Lindquist Olsen (based on code by Paul D Turner) 00005 00006 purpose: Interface to base class for ItemEntry widget 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUIItemEntry_h_ 00031 #define _CEGUIItemEntry_h_ 00032 00033 #include "../CEGUIBase.h" 00034 #include "../CEGUIWindow.h" 00035 #include "CEGUIItemEntryProperties.h" 00036 00037 #if defined(_MSC_VER) 00038 # pragma warning(push) 00039 # pragma warning(disable : 4251) 00040 #endif 00041 00042 // Start of CEGUI namespace section 00043 namespace CEGUI 00044 { 00045 00050 class CEGUIEXPORT ItemEntryWindowRenderer : public WindowRenderer 00051 { 00052 public: 00057 ItemEntryWindowRenderer(const String& name); 00058 00067 virtual Size getItemPixelSize(void) const = 0; 00068 }; 00069 00078 class CEGUIEXPORT ItemEntry : public Window 00079 { 00080 public: 00081 /************************************************************************* 00082 Constants 00083 *************************************************************************/ 00084 static const String WidgetTypeName; 00085 00090 static const String EventSelectionChanged; 00091 00092 /************************************************************************* 00093 Accessors 00094 *************************************************************************/ 00103 Size getItemPixelSize(void) const; 00104 00110 ItemListBase* getOwnerList(void) const {return d_ownerList;} 00111 00116 bool isSelected(void) const {return d_selected;} 00117 00122 bool isSelectable(void) const {return d_selectable;} 00123 00124 /************************************************************************* 00125 Set methods 00126 *************************************************************************/ 00136 void setSelected(bool setting) {setSelected_impl(setting, true);} 00137 00142 void select(void) {setSelected_impl(true, true);} 00143 00148 void deselect(void) {setSelected_impl(false, true);} 00149 00155 void setSelected_impl(bool state, bool notify); 00156 00170 void setSelectable(bool setting); 00171 00172 /************************************************************************* 00173 Construction and Destruction 00174 *************************************************************************/ 00179 ItemEntry(const String& type, const String& name); 00180 00185 virtual ~ItemEntry(void) {} 00186 00187 protected: 00188 /************************************************************************* 00189 Abstract Implementation Functions 00190 *************************************************************************/ 00199 //virtual Size getItemPixelSize_impl(void) const = 0; 00200 00201 /************************************************************************* 00202 Implementation Functions 00203 *************************************************************************/ 00215 virtual bool testClassName_impl(const String& class_name) const 00216 { 00217 if (class_name=="ItemEntry") return true; 00218 return Window::testClassName_impl(class_name); 00219 } 00220 00221 // validate window renderer 00222 virtual bool validateWindowRenderer(const String& name) const 00223 { 00224 return (name == "ItemEntry"); 00225 } 00226 00227 /************************************************************************* 00228 New Event Handlers 00229 *************************************************************************/ 00234 virtual void onSelectionChanged(WindowEventArgs& e); 00235 00236 /************************************************************************* 00237 Overridden Event Handlers 00238 *************************************************************************/ 00239 virtual void onMouseClicked(MouseEventArgs& e); 00240 00241 /************************************************************************* 00242 Implementation Data 00243 *************************************************************************/ 00244 00246 ItemListBase* d_ownerList; 00247 00249 bool d_selected; 00250 00252 bool d_selectable; 00253 00254 // make the ItemListBase a friend 00255 friend class ItemListBase; 00256 00257 private: 00258 /************************************************************************ 00259 Static Properties for this class 00260 ************************************************************************/ 00261 static ItemEntryProperties::Selectable d_selectableProperty; 00262 static ItemEntryProperties::Selected d_selectedProperty; 00263 00264 void addItemEntryProperties(void); 00265 }; 00266 00267 } // End of CEGUI namespace section 00268 00269 #if defined(_MSC_VER) 00270 # pragma warning(pop) 00271 #endif 00272 00273 #endif // end of guard _CEGUIItemEntry_h_