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_
51 #undef GTK_DISABLE_DEPRECATED
57 #endif /* __cplusplus */
59 /*** type definitions ***/
67 /* The depressed state is for buttons which remain active for a longer period:
68 * activated toggle buttons or buttons showing a popup menu. */
70 gint32 curpos; /* curpos and maxpos are used for scrollbars */
80 gboolean trough_under_steppers;
81 gboolean has_secondary_forward_stepper;
82 gboolean has_secondary_backward_stepper;
83 } MozGtkScrollbarMetrics;
85 typedef struct _GtkThemeParts {
86 GdkColormap* colormap;
87 GtkWidget* protoWindow;
88 GtkWidget* protoLayout;
89 GtkWidget* horizScrollbarWidget;
90 GtkWidget* vertScrollbarWidget;
91 GtkWidget* scrolledWindowWidget;
95 MOZ_GTK_STEPPER_DOWN = 1 << 0,
96 MOZ_GTK_STEPPER_BOTTOM = 1 << 1,
97 MOZ_GTK_STEPPER_VERTICAL = 1 << 2
98 } GtkScrollbarButtonFlags;
100 /* function type for moz_gtk_enable_style_props */
101 typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
103 /*** result/error codes ***/
104 #define MOZ_GTK_SUCCESS 0
105 #define MOZ_GTK_UNKNOWN_WIDGET -1
106 #define MOZ_GTK_UNSAFE_THEME -2
108 /*** widget type constants ***/
110 /* Paints a GtkButton. flags is a GtkReliefStyle. */
113 * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
114 * the arrow direction.
116 MOZ_GTK_SCROLLBAR_BUTTON,
117 /* Paints the trough (track) of a GtkScrollbar. */
118 MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL,
119 MOZ_GTK_SCROLLBAR_TRACK_VERTICAL,
120 /* Paints the slider (thumb) of a GtkScrollbar. */
121 MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
122 MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
123 /* Paints the background of a scrolled window */
124 MOZ_GTK_SCROLLED_WINDOW,
125 } GtkThemeWidgetType;
127 /*** General library functions ***/
129 * Initializes the drawing library. You must call this function
130 * prior to using any other functionality.
131 * returns: MOZ_GTK_SUCCESS if there were no errors
132 * MOZ_GTK_UNSAFE_THEME if the current theme engine is known
133 * to crash with gtkdrawing.
138 * Instruct the drawing library to do all rendering based on
139 * the given collection of theme parts. If any members of the
140 * GtkThemeParts struct are NULL, they will be created lazily.
143 moz_gtk_use_theme_parts(GtkThemeParts* parts);
146 * Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer
147 * to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental".
148 * styleGetProp: pointer to gtk_style_get_prop_experimental
150 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
152 gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
155 * Perform cleanup of the drawing library. You should call this function
156 * when your program exits, or you no longer need the library.
158 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
160 gint moz_gtk_shutdown();
163 * Destroy the widgets in the given GtkThemeParts, which should
164 * be destroyed before the GtkThemeParts can be freed.
166 void moz_gtk_destroy_theme_parts_widgets(GtkThemeParts* parts);
168 /*** Widget drawing ***/
170 * Paint a widget in the current theme.
171 * widget: a constant giving the widget to paint
172 * rect: the bounding rectangle for the widget
173 * cliprect: a clipprect rectangle for this painting operation
174 * state: the state of the widget. ignored for some widgets.
175 * flags: widget-dependant flags; see the GtkThemeWidgetType definition.
176 * direction: the text direction, to draw the widget correctly LTR and RTL.
179 moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
180 GdkRectangle* rect, GdkRectangle* cliprect,
181 GtkWidgetState* state, gint flags,
182 GtkTextDirection direction);
184 /*** Widget metrics ***/
186 * Get the border size of a widget
187 * left/right: [OUT] the widget's left/right border
188 * top/bottom: [OUT] the widget's top/bottom border
189 * direction: the text direction for the widget
190 * inhtml: boolean indicating whether this widget will be drawn as a HTML form control,
191 * in order to workaround a size issue (MOZ_GTK_BUTTON only, ignored otherwise)
193 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
195 gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
196 gint* right, gint* bottom, GtkTextDirection direction,
199 * Get the desired metrics for a GtkScrollbar
200 * metrics: [IN] struct which will contain the metrics
202 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
205 moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
208 * Retrieve an actual GTK scrollbar widget for style analysis. It will not
211 GtkWidget* moz_gtk_get_scrollbar_widget(void);
215 #endif /* __cplusplus */