gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
MessageDialog.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #ifndef MESSAGEDIALOG_H_
18 #define MESSAGEDIALOG_H_
19 
20 #include "Container.H"
21 #include "Pango.H"
22 
32 class MessageDialog : public Container {
33 public:
41  MessageDialog(GtkWidget *parent, GtkDialogFlags flags, GtkMessageType whichType, GtkButtonsType buttonsType, const char *text) {
42  widget=gtk_message_dialog_new(GTK_WINDOW(parent), flags, whichType, buttonsType, "%s", text);
43  }
44 
52  MessageDialog(GtkWidget *parent, GtkDialogFlags flags, GtkMessageType whichType, GtkButtonsType buttonsType, string &text) {
53  widget=gtk_message_dialog_new(GTK_WINDOW(parent), flags, whichType, buttonsType, "%s", text.c_str());
54  }
55 
63  MessageDialog(GtkWidget *parent, GtkDialogFlags flags, GtkMessageType whichType, GtkButtonsType buttonsType, Pango &pango) {
64  // the following has tring literal warning messages
65  //widget=gtk_message_dialog_new_with_markup(GTK_WINDOW(parent), flags, whichType, buttonsType, pango.getMarkup().c_str());
66  widget=gtk_message_dialog_new(GTK_WINDOW(parent), flags, whichType, buttonsType, NULL);
67  gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(widget), pango.getMarkup().c_str());
68  }
69 
72  virtual ~MessageDialog() {
73  gtk_widget_destroy(widget);
74  }
75 
80  MessageDialog& operator<<(char *str) {
81  return operator<<(string(str));
82  }
83 
88  MessageDialog& operator<<(string str) {
89  Pango pango;
90  pango<<str;
91  return operator<<(pango);
92  }
93 
99  gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(widget), pango.getMarkup().c_str());
100  cout<<"created"<<endl;
101  return *this;
102  }
103 
106  void run(void) {
107  gtk_dialog_run(GTK_DIALOG(widget));
108  }
109 
113  void title(char *text) {
114  string t(text);
115  title(t);
116  }
117 
121  void title(string &text) {
122  gtk_window_set_title(GTK_WINDOW(widget), text.c_str());
123  }
124 
125 };
126 
130 class MessageInfo : public MessageDialog {
131 public:
136  MessageInfo(GtkWidget *win, char *text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, text) {
137  }
141  MessageInfo(char *text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, text) {
142  }
143 
148  MessageInfo(GtkWidget *win, string text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, text) {
149  }
153  MessageInfo(string text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, text) {
154  }
155 
160  MessageInfo(GtkWidget *win, Pango &pango) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, pango) {
161  }
162 
166  MessageInfo(Pango &pango) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, pango) {
167  }
168 };
169 
173 class MessageError : public MessageDialog {
174 public:
179  MessageError(GtkWidget *win, char *text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text) {
180  }
184  MessageError(char *text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text) {
185  }
190  MessageError(GtkWidget *win, string text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text) {
191  }
195  MessageError(string text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text) {
196  }
201  MessageError(GtkWidget *win, Pango &pango) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, pango) {
202  }
206  MessageError(Pango &pango) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, pango) {
207  }
208 };
209 
214 public:
219  MessageQuestion(GtkWidget *win, char *text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, text) {
220  }
224  MessageQuestion(char *text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, text) {
225  }
230  MessageQuestion(GtkWidget *win, string text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, text) {
231  }
235  MessageQuestion(string text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, text) {
236  }
241  MessageQuestion(GtkWidget *win, Pango &pango) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, pango) {
242  }
246  MessageQuestion(Pango &pango) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, pango) {
247  }
248 };
249 
254 public:
259  MessageWarning(GtkWidget *win, string text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, text) {
260  }
264  MessageWarning(string text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, text) {
265  }
270  MessageWarning(GtkWidget *win, char *text) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, text) {
271  }
275  MessageWarning(char *text) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, text) {
276  }
281  MessageWarning(GtkWidget *win, Pango &pango) : MessageDialog(win, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, pango) {
282  }
286  MessageWarning(Pango &pango) : MessageDialog(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, pango) {
287  }
288 };
289 
290 #endif // MESSAGEDIALOG_H_
MessageQuestion(GtkWidget *win, char *text)
MessageWarning(GtkWidget *win, Pango &pango)
MessageDialog & operator<<(Pango &pango)
Definition: MessageDialog.H:98
MessageInfo(GtkWidget *win, char *text)
MessageDialog(GtkWidget *parent, GtkDialogFlags flags, GtkMessageType whichType, GtkButtonsType buttonsType, Pango &pango)
Definition: MessageDialog.H:63
MessageInfo(GtkWidget *win, string text)
MessageWarning(Pango &pango)
void title(string &text)
MessageError(GtkWidget *win, char *text)
MessageInfo(Pango &pango)
MessageWarning(char *text)
void title(char *text)
virtual ~MessageDialog()
Definition: MessageDialog.H:72
MessageInfo(GtkWidget *win, Pango &pango)
string & getMarkup(void)
Definition: Pango.H:155
MessageDialog(GtkWidget *parent, GtkDialogFlags flags, GtkMessageType whichType, GtkButtonsType buttonsType, const char *text)
Definition: MessageDialog.H:41
MessageError(Pango &pango)
MessageError(GtkWidget *win, string text)
MessageWarning(GtkWidget *win, string text)
MessageQuestion(string text)
MessageWarning(GtkWidget *win, char *text)
MessageQuestion(Pango &pango)
MessageQuestion(GtkWidget *win, string text)
Definition: Pango.H:102
MessageDialog & operator<<(char *str)
Definition: MessageDialog.H:80
MessageDialog(GtkWidget *parent, GtkDialogFlags flags, GtkMessageType whichType, GtkButtonsType buttonsType, string &text)
Definition: MessageDialog.H:52
MessageWarning(string text)
GtkWidget * widget
The container based widget.
Definition: Widget.H:33
void run(void)
MessageInfo(char *text)
MessageError(char *text)
MessageInfo(string text)
MessageError(string text)
MessageError(GtkWidget *win, Pango &pango)
MessageQuestion(GtkWidget *win, Pango &pango)
MessageQuestion(char *text)
MessageDialog & operator<<(string str)
Definition: MessageDialog.H:88
gtkIOStream: /tmp/gtkiostream/include/MessageDialog.H Source File
GTK+ IOStream  Beta