1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_GTK_CHROME_SHRINKABLE_HBOX_H_
6 #define CHROME_BROWSER_UI_GTK_GTK_CHROME_SHRINKABLE_HBOX_H_
11 // A specialized container derived from GtkHBox, which can shrink or hide its
12 // children one by one to fit into its width.
14 // Limitations of this container:
15 // - All children should have the same pack type, otherwise they may be
16 // overlapped with each other.
17 // - All children must be packed with expand == false and fill == false,
18 // otherwise they may be overlapped with each other.
19 // - The visibility of a child is adjusted automatically according to the
20 // container's width. The child may not show or hide itself.
24 #define GTK_TYPE_CHROME_SHRINKABLE_HBOX \
25 (gtk_chrome_shrinkable_hbox_get_type())
26 #define GTK_CHROME_SHRINKABLE_HBOX(obj) \
27 (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_CHROME_SHRINKABLE_HBOX, \
28 GtkChromeShrinkableHBox))
29 #define GTK_CHROME_SHRINKABLE_HBOX_CLASS(klass) \
30 (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_CHROME_SHRINKABLE_HBOX, \
31 GtkChromeShrinkableHBoxClass))
32 #define GTK_IS_CHROME_SHRINKABLE_HBOX(obj) \
33 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_CHROME_SHRINKABLE_HBOX))
34 #define GTK_IS_CHROME_SHRINKABLE_HBOX_CLASS(klass) \
35 (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_CHROME_SHRINKABLE_HBOX))
36 #define GTK_CHROME_SHRINKABLE_HBOX_GET_CLASS(obj) \
37 (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_CHROME_SHRINKABLE_HBOX, \
38 GtkChromeShrinkableHBoxClass))
40 typedef struct _GtkChromeShrinkableHBox GtkChromeShrinkableHBox
;
41 typedef struct _GtkChromeShrinkableHBoxClass GtkChromeShrinkableHBoxClass
;
43 struct _GtkChromeShrinkableHBox
{
47 gboolean hide_child_directly
;
50 int children_width_requisition
;
53 struct _GtkChromeShrinkableHBoxClass
{
54 GtkHBoxClass parent_class
;
57 GType
gtk_chrome_shrinkable_hbox_get_type() G_GNUC_CONST
;
59 // Creates a new shrinkable hbox.
60 // If |hide_child_directly| is true then its child widgets will be hid directly
61 // if they are too wide to be fit into the hbox's width. Otherwise they will be
62 // shrunk first before being hid completely.
63 GtkWidget
* gtk_chrome_shrinkable_hbox_new(gboolean hide_child_directly
,
67 void gtk_chrome_shrinkable_hbox_set_hide_child_directly(
68 GtkChromeShrinkableHBox
* box
, gboolean hide_child_directly
);
70 gboolean
gtk_chrome_shrinkable_hbox_get_hide_child_directly(
71 GtkChromeShrinkableHBox
* box
);
73 void gtk_chrome_shrinkable_hbox_pack_start(GtkChromeShrinkableHBox
* box
,
77 void gtk_chrome_shrinkable_hbox_pack_end(GtkChromeShrinkableHBox
* box
,
81 gint
gtk_chrome_shrinkable_hbox_get_visible_child_count(
82 GtkChromeShrinkableHBox
* box
);
86 #endif // CHROME_BROWSER_UI_GTK_GTK_CHROME_SHRINKABLE_HBOX_H_