cxWidgets 1.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cx::cxMenu Class Reference

Represents a list of items, one of which may be selected. More...

#include <cxMenu.h>

Inheritance diagram for cx::cxMenu:
Inheritance graph
Collaboration diagram for cx::cxMenu:
Collaboration graph

Public Member Functions

 cxMenu (cxWindow *pParentWindow=nullptr, int pRow=0, int pCol=0, int pHeight=DEFAULT_HEIGHT, int pWidth=DEFAULT_WIDTH, const std::string &pTitle="", cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, eBorderStyle pBorderStyle=eBS_SINGLE_LINE)
 
 cxMenu (const cxMenu &pThatMenu)
 Copy constructor.
 
virtual ~cxMenu ()
 
virtual void append (const std::string &pDisplayText, long pReturnCode, const std::string &pHelpString="", cxMenuItemType pType=cxITEM_NORMAL, bool pResize=false, const std::string &pItemText="")
 Adds a string item to the end of the menu.
 
virtual void appendWithPullRight (const std::string &pDisplayText, cxMenu *pSubMenu, const std::string &pHelpString="", bool pResize=false)
 
virtual void appendWithPopUp (const std::string &pDisplayText, cxMenu *pSubMenu, const std::string &pHelpString="", bool pResize=false)
 
virtual bool remove (unsigned pItemIndex, bool pResize=false, bool pRefresh=false)
 Removes a menu item from the menu. If the item has a submenu,.
 
virtual bool remove (const std::string &pItemText, bool pUseDisplayText=true, bool pResize=false, bool pRefresh=false)
 Removes a menu item from the menu (by display text or alternate.
 
virtual bool removeByReturnCode (long pReturnCode, bool pResize=false, bool pRefresh=false)
 Removes a menu item based on its return code.
 
virtual void removeAllItems (bool pResize=false, bool pRefresh=false)
 Removes all items from the menu.
 
virtual void clear (bool pRefresh=false) override
 Alias for removeAllItems() (this is here to overload the clear()
 
virtual long showModal (bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=true) override
 Shows the menu, waits for input, and returns the menu item's return.
 
virtual bool modalGetsKeypress () const override
 Returns whether or not a call to showModal() will wait for a.
 
virtual void scrollItems (int pScrollAmt, bool pRefresh=false)
 Scrolls the menu item list by a certain amount.
 
virtual void scrollToTop (bool pRefresh=false)
 Scrolls the menu to the top.
 
virtual void scrollToBottom (bool pRefresh=false)
 Scrolls the menu to the bottom.
 
virtual void setTopItem (unsigned pTopItem, bool pRefresh=false)
 Sets the item to appear at the top of the menu (by index).
 
virtual void setTopItem (const std::string &pItemText, bool pRefresh=false)
 Sets the item to appear at the top of the menu (by item text).
 
virtual void setBottomItem (unsigned pItemIndex, bool pRefresh=false)
 Sets the item to appear at the bottom of the menu (by index).
 
virtual bool move (int pNewRow, int pNewCol, bool pRefresh=true) override
 
virtual unsigned numMenuItems () const
 
virtual void resize (int pNewHeight, int pNewWidth, bool pRefresh=false) override
 
virtual void drawMessage () override
 
virtual long show (bool pBringToTop=true, bool pShowSubwindows=true) override
 Shows the menu.
 
virtual void erase (bool pEraseSubwindows=true) override
 
int getSubWinWidth () const
 
int getSubWinHeight () const
 
virtual long getReturnCode () const override
 Returns the return code set by the last call to.
 
virtual long getReturnCode (unsigned pIndex) const
 
virtual long getReturnCode (const std::string &pItemText, bool pUseDisplayText=true) const
 Returns the return code for a menu item (by item text).
 
virtual long getCurrentItemReturnCode () const
 Returns the return code of the currently-highlited item.
 
virtual std::string getItemText (int pIndex, bool pGetDisplayText=true) const
 Returns the text for a menu item.
 
virtual std::string getCurrentItemText (bool pGetDisplayText=true) const
 Returns the text of the current selected menu item. Could.
 
virtual void drawBorder () override
 Draws a border around the menu.
 
void toggleSelectability (unsigned pIndex, bool pSelectable)
 Toggles selectability for an item (by index). Selectability.
 
void toggleSelectability (const std::string &pItemText, bool pSelectable)
 Toggles selectability for an item (by item text).
 
void setClearOnSearch (bool pClearOnSearch)
 Sets whether or not to clear the search text.
 
void setCaseSensitiveSearch (bool pCaseSensitiveSearch)
 Sets whether or not item searching should be case-sensitive.
 
void setSearchKey (int pSearchKey)
 Changes the key to be used for menu item searching (static)
 
void setAltPgUpKey (int pPgUpKey)
 Sets the alternate pageUp key.
 
int getAltPgUpKey () const
 Returns the key that is set as the alternate pageUp key.
 
void setAltPgDownKey (int pPgDownKey)
 Sets the new alternate pageDown key.
 
int getAltPgDownKey () const
 Returns the key that is set as the alternate pageDown key.
 
virtual void setStatus (const std::string &pStatus, bool pRefreshStatus=true) override
 Mutator for the status line text. After this method.
 
void disableCustomStatus (bool pRefreshStatus=true)
 Turns off the custom status text set with setStatus.
 
cxMenuoperator= (const cxMenu &pThatMenu)
 Assignment operator.
 
virtual void refreshMenuItems ()
 Refreshes the list of menu items.
 
virtual bool setItemTextByReturnCode (long pReturnCode, const std::string &pItemText, bool pSetAll=false, bool pRefresh=false)
 Sets the text of an item (by its return code).
 
virtual bool setItemTextByIndex (int pIndex, const std::string &pItemText, bool pRefresh=false)
 Sets the text of an item (by index).
 
virtual void setBorderStyle (eBorderStyle pBorderStyle) override
 Sets the border style.
 
virtual bool itemExists (const std::string &pItemText, bool pUseDisplayText=true) const
 Returns whether or not an item exists in the menu.
 
void setAllowQuit (bool pAllowQuit)
 Sets whether the form should allow the user to quit.
 
bool getAllowQuit () const
 Returns whether the user is able to quit out of the form.
 
void setAllowExit (bool pAllowExit)
 Sets whether the form should allow the user to exit.
 
bool getAllowExit () const
 Returns whether the user is able to exit out of the form.
 
int getIndexByReturnCode (long pReturnCode) const
 Returns the index of a menu item by its return code.
 
std::string getItemTextByReturnCode (long pReturnCode, bool pGetDisplayText=true)
 Returns an item's text by its return code. If there is no.
 
void setLoopStartFunction (const std::shared_ptr< cxFunction > &pFuncPtr)
 Sets a function to be run at the start of each.
 
void setLoopEndFunction (const std::shared_ptr< cxFunction > &pFuncPtr)
 Sets a function to be run at the end of each.
 
virtual bool runLoopStartFunction ()
 Runs the loop start function, if it's set.
 
virtual bool runLoopEndFunction ()
 Runs the loop end function, if it's set.
 
cxMenuItemType getItemType (unsigned pIndex) const
 Returns the type of a menu item (by index), or -1 if the given.
 
cxMenuItemType getItemType (const std::string &pItemText) const
 Returns the type of a menu item (by item text), or -1 if the.
 
virtual void setWrapping (bool pWrap)
 Enables or disables wrapping when trying to scroll beyond.
 
virtual bool getWrapping () const
 Returns whether scroll wrapping is enabled.
 
virtual void setWaitForInputIfEmpty (bool pWaitForInputIfEmpty)
 Toggles whether or not the menu should display a message.
 
virtual bool getWaitForInputIfEmpty () const
 Returns whether or not the menu will display a message.
 
virtual int getCurrentMenuItem () const
 Returns the index of the current menu item.
 
virtual void setCurrentMenuItem (int pItemIndex, bool pRefresh=false)
 Sets the current menu item (by index)
 
void setExitWhenLeaveFirst (bool pExitWhenLeaveFirst)
 Changes the behavior of exiting the input loop when the user.
 
bool getExitWhenLeaveFirst () const
 Returns whether the menu will exit its input loop when the.
 
void setExitWhenLeaveLast (bool pExitWhenLeaveLast)
 Changes the behavior of exiting the input loop when the user.
 
void setExitOnOutsideClick (bool pExitOnOutsideClick)
 When set to true, the menu will exit its input loop whenever a mouse click occurs outside the menu window, regardless of whether the menu has a parent menu or is embedded in a cxPanel. Use this when showing a standalone dropdown that should close on any outside click (e.g., a cxMenuBar dropdown).
 
bool getExitWhenLeaveLast () const
 Returns whether the menu will exit its input loop when the.
 
void setRefreshItemsWhenModal (bool pRefreshItemsWhenModal)
 Sets whether the list of items should be refreshed when the.
 
bool getRefreshItemsWhenModal () const
 Returns whether or not the list of items will be refreshed when.
 
virtual void addAttr (e_WidgetItems pItem, attr_t pAttr) override
 Adds an ncurses attribute to use for one of the items in the.
 
virtual void setAttr (e_WidgetItems pItem, attr_t pAttr) override
 Sets the ncurses attribute to use for one of the items in the.
 
virtual void removeAttr (e_WidgetItems pItem, attr_t pAttr) override
 Removes an ncurses attribute from one of the item lists.
 
virtual void removeAttrs (e_WidgetItems pItem) override
 Removes all attributes for a given window item.
 
virtual void getAttrs (e_WidgetItems pItem, std::set< attr_t > &pAttrs) const override
 Returns the set of ncurses attributes for a given item.
 
virtual void setHotkeyHighlighting (bool pHotkeyHighlighting) override
 Enables/disables the use of hotkey attributes.
 
virtual std::string cxTypeStr () const override
 Returns the name of the cxWidgets class, "cxMenu". This can be.
 
virtual void sortByReturnCode (bool pRefresh=false)
 Sorts the menu items by their return code. Note: If the same.
 
long getHighestReturnCode () const
 Returns the highest return code of the menu items.
 
virtual bool itemWasSelected () const
 Returns whether an item was selected the last time the menu was.
 
bool mouseEvtWasInItemArea (int &pItemIndex) const
 Returns whether the last mouse event occurred in the area where.
 
virtual bool setOnSelectItemFunction (funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pExitAfterRun, bool pRunOnLeaveFunction)
 Sets a function to run when the user selects an item.
 
virtual bool setOnSelectItemFunction (funcPtr2 pFunction, void *p1, void *p2, bool pExitAfterRun, bool pRunOnLeaveFunction)
 Sets a function to run when the user selects an item.
 
virtual bool setOnSelectItemFunction (funcPtr0 pFunction, bool pExitAfterRun, bool pRunOnLeaveFunction)
 Sets a function to run when the user selects an item.
 
std::shared_ptr< cxFunctiongetOnSelectItemFunction () const
 Returns the pointer to the onSelectMenuItem function.
 
- Public Member Functions inherited from cx::cxWindow
 cxWindow (cxWindow *pParentWindow=nullptr, int pRow=0, int pCol=0, int pHeight=DEFAULT_HEIGHT, int pWidth=DEFAULT_WIDTH, const std::string &pTitle="", const std::string &pMessage="", const std::string &pStatus="", eBorderStyle pBorderStyle=eBS_SINGLE_LINE, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Default constructor.
 
 cxWindow (cxWindow *pParentWindow, int pRow, int pCol, const std::string &pTitle, const std::string &pMessage, const std::string &pStatus, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Overloaded constructor.
 
 cxWindow (cxWindow *pParentWindow, const std::string &pTitle, const std::string &pMessage, const std::string &pStatus, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Overloaded constructor - Centers the window in the middle of the screen.
 
 cxWindow (cxWindow *pParentWindow, const std::string &pTitle, const std::string &pMessage, const std::string &pStatus, int pHeight, int pWidth, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Overloaded constructor - Centers the window in the middle of the screen.
 
 cxWindow (cxWindow *pParentWindow, const std::string &pMessage, const std::string &pStatus, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Overloaded constructor - Centers the window in the middle of the screen.
 
 cxWindow (cxWindow *pParentWindow, const std::string &pMessage, const std::string &pStatus, int pHeight, int pWidth, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Overloaded constructor - Centers the window in the middle of the screen.
 
 cxWindow (cxWindow *pParentWindow, const std::string &pMessage, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Overloaded constructor - Centers the window in the middle of the screen.
 
 cxWindow (cxWindow *pParentWindow, eHPosition pHPosition, const std::string &pTitle, const std::string &pMessage, const std::string &pStatus, cxWindow *pExtTitleWindow=nullptr, cxWindow *pExtStatusWindow=nullptr, bool pHotkeyHighlighting=false)
 Overloaded constructor - Lets you specify the horizontal position.
 
 cxWindow (const cxWindow &pThatWindow)
 Copy constructor.
 
virtual ~cxWindow ()
 
virtual void centerHoriz (bool pRefresh=true)
 Centers the window horizontally on the screen.
 
virtual void alignHoriz (eHPosition pPosition, bool pRefresh=true)
 Aligns the window horizontally on the screen.
 
virtual void centerVert (bool pRefresh=true)
 Centers the window vertically on the screen.
 
virtual void alignVert (eVPosition pPosition, bool pRefresh=true)
 Aligns the window vertically on the screen.
 
virtual void center (bool pRefresh=true)
 Centers the window on the screen.
 
virtual std::string getTitle () const
 Accessor for title text - Returns the first string in the.
 
virtual void setTitle (const std::string &pTitle, bool pRefreshTitle=true)
 Setter for the title text - This sets the first string in the.
 
std::string getStatus () const
 Accessor for the status line text.
 
std::string getMessage () const
 Returns the message that appears in the window, concatenating all message lines together.
 
virtual void setMessage (const std::string &pMessage)
 Sets the text that appears within the window.
 
virtual void addMessageLineBelow (const std::string &pLine)
 Adds a line to the message to be displayed in the window,.
 
virtual void addMessageLinesBelow (const std::vector< std::string > &pLines)
 Adds lines to the message below the current message text.
 
virtual void addMessageLinesBelow (const std::list< std::string > &pLines)
 Adds lines to the message below the current message text.
 
virtual void addMessageLinesBelow (const std::deque< std::string > &pLines)
 Adds lines to the message below the current message text.
 
virtual void addMessageLineAbove (const std::string &pLine)
 Adds a line to the message to be displayed in the window,.
 
virtual void addMessageLinesAbove (const std::vector< std::string > &pLines)
 Adds lines to the message above the current message text.
 
virtual void addMessageLinesAbove (const std::list< std::string > &pLines)
 Adds lines to the message above the current message text.
 
virtual void addMessageLinesAbove (const std::deque< std::string > &pLines)
 Adds lines to the message above the current message text.
 
virtual void setMessageLines (const std::vector< std::string > &pLines)
 Sets the message lines in the window.
 
virtual void setMessageLines (const std::list< std::string > &pLines)
 Sets the message lines in the window.
 
virtual void setMessageLines (const std::deque< std::string > &pLines)
 Sets the message lines in the window.
 
virtual void removeMessageLine (unsigned pIndex)
 Removes a line from the text inside the window (by index).
 
virtual void setMessageLine (unsigned pIndex, const std::string &pLine)
 Modifies one of the lines displayed in the window.
 
void setHorizTitleAlignment (eHPosition pHAlignment)
 Sets the horizontal alignment of the title text.
 
eHPosition getHorizTitleAlignment () const
 Accessor for the title text alignment.
 
void setHorizMessageAlignment (eHPosition pHAlignment)
 Sets the horizontal alignment of the message text.
 
eHPosition getHorizMessageAlignment () const
 Accessor for the horizontal message text alignment.
 
void setHorizStatusAlignment (eHPosition pHAlignment)
 Sets the horizontal alignment of the status text.
 
eHPosition getHorizStatusAlignment () const
 Accessor for the horizontal status text alignment.
 
void setVerticalMessageAlignment (eVPosition pVAlignment)
 Sets the vertical alignment of the message text.
 
eVPosition getVerticalMessageAlignment () const
 Accessor for the vertical message text alignment.
 
void setExtTitleWindow (cxWindow *pWindow, bool pRefreshTitle=true)
 Sets an external cxWindow object to be used for the title, rather.
 
cxWindowgetExtTitleWindow () const
 Accessor for the external title window pointer.
 
void setExtStatusWindow (cxWindow *pWindow, bool pRefreshStatus=true)
 Sets an external cxWindow object to be used for status, rather.
 
cxWindowgetExtStatusWindow () const
 Accessor for the external status window pointer.
 
bool isHidden () const
 Returns whether or not the window is hidden.
 
virtual long setFocus (bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=true)
 Alias for showModal()
 
virtual void setFocusColors ()
 Turns on the ncurses attribute A_REVERSE for the window to.
 
virtual void setFocusColors (attr_t pAttr)
 Turns on the ncurses attribute pAttr for the window to.
 
virtual void unSetFocusColors ()
 Disables focus for this window and unhighlights the message.
 
virtual void unSetFocusColors (attr_t pAttr)
 Disables focus for this window and un-highlights the message (using pAttr)
 
virtual void bringToTop (bool pRefresh=true)
 Brings the window to the top.
 
virtual void bringToBottom (bool pRefresh=false)
 Puts the window on the bottom of all other windows.
 
virtual bool isOnTop () const
 Returns whether the window is on top of all other windows.
 
virtual bool isOnBottom () const
 Returns whether the window is on the bottom of all other windows.
 
virtual bool isAbove (const cxWindow &pThatWindow) const
 Returns whether the window is above another window.
 
virtual bool isBelow (const cxWindow &pThatWindow) const
 Returns whether a window is below another window.
 
virtual void hide (bool pHideSubwindows=true)
 Hides the window.
 
virtual void unhide (bool pUnhideSubwindows=true)
 Un-hides the window.
 
void touchWindow ()
 Marks the window's entire content as dirty so that the next.
 
virtual void drawBorder (int pRow, int pCol, int pHeight, int pWidth, bool pTop=true, bool pBottom=true, bool pLeft=true, bool pRight=true)
 Draws the border (based on the border style)
 
virtual void drawBorder (int pHeight, int pWidth)
 Draws a box in the window.
 
virtual int top () const
 Returns the top row of the window.
 
virtual int centerRow () const
 Returns the center row of the window.
 
virtual int bottom () const
 Returns the bottom row of the window.
 
virtual int left () const
 Returns the left column of the window.
 
virtual int centerCol () const
 Returns the center column of the window.
 
virtual int right () const
 Returns the right column of the window.
 
virtual int width (int pWidth)
 Changes the width of the window.
 
virtual int width () const
 Returns the width of the window.
 
virtual int height (int pHeight)
 Changes the height of the window.
 
virtual int height () const
 Returns the height of the window.
 
virtual void getRect (int &pTop, int &pLeft, int &pBottom, int &pRight)
 Returns the coordinates of the rectangle defining the window.
 
virtual bool pointIsInWindow (int pY, int pX) const
 Returns whether a screen location is in the window (including.
 
virtual bool pointIsInTitle (int pY, int pX) const
 Returns whether a screen location is in the title of the window.
 
virtual void getSize (int &pHeight, int &pWidth)
 Returns the height & width of the window.
 
virtual bool moveRelative (int pVerticalOffset, int pHorizOffset, bool pRefresh=true)
 Changes the window's position via vertical & horizontal offsets.
 
unsigned numSubWindows ()
 Returns the number of subwindows in this window.
 
void setSubWinMessage (unsigned pIndex, const std::string &pMessage)
 Sets the message of one of the subwindows (by index).
 
void setSubWinMessage (const std::string &pTitle, const std::string &pMessage)
 Sets the message of one of the subwindows (by title).
 
virtual bool hasFocus () const
 Returns true if window has focus, false otherwise.
 
eBorderStyle getBorderStyle () const
 Returns the border style.
 
bool hasBorder () const
 Does this window have a border?
 
virtual cxWindowgetParent () const
 Returns a pointer to the parent window.
 
void setParent (cxWindow *pNewParent)
 Changes the pointer to the parent window; changes the parent window.
 
virtual void dump (std::string &pResult)
 Returns a string containing all the characters.
 
virtual void showSubwindows (bool pBringToTop=true, bool pShowSubwindows=true)
 Shows the subwindows for the window.
 
cxWindowoperator= (const cxWindow &pThatWindow)
 Assignment operator.
 
virtual void writeText (int pRow, int pCol, const std::string &pText, bool pRefresh=true)
 Writes text on the window. Note that the text is not permanant, so.
 
bool getHotkeyHighlighting () const
 Returns whether hotkey attributes are used when writing the message.
 
virtual bool isEnabled () const
 Returns whether or not the window is enabled.
 
virtual void setEnabled (bool pEnabled)
 Enables or disables the window. If the window is.
 
virtual void setDisableCursorOnShow (bool pDisableCursorOnShow)
 Sets whether the window should disable the cursor.
 
virtual bool getDisableCursorOnShow () const
 Returns whether or not the window will disable.
 
virtual bool getExitOnMouseOutside () const
 Returns whether the window exits its modal input loop when.
 
virtual void setExitOnMouseOutside (bool pExitOnMouseOutside)
 Sets whether the window should exit its modal input loop.
 
virtual int getLastKey () const
 Returns the last key pressed by the user (for showModal(), etc.)
 
virtual void setLastKey (int pLastKey)
 Sets the last keypress.
 
virtual bool lastKeyWasMouseEvt () const
 Returns whether or not the last keypress was a mouse event.
 
virtual void getLastMouseEvtCoords (int &pY, int &pX)
 Returns the coordinates of the last mouse event in the window.
 
virtual bool getChangeColorsOnFocus () const
 Returns whether the window will change.
 
virtual void setChangeColorsOnFocus (bool pChangeColorsOnFocus)
 Sets whether colors should change when focus.
 
virtual void setOnFocusFunction (const std::shared_ptr< cxFunction > &pFunction)
 Sets the window's "on focus" function.
 
virtual void setOnFocusFunction (funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pUseVal=false, bool pExitAfterRun=false)
 Sets the "on focus" function pointer.
 
virtual void setOnFocusFunction (funcPtr2 pFunction, void *p1, void *p2, bool pUseVal=false, bool pExitAfterRun=false)
 Sets the "on focus" function pointer.
 
virtual void setOnFocusFunction (funcPtr0 pFunction, bool pUseVal=false, bool pExitAfterRun=false)
 Sets the "on focus" function pointer.
 
virtual void setOnLeaveFunction (const std::shared_ptr< cxFunction > &pFunction)
 Sets the window's "on leave" function.
 
virtual void setOnLeaveFunction (funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4)
 Sets the "on leave" function pointer.
 
virtual void setOnLeaveFunction (funcPtr2 pFunction, void *p1, void *p2)
 Sets the "on focus" function pointer.
 
virtual void setOnLeaveFunction (funcPtr0 pFunction)
 Sets the "on focus" function pointer.
 
virtual bool runOnFocusFunction (std::string *pFunctionRetval=nullptr)
 Runs the onFocus function, if it's set.
 
virtual bool runOnLeaveFunction (std::string *pFunctionRetval=nullptr)
 Runs the onLeave function, if it's set. However, if the last.
 
virtual void toggleOnFocusFunction (bool pRunOnFocus)
 Sets whether or not the onFocus function should run.
 
virtual void toggleOnLeaveFunction (bool pRunOnLeave)
 Sets whether or not the onLeave function should run.
 
virtual bool onFocusFunctionEnabled () const
 Returns whether or not the onFocus function is set to run.
 
virtual bool onLeaveFunctionEnabled () const
 Returns whether or not the onLeave function is set to run.
 
virtual const std::shared_ptr< cxFunction > & getOnFocusFunction () const
 Accessor for the onFocus function.
 
virtual const std::shared_ptr< cxFunction > & getOnLeaveFunction () const
 Accessor for the onLeave function.
 
virtual bool isModal () const
 Returns whether or not the window is currently.
 
virtual bool setKeyFunction (int pKey, const std::shared_ptr< cxFunction > &pFunction)
 Sets a function to be called when a key is pressed.
 
virtual bool setKeyFunction (int pKey, funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
 Sets a function to be called when a key is pressed.
 
virtual bool setKeyFunction (int pKey, funcPtr2 pFunction, void *p1, void *p2, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
 Sets a function to be called when a key is pressed.
 
virtual bool setKeyFunction (int pKey, funcPtr0 pFunction, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
 Sets a function to be called when a key is pressed. This.
 
virtual void clearKeyFunction (int pKey)
 Removes a function pointer for a keypress so that it will no.
 
virtual void clearKeyFunctionByPtr (funcPtr4 pFunction)
 Removes a keypress function pointer.
 
virtual void clearKeyFunctionByPtr (funcPtr2 pFunction)
 Removes a keypress function pointer.
 
virtual void clearKeyFunctionByPtr (funcPtr0 pFunction)
 Removes a keypress function pointer.
 
virtual void clearKeyFunctions ()
 Clears the list of external functions fired by hotkeys.
 
virtual bool hasKeyFunction (int pKey) const
 Returns whether an external function exists for a keypress.
 
virtual bool setMouseFunction (int pMouseState, const std::shared_ptr< cxFunction > &pFunction)
 Sets a function to be called for a certain mouse state.
 
virtual bool setMouseFunction (int pMouseState, funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
 Sets a function to be called for a certain mouse state.
 
virtual bool setMouseFunction (int pMouseState, funcPtr2 pFunction, void *p1, void *p2, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
 Sets a function to be called for a certain mouse state.
 
virtual bool setMouseFunction (int pMouseState, funcPtr0 pFunction, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
 Sets a function to be called for a certain mouse state. This.
 
virtual void clearMouseFunction (int pMouseState)
 Removes a function pointer for a mouse event so that it will.
 
virtual void clearMouseFunctions ()
 Clears the list of external functions fired by mouse events.
 
virtual bool hasMouseFunction (int pMouseState) const
 Returns whether an external function exists for a mouse event.
 
std::map< int, std::shared_ptr< cxFunction > >::iterator keyFunctions_begin ()
 Returns a begin iterator to the map of cxFunction pointers.
 
std::map< int, std::shared_ptr< cxFunction > >::iterator keyFunctions_end ()
 Returns an end iterator to the map of cxFunction pointers.
 
virtual void getFunctionKeyStrings (std::vector< std::string > &pKeys) const
 Populates a collection of strings representing the keys.
 
virtual void getFunctionKeys (std::vector< int > &pKeys) const
 Populates a collection with integers representing the keys.
 
virtual void setShowSubwinsForward (bool pShowSubwinsForward)
 Toggles the order in which subwindows will be shown.
 
virtual bool getShowSubwinsForward () const
 Returns whether or not the subwindows will be shown.
 
virtual void setShowSelfBeforeSubwins (bool pShowSelfBeforeSubwins)
 Sets whether the window will show itself before.
 
virtual bool getShowSelfBeforeSubwins () const
 Returns whether or not the window will show itself before.
 
virtual bool addTitleString (int pHPos, const std::string &pStr, bool pRefreshTitle=false)
 Adds/sets a string to appear in the title at.
 
virtual std::string getTitleString (int pHPos) const
 Returns the title string set at a given horizontal position.
 
virtual std::map< int, std::string > getTitleStrings () const
 Returns the map of title strings for the window.
 
virtual void getTitleStrings (std::map< int, std::string > &pTitleStrings) const
 Returns the map of title strings for the window (using an.
 
virtual void setTitleStrings (const std::map< int, std::string > &pTitleStrings)
 Sets all the title strings via a map of horizontal.
 
virtual void removeTitleString (int pHPos)
 Removes a title string at a given horizontal position.
 
virtual void removeTitleStrings ()
 Removes all title strings.
 
virtual bool addStatusString (int pHPos, const std::string &pStr, bool pRefreshStatus=false)
 Adds/sets a string to appear in the status line at.
 
virtual std::string getStatusString (int pHPos) const
 Returns the status string set at a given horizontal position.
 
virtual std::map< int, std::string > getStatusStrings () const
 Returns the map of status strings for the window.
 
virtual void getStatusStrings (std::map< int, std::string > &pStatusStrings) const
 Returns the map of status strings for the window (using an.
 
virtual void setStatusStrings (const std::map< int, std::string > &pStatusStrings)
 Sets all the status strings via a map of horizontal.
 
virtual void removeStatusString (int pHPos)
 Removes a status string at a given horizontal position.
 
virtual void removeStatusStrings ()
 Removes all status strings.
 
virtual bool addQuitKey (int pKey, bool pRunOnLeaveFunction=true, bool pOverride=false)
 Adds a key that will cause the window to quit its input loop.
 
virtual void removeQuitKey (int pKey)
 Removes a quit key.
 
virtual void removeQuitKeys ()
 Removes all quit keys.
 
virtual bool addExitKey (int pKey, bool pRunOnLeaveFunction=true, bool pOverride=false)
 Adds a key that will cause the window to quit its input loop.
 
virtual void removeExitKey (int pKey)
 Removes an exit key.
 
virtual void removeExitKeys ()
 Removes all exit keys.
 
virtual bool hasExitKey (int pKey) const
 Returns whether or not a key exists in the.
 
virtual bool hasQuitKey (int pKey) const
 Returns whether or not a key exists in the.
 
virtual void quitNow ()
 This is mainly for deriving classes. This causes the object.
 
virtual void exitNow ()
 This is mainly for deriving classes. It tells the object.
 
virtual void getQuitKeyStrings (std::vector< std::string > &pKeys) const
 Populates a collection of strings representing the keys.
 
virtual std::string getQuitKeyListString () const
 Returns a string containing a comma-separated list of the.
 
virtual void getExitKeyStrings (std::vector< std::string > &pKeys) const
 Populates a collection of strings representing the keys.
 
virtual std::string getExitKeyListString () const
 Returns a string containing a comma-separated list of the.
 
virtual std::map< int, bool > getQuitKeys () const
 Returns the keys that will make the window quit its input.
 
virtual std::map< int, bool > getExitKeys () const
 Returns the keys that will make the window exit is input.
 
void toggleMessage (bool pDrawMessage)
 Sets whether or not to draw the message area (the area within.
 
void toggleTitle (bool pDrawTitle)
 Sets whether or not to draw the title.
 
void toggleStatus (bool pDrawStatus)
 Sets whether or not to draw the status line.
 
bool messageWillDraw () const
 Returns whether the message will draw or not.
 
bool titleWillDraw () const
 Returns whether the title will draw or not.
 
bool statusWillDraw () const
 Returns whether the status line will draw or not.
 
void toggleSpecialChars (bool pDrawSpecialChars)
 Sets whether or not to draw the "special" characters (these are.
 
bool specialCharsWillDraw () const
 Returns whether the "special" characters will be drawn or.
 
virtual void drawTitle ()
 Writes the title line.
 
virtual void drawStatus ()
 Writes the status line.
 
virtual void drawSpecialChars ()
 Writes the set of "special" characters to the window.
 
virtual void setReturnCode (const long &pReturnCode)
 Explicitly sets the member return code for the window.
 
virtual void setMessageColor (e_cxColors pColor)
 Returns the message color.
 
virtual void setTitleColor (e_cxColors pColor)
 Sets the title color.
 
virtual void setStatusColor (e_cxColors pColor)
 Sets the color of the status line at bottom of window.
 
virtual void setBorderColor (e_cxColors pColor)
 Sets the color of the window border.
 
virtual void setColor (e_WidgetItems pItem, e_cxColors pColor)
 Sets the color of one of the window items.
 
virtual bool hasAttr (e_WidgetItems pItem, attr_t pAttr)
 Returns whether an attribute is set for a widget item.
 
bool getLeaveNow () const
 Returns whether or not something told the window to leave now.
 
std::string getName () const
 
virtual void setName (const std::string &pName)
 Sets the name of the window. The name is an alternative means.
 
bool mouseEvtWasInWindow () const
 Returns whether the current mouse information stored in the.
 
virtual bool mouseEvtWasInTitle () const
 Returns whether the current mouse information stored in the.
 
virtual void doMouseBehavior ()
 Triggers the window's mouse event behavior. This method can.
 
virtual void doMouseBehavior (int pMouseY, int pMouseX)
 Triggers the window's mouse event behavior. Also sets the.
 
std::shared_ptr< cxFunctiongetKeyFunction (int pKey) const
 Returns a cxFunction pointer for a key.
 
std::shared_ptr< cxFunction0getKeyFunctionAsFunction0 (int pKey) const
 Returns a cxFunction pointer for a key, casted to a cxFunction0.
 
std::shared_ptr< cxFunction2getKeyFunctionAsFunction2 (int pKey) const
 Returns a cxFunction pointer for a key, casted to a cxFunction2.
 
std::shared_ptr< cxFunction4getKeyFunctionAsFunction4 (int pKey) const
 Returns a cxFunction pointer for a key, casted to a cxFunction4.
 
bool mouseEvtWasButtonEvt () const
 Returns whether or not the mouse event read in mMouse was.
 
bool mouseButton1Pressed () const
 Returns whether or not the first mouse button was pressed.
 
bool mouseButton1Released () const
 Returns whether or not the first mouse button was released.
 
bool mouseButton1Clicked () const
 Returns whether or not the first mouse button was clicked.
 
bool mouseButton1DoubleClicked () const
 Returns whether or not the first mouse button was double-clicked.
 
bool mouseButton2Clicked () const
 Returns whether or not the second mouse button was clicked.
 
bool mouseButton2DoubleClicked () const
 Returns whether or not the second mouse button was double-clicked.
 
bool mouseButton3Clicked () const
 Returns whether or not the second mouse button was clicked.
 
virtual void mouseButton1Click (int pY, int pX)
 Tells the window that mouse button 1 was clicked at a certain.
 
virtual void mouseButton2Click (int pY, int pX)
 Tells the window that mouse button 2 was clicked at a certain.
 
virtual void mouseButton3Click (int pY, int pX)
 Tells the window that mouse button 3 was clicked at a certain.
 
std::string getString (int pRow, int pCol, int pNumber)
 Get the contents of a portion of the window. (for debugging/testing)
 
void info ()
 Display information about a window (for debugging/testing)
 
virtual void toggleBorderTop (bool pToggle)
 Sets whether or not to display the top border.
 
virtual void toggleBorderBottom (bool pToggle)
 Sets whether or not to display the bottom border.
 
virtual void toggleBorderLeft (bool pToggle)
 Sets whether or not to display the left border.
 
virtual void toggleBorderRight (bool pToggle)
 Sets whether or not to display the right border.
 
virtual void addSpecialChar (int pY, int pX, chtype pChar, attr_t pAttr=A_NORMAL)
 Adds a character to be written somewhere in the window. These.
 
virtual void removeSpecialChar (int pY, int pX)
 Removes a character from the set of special characters (by.
 
virtual void clearSpecialChars ()
 Clears the collection of special characters.
 
virtual bool functionExistsForLastMouseState () const
 Returns whether an external function pointer exists for the.
 
int getMouseState () const
 Returns the current mouse state as it was last captured by the.
 
std::string getMouseStateStr () const
 Returns a string version of the current mouse state as it was.
 
virtual e_cxColors getItemColor (e_WidgetItems pItem) const
 Returns the color of one of the items in a window.
 
- Public Member Functions inherited from cx::cxObject
 cxObject ()
 
virtual ~cxObject ()
 
virtual void beep ()
 

Protected Member Functions

void copyCxMenuStuff (const cxMenu *pThatMenu)
 Makes a copy of a cxMenu's member variables.
 
int subWinTop () const
 Returns the top row of the subwindow.
 
int subWinLeft () const
 Returns the left column of the subwindow.
 
long doInputLoop (bool &pRunOnLeaveFunction)
 Handles the input loop and returns the menu item's return.
 
virtual void enableAttrs (WINDOW *pWin, e_WidgetItems pItem) override
 Enables the attributes for one of the m*Attrs sets for an ncurses window.
 
virtual void disableAttrs (WINDOW *pWin, e_WidgetItems pItem) override
 Disables the attributes for one of the m*Attrs sets for an ncurses window.
 
- Protected Member Functions inherited from cx::cxWindow
virtual void reCreatePanel ()
 Creates mPanel (by calling new_panel()), then sets up.
 
void freeWindow ()
 Frees the memory used by the ncurses window and.
 
virtual void init (int pRow, int pCol, int pHeight, int pWidth, const std::string &pTitle, const std::string &pMessage, const std::string &pStatus, cxWindow *pParentWindow=nullptr, bool pResizeVertically=true)
 Initializes the window parameters and sets up the internal.
 
virtual void removeAllSubwindows ()
 Removes all subwindow pointers.
 
virtual void addSubwindow (cxWindow *pSubWindow)
 Adds a subwindow to the window. Subwindows of a.
 
virtual void removeSubWindow (const cxWindow *pSubWindow)
 Removes a window from the subwindow list.
 
virtual void setElementColor (short &pColorPair, attr_t &pElementAttr, e_cxColors pColor)
 Sets the color (and attribute, if necessary) of a color element.
 
virtual void writeWithHighlighting (WINDOW *pWindow, const std::string &pText, const int &pY, const int &pStartX, const int &pEndX, int pNormalTextItem=-1)
 Writes text to an ncurses WINDOW, highlighting any characters.
 
virtual void copyCxWinStuff (const cxWindow *pThatWindow, bool pRecreateWin=true)
 Makes a copy of a cxWindow's member variables.
 
virtual void getRowColBasedOn (cxWindow *pParentWindow, eHPosition pPosition, const std::string &pTitle, const std::string &pStatus, const std::string &pMessage, int &pRow, int &pCol)
 Figures out how to align text based on a title & message.
 
virtual bool handleFunctionForLastKey (bool *pFunctionExists=nullptr, bool *pRunOnLeaveFunction=nullptr)
 Looks for a function tied to the last keypress and.
 
virtual bool handleFunctionForLastMouseState (bool *pFunctionExists=nullptr, bool *pRunOnLeaveFunction=nullptr)
 Looks for a function tied to the last mouse state captured.
 
virtual void draw ()
 Fills the member ncurses window structure with the current.
 
void setKeyFunctions (const cxWindow &pWindow)
 Returns whether or not a mouse event location is within.
 
void setFocusFunctions (const cxWindow &pWindow)
 Re-sets the onFocus and onLeave functions from another.
 
bool parentIsCxPanel () const
 Returns whether or not the parent window, if there is one, is.
 
bool parentIsCxForm () const
 Returns whether or not the parent window, if there is one, is.
 
bool parentIsCxNotebook () const
 Returns whether or not the parent window, if there is one, is.
 
cxWindowPtrContainer::const_iterator subWindows_begin () const
 Returns a const iterator to the first subwindow.
 
cxWindowPtrContainer::const_iterator subWindows_end () const
 Returns a const iterator to the one past the last subwindow.
 
cxWindowPtrContainer::const_reverse_iterator subWindows_rbegin () const
 Returns a const reverse begin iterator for the subwindow collection.
 
cxWindowPtrContainer::const_reverse_iterator subWindows_rend () const
 Returns a const reverse end iterator for the subwindow collection.
 
bool onFocusFunctionIsSet () const
 Returns whether or not the onFocus function is set (if.
 
bool onLeaveFunctionIsSet () const
 Returns whether or not the onLeave function is set (if.
 

Protected Attributes

std::set< attr_t > mMenuSelectionAttrs
 Menu selection attributes.
 
- Protected Attributes inherited from cx::cxWindow
WINDOW * mWindow = nullptr
 Everything in the window is written here; this is an nCurses window structure.
 
messageLineContainer mMessageLines
 Contains the text to be shown inside the window (note: the.
 
std::map< std::pair< int, int >, chtype > mSpecialChars
 Contains "special" characters which are added to the window.
 
std::set< attr_t > mMessageAttrs
 Message attributes.
 
std::set< attr_t > mTitleAttrs
 Title attributes.
 
std::set< attr_t > mStatusAttrs
 Status attributes.
 
std::set< attr_t > mBorderAttrs
 Border attributes.
 
std::set< attr_t > mHotkeyAttrs
 Hotkey attributes.
 
std::map< std::pair< int, int >, attr_t > mSpecialCharAttrs
 Attributes for the "special" characters (which are added to.
 
short mMessageColorPair = eWHITE_BLUE
 
short mTitleColorPair = eGRAY_BLUE
 
short mStatusColorPair = eBROWN_BLUE
 
short mBorderColorPair = eGRAY_BLUE
 
eHPosition mHorizTitleAlignment = eHP_LEFT
 
eHPosition mHorizMessageAlignment = eHP_LEFT
 
eHPosition mHorizStatusAlignment = eHP_LEFT
 
eVPosition mVerticalMessageAlignment = eVP_TOP
 
bool mDrawMessage = true
 
bool mDrawTitle = true
 
bool mDrawStatus = true
 
bool mDrawSpecialChars = true
 
std::shared_ptr< cxFunctionmOnFocusFunction = nullptr
 
std::shared_ptr< cxFunctionmOnLeaveFunction = nullptr
 
bool mIsModal = false
 
bool mLeaveNow = false
 
std::map< int, std::shared_ptr< cxFunction > > mKeyFunctions
 
std::map< int, std::shared_ptr< cxFunction > > mMouseFunctions
 
std::map< int, bool > mQuitKeys
 
std::map< int, bool > mExitKeys
 
bool mHotkeyHighlighting
 

Additional Inherited Members

- Static Public Member Functions inherited from cx::cxObject
static bool UseColors ()
 
static void UseColors (bool useIt)
 
static bool UseBeeps ()
 
static void UseBeeps (bool useIt)
 
- Static Protected Attributes inherited from cx::cxObject
static bool useColors
 Whether or not to use colors.
 
static bool useBeeps
 Whether or not to enable beeping.
 

Detailed Description

Represents a list of items, one of which may be selected.

before the menu goes away. The items are one-line text entries. An item can additionally have a sub-menu associated with it. The shortcut characters for the item can be underlined via an ampersand (&) placed before a character when setting the item text.
Each item in a cxMenu has 2 pieces of text: The text that is displayed, and alternate text. When appending an item to the menu, both can be specified. When retrieving item text from the menu, you can retrieve either the displayed text or the item's alternate text.
By default, the menu does not wrap around when the user scrolls beyond the last or first item; however, this behavior can be changed with a call to enableWrapping().
The user can also search for a menu item - by default, the search key is '/', but this can be changed via a call to setSearchKey(). By default, the previous search text is used again for additional searches but can be changed by the user. If you don't want the form to use the previous search text in additional searches, you can change this behavior with a call to setClearOnSearch(), passing true as the parameter. Also, item searching is not case-sensitive by default, but this can be changed with a call to setCaseSensitiveSearch().
Also, cxMenu supports page scrolling with the pageUp and pageDown keys. In addition, cxMenu also uses alternate keys for doing a pageUp and pageDown, which by default are '.' and ',', respectively. These defaults can be changed via setAltPgUpKey() and setAltPgDownKey().
Note that the search key and the alternate pageUp and pageDown keys are static; therefore, when these keys are changed, they are changed for all instances of cxMenu. setSearchKey(), setAltPgUpKey(), and setAltPgDownKey() are static methods; therefore, they can be called without an instance of cxMenu.

Constructor & Destructor Documentation

◆ cxMenu() [1/2]

cx::cxMenu::cxMenu ( cxWindow pParentWindow = nullptr,
int  pRow = 0,
int  pCol = 0,
int  pHeight = DEFAULT_HEIGHT,
int  pWidth = DEFAULT_WIDTH,
const std::string &  pTitle = "",
cxWindow pExtTitleWindow = nullptr,
cxWindow pExtStatusWindow = nullptr,
eBorderStyle  pBorderStyle = eBS_SINGLE_LINE 
)
explicit

Default constructor

Parameters
pParentWindowPointer to parent window; defaults to nullptr
pRowThe y location of the upper-left corner of menu; defaults to 0
pColthe x location of the upper-left corner of menu; defaults to 0
pHeightThe height of the menu; defaults to DEFAULT_HEIGHT
pWidthThe width of the menu; defaults to DEFAULT_WIDTH
pTitleThe title of the menu; blank by default
pExtTitleWindowA pointer to another cxWindow in which to display the window title.
pExtStatusWindowA pointer to another cxWindow in which to display the status.
pBorderStyleThe type of border to use - can be eBS_SINGLE_LINE for a single-line border or eBS_NOBORDER for no border.

◆ cxMenu() [2/2]

cx::cxMenu::cxMenu ( const cxMenu pThatMenu)

Copy constructor.

Parameters
pThatMenuAnother cxMenu to be copied

References copyCxMenuStuff(), cx::height(), cx::left(), cx::mMenuSelectionAttrs, cx::top(), and cx::width().

◆ ~cxMenu()

cx::cxMenu::~cxMenu ( )
virtual

Destructor

Member Function Documentation

◆ addAttr()

void cx::cxMenu::addAttr ( e_WidgetItems  pItem,
attr_t  pAttr 
)
overridevirtual

Adds an ncurses attribute to use for one of the items in the.

window (see the e_WidgetItems enumeration).

Parameters
pItemThe item to add the attribute for (see the e_WidgetItems enumeration).
pAttrThe ncurses atribute to add.

Reimplemented from cx::cxWindow.

References cx::cxWindow::addAttr(), cx::eBORDER, cx::eDATA, cx::eDATA_EDITABLE, cx::eDATA_READONLY, cx::eHOTKEY, cx::eLABEL, cx::eMENU_SELECTION, cx::eMESSAGE, cx::eSTATUS, cx::eTITLE, and mMenuSelectionAttrs.

◆ append()

void cx::cxMenu::append ( const std::string &  pDisplayText,
long  pReturnCode,
const std::string &  pHelpString = "",
cxMenuItemType  pType = cxITEM_NORMAL,
bool  pResize = false,
const std::string &  pItemText = "" 
)
virtual

Adds a string item to the end of the menu.

Parameters
pDisplayTextThe text to display for the item
pReturnCodeThe integer code that the the menu should return when show() exits
pHelpStringA string to be displayed in the statusbar of the main window when the item is highlighted
pTypeThe type of menu item - This defines whether it's a regular menu item (cxITEM_NORMAL), a pop-up menu, etc. (see the cxMenuItemType enumeration in cxMenuItemType.h)
pResizeIf true, the menu will resize itself so that it can show all the items. Defaults to false.
pItemTextAlternate text to use for the item

References cx::cxITEM_NORMAL, cx::cxITEM_SUBMENU, cx::cxITEM_UNSELECTABLE, cx::eBS_NOBORDER, cx::cxWindow::getBorderStyle(), cx::cxWindow::height(), cx::cxWindow::mMessageLines, resize(), and cx::cxWindow::width().

Referenced by cx::cxComboBox::appendToMenu(), appendWithPopUp(), appendWithPullRight(), attributesSetter(), changeMenuItemText(), cxFormAppendPair(), cxMenuAltItemText(), cxMenuAssignment(), cxMenuFocusFunctions(), cxMenuItemHotkeysOffMenu(), cxMenuMiscTests(), cxMenuMouseFunctionTest(), cxMenuNoMoreSelectableItemsWhileModal(), cxMenuNoQuit(), cxMenuResize(), cxMenuScrolling(), cxMenuWithDuplicateHotkeys(), cxMenuWithMultipleItemHotkeys(), demoPanels(), doMenu(), externalStatusWindow(), externalTitleWindow(), formWithMenu(), menuItemWithMultipleHotkeys(), SpreadsheetApp::run(), sortByReturnCode(), testMenu1(), and unselectableMenuItem().

◆ appendWithPopUp()

void cx::cxMenu::appendWithPopUp ( const std::string &  pDisplayText,
cxMenu pSubMenu,
const std::string &  pHelpString = "",
bool  pResize = false 
)
virtual

Adds an item with a pop-up submenu

Parameters
pDisplayTextThe text to display for the item
pSubMenuA pointer to the submenu to display
pHelpStringA string to be displayed in the statusbar of the main window when the item is highlighted
pResizeIf true, the menu will resize itself so that it can show all the items.

References append(), cx::cxITEM_POPUPMENU, and cx::cxWindow::mMessageLines.

◆ appendWithPullRight()

void cx::cxMenu::appendWithPullRight ( const std::string &  pDisplayText,
cxMenu pSubMenu,
const std::string &  pHelpString = "",
bool  pResize = false 
)
virtual

Adds an item with a pull-right submenu

Parameters
pDisplayTextThe text to display for the item
pSubMenuA pointer to the submenu to display
pHelpStringA string to be displayed in the statusbar of the main window when the item is highlighted
pResizeIf true, the menu will resize itself so that it can show all the items.

References append(), cx::cxITEM_SUBMENU, and cx::cxWindow::mMessageLines.

Referenced by cxMenuItemHotkeysOffMenu(), cxMenuScrolling(), doMenu(), and testMenu1().

◆ clear()

void cx::cxMenu::clear ( bool  pRefresh = false)
overridevirtual

Alias for removeAllItems() (this is here to overload the clear()

inherited from cxWindow). Does not resize the menu, and does

not bring it to the top.

Parameters
pRefreshWhether or not to refresh the menu (defaults to false)

Reimplemented from cx::cxWindow.

References removeAllItems().

◆ copyCxMenuStuff()

void cx::cxMenu::copyCxMenuStuff ( const cxMenu pThatMenu)
protected

Makes a copy of a cxMenu's member variables.

Parameters
pThatMenuA pointer to another cxMenu whose members to copy

References cx::cxWindow::copyCxWinStuff(), cx::cxWindow::getHotkeyHighlighting(), mMenuSelectionAttrs, and setHotkeyHighlighting().

Referenced by cxMenu(), and operator=().

◆ cxTypeStr()

string cx::cxMenu::cxTypeStr ( ) const
overridevirtual

Returns the name of the cxWidgets class, "cxMenu". This can be.

used to determine the type of cxWidgets object that deriving

classes derive from in applications.

Returns
The name of the cxWidgets class ("cxMenu").

Reimplemented from cx::cxWindow.

◆ disableAttrs()

void cx::cxMenu::disableAttrs ( WINDOW *  pWin,
e_WidgetItems  pItem 
)
overrideprotectedvirtual

Disables the attributes for one of the m*Attrs sets for an ncurses window.

If the m*Attrs collection is empty, this will disable the cxBase attributes

instead.

Parameters
pWinA pointer to the ncurses window for which to disable the attributes (will usually be mWindow).
pItemThe item type to retrieve attributes for - see the e_cxWidgetItems enumeration (defined in cxWidgetItems.h).

Reimplemented from cx::cxWindow.

References cx::cxWindow::disableAttrs(), cx::disableAttrs(), cx::eBORDER, cx::eDATA, cx::eDATA_EDITABLE, cx::eDATA_READONLY, cx::eHOTKEY, cx::eLABEL, cx::eMENU_SELECTION, cx::eMESSAGE, cx::eSTATUS, cx::eTITLE, and mMenuSelectionAttrs.

Referenced by drawBorder(), and drawMessage().

◆ disableCustomStatus()

void cx::cxMenu::disableCustomStatus ( bool  pRefreshStatus = true)

Turns off the custom status text set with setStatus.

After a call to this function, the current status

text will be cleared, and the form will go back to

using the help messages from the inputs in the status line.

Parameters
pRefreshStatusWhether or not to refresh the status area (defaults to true)

References cx::cxWindow::setStatus().

◆ doInputLoop()

long cx::cxMenu::doInputLoop ( bool &  pRunOnLeaveFunction)
protected

◆ drawBorder()

void cx::cxMenu::drawBorder ( )
overridevirtual

◆ drawMessage()

void cx::cxMenu::drawMessage ( )
overridevirtual

◆ enableAttrs()

void cx::cxMenu::enableAttrs ( WINDOW *  pWin,
e_WidgetItems  pItem 
)
overrideprotectedvirtual

Enables the attributes for one of the m*Attrs sets for an ncurses window.

If the m*Attrs collection is empty, this will enable the cxBase attributes

instead.

Parameters
pWinA pointer to the ncurses window for which to enable the attributes (will usually be mWindow).
pItemThe item type to retrieve attributes for - see the e_cxWidgetItems enumeration (defined in cxWidgetItems.h).

Reimplemented from cx::cxWindow.

References cx::eBORDER, cx::eDATA, cx::eDATA_EDITABLE, cx::eDATA_READONLY, cx::eHOTKEY, cx::eLABEL, cx::eMENU_SELECTION, cx::eMESSAGE, cx::cxWindow::enableAttrs(), cx::enableAttrs(), cx::eSTATUS, cx::eTITLE, and mMenuSelectionAttrs.

Referenced by drawBorder(), and drawMessage().

◆ erase()

void cx::cxMenu::erase ( bool  pEraseSubwindows = true)
overridevirtual

Erases the window

Reimplemented from cx::cxWindow.

References cx::cxWindow::erase().

Referenced by cx::cxComboBox::erase(), and remove().

◆ getAllowExit()

bool cx::cxMenu::getAllowExit ( ) const

Returns whether the user is able to exit out of the form.

Returns
Whether or not the use is able to exit out of the form

◆ getAllowQuit()

bool cx::cxMenu::getAllowQuit ( ) const

Returns whether the user is able to quit out of the form.

Returns
Whether or not the use is able to quit out of the form

◆ getAltPgDownKey()

int cx::cxMenu::getAltPgDownKey ( ) const

Returns the key that is set as the alternate pageDown key.

Returns
The key that is set as the alternate pageDown key

◆ getAltPgUpKey()

int cx::cxMenu::getAltPgUpKey ( ) const

Returns the key that is set as the alternate pageUp key.

Returns
The key that is set as the alternate pageUp key

◆ getAttrs()

void cx::cxMenu::getAttrs ( e_WidgetItems  pItem,
std::set< attr_t > &  pAttrs 
) const
overridevirtual

Returns the set of ncurses attributes for a given item.

Parameters
pItemThe item to retrieve attributes for (see the e_WidgetItems enumeration).
pAttrsThis will contain the attributes for the item.

Reimplemented from cx::cxWindow.

References cx::eBORDER, cx::eDATA, cx::eDATA_EDITABLE, cx::eDATA_READONLY, cx::eHOTKEY, cx::eLABEL, cx::eMENU_SELECTION, cx::eMESSAGE, cx::eSTATUS, cx::eTITLE, cx::cxWindow::getAttrs(), and mMenuSelectionAttrs.

◆ getCurrentItemReturnCode()

long cx::cxMenu::getCurrentItemReturnCode ( ) const
virtual

Returns the return code of the currently-highlited item.

Returns
The return code of the currently-highlighted item.

References getCurrentMenuItem(), and getReturnCode().

Referenced by doInputLoop().

◆ getCurrentItemText()

string cx::cxMenu::getCurrentItemText ( bool  pGetDisplayText = true) const
virtual

Returns the text of the current selected menu item. Could.

return a blank string if there is no current selected menu

item.

Parameters
pGetDisplayTextIf true (default), then this will return the text displayed on the menu for the item. If false, then this will return the alternate text for the item.
Returns
The text of the current selected menu item, or a blank string if there is no current selected menu item.

References getCurrentMenuItem(), getItemText(), and numMenuItems().

Referenced by cxMenuAltItemText().

◆ getCurrentMenuItem()

int cx::cxMenu::getCurrentMenuItem ( ) const
virtual

Returns the index of the current menu item.

Returns
The index of the current menu item

Referenced by getCurrentItemReturnCode(), getCurrentItemText(), and sortByReturnCode().

◆ getExitWhenLeaveFirst()

bool cx::cxMenu::getExitWhenLeaveFirst ( ) const

Returns whether the menu will exit its input loop when the.

user presses the up arrow on the first menu item.

Returns
Whether or not the menu will exit its input loop when the user prsses the up arrow on the first menu item.

◆ getExitWhenLeaveLast()

bool cx::cxMenu::getExitWhenLeaveLast ( ) const

Returns whether the menu will exit its input loop when the.

user presses the down arrow on the last menu item.

Returns
Whether or not the menu will exit its input loop when the user prsses the down arrow on the last menu item.

◆ getHighestReturnCode()

long cx::cxMenu::getHighestReturnCode ( ) const

Returns the highest return code of the menu items.

Returns
The highest return code of the menu items

◆ getIndexByReturnCode()

int cx::cxMenu::getIndexByReturnCode ( long  pReturnCode) const

Returns the index of a menu item by its return code.

Parameters
pReturnCodeThe return code of the menu item
Returns
The index of the item, or -1 if it's not found.

Referenced by getItemTextByReturnCode(), itemWasSelected(), and sortByReturnCode().

◆ getItemText()

string cx::cxMenu::getItemText ( int  pIndex,
bool  pGetDisplayText = true 
) const
virtual

Returns the text for a menu item.

Parameters
pIndexThe index of the menu item
pGetDisplayTextIf true (default), then this will return the text displayed on the menu for the item. If false, then this will return the alternate text for the item.
Returns
The text at the specified index, or a blank string if the index is out of bounds.

References cx::cxWindow::mMessageLines.

Referenced by cxMenuAltItemText(), getCurrentItemText(), cx::cxComboBox::getItemText(), getItemTextByReturnCode(), and sortByReturnCode().

◆ getItemTextByReturnCode()

string cx::cxMenu::getItemTextByReturnCode ( long  pReturnCode,
bool  pGetDisplayText = true 
)

Returns an item's text by its return code. If there is no.

item with the given return code, a blank string is returned.

Parameters
pReturnCodeThe return code to look for
pGetDisplayTextIf true (default), then this will return the text displayed on the menu for the item. If false, then this will return the alternate text for the item.
Returns
The item text for the given return code, or a blank string if there is no item with the given return code.

References getIndexByReturnCode(), and getItemText().

Referenced by cxMenuAltItemText(), and cxMenuMiscTests().

◆ getItemType() [1/2]

cxMenuItemType cx::cxMenu::getItemType ( const std::string &  pItemText) const

Returns the type of a menu item (by item text), or -1 if the.

given item textis not valid.

Parameters
pItemTextThe text of the menu item
Returns
The type of the menu item

◆ getItemType() [2/2]

cxMenuItemType cx::cxMenu::getItemType ( unsigned  pIndex) const

Returns the type of a menu item (by index), or -1 if the given.

index is not valid.

Parameters
pIndexThe index of the menu item
Returns
The type of the menu item

◆ getOnSelectItemFunction()

shared_ptr< cxFunction > cx::cxMenu::getOnSelectItemFunction ( ) const

Returns the pointer to the onSelectMenuItem function.

Returns
The pointer to the onSelectMenuItem function

◆ getRefreshItemsWhenModal()

bool cx::cxMenu::getRefreshItemsWhenModal ( ) const

Returns whether or not the list of items will be refreshed when.

the menu is shown modally.

Returns
true if the list of items will be refreshed when the menu is shown modally, or false if not.

◆ getReturnCode() [1/3]

long cx::cxMenu::getReturnCode ( ) const
overridevirtual

Returns the return code set by the last call to.

showModal() based on the user's interaction. The

return code is set to cxID_EXIT by default before

the first call to showModal().

Returns
The return code set by the last call to showModal()

Reimplemented from cx::cxWindow.

References cx::cxWindow::getReturnCode().

Referenced by cxMenuAltItemText(), doInputLoop(), getCurrentItemReturnCode(), itemWasSelected(), showModal(), and sortByReturnCode().

◆ getReturnCode() [2/3]

virtual long cx::cxMenu::getReturnCode ( const std::string &  pItemText,
bool  pUseDisplayText = true 
) const
virtual

Returns the return code for a menu item (by item text).

Parameters
pItemTextThe text of the menu item whose return code to get
pUseDisplayTextIf true (default), then this will return the text displayed on the menu for the item. If false, then this will return the alternate text for the item.
Returns
The item's return code (if index is within range). If no item with the given text is not found, -1 is returned.

◆ getReturnCode() [3/3]

long cx::cxMenu::getReturnCode ( unsigned  pIndex) const
virtual

Returns the return code for a menu item at a specified index.

Parameters
pIndexThe index of the item whose return code to get
Returns
The item's return code (if index is within range). If the index is not within range, -1 is returned.

◆ getSubWinHeight()

int cx::cxMenu::getSubWinHeight ( ) const

Returns the height of the submenu

Returns
The height of the submenu

◆ getSubWinWidth()

int cx::cxMenu::getSubWinWidth ( ) const

Returns the width of the submenu

Returns
The width of the submenu

◆ getWaitForInputIfEmpty()

bool cx::cxMenu::getWaitForInputIfEmpty ( ) const
virtual

Returns whether or not the menu will display a message.

and wait for user input if there are no menu items.

Returns
Whether or not the menu will display a message and wait for user input if there are no menu items.

◆ getWrapping()

bool cx::cxMenu::getWrapping ( ) const
virtual

Returns whether scroll wrapping is enabled.

Returns
Whether or not scroll wrapping is enabled

◆ itemExists()

bool cx::cxMenu::itemExists ( const std::string &  pItemText,
bool  pUseDisplayText = true 
) const
virtual

Returns whether or not an item exists in the menu.

Parameters
pItemTextThe text of the item for which to search
pUseDisplayTextIf true (default), then pItemText specifies the text displayed in the menu. If false, then pItemText specifies the alternate item text.
Returns
Whether or not the item exists in the menu

References cx::cxWindow::mMessageLines, and cx::stringWithoutHotkeyChars().

Referenced by cxMenuAltItemText().

◆ itemWasSelected()

bool cx::cxMenu::itemWasSelected ( ) const
virtual

Returns whether an item was selected the last time the menu was.

shown (either from the menu or from a submenu).

Returns
true if an item was selected, or false if not.

References cx::cxID_EXIT, cx::cxID_QUIT, cx::cxITEM_POPUPMENU, cx::cxITEM_SUBMENU, ENTER, getIndexByReturnCode(), cx::cxWindow::getLastKey(), getReturnCode(), cx::cxWindow::lastKeyWasMouseEvt(), cx::cxWindow::mouseButton1Clicked(), cx::cxWindow::mouseButton1DoubleClicked(), and cx::cxWindow::mouseEvtWasInWindow().

Referenced by testMenu1().

◆ modalGetsKeypress()

bool cx::cxMenu::modalGetsKeypress ( ) const
overridevirtual

Returns whether or not a call to showModal() will wait for a.

keypress from the user. A cxmenu will wait for a keypress if

it is enabled and it has at least 1 selectable menu item. If

it is enabled but does not have any selectable items, it may

or may not wait for a keypress, depending on whether

setWaitForInputIfEmpty() has been called.

Returns
Whether or not a call to showModal() will wait for a keypress from the user.

Reimplemented from cx::cxWindow.

References cx::cxWindow::isEnabled(), and cx::cxWindow::mMessageLines.

◆ mouseEvtWasInItemArea()

bool cx::cxMenu::mouseEvtWasInItemArea ( int &  pItemIndex) const

Returns whether the last mouse event occurred in the area where.

the menu items are listed. If so, then this will also get the

index of the menu item that is located there. If there is no

item at that location or if the mouse event didn't occur in

the item, the index this gets will be -1.

Note that the return code of the item can be retrieved using

the version of getReturnCode() that takes an item index.

Parameters
pItemIndex(OUT) This will be set to the index of the item that was clicked on, or -1 if the mouse event didn't occur at one of the menu items.
Returns
true if the last mouse event occurred in the item area, or false if not.

References cx::cxWindow::bottom(), cx::eBS_NOBORDER, cx::cxWindow::getBorderStyle(), cx::cxWindow::height(), cx::cxWindow::left(), cx::cxWindow::mouseEvtWasInWindow(), numMenuItems(), cx::cxWindow::right(), and cx::cxWindow::top().

Referenced by doInputLoop().

◆ move()

bool cx::cxMenu::move ( int  pNewRow,
int  pNewCol,
bool  pRefresh = true 
)
overridevirtual

Changes the window's position (based on a new upper-left corner).

Parameters
pNewRowThe new topmost row of the form
pNewColThe new leftmost column of the form
pRefreshWhether or not to refresh the window (defaults to true)
Returns
Whether or not the move succeeded or not (true/false)

Reimplemented from cx::cxWindow.

References cx::cxWindow::move(), and show().

Referenced by demoPanels(), cx::cxComboBox::move(), and cx::cxComboBox::toggleMenu().

◆ numMenuItems()

unsigned cx::cxMenu::numMenuItems ( ) const
virtual

◆ operator=()

cxMenu & cx::cxMenu::operator= ( const cxMenu pThatMenu)

Assignment operator.

Parameters
pThatMenuAnother cxMenu to be copied
Returns
The current cxMenu

References copyCxMenuStuff().

◆ refreshMenuItems()

void cx::cxMenu::refreshMenuItems ( )
virtual

Refreshes the list of menu items.

References drawMessage().

Referenced by showModal().

◆ remove() [1/2]

virtual bool cx::cxMenu::remove ( const std::string &  pItemText,
bool  pUseDisplayText = true,
bool  pResize = false,
bool  pRefresh = false 
)
virtual

Removes a menu item from the menu (by display text or alternate.

item text). If the item has a submenu, the submenu will NOT be

deleted and may be reused.

Parameters
pItemTextThe text of the item to delete
pUseDisplayTextIf true (default), then pItemText specifies the text displayed in the menu. If false, then pItemText specifies the alternate item text.
pResizeIf true, the menu will resize itself accordingly
pRefreshWhether or not to refresh the menu (defaults to false)
Returns
True if the item was deleted; false if not.

◆ remove() [2/2]

bool cx::cxMenu::remove ( unsigned  pItemIndex,
bool  pResize = false,
bool  pRefresh = false 
)
virtual

Removes a menu item from the menu. If the item has a submenu,.

the submenu will NOT be deleted and may be reused.

Parameters
pItemIndexIndex of the item to delete
pResizeIf true, the menu will resize itself accordingly
pRefreshWhether or not to refresh the menu (defaults to false)
Returns
True if the item was deleted; false if not.

References cx::eBS_NOBORDER, erase(), cx::cxWindow::getBorderStyle(), cx::cxWindow::mMessageLines, numMenuItems(), resize(), setTopItem(), and cx::cxWindow::width().

Referenced by cxMenuAltItemText(), removeByReturnCode(), and cx::cxComboBox::removeFromMenu().

◆ removeAllItems()

void cx::cxMenu::removeAllItems ( bool  pResize = false,
bool  pRefresh = false 
)
virtual

Removes all items from the menu.

Parameters
pResizeWhether or not to resize the menu when done (defaults to false).
pRefreshWhether or not to refresh the menu (defaults to false)

References cx::eBS_NOBORDER, cx::cxWindow::getBorderStyle(), cx::cxWindow::mMessageLines, resize(), show(), and cx::cxWindow::width().

Referenced by clear(), clearAllMenuItems(), cx::cxComboBox::removeAllItemsFromMenu(), and sortByReturnCode().

◆ removeAttr()

void cx::cxMenu::removeAttr ( e_WidgetItems  pItem,
attr_t  pAttr 
)
overridevirtual

Removes an ncurses attribute from one of the item lists.

Parameters
pItemThe item to remove the attribute for (see the e_WidgetItems enumeration).
pAttrThe ncurses attribute to remove

Reimplemented from cx::cxWindow.

References cx::eBORDER, cx::eDATA, cx::eDATA_EDITABLE, cx::eDATA_READONLY, cx::eHOTKEY, cx::eLABEL, cx::eMENU_SELECTION, cx::eMESSAGE, cx::eSTATUS, cx::eTITLE, mMenuSelectionAttrs, and cx::cxWindow::removeAttr().

◆ removeAttrs()

void cx::cxMenu::removeAttrs ( e_WidgetItems  pItem)
overridevirtual

Removes all attributes for a given window item.

Parameters
pItemThe item to remove attributes for (see the e_WidgetItems enumeration).

Reimplemented from cx::cxWindow.

References cx::eBORDER, cx::eDATA, cx::eDATA_EDITABLE, cx::eDATA_READONLY, cx::eHOTKEY, cx::eLABEL, cx::eMENU_SELECTION, cx::eMESSAGE, cx::eSTATUS, cx::eTITLE, mMenuSelectionAttrs, and cx::cxWindow::removeAttrs().

◆ removeByReturnCode()

bool cx::cxMenu::removeByReturnCode ( long  pReturnCode,
bool  pResize = false,
bool  pRefresh = false 
)
virtual

Removes a menu item based on its return code.

Parameters
pReturnCodeThe return code of the menu item
pResizeIf true, the menu will resize itself accordingly
pRefreshWhether or not to refresh the menu (defaults to false)
Returns
True of the item was removed, or false if not.

References remove().

◆ resize()

void cx::cxMenu::resize ( int  pNewHeight,
int  pNewWidth,
bool  pRefresh = false 
)
overridevirtual

◆ runLoopEndFunction()

bool cx::cxMenu::runLoopEndFunction ( )
virtual

Runs the loop end function, if it's set.

Returns
The value of the loop end function's mExitAfterRun, or false if the loop start end isn't set.

Referenced by doInputLoop().

◆ runLoopStartFunction()

bool cx::cxMenu::runLoopStartFunction ( )
virtual

Runs the loop start function, if it's set.

Returns
The value of the loop start function's mExitAfterRun, or false if the loop start function isn't set.

Referenced by doInputLoop().

◆ scrollItems()

void cx::cxMenu::scrollItems ( int  pScrollAmt,
bool  pRefresh = false 
)
virtual

Scrolls the menu item list by a certain amount.

Parameters
pScrollAmtThe amount by which to scroll. If this is positive, the menu will scroll down (the items will move upwards), and if this is negative, the menu will scroll up.
pRefreshWhether or not to refresh the menu (defaults to false).

References cx::cxWindow::bottom(), cx::cxWindow::height(), cx::cxWindow::mMessageLines, and show().

Referenced by doInputLoop(), and setBottomItem().

◆ scrollToBottom()

void cx::cxMenu::scrollToBottom ( bool  pRefresh = false)
virtual

Scrolls the menu to the bottom.

Parameters
pRefreshWhether or not to refresh the menu (defaults to false).

References numMenuItems(), and setBottomItem().

◆ scrollToTop()

void cx::cxMenu::scrollToTop ( bool  pRefresh = false)
virtual

Scrolls the menu to the top.

Parameters
pRefreshWhether or not to refresh the menu (defaults to false).

References setTopItem().

◆ setAllowExit()

void cx::cxMenu::setAllowExit ( bool  pAllowExit)

Sets whether the form should allow the user to exit.

Parameters
pAllowExitIf true, the user will be able to exit out of the form; if false, the user won't be able to exit.

◆ setAllowQuit()

void cx::cxMenu::setAllowQuit ( bool  pAllowQuit)

Sets whether the form should allow the user to quit.

Parameters
pAllowQuitIf true, the user will be able to quit out of the form; if false, the user won't be able to quit.

Referenced by cxMenuNoQuit().

◆ setAltPgDownKey()

void cx::cxMenu::setAltPgDownKey ( int  pPgDownKey)

Sets the new alternate pageDown key.

Parameters
pPgDownKeyThe new alternate pageDown key

◆ setAltPgUpKey()

void cx::cxMenu::setAltPgUpKey ( int  pPgUpKey)

Sets the alternate pageUp key.

Parameters
pPgUpKeyThe new alternate pageUp key

◆ setAttr()

void cx::cxMenu::setAttr ( e_WidgetItems  pItem,
attr_t  pAttr 
)
overridevirtual

Sets the ncurses attribute to use for one of the items in the.

window (see the e_WidgetItems enumeration). Clears the current

set of attributes for the item and inserts the given attribute

into the set.

Parameters
pItemThe item to apply the attribute for (see the e_WidgetItems enumeration).
pAttrThe ncurses atribute to apply.

Reimplemented from cx::cxWindow.

References cx::eBORDER, cx::eDATA, cx::eDATA_EDITABLE, cx::eDATA_READONLY, cx::eHOTKEY, cx::eLABEL, cx::eMENU_SELECTION, cx::eMESSAGE, cx::eSTATUS, cx::eTITLE, mMenuSelectionAttrs, and cx::cxWindow::setAttr().

◆ setBorderStyle()

void cx::cxMenu::setBorderStyle ( eBorderStyle  pBorderStyle)
overridevirtual

Sets the border style.

Parameters
pBorderStyleA eBorderStyle enumeration value (see cxBorderStyles.h)

Reimplemented from cx::cxWindow.

References cx::cxWindow::getBorderStyle(), and cx::cxWindow::setBorderStyle().

◆ setBottomItem()

void cx::cxMenu::setBottomItem ( unsigned  pItemIndex,
bool  pRefresh = false 
)
virtual

Sets the item to appear at the bottom of the menu (by index).

Parameters
pItemIndexThe index of the item to appear at the bottom of the menu
pRefreshWhether or not to refresh the menu (defaults to false).

References cx::cxWindow::mMessageLines, scrollItems(), and setTopItem().

Referenced by scrollToBottom().

◆ setCaseSensitiveSearch()

void cx::cxMenu::setCaseSensitiveSearch ( bool  pCaseSensitiveSearch)

Sets whether or not item searching should be case-sensitive.

Parameters
pCaseSensitiveSearchIf true, item searching will be case-sensitive. If false, item searching will not be case-sensitive.

◆ setClearOnSearch()

void cx::cxMenu::setClearOnSearch ( bool  pClearOnSearch)

Sets whether or not to clear the search text.

upon showing the search input box.

Parameters
pClearOnSearchIf true, the previous search text will not be used in new searches. If false, the previous search text will be used in new searches (but can still be changed by the user).

◆ setCurrentMenuItem()

void cx::cxMenu::setCurrentMenuItem ( int  pItemIndex,
bool  pRefresh = false 
)
virtual

Sets the current menu item (by index)

Parameters
pItemIndexThe index of the new menu item
pRefreshWhether or not to refresh the menu after setting the menu item (defaults to false)

References cx::cxWindow::mMessageLines, setTopItem(), and show().

Referenced by doInputLoop(), and sortByReturnCode().

◆ setExitOnOutsideClick()

void cx::cxMenu::setExitOnOutsideClick ( bool  pExitOnOutsideClick)

When set to true, the menu will exit its input loop whenever a mouse click occurs outside the menu window, regardless of whether the menu has a parent menu or is embedded in a cxPanel. Use this when showing a standalone dropdown that should close on any outside click (e.g., a cxMenuBar dropdown).

Parameters
pExitOnOutsideClickIf true, exit the input loop on any outside mouse click.

◆ setExitWhenLeaveFirst()

void cx::cxMenu::setExitWhenLeaveFirst ( bool  pExitWhenLeaveFirst)

Changes the behavior of exiting the input loop when the user.

presses the up arrow on the first menu item.

Parameters
pExitWhenLeaveFirstIf true, then when the user presses the up arrow on the first menu item, the menu will exit its input loop.

◆ setExitWhenLeaveLast()

void cx::cxMenu::setExitWhenLeaveLast ( bool  pExitWhenLeaveLast)

Changes the behavior of exiting the input loop when the user.

presses the down arrow on the last menu item.

Parameters
pExitWhenLeaveFirstIf true, then when the user presses the down arrow on the last menu item, the menu will exit its input loop.

◆ setHotkeyHighlighting()

void cx::cxMenu::setHotkeyHighlighting ( bool  pHotkeyHighlighting)
overridevirtual

Enables/disables the use of hotkey attributes.

If true, wherever there's an ampersand (&) before a character in

the message, that character will have hotkey attributes

applied to it.

Parameters
pHotkeyHighlightingWhether or not to use hotkey attributes.

Reimplemented from cx::cxWindow.

References cx::cxWindow::mHotkeyHighlighting.

Referenced by copyCxMenuStuff().

◆ setItemTextByIndex()

bool cx::cxMenu::setItemTextByIndex ( int  pIndex,
const std::string &  pItemText,
bool  pRefresh = false 
)
virtual

Sets the text of an item (by index).

Parameters
pIndexThe index of the item
pItemTextThe new text for the item
pRefreshWhether or not to refresh the menu (defaults to false).
Returns
If true, the set was successful; if false, the set was unsuccessful (i.e., if pIndex is an invalid index, etc.)

References cx::cxWindow::mMessageLines.

Referenced by changeMenuItemText().

◆ setItemTextByReturnCode()

bool cx::cxMenu::setItemTextByReturnCode ( long  pReturnCode,
const std::string &  pItemText,
bool  pSetAll = false,
bool  pRefresh = false 
)
virtual

Sets the text of an item (by its return code).

Parameters
pReturnCodeThe return code of the item
pItemTextThe new text for the item
pSetAllIf true, will change the text of all items with the given return code (defaults to false).
pRefreshWhether or not to refresh the menu (defaults to false).
Returns
If true, the set was successful; if false, the set was unsuccessful (i.e., if there are no items with the given return code, etc.)

References cx::cxWindow::isModal(), and cx::cxWindow::mMessageLines.

Referenced by changeMenuItemText().

◆ setLoopEndFunction()

void cx::cxMenu::setLoopEndFunction ( const std::shared_ptr< cxFunction > &  pFuncPtr)

Sets a function to be run at the end of each.

cycle through the input loop. The return value

of the function is not used.

Parameters
pFuncPtrA pointer to the function

Referenced by cxMenuFocusFunctions().

◆ setLoopStartFunction()

void cx::cxMenu::setLoopStartFunction ( const std::shared_ptr< cxFunction > &  pFuncPtr)

Sets a function to be run at the start of each.

input loop. The return value of the function is

not used.

Parameters
pFuncPtrA pointer to the function

Referenced by cxMenuFocusFunctions().

◆ setOnSelectItemFunction() [1/3]

bool cx::cxMenu::setOnSelectItemFunction ( funcPtr0  pFunction,
bool  pExitAfterRun,
bool  pRunOnLeaveFunction 
)
virtual

Sets a function to run when the user selects an item.

Parameters
pFunctionA pointer to the function to run. Must have this signature: string func()
pExitAfterRunWhether or not the menu should exit after the function runs
pRunOnLeaveFunctionWhether or not the function should run its onLeave function if it exits after the function runs
Returns
true if the function was set, or false if not

◆ setOnSelectItemFunction() [2/3]

bool cx::cxMenu::setOnSelectItemFunction ( funcPtr2  pFunction,
void *  p1,
void *  p2,
bool  pExitAfterRun,
bool  pRunOnLeaveFunction 
)
virtual

Sets a function to run when the user selects an item.

Parameters
pFunctionA pointer to the function to run. Must have this signature: string func(void*, void*)
p1A pointer to the first parameter to pass to the function
p2A pointer to the second parameter to pass to the function
pExitAfterRunWhether or not the menu should exit after the function runs
pRunOnLeaveFunctionWhether or not the function should run its onLeave function if it exits after the function runs
Returns
true if the function was set, or false if not

◆ setOnSelectItemFunction() [3/3]

bool cx::cxMenu::setOnSelectItemFunction ( funcPtr4  pFunction,
void *  p1,
void *  p2,
void *  p3,
void *  p4,
bool  pExitAfterRun,
bool  pRunOnLeaveFunction 
)
virtual

Sets a function to run when the user selects an item.

Parameters
pFunctionA pointer to the function to run. Must have this signature: string func(void*, void*, void*, void*)
p1A pointer to the first parameter to pass to the function
p2A pointer to the second parameter to pass to the function
p3A pointer to the 3rd parameter to pass to the function
p4A pointer to the 4th parameter to pass to the function
pExitAfterRunWhether or not the menu should exit after the function runs
pRunOnLeaveFunctionWhether or not the function should run its onLeave function if it exits after the function runs
Returns
true if the function was set, or false if not

◆ setRefreshItemsWhenModal()

void cx::cxMenu::setRefreshItemsWhenModal ( bool  pRefreshItemsWhenModal)

Sets whether the list of items should be refreshed when the.

menu is shown modally.

Parameters
pRefreshItemsWhenModalWhether or not the list of htems should be refreshed when the menu is shown modally

◆ setSearchKey()

void cx::cxMenu::setSearchKey ( int  pSearchKey)

Changes the key to be used for menu item searching (static)

Parameters
pSearchKeyThe new key to be used for searching

◆ setStatus()

void cx::cxMenu::setStatus ( const std::string &  pStatus,
bool  pRefreshStatus = true 
)
overridevirtual

Mutator for the status line text. After this method.

is called, the status provided with this method will

be used instead of the menu item help messages.

Parameters
pStatusThe new status message for window
pRefreshStatusWhether or not to refresh the status area (defaults to true)

Reimplemented from cx::cxWindow.

References cx::cxWindow::setStatus().

Referenced by externalStatusWindow(), and externalTitleWindow().

◆ setTopItem() [1/2]

virtual void cx::cxMenu::setTopItem ( const std::string &  pItemText,
bool  pRefresh = false 
)
virtual

Sets the item to appear at the top of the menu (by item text).

Parameters
pItemtextThe text of the item
pRefreshWhether or not to refresh the menu (defaults to false).

◆ setTopItem() [2/2]

void cx::cxMenu::setTopItem ( unsigned  pTopItem,
bool  pRefresh = false 
)
virtual

Sets the item to appear at the top of the menu (by index).

Parameters
pTopItemThe index of the item to appear at the top of the menu
pRefreshWhether or not to refresh the menu (defaults to false).

References drawMessage(), and cx::cxWindow::mMessageLines.

Referenced by cxMenuScrolling(), remove(), scrollToTop(), setBottomItem(), and setCurrentMenuItem().

◆ setWaitForInputIfEmpty()

void cx::cxMenu::setWaitForInputIfEmpty ( bool  pWaitForInputIfEmpty)
virtual

Toggles whether or not the menu should display a message.

and wait for user input if there are no menu items. This

is the default behavior.

Parameters
pWaitForInputIfEmptyWhether or not to display a message and wait for user input if there are no menu items.

◆ setWrapping()

void cx::cxMenu::setWrapping ( bool  pWrap)
virtual

Enables or disables wrapping when trying to scroll beyond.

the last or first item.

Parameters
pWrapWhether or not to enable wrapping

Referenced by doMenu().

◆ show()

long cx::cxMenu::show ( bool  pBringToTop = true,
bool  pShowSubwindows = true 
)
overridevirtual

Shows the menu.

Parameters
pBringToTopWhether or not to bring the window to the top. Defaults to true.
pShowSubwindowsWhether or not to show sub-windows also. Defaults to true.
Returns
This method returns a long to support overriding in derived classes that might need to return a value. For cxWindow, cxID_EXIT is always returned.

Reimplemented from cx::cxWindow.

References cx::cxFIRST_AVAIL_RETURN_CODE, cx::cxWindow::hide(), cx::cxWindow::isEnabled(), and cx::cxWindow::show().

Referenced by cx::cxComboBox::appendToMenu(), demoPanels(), move(), removeAllItems(), resize(), scrollItems(), setCurrentMenuItem(), cx::cxComboBox::showMenu(), and showModal().

◆ showModal()

long cx::cxMenu::showModal ( bool  pShowSelf = true,
bool  pBringToTop = true,
bool  pShowSubwindows = true 
)
overridevirtual

Shows the menu, waits for input, and returns the menu item's return.

code. Could also return cxID_QUIT if the user presses ESC.

Parameters
pShowSelfWhether or not to show the window before running the input loop. Defaults to true.
pBringToTopWhether or not to bring the window to the top. Defaults to false.
pShowSubwindowsWhether or not to show sub-windows also. Defaults to true.
Returns
The return code associated with the item selected (passed in with the append() function for the item). Could also return cxID_QUIT if the user presses ESC.

Reimplemented from cx::cxWindow.

References cx::cxID_EXIT, doInputLoop(), cx::cxWindow::getLeaveNow(), getReturnCode(), cx::cxWindow::isEnabled(), cx::cxWindow::mIsModal, refreshMenuItems(), cx::cxWindow::runOnFocusFunction(), cx::cxWindow::runOnLeaveFunction(), cx::cxWindow::setReturnCode(), and show().

Referenced by attributesSetter(), changeMenuItemText(), cxFormAppendPair(), cxMenuAltItemText(), cxMenuAssignment(), cxMenuFocusFunctions(), cxMenuItemHotkeysOffMenu(), cxMenuMouseFunctionTest(), cxMenuNoMoreSelectableItemsWhileModal(), cxMenuNoQuit(), cxMenuResize(), cxMenuScrolling(), cx::cxMenuShowModal(), cxMenuWithDuplicateHotkeys(), cxMenuWithMultipleItemHotkeys(), demoPanels(), doMenu(), externalStatusWindow(), externalTitleWindow(), formWithMenu(), menuItemWithMultipleHotkeys(), testMenu1(), and unselectableMenuItem().

◆ sortByReturnCode()

void cx::cxMenu::sortByReturnCode ( bool  pRefresh = false)
virtual

Sorts the menu items by their return code. Note: If the same.

return code exists for more than 1 item, then other attributes

for those menu items (i.e., a sub-menu, unselectability, help

text, etc.) will be duplicated too. Use with care!

Parameters
pRefreshWhether or not to refresh the menu. Defaults to false.

References append(), drawMessage(), getCurrentMenuItem(), getIndexByReturnCode(), getItemText(), getReturnCode(), cx::cxWindow::mMessageLines, numMenuItems(), removeAllItems(), and setCurrentMenuItem().

◆ subWinLeft()

int cx::cxMenu::subWinLeft ( ) const
protected

Returns the left column of the subwindow.

Returns
The left column of the subwindow

◆ subWinTop()

int cx::cxMenu::subWinTop ( ) const
protected

Returns the top row of the subwindow.

Returns
The top row of the subwindow

◆ toggleSelectability() [1/2]

void cx::cxMenu::toggleSelectability ( const std::string &  pItemText,
bool  pSelectable 
)

Toggles selectability for an item (by item text).

Selectability is currently not dealt with when

showing a cxMenu.

Parameters
pItemTextThe text of the item.
pSelectableIf true, the item will be selectable. If true, the item will be selectable. If false, the item will not be selectable.

◆ toggleSelectability() [2/2]

void cx::cxMenu::toggleSelectability ( unsigned  pIndex,
bool  pSelectable 
)

Toggles selectability for an item (by index). Selectability.

is currently not dealt with when showing a cxMenu.

Parameters
pIndexThe index of the item
pSelectableIf true, the item will be selectable. If true, the item will be selectable. If false, the item will not be selectable.

References cx::cxWindow::mMessageLines.

Referenced by allMenuItemsUnselectable(), and unselectableMenuItem().

Member Data Documentation

◆ mMenuSelectionAttrs

std::set<attr_t> cx::cxMenu::mMenuSelectionAttrs
protected

The documentation for this class was generated from the following files: