Crazy Eddies GUI System  0.7.1
CEGUIItemEntry.h
1 /***********************************************************************
2  filename: CEGUIItemEntry.h
3  created: 31/3/2005
4  author: Tomas Lindquist Olsen (based on code by Paul D Turner)
5 
6  purpose: Interface to base class for ItemEntry widget
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIItemEntry_h_
31 #define _CEGUIItemEntry_h_
32 
33 #include "../CEGUIBase.h"
34 #include "../CEGUIWindow.h"
35 #include "CEGUIItemEntryProperties.h"
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
50 class CEGUIEXPORT ItemEntryWindowRenderer : public WindowRenderer
51 {
52 public:
57  ItemEntryWindowRenderer(const String& name);
58 
67  virtual Size getItemPixelSize(void) const = 0;
68 };
69 
78 class CEGUIEXPORT ItemEntry : public Window
79 {
80 public:
81  /*************************************************************************
82  Constants
83  *************************************************************************/
84  static const String WidgetTypeName;
86 
87  /*************************************************************************
88  Accessors
89  *************************************************************************/
98  Size getItemPixelSize(void) const;
99 
105  ItemListBase* getOwnerList(void) const {return d_ownerList;}
106 
111  bool isSelected(void) const {return d_selected;}
112 
117  bool isSelectable(void) const {return d_selectable;}
118 
119  /*************************************************************************
120  Set methods
121  *************************************************************************/
131  void setSelected(bool setting) {setSelected_impl(setting, true);}
132 
137  void select(void) {setSelected_impl(true, true);}
138 
143  void deselect(void) {setSelected_impl(false, true);}
144 
150  void setSelected_impl(bool state, bool notify);
151 
165  void setSelectable(bool setting);
166 
167  /*************************************************************************
168  Construction and Destruction
169  *************************************************************************/
174  ItemEntry(const String& type, const String& name);
175 
180  virtual ~ItemEntry(void) {}
181 
182 protected:
183  /*************************************************************************
184  Abstract Implementation Functions
185  *************************************************************************/
194  //virtual Size getItemPixelSize_impl(void) const = 0;
195 
196  /*************************************************************************
197  Implementation Functions
198  *************************************************************************/
210  virtual bool testClassName_impl(const String& class_name) const
211  {
212  if (class_name=="ItemEntry") return true;
213  return Window::testClassName_impl(class_name);
214  }
215 
216  // validate window renderer
217  virtual bool validateWindowRenderer(const String& name) const
218  {
219  return (name == "ItemEntry");
220  }
221 
222  /*************************************************************************
223  New Event Handlers
224  *************************************************************************/
229  virtual void onSelectionChanged(WindowEventArgs& e);
230 
231  /*************************************************************************
232  Overridden Event Handlers
233  *************************************************************************/
234  virtual void onMouseClicked(MouseEventArgs& e);
235 
236  /*************************************************************************
237  Implementation Data
238  *************************************************************************/
239 
241  ItemListBase* d_ownerList;
242 
244  bool d_selected;
245 
247  bool d_selectable;
248 
249  // make the ItemListBase a friend
250  friend class ItemListBase;
251 
252 private:
253  /************************************************************************
254  Static Properties for this class
255  ************************************************************************/
256  static ItemEntryProperties::Selectable d_selectableProperty;
257  static ItemEntryProperties::Selected d_selectedProperty;
258 
259  void addItemEntryProperties(void);
260 };
261 
262 } // End of CEGUI namespace section
263 
264 #if defined(_MSC_VER)
265 # pragma warning(pop)
266 #endif
267 
268 #endif // end of guard _CEGUIItemEntry_h_