Debian Codegraph @

gtk/src/bin.ccg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtk/gtk.h>
18 #include <gtkmm/adjustment.h>
19 #include <gtkmm/label.h>
20 #include <gtkmm/box.h>
21 #include <gtkmm/image.h>
22
23 namespace Gtk
24 {
25
26 void
27 Bin::remove()
28 {
29 auto child = get_child();
30 if (child)
31 Container::remove(*child);
32 }
33
34 _DEPRECATE_IFDEF_START
35 void
36 Bin::add_label(const Glib::ustring& str, bool mnemonic /* = false */,
37 double x_align /* = 0.5 */, double y_align /* = 0.5 */)
38 {
39 auto label = manage(new Label(str, x_align, y_align, mnemonic));
40 add(*label);
41
42 //This might not always be appropriate:
43 //because maybe the mnemonic widget should be another child widget.
44 //if(mnemonic)
45 //label->set_mnemonic_widget(*this);
46
47 label->show();
48 }
49 _DEPRECATE_IFDEF_END
50
51 void
52 Bin::add_label(const Glib::ustring& str, bool mnemonic,
53 Align x_align, Align y_align /* = ALIGN_CENTER */)
54 {
55 auto label = manage(new Label(str, x_align, y_align, mnemonic));
56 add(*label);
57 label->show();
58 }
59
60 _DEPRECATE_IFDEF_START
61 void
62 Bin::add_pixlabel(const std::string& pixfile,
63 const Glib::ustring& str,
64 double x_align /* = 0.5 */, double y_align /* = 0.5 */)
65 {
66 //Create Image and Label widgets:
67 auto pmap = manage(new Image(pixfile));
68 auto label = manage(new Label(str));
69 label->set_alignment (x_align, y_align);
70
71 //Put them in a Box:
72 auto hbox = manage(new Box(ORIENTATION_HORIZONTAL, 5));
73 hbox->pack_start(*pmap, PACK_SHRINK);
74 hbox->pack_start(*label);
75 hbox->show_all();
76
77 //And put that Box in this:
78 add(*hbox);
79 }
80 _DEPRECATE_IFDEF_END
81
82 void
83 Bin::add_pixlabel(const std::string& pixfile,
84 const Glib::ustring& str,
85 Align x_align, Align y_align /* = ALIGN_CENTER */)
86 {
87 //Create Image and Label widgets:
88 auto pmap = manage(new Image(pixfile));
89 auto label = manage(new Label(str, x_align, y_align));
90
91 //Put them in a Box:
92 auto hbox = manage(new Box(ORIENTATION_HORIZONTAL, 5));
93 hbox->pack_start(*pmap, PACK_SHRINK);
94 hbox->pack_start(*label);
95 hbox->show_all();
96
97 //And put that Box in this:
98 add(*hbox);
99 }
100
101 } //namespace Gtk