Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gtk / src / bin.hg
1 /* $Id: bin.hg,v 1.2 2003/03/03 07:49:05 murrayc Exp $ */
2
3 /* bin.h
4  * 
5  * Copyright (C) 1998-2002 The gtkmm Development Team
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #include <gtkmm/container.h>
23 _DEFS(gtkmm,gtk)
24 _PINCLUDE(gtkmm/private/container_p.h)
25
26
27 namespace Gtk
28 {
29
30 /** A container with just one child.
31  *
32  * This is an abstract base class from which all classes holding
33  * up to 1 widget inside of them derive.  It provides access to methods
34  * relevent to a single object, such as add_label, add_pixmap, etc.
35  *
36  * @ingroup Widgets
37  */
38 class Bin : public Container
39 {
40   _CLASS_GTKOBJECT(Bin,GtkBin,GTK_BIN,Gtk::Container,GtkContainer)
41 protected:
42   _CTOR_DEFAULT
43 public:
44   
45
46   // get_child() is a convenience function to get a c++ wrapper of
47   // the contained widget. It may return NULL if such an item is not
48   // available.
49   _MEMBER_GET_PTR(child, child, Widget*, GtkWidget*)
50
51   /** Remove the contained object
52    * Since this can only hold one object it is not necessary to
53    * specify which object to remove like other containers.
54    *
55    * When calling remove() on a Gtk::ScrolledWindow this might not remove the
56    * expected child directly, because Gtk::ScrolledWindow::add() sometimes creates a
57    * Gtk::ViewPort child and places the widget in that.
58    */
59   void remove();
60
61   //Convenience methods that don't correspond to GTK+ functions:
62
63   /** Add a Label object.
64    * This does not correspond to any GTK+ function and is provided purely for
65    * convenience.
66    * @param label The text for the label.
67    * @param mnemonic If <tt>true</tt>, characters preceded by an underscore 
68    * (_) will be underlined and used as a keyboard accelerator (shortcut).
69    * @param x_align The horizontal alignment of the text.  This ranges from 
70    * 0.0 (left aligned) to 1.0 (right aligned).
71    * @param y_align The vertical alignment of the text.  This ranges from 
72    * 0.0 (top aligned) to 1.0 (bottom aligned).
73    */
74   void add_label(const Glib::ustring& label, bool mnemonic = false,
75                  double x_align = 0.5, double y_align = 0.5);
76
77   /** Add a Label object.
78    * This does not correspond to any GTK+ function and is provided purely for
79    * convenience.
80    * @param label The label text.
81    * @param mnemonic If <tt>true</tt>, characters preceded by an underscore
82    * (_) will be underlined and used as a keyboard accelerator (shortcut).
83    * @param x_align The horizontal alignment of the text.  For possible 
84    * values, see Gtk::AlignmentEnum.
85    * @param y_align The vertical alignment of the text.  For possible 
86    * values, see Gtk::AlignmentEnum.
87    */
88   void add_label(const Glib::ustring& label, bool mnemonic,
89                  AlignmentEnum x_align, AlignmentEnum y_align = ALIGN_CENTER);
90
91   /** Add an Image object.
92    * This does not correspond to any GTK+ function and is provided purely for
93    * convenience.
94    * This will create, manage, add, and show a new Image to this Bin.
95    * @param pixmap A Glib::RefPtr to a Gdk::Pixmap.
96    * @param mask A Glib::RefPtr to a Gdk::Bitmap.
97    */
98   void add_pixmap(const Glib::RefPtr<Gdk::Pixmap>& pixmap,
99                   const Glib::RefPtr<Gdk::Bitmap>& mask);
100
101   /** Add Image and Label objects.
102    * This does not correspond to any GTK+ function and is provided purely for
103    * convenience.
104    * This will create, manage, add, and show a new Image and Label (within an 
105    * HBox) to this Bin.
106    * @param pixmap A Glib::RefPtr to a Gdk::Pixmap.
107    * @param mask A Glib::RefPtr to a Gdk::Bitmap.
108    * @param label The text for the label.
109    * @param x_align The horizontal alignment of the text in the label.
110    * @param y_align The vertical alignment of the text in the label.
111    */
112   void add_pixlabel(const Glib::RefPtr<Gdk::Pixmap>& pixmap,
113                     const Glib::RefPtr<Gdk::Bitmap>& mask,
114                     const Glib::ustring& label,
115                                 double x_align = 0.5, double y_align = 0.5);
116
117   /** Add Image and Label objects.
118    * This does not correspond to any GTK+ function and is provided purely for
119    * convenience.
120    * This will create, manage, add, and show a new Image and Label (within an 
121    * HBox) to this Bin.
122    * @param pixfile The path to a file to be displayed.
123    * @param label The text for the label.
124    * @param x_align The horizontal alignment of the text in the label.
125    * @param y_align The vertical alignment of the text in the label.
126    */
127   void add_pixlabel(const Glib::ustring& pixfile,
128                     const Glib::ustring& label,
129                                 double x_align = 0.5, double y_align = 0.5);
130 };
131
132 }  /* namespace Gtk */
133