root/trunk/WebCore/platform/gtk/gtkdrawing.h
| Revision 29824, 13.1 kB (checked in by alp@webkit.org, 6 months ago) | |
|---|---|
| |
| 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/gtkstyle.h> |
| 53 | |
| 54 | #ifdef __cplusplus |
| 55 | extern "C" { |
| 56 | #endif /* __cplusplus */ |
| 57 | |
| 58 | /*** type definitions ***/ |
| 59 | typedef 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 | |
| 73 | typedef 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 | |
| 81 | typedef 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 **/ |
| 88 | typedef 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 **/ |
| 100 | typedef 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 */ |
| 106 | typedef 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 | /*** widget type constants ***/ |
| 114 | typedef enum { |
| 115 | /* Paints a GtkButton. flags is a GtkReliefStyle. */ |
| 116 | MOZ_GTK_BUTTON, |
| 117 | /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */ |
| 118 | MOZ_GTK_CHECKBUTTON, |
| 119 | /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */ |
| 120 | MOZ_GTK_RADIOBUTTON, |
| 121 | /** |
| 122 | * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving |
| 123 | * the arrow direction. |
| 124 | */ |
| 125 | MOZ_GTK_SCROLLBAR_BUTTON, |
| 126 | /* Paints the trough (track) of a GtkScrollbar. */ |
| 127 | MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL, |
| 128 | MOZ_GTK_SCROLLBAR_TRACK_VERTICAL, |
| 129 | /* Paints the slider (thumb) of a GtkScrollbar. */ |
| 130 | MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL, |
| 131 | MOZ_GTK_SCROLLBAR_THUMB_VERTICAL, |
| 132 | /* Paints a GtkScale. */ |
| 133 | MOZ_GTK_SCALE_HORIZONTAL, |
| 134 | MOZ_GTK_SCALE_VERTICAL, |
| 135 | /* Paints a GtkScale thumb. */ |
| 136 | MOZ_GTK_SCALE_THUMB_HORIZONTAL, |
| 137 | MOZ_GTK_SCALE_THUMB_VERTICAL, |
| 138 | /* Paints a GtkSpinButton */ |
| 139 | MOZ_GTK_SPINBUTTON, |
| 140 | MOZ_GTK_SPINBUTTON_UP, |
| 141 | MOZ_GTK_SPINBUTTON_DOWN, |
| 142 | MOZ_GTK_SPINBUTTON_ENTRY, |
| 143 | /* Paints the gripper of a GtkHandleBox. */ |
| 144 | MOZ_GTK_GRIPPER, |
| 145 | /* Paints a GtkEntry. */ |
| 146 | MOZ_GTK_ENTRY, |
| 147 | /* Paints a GtkOptionMenu. */ |
| 148 | MOZ_GTK_DROPDOWN, |
| 149 | /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */ |
| 150 | MOZ_GTK_DROPDOWN_ARROW, |
| 151 | /* Paints an entry in an editable option menu */ |
| 152 | MOZ_GTK_DROPDOWN_ENTRY, |
| 153 | /* Paints the container part of a GtkCheckButton. */ |
| 154 | MOZ_GTK_CHECKBUTTON_CONTAINER, |
| 155 | /* Paints the container part of a GtkRadioButton. */ |
| 156 | MOZ_GTK_RADIOBUTTON_CONTAINER, |
| 157 | /* Paints the label of a GtkCheckButton (focus outline) */ |
| 158 | MOZ_GTK_CHECKBUTTON_LABEL, |
| 159 | /* Paints the label of a GtkRadioButton (focus outline) */ |
| 160 | MOZ_GTK_RADIOBUTTON_LABEL, |
| 161 | /* Paints the background of a GtkHandleBox. */ |
| 162 | MOZ_GTK_TOOLBAR, |
| 163 | /* Paints a toolbar separator */ |
| 164 | MOZ_GTK_TOOLBAR_SEPARATOR, |
| 165 | /* Paints a GtkToolTip */ |
| 166 | MOZ_GTK_TOOLTIP, |
| 167 | /* Paints a GtkFrame (e.g. a status bar panel). */ |
| 168 | MOZ_GTK_FRAME, |
| 169 | /* Paints a resize grip for a GtkWindow */ |
| 170 | MOZ_GTK_RESIZER, |
| 171 | /* Paints a GtkProgressBar. */ |
| 172 | MOZ_GTK_PROGRESSBAR, |
| 173 | /* Paints a progress chunk of a GtkProgressBar. */ |
| 174 | MOZ_GTK_PROGRESS_CHUNK, |
| 175 | /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */ |
| 176 | MOZ_GTK_TAB, |
| 177 | /* Paints the background and border of a GtkNotebook. */ |
| 178 | MOZ_GTK_TABPANELS, |
| 179 | /* Paints the background and border of a GtkTreeView */ |
| 180 | MOZ_GTK_TREEVIEW, |
| 181 | /* Paints treeheader cells */ |
| 182 | MOZ_GTK_TREE_HEADER_CELL, |
| 183 | /* Paints sort arrows in treeheader cells */ |
| 184 | MOZ_GTK_TREE_HEADER_SORTARROW, |
| 185 | /* Paints an expander for a GtkTreeView */ |
| 186 | MOZ_GTK_TREEVIEW_EXPANDER, |
| 187 | /* Paints a GtkExpander */ |
| 188 | MOZ_GTK_EXPANDER, |
| 189 | /* Paints the background of the menu bar. */ |
| 190 | MOZ_GTK_MENUBAR, |
| 191 | /* Paints the background of menus, context menus. */ |
| 192 | MOZ_GTK_MENUPOPUP, |
| 193 | /* Paints the arrow of menuitems that contain submenus */ |
| 194 | MOZ_GTK_MENUARROW, |
| 195 | /* Paints an arrow that points down */ |
| 196 | MOZ_GTK_TOOLBARBUTTON_ARROW, |
| 197 | /* Paints items of menubar and popups. */ |
| 198 | MOZ_GTK_MENUITEM, |
| 199 | MOZ_GTK_CHECKMENUITEM, |
| 200 | MOZ_GTK_RADIOMENUITEM, |
| 201 | MOZ_GTK_MENUSEPARATOR, |
| 202 | /* Paints a GtkVPaned separator */ |
| 203 | MOZ_GTK_SPLITTER_HORIZONTAL, |
| 204 | /* Paints a GtkHPaned separator */ |
| 205 | MOZ_GTK_SPLITTER_VERTICAL, |
| 206 | /* Paints the background of a window, dialog or page. */ |
| 207 | MOZ_GTK_WINDOW |
| 208 | } GtkThemeWidgetType; |
| 209 | |
| 210 | /*** General library functions ***/ |
| 211 | /** |
| 212 | * Initializes the drawing library. You must call this function |
| 213 | * prior to using any other functionality. |
| 214 | * returns: MOZ_GTK_SUCCESS if there were no errors |
| 215 | * MOZ_GTK_UNSAFE_THEME if the current theme engine is known |
| 216 | * to crash with gtkdrawing. |
| 217 | */ |
| 218 | gint moz_gtk_init(); |
| 219 | |
| 220 | /** |
| 221 | * Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer |
| 222 | * to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental". |
| 223 | * styleGetProp: pointer to gtk_style_get_prop_experimental |
| 224 | * |
| 225 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 226 | */ |
| 227 | gint moz_gtk_enable_style_props(style_prop_t styleGetProp); |
| 228 | |
| 229 | /** |
| 230 | * Perform cleanup of the drawing library. You should call this function |
| 231 | * when your program exits, or you no longer need the library. |
| 232 | * |
| 233 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 234 | */ |
| 235 | gint moz_gtk_shutdown(); |
| 236 | |
| 237 | |
| 238 | /*** Widget drawing ***/ |
| 239 | /** |
| 240 | * Paint a widget in the current theme. |
| 241 | * widget: a constant giving the widget to paint |
| 242 | * rect: the bounding rectangle for the widget |
| 243 | * cliprect: a clipprect rectangle for this painting operation |
| 244 | * state: the state of the widget. ignored for some widgets. |
| 245 | * flags: widget-dependant flags; see the GtkThemeWidgetType definition. |
| 246 | * direction: the text direction, to draw the widget correctly LTR and RTL. |
| 247 | */ |
| 248 | gint |
| 249 | moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, |
| 250 | GdkRectangle* rect, GdkRectangle* cliprect, |
| 251 | GtkWidgetState* state, gint flags, |
| 252 | GtkTextDirection direction); |
| 253 | |
| 254 | |
| 255 | /*** Widget metrics ***/ |
| 256 | /** |
| 257 | * Get the border size of a widget |
| 258 | * left/right: [OUT] the widget's left/right border |
| 259 | * top/bottom: [OUT] the widget's top/bottom border |
| 260 | * direction: the text direction for the widget |
| 261 | * inhtml: boolean indicating whether this widget will be drawn as a HTML form control, |
| 262 | * in order to workaround a size issue (MOZ_GTK_BUTTON only, ignored otherwise) |
| 263 | * |
| 264 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 265 | */ |
| 266 | gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, |
| 267 | gint* right, gint* bottom, GtkTextDirection direction, |
| 268 | gboolean inhtml); |
| 269 | |
| 270 | /** |
| 271 | * Get the desired size of a GtkCheckButton |
| 272 | * indicator_size: [OUT] the indicator size |
| 273 | * indicator_spacing: [OUT] the spacing between the indicator and its |
| 274 | * container |
| 275 | * |
| 276 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 277 | */ |
| 278 | gint |
| 279 | moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing); |
| 280 | |
| 281 | /** |
| 282 | * Get the desired size of a GtkRadioButton |
| 283 | * indicator_size: [OUT] the indicator size |
| 284 | * indicator_spacing: [OUT] the spacing between the indicator and its |
| 285 | * container |
| 286 | * |
| 287 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 288 | */ |
| 289 | gint |
| 290 | moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing); |
| 291 | |
| 292 | /** Get the focus metrics for a treeheadercell, button, checkbox, or radio button. |
| 293 | * widget: [IN] the widget to get the focus metrics for |
| 294 | * interior_focus: [OUT] whether the focus is drawn around the |
| 295 | * label (TRUE) or around the whole container (FALSE) |
| 296 | * focus_width: [OUT] the width of the focus line |
| 297 | * focus_pad: [OUT] the padding between the focus line and children |
| 298 | * |
| 299 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 300 | */ |
| 301 | gint |
| 302 | moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus, |
| 303 | gint* focus_width, gint* focus_pad); |
| 304 | |
| 305 | /** |
| 306 | * Get the desired size of a GtkScale thumb |
| 307 | * orient: [IN] the scale orientation |
| 308 | * thumb_length: [OUT] the length of the thumb |
| 309 | * thumb_height: [OUT] the height of the thumb |
| 310 | * |
| 311 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 312 | */ |
| 313 | gint |
| 314 | moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height); |
| 315 | |
| 316 | /** |
| 317 | * Get the desired metrics for a GtkScrollbar |
| 318 | * metrics: [IN] struct which will contain the metrics |
| 319 | * |
| 320 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 321 | */ |
| 322 | gint |
| 323 | moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics); |
| 324 | |
| 325 | /** |
| 326 | * Get the desired size of a dropdown arrow button |
| 327 | * width: [OUT] the desired width |
| 328 | * height: [OUT] the desired height |
| 329 | * |
| 330 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 331 | */ |
| 332 | gint moz_gtk_get_dropdown_arrow_size(gint* width, gint* height); |
| 333 | |
| 334 | /** |
| 335 | * Get the desired size of a toolbar separator |
| 336 | * size: [OUT] the desired width |
| 337 | * |
| 338 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 339 | */ |
| 340 | gint moz_gtk_get_toolbar_separator_width(gint* size); |
| 341 | |
| 342 | /** |
| 343 | * Get the size of a regular GTK expander that shows/hides content |
| 344 | * size: [OUT] the size of the GTK expander, size = width = height. |
| 345 | * |
| 346 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 347 | */ |
| 348 | gint moz_gtk_get_expander_size(gint* size); |
| 349 | |
| 350 | /** |
| 351 | * Get the size of a treeview's expander (we call them twisties) |
| 352 | * size: [OUT] the size of the GTK expander, size = width = height. |
| 353 | * |
| 354 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 355 | */ |
| 356 | gint moz_gtk_get_treeview_expander_size(gint* size); |
| 357 | |
| 358 | /** |
| 359 | * Get the desired height of a menu separator |
| 360 | * size: [OUT] the desired height |
| 361 | * |
| 362 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 363 | */ |
| 364 | gint moz_gtk_get_menu_separator_height(gint* size); |
| 365 | |
| 366 | /** |
| 367 | * Get the desired size of a splitter |
| 368 | * orientation: [IN] GTK_ORIENTATION_HORIZONTAL or GTK_ORIENTATION_VERTICAL |
| 369 | * size: [OUT] width or height of the splitter handle |
| 370 | * |
| 371 | * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise |
| 372 | */ |
| 373 | gint moz_gtk_splitter_get_metrics(gint orientation, gint* size); |
| 374 | |
| 375 | /** |
| 376 | * Retrieve an actual GTK scrollbar widget for style analysis. It will not |
| 377 | * be modified. |
| 378 | */ |
| 379 | GtkWidget* moz_gtk_get_scrollbar_widget(void); |
| 380 | |
| 381 | /** |
| 382 | * Get the YTHICKNESS of a tab (notebook extension). |
| 383 | */ |
| 384 | gint moz_gtk_get_tab_thickness(void); |
| 385 | |
| 386 | #ifdef __cplusplus |
| 387 | } |
| 388 | #endif /* __cplusplus */ |
| 389 | |
| 390 | #endif |
| 391 |
Note: See TracBrowser for help on using the browser.