[1] | 1 | /* |
---|
| 2 | ----------------------------------------------------------------------------- |
---|
| 3 | This source file is part of OGRE |
---|
| 4 | (Object-oriented Graphics Rendering Engine) |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
| 8 | Also see acknowledgements in Readme.html |
---|
| 9 | |
---|
| 10 | You may use this sample code for anything you like, it is not covered by the |
---|
| 11 | LGPL like the rest of the engine. |
---|
| 12 | ----------------------------------------------------------------------------- |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #ifndef _ItemSelectorViewManager_H_ |
---|
| 16 | #define _ItemSelectorViewManager_H_ |
---|
| 17 | |
---|
| 18 | #include "OgreString.h" |
---|
| 19 | |
---|
| 20 | #include "OgreNoMemoryMacros.h" |
---|
| 21 | #include <CEGUI/CEGUIImageset.h> |
---|
| 22 | #include <CEGUI/CEGUISystem.h> |
---|
| 23 | #include <CEGUI/CEGUILogger.h> |
---|
| 24 | #include <CEGUI/CEGUISchemeManager.h> |
---|
| 25 | #include <CEGUI/CEGUIWindowManager.h> |
---|
| 26 | #include <CEGUI/CEGUIWindow.h> |
---|
| 27 | #include <CEGUI/elements/CEGUICheckbox.h> |
---|
| 28 | #include <CEGUI/elements/CEGUICombobox.h> |
---|
| 29 | #include <CEGUI/elements/CEGUIListbox.h> |
---|
| 30 | #include <CEGUI/elements/CEGUIListboxTextItem.h> |
---|
| 31 | #include <CEGUI/elements/CEGUIPushButton.h> |
---|
| 32 | #include <CEGUI/elements/CEGUIScrollbar.h> |
---|
| 33 | #include <CEGUI/elements/CEGUIScrollablePane.h> |
---|
| 34 | #include "OgreMemoryMacros.h" |
---|
| 35 | |
---|
| 36 | /** Provides interface between a View and a Controller. |
---|
| 37 | */ |
---|
| 38 | class ItemSelectorInterface |
---|
| 39 | { |
---|
| 40 | public: |
---|
| 41 | virtual ~ItemSelectorInterface(void) {} |
---|
| 42 | virtual void itemStateChanged(const size_t index, const bool state) = 0; |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | /** A generic view for showing checkbox items in a vertical list. Checkboxes |
---|
| 46 | are in a Scrollable pane so items can be scrolled into view. |
---|
| 47 | */ |
---|
| 48 | class ItemSelectorViewManager |
---|
| 49 | { |
---|
| 50 | public: |
---|
| 51 | ItemSelectorViewManager(const Ogre::String& parentWindowName); |
---|
| 52 | ~ItemSelectorViewManager(void){} |
---|
| 53 | |
---|
| 54 | /** Returns number of items in the container. |
---|
| 55 | */ |
---|
| 56 | size_t getSelectorCount(void) const { return mItemSelectorContainer.size(); } |
---|
| 57 | /** iterates through compositors available through CompositorManager and update list |
---|
| 58 | */ |
---|
| 59 | /** Add a new Item selector to the container |
---|
| 60 | */ |
---|
| 61 | void addItemSelector(const Ogre::String& displayText); |
---|
| 62 | Ogre::String getItemSelectorText(const size_t index) const |
---|
| 63 | { |
---|
| 64 | return Ogre::String(mItemSelectorContainer.at(index).CheckBoxWidget->getText().c_str()); |
---|
| 65 | } |
---|
| 66 | /** Inform Manager about who will be the controller that responds to item event messages. |
---|
| 67 | */ |
---|
| 68 | void setItemSelectorController(ItemSelectorInterface* controller); |
---|
| 69 | |
---|
| 70 | protected: |
---|
| 71 | struct ItemSelector |
---|
| 72 | { |
---|
| 73 | // make use of widget text member to store Compositor name |
---|
| 74 | // widget toggle state is used for enable/disable compositor |
---|
| 75 | // widget ID used for selector index |
---|
| 76 | CEGUI::Checkbox* CheckBoxWidget; |
---|
| 77 | |
---|
| 78 | ItemSelector() : CheckBoxWidget(0) {} |
---|
| 79 | }; |
---|
| 80 | typedef std::vector<ItemSelector> ItemSelectorContainer; |
---|
| 81 | typedef ItemSelectorContainer::iterator ItemSelectorIterator; |
---|
| 82 | |
---|
| 83 | float mVerticalScrollPosition; |
---|
| 84 | CEGUI::Window* mParentWindow; |
---|
| 85 | CEGUI::ScrollablePane* mScrollablePane; |
---|
| 86 | ItemSelectorInterface* mItemSelectorController; |
---|
| 87 | |
---|
| 88 | ItemSelectorContainer mItemSelectorContainer; |
---|
| 89 | |
---|
| 90 | private: |
---|
| 91 | bool handleCheckStateChanged(const CEGUI::EventArgs& e); |
---|
| 92 | |
---|
| 93 | }; |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | #endif |
---|