Update list of wide characters
[centerim5.git] / cppconsui / AbstractDialog.h
blob5d82716669d57e03b12c975a42badcd4cedbfab4
1 // Copyright (C) 2011-2015 Petr Pavlu <setup@dagobah.cz>
2 //
3 // This file is part of CenterIM.
4 //
5 // CenterIM is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // CenterIM is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
18 /// @file
19 /// AbstractDialog class.
20 ///
21 /// @ingroup cppconsui
23 #ifndef ABSTRACTDIALOG_H
24 #define ABSTRACTDIALOG_H
26 #define OK_BUTTON_TEXT _("Ok")
27 #define CANCEL_BUTTON_TEXT _("Cancel")
28 #define YES_BUTTON_TEXT _("Yes")
29 #define NO_BUTTON_TEXT _("No")
31 #include "HorizontalLine.h"
32 #include "HorizontalListBox.h"
33 #include "ListBox.h"
34 #include "Window.h"
36 namespace CppConsUI {
38 class AbstractDialog : public Window {
39 public:
40 enum ResponseType {
41 RESPONSE_OK,
42 RESPONSE_CANCEL, ///< Cancel button or close dialog.
43 RESPONSE_YES,
44 RESPONSE_NO,
47 AbstractDialog(int x, int y, int w, int h, const char *title = nullptr);
48 explicit AbstractDialog(const char *title = nullptr);
49 virtual ~AbstractDialog() override {}
51 // FreeWindow
52 virtual void close() override;
54 virtual void addButton(const char *label, ResponseType response);
55 virtual void addSeparator();
56 virtual void response(ResponseType response_type);
58 protected:
59 ListBox *layout_;
60 HorizontalLine *separator_;
61 HorizontalListBox *buttons_;
63 virtual void initLayout();
64 virtual void emitResponse(ResponseType response) = 0;
65 virtual void onButtonResponse(Button &activator, ResponseType response_type);
67 private:
68 CONSUI_DISABLE_COPY(AbstractDialog);
71 } // namespace CppConsUI
73 #endif // ABSTRACTDIALOG_H
75 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: