michael@0: /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * gtkdrawing.h: GTK widget rendering utilities michael@0: * michael@0: * gtkdrawing provides an API for rendering GTK widgets in the michael@0: * current theme to a pixmap or window, without requiring an actual michael@0: * widget instantiation, similar to the Macintosh Appearance Manager michael@0: * or Windows XP's DrawThemeBackground() API. michael@0: */ michael@0: michael@0: #ifndef _GTK_DRAWING_H_ michael@0: #define _GTK_DRAWING_H_ michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif /* __cplusplus */ michael@0: michael@0: /*** type definitions ***/ michael@0: typedef struct { michael@0: guint8 active; michael@0: guint8 focused; michael@0: guint8 inHover; michael@0: guint8 disabled; michael@0: guint8 isDefault; michael@0: guint8 canDefault; michael@0: /* The depressed state is for buttons which remain active for a longer period: michael@0: * activated toggle buttons or buttons showing a popup menu. */ michael@0: guint8 depressed; michael@0: gint32 curpos; /* curpos and maxpos are used for scrollbars */ michael@0: gint32 maxpos; michael@0: } GtkWidgetState; michael@0: michael@0: typedef struct { michael@0: gint slider_width; michael@0: gint trough_border; michael@0: gint stepper_size; michael@0: gint stepper_spacing; michael@0: gint min_slider_size; michael@0: } MozGtkScrollbarMetrics; michael@0: michael@0: typedef enum { michael@0: MOZ_GTK_STEPPER_DOWN = 1 << 0, michael@0: MOZ_GTK_STEPPER_BOTTOM = 1 << 1, michael@0: MOZ_GTK_STEPPER_VERTICAL = 1 << 2 michael@0: } GtkScrollbarButtonFlags; michael@0: michael@0: /** flags for tab state **/ michael@0: typedef enum { michael@0: /* first eight bits are used to pass a margin */ michael@0: MOZ_GTK_TAB_MARGIN_MASK = 0xFF, michael@0: /* bottom tabs */ michael@0: MOZ_GTK_TAB_BOTTOM = 1 << 8, michael@0: /* the first tab in the group */ michael@0: MOZ_GTK_TAB_FIRST = 1 << 9, michael@0: /* the selected tab */ michael@0: MOZ_GTK_TAB_SELECTED = 1 << 10 michael@0: } GtkTabFlags; michael@0: michael@0: /** flags for menuitems **/ michael@0: typedef enum { michael@0: /* menuitem is part of the menubar */ michael@0: MOZ_TOPLEVEL_MENU_ITEM = 1 << 0 michael@0: } GtkMenuItemFlags; michael@0: michael@0: /* function type for moz_gtk_enable_style_props */ michael@0: typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint); michael@0: michael@0: /*** result/error codes ***/ michael@0: #define MOZ_GTK_SUCCESS 0 michael@0: #define MOZ_GTK_UNKNOWN_WIDGET -1 michael@0: #define MOZ_GTK_UNSAFE_THEME -2 michael@0: michael@0: /*** checkbox/radio flags ***/ michael@0: #define MOZ_GTK_WIDGET_CHECKED 1 michael@0: #define MOZ_GTK_WIDGET_INCONSISTENT (1 << 1) michael@0: michael@0: /*** widget type constants ***/ michael@0: typedef enum { michael@0: /* Paints a GtkButton. flags is a GtkReliefStyle. */ michael@0: MOZ_GTK_BUTTON, michael@0: /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */ michael@0: MOZ_GTK_CHECKBUTTON, michael@0: /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */ michael@0: MOZ_GTK_RADIOBUTTON, michael@0: /** michael@0: * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving michael@0: * the arrow direction. michael@0: */ michael@0: MOZ_GTK_SCROLLBAR_BUTTON, michael@0: /* Paints the trough (track) of a GtkScrollbar. */ michael@0: MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL, michael@0: MOZ_GTK_SCROLLBAR_TRACK_VERTICAL, michael@0: /* Paints the slider (thumb) of a GtkScrollbar. */ michael@0: MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL, michael@0: MOZ_GTK_SCROLLBAR_THUMB_VERTICAL, michael@0: /* Paints a GtkScale. */ michael@0: MOZ_GTK_SCALE_HORIZONTAL, michael@0: MOZ_GTK_SCALE_VERTICAL, michael@0: /* Paints a GtkScale thumb. */ michael@0: MOZ_GTK_SCALE_THUMB_HORIZONTAL, michael@0: MOZ_GTK_SCALE_THUMB_VERTICAL, michael@0: /* Paints a GtkSpinButton */ michael@0: MOZ_GTK_SPINBUTTON, michael@0: MOZ_GTK_SPINBUTTON_UP, michael@0: MOZ_GTK_SPINBUTTON_DOWN, michael@0: MOZ_GTK_SPINBUTTON_ENTRY, michael@0: /* Paints the gripper of a GtkHandleBox. */ michael@0: MOZ_GTK_GRIPPER, michael@0: /* Paints a GtkEntry. */ michael@0: MOZ_GTK_ENTRY, michael@0: /* Paints a GtkOptionMenu. */ michael@0: MOZ_GTK_DROPDOWN, michael@0: /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */ michael@0: MOZ_GTK_DROPDOWN_ARROW, michael@0: /* Paints an entry in an editable option menu */ michael@0: MOZ_GTK_DROPDOWN_ENTRY, michael@0: /* Paints the container part of a GtkCheckButton. */ michael@0: MOZ_GTK_CHECKBUTTON_CONTAINER, michael@0: /* Paints the container part of a GtkRadioButton. */ michael@0: MOZ_GTK_RADIOBUTTON_CONTAINER, michael@0: /* Paints the label of a GtkCheckButton (focus outline) */ michael@0: MOZ_GTK_CHECKBUTTON_LABEL, michael@0: /* Paints the label of a GtkRadioButton (focus outline) */ michael@0: MOZ_GTK_RADIOBUTTON_LABEL, michael@0: /* Paints the background of a GtkHandleBox. */ michael@0: MOZ_GTK_TOOLBAR, michael@0: /* Paints a toolbar separator */ michael@0: MOZ_GTK_TOOLBAR_SEPARATOR, michael@0: /* Paints a GtkToolTip */ michael@0: MOZ_GTK_TOOLTIP, michael@0: /* Paints a GtkFrame (e.g. a status bar panel). */ michael@0: MOZ_GTK_FRAME, michael@0: /* Paints a resize grip for a GtkWindow */ michael@0: MOZ_GTK_RESIZER, michael@0: /* Paints a GtkProgressBar. */ michael@0: MOZ_GTK_PROGRESSBAR, michael@0: /* Paints a progress chunk of a GtkProgressBar. */ michael@0: MOZ_GTK_PROGRESS_CHUNK, michael@0: /* Paints a progress chunk of an indeterminated GtkProgressBar. */ michael@0: MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE, michael@0: /* Paints a progress chunk of a vertical indeterminated GtkProgressBar. */ michael@0: MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE, michael@0: /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */ michael@0: MOZ_GTK_TAB, michael@0: /* Paints the background and border of a GtkNotebook. */ michael@0: MOZ_GTK_TABPANELS, michael@0: /* Paints a GtkArrow for a GtkNotebook. flags is a GtkArrowType. */ michael@0: MOZ_GTK_TAB_SCROLLARROW, michael@0: /* Paints the background and border of a GtkTreeView */ michael@0: MOZ_GTK_TREEVIEW, michael@0: /* Paints treeheader cells */ michael@0: MOZ_GTK_TREE_HEADER_CELL, michael@0: /* Paints sort arrows in treeheader cells */ michael@0: MOZ_GTK_TREE_HEADER_SORTARROW, michael@0: /* Paints an expander for a GtkTreeView */ michael@0: MOZ_GTK_TREEVIEW_EXPANDER, michael@0: /* Paints the background of the menu bar. */ michael@0: MOZ_GTK_MENUBAR, michael@0: /* Paints the background of menus, context menus. */ michael@0: MOZ_GTK_MENUPOPUP, michael@0: /* Paints the arrow of menuitems that contain submenus */ michael@0: MOZ_GTK_MENUARROW, michael@0: /* Paints an arrow in a toolbar button. flags is a GtkArrowType. */ michael@0: MOZ_GTK_TOOLBARBUTTON_ARROW, michael@0: /* Paints items of menubar and popups. */ michael@0: MOZ_GTK_MENUITEM, michael@0: MOZ_GTK_CHECKMENUITEM, michael@0: MOZ_GTK_RADIOMENUITEM, michael@0: MOZ_GTK_MENUSEPARATOR, michael@0: /* Paints a GtkVPaned separator */ michael@0: MOZ_GTK_SPLITTER_HORIZONTAL, michael@0: /* Paints a GtkHPaned separator */ michael@0: MOZ_GTK_SPLITTER_VERTICAL, michael@0: /* Paints the background of a window, dialog or page. */ michael@0: MOZ_GTK_WINDOW michael@0: } GtkThemeWidgetType; michael@0: michael@0: /*** General library functions ***/ michael@0: /** michael@0: * Initializes the drawing library. You must call this function michael@0: * prior to using any other functionality. michael@0: * returns: MOZ_GTK_SUCCESS if there were no errors michael@0: * MOZ_GTK_UNSAFE_THEME if the current theme engine is known michael@0: * to crash with gtkdrawing. michael@0: */ michael@0: gint moz_gtk_init(); michael@0: michael@0: /** michael@0: * Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer michael@0: * to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental". michael@0: * styleGetProp: pointer to gtk_style_get_prop_experimental michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_enable_style_props(style_prop_t styleGetProp); michael@0: michael@0: /** michael@0: * Perform cleanup of the drawing library. You should call this function michael@0: * when your program exits, or you no longer need the library. michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_shutdown(); michael@0: michael@0: #if (MOZ_WIDGET_GTK == 2) michael@0: /** michael@0: * Retrieves the colormap to use for drawables passed to moz_gtk_widget_paint. michael@0: */ michael@0: GdkColormap* moz_gtk_widget_get_colormap(); michael@0: #endif michael@0: michael@0: /*** Widget drawing ***/ michael@0: #if (MOZ_WIDGET_GTK == 2) michael@0: /** michael@0: * Paint a widget in the current theme. michael@0: * widget: a constant giving the widget to paint michael@0: * drawable: the drawable to paint to; michael@0: * it's colormap must be moz_gtk_widget_get_colormap(). michael@0: * rect: the bounding rectangle for the widget michael@0: * cliprect: a clipprect rectangle for this painting operation michael@0: * state: the state of the widget. ignored for some widgets. michael@0: * flags: widget-dependant flags; see the GtkThemeWidgetType definition. michael@0: * direction: the text direction, to draw the widget correctly LTR and RTL. michael@0: */ michael@0: gint michael@0: moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, michael@0: GdkRectangle* rect, GdkRectangle* cliprect, michael@0: GtkWidgetState* state, gint flags, michael@0: GtkTextDirection direction); michael@0: #else michael@0: gint michael@0: moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t *cr, michael@0: GdkRectangle* rect, michael@0: GtkWidgetState* state, gint flags, michael@0: GtkTextDirection direction); michael@0: #endif michael@0: michael@0: michael@0: /*** Widget metrics ***/ michael@0: /** michael@0: * Get the border size of a widget michael@0: * left/right: [OUT] the widget's left/right border michael@0: * top/bottom: [OUT] the widget's top/bottom border michael@0: * direction: the text direction for the widget michael@0: * inhtml: boolean indicating whether this widget will be drawn as a HTML form control, michael@0: * in order to workaround a size issue (MOZ_GTK_BUTTON only, ignored otherwise) michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, michael@0: gint* right, gint* bottom, GtkTextDirection direction, michael@0: gboolean inhtml); michael@0: michael@0: /** michael@0: * Get the desired size of a GtkCheckButton michael@0: * indicator_size: [OUT] the indicator size michael@0: * indicator_spacing: [OUT] the spacing between the indicator and its michael@0: * container michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing); michael@0: michael@0: /** michael@0: * Get the desired size of a GtkRadioButton michael@0: * indicator_size: [OUT] the indicator size michael@0: * indicator_spacing: [OUT] the spacing between the indicator and its michael@0: * container michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing); michael@0: michael@0: /** michael@0: * Get the inner-border value for a GtkButton widget (button or tree header) michael@0: * widget: [IN] the widget to get the border value for michael@0: * inner_border: [OUT] the inner border michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border); michael@0: michael@0: /** Get the focus metrics for a treeheadercell, button, checkbox, or radio button. michael@0: * widget: [IN] the widget to get the focus metrics for michael@0: * interior_focus: [OUT] whether the focus is drawn around the michael@0: * label (TRUE) or around the whole container (FALSE) michael@0: * focus_width: [OUT] the width of the focus line michael@0: * focus_pad: [OUT] the padding between the focus line and children michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus, michael@0: gint* focus_width, gint* focus_pad); michael@0: michael@0: /** Get the horizontal padding for the menuitem widget or checkmenuitem widget. michael@0: * horizontal_padding: [OUT] The left and right padding of the menuitem or checkmenuitem michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_menuitem_get_horizontal_padding(gint* horizontal_padding); michael@0: michael@0: gint michael@0: moz_gtk_checkmenuitem_get_horizontal_padding(gint* horizontal_padding); michael@0: michael@0: /** michael@0: * Some GTK themes draw their indication for the default button outside michael@0: * the button (e.g. the glow in New Wave). This gets the extra space necessary. michael@0: * michael@0: * border_top: [OUT] extra space to add above michael@0: * border_left: [OUT] extra space to add to the left michael@0: * border_bottom: [OUT] extra space to add underneath michael@0: * border_right: [OUT] extra space to add to the right michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_button_get_default_overflow(gint* border_top, gint* border_left, michael@0: gint* border_bottom, gint* border_right); michael@0: michael@0: /** michael@0: * Get the desired size of a GtkScale thumb michael@0: * orient: [IN] the scale orientation michael@0: * thumb_length: [OUT] the length of the thumb michael@0: * thumb_height: [OUT] the height of the thumb michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height); michael@0: michael@0: /** michael@0: * Get the desired metrics for a GtkScrollbar michael@0: * metrics: [IN] struct which will contain the metrics michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint michael@0: moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics); michael@0: michael@0: /** michael@0: * Get the desired size of a dropdown arrow button michael@0: * width: [OUT] the desired width michael@0: * height: [OUT] the desired height michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_combo_box_entry_button_size(gint* width, gint* height); michael@0: michael@0: /** michael@0: * Get the desired size of a scroll arrow widget michael@0: * width: [OUT] the desired width michael@0: * height: [OUT] the desired height michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height); michael@0: michael@0: /** michael@0: * Get the desired size of an arrow in a button michael@0: * width: [OUT] the desired width michael@0: * height: [OUT] the desired height michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_arrow_size(gint* width, gint* height); michael@0: michael@0: /** michael@0: * Get the desired size of a toolbar separator michael@0: * size: [OUT] the desired width michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_toolbar_separator_width(gint* size); michael@0: michael@0: /** michael@0: * Get the size of a regular GTK expander that shows/hides content michael@0: * size: [OUT] the size of the GTK expander, size = width = height. michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_expander_size(gint* size); michael@0: michael@0: /** michael@0: * Get the size of a treeview's expander (we call them twisties) michael@0: * size: [OUT] the size of the GTK expander, size = width = height. michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_treeview_expander_size(gint* size); michael@0: michael@0: /** michael@0: * Get the desired height of a menu separator michael@0: * size: [OUT] the desired height michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_get_menu_separator_height(gint* size); michael@0: michael@0: /** michael@0: * Get the desired size of a splitter michael@0: * orientation: [IN] GTK_ORIENTATION_HORIZONTAL or GTK_ORIENTATION_VERTICAL michael@0: * size: [OUT] width or height of the splitter handle michael@0: * michael@0: * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise michael@0: */ michael@0: gint moz_gtk_splitter_get_metrics(gint orientation, gint* size); michael@0: michael@0: /** michael@0: * Retrieve an actual GTK scrollbar widget for style analysis. It will not michael@0: * be modified. michael@0: */ michael@0: GtkWidget* moz_gtk_get_scrollbar_widget(void); michael@0: michael@0: /** michael@0: * Get the YTHICKNESS of a tab (notebook extension). michael@0: */ michael@0: gint moz_gtk_get_tab_thickness(void); michael@0: michael@0: /** michael@0: * Get a boolean which indicates whether or not to use images in menus. michael@0: * If TRUE, use images in menus. michael@0: */ michael@0: gboolean moz_gtk_images_in_menus(void); michael@0: michael@0: /** michael@0: * Get a boolean which indicates whether or not to use images in buttons. michael@0: * If TRUE, use images in buttons. michael@0: */ michael@0: gboolean moz_gtk_images_in_buttons(void); michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif /* __cplusplus */ michael@0: michael@0: #endif