]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: msgdlg.h | |
e54c96f1 | 3 | // Purpose: interface of wxMessageDialog |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxMessageDialog | |
11 | @wxheader{msgdlg.h} | |
7c913512 | 12 | |
23324ae1 FM |
13 | This class represents a dialog that shows a single or multi-line message, |
14 | with a choice of OK, Yes, No and Cancel buttons. | |
7c913512 | 15 | |
23324ae1 FM |
16 | @library{wxcore} |
17 | @category{cmndlg} | |
7c913512 | 18 | |
e54c96f1 | 19 | @see @ref overview_wxmessagedialogoverview "wxMessageDialog overview" |
23324ae1 FM |
20 | */ |
21 | class wxMessageDialog : public wxDialog | |
22 | { | |
23 | public: | |
24 | /** | |
25 | Constructor. Use ShowModal() to show the dialog. | |
3c4f71cc | 26 | |
7c913512 | 27 | @param parent |
4cc4bfaf | 28 | Parent window. |
7c913512 | 29 | @param message |
4cc4bfaf | 30 | Message to show on the dialog. |
7c913512 | 31 | @param caption |
4cc4bfaf | 32 | The dialog caption. |
7c913512 | 33 | @param style |
4cc4bfaf | 34 | A dialog style (bitlist) containing flags chosen from the following: |
3c4f71cc | 35 | |
4cc4bfaf | 36 | wxOK |
3c4f71cc | 37 | |
4cc4bfaf | 38 | Show an OK button. |
3c4f71cc | 39 | |
4cc4bfaf | 40 | wxCANCEL |
3c4f71cc | 41 | |
4cc4bfaf | 42 | Show a Cancel button. |
3c4f71cc | 43 | |
4cc4bfaf | 44 | wxYES_NO |
3c4f71cc | 45 | |
4cc4bfaf | 46 | Show Yes and No buttons. |
3c4f71cc | 47 | |
4cc4bfaf | 48 | wxYES_DEFAULT |
3c4f71cc | 49 | |
4cc4bfaf | 50 | Used with wxYES_NO, makes Yes button the default - which is the default |
23324ae1 | 51 | behaviour. |
3c4f71cc | 52 | |
4cc4bfaf | 53 | wxNO_DEFAULT |
3c4f71cc | 54 | |
4cc4bfaf | 55 | Used with wxYES_NO, makes No button the default. |
3c4f71cc | 56 | |
4cc4bfaf | 57 | wxICON_EXCLAMATION |
3c4f71cc | 58 | |
4cc4bfaf | 59 | Shows an exclamation mark icon. |
3c4f71cc | 60 | |
4cc4bfaf | 61 | wxICON_HAND |
3c4f71cc | 62 | |
4cc4bfaf | 63 | Shows an error icon. |
3c4f71cc | 64 | |
4cc4bfaf | 65 | wxICON_ERROR |
3c4f71cc | 66 | |
4cc4bfaf | 67 | Shows an error icon - the same as wxICON_HAND. |
3c4f71cc | 68 | |
4cc4bfaf | 69 | wxICON_QUESTION |
3c4f71cc | 70 | |
4cc4bfaf | 71 | Shows a question mark icon. |
3c4f71cc | 72 | |
4cc4bfaf | 73 | wxICON_INFORMATION |
3c4f71cc | 74 | |
4cc4bfaf | 75 | Shows an information (i) icon. |
3c4f71cc | 76 | |
4cc4bfaf | 77 | wxSTAY_ON_TOP |
3c4f71cc | 78 | |
4cc4bfaf FM |
79 | The message box stays on top of all other window, even those of the other |
80 | applications (Windows only). | |
7c913512 | 81 | @param pos |
4cc4bfaf | 82 | Dialog position. Not Windows. |
23324ae1 FM |
83 | */ |
84 | wxMessageDialog(wxWindow* parent, const wxString& message, | |
85 | const wxString& caption = "Message box", | |
4cc4bfaf | 86 | long style = wxOK | wxCANCEL, |
23324ae1 FM |
87 | const wxPoint& pos = wxDefaultPosition); |
88 | ||
89 | /** | |
90 | Destructor. | |
91 | */ | |
92 | ~wxMessageDialog(); | |
93 | ||
94 | /** | |
95 | Sets the extended message for the dialog: this message is usually an extension | |
7c913512 | 96 | of the short message specified in the constructor or set with |
23324ae1 FM |
97 | SetMessage(). If it is set, the main message |
98 | appears highlighted -- if supported -- and this message appears beneath it in | |
99 | normal font. On the platforms which don't support extended messages, it is | |
100 | simply appended to the normal message with a new line separating them. | |
101 | */ | |
102 | void SetExtendedMessage(const wxString exMsg); | |
103 | ||
104 | /** | |
105 | Sets the message shown by the dialog. | |
106 | */ | |
107 | void SetMessage(const wxString msg); | |
108 | ||
109 | /** | |
110 | Overrides the default labels of the OK and Cancel buttons. | |
7c913512 | 111 | Please see the remarks in |
23324ae1 FM |
112 | SetYesNoLabels() documentation. |
113 | */ | |
114 | bool SetOKCancelLabels(const wxString ok, const wxString cancel); | |
115 | ||
116 | /** | |
117 | Overrides the default label of the OK button. | |
7c913512 | 118 | Please see the remarks in |
23324ae1 FM |
119 | SetYesNoLabels() documentation. |
120 | */ | |
121 | bool SetOKLabel(const wxString ok); | |
122 | ||
123 | /** | |
124 | Overrides the default labels of the Yes, No and Cancel buttons. | |
7c913512 | 125 | Please see the remarks in |
23324ae1 FM |
126 | SetYesNoLabels() documentation. |
127 | */ | |
128 | bool SetYesNoCancelLabels(const wxString yes, const wxString no, | |
129 | const wxString cancel); | |
130 | ||
131 | /** | |
132 | Overrides the default labels of the Yes and No buttons. | |
23324ae1 FM |
133 | Notice that this function is not currently available on all platforms, so it |
134 | may return @false to indicate that the labels couldn't be changed. If it | |
135 | returns @true (currently only under wxMac), the labels were set successfully. | |
136 | Typically, if the function was used successfully, the main dialog message may | |
137 | need to be changed, e.g.: | |
138 | */ | |
139 | bool SetYesNoLabels(const wxString yes, const wxString no); | |
140 | ||
141 | /** | |
142 | Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO. | |
143 | */ | |
144 | int ShowModal(); | |
145 | }; | |
146 | ||
147 | ||
e54c96f1 | 148 | |
23324ae1 FM |
149 | // ============================================================================ |
150 | // Global functions/macros | |
151 | // ============================================================================ | |
152 | ||
ba2874ff BP |
153 | /** @ingroup group_funcmacro_dialog */ |
154 | //@{ | |
155 | ||
23324ae1 | 156 | /** |
ba2874ff | 157 | General purpose message dialog. @c style may be a bit list of the |
23324ae1 | 158 | following identifiers: |
7c913512 | 159 | |
ba2874ff BP |
160 | @beginStyleTable |
161 | @style{wxYES_NO}: | |
162 | Puts Yes and No buttons on the message box. May be combined with | |
163 | wxCANCEL. | |
164 | @style{wxCANCEL}: | |
165 | Puts a Cancel button on the message box. May only be combined with | |
166 | wxYES_NO or wxOK. | |
167 | @style{wxOK}: | |
168 | Puts an Ok button on the message box. May be combined with wxCANCEL. | |
169 | @style{wxICON_EXCLAMATION}: | |
170 | Displays an exclamation mark symbol. | |
171 | @style{wxICON_HAND}: | |
172 | Displays an error symbol. | |
173 | @style{wxICON_ERROR}: | |
174 | Displays an error symbol - the same as wxICON_HAND. | |
175 | @style{wxICON_QUESTION}: | |
176 | Displays a question mark symbol. | |
177 | @style{wxICON_INFORMATION}: | |
178 | Displays an information symbol. | |
179 | ||
180 | The return value is one of: wxYES, wxNO, wxCANCEL, wxOK. For example: | |
4cc4bfaf | 181 | |
23324ae1 | 182 | @code |
ba2874ff BP |
183 | int answer = wxMessageBox("Quit program?", "Confirm", |
184 | wxYES_NO | wxCANCEL, main_frame); | |
185 | if (answer == wxYES) | |
186 | main_frame->Close(); | |
23324ae1 | 187 | @endcode |
7c913512 | 188 | |
ba2874ff BP |
189 | @a message may contain newline characters, in which case the message will |
190 | be split into separate lines, to cater for large messages. | |
191 | ||
192 | @header{wx/msgdlg.h} | |
23324ae1 FM |
193 | */ |
194 | int wxMessageBox(const wxString& message, | |
195 | const wxString& caption = "Message", | |
196 | int style = wxOK, | |
4cc4bfaf | 197 | wxWindow* parent = NULL, |
23324ae1 FM |
198 | int x = -1, int y = -1); |
199 | ||
ba2874ff BP |
200 | //@} |
201 |