Debian Codegraph @

plugins/dm.gui/TextViewInfoDialog.h

raw
1 #pragma once
2
3 #include "wxutil/dialog/DialogBase.h"
4
5 #include <wx/textctrl.h>
6 #include <wx/sizer.h>
7
8 namespace ui
9 {
10
11 ///////////////////////////// TextViewInfoDialog:
12 // Small Info-Dialog showing text in a scrolled, non-editable textview and an ok button.
13 class TextViewInfoDialog :
14 public wxutil::DialogBase
15 {
16 private:
17 wxTextCtrl* _text;
18
19 public:
20 TextViewInfoDialog(const std::string& title, const std::string& text,
21 wxWindow* parent = NULL,
22 int win_width = 650, int win_height = 500) :
23 DialogBase(title),
24 _text(new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition,
25 wxDefaultSize, wxTE_LEFT | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP))
26 {
27 SetSize(win_width, win_height);
28
29 // Add a vbox for the dialog elements
30 SetSizer(new wxBoxSizer(wxVERTICAL));
31
32 // Add a vbox for the dialog elements
33 wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
34 GetSizer()->Add(vbox, 1, wxEXPAND | wxALL, 12);
35
36 vbox->Add(_text, 1, wxEXPAND | wxBOTTOM, 6);
37 vbox->Add(CreateStdDialogButtonSizer(wxOK), 0, wxALIGN_RIGHT);
38
39 _text->SetValue(text);
40
41 CenterOnParent();
42 }
43
44 static void Show(const std::string& title, const std::string& text, wxWindow* parent = NULL)
45 {
46 TextViewInfoDialog* dialog = new TextViewInfoDialog(title, text, parent);
47
48 dialog->ShowModal();
49 dialog->Destroy();
50 }
51 };
52
53 } // namespace