1 // Copyright (C) 2011-2015 Petr Pavlu <setup@dagobah.cz>
3 // This file is part of CenterIM.
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.
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/>.
19 /// AbstractDialog class implementation.
21 /// @ingroup cppconsui
23 #include "AbstractDialog.h"
27 AbstractDialog::AbstractDialog(int x
, int y
, int w
, int h
, const char *title
)
28 : Window(x
, y
, w
, h
, title
, TYPE_TOP
)
33 AbstractDialog::AbstractDialog(const char *title
)
34 : Window(10, 10, 60, 12, title
, TYPE_TOP
)
39 void AbstractDialog::close()
41 response(RESPONSE_CANCEL
);
44 void AbstractDialog::addButton(
45 const char *text
, AbstractDialog::ResponseType response
)
49 sigc::mem_fun(this, &AbstractDialog::onButtonResponse
), response
));
52 void AbstractDialog::addSeparator()
54 buttons_
->appendSeparator();
57 void AbstractDialog::response(ResponseType response_type
)
59 emitResponse(response_type
);
63 void AbstractDialog::initLayout()
65 layout_
= new ListBox(AUTOSIZE
, AUTOSIZE
);
66 addWidget(*layout_
, 1, 1);
68 separator_
= new HorizontalLine(AUTOSIZE
);
69 layout_
->appendWidget(*separator_
);
70 buttons_
= new HorizontalListBox(AUTOSIZE
, 1);
71 layout_
->appendWidget(*buttons_
);
74 void AbstractDialog::onButtonResponse(
75 Button
& /*activator*/, ResponseType response_type
)
77 response(response_type
);
80 } // namespace CppConsUI
82 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: