]> git.karo-electronics.de Git - gbdfed.git/blob - labcon.h
Fixup several compile faults due to changes in recent distributions,
[gbdfed.git] / labcon.h
1 /*
2  * Copyright 2008 Department of Mathematical Sciences, New Mexico State University
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * DEPARTMENT OF MATHEMATICAL SCIENCES OR NEW MEXICO STATE UNIVERSITY BE
18  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #ifndef _h_labcon
23 #define _h_labcon
24
25 #include <gtk/gtkcontainer.h>
26 #include "gtkcompat.h"
27
28 G_BEGIN_DECLS
29
30 /*
31  * The LabCon (Labeled Container) widget. Created to provide a container
32  * that contains a label and a single child, and can be part of a group
33  * of other LabCon widgets. All members of the group have the same label
34  * width. The labels will be on the left or the right side of the child
35  * widget and can be aligned to the right, left, or center.
36  */
37
38 #define LABCON(obj) \
39       (G_TYPE_CHECK_INSTANCE_CAST(obj, labcon_get_type(), LabCon))
40 #define LABCON_CLASS(klass) \
41       (G_TYPE_CHECK_CLASS_CAST(klass, labcon_get_type(), LabConClass))
42
43 #define IS_LABCON(obj) \
44       (G_TYPE_CHECK_INSTANCE_TYPE(obj, labcon_get_type()))
45 #define IS_LABCON_CLASS(klass) \
46       (G_TYPE_CHECK_CLASS_TYPE(klass, labcon_get_type()))
47
48 #define LABCON_GET_CLASS(obj) \
49       (G_TYPE_INSTANCE_GET_CLASS(obj, labcon_get_type(), LabConClass))
50
51 typedef struct _LabCon      LabCon;
52 typedef struct _LabConClass LabConClass;
53
54 typedef enum {
55     LABCON_ALIGN_LEFT,
56     LABCON_ALIGN_RIGHT,
57     LABCON_ALIGN_CENTER
58 } LabConAlignment;
59
60 struct _LabCon {
61     GtkContainer container;
62
63     GtkWidget *image;
64     GtkWidget *label;
65     GtkWidget *child;
66
67     /*
68      * The pixbuf that will be shown as the image instead of a label.
69      */
70     const GdkPixbuf *pixbuf;
71
72     /*
73      * Spacing between the label and the child widget.
74      */
75     guint spacing;
76
77     /*
78      * Alignment.
79      */
80     LabConAlignment align;
81
82     /*
83      * Label positioning (GTK_POS_LEFT or GTK_POS_RIGHT).
84      */
85     GtkPositionType pos;
86
87     /*
88      * The current width all labels should be.
89      */
90     guint label_width;
91
92     /*
93      * All the widgets that should have the same width labels.
94      */
95     GtkWidget *leader;
96     GtkWidget **group;
97     guint group_size;
98     guint group_used;
99 };
100
101 struct _LabConClass {
102     GtkContainerClass parent_class;
103 };
104
105 /**********************************************************************
106  *
107  * API functions.
108  *
109  **********************************************************************/
110
111 extern GType labcon_get_type(void);
112
113 extern GtkWidget *labcon_new_label(const gchar *label, LabConAlignment align,
114                                    GtkPositionType pos, guint spacing,
115                                    GtkWidget *child, GtkWidget *group);
116
117 extern GtkWidget *labcon_new_label_defaults(const gchar *label,
118                                             GtkWidget *child,
119                                             GtkWidget *group);
120
121 extern GtkWidget *labcon_new_pixbuf(const GdkPixbuf *pixbuf,
122                                     LabConAlignment align,
123                                     GtkPositionType pos,
124                                     guint spacing,
125                                     GtkWidget *child,
126                                     GtkWidget *group);
127
128 extern GtkWidget *labcon_new_pixbuf_defaults(const GdkPixbuf *pixbuf,
129                                              GtkWidget *child,
130                                              GtkWidget *group);
131
132 extern const GdkPixbuf *labcon_get_pixbuf(LabCon *l);
133 extern GtkWidget *labcon_get_image(LabCon *l);
134 extern GtkWidget *labcon_get_label(LabCon *l);
135 extern GtkWidget *labcon_get_child(LabCon *l);
136
137 G_END_DECLS
138
139 #endif /* _h_labcon */