Crazy Eddies GUI System  0.7.2
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;
85 
91 
92  /*************************************************************************
93  Accessors
94  *************************************************************************/
103  Size getItemPixelSize(void) const;
104 
110  ItemListBase* getOwnerList(void) const {return d_ownerList;}
111 
116  bool isSelected(void) const {return d_selected;}
117 
122  bool isSelectable(void) const {return d_selectable;}
123 
124  /*************************************************************************
125  Set methods
126  *************************************************************************/
136  void setSelected(bool setting) {setSelected_impl(setting, true);}
137 
142  void select(void) {setSelected_impl(true, true);}
143 
148  void deselect(void) {setSelected_impl(false, true);}
149 
155  void setSelected_impl(bool state, bool notify);
156 
170  void setSelectable(bool setting);
171 
172  /*************************************************************************
173  Construction and Destruction
174  *************************************************************************/
179  ItemEntry(const String& type, const String& name);
180 
185  virtual ~ItemEntry(void) {}
186 
187 protected:
188  /*************************************************************************
189  Abstract Implementation Functions
190  *************************************************************************/
199  //virtual Size getItemPixelSize_impl(void) const = 0;
200 
201  /*************************************************************************
202  Implementation Functions
203  *************************************************************************/
215  virtual bool testClassName_impl(const String& class_name) const
216  {
217  if (class_name=="ItemEntry") return true;
218  return Window::testClassName_impl(class_name);
219  }
220 
221  // validate window renderer
222  virtual bool validateWindowRenderer(const String& name) const
223  {
224  return (name == "ItemEntry");
225  }
226 
227  /*************************************************************************
228  New Event Handlers
229  *************************************************************************/
234  virtual void onSelectionChanged(WindowEventArgs& e);
235 
236  /*************************************************************************
237  Overridden Event Handlers
238  *************************************************************************/
239  virtual void onMouseClicked(MouseEventArgs& e);
240 
241  /*************************************************************************
242  Implementation Data
243  *************************************************************************/
244 
246  ItemListBase* d_ownerList;
247 
249  bool d_selected;
250 
252  bool d_selectable;
253 
254  // make the ItemListBase a friend
255  friend class ItemListBase;
256 
257 private:
258  /************************************************************************
259  Static Properties for this class
260  ************************************************************************/
261  static ItemEntryProperties::Selectable d_selectableProperty;
262  static ItemEntryProperties::Selected d_selectedProperty;
263 
264  void addItemEntryProperties(void);
265 };
266 
267 } // End of CEGUI namespace section
268 
269 #if defined(_MSC_VER)
270 # pragma warning(pop)
271 #endif
272 
273 #endif // end of guard _CEGUIItemEntry_h_