diff -r 12dff7d3d115 lib/irrlicht/include/IGUIContextMenu.h --- a/lib/irrlicht/include/IGUIContextMenu.h Wed Sep 23 01:03:09 2009 +0200 +++ b/lib/irrlicht/include/IGUIContextMenu.h Wed Sep 23 01:10:27 2009 +0200 @@ -36,7 +36,7 @@ namespace gui \param checked: Specifies if the menu item should be initially checked. \return Returns the index of the new item */ virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true, - bool hasSubMenu=false, bool checked=false) = 0; + bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0; //! Adds a separator item to the menu virtual void addSeparator() = 0; @@ -100,6 +100,12 @@ namespace gui \param idx: Zero based index of the menu item \return Returns a pointer to the submenu of an item. */ virtual IGUIContextMenu* getSubMenu(u32 idx) const = 0; + + //! should the element change the checked status on clicking + virtual void setItemAutoChecking(u32 idx, bool autoChecking) = 0; + + //! does the element change the checked status on clicking + virtual bool getItemAutoChecking(u32 idx) const = 0; }; } // end namespace gui diff -r 12dff7d3d115 lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Wed Sep 23 01:03:09 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.cpp Wed Sep 23 01:10:27 2009 +0200 @@ -60,11 +60,12 @@ u32 CGUIContextMenu::getItemCount() cons //! Adds a menu item. -u32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu, bool checked) +u32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu, bool checked, bool autoChecking) { SItem s; s.Enabled = enabled; s.Checked = checked; + s.AutoChecking = autoChecking; s.Text = text; s.IsSeparator = (text == 0); s.SubMenu = 0; @@ -114,7 +115,7 @@ void CGUIContextMenu::setSubMenu(u32 ind //! Adds a separator item to the menu void CGUIContextMenu::addSeparator() { - addItem(0, -1, true, false, false); + addItem(0, -1, true, false, false, false); } @@ -136,6 +137,24 @@ void CGUIContextMenu::setItemText(u32 id Items[idx].Text = text; recalculateSize(); +} + +//! should the element change the checked status on clicking +void CGUIContextMenu::setItemAutoChecking(u32 idx, bool autoChecking) +{ + if ( idx >= Items.size()) + return; + + Items[idx].AutoChecking = autoChecking; +} + +//! does the element change the checked status on clicking +bool CGUIContextMenu::getItemAutoChecking(u32 idx) const +{ + if (idx >= Items.size()) + return false; + + return Items[idx].AutoChecking; } //! get a textID which can be used for stringtables @@ -343,6 +362,11 @@ u32 CGUIContextMenu::sendClick(const cor Items[HighLighted].IsSeparator || Items[HighLighted].SubMenu) return 2; + + if ( Items[HighLighted].AutoChecking ) + { + Items[HighLighted].Checked = Items[HighLighted].Checked ? false : true; + } SEvent event; event.EventType = EET_GUI_EVENT; @@ -682,6 +706,10 @@ void CGUIContextMenu::serializeAttribute out->addInt(tmp.c_str(), Items[i].CommandId); tmp = "Enabled"; tmp += i; out->addBool(tmp.c_str(), Items[i].Enabled); + tmp = "Checked"; tmp += i; + out->addBool(tmp.c_str(), Items[i].Checked); + tmp = "AutoChecking"; tmp += i; + out->addBool(tmp.c_str(), Items[i].AutoChecking); } } } @@ -709,9 +737,10 @@ void CGUIContextMenu::deserializeAttribu core::stringc tmp; core::stringw txt; core::stringw txtID; - s32 commandid; - bool enabled; - bool checked; + s32 commandid = -1; + bool enabled=true; + bool checked=false; + bool autochecking=false; tmp = "IsSeparator"; tmp += i; if ( in->getAttributeAsBool(tmp.c_str()) ) @@ -733,8 +762,11 @@ void CGUIContextMenu::deserializeAttribu tmp = "Checked"; tmp += i; checked = in->getAttributeAsBool(tmp.c_str()); - addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked); - Items[i].TextID = txtID; + tmp = "AutoChecking"; tmp += i; + autochecking = in->getAttributeAsBool(tmp.c_str()); + + s32 id = addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked, autochecking); + Items[id].TextID = txtID; } } diff -r 12dff7d3d115 lib/irrlicht/source/Irrlicht/CGUIContextMenu.h --- a/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Wed Sep 23 01:03:09 2009 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIContextMenu.h Wed Sep 23 01:10:27 2009 +0200 @@ -36,7 +36,7 @@ namespace gui //! Adds a menu item. virtual u32 addItem(const wchar_t* text, s32 commandid, - bool enabled, bool hasSubMenu, bool checked); + bool enabled, bool hasSubMenu, bool checked, bool autoChecking); //! Adds a separator item to the menu virtual void addSeparator(); @@ -87,6 +87,12 @@ namespace gui //! Sets the visible state of this element. virtual void setVisible(bool visible); + //! should the element change the checked status on clicking + virtual void setItemAutoChecking(u32 idx, bool autoChecking); + + //! does the element change the checked status on clicking + virtual bool getItemAutoChecking(u32 idx) const; + //! Returns command id of a menu item virtual s32 getItemCommandId(u32 idx) const; @@ -114,6 +120,7 @@ namespace gui bool IsSeparator; bool Enabled; bool Checked; + bool AutoChecking; core::dimension2d Dim; s32 PosY; CGUIContextMenu* SubMenu;