1
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 2002
20
* the Initial Developer. All Rights Reserved.
23
* Brian Ryner <bryner@brianryner.com> (Original Author)
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
40
* gtkdrawing.h: GTK widget rendering utilities
42
* gtkdrawing provides an API for rendering GTK widgets in the
43
* current theme to a pixmap or window, without requiring an actual
44
* widget instantiation, similar to the Macintosh Appearance Manager
45
* or Windows XP's DrawThemeBackground() API.
48
#ifndef _GTK_DRAWING_H_
49
#define _GTK_DRAWING_H_
52
#include <gtk/gtkstyle.h>
56
#endif /* __cplusplus */
58
/*** type definitions ***/
66
gint32 curpos; /* curpos and maxpos are used for scrollbars */
76
} MozGtkScrollbarMetrics;
78
/** flags for tab state **/
80
/* the first tab in the group */
81
MOZ_GTK_TAB_FIRST = 1 << 0,
82
/* the tab just before the selected tab */
83
MOZ_GTK_TAB_BEFORE_SELECTED = 1 << 1,
84
/* the selected tab */
85
MOZ_GTK_TAB_SELECTED = 1 << 2
88
/* function type for moz_gtk_enable_style_props */
89
typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
91
/*** result/error codes ***/
92
#define MOZ_GTK_SUCCESS 0
93
#define MOZ_GTK_UNKNOWN_WIDGET -1
94
#define MOZ_GTK_UNSAFE_THEME -2
96
/*** widget type constants ***/
98
/* Paints a GtkButton. flags is a GtkReliefStyle. */
100
/* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
102
/* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
105
* Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
106
* the arrow direction.
108
MOZ_GTK_SCROLLBAR_BUTTON,
109
/* Paints the trough (track) of a GtkScrollbar. */
110
MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL,
111
MOZ_GTK_SCROLLBAR_TRACK_VERTICAL,
112
/* Paints the slider (thumb) of a GtkScrollbar. */
113
MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
114
MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
115
/* Paints the gripper of a GtkHandleBox. */
117
/* Paints a GtkEntry. */
119
/* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
120
MOZ_GTK_DROPDOWN_ARROW,
121
/* Paints the container part of a GtkCheckButton. */
122
MOZ_GTK_CHECKBUTTON_CONTAINER,
123
/* Paints the container part of a GtkRadioButton. */
124
MOZ_GTK_RADIOBUTTON_CONTAINER,
125
/* Paints the label of a GtkCheckButton (focus outline) */
126
MOZ_GTK_CHECKBUTTON_LABEL,
127
/* Paints the label of a GtkRadioButton (focus outline) */
128
MOZ_GTK_RADIOBUTTON_LABEL,
129
/* Paints the background of a GtkHandleBox. */
131
/* Paints a GtkToolTip */
133
/* Paints a GtkFrame (e.g. a status bar panel). */
135
/* Paints a GtkProgressBar. */
137
/* Paints a progress chunk of a GtkProgressBar. */
138
MOZ_GTK_PROGRESS_CHUNK,
139
/* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
141
/* Paints the background and border of a GtkNotebook. */
143
/* Paints the background of the menu bar. */
145
/* Paints the background of menus, context menus. */
147
/* Paints items of menubar and popups. */
149
/* Paints the background of a window, dialog or page. */
151
} GtkThemeWidgetType;
153
/*** General library functions ***/
155
* Initializes the drawing library. You must call this function
156
* prior to using any other functionality.
157
* returns: MOZ_GTK_SUCCESS if there were no errors
158
* MOZ_GTK_UNSAFE_THEME if the current theme engine is known
159
* to crash with gtkdrawing.
164
* Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer
165
* to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental".
166
* styleGetProp: pointer to gtk_style_get_prop_experimental
168
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
170
gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
173
* Perform cleanup of the drawing library. You should call this function
174
* when your program exits, or you no longer need the library.
176
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
178
gint moz_gtk_shutdown();
181
/*** Widget drawing ***/
183
* Paint a widget in the current theme.
184
* widget: a constant giving the widget to paint
185
* rect: the bounding rectangle for the widget
186
* cliprect: a clipprect rectangle for this painting operation
187
* state: the state of the widget. ignored for some widgets.
188
* flags: widget-dependant flags; see the GtkThemeWidgetType definition.
191
moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
192
GdkRectangle* rect, GdkRectangle* cliprect,
193
GtkWidgetState* state, gint flags);
196
/*** Widget metrics ***/
198
* Get the border size of a widget
199
* xthickness: [OUT] the widget's left/right border
200
* ythickness: [OUT] the widget's top/bottom border
202
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
204
gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
208
* Get the desired size of a GtkCheckButton
209
* indicator_size: [OUT] the indicator size
210
* indicator_spacing: [OUT] the spacing between the indicator and its
213
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
216
moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing);
219
* Get the desired size of a GtkRadioButton
220
* indicator_size: [OUT] the indicator size
221
* indicator_spacing: [OUT] the spacing between the indicator and its
224
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
227
moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing);
229
/** Get the focus metrics for a button, checkbox, or radio button.
230
* interior_focus: [OUT] whether the focus is drawn around the
231
* label (TRUE) or around the whole container (FALSE)
232
* focus_width: [OUT] the width of the focus line
233
* focus_pad: [OUT] the padding between the focus line and children
235
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
238
moz_gtk_button_get_focus(gboolean* interior_focus,
239
gint* focus_width, gint* focus_pad);
241
moz_gtk_checkbox_get_focus(gboolean* interior_focus,
242
gint* focus_width, gint* focus_pad);
244
moz_gtk_radio_get_focus(gboolean* interior_focus,
245
gint* focus_width, gint* focus_pad);
248
* Get the desired metrics for a GtkScrollbar
249
* metrics: [IN] struct which will contain the metrics
251
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
254
moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
257
* Get the desired size of a dropdown arrow button
258
* width: [OUT] the desired width
259
* height: [OUT] the desired height
261
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
263
gint moz_gtk_get_dropdown_arrow_size(gint* width, gint* height);
267
#endif /* __cplusplus */