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_
56 #endif /* __cplusplus */
58 /*** type definitions ***/
66 /* The depressed state is for buttons which remain active for a longer period:
67 * activated toggle buttons or buttons showing a popup menu. */
69 gint32 curpos
; /* curpos and maxpos are used for scrollbars */
79 } MozGtkScrollbarMetrics
;
82 MOZ_GTK_STEPPER_DOWN
= 1 << 0,
83 MOZ_GTK_STEPPER_BOTTOM
= 1 << 1,
84 MOZ_GTK_STEPPER_VERTICAL
= 1 << 2
85 } GtkScrollbarButtonFlags
;
87 /** flags for tab state **/
89 /* first eight bits are used to pass a margin */
90 MOZ_GTK_TAB_MARGIN_MASK
= 0xFF,
92 MOZ_GTK_TAB_BOTTOM
= 1 << 8,
93 /* the first tab in the group */
94 MOZ_GTK_TAB_FIRST
= 1 << 9,
95 /* the selected tab */
96 MOZ_GTK_TAB_SELECTED
= 1 << 10
99 /** flags for menuitems **/
101 /* menuitem is part of the menubar */
102 MOZ_TOPLEVEL_MENU_ITEM
= 1 << 0
105 /* function type for moz_gtk_enable_style_props */
106 typedef gint (*style_prop_t
)(GtkStyle
*, const gchar
*, gint
);
108 /*** result/error codes ***/
109 #define MOZ_GTK_SUCCESS 0
110 #define MOZ_GTK_UNKNOWN_WIDGET -1
111 #define MOZ_GTK_UNSAFE_THEME -2
113 /*** checkbox/radio flags ***/
114 #define MOZ_GTK_WIDGET_CHECKED 1
115 #define MOZ_GTK_WIDGET_INCONSISTENT (1 << 1)
117 /*** widget type constants ***/
119 /* Paints a GtkButton. flags is a GtkReliefStyle. */
121 /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
123 /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
126 * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
127 * the arrow direction.
129 MOZ_GTK_SCROLLBAR_BUTTON
,
130 /* Paints the trough (track) of a GtkScrollbar. */
131 MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL
,
132 MOZ_GTK_SCROLLBAR_TRACK_VERTICAL
,
133 /* Paints the slider (thumb) of a GtkScrollbar. */
134 MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL
,
135 MOZ_GTK_SCROLLBAR_THUMB_VERTICAL
,
136 /* Paints a GtkScale. */
137 MOZ_GTK_SCALE_HORIZONTAL
,
138 MOZ_GTK_SCALE_VERTICAL
,
139 /* Paints a GtkScale thumb. */
140 MOZ_GTK_SCALE_THUMB_HORIZONTAL
,
141 MOZ_GTK_SCALE_THUMB_VERTICAL
,
142 /* Paints a GtkSpinButton */
144 MOZ_GTK_SPINBUTTON_UP
,
145 MOZ_GTK_SPINBUTTON_DOWN
,
146 MOZ_GTK_SPINBUTTON_ENTRY
,
147 /* Paints the gripper of a GtkHandleBox. */
149 /* Paints a GtkEntry. */
151 /* Paints the native caret (or in GTK-speak: insertion cursor) */
153 /* Paints a GtkOptionMenu. */
155 /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
156 MOZ_GTK_DROPDOWN_ARROW
,
157 /* Paints an entry in an editable option menu */
158 MOZ_GTK_DROPDOWN_ENTRY
,
159 /* Paints the container part of a GtkCheckButton. */
160 MOZ_GTK_CHECKBUTTON_CONTAINER
,
161 /* Paints the container part of a GtkRadioButton. */
162 MOZ_GTK_RADIOBUTTON_CONTAINER
,
163 /* Paints the label of a GtkCheckButton (focus outline) */
164 MOZ_GTK_CHECKBUTTON_LABEL
,
165 /* Paints the label of a GtkRadioButton (focus outline) */
166 MOZ_GTK_RADIOBUTTON_LABEL
,
167 /* Paints the background of a GtkHandleBox. */
169 /* Paints a toolbar separator */
170 MOZ_GTK_TOOLBAR_SEPARATOR
,
171 /* Paints a GtkToolTip */
173 /* Paints a GtkFrame (e.g. a status bar panel). */
175 /* Paints a resize grip for a GtkWindow */
177 /* Paints a GtkProgressBar. */
179 /* Paints a progress chunk of a GtkProgressBar. */
180 MOZ_GTK_PROGRESS_CHUNK
,
181 /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
183 /* Paints the background and border of a GtkNotebook. */
185 /* Paints a GtkArrow for a GtkNotebook. flags is a GtkArrowType. */
186 MOZ_GTK_TAB_SCROLLARROW
,
187 /* Paints the background and border of a GtkTreeView */
189 /* Paints treeheader cells */
190 MOZ_GTK_TREE_HEADER_CELL
,
191 /* Paints sort arrows in treeheader cells */
192 MOZ_GTK_TREE_HEADER_SORTARROW
,
193 /* Paints an expander for a GtkTreeView */
194 MOZ_GTK_TREEVIEW_EXPANDER
,
195 /* Paints a GtkExpander */
197 /* Paints the background of the menu bar. */
199 /* Paints the background of menus, context menus. */
201 /* Paints the arrow of menuitems that contain submenus */
203 /* Paints an arrow in a toolbar button. flags is a GtkArrowType. */
204 MOZ_GTK_TOOLBARBUTTON_ARROW
,
205 /* Paints items of menubar and popups. */
207 MOZ_GTK_CHECKMENUITEM
,
208 MOZ_GTK_RADIOMENUITEM
,
209 MOZ_GTK_MENUSEPARATOR
,
210 /* Paints a GtkVPaned separator */
211 MOZ_GTK_SPLITTER_HORIZONTAL
,
212 /* Paints a GtkHPaned separator */
213 MOZ_GTK_SPLITTER_VERTICAL
,
214 /* Paints the background of a window, dialog or page. */
216 } GtkThemeWidgetType
;
218 /*** General library functions ***/
220 * Initializes the drawing library. You must call this function
221 * prior to using any other functionality.
222 * returns: MOZ_GTK_SUCCESS if there were no errors
223 * MOZ_GTK_UNSAFE_THEME if the current theme engine is known
224 * to crash with gtkdrawing.
229 * Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer
230 * to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental".
231 * styleGetProp: pointer to gtk_style_get_prop_experimental
233 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
235 gint
moz_gtk_enable_style_props(style_prop_t styleGetProp
);
238 * Perform cleanup of the drawing library. You should call this function
239 * when your program exits, or you no longer need the library.
241 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
243 gint
moz_gtk_shutdown();
246 * Retrieves the colormap to use for drawables passed to moz_gtk_widget_paint.
248 GdkColormap
* moz_gtk_widget_get_colormap();
250 /*** Widget drawing ***/
252 * Paint a widget in the current theme.
253 * widget: a constant giving the widget to paint
254 * drawable: the drawable to paint to;
255 * it's colormap must be moz_gtk_widget_get_colormap().
256 * rect: the bounding rectangle for the widget
257 * cliprect: a clipprect rectangle for this painting operation
258 * state: the state of the widget. ignored for some widgets.
259 * flags: widget-dependant flags; see the GtkThemeWidgetType definition.
260 * direction: the text direction, to draw the widget correctly LTR and RTL.
263 moz_gtk_widget_paint(GtkThemeWidgetType widget
, GdkDrawable
* drawable
,
264 GdkRectangle
* rect
, GdkRectangle
* cliprect
,
265 GtkWidgetState
* state
, gint flags
,
266 GtkTextDirection direction
);
269 /*** Widget metrics ***/
271 * Get the border size of a widget
272 * left/right: [OUT] the widget's left/right border
273 * top/bottom: [OUT] the widget's top/bottom border
274 * direction: the text direction for the widget
275 * inhtml: boolean indicating whether this widget will be drawn as a HTML form control,
276 * in order to workaround a size issue (MOZ_GTK_BUTTON only, ignored otherwise)
278 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
280 gint
moz_gtk_get_widget_border(GtkThemeWidgetType widget
, gint
* left
, gint
* top
,
281 gint
* right
, gint
* bottom
, GtkTextDirection direction
,
285 * Get the desired size of a GtkCheckButton
286 * indicator_size: [OUT] the indicator size
287 * indicator_spacing: [OUT] the spacing between the indicator and its
290 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
293 moz_gtk_checkbox_get_metrics(gint
* indicator_size
, gint
* indicator_spacing
);
296 * Get the desired size of a GtkRadioButton
297 * indicator_size: [OUT] the indicator size
298 * indicator_spacing: [OUT] the spacing between the indicator and its
301 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
304 moz_gtk_radio_get_metrics(gint
* indicator_size
, gint
* indicator_spacing
);
307 * Get the inner-border value for a GtkButton widget (button or tree header)
308 * widget: [IN] the widget to get the border value for
309 * inner_border: [OUT] the inner border
311 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
314 moz_gtk_button_get_inner_border(GtkWidget
* widget
, GtkBorder
* inner_border
);
316 /** Get the focus metrics for a treeheadercell, button, checkbox, or radio button.
317 * widget: [IN] the widget to get the focus metrics for
318 * interior_focus: [OUT] whether the focus is drawn around the
319 * label (TRUE) or around the whole container (FALSE)
320 * focus_width: [OUT] the width of the focus line
321 * focus_pad: [OUT] the padding between the focus line and children
323 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
326 moz_gtk_widget_get_focus(GtkWidget
* widget
, gboolean
* interior_focus
,
327 gint
* focus_width
, gint
* focus_pad
);
330 * Some GTK themes draw their indication for the default button outside
331 * the button (e.g. the glow in New Wave). This gets the extra space necessary.
333 * border_top: [OUT] extra space to add above
334 * border_left: [OUT] extra space to add to the left
335 * border_bottom: [OUT] extra space to add underneath
336 * border_right: [OUT] extra space to add to the right
338 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
341 moz_gtk_button_get_default_overflow(gint
* border_top
, gint
* border_left
,
342 gint
* border_bottom
, gint
* border_right
);
345 * Get the desired size of a GtkScale thumb
346 * orient: [IN] the scale orientation
347 * thumb_length: [OUT] the length of the thumb
348 * thumb_height: [OUT] the height of the thumb
350 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
353 moz_gtk_get_scalethumb_metrics(GtkOrientation orient
, gint
* thumb_length
, gint
* thumb_height
);
356 * Get the desired metrics for a GtkScrollbar
357 * metrics: [IN] struct which will contain the metrics
359 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
362 moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics
* metrics
);
365 * Get the desired size of a dropdown arrow button
366 * width: [OUT] the desired width
367 * height: [OUT] the desired height
369 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
371 gint
moz_gtk_get_combo_box_entry_button_size(gint
* width
, gint
* height
);
374 * Get the desired size of a scroll arrow widget
375 * width: [OUT] the desired width
376 * height: [OUT] the desired height
378 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
380 gint
moz_gtk_get_tab_scroll_arrow_size(gint
* width
, gint
* height
);
383 * Get the desired size of an arrow in a button
384 * width: [OUT] the desired width
385 * height: [OUT] the desired height
387 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
389 gint
moz_gtk_get_arrow_size(gint
* width
, gint
* height
);
392 * Get the desired size of a toolbar separator
393 * size: [OUT] the desired width
395 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
397 gint
moz_gtk_get_toolbar_separator_width(gint
* size
);
400 * Get the size of a regular GTK expander that shows/hides content
401 * size: [OUT] the size of the GTK expander, size = width = height.
403 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
405 gint
moz_gtk_get_expander_size(gint
* size
);
408 * Get the size of a treeview's expander (we call them twisties)
409 * size: [OUT] the size of the GTK expander, size = width = height.
411 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
413 gint
moz_gtk_get_treeview_expander_size(gint
* size
);
416 * Get the desired height of a menu separator
417 * size: [OUT] the desired height
419 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
421 gint
moz_gtk_get_menu_separator_height(gint
* size
);
424 * Get the desired size of a splitter
425 * orientation: [IN] GTK_ORIENTATION_HORIZONTAL or GTK_ORIENTATION_VERTICAL
426 * size: [OUT] width or height of the splitter handle
428 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
430 gint
moz_gtk_splitter_get_metrics(gint orientation
, gint
* size
);
433 * Retrieve an actual GTK scrollbar widget for style analysis. It will not
436 GtkWidget
* moz_gtk_get_scrollbar_widget(void);
439 * Get the YTHICKNESS of a tab (notebook extension).
441 gint
moz_gtk_get_tab_thickness(void);
444 * Get a boolean which indicates whether or not to use images in menus.
445 * If TRUE, use images in menus.
447 gboolean
moz_gtk_images_in_menus(void);
450 * Get a boolean which indicates whether or not to use images in buttons.
451 * If TRUE, use images in buttons.
453 gboolean
moz_gtk_images_in_buttons(void);
457 #endif /* __cplusplus */