cxWidgets 1.0
cxMessageDialog.h
Go to the documentation of this file.
1// Copyright (c) 2026 E. Oulashin
2#ifndef __CXMESSAGEDIALOG_H__
3#define __CXMESSAGEDIALOG_H__
4
5// Copyright (c) 2005-2007 Michael H. Kinney
6
7#include "cxDialog.h"
8#include "cxButton.h"
10#include <string>
11#include <memory>
12
13namespace cx {
14
15#define OKBTN_HEIGHT 3
16#define OKBTN_WIDTH 4
17#define CANCELBTN_HEIGHT 3
18#define CANCELBTN_WIDTH 8
19#define YESBTN_HEIGHT 3
20#define YESBTN_WIDTH 5
21#define NOBTN_HEIGHT 3
22#define NOBTN_WIDTH 4
23
29{
30
31 public:
44 explicit cxMessageDialog(cxWindow *pParentWindow = nullptr, int pRow = 0,
45 int pCol = 0, int pHeight = DEFAULT_HEIGHT,
46 int pWidth = DEFAULT_WIDTH,
47 const std::string& pTitle = "",
48 const std::string& pMessage = "",
49 long pStyle = cxOK|cxCANCEL,
50 const std::string& pStatus = "");
51
59 cxMessageDialog(cxWindow *pParentWindow, const std::string& pTitle, const std::string& pMessage);
60
70 cxMessageDialog(cxWindow *pParentWindow, const std::string& pTitle, const std::string& pMessage, int pHeight, int pWidth);
71
76 cxMessageDialog(const cxMessageDialog& pThatDialog);
77
81 virtual ~cxMessageDialog();
82
96 virtual long showModal(bool pShowSelf = true, bool pBringToTop = true,
97 bool pShowSubwindows = true) override;
98
104 virtual void hide(bool pHideSubwindows = true) override;
105
111 virtual void unhide(bool pUnhideSubwindows = true) override;
112
121 virtual bool move(int pNewRow, int pNewCol, bool pRefresh = true) override;
122
127 virtual std::shared_ptr<cxButton> getOKButton() const { return(mOKBtn); }
128
133 virtual std::shared_ptr<cxButton> getCancelButton() const { return(mCancelBtn); }
134
135 // Overridden from cxWindow so that this function doesn't get hidden
136 virtual long setFocus(bool pShowSelf = true, bool pBringToTop = true, bool pShowSubwindows = true) override;
137
143 void setFocus(const std::shared_ptr<cxButton>& pButton, bool pShow=true);
144
152 virtual std::string cxTypeStr() const override;
153
154 protected:
155 // Handles the input loop. Returns the return code as a result of
156 // the user's interaction.
157 long doInputLoop();
158
159 private:
160 //cxButton *mOKBtn = nullptr; // OK/Yes button
161 //cxButton *mCancelBtn = nullptr; // Cancel/No button
162 std::shared_ptr<cxButton> mOKBtn; // OK/Yes button
163 std::shared_ptr<cxButton> mCancelBtn; // Cancel/No button
164
165 // Dis-allow show() for this class
166 virtual long show(bool pBringToTop = false, bool pShowSubwindows = true) override
167 {
168 return(showModal(true, pBringToTop, pShowSubwindows));
169 }
170
171}; // end of class cxMessageDialog
172
173} // namespace cx
174
175#endif
Represents a dialog window on the screen (i.e., something to be shown.
Definition cxDialog.h:20
Represents a dialog box with "OK" and/or "Cancel".
Definition cxMessageDialog.h:29
virtual long setFocus(bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=true) override
Alias for showModal()
Definition cxMessageDialog.cpp:304
long doInputLoop()
Definition cxMessageDialog.cpp:360
cxMessageDialog(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="", long pStyle=cxOK|cxCANCEL, const std::string &pStatus="")
virtual ~cxMessageDialog()
Definition cxMessageDialog.cpp:195
virtual long showModal(bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=true) override
Shows the dialog, waits for input, and returns the code.
Definition cxMessageDialog.cpp:199
virtual void unhide(bool pUnhideSubwindows=true) override
Definition cxMessageDialog.cpp:251
virtual void hide(bool pHideSubwindows=true) override
Definition cxMessageDialog.cpp:236
cxMessageDialog(cxWindow *pParentWindow, const std::string &pTitle, const std::string &pMessage)
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class. This can be used to.
Definition cxMessageDialog.cpp:353
virtual bool move(int pNewRow, int pNewCol, bool pRefresh=true) override
Changes the window's position, based on a new upper-left corner.
Definition cxMessageDialog.cpp:269
virtual std::shared_ptr< cxButton > getOKButton() const
get a pointer to the the OK/Yes button
Definition cxMessageDialog.h:127
virtual std::shared_ptr< cxButton > getCancelButton() const
get a pointer to the the Cancel/NO button
Definition cxMessageDialog.h:133
Represents a text-based window on the screen. Can contain a title, status, and a message to appear wi...
Definition cxWindow.h:195
#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
@ cxCANCEL
Definition cxMessageDialogStyles.h:17
@ cxOK
Definition cxMessageDialogStyles.h:15