cxWidgets 1.0
cxMenu.h
Go to the documentation of this file.
1// Copyright (c) 2026 E. Oulashin
2#ifndef __CXMENU_H__
3#define __CXMENU_H__
4
5// Copyright (c) 2005-2007 Michael H. Kinney
6//
7// This represents a pop-up (or pull-down) list of items,
8// one of which may be selected before the menu goes away.
9// The items are text, with the shortcut letter underlined.
10
11#include "cxWindow.h"
12#include "cxMenuItemType.h"
13#include "cxFunction.h"
14
15#include <string>
16#include <map>
17#include <set>
18#include <vector>
19#include <memory>
20
21namespace cx {
22
23#define DEFAULT_CXMENU_SEARCH_KEY '/' // Default search key
24#define DEFAULT_CXMENU_ALT_PGUP_KEY '.' // Default alternate PgUp key
25#define DEFAULT_CXMENU_ALT_PGDOWN_KEY ',' // Default alternate PgDown key
26
61class cxMenu : public cxWindow
62{
63 public:
82 explicit cxMenu(cxWindow *pParentWindow = nullptr, int pRow = 0, int pCol = 0,
83 int pHeight = DEFAULT_HEIGHT, int pWidth = DEFAULT_WIDTH,
84 const std::string& pTitle = "", cxWindow *pExtTitleWindow = nullptr,
85 cxWindow *pExtStatusWindow = nullptr,
86 eBorderStyle pBorderStyle = eBS_SINGLE_LINE);
87
93 cxMenu(const cxMenu& pThatMenu);
94
98 virtual ~cxMenu();
99
114 virtual void append(const std::string& pDisplayText, long pReturnCode,
115 const std::string& pHelpString = "",
117 bool pResize = false, const std::string& pItemText = "");
118
127 virtual void appendWithPullRight(const std::string& pDisplayText, cxMenu *pSubMenu,
128 const std::string& pHelpString = "",
129 bool pResize = false);
130
139 virtual void appendWithPopUp(const std::string& pDisplayText, cxMenu *pSubMenu,
140 const std::string& pHelpString = "", bool pResize = false);
141
152 virtual bool remove(unsigned pItemIndex, bool pResize = false,
153 bool pRefresh = false);
154
169 virtual bool remove(const std::string& pItemText, bool pUseDisplayText = true,
170 bool pResize = false, bool pRefresh = false);
171
181 virtual bool removeByReturnCode(long pReturnCode, bool pResize = false,
182 bool pRefresh = false);
183
190 virtual void removeAllItems(bool pResize = false, bool pRefresh = false);
191
199 virtual void clear(bool pRefresh = false) override;
200
216 virtual long showModal(bool pShowSelf = true, bool pBringToTop = true,
217 bool pShowSubwindows = true) override;
218
230 virtual bool modalGetsKeypress() const override;
231
240 virtual void scrollItems(int pScrollAmt, bool pRefresh = false);
241
247 virtual void scrollToTop(bool pRefresh = false);
248
254 virtual void scrollToBottom(bool pRefresh = false);
255
262 virtual void setTopItem(unsigned pTopItem, bool pRefresh = false);
263
270 virtual void setTopItem(const std::string& pItemText, bool pRefresh = false);
271
278 virtual void setBottomItem(unsigned pItemIndex, bool pRefresh = false);
279
288 virtual bool move(int pNewRow, int pNewCol, bool pRefresh = true) override;
289
294 virtual unsigned numMenuItems() const;
295
303 virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh = false) override;
304
308 virtual void drawMessage() override;
309
320 virtual long show(bool pBringToTop = true, bool pShowSubwindows = true) override;
321
325 virtual void erase(bool pEraseSubwindows = true) override;
326
331 int getSubWinWidth() const;
332
337 int getSubWinHeight() const;
338
347 virtual long getReturnCode() const override;
348
355 virtual long getReturnCode(unsigned pIndex) const;
356
368 virtual long getReturnCode(const std::string& pItemText, bool pUseDisplayText = true) const;
369
374 virtual long getCurrentItemReturnCode() const;
375
387 virtual std::string getItemText(int pIndex, bool pGetDisplayText = true) const;
388
401 virtual std::string getCurrentItemText(bool pGetDisplayText = true) const;
402
406 virtual void drawBorder() override;
407
417 void toggleSelectability(unsigned pIndex, bool pSelectable);
418
429 void toggleSelectability(const std::string& pItemText, bool pSelectable);
430
439 void setClearOnSearch(bool pClearOnSearch);
440
447 void setCaseSensitiveSearch(bool pCaseSensitiveSearch);
448
454 void setSearchKey(int pSearchKey);
455
461 void setAltPgUpKey(int pPgUpKey);
462
468 int getAltPgUpKey() const;
469
475 void setAltPgDownKey(int pPgDownKey);
476
482 int getAltPgDownKey() const;
483
492 virtual void setStatus(const std::string& pStatus, bool pRefreshStatus = true) override;
493
503 void disableCustomStatus(bool pRefreshStatus = true);
504
512 cxMenu& operator =(const cxMenu& pThatMenu);
513
517 virtual void refreshMenuItems();
518
531 virtual bool setItemTextByReturnCode(long pReturnCode, const std::string& pItemText,
532 bool pSetAll = false, bool pRefresh = false);
533
544 virtual bool setItemTextByIndex(int pIndex, const std::string& pItemText,
545 bool pRefresh = false);
546
552 virtual void setBorderStyle(eBorderStyle pBorderStyle) override;
553
564 virtual bool itemExists(const std::string& pItemText, bool pUseDisplayText = true) const;
565
572 void setAllowQuit(bool pAllowQuit);
573
579 bool getAllowQuit() const;
580
587 void setAllowExit(bool pAllowExit);
588
594 bool getAllowExit() const;
595
603 int getIndexByReturnCode(long pReturnCode) const;
604
617 std::string getItemTextByReturnCode(long pReturnCode, bool pGetDisplayText = true);
618
626 void setLoopStartFunction(const std::shared_ptr<cxFunction>& pFuncPtr);
627
635 void setLoopEndFunction(const std::shared_ptr<cxFunction>& pFuncPtr);
636
643 virtual bool runLoopStartFunction();
644
651 virtual bool runLoopEndFunction();
652
661 cxMenuItemType getItemType(unsigned pIndex) const;
662
671 cxMenuItemType getItemType(const std::string& pItemText) const;
672
679 virtual void setWrapping(bool pWrap);
680
686 virtual bool getWrapping() const;
687
696 virtual void setWaitForInputIfEmpty(bool pWaitForInputIfEmpty);
697
705 virtual bool getWaitForInputIfEmpty() const;
706
712 virtual int getCurrentMenuItem() const;
713
721 virtual void setCurrentMenuItem(int pItemIndex, bool pRefresh = false);
722
730 void setExitWhenLeaveFirst(bool pExitWhenLeaveFirst);
731
739 bool getExitWhenLeaveFirst() const;
740
748 void setExitWhenLeaveLast(bool pExitWhenLeaveLast);
749
760 void setExitOnOutsideClick(bool pExitOnOutsideClick);
761
769 bool getExitWhenLeaveLast() const;
770
778 void setRefreshItemsWhenModal(bool pRefreshItemsWhenModal);
779
787 bool getRefreshItemsWhenModal() const;
788
797 virtual void addAttr(e_WidgetItems pItem, attr_t pAttr) override;
798
809 virtual void setAttr(e_WidgetItems pItem, attr_t pAttr) override;
810
818 virtual void removeAttr(e_WidgetItems pItem, attr_t pAttr) override;
819
826 virtual void removeAttrs(e_WidgetItems pItem) override;
827
835 virtual void getAttrs(e_WidgetItems pItem, std::set<attr_t>& pAttrs) const override;
836
845 virtual void setHotkeyHighlighting(bool pHotkeyHighlighting) override;
846
854 virtual std::string cxTypeStr() const override;
855
865 virtual void sortByReturnCode(bool pRefresh = false);
866
872 long getHighestReturnCode() const;
873
880 virtual bool itemWasSelected() const;
881
898 bool mouseEvtWasInItemArea(int& pItemIndex) const;
899
916 virtual bool setOnSelectItemFunction(funcPtr4 pFunction, void *p1,
917 void *p2, void *p3, void *p4,
918 bool pExitAfterRun,
919 bool pRunOnLeaveFunction);
920
935 virtual bool setOnSelectItemFunction(funcPtr2 pFunction, void *p1,
936 void *p2, bool pExitAfterRun,
937 bool pRunOnLeaveFunction);
938
951 virtual bool setOnSelectItemFunction(funcPtr0 pFunction,
952 bool pExitAfterRun,
953 bool pRunOnLeaveFunction);
954
960 std::shared_ptr<cxFunction> getOnSelectItemFunction() const;
961
962 protected:
966 std::set<attr_t> mMenuSelectionAttrs;
967
973 void copyCxMenuStuff(const cxMenu* pThatMenu);
974
980 int subWinTop() const;
981
987 int subWinLeft() const;
988
1000 long doInputLoop(bool& pRunOnLeaveFunction);
1001
1012 virtual void enableAttrs(WINDOW *pWin, e_WidgetItems pItem) override;
1013
1024 virtual void disableAttrs(WINDOW *pWin, e_WidgetItems pItem) override;
1025
1026 private:
1027 WINDOW *mSubWindow = nullptr; // For scrolling
1028 int mSubWinHeight; // Height of the subwindow
1029 int mSubWinWidth; // Width of the subwindow
1030 int mCurrentMenuItem = 0; // Keeps track of the currently highlighted item
1031 int mTopMenuItem = 0; // The index of the topmost menu item shown
1032 int mAltPgUpKey = DEFAULT_CXMENU_ALT_PGUP_KEY; // Alternate key for doing a pageUp
1033 int mAltPgDownKey = DEFAULT_CXMENU_ALT_PGDOWN_KEY; // Alternate key for doing a pageDown
1034 int mSearchKey = DEFAULT_CXMENU_SEARCH_KEY; // Key to use for item searching
1035 std::string mSearchText; // For item searching
1036 std::string mLastSearchText; // For item searching
1037 bool mClearOnSearch = false; // Whether or not to clear the search text
1038 bool mCaseSensitiveSearch = false; // Whether or not searches are case-sensitive
1039 // mCustomStatus will be true if we're using custom
1040 // status text (not the help text for the menu items)
1041 bool mCustomStatus = false;
1042 bool mAllowQuit = true; // Whether or not to allow the user to quit
1043 bool mAllowExit = true; // Whether or not to allow the user to exit
1044 bool mSelectableItemExists = false; // Whether or not a selectable item exists
1045 bool mWrap = true; // Whether or not to wrap around when scrolling
1046 bool mWaitForInputIfEmpty = true; // Whether or not to get input in showModal()
1047 // if there are no menu items
1048 std::vector<long> mReturnCodes; // Return codes for the menu items
1049 std::vector<std::string> mHelpStrings; // Help strings for the menu items
1050 std::vector<cxMenuItemType> mItemTypes; // Stores the type of each menu item
1051 std::vector<std::string> mAltItemText; // Alternate text for each item
1052 // mSubMenus stores submenus for menu items. The keys to this
1053 // map are the indexes in mMessageLines that the submenus belong
1054 // to.
1055 std::map<int, cxMenu*> mSubMenus;
1056 std::set<unsigned> mUnselectableItems; // Contains indexes of unselectable items
1057
1058 // Functions to be run at various points in the input loop
1059 std::shared_ptr<cxFunction> mLoopStartFunction; // At the start of each input loop iteration
1060 std::shared_ptr<cxFunction> mLoopEndFunction; // At the end of each input loop iteration
1061
1062 // mOnSelectItemFunction is a function that can be fired when the user
1063 // selects an item.
1064 std::shared_ptr<cxFunction> mOnSelectItemFunction;
1065
1066 // mItemHotkeys keeps track of which keys are mapped to which menu items.
1067 std::multimap<char, int> mItemHotkeys;
1068 // If there is a hotkey that goes to more than 1 menu item, we
1069 // want the user to be able to continue pressing the hotkey to
1070 // go to the next item, rather than automatically selecting the
1071 // item, which is the default behavior. mHotkeyIndex keeps
1072 // track of the "index" into mItemHotkeys of the current element with
1073 // the hotkey that should be checked when the user presses a
1074 // hotkey.
1075 unsigned int mItemHotkeyIndex = 0;
1076 // Keeps track of the last hotkey that was pressed If different,
1077 // mItemHotkeyIndex will need to be reset to 0)
1078 int mLastItemHotkey = NOKEY;
1079 // mExitWhenLeaveFirst and mExitWhenLeaveLast control whether the menu
1080 // will exit the input loop when the user is scrolling through the menu
1081 // items and leaves the first or last menu item, respectively.
1082 bool mExitWhenLeaveFirst = false;
1083 bool mExitWhenLeaveLast = false;
1084 // mRefreshItemsWhenModal controls whether or not the menu items will
1085 // be refreshed when showModal() is called.
1086 bool mRefreshItemsWhenModal = false;
1087 // mNumParentMenus is incremented when a cxMenu is added to another menu
1088 // as a pull-right or pop-up menu. It is decremented when the menu is
1089 // removed.
1090 int mNumParentMenus = 0;
1091 // mExitOnOutsideClick: when true, any mouse click outside the menu
1092 // window will close the menu, even without a parent menu/panel.
1093 bool mExitOnOutsideClick = false;
1094 // mLastInputWasMouseEvent will be set true if the last input
1095 // was a mouse event in the input loop.
1096 bool mLastInputWasMouseEvent = false;
1097
1098 // Returns the index of the bottommost item to show in the subwindow.
1099 // Note: If there are less items than will fill the menu, this returns
1100 // the index of the last item.
1101 inline int getBottomItemIndex();
1102
1103 // Shows the submenu for the current menu item and returns the
1104 // return code returned by the submenu. Returns -1 if the
1105 // current menu item isn't a submenu type.
1106 inline long doSubmenu();
1107
1108 // Writes a menu item line (from mMessageLines) to the subwindow.
1109 // Checks for hotkeys (ampersands), and pads with spaces on the
1110 // right so it fills the entire row in the subwindow.
1111 // pItemIndex: The index of the item (in mMessageLines) to write
1112 // pSubWinRow: The row in the subwindow to write on
1113 // pRefreshSubwindow: Whether or not to refresh the subwindow
1114 // pHighlight: Whether or not to highlight the item
1115 void drawMenuItem(int pItemIndex, int pSubWinRow, bool pRefreshSubwindow,
1116 bool pHighlight = false);
1117
1118 // Scans a string for a hotkey and adds it hotkey to mItemHotkeys, if the
1119 // string contains one.
1120 void addHotKey(const std::string& pItemText);
1121
1122 // Makes sure this window is exactly the size needed to
1123 // surround the menu items.
1124 //void fitToItems();
1125
1126 // Copies the current menu item's help string to the
1127 // status string, and optionally updates the status.
1128 inline void useHelpAsStatus(bool pRefreshStatus = false);
1129
1130 // Goes through the menu items and resizes their text
1131 // to make sure they're all exactly the width of the inside of
1132 // this window.
1133 void fitItemsToWidth();
1134
1135 // Makes sure mCurrentItem is a selectable menu item.
1136 // Parameters:
1137 // pForward: If true, go downward. If false, go upward.
1138 // pBringToTop: Whether or not to bring the item to the top
1139 void goToSelectableItem(bool pForward, bool pBringToTop);
1140
1141 // Handles item searching
1142 void doSearch();
1143
1144 // Scrolls up one menu item (helper for doInputLoop()).
1145 //
1146 // Parameters:
1147 // pContinueOn (INOUT): This is the continueOn boolean that is used
1148 // in the input loop.
1149 void scrollUpOne(bool& pContinueOn);
1150
1151 // Scrolls down one menu item (helper for doInputLoop()).
1152 //
1153 // Parameters:
1154 // pContinueOn (INOUT): This is the continueOn boolean that is used
1155 // in the input loop.
1156 void scrollDownOne(bool& pContinueOn);
1157
1158 // Scrolls up one page
1159 inline void doPgUp();
1160
1161 // Scrolls down one page
1162 inline void doPgDown();
1163
1164 // Re-creates the subwindow
1165 inline void reCreateSubWindow();
1166
1167 // Frees the memory used by the subwindow
1168 inline void freeSubWindow();
1169
1170 // Updates mSelectableItemExists. Returns the value of
1171 // mSelectableItemExists (to support recursive calls).
1172 bool lookForSelectableItem();
1173
1174 // For scrolling - Goes to the first menu item
1175 void doHome();
1176
1177 // For scrolling - Goes to the last menu item
1178 void doEnd();
1179
1180 // Returns a return code for the currently-selected menu item. For use
1181 // in the input loop when the user presses enter or tab.
1182 // Parameters:
1183 // pLastKey: The last key pressed by the user
1184 // pContinueOn: This variable gets set to whether the input loop
1185 // should continue on.
1186 long getCurrentItemReturnCode(const int& pLastKey, bool& pContinueOn);
1187
1188 // Returns the index of the first selectable item. Returns -1 if there
1189 // are no selectable items.
1190 int firstSelectableItem() const;
1191
1192 // Returns the index of the last selectable item. Returns -1 if there
1193 // are no selectable items.
1194 int lastSelectableItem() const;
1195
1196 // Makes an item highlighted. Also uses its help as the status, etc.
1197 //
1198 // Parameters:
1199 // pItemIndex: The index of the item to highlight
1200 void highlightItem(int pItemIndex);
1201
1202 // Frees the memory used by mOnSelectItemFunction and sets it to nullptr.
1203 void freeOnSelectItemFunction();
1204
1205 // Runs the function for when the user selects an item, if one is set.
1206 //
1207 // Parameters:
1208 // pExitAfterRun (OUT): This will store whether or not the menu should
1209 // exit after the function runs.
1210 // pRunOnLeaveFunction (OUT): This will store whether or not the onLeave
1211 // function should run.
1212 void runOnSelectItemFunction(bool& pExitAfterRun,
1213 bool& pRunOnLeaveFunction);
1214
1215 // This function is used when copying another cxMenu. It checks the
1216 // parameters of the event functions (i.e., mOnSelectItemFunction), and
1217 // if any of the parameters of the other menu's event functions point
1218 // to the other menu, they will be changed to point to this one.
1219 //
1220 // Parameters:
1221 // pMenu: Another cxMenu being copied
1222 void checkEventFunctionPointers(const cxMenu& pMenu);
1223};
1224
1225} // namespace cx
1226
1227#endif
Represents a list of items, one of which may be selected.
Definition cxMenu.h:62
virtual bool remove(unsigned pItemIndex, bool pResize=false, bool pRefresh=false)
Removes a menu item from the menu. If the item has a submenu,.
Definition cxMenu.cpp:242
virtual std::string getCurrentItemText(bool pGetDisplayText=true) const
Returns the text of the current selected menu item. Could.
Definition cxMenu.cpp:971
void setExitOnOutsideClick(bool pExitOnOutsideClick)
When set to true, the menu will exit its input loop whenever a mouse click occurs outside the menu wi...
Definition cxMenu.cpp:1445
virtual void setWaitForInputIfEmpty(bool pWaitForInputIfEmpty)
Toggles whether or not the menu should display a message.
Definition cxMenu.cpp:1390
int getIndexByReturnCode(long pReturnCode) const
Returns the index of a menu item by its return code.
Definition cxMenu.cpp:1279
int getSubWinHeight() const
Definition cxMenu.cpp:885
long getHighestReturnCode() const
Returns the highest return code of the menu items.
Definition cxMenu.cpp:1762
virtual void clear(bool pRefresh=false) override
Alias for removeAllItems() (this is here to overload the clear()
Definition cxMenu.cpp:418
cxMenu & operator=(const cxMenu &pThatMenu)
Assignment operator.
Definition cxMenu.cpp:1095
virtual ~cxMenu()
Definition cxMenu.cpp:127
virtual void setBorderStyle(eBorderStyle pBorderStyle) override
Sets the border style.
Definition cxMenu.cpp:1213
bool getAllowExit() const
Returns whether the user is able to exit out of the form.
Definition cxMenu.cpp:1274
virtual bool runLoopEndFunction()
Runs the loop end function, if it's set.
Definition cxMenu.cpp:1336
void setAltPgDownKey(int pPgDownKey)
Sets the new alternate pageDown key.
Definition cxMenu.cpp:1072
virtual void setStatus(const std::string &pStatus, bool pRefreshStatus=true) override
Mutator for the status line text. After this method.
Definition cxMenu.cpp:1082
virtual long getReturnCode(const std::string &pItemText, bool pUseDisplayText=true) const
Returns the return code for a menu item (by item text).
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 getAttrs(e_WidgetItems pItem, std::set< attr_t > &pAttrs) const override
Returns the set of ncurses attributes for a given item.
Definition cxMenu.cpp:1620
void disableCustomStatus(bool pRefreshStatus=true)
Turns off the custom status text set with setStatus.
Definition cxMenu.cpp:1088
virtual void setCurrentMenuItem(int pItemIndex, bool pRefresh=false)
Sets the current menu item (by index)
Definition cxMenu.cpp:1405
void setLoopStartFunction(const std::shared_ptr< cxFunction > &pFuncPtr)
Sets a function to be run at the start of each.
Definition cxMenu.cpp:1313
bool getRefreshItemsWhenModal() const
Returns whether or not the list of items will be refreshed when.
Definition cxMenu.cpp:1455
void setAltPgUpKey(int pPgUpKey)
Sets the alternate pageUp key.
Definition cxMenu.cpp:1062
virtual void addAttr(e_WidgetItems pItem, attr_t pAttr) override
Adds an ncurses attribute to use for one of the items in the.
Definition cxMenu.cpp:1460
bool getAllowQuit() const
Returns whether the user is able to quit out of the form.
Definition cxMenu.cpp:1264
virtual bool getWaitForInputIfEmpty() const
Returns whether or not the menu will display a message.
Definition cxMenu.cpp:1395
virtual void setHotkeyHighlighting(bool pHotkeyHighlighting) override
Enables/disables the use of hotkey attributes.
Definition cxMenu.cpp:1652
cxMenuItemType getItemType(const std::string &pItemText) const
Returns the type of a menu item (by item text), or -1 if the.
void toggleSelectability(const std::string &pItemText, bool pSelectable)
Toggles selectability for an item (by item text).
virtual void appendWithPullRight(const std::string &pDisplayText, cxMenu *pSubMenu, const std::string &pHelpString="", bool pResize=false)
Definition cxMenu.cpp:214
virtual void setWrapping(bool pWrap)
Enables or disables wrapping when trying to scroll beyond.
Definition cxMenu.cpp:1380
cxMenuItemType getItemType(unsigned pIndex) const
Returns the type of a menu item (by index), or -1 if the given.
Definition cxMenu.cpp:1349
virtual void removeAllItems(bool pResize=false, bool pRefresh=false)
Removes all items from the menu.
Definition cxMenu.cpp:378
int subWinTop() const
Returns the top row of the subwindow.
Definition cxMenu.cpp:1990
void copyCxMenuStuff(const cxMenu *pThatMenu)
Makes a copy of a cxMenu's member variables.
Definition cxMenu.cpp:1937
void setAllowQuit(bool pAllowQuit)
Sets whether the form should allow the user to quit.
Definition cxMenu.cpp:1259
virtual void sortByReturnCode(bool pRefresh=false)
Sorts the menu items by their return code. Note: If the same.
Definition cxMenu.cpp:1662
virtual unsigned numMenuItems() const
Definition cxMenu.cpp:681
virtual long getReturnCode() const override
Returns the return code set by the last call to.
Definition cxMenu.cpp:890
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)
void setCaseSensitiveSearch(bool pCaseSensitiveSearch)
Sets whether or not item searching should be case-sensitive.
Definition cxMenu.cpp:1052
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxMenu". This can be.
Definition cxMenu.cpp:1657
virtual void drawBorder() override
Draws a border around the menu.
Definition cxMenu.cpp:986
virtual bool setItemTextByIndex(int pIndex, const std::string &pItemText, bool pRefresh=false)
Sets the text of an item (by index).
Definition cxMenu.cpp:1170
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.
Definition cxMenu.cpp:1895
int subWinLeft() const
Returns the left column of the subwindow.
Definition cxMenu.cpp:1998
virtual void appendWithPopUp(const std::string &pDisplayText, cxMenu *pSubMenu, const std::string &pHelpString="", bool pResize=false)
Definition cxMenu.cpp:228
bool getExitWhenLeaveFirst() const
Returns whether the menu will exit its input loop when the.
Definition cxMenu.cpp:1430
virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh=false) override
Definition cxMenu.cpp:687
virtual void removeAttrs(e_WidgetItems pItem) override
Removes all attributes for a given window item.
Definition cxMenu.cpp:1581
virtual void erase(bool pEraseSubwindows=true) override
Definition cxMenu.cpp:870
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.
Definition cxMenu.cpp:423
int getSubWinWidth() const
Definition cxMenu.cpp:880
virtual void enableAttrs(WINDOW *pWin, e_WidgetItems pItem) override
Enables the attributes for one of the m*Attrs sets for an ncurses window.
Definition cxMenu.cpp:2648
virtual int getCurrentMenuItem() const
Returns the index of the current menu item.
Definition cxMenu.cpp:1400
virtual bool itemExists(const std::string &pItemText, bool pUseDisplayText=true) const
Returns whether or not an item exists in the menu.
Definition cxMenu.cpp:1223
virtual bool modalGetsKeypress() const override
Returns whether or not a call to showModal() will wait for a.
Definition cxMenu.cpp:463
virtual void setBottomItem(unsigned pItemIndex, bool pRefresh=false)
Sets the item to appear at the bottom of the menu (by index).
Definition cxMenu.cpp:619
virtual bool itemWasSelected() const
Returns whether an item was selected the last time the menu was.
Definition cxMenu.cpp:1778
void setSearchKey(int pSearchKey)
Changes the key to be used for menu item searching (static)
Definition cxMenu.cpp:1057
virtual void disableAttrs(WINDOW *pWin, e_WidgetItems pItem) override
Disables the attributes for one of the m*Attrs sets for an ncurses window.
Definition cxMenu.cpp:2702
virtual void setAttr(e_WidgetItems pItem, attr_t pAttr) override
Sets the ncurses attribute to use for one of the items in the.
Definition cxMenu.cpp:1500
void setExitWhenLeaveLast(bool pExitWhenLeaveLast)
Changes the behavior of exiting the input loop when the user.
Definition cxMenu.cpp:1435
virtual void scrollItems(int pScrollAmt, bool pRefresh=false)
Scrolls the menu item list by a certain amount.
Definition cxMenu.cpp:489
void setExitWhenLeaveFirst(bool pExitWhenLeaveFirst)
Changes the behavior of exiting the input loop when the user.
Definition cxMenu.cpp:1425
void setClearOnSearch(bool pClearOnSearch)
Sets whether or not to clear the search text.
Definition cxMenu.cpp:1047
virtual void scrollToTop(bool pRefresh=false)
Scrolls the menu to the top.
Definition cxMenu.cpp:544
void setRefreshItemsWhenModal(bool pRefreshItemsWhenModal)
Sets whether the list of items should be refreshed when the.
Definition cxMenu.cpp:1450
virtual long show(bool pBringToTop=true, bool pShowSubwindows=true) override
Shows the menu.
Definition cxMenu.cpp:849
virtual void scrollToBottom(bool pRefresh=false)
Scrolls the menu to the bottom.
Definition cxMenu.cpp:549
std::shared_ptr< cxFunction > getOnSelectItemFunction() const
Returns the pointer to the onSelectMenuItem function.
Definition cxMenu.cpp:1930
virtual void refreshMenuItems()
Refreshes the list of menu items.
Definition cxMenu.cpp:1107
bool mouseEvtWasInItemArea(int &pItemIndex) const
Returns whether the last mouse event occurred in the area where.
Definition cxMenu.cpp:1834
virtual std::string getItemText(int pIndex, bool pGetDisplayText=true) const
Returns the text for a menu item.
Definition cxMenu.cpp:949
void toggleSelectability(unsigned pIndex, bool pSelectable)
Toggles selectability for an item (by index). Selectability.
Definition cxMenu.cpp:1016
virtual bool removeByReturnCode(long pReturnCode, bool pResize=false, bool pRefresh=false)
Removes a menu item based on its return code.
Definition cxMenu.cpp:358
virtual bool runLoopStartFunction()
Runs the loop start function, if it's set.
Definition cxMenu.cpp:1323
virtual void drawMessage() override
Definition cxMenu.cpp:802
std::string getItemTextByReturnCode(long pReturnCode, bool pGetDisplayText=true)
Returns an item's text by its return code. If there is no.
Definition cxMenu.cpp:1299
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 long getCurrentItemReturnCode() const
Returns the return code of the currently-highlited item.
Definition cxMenu.cpp:944
long doInputLoop(bool &pRunOnLeaveFunction)
Handles the input loop and returns the menu item's return.
Definition cxMenu.cpp:2006
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).
Definition cxMenu.cpp:1114
std::set< attr_t > mMenuSelectionAttrs
Menu selection attributes.
Definition cxMenu.h:966
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.
Definition cxMenu.cpp:136
int getAltPgDownKey() const
Returns the key that is set as the alternate pageDown key.
Definition cxMenu.cpp:1077
void setAllowExit(bool pAllowExit)
Sets whether the form should allow the user to exit.
Definition cxMenu.cpp:1269
virtual bool move(int pNewRow, int pNewCol, bool pRefresh=true) override
Definition cxMenu.cpp:639
bool getExitWhenLeaveLast() const
Returns whether the menu will exit its input loop when the.
Definition cxMenu.cpp:1440
int getAltPgUpKey() const
Returns the key that is set as the alternate pageUp key.
Definition cxMenu.cpp:1067
virtual void setTopItem(unsigned pTopItem, bool pRefresh=false)
Sets the item to appear at the top of the menu (by index).
Definition cxMenu.cpp:557
virtual bool getWrapping() const
Returns whether scroll wrapping is enabled.
Definition cxMenu.cpp:1385
virtual void removeAttr(e_WidgetItems pItem, attr_t pAttr) override
Removes an ncurses attribute from one of the item lists.
Definition cxMenu.cpp:1541
void setLoopEndFunction(const std::shared_ptr< cxFunction > &pFuncPtr)
Sets a function to be run at the end of each.
Definition cxMenu.cpp:1318
Represents a text-based window on the screen. Can contain a title, status, and a message to appear wi...
Definition cxWindow.h:195
#define NOKEY
Definition cxKeyDefines.h:64
#define DEFAULT_CXMENU_ALT_PGUP_KEY
Definition cxMenu.h:24
#define DEFAULT_CXMENU_ALT_PGDOWN_KEY
Definition cxMenu.h:25
#define DEFAULT_CXMENU_SEARCH_KEY
Definition cxMenu.h:23
#define DEFAULT_HEIGHT
Definition cxWindow.h:68
#define DEFAULT_WIDTH
Definition cxWindow.h:69
cxBorderChars.h - Defines border characters to be used in drawing a box (i.e., in cxWindow and all it...
Definition cxApp.cpp:5
std::string(* funcPtr4)(void *p1, void *p2, void *p3, void *p4)
Definition cxFunction.h:21
e_WidgetItems
Definition cxWidgetItems.h:42
std::string(* funcPtr0)()
Definition cxFunction.h:19
std::string(* funcPtr2)(void *p1, void *p2)
Definition cxFunction.h:20
cxMenuItemType
Definition cxMenuItemType.h:14
@ cxITEM_NORMAL
Definition cxMenuItemType.h:15
eBorderStyle
Definition cxBorderStyles.h:26
@ eBS_SINGLE_LINE
Definition cxBorderStyles.h:28