Supporters update.
[dcpomatic.git] / src / wx / table_dialog.cc
1 /*
2     Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "static_text.h"
23 #include "table_dialog.h"
24 #include "wx_util.h"
25
26
27 TableDialog::TableDialog (wxWindow* parent, wxString title, int columns, int growable, bool cancel)
28         : wxDialog (parent, wxID_ANY, title)
29 {
30         _overall_sizer = new wxBoxSizer (wxVERTICAL);
31         SetSizer (_overall_sizer);
32
33         _table = new wxFlexGridSizer (columns, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
34         _table->AddGrowableCol (growable, 1);
35
36         _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
37
38         long int flags = wxOK;
39         if (cancel) {
40                 flags |= wxCANCEL;
41         }
42
43         auto buttons = CreateSeparatedButtonSizer (flags);
44         if (buttons) {
45                 _overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
46         }
47 }
48
49
50 void
51 TableDialog::layout ()
52 {
53         _overall_sizer->Layout ();
54         _overall_sizer->SetSizeHints (this);
55 }
56
57
58 wxStaticText *
59 #ifdef DCPOMATIC_OSX
60 TableDialog::add (wxString text, bool label, int flags)
61 #else
62 TableDialog::add (wxString text, bool, int flags)
63 #endif
64 {
65 #ifdef DCPOMATIC_OSX
66         if (label) {
67                 flags |= wxALIGN_RIGHT;
68                 text += wxT (":");
69         }
70 #endif
71         auto m = new StaticText (this, wxT (""));
72         m->SetLabelMarkup (text);
73         _table->Add (m, 0, flags, 6);
74         return m;
75 }
76
77
78 void
79 TableDialog::add_spacer ()
80 {
81         _table->AddSpacer (0);
82 }