root/trunk/WebCore/platform/gtk/gtkdrawing.h

Revision 42892, 14.5 KB (checked in by jmalonzo@webkit.org, 6 months ago)

2009-04-27 Jan Michael Alonzo < jmalonzo@webkit.org>

Reviewed by Gustavo Noronha.

[Gtk] gtkdrawing update
 https://bugs.webkit.org/show_bug.cgi?id=25408

Update to the 25 Apr 2009 version of gtk2drawing.c and
gtkdrawing.h from Mozilla ( http://hg.mozilla.org/mozilla-central)

  • platform/gtk/gtk2drawing.c: (setup_widget_prototype): (moz_gtk_get_combo_box_entry_arrow): (ensure_toolbar_widget): (ensure_tree_header_cell_widget): (moz_gtk_init): (moz_gtk_button_get_inner_border): (moz_gtk_toggle_paint): (moz_gtk_caret_paint): (moz_gtk_entry_paint): (moz_gtk_tree_header_cell_paint): (moz_gtk_combo_box_paint): (moz_gtk_toolbar_separator_paint): (moz_gtk_menu_separator_paint): (moz_gtk_get_widget_border): (moz_gtk_get_tab_scroll_arrow_size): (moz_gtk_get_toolbar_separator_width): (moz_gtk_get_menu_separator_height): (moz_gtk_widget_paint): (moz_gtk_shutdown):
  • platform/gtk/gtkdrawing.h:
  • Property svn:eol-style set to native
Line 
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
4 *
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/
9 *
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
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
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.
21 *
22 * Contributor(s):
23 *  Brian Ryner <bryner@brianryner.com>  (Original Author)
24 *
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.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39/**
40 * gtkdrawing.h: GTK widget rendering utilities
41 *
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.
46 */
47
48#ifndef _GTK_DRAWING_H_
49#define _GTK_DRAWING_H_
50
51#include <gdk/gdk.h>
52#include <gtk/gtk.h>
53
54#ifdef __cplusplus
55extern "C" {
56#endif /* __cplusplus */
57
58/*** type definitions ***/
59typedef struct {
60  guint8 active;
61  guint8 focused;
62  guint8 inHover;
63  guint8 disabled;
64  guint8 isDefault;
65  guint8 canDefault;
66  /* The depressed state is for buttons which remain active for a longer period:
67   * activated toggle buttons or buttons showing a popup menu. */
68  guint8 depressed;
69  gint32 curpos; /* curpos and maxpos are used for scrollbars */
70  gint32 maxpos;
71} GtkWidgetState;
72
73typedef struct {
74  gint slider_width;
75  gint trough_border;
76  gint stepper_size;
77  gint stepper_spacing;
78  gint min_slider_size;
79} MozGtkScrollbarMetrics;
80
81typedef enum {
82  MOZ_GTK_STEPPER_DOWN        = 1 << 0,
83  MOZ_GTK_STEPPER_BOTTOM      = 1 << 1,
84  MOZ_GTK_STEPPER_VERTICAL    = 1 << 2
85} GtkScrollbarButtonFlags;
86
87/** flags for tab state **/
88typedef enum {
89  /* first eight bits are used to pass a margin */
90  MOZ_GTK_TAB_MARGIN_MASK     = 0xFF,
91  /* bottom tabs */
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
97} GtkTabFlags;
98
99/** flags for menuitems **/
100typedef enum {
101  /* menuitem is part of the menubar */
102  MOZ_TOPLEVEL_MENU_ITEM      = 1 << 0
103} GtkMenuItemFlags;
104
105/* function type for moz_gtk_enable_style_props */
106typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
107
108/*** result/error codes ***/
109#define MOZ_GTK_SUCCESS 0
110#define MOZ_GTK_UNKNOWN_WIDGET -1
111#define MOZ_GTK_UNSAFE_THEME -2
112
113/*** checkbox/radio flags ***/
114#define MOZ_GTK_WIDGET_CHECKED 1
115#define MOZ_GTK_WIDGET_INCONSISTENT (1 << 1)
116
117/*** widget type constants ***/
118typedef enum {
119  /* Paints a GtkButton. flags is a GtkReliefStyle. */
120  MOZ_GTK_BUTTON,
121  /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
122  MOZ_GTK_CHECKBUTTON,
123  /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
124  MOZ_GTK_RADIOBUTTON,
125  /**
126   * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
127   * the arrow direction.
128   */
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 */
143  MOZ_GTK_SPINBUTTON,
144  MOZ_GTK_SPINBUTTON_UP,
145  MOZ_GTK_SPINBUTTON_DOWN,
146  MOZ_GTK_SPINBUTTON_ENTRY,
147  /* Paints the gripper of a GtkHandleBox. */
148  MOZ_GTK_GRIPPER,
149  /* Paints a GtkEntry. */
150  MOZ_GTK_ENTRY,
151  /* Paints the native caret (or in GTK-speak: insertion cursor) */
152  MOZ_GTK_ENTRY_CARET,
153  /* Paints a GtkOptionMenu. */
154  MOZ_GTK_DROPDOWN,
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. */
168  MOZ_GTK_TOOLBAR,
169  /* Paints a toolbar separator */
170  MOZ_GTK_TOOLBAR_SEPARATOR,
171  /* Paints a GtkToolTip */
172  MOZ_GTK_TOOLTIP,
173  /* Paints a GtkFrame (e.g. a status bar panel). */
174  MOZ_GTK_FRAME,
175  /* Paints a resize grip for a GtkWindow */
176  MOZ_GTK_RESIZER,
177  /* Paints a GtkProgressBar. */
178  MOZ_GTK_PROGRESSBAR,
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. */
182  MOZ_GTK_TAB,
183  /* Paints the background and border of a GtkNotebook. */
184  MOZ_GTK_TABPANELS,
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 */
188  MOZ_GTK_TREEVIEW,
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 */
196  MOZ_GTK_EXPANDER,
197  /* Paints the background of the menu bar. */
198  MOZ_GTK_MENUBAR,
199  /* Paints the background of menus, context menus. */
200  MOZ_GTK_MENUPOPUP,
201  /* Paints the arrow of menuitems that contain submenus */
202  MOZ_GTK_MENUARROW,
203  /* Paints an arrow that points down */
204  MOZ_GTK_TOOLBARBUTTON_ARROW,
205  /* Paints items of menubar and popups. */
206  MOZ_GTK_MENUITEM,
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. */
215  MOZ_GTK_WINDOW
216} GtkThemeWidgetType;
217
218/*** General library functions ***/
219/**
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.
225 */
226gint moz_gtk_init();
227
228/**
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
232 *
233 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
234 */
235gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
236
237/**
238 * Perform cleanup of the drawing library. You should call this function
239 * when your program exits, or you no longer need the library.
240 *
241 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
242 */
243gint moz_gtk_shutdown();
244
245
246/*** Widget drawing ***/
247/**
248 * Paint a widget in the current theme.
249 * widget:    a constant giving the widget to paint
250 * rect:      the bounding rectangle for the widget
251 * cliprect:  a clipprect rectangle for this painting operation
252 * state:     the state of the widget.  ignored for some widgets.
253 * flags:     widget-dependant flags; see the GtkThemeWidgetType definition.
254 * direction: the text direction, to draw the widget correctly LTR and RTL.
255 */
256gint
257moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
258                     GdkRectangle* rect, GdkRectangle* cliprect,
259                     GtkWidgetState* state, gint flags,
260                     GtkTextDirection direction);
261
262
263/*** Widget metrics ***/
264/**
265 * Get the border size of a widget
266 * left/right:  [OUT] the widget's left/right border
267 * top/bottom:  [OUT] the widget's top/bottom border
268 * direction:   the text direction for the widget
269 * inhtml:      boolean indicating whether this widget will be drawn as a HTML form control,
270 *              in order to workaround a size issue (MOZ_GTK_BUTTON only, ignored otherwise)
271 *
272 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
273 */
274gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, 
275                               gint* right, gint* bottom, GtkTextDirection direction,
276                               gboolean inhtml);
277
278/**
279 * Get the desired size of a GtkCheckButton
280 * indicator_size:     [OUT] the indicator size
281 * indicator_spacing:  [OUT] the spacing between the indicator and its
282 *                     container
283 *
284 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
285 */
286gint
287moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing);
288
289/**
290 * Get the desired size of a GtkRadioButton
291 * indicator_size:     [OUT] the indicator size
292 * indicator_spacing:  [OUT] the spacing between the indicator and its
293 *                     container
294 *
295 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
296 */
297gint
298moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing);
299
300/**
301 * Get the inner-border value for a GtkButton widget (button or tree header)
302 * widget:             [IN]  the widget to get the border value for
303 * inner_border:       [OUT] the inner border
304 *
305 * returns:   MOZ_GTK_SUCCESS if there was no error, an error code otherwise
306 */
307gint
308moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border);
309
310/** Get the focus metrics for a treeheadercell, button, checkbox, or radio button.
311 * widget:             [IN]  the widget to get the focus metrics for   
312 * interior_focus:     [OUT] whether the focus is drawn around the
313 *                           label (TRUE) or around the whole container (FALSE)
314 * focus_width:        [OUT] the width of the focus line
315 * focus_pad:          [OUT] the padding between the focus line and children
316 *
317 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
318 */
319gint
320moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus,
321                         gint* focus_width, gint* focus_pad);
322
323/**
324 * Get the desired size of a GtkScale thumb
325 * orient:           [IN] the scale orientation
326 * thumb_length:     [OUT] the length of the thumb
327 * thumb_height:     [OUT] the height of the thumb
328 *
329 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
330 */
331gint
332moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height);
333
334/**
335 * Get the desired metrics for a GtkScrollbar
336 * metrics:          [IN]  struct which will contain the metrics
337 *
338 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
339 */
340gint
341moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
342
343/**
344 * Get the desired size of a dropdown arrow button
345 * width:   [OUT] the desired width
346 * height:  [OUT] the desired height
347 *
348 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
349 */
350gint moz_gtk_get_combo_box_entry_button_size(gint* width, gint* height);
351
352/**
353 * Get the desired size of a scroll arrow widget
354 * width:   [OUT] the desired width
355 * height:  [OUT] the desired height
356 *
357 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
358 */
359gint moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height);
360
361/**
362 * Get the desired size of a toolbar button dropdown arrow
363 * width:   [OUT] the desired width
364 * height:  [OUT] the desired height
365 *
366 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
367 */
368gint moz_gtk_get_downarrow_size(gint* width, gint* height);
369
370/**
371 * Get the desired size of a toolbar separator
372 * size:    [OUT] the desired width
373 *
374 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
375 */
376gint moz_gtk_get_toolbar_separator_width(gint* size);
377
378/**
379 * Get the size of a regular GTK expander that shows/hides content
380 * size:    [OUT] the size of the GTK expander, size = width = height.
381 *
382 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
383 */
384gint moz_gtk_get_expander_size(gint* size);
385
386/**
387 * Get the size of a treeview's expander (we call them twisties)
388 * size:    [OUT] the size of the GTK expander, size = width = height.
389 *
390 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
391 */
392gint moz_gtk_get_treeview_expander_size(gint* size);
393
394/**
395 * Get the desired height of a menu separator
396 * size:    [OUT] the desired height
397 *
398 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
399 */
400gint moz_gtk_get_menu_separator_height(gint* size);
401
402/**
403 * Get the desired size of a splitter
404 * orientation:   [IN]  GTK_ORIENTATION_HORIZONTAL or GTK_ORIENTATION_VERTICAL
405 * size:          [OUT] width or height of the splitter handle
406 *
407 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
408 */
409gint moz_gtk_splitter_get_metrics(gint orientation, gint* size);
410
411/**
412 * Retrieve an actual GTK scrollbar widget for style analysis. It will not
413 * be modified.
414 */
415GtkWidget* moz_gtk_get_scrollbar_widget(void);
416
417/**
418 * Get the YTHICKNESS of a tab (notebook extension).
419 */
420gint moz_gtk_get_tab_thickness(void);
421
422/**
423 * Get a boolean which indicates whether or not to use images in menus.
424 * If TRUE, use images in menus.
425 */
426gboolean moz_gtk_images_in_menus(void);
427
428#ifdef __cplusplus
429}
430#endif /* __cplusplus */
431
432#endif
Note: See TracBrowser for help on using the browser.