Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / gtk / gtk_chrome_shrinkable_hbox.h
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.
4
5 #ifndef CHROME_BROWSER_UI_GTK_GTK_CHROME_SHRINKABLE_HBOX_H_
6 #define CHROME_BROWSER_UI_GTK_GTK_CHROME_SHRINKABLE_HBOX_H_
7
8 #include <gdk/gdk.h>
9 #include <gtk/gtk.h>
10
11 // A specialized container derived from GtkHBox, which can shrink or hide its
12 // children one by one to fit into its width.
13 //
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.
21
22 G_BEGIN_DECLS
23
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))
39
40 typedef struct _GtkChromeShrinkableHBox GtkChromeShrinkableHBox;
41 typedef struct _GtkChromeShrinkableHBoxClass GtkChromeShrinkableHBoxClass;
42
43 struct _GtkChromeShrinkableHBox {
44   // Parent class.
45   GtkHBox hbox;
46
47   gboolean hide_child_directly;
48
49   // Private
50   int children_width_requisition;
51 };
52
53 struct _GtkChromeShrinkableHBoxClass {
54   GtkHBoxClass parent_class;
55 };
56
57 GType gtk_chrome_shrinkable_hbox_get_type() G_GNUC_CONST;
58
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,
64                                           gboolean homogeneous,
65                                           gint spacing);
66
67 void gtk_chrome_shrinkable_hbox_set_hide_child_directly(
68     GtkChromeShrinkableHBox* box, gboolean hide_child_directly);
69
70 gboolean gtk_chrome_shrinkable_hbox_get_hide_child_directly(
71     GtkChromeShrinkableHBox* box);
72
73 void gtk_chrome_shrinkable_hbox_pack_start(GtkChromeShrinkableHBox* box,
74                                            GtkWidget* child,
75                                            guint padding);
76
77 void gtk_chrome_shrinkable_hbox_pack_end(GtkChromeShrinkableHBox* box,
78                                          GtkWidget* child,
79                                          guint padding);
80
81 gint gtk_chrome_shrinkable_hbox_get_visible_child_count(
82     GtkChromeShrinkableHBox* box);
83
84 G_END_DECLS
85
86 #endif  // CHROME_BROWSER_UI_GTK_GTK_CHROME_SHRINKABLE_HBOX_H_