cxWidgets 1.0
cxWindow.h
Go to the documentation of this file.
1// Copyright (c) 2026 E. Oulashin
2#ifndef __CXWINDOW_H__
3#define __CXWINDOW_H__
4
5// Copyright (c) 2005-2007 Michael H. Kinney
6
7// The cxWindow class is used to draw windows/boxes on the screen.
8// Note: Quite a few objects are derived from this class.
9// Note: If cxWindow is updated so that it might not wait for a keypress in
10// its input loop, modalGetsKeypress() will need to be updated to reflect
11// this.
12//
13// Maybe in the future we can add a window ID member variable (and
14// parameters to the constructors, making sure it's consistent with
15// wxWidgets classes). This way, as in the wxWidgets framework, we
16// can identify what command came from which window, etc.).
17
18#include "cxObject.h"
19#include "cxPositions.h"
20#include "cxReturnCodes.h"
21#include "cxBorderStyles.h"
22#include "cxMiscDefines.h"
23#include "cxFunction.h"
24#include "cxWidgetItems.h"
25#include <unistd.h>
26#include <sstream>
27#include <iostream>
28#include <fstream>
29#include <vector>
30#include <set>
31#include <map>
32#include <list>
33#include <deque>
34#include <utility>
35#include <memory>
36
37namespace cx {
38
39class cxWindow;
40typedef std::vector<cxWindow*> cxWindowPtrContainer;
41
42// If the version of ncurses on the current machine doesn't support the mouse,
43// then define some of ncurses' mouse event macros so that code using them
44// will still compile.
45#ifndef NCURSES_MOUSE_VERSION
46 #define BUTTON1_PRESSED 2
47 #define BUTTON1_RELEASED 1
48 #define BUTTON1_CLICKED 4
49 #define BUTTON1_DOUBLE_CLICKED 8
50 #define BUTTON1_TRIPLE_CLICKED 16
51 #define BUTTON2_PRESSED 128
52 #define BUTTON2_RELEASED 64
53 #define BUTTON2_CLICKED 256
54 #define BUTTON2_DOUBLE_CLICKED 512
55 #define BUTTON2_TRIPLE_CLICKED 1024
56 #define BUTTON3_PRESSED 8192
57 #define BUTTON3_RELEASED 4096
58 #define BUTTON3_CLICKED 16384
59 #define BUTTON3_DOUBLE_CLICKED 32768
60 #define BUTTON3_TRIPLE_CLICKED 65536
61 #define BUTTON4_PRESSED 524288
62 #define BUTTON4_RELEASED 262144
63 #define BUTTON4_CLICKED 1048576
64 #define BUTTON4_DOUBLE_CLICKED 2097152
65 #define BUTTON4_TRIPLE_CLICKED 4194304
66#endif
67
68#define DEFAULT_HEIGHT 24
69#define DEFAULT_WIDTH 80
70
71typedef std::deque<std::string> messageLineContainer;
72
194class cxWindow : public cxObject
195{
196 public:
217 explicit cxWindow(cxWindow *pParentWindow = nullptr,
218 int pRow = 0, int pCol = 0,
219 int pHeight = DEFAULT_HEIGHT,
220 int pWidth = DEFAULT_WIDTH,
221 const std::string& pTitle = "",
222 const std::string& pMessage = "",
223 const std::string& pStatus = "",
224 eBorderStyle pBorderStyle = eBS_SINGLE_LINE,
225 cxWindow *pExtTitleWindow = nullptr,
226 cxWindow *pExtStatusWindow = nullptr,
227 bool pHotkeyHighlighting = false);
228
242 cxWindow(cxWindow *pParentWindow,
243 int pRow, int pCol, const std::string& pTitle,
244 const std::string& pMessage, const std::string& pStatus,
245 cxWindow *pExtTitleWindow = nullptr,
246 cxWindow *pExtStatusWindow = nullptr,
247 bool pHotkeyHighlighting = false);
259 cxWindow(cxWindow *pParentWindow,
260 const std::string& pTitle, const std::string& pMessage,
261 const std::string& pStatus,
262 cxWindow *pExtTitleWindow = nullptr,
263 cxWindow *pExtStatusWindow = nullptr,
264 bool pHotkeyHighlighting = false);
265
279 cxWindow(cxWindow *pParentWindow,
280 const std::string& pTitle, const std::string& pMessage,
281 const std::string& pStatus,
282 int pHeight, int pWidth,
283 cxWindow *pExtTitleWindow = nullptr,
284 cxWindow *pExtStatusWindow = nullptr,
285 bool pHotkeyHighlighting = false);
286
297 cxWindow(cxWindow *pParentWindow,
298 const std::string& pMessage, const std::string& pStatus,
299 cxWindow *pExtTitleWindow = nullptr,
300 cxWindow *pExtStatusWindow = nullptr,
301 bool pHotkeyHighlighting = false);
302
315 cxWindow(cxWindow *pParentWindow,
316 const std::string& pMessage, const std::string& pStatus,
317 int pHeight, int pWidth,
318 cxWindow *pExtTitleWindow = nullptr,
319 cxWindow *pExtStatusWindow = nullptr,
320 bool pHotkeyHighlighting = false);
321
331 cxWindow(cxWindow *pParentWindow, const std::string& pMessage,
332 cxWindow *pExtTitleWindow = nullptr,
333 cxWindow *pExtStatusWindow = nullptr,
334 bool pHotkeyHighlighting = false);
347 cxWindow(cxWindow *pParentWindow, eHPosition pHPosition,
348 const std::string& pTitle, const std::string& pMessage,
349 const std::string& pStatus,
350 cxWindow *pExtTitleWindow = nullptr,
351 cxWindow *pExtStatusWindow = nullptr,
352 bool pHotkeyHighlighting = false);
353
358 cxWindow(const cxWindow& pThatWindow);
359
363 virtual ~cxWindow();
364
369 virtual void centerHoriz(bool pRefresh = true);
370
376 virtual void alignHoriz(eHPosition pPosition, bool pRefresh = true);
377
382 virtual void centerVert(bool pRefresh = true);
383
389 virtual void alignVert(eVPosition pPosition, bool pRefresh = true);
390
395 virtual void center(bool pRefresh = true);
396
403 virtual std::string getTitle() const;
404
412 virtual void setTitle(const std::string& pTitle, bool pRefreshTitle = true);
413
418 std::string getStatus() const;
419
425 virtual void setStatus(const std::string& pStatus, bool pRefreshStatus = true);
426
431 std::string getMessage() const;
432
437 virtual void setMessage(const std::string &pMessage);
438
445 virtual void addMessageLineBelow(const std::string &pLine);
446
452 virtual void addMessageLinesBelow(const std::vector<std::string>& pLines);
453
459 virtual void addMessageLinesBelow(const std::list<std::string>& pLines);
460
466 virtual void addMessageLinesBelow(const std::deque<std::string>& pLines);
467
474 virtual void addMessageLineAbove(const std::string& pLine);
475
481 virtual void addMessageLinesAbove(const std::vector<std::string>& pLines);
482
488 virtual void addMessageLinesAbove(const std::list<std::string>& pLines);
489
495 virtual void addMessageLinesAbove(const std::deque<std::string>& pLines);
496
502 virtual void setMessageLines(const std::vector<std::string>& pLines);
503
509 virtual void setMessageLines(const std::list<std::string>& pLines);
510
516 virtual void setMessageLines(const std::deque<std::string>& pLines);
517
523 virtual void removeMessageLine(unsigned pIndex);
524
531 virtual void setMessageLine(unsigned pIndex, const std::string& pLine);
532
542 void setHorizTitleAlignment(eHPosition pHAlignment);
543
549
554 void setHorizMessageAlignment(eHPosition pHAlignment);
555
561
566 void setHorizStatusAlignment(eHPosition pHAlignment);
567
573
578 void setVerticalMessageAlignment(eVPosition pVAlignment);
579
585
592 void setExtTitleWindow(cxWindow *pWindow, bool pRefreshTitle = true);
593
599
606 void setExtStatusWindow(cxWindow *pWindow, bool pRefreshStatus = true);
607
613
618 bool isHidden() const;
619
630 virtual long show(bool pBringToTop = false, bool pShowSubwindows = true);
631
645 virtual long showModal(bool pShowSelf = true, bool pBringToTop = true,
646 bool pShowSubwindows = true);
647
656 virtual bool modalGetsKeypress() const;
657
670 virtual long setFocus(bool pShowSelf = true, bool pBringToTop = true,
671 bool pShowSubwindows = true);
672
677 virtual void setFocusColors();
678
683 virtual void setFocusColors(attr_t pAttr);
684
688 virtual void unSetFocusColors();
689
693 virtual void unSetFocusColors(attr_t pAttr);
694
700 virtual void erase(bool pEraseSubwindows = true);
701
706 virtual void bringToTop(bool pRefresh = true);
707
712 virtual void bringToBottom(bool pRefresh = false);
713
719 virtual bool isOnTop() const;
720
726 virtual bool isOnBottom() const;
727
735 virtual bool isAbove(const cxWindow& pThatWindow) const;
736
744 virtual bool isBelow(const cxWindow& pThatWindow) const;
745
752 virtual void hide(bool pHideSubwindows = true);
753
760 virtual void unhide(bool pUnhideSubwindows = true);
761
769 void touchWindow() { if (mWindow) touchwin(mWindow); }
770
783 virtual void drawBorder(int pRow, int pCol, int pHeight, int pWidth,
784 bool pTop=true, bool pBottom=true,
785 bool pLeft=true, bool pRight=true);
786
792 virtual void drawBorder(int pHeight, int pWidth);
793
797 virtual void drawBorder();
798
803 virtual int top() const;
804
809 virtual int centerRow() const;
810
815 virtual int bottom() const;
816
821 virtual int left() const;
822
827 virtual int centerCol() const;
828
833 virtual int right() const;
834
842 virtual int width(int pWidth);
843
848 virtual int width() const;
849
857 virtual int height(int pHeight);
858
863 virtual int height() const;
864
873 virtual void getRect(int& pTop, int& pLeft, int& pBottom, int& pRight);
874
884 virtual bool pointIsInWindow(int pY, int pX) const;
885
894 virtual bool pointIsInTitle(int pY, int pX) const;
895
902 virtual void getSize(int& pHeight, int& pWidth);
903
912 virtual void addAttr(e_WidgetItems pItem, attr_t pAttr);
913
924 virtual void setAttr(e_WidgetItems pItem, attr_t pAttr);
925
933 virtual void removeAttr(e_WidgetItems pItem, attr_t pAttr);
934
941 virtual void removeAttrs(e_WidgetItems pItem);
942
950 virtual void getAttrs(e_WidgetItems pItem, std::set<attr_t>& pAttrs) const;
951
959 virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh = true);
960
969 virtual bool move(int pNewRow, int pNewCol, bool pRefresh = true);
970
984 virtual bool moveRelative(int pVerticalOffset, int pHorizOffset, bool pRefresh = true);
985
990 unsigned numSubWindows();
991
997 void setSubWinMessage(unsigned pIndex, const std::string& pMessage);
998
1004 void setSubWinMessage(const std::string& pTitle, const std::string& pMessage);
1005
1010 virtual bool hasFocus() const;
1011
1023 virtual void setBorderStyle(eBorderStyle pBorderStyle);
1024
1030
1035 bool hasBorder() const;
1036
1041 virtual cxWindow* getParent() const;
1042
1047 void setParent(cxWindow *pNewParent);
1048
1058 virtual void dump(std::string& pResult);
1059
1067 virtual void showSubwindows(bool pBringToTop = true, bool pShowSubwindows = true);
1068
1076 cxWindow& operator =(const cxWindow& pThatWindow);
1077
1090 virtual void writeText(int pRow, int pCol, const std::string& pText, bool pRefresh = true);
1091
1101 virtual void setHotkeyHighlighting(bool pHotkeyHighlighting);
1102
1108 bool getHotkeyHighlighting() const;
1109
1115 virtual bool isEnabled() const;
1116
1128 virtual void setEnabled(bool pEnabled);
1129
1137 virtual void setDisableCursorOnShow(bool pDisableCursorOnShow);
1138
1146 virtual bool getDisableCursorOnShow() const;
1147
1154 virtual bool getExitOnMouseOutside() const;
1155
1164 virtual void setExitOnMouseOutside(bool pExitOnMouseOutside);
1165
1171 virtual int getLastKey() const;
1172
1178 virtual void setLastKey(int pLastKey);
1179
1186 virtual bool lastKeyWasMouseEvt() const;
1187
1197 virtual void getLastMouseEvtCoords(int& pY, int& pX);
1198
1206 virtual bool getChangeColorsOnFocus() const;
1207
1217 virtual void setChangeColorsOnFocus(bool pChangeColorsOnFocus);
1218
1224 virtual void setOnFocusFunction(const std::shared_ptr<cxFunction>& pFunction);
1225
1241 virtual void setOnFocusFunction(funcPtr4 pFunction, void *p1, void *p2,
1242 void *p3, void *p4, bool pUseVal = false,
1243 bool pExitAfterRun = false);
1244
1258 virtual void setOnFocusFunction(funcPtr2 pFunction, void *p1, void *p2,
1259 bool pUseVal = false, bool pExitAfterRun = false);
1260
1272 virtual void setOnFocusFunction(funcPtr0 pFunction, bool pUseVal = false,
1273 bool pExitAfterRun = false);
1274
1280 virtual void setOnLeaveFunction(const std::shared_ptr<cxFunction>& pFunction);
1281
1293 virtual void setOnLeaveFunction(funcPtr4 pFunction, void *p1, void *p2, void *p3,
1294 void *p4);
1295
1305 virtual void setOnLeaveFunction(funcPtr2 pFunction, void *p1, void *p2);
1306
1314 virtual void setOnLeaveFunction(funcPtr0 pFunction);
1315
1327 virtual bool runOnFocusFunction(std::string *pFunctionRetval = nullptr);
1328
1342 virtual bool runOnLeaveFunction(std::string *pFunctionRetval = nullptr);
1343
1350 virtual void toggleOnFocusFunction(bool pRunOnFocus);
1351
1358 virtual void toggleOnLeaveFunction(bool pRunOnLeave);
1359
1365 virtual bool onFocusFunctionEnabled() const;
1366
1372 virtual bool onLeaveFunctionEnabled() const;
1373
1379 virtual const std::shared_ptr<cxFunction>& getOnFocusFunction() const;
1380
1386 virtual const std::shared_ptr<cxFunction>& getOnLeaveFunction() const;
1387
1395 virtual bool isModal() const;
1396
1406 virtual bool setKeyFunction(int pKey, const std::shared_ptr<cxFunction>& pFunction);
1407
1429 virtual bool setKeyFunction(int pKey, funcPtr4 pFunction,
1430 void *p1, void *p2, void *p3, void *p4,
1431 bool pUseReturnVal = false,
1432 bool pExitAfterRun = false,
1433 bool pRunOnLeaveFunction = true);
1434
1454 virtual bool setKeyFunction(int pKey, funcPtr2 pFunction,
1455 void *p1, void *p2,
1456 bool pUseReturnVal = false,
1457 bool pExitAfterRun = false,
1458 bool pRunOnLeaveFunction = true);
1459
1480 virtual bool setKeyFunction(int pKey, funcPtr0 pFunction,
1481 bool pUseReturnVal = false,
1482 bool pExitAfterRun = false,
1483 bool pRunOnLeaveFunction = true);
1484
1491 virtual void clearKeyFunction(int pKey);
1492
1498 virtual void clearKeyFunctionByPtr(funcPtr4 pFunction);
1499
1505 virtual void clearKeyFunctionByPtr(funcPtr2 pFunction);
1506
1512 virtual void clearKeyFunctionByPtr(funcPtr0 pFunction);
1513
1517 virtual void clearKeyFunctions();
1518
1527 virtual bool hasKeyFunction(int pKey) const;
1528
1559 virtual bool setMouseFunction(int pMouseState, const std::shared_ptr<cxFunction>& pFunction);
1560
1603 virtual bool setMouseFunction(int pMouseState, funcPtr4 pFunction,
1604 void *p1, void *p2, void *p3, void *p4,
1605 bool pUseReturnVal = false,
1606 bool pExitAfterRun = false,
1607 bool pRunOnLeaveFunction = true);
1608
1650 virtual bool setMouseFunction(int pMouseState, funcPtr2 pFunction,
1651 void *p1, void *p2,
1652 bool pUseReturnVal = false,
1653 bool pExitAfterRun = false,
1654 bool pRunOnLeaveFunction = true);
1655
1699 virtual bool setMouseFunction(int pMouseState, funcPtr0 pFunction,
1700 bool pUseReturnVal = false,
1701 bool pExitAfterRun = false,
1702 bool pRunOnLeaveFunction = true);
1703
1710 virtual void clearMouseFunction(int pMouseState);
1711
1715 virtual void clearMouseFunctions();
1716
1725 virtual bool hasMouseFunction(int pMouseState) const;
1726
1736 std::map<int, std::shared_ptr<cxFunction> >::iterator keyFunctions_begin();
1737
1747 std::map<int, std::shared_ptr<cxFunction> >::iterator keyFunctions_end();
1748
1757 virtual void getFunctionKeyStrings(std::vector<std::string>& pKeys) const;
1758
1766 virtual void getFunctionKeys(std::vector<int>& pKeys) const;
1767
1775 virtual void setShowSubwinsForward(bool pShowSubwinsForward);
1776
1784 virtual bool getShowSubwinsForward() const;
1785
1794 virtual void setShowSelfBeforeSubwins(bool pShowSelfBeforeSubwins);
1795
1803 virtual bool getShowSelfBeforeSubwins() const;
1804
1813 virtual long getReturnCode() const;
1814
1831 virtual bool addTitleString(int pHPos, const std::string& pStr,
1832 bool pRefreshTitle = false);
1833
1846 virtual std::string getTitleString(int pHPos) const;
1847
1855 virtual std::map<int, std::string> getTitleStrings() const;
1856
1865 virtual void getTitleStrings(std::map<int, std::string>& pTitleStrings) const;
1866
1874 virtual void setTitleStrings(const std::map<int, std::string>& pTitleStrings);
1875
1881 virtual void removeTitleString(int pHPos);
1882
1886 virtual void removeTitleStrings();
1887
1904 virtual bool addStatusString(int pHPos, const std::string& pStr,
1905 bool pRefreshStatus = false);
1906
1919 virtual std::string getStatusString(int pHPos) const;
1920
1928 virtual std::map<int, std::string> getStatusStrings() const;
1929
1938 virtual void getStatusStrings(std::map<int, std::string>& pStatusStrings) const;
1939
1947 virtual void setStatusStrings(const std::map<int, std::string>& pStatusStrings);
1948
1954 virtual void removeStatusString(int pHPos);
1955
1959 virtual void removeStatusStrings();
1960
1975 virtual bool addQuitKey(int pKey, bool pRunOnLeaveFunction = true,
1976 bool pOverride = false);
1977
1983 virtual void removeQuitKey(int pKey);
1984
1988 virtual void removeQuitKeys();
1989
2004 virtual bool addExitKey(int pKey, bool pRunOnLeaveFunction = true,
2005 bool pOverride = false);
2006
2012 virtual void removeExitKey(int pKey);
2013
2017 virtual void removeExitKeys();
2018
2028 virtual bool hasExitKey(int pKey) const;
2029
2039 virtual bool hasQuitKey(int pKey) const;
2040
2047 virtual void clear(bool pRefresh = false);
2048
2053 virtual void quitNow();
2054
2059 virtual void exitNow();
2060
2068 virtual void getQuitKeyStrings(std::vector<std::string>& pKeys) const;
2069
2077 virtual std::string getQuitKeyListString() const;
2078
2086 virtual void getExitKeyStrings(std::vector<std::string>& pKeys) const;
2087
2095 virtual std::string getExitKeyListString() const;
2096
2105 virtual std::map<int, bool> getQuitKeys() const;
2106
2115 virtual std::map<int, bool> getExitKeys() const;
2116
2123 void toggleMessage(bool pDrawMessage);
2124
2130 void toggleTitle(bool pDrawTitle);
2131
2137 void toggleStatus(bool pDrawStatus);
2138
2144 bool messageWillDraw() const;
2145
2151 bool titleWillDraw() const;
2152
2158 bool statusWillDraw() const;
2159
2167 void toggleSpecialChars(bool pDrawSpecialChars);
2168
2176 bool specialCharsWillDraw() const;
2177
2181 virtual void drawTitle();
2182
2186 virtual void drawStatus();
2187
2191 virtual void drawMessage();
2192
2196 virtual void drawSpecialChars();
2197
2204 virtual void setReturnCode(const long& pReturnCode);
2205
2210 virtual void setMessageColor(e_cxColors pColor);
2211
2216 virtual void setTitleColor(e_cxColors pColor);
2217
2222 virtual void setStatusColor(e_cxColors pColor);
2223
2228 virtual void setBorderColor(e_cxColors pColor);
2229
2238 virtual void setColor(e_WidgetItems pItem, e_cxColors pColor);
2239
2249 virtual bool hasAttr(e_WidgetItems pItem, attr_t pAttr);
2250
2259 virtual std::string cxTypeStr() const override;
2260
2268 bool getLeaveNow() const;
2269
2274 std::string getName() const;
2275
2282 virtual void setName(const std::string& pName);
2283
2293 bool mouseEvtWasInWindow() const;
2294
2304 virtual bool mouseEvtWasInTitle() const;
2305
2310 virtual void doMouseBehavior();
2311
2323 virtual void doMouseBehavior(int pMouseY, int pMouseX);
2324
2336 std::shared_ptr<cxFunction> getKeyFunction(int pKey) const;
2337
2349 std::shared_ptr<cxFunction0> getKeyFunctionAsFunction0(int pKey) const;
2350
2362 std::shared_ptr<cxFunction2> getKeyFunctionAsFunction2(int pKey) const;
2363
2375 std::shared_ptr<cxFunction4> getKeyFunctionAsFunction4(int pKey) const;
2376
2384 bool mouseEvtWasButtonEvt() const;
2385
2393 bool mouseButton1Pressed() const;
2394
2403 bool mouseButton1Released() const;
2404
2411 bool mouseButton1Clicked() const;
2412
2419 bool mouseButton1DoubleClicked() const;
2420
2427 bool mouseButton2Clicked() const;
2428
2435 bool mouseButton2DoubleClicked() const;
2436
2443 bool mouseButton3Clicked() const;
2444
2453 virtual void mouseButton1Click(int pY, int pX);
2454
2463 virtual void mouseButton2Click(int pY, int pX);
2464
2473 virtual void mouseButton3Click(int pY, int pX);
2474
2475#ifdef NCURSES_MOUSE_VERSION
2484 MEVENT getMouseEvent() const;
2485#endif
2486
2496 std::string getString(int pRow, int pCol, int pNumber);
2497
2502 void info();
2503
2509 virtual void toggleBorderTop(bool pToggle);
2510
2516 virtual void toggleBorderBottom(bool pToggle);
2517
2523 virtual void toggleBorderLeft(bool pToggle);
2524
2530 virtual void toggleBorderRight(bool pToggle);
2531
2546 virtual void addSpecialChar(int pY, int pX, chtype pChar,
2547 attr_t pAttr = A_NORMAL);
2548
2556 virtual void removeSpecialChar(int pY, int pX);
2557
2561 virtual void clearSpecialChars();
2562
2569 virtual bool functionExistsForLastMouseState() const;
2570
2578 int getMouseState() const;
2579
2589 std::string getMouseStateStr() const;
2590
2600 virtual e_cxColors getItemColor(e_WidgetItems pItem) const;
2601
2602 protected:
2603
2607 WINDOW *mWindow = nullptr;
2608
2615
2622 std::map<std::pair<int, int>, chtype> mSpecialChars;
2623
2627 std::set<attr_t> mMessageAttrs;
2631 std::set<attr_t> mTitleAttrs;
2635 std::set<attr_t> mStatusAttrs;
2639 std::set<attr_t> mBorderAttrs;
2643 std::set<attr_t> mHotkeyAttrs;
2650 std::map<std::pair<int, int>, attr_t> mSpecialCharAttrs;
2651
2652 // Colors for the various elements
2657
2658 eHPosition mHorizTitleAlignment = eHP_LEFT; // Horizontal title alignment
2659 eHPosition mHorizMessageAlignment = eHP_LEFT; // Horizontal message alignment
2660 eHPosition mHorizStatusAlignment = eHP_LEFT; // Horizontal status alignment
2661 eVPosition mVerticalMessageAlignment = eVP_TOP; // Vertical message alignment
2662
2663 bool mDrawMessage = true; // Whether or not to draw the message
2664 bool mDrawTitle = true; // Whether or not to draw the title
2665 bool mDrawStatus = true; // Whether or not to draw the status
2666 bool mDrawSpecialChars = true; // Whether or not to draw the "special" chars
2667
2668 std::shared_ptr<cxFunction> mOnFocusFunction = nullptr; // Function for when focus is gained
2669 std::shared_ptr<cxFunction> mOnLeaveFunction = nullptr; // Function for when focus is lost
2670 bool mIsModal = false; // Whether or not the window is being shown modally
2671 // mLeaveNow can be set true by exitNow() or quitNow() if an external
2672 // function wants the window object to leave its input loop.
2673 bool mLeaveNow = false;
2674 // This map contains pointers to functions to be called for various
2675 // keypresses.
2676 std::map<int, std::shared_ptr<cxFunction> > mKeyFunctions;
2677 // This map contains pointers to functions to be called for various
2678 // mouse states.
2679 std::map<int, std::shared_ptr<cxFunction> > mMouseFunctions;
2680 // mQuitKeys and mExitKeys contain additional keys to cause the window
2681 // to quit the input loop & return cxID_QUIT and cxID_EXIT,
2682 // respectively. The key to the maps is the keypress, and the boolean
2683 // tells whether or not to run the onLeave function before leaving.
2684 std::map<int, bool> mQuitKeys;
2685 std::map<int, bool> mExitKeys;
2686 // mHotkeyHighlighting specifies whether or not to use hotkey
2687 // attributes in the message.
2689#ifdef NCURSES_MOUSE_VERSION
2690 MEVENT mMouse; // Stores data for mouse events
2691#endif
2692
2701 virtual void reCreatePanel();
2702
2707 void freeWindow();
2708
2724 virtual void init(int pRow, int pCol, int pHeight, int pWidth,
2725 const std::string& pTitle, const std::string& pMessage,
2726 const std::string& pStatus, cxWindow *pParentWindow = nullptr,
2727 bool pResizeVertically = true);
2728
2732 virtual void removeAllSubwindows();
2733
2740 virtual void addSubwindow(cxWindow *pSubWindow);
2741
2747 virtual void removeSubWindow(const cxWindow *pSubWindow);
2748
2759 virtual void setElementColor(short& pColorPair, attr_t& pElementAttr, e_cxColors pColor);
2760
2771 virtual void enableAttrs(WINDOW *pWin, e_WidgetItems pItem);
2772
2783 virtual void disableAttrs(WINDOW *pWin, e_WidgetItems pItem);
2784
2802 virtual void writeWithHighlighting(WINDOW* pWindow, const std::string& pText,
2803 const int& pY, const int& pStartX, const int& pEndX,
2804 int pNormalTextItem = -1);
2805
2813 virtual void copyCxWinStuff(const cxWindow* pThatWindow, bool pRecreateWin = true);
2814
2826 virtual void getRowColBasedOn(cxWindow *pParentWindow, eHPosition pPosition,
2827 const std::string& pTitle, const std::string& pStatus,
2828 const std::string& pMessage, int& pRow, int& pCol);
2829
2843 virtual bool handleFunctionForLastKey(bool *pFunctionExists = nullptr,
2844 bool *pRunOnLeaveFunction = nullptr);
2845
2859 virtual bool handleFunctionForLastMouseState(bool *pFunctionExists = nullptr,
2860 bool *pRunOnLeaveFunction = nullptr);
2861
2867 virtual void draw();
2868
2882#ifdef NCURSES_MOUSE_VERSION
2883 static bool mouseEvtInRect(const MEVENT& pMouse, int pTop, int pLeft,
2884 int pBottom, int pRight);
2885#endif
2886
2893 void setKeyFunctions(const cxWindow& pWindow);
2894
2901 void setFocusFunctions(const cxWindow& pWindow);
2902
2909 bool parentIsCxPanel() const;
2910
2917 bool parentIsCxForm() const;
2918
2925 bool parentIsCxNotebook() const;
2926
2932 cxWindowPtrContainer::const_iterator subWindows_begin() const;
2933
2939 cxWindowPtrContainer::const_iterator subWindows_end() const;
2940
2946 cxWindowPtrContainer::const_reverse_iterator subWindows_rbegin() const;
2947
2953 cxWindowPtrContainer::const_reverse_iterator subWindows_rend() const;
2954
2962 bool onFocusFunctionIsSet() const;
2963
2971 bool onLeaveFunctionIsSet() const;
2972
2973 private:
2974 PANEL *mPanel = nullptr; // For layered window management
2975 cxWindow *mExtTitleWindow; // Optionally used for the title instead of the title line.
2976 cxWindow *mExtStatusWindow; // Optionally used for status instead
2977 // of the status line.
2978 cxWindow *mTitleParent = nullptr; // Pointer to a window using me for its title
2979 cxWindow *mStatusParent = nullptr; // Pointer to a window using me for its status
2980 std::string mExtTitleTemp; // Keeps track of old external title window text
2981 std::string mExtStatusTemp; // Keeps track of old external status window text
2982 cxWindow *mParentWindow; // Pointer to the parent window (can be nullptr for none)
2983 cxWindowPtrContainer mSubWindows; // Contains subwindows for this window
2984 bool mFocus = false; // Whether or not the window has focus
2985 eBorderStyle mBorderStyle; // Border style
2986 bool mEnabled = true; // Whether or not the window is enabled
2987 bool mDisableCursorOnShow = true; // Whether or not to disable the cursor in show()
2988 bool mExitOnMouseOutside = false; // Exit modal input loop on mouse click outside window
2989 int mLastKey = NOKEY; // The last key typed by the user during an input loop
2990 bool mChangeColorsOnFocus = false; // Whether or not to apply colors upon setting focus
2991 bool mShowSubwinsForward = true; // If true, the subwindows will be shown in
2992 // forward order; if false, they will be shown
2993 // in reverse order.
2994 bool mShowSelfBeforeSubwins = true; // Whether or not to show this window before
2995 // showing the subwindows
2996 long mReturnCode = cxID_EXIT; // Keeps track of the return code set by showModal()
2997 bool mRunOnFocus = true; // Whether or not to run the onFocus function
2998 bool mRunOnLeave = true; // Whether or not to run the onLeave function
2999 // mTitleStrings and mStatusStrings keep track of horizontal positions
3000 // and strings to write for the title and status lines, respectively.
3001 std::map<int, std::string> mTitleStrings;
3002 std::map<int, std::string> mStatusStrings;
3003 // mName provides an alternate way to identify a window.
3004 std::string mName;
3005 bool mDrawBorderTop = true; // Display the top border (only applicable if borderstyle != eBS_NOBORDER)
3006 bool mDrawBorderBottom = true; // Display the bottom border (only applicable if borderstyle != eBS_NOBORDER)
3007 bool mDrawBorderLeft = true; // Display the left border (only applicable if borderstyle != eBS_NOBORDER)
3008 bool mDrawBorderRight = true; // Display the top border (only applicable if borderstyle != eBS_NOBORDER)
3009
3011
3012 // Writes text at a row & column
3013 void drawLabel(int pRow, int pCol, const std::string& pLabel);
3014
3015 // Returns the largest subwindow height (or 0 if there are none).
3016 inline int maxSubwindowHeight() const;
3017
3018 // Combines all the messages lines into one
3019 // string.
3020 void combineMessageLines(std::string& message);
3021
3022 // Returns whether or not a cxWindow exists in mSubWindows.
3023 // Parameters:
3024 // pWindow: A cxWindow pointer to see if exists in mSubWindows
3025 inline bool subWindowExists(cxWindow *pWindow) const;
3026
3027 // Helper method for the constructors - Checks the parent
3028 // window pointer and adds this window to the parent (might
3029 // have to call a different method if the parent window is
3030 // a cxPanel)
3031 void addToParentWindow(cxWindow *pParentWindow);
3032
3033 // Writes strings to a border, where the strings are mapped to
3034 // horizontal positions. This is a helper for writing multiple
3035 // strings in the top/bottom border.
3036 // Parameters:
3037 // pStrings: This maps strings to their horizontal positions
3038 // pVPos: This is the vertical position in the window of where
3039 // the strings will be written (this will probably be
3040 // the top or bottom border position).
3041 // pItem: The item type of the text, for applying the attributes.
3042 // pTextColorPair: The color to apply to the text
3043 void writeBorderStrings(const std::map<int, std::string>& pStrings, int pVPos,
3044 e_WidgetItems pItem, short pTextColorPair);
3045
3046 // This is a helper for the destructor - It returns whether or not any
3047 // of the subwindows has this window as its parent.
3048 inline bool anySubwinHasThisParent();
3049
3050}; // end of class cxWindow
3051
3052
3053} // namespace cx
3054
3055#endif
The base class for windowing classes in the cxWidgets.
Definition cxObject.h:41
Represents a text-based window on the screen. Can contain a title, status, and a message to appear wi...
Definition cxWindow.h:195
void freeWindow()
Frees the memory used by the ncurses window and.
Definition cxWindow.cpp:5403
cxWindowPtrContainer::const_iterator subWindows_begin() const
Returns a const iterator to the first subwindow.
Definition cxWindow.cpp:6168
virtual e_cxColors getItemColor(e_WidgetItems pItem) const
Returns the color of one of the items in a window.
Definition cxWindow.cpp:4121
virtual void unSetFocusColors()
Disables focus for this window and unhighlights the message.
Definition cxWindow.cpp:1657
cxWindowPtrContainer::const_iterator subWindows_end() const
Returns a const iterator to the one past the last subwindow.
Definition cxWindow.cpp:6173
virtual bool pointIsInWindow(int pY, int pX) const
Returns whether a screen location is in the window (including.
Definition cxWindow.cpp:1991
virtual bool addQuitKey(int pKey, bool pRunOnLeaveFunction=true, bool pOverride=false)
Adds a key that will cause the window to quit its input loop.
Definition cxWindow.cpp:3267
virtual int bottom() const
Returns the bottom row of the window.
Definition cxWindow.cpp:1929
virtual bool onLeaveFunctionEnabled() const
Returns whether or not the onLeave function is set to run.
Definition cxWindow.cpp:2556
virtual void getExitKeyStrings(std::vector< std::string > &pKeys) const
Populates a collection of strings representing the keys.
Definition cxWindow.cpp:3400
bool mouseButton1DoubleClicked() const
Returns whether or not the first mouse button was double-clicked.
Definition cxWindow.cpp:3935
std::map< int, std::shared_ptr< cxFunction > > mMouseFunctions
Definition cxWindow.h:2679
virtual void getFunctionKeyStrings(std::vector< std::string > &pKeys) const
Populates a collection of strings representing the keys.
Definition cxWindow.cpp:4199
virtual void removeStatusStrings()
Removes all status strings.
Definition cxWindow.cpp:3258
virtual void setExitOnMouseOutside(bool pExitOnMouseOutside)
Sets whether the window should exit its modal input loop.
Definition cxWindow.cpp:2318
virtual void getQuitKeyStrings(std::vector< std::string > &pKeys) const
Populates a collection of strings representing the keys.
Definition cxWindow.cpp:3377
virtual void setTitle(const std::string &pTitle, bool pRefreshTitle=true)
Setter for the title text - This sets the first string in the.
Definition cxWindow.cpp:925
virtual void addMessageLineAbove(const std::string &pLine)
Adds a line to the message to be displayed in the window,.
Definition cxWindow.cpp:1105
bool onFocusFunctionIsSet() const
Returns whether or not the onFocus function is set (if.
Definition cxWindow.cpp:6188
bool mouseButton1Released() const
Returns whether or not the first mouse button was released.
Definition cxWindow.cpp:3913
virtual void exitNow()
This is mainly for deriving classes. It tells the object.
Definition cxWindow.cpp:3362
virtual std::map< int, std::string > getStatusStrings() const
Returns the map of status strings for the window.
Definition cxWindow.cpp:3219
virtual bool handleFunctionForLastMouseState(bool *pFunctionExists=nullptr, bool *pRunOnLeaveFunction=nullptr)
Looks for a function tied to the last mouse state captured.
Definition cxWindow.cpp:5317
void setKeyFunctions(const cxWindow &pWindow)
Returns whether or not a mouse event location is within.
Definition cxWindow.cpp:5768
virtual void setHotkeyHighlighting(bool pHotkeyHighlighting)
Enables/disables the use of hotkey attributes when writing the message.
Definition cxWindow.cpp:2262
virtual void getRect(int &pTop, int &pLeft, int &pBottom, int &pRight)
Returns the coordinates of the rectangle defining the window.
Definition cxWindow.cpp:1983
virtual bool addStatusString(int pHPos, const std::string &pStr, bool pRefreshStatus=false)
Adds/sets a string to appear in the status line at.
Definition cxWindow.cpp:3179
virtual const std::shared_ptr< cxFunction > & getOnLeaveFunction() const
Accessor for the onLeave function.
Definition cxWindow.cpp:2566
virtual int width() const
Returns the width of the window.
Definition cxWindow.cpp:1961
virtual void addMessageLinesBelow(const std::list< std::string > &pLines)
Adds lines to the message below the current message text.
virtual void addMessageLineBelow(const std::string &pLine)
Adds a line to the message to be displayed in the window,.
Definition cxWindow.cpp:1082
virtual void clearMouseFunction(int pMouseState)
Removes a function pointer for a mouse event so that it will.
Definition cxWindow.cpp:3036
bool mouseEvtWasButtonEvt() const
Returns whether or not the mouse event read in mMouse was.
Definition cxWindow.cpp:5730
virtual void drawMessage()
Writes the message text (in the area within the borders)
Definition cxWindow.cpp:3517
virtual void setReturnCode(const long &pReturnCode)
Explicitly sets the member return code for the window.
Definition cxWindow.cpp:3699
virtual cxWindow * getParent() const
Returns a pointer to the parent window.
Definition cxWindow.cpp:2037
messageLineContainer mMessageLines
Contains the text to be shown inside the window (note: the.
Definition cxWindow.h:2614
virtual void setStatusStrings(const std::map< int, std::string > &pStatusStrings)
Sets all the status strings via a map of horizontal.
Definition cxWindow.cpp:3229
std::map< int, bool > mExitKeys
Definition cxWindow.h:2685
bool mouseButton2Clicked() const
Returns whether or not the second mouse button was clicked.
Definition cxWindow.cpp:3946
virtual bool getShowSelfBeforeSubwins() const
Returns whether or not the window will show itself before.
Definition cxWindow.cpp:3081
std::string getMouseStateStr() const
Returns a string version of the current mouse state as it was.
Definition cxWindow.cpp:4102
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.
Definition cxWindow.cpp:4511
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.
eVPosition getVerticalMessageAlignment() const
Accessor for the vertical message text alignment.
Definition cxWindow.cpp:1236
std::string getMessage() const
Returns the message that appears in the window, concatenating all message lines together.
Definition cxWindow.cpp:1046
std::string getString(int pRow, int pCol, int pNumber)
Get the contents of a portion of the window. (for debugging/testing)
Definition cxWindow.cpp:4013
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.
Definition cxWindow.cpp:5173
void setHorizStatusAlignment(eHPosition pHAlignment)
Sets the horizontal alignment of the status text.
Definition cxWindow.cpp:1204
std::map< std::pair< int, int >, attr_t > mSpecialCharAttrs
Attributes for the "special" characters (which are added to.
Definition cxWindow.h:2650
virtual void removeTitleString(int pHPos)
Removes a title string at a given horizontal position.
Definition cxWindow.cpp:3154
virtual void removeAttr(e_WidgetItems pItem, attr_t pAttr)
Removes an ncurses attribute from one of the item lists.
Definition cxWindow.cpp:4300
virtual void setAttr(e_WidgetItems pItem, attr_t pAttr)
Sets the ncurses attribute to use for one of the items in the.
Definition cxWindow.cpp:4259
bool getLeaveNow() const
Returns whether or not something told the window to leave now.
Definition cxWindow.cpp:3788
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class. This is overridden.
Definition cxWindow.cpp:3783
virtual int right() const
Returns the right column of the window.
Definition cxWindow.cpp:1950
virtual void removeSpecialChar(int pY, int pX)
Removes a character from the set of special characters (by.
Definition cxWindow.cpp:4071
virtual bool lastKeyWasMouseEvt() const
Returns whether or not the last keypress was a mouse event.
Definition cxWindow.cpp:2340
std::set< attr_t > mStatusAttrs
Status attributes.
Definition cxWindow.h:2635
virtual bool isOnTop() const
Returns whether the window is on top of all other windows.
Definition cxWindow.cpp:1705
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.
Definition cxWindow.cpp:2248
virtual void bringToBottom(bool pRefresh=false)
Puts the window on the bottom of all other windows.
Definition cxWindow.cpp:1695
virtual bool hasAttr(e_WidgetItems pItem, attr_t pAttr)
Returns whether an attribute is set for a widget item.
Definition cxWindow.cpp:3774
std::map< std::pair< int, int >, chtype > mSpecialChars
Contains "special" characters which are added to the window.
Definition cxWindow.h:2622
std::set< attr_t > mTitleAttrs
Title attributes.
Definition cxWindow.h:2631
std::map< int, std::shared_ptr< cxFunction > >::iterator keyFunctions_end()
Returns an end iterator to the map of cxFunction pointers.
Definition cxWindow.cpp:4194
virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh=true)
Changes the window's width and height. The window's upper-left.
Definition cxWindow.cpp:4415
bool getHotkeyHighlighting() const
Returns whether hotkey attributes are used when writing the message.
Definition cxWindow.cpp:2283
virtual void centerVert(bool pRefresh=true)
Centers the window vertically on the screen.
Definition cxWindow.cpp:856
virtual void addSubwindow(cxWindow *pSubWindow)
Adds a subwindow to the window. Subwindows of a.
Definition cxWindow.cpp:4873
void setFocusFunctions(const cxWindow &pWindow)
Re-sets the onFocus and onLeave functions from another.
Definition cxWindow.cpp:5973
virtual void clearKeyFunctionByPtr(funcPtr4 pFunction)
Removes a keypress function pointer.
Definition cxWindow.cpp:2783
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.
virtual void clearKeyFunction(int pKey)
Removes a function pointer for a keypress so that it will no.
Definition cxWindow.cpp:2749
virtual void mouseButton1Click(int pY, int pX)
Tells the window that mouse button 1 was clicked at a certain.
Definition cxWindow.cpp:3979
virtual bool hasExitKey(int pKey) const
Returns whether or not a key exists in the.
Definition cxWindow.cpp:3328
virtual int left() const
Returns the left column of the window.
Definition cxWindow.cpp:1935
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.
virtual void addMessageLinesAbove(const std::deque< std::string > &pLines)
Adds lines to the message above the current message text.
std::map< int, std::shared_ptr< cxFunction > >::iterator keyFunctions_begin()
Returns a begin iterator to the map of cxFunction pointers.
Definition cxWindow.cpp:4189
eHPosition mHorizTitleAlignment
Definition cxWindow.h:2658
eHPosition getHorizStatusAlignment() const
Accessor for the horizontal status text alignment.
Definition cxWindow.cpp:1216
virtual void setShowSubwinsForward(bool pShowSubwinsForward)
Toggles the order in which subwindows will be shown.
Definition cxWindow.cpp:3066
virtual void addMessageLinesBelow(const std::deque< std::string > &pLines)
Adds lines to the message below the current message text.
short mBorderColorPair
Definition cxWindow.h:2656
virtual void setOnLeaveFunction(const std::shared_ptr< cxFunction > &pFunction)
Sets the window's "on leave" function.
Definition cxWindow.cpp:2420
virtual void setMessageLines(const std::list< std::string > &pLines)
Sets the message lines in the window.
virtual std::string getExitKeyListString() const
Returns a string containing a comma-separated list of the.
Definition cxWindow.cpp:3410
bool titleWillDraw() const
Returns whether the title will draw or not.
Definition cxWindow.cpp:3453
virtual std::string getStatusString(int pHPos) const
Returns the status string set at a given horizontal position.
Definition cxWindow.cpp:3203
virtual bool pointIsInTitle(int pY, int pX) const
Returns whether a screen location is in the title of the window.
Definition cxWindow.cpp:1997
virtual std::string getTitle() const
Accessor for title text - Returns the first string in the.
Definition cxWindow.cpp:907
virtual std::map< int, std::string > getTitleStrings() const
Returns the map of title strings for the window.
Definition cxWindow.cpp:3131
virtual bool hasQuitKey(int pKey) const
Returns whether or not a key exists in the.
Definition cxWindow.cpp:3333
virtual std::string getTitleString(int pHPos) const
Returns the title string set at a given horizontal position.
Definition cxWindow.cpp:3115
cxWindow & operator=(const cxWindow &pThatWindow)
Assignment operator.
Definition cxWindow.cpp:2237
virtual bool isOnBottom() const
Returns whether the window is on the bottom of all other windows.
Definition cxWindow.cpp:1713
virtual void getStatusStrings(std::map< int, std::string > &pStatusStrings) const
Returns the map of status strings for the window (using an.
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.
cxWindowPtrContainer::const_reverse_iterator subWindows_rend() const
Returns a const reverse end iterator for the subwindow collection.
Definition cxWindow.cpp:6183
virtual void mouseButton2Click(int pY, int pX)
Tells the window that mouse button 2 was clicked at a certain.
Definition cxWindow.cpp:3988
void setHorizMessageAlignment(eHPosition pHAlignment)
Sets the horizontal alignment of the message text.
Definition cxWindow.cpp:1193
bool mouseButton3Clicked() const
Returns whether or not the second mouse button was clicked.
Definition cxWindow.cpp:3968
void setExtTitleWindow(cxWindow *pWindow, bool pRefreshTitle=true)
Sets an external cxWindow object to be used for the title, rather.
Definition cxWindow.cpp:1241
bool mouseButton1Clicked() const
Returns whether or not the first mouse button was clicked.
Definition cxWindow.cpp:3924
cxWindowPtrContainer::const_reverse_iterator subWindows_rbegin() const
Returns a const reverse begin iterator for the subwindow collection.
Definition cxWindow.cpp:6178
virtual void setStatusColor(e_cxColors pColor)
Sets the color of the status line at bottom of window.
Definition cxWindow.cpp:3724
virtual void enableAttrs(WINDOW *pWin, e_WidgetItems pItem)
Enables the attributes for one of the m*Attrs sets for an ncurses window.
Definition cxWindow.cpp:4917
virtual bool getExitOnMouseOutside() const
Returns whether the window exits its modal input loop when.
Definition cxWindow.cpp:2313
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.
void setSubWinMessage(const std::string &pTitle, const std::string &pMessage)
Sets the message of one of the subwindows (by title).
virtual int centerCol() const
Returns the center column of the window.
Definition cxWindow.cpp:1944
bool mDrawTitle
Definition cxWindow.h:2664
virtual void setTitleColor(e_cxColors pColor)
Sets the title color.
Definition cxWindow.cpp:3714
virtual bool modalGetsKeypress() const
Returns whether or not a call to showModal() will wait for a.
Definition cxWindow.cpp:1624
virtual long show(bool pBringToTop=false, bool pShowSubwindows=true)
Shows the window.
Definition cxWindow.cpp:1386
virtual bool runOnLeaveFunction(std::string *pFunctionRetval=nullptr)
Runs the onLeave function, if it's set. However, if the last.
Definition cxWindow.cpp:2487
virtual void addMessageLinesAbove(const std::list< std::string > &pLines)
Adds lines to the message above the current message text.
virtual void setMessage(const std::string &pMessage)
Sets the text that appears within the window.
Definition cxWindow.cpp:1058
virtual void drawSpecialChars()
Writes the set of "special" characters to the window.
Definition cxWindow.cpp:3657
virtual void setStatus(const std::string &pStatus, bool pRefreshStatus=true)
Mutator for the status line text.
Definition cxWindow.cpp:994
virtual void mouseButton3Click(int pY, int pX)
Tells the window that mouse button 3 was clicked at a certain.
Definition cxWindow.cpp:3997
cxWindow * getExtTitleWindow() const
Accessor for the external title window pointer.
Definition cxWindow.cpp:1305
virtual void clearMouseFunctions()
Clears the list of external functions fired by mouse events.
Definition cxWindow.cpp:3046
std::shared_ptr< cxFunction2 > getKeyFunctionAsFunction2(int pKey) const
Returns a cxFunction pointer for a key, casted to a cxFunction2.
Definition cxWindow.cpp:3862
virtual void setLastKey(int pLastKey)
Sets the last keypress.
Definition cxWindow.cpp:2328
virtual void clearKeyFunctions()
Clears the list of external functions fired by hotkeys.
Definition cxWindow.cpp:2873
bool isHidden() const
Returns whether or not the window is hidden.
Definition cxWindow.cpp:1380
virtual void bringToTop(bool pRefresh=true)
Brings the window to the top.
Definition cxWindow.cpp:1685
std::shared_ptr< cxFunction > mOnFocusFunction
Definition cxWindow.h:2668
virtual bool addExitKey(int pKey, bool pRunOnLeaveFunction=true, bool pOverride=false)
Adds a key that will cause the window to quit its input loop.
Definition cxWindow.cpp:3298
virtual bool handleFunctionForLastKey(bool *pFunctionExists=nullptr, bool *pRunOnLeaveFunction=nullptr)
Looks for a function tied to the last keypress and.
Definition cxWindow.cpp:5272
bool parentIsCxNotebook() const
Returns whether or not the parent window, if there is one, is.
Definition cxWindow.cpp:6156
void setVerticalMessageAlignment(eVPosition pVAlignment)
Sets the vertical alignment of the message text.
Definition cxWindow.cpp:1231
void setSubWinMessage(unsigned pIndex, const std::string &pMessage)
Sets the message of one of the subwindows (by index).
virtual void removeQuitKeys()
Removes all quit keys.
Definition cxWindow.cpp:3293
virtual void addMessageLinesAbove(const std::vector< std::string > &pLines)
Adds lines to the message above the current message text.
virtual void setBorderStyle(eBorderStyle pBorderStyle)
Sets the border style.
Definition cxWindow.cpp:2022
virtual void quitNow()
This is mainly for deriving classes. This causes the object.
Definition cxWindow.cpp:3347
virtual void getAttrs(e_WidgetItems pItem, std::set< attr_t > &pAttrs) const
Returns the set of ncurses attributes for a given item.
Definition cxWindow.cpp:4380
virtual bool hasMouseFunction(int pMouseState) const
Returns whether an external function exists for a mouse event.
Definition cxWindow.cpp:3052
virtual void toggleBorderRight(bool pToggle)
Sets whether or not to display the right border.
Definition cxWindow.cpp:4058
virtual bool addTitleString(int pHPos, const std::string &pStr, bool pRefreshTitle=false)
Adds/sets a string to appear in the title at.
Definition cxWindow.cpp:3091
virtual void setChangeColorsOnFocus(bool pChangeColorsOnFocus)
Sets whether colors should change when focus.
Definition cxWindow.cpp:2364
virtual void removeSubWindow(const cxWindow *pSubWindow)
Removes a window from the subwindow list.
Definition cxWindow.cpp:4883
bool mouseButton1Pressed() const
Returns whether or not the first mouse button was pressed.
Definition cxWindow.cpp:3902
bool mIsModal
Definition cxWindow.h:2670
virtual std::map< int, bool > getExitKeys() const
Returns the keys that will make the window exit is input.
Definition cxWindow.cpp:3428
std::set< attr_t > mBorderAttrs
Border attributes.
Definition cxWindow.h:2639
virtual void addAttr(e_WidgetItems pItem, attr_t pAttr)
Adds an ncurses attribute to use for one of the items in the.
Definition cxWindow.cpp:4219
virtual std::string getQuitKeyListString() const
Returns a string containing a comma-separated list of the.
Definition cxWindow.cpp:3387
virtual std::map< int, bool > getQuitKeys() const
Returns the keys that will make the window quit its input.
Definition cxWindow.cpp:3423
virtual void setMessageLine(unsigned pIndex, const std::string &pLine)
Modifies one of the lines displayed in the window.
Definition cxWindow.cpp:1158
virtual bool getShowSubwinsForward() const
Returns whether or not the subwindows will be shown.
Definition cxWindow.cpp:3071
std::shared_ptr< cxFunction > getKeyFunction(int pKey) const
Returns a cxFunction pointer for a key.
Definition cxWindow.cpp:3829
void setExtStatusWindow(cxWindow *pWindow, bool pRefreshStatus=true)
Sets an external cxWindow object to be used for status, rather.
Definition cxWindow.cpp:1310
bool mDrawStatus
Definition cxWindow.h:2665
virtual bool onFocusFunctionEnabled() const
Returns whether or not the onFocus function is set to run.
Definition cxWindow.cpp:2551
bool mDrawMessage
Definition cxWindow.h:2663
virtual const std::shared_ptr< cxFunction > & getOnFocusFunction() const
Accessor for the onFocus function.
Definition cxWindow.cpp:2561
virtual void setTitleStrings(const std::map< int, std::string > &pTitleStrings)
Sets all the title strings via a map of horizontal.
Definition cxWindow.cpp:3141
std::set< attr_t > mHotkeyAttrs
Hotkey attributes.
Definition cxWindow.h:2643
virtual void getSize(int &pHeight, int &pWidth)
Returns the height & width of the window.
Definition cxWindow.cpp:2011
virtual int top() const
Returns the top row of the window.
Definition cxWindow.cpp:1914
virtual void removeAllSubwindows()
Removes all subwindow pointers.
Definition cxWindow.cpp:4853
virtual void drawTitle()
Writes the title line.
Definition cxWindow.cpp:3473
void touchWindow()
Marks the window's entire content as dirty so that the next.
Definition cxWindow.h:769
virtual bool isModal() const
Returns whether or not the window is currently.
Definition cxWindow.cpp:2571
virtual void getLastMouseEvtCoords(int &pY, int &pX)
Returns the coordinates of the last mouse event in the window.
Definition cxWindow.cpp:2349
void toggleTitle(bool pDrawTitle)
Sets whether or not to draw the title.
Definition cxWindow.cpp:3438
virtual void getFunctionKeys(std::vector< int > &pKeys) const
Populates a collection with integers representing the keys.
Definition cxWindow.cpp:4209
std::string getName() const
Definition cxWindow.cpp:3793
virtual void disableAttrs(WINDOW *pWin, e_WidgetItems pItem)
Disables the attributes for one of the m*Attrs sets for an ncurses window.
Definition cxWindow.cpp:4974
std::set< attr_t > mMessageAttrs
Message attributes.
Definition cxWindow.h:2627
eHPosition getHorizMessageAlignment() const
Accessor for the horizontal message text alignment.
Definition cxWindow.cpp:1199
virtual void setDisableCursorOnShow(bool pDisableCursorOnShow)
Sets whether the window should disable the cursor.
Definition cxWindow.cpp:2303
virtual int height() const
Returns the height of the window.
Definition cxWindow.cpp:1975
virtual bool isEnabled() const
Returns whether or not the window is enabled.
Definition cxWindow.cpp:2288
virtual void erase(bool pEraseSubwindows=true)
Erases the window.
Definition cxWindow.cpp:1665
virtual void dump(std::string &pResult)
Returns a string containing all the characters.
Definition cxWindow.cpp:2104
virtual void toggleBorderTop(bool pToggle)
Sets whether or not to display the top border.
Definition cxWindow.cpp:4043
std::map< int, bool > mQuitKeys
Definition cxWindow.h:2684
virtual bool moveRelative(int pVerticalOffset, int pHorizOffset, bool pRefresh=true)
Changes the window's position via vertical & horizontal offsets.
Definition cxWindow.cpp:4473
virtual void removeQuitKey(int pKey)
Removes a quit key.
Definition cxWindow.cpp:3288
std::map< int, std::shared_ptr< cxFunction > > mKeyFunctions
Definition cxWindow.h:2676
virtual void setEnabled(bool pEnabled)
Enables or disables the window. If the window is.
Definition cxWindow.cpp:2293
virtual void clearSpecialChars()
Clears the collection of special characters.
Definition cxWindow.cpp:4078
void setHorizTitleAlignment(eHPosition pHAlignment)
Sets the horizontal alignment of the title text.
Definition cxWindow.cpp:1166
short mStatusColorPair
Definition cxWindow.h:2655
virtual bool setKeyFunction(int pKey, const std::shared_ptr< cxFunction > &pFunction)
Sets a function to be called when a key is pressed.
std::shared_ptr< cxFunction > mOnLeaveFunction
Definition cxWindow.h:2669
void toggleMessage(bool pDrawMessage)
Sets whether or not to draw the message area (the area within.
Definition cxWindow.cpp:3433
virtual bool functionExistsForLastMouseState() const
Returns whether an external function pointer exists for the.
Definition cxWindow.cpp:4084
virtual void drawBorder()
Draws a box for the window border.
Definition cxWindow.cpp:1908
virtual void setFocusColors()
Turns on the ncurses attribute A_REVERSE for the window to.
Definition cxWindow.cpp:1636
bool hasBorder() const
Does this window have a border?
Definition cxWindow.cpp:2032
virtual void toggleOnLeaveFunction(bool pRunOnLeave)
Sets whether or not the onLeave function should run.
Definition cxWindow.cpp:2546
virtual void setMessageLines(const std::deque< std::string > &pLines)
Sets the message lines in the window.
virtual long getReturnCode() const
Returns the return code set by the last call to.
Definition cxWindow.cpp:3086
bool parentIsCxPanel() const
Returns whether or not the parent window, if there is one, is.
Definition cxWindow.cpp:6132
virtual bool hasFocus() const
Returns true if window has focus, false otherwise.
Definition cxWindow.cpp:2017
bool onLeaveFunctionIsSet() const
Returns whether or not the onLeave function is set (if.
Definition cxWindow.cpp:6200
std::shared_ptr< cxFunction0 > getKeyFunctionAsFunction0(int pKey) const
Returns a cxFunction pointer for a key, casted to a cxFunction0.
Definition cxWindow.cpp:3842
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, 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.
virtual void getTitleStrings(std::map< int, std::string > &pTitleStrings) const
Returns the map of title strings for the window (using an.
void toggleStatus(bool pDrawStatus)
Sets whether or not to draw the status line.
Definition cxWindow.cpp:3443
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.
virtual void reCreatePanel()
Creates mPanel (by calling new_panel()), then sets up.
Definition cxWindow.cpp:5383
virtual void removeMessageLine(unsigned pIndex)
Removes a line from the text inside the window (by index).
Definition cxWindow.cpp:1150
virtual void setElementColor(short &pColorPair, attr_t &pElementAttr, e_cxColors pColor)
Sets the color (and attribute, if necessary) of a color element.
Definition cxWindow.cpp:4902
virtual void center(bool pRefresh=true)
Centers the window on the screen.
Definition cxWindow.cpp:901
eHPosition getHorizTitleAlignment() const
Accessor for the title text alignment.
Definition cxWindow.cpp:1178
virtual void setName(const std::string &pName)
Sets the name of the window. The name is an alternative means.
Definition cxWindow.cpp:3798
void toggleSpecialChars(bool pDrawSpecialChars)
Sets whether or not to draw the "special" characters (these are.
Definition cxWindow.cpp:3463
virtual void copyCxWinStuff(const cxWindow *pThatWindow, bool pRecreateWin=true)
Makes a copy of a cxWindow's member variables.
Definition cxWindow.cpp:5077
bool parentIsCxForm() const
Returns whether or not the parent window, if there is one, is.
Definition cxWindow.cpp:6144
virtual long setFocus(bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=true)
Alias for showModal()
Definition cxWindow.cpp:1631
virtual bool setMouseFunction(int pMouseState, const std::shared_ptr< cxFunction > &pFunction)
Sets a function to be called for a certain mouse state.
virtual bool getDisableCursorOnShow() const
Returns whether or not the window will disable.
Definition cxWindow.cpp:2308
virtual void hide(bool pHideSubwindows=true)
Hides the window.
Definition cxWindow.cpp:1775
virtual void toggleBorderBottom(bool pToggle)
Sets whether or not to display the bottom border.
Definition cxWindow.cpp:4048
eVPosition mVerticalMessageAlignment
Definition cxWindow.h:2661
std::shared_ptr< cxFunction4 > getKeyFunctionAsFunction4(int pKey) const
Returns a cxFunction pointer for a key, casted to a cxFunction4.
Definition cxWindow.cpp:3882
virtual bool move(int pNewRow, int pNewCol, bool pRefresh=true)
Changes the window's position, based on a new upper-left corner.
Definition cxWindow.cpp:4456
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.
Definition cxWindow.cpp:4063
virtual void toggleOnFocusFunction(bool pRunOnFocus)
Sets whether or not the onFocus function should run.
Definition cxWindow.cpp:2541
virtual void doMouseBehavior()
Triggers the window's mouse event behavior. This method can.
Definition cxWindow.cpp:3825
virtual int centerRow() const
Returns the center row of the window.
Definition cxWindow.cpp:1923
void setParent(cxWindow *pNewParent)
Changes the pointer to the parent window; changes the parent window.
Definition cxWindow.cpp:2043
virtual void alignHoriz(eHPosition pPosition, bool pRefresh=true)
Aligns the window horizontally on the screen.
Definition cxWindow.cpp:816
virtual void setMessageLines(const std::vector< std::string > &pLines)
Sets the message lines in the window.
virtual void toggleBorderLeft(bool pToggle)
Sets whether or not to display the left border.
Definition cxWindow.cpp:4053
virtual void setBorderColor(e_cxColors pColor)
Sets the color of the window border.
Definition cxWindow.cpp:3734
WINDOW * mWindow
Everything in the window is written here; this is an nCurses window structure.
Definition cxWindow.h:2607
virtual void removeExitKey(int pKey)
Removes an exit key.
Definition cxWindow.cpp:3318
unsigned numSubWindows()
Returns the number of subwindows in this window.
Definition cxWindow.cpp:4485
virtual void draw()
Fills the member ncurses window structure with the current.
Definition cxWindow.cpp:5686
virtual void removeStatusString(int pHPos)
Removes a status string at a given horizontal position.
Definition cxWindow.cpp:3242
virtual ~cxWindow()
Definition cxWindow.cpp:706
virtual bool isAbove(const cxWindow &pThatWindow) const
Returns whether the window is above another window.
Definition cxWindow.cpp:1721
virtual void alignVert(eVPosition pPosition, bool pRefresh=true)
Aligns the window vertically on the screen.
Definition cxWindow.cpp:861
eHPosition mHorizMessageAlignment
Definition cxWindow.h:2659
std::string getStatus() const
Accessor for the status line text.
Definition cxWindow.cpp:976
virtual void setColor(e_WidgetItems pItem, e_cxColors pColor)
Sets the color of one of the window items.
Definition cxWindow.cpp:3744
virtual void clear(bool pRefresh=false)
Clears the text from the window.
Definition cxWindow.cpp:3338
virtual void removeExitKeys()
Removes all exit keys.
Definition cxWindow.cpp:3323
int getMouseState() const
Returns the current mouse state as it was last captured by the.
Definition cxWindow.cpp:4093
virtual void setOnFocusFunction(const std::shared_ptr< cxFunction > &pFunction)
Sets the window's "on focus" function.
Definition cxWindow.cpp:2369
virtual bool hasKeyFunction(int pKey) const
Returns whether an external function exists for a keypress.
Definition cxWindow.cpp:2908
bool specialCharsWillDraw() const
Returns whether the "special" characters will be drawn or.
Definition cxWindow.cpp:3468
bool messageWillDraw() const
Returns whether the message will draw or not.
Definition cxWindow.cpp:3448
bool mouseButton2DoubleClicked() const
Returns whether or not the second mouse button was double-clicked.
Definition cxWindow.cpp:3957
virtual void setMessageColor(e_cxColors pColor)
Returns the message color.
Definition cxWindow.cpp:3704
virtual void setShowSelfBeforeSubwins(bool pShowSelfBeforeSubwins)
Sets whether the window will show itself before.
Definition cxWindow.cpp:3076
void info()
Display information about a window (for debugging/testing)
Definition cxWindow.cpp:4018
virtual long showModal(bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=true)
Shows the window and waits for input.
Definition cxWindow.cpp:1442
short mMessageColorPair
Definition cxWindow.h:2653
eHPosition mHorizStatusAlignment
Definition cxWindow.h:2660
eBorderStyle getBorderStyle() const
Returns the border style.
Definition cxWindow.cpp:2027
virtual void removeAttrs(e_WidgetItems pItem)
Removes all attributes for a given window item.
Definition cxWindow.cpp:4340
virtual void showSubwindows(bool pBringToTop=true, bool pShowSubwindows=true)
Shows the subwindows for the window.
Definition cxWindow.cpp:2215
bool mDrawSpecialChars
Definition cxWindow.h:2666
virtual void removeTitleStrings()
Removes all title strings.
Definition cxWindow.cpp:3170
cxWindow * getExtStatusWindow() const
Accessor for the external status window pointer.
Definition cxWindow.cpp:1375
virtual bool isBelow(const cxWindow &pThatWindow) const
Returns whether a window is below another window.
Definition cxWindow.cpp:1748
virtual bool runOnFocusFunction(std::string *pFunctionRetval=nullptr)
Runs the onFocus function, if it's set.
Definition cxWindow.cpp:2467
short mTitleColorPair
Definition cxWindow.h:2654
virtual void unhide(bool pUnhideSubwindows=true)
Un-hides the window.
Definition cxWindow.cpp:1796
virtual int getLastKey() const
Returns the last key pressed by the user (for showModal(), etc.)
Definition cxWindow.cpp:2323
virtual void drawStatus()
Writes the status line.
Definition cxWindow.cpp:3495
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.
Definition cxWindow.cpp:5027
virtual bool getChangeColorsOnFocus() const
Returns whether the window will change.
Definition cxWindow.cpp:2359
bool mouseEvtWasInWindow() const
Returns whether the current mouse information stored in the.
Definition cxWindow.cpp:3803
bool statusWillDraw() const
Returns whether the status line will draw or not.
Definition cxWindow.cpp:3458
virtual void centerHoriz(bool pRefresh=true)
Centers the window horizontally on the screen.
Definition cxWindow.cpp:811
bool mHotkeyHighlighting
Definition cxWindow.h:2688
virtual bool mouseEvtWasInTitle() const
Returns whether the current mouse information stored in the.
Definition cxWindow.cpp:3812
bool mLeaveNow
Definition cxWindow.h:2673
virtual void addMessageLinesBelow(const std::vector< std::string > &pLines)
Adds lines to the message below the current message text.
#define NOKEY
Definition cxKeyDefines.h:64
Defines an enumeration for the different cxWidgets items (title,.
#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::deque< std::string > messageLineContainer
Definition cxWindow.h:71
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
eVPosition
Definition cxPositions.h:26
@ eVP_TOP
Definition cxPositions.h:28
eBorderStyle
Definition cxBorderStyles.h:26
@ eBS_SINGLE_LINE
Definition cxBorderStyles.h:28
@ cxID_EXIT
Definition cxReturnCodes.h:30
std::vector< cxWindow * > cxWindowPtrContainer
Definition cxWindow.h:40
eHPosition
Definition cxPositions.h:16
@ eHP_LEFT
Definition cxPositions.h:18
e_cxColors
Definition cxColors.h:46
@ eBROWN_BLUE
Definition cxColors.h:91
@ eWHITE_BLUE
Definition cxColors.h:100
@ eGRAY_BLUE
Definition cxColors.h:99