~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/gfx/src/gtk/gtkdrawing.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
  gint32 curpos; /* curpos and maxpos are used for scrollbars */
 
67
  gint32 maxpos;
 
68
} GtkWidgetState;
 
69
 
 
70
typedef struct {
 
71
  gint slider_width;
 
72
  gint trough_border;
 
73
  gint stepper_size;
 
74
  gint stepper_spacing;
 
75
  gint min_slider_size;
 
76
} MozGtkScrollbarMetrics;
 
77
 
 
78
/** flags for tab state **/
 
79
typedef enum {
 
80
  /* the first tab in the group */
 
81
  MOZ_GTK_TAB_FIRST           = 1 << 0,
 
82
  /* the tab just before the selected tab */
 
83
  MOZ_GTK_TAB_BEFORE_SELECTED = 1 << 1,
 
84
  /* the selected tab */
 
85
  MOZ_GTK_TAB_SELECTED        = 1 << 2
 
86
} GtkTabFlags;
 
87
 
 
88
/* function type for moz_gtk_enable_style_props */
 
89
typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
 
90
 
 
91
/*** result/error codes ***/
 
92
#define MOZ_GTK_SUCCESS 0
 
93
#define MOZ_GTK_UNKNOWN_WIDGET -1
 
94
#define MOZ_GTK_UNSAFE_THEME -2
 
95
 
 
96
/*** widget type constants ***/
 
97
typedef enum {
 
98
  /* Paints a GtkButton. flags is a GtkReliefStyle. */
 
99
  MOZ_GTK_BUTTON,
 
100
  /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
 
101
  MOZ_GTK_CHECKBUTTON,
 
102
  /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
 
103
  MOZ_GTK_RADIOBUTTON,
 
104
  /**
 
105
   * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
 
106
   * the arrow direction.
 
107
   */
 
108
  MOZ_GTK_SCROLLBAR_BUTTON,
 
109
  /* Paints the trough (track) of a GtkScrollbar. */
 
110
  MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL,
 
111
  MOZ_GTK_SCROLLBAR_TRACK_VERTICAL,
 
112
  /* Paints the slider (thumb) of a GtkScrollbar. */
 
113
  MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
 
114
  MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
 
115
  /* Paints the gripper of a GtkHandleBox. */
 
116
  MOZ_GTK_GRIPPER,
 
117
  /* Paints a GtkEntry. */
 
118
  MOZ_GTK_ENTRY,
 
119
  /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
 
120
  MOZ_GTK_DROPDOWN_ARROW,
 
121
  /* Paints the container part of a GtkCheckButton. */
 
122
  MOZ_GTK_CHECKBUTTON_CONTAINER,
 
123
  /* Paints the container part of a GtkRadioButton. */
 
124
  MOZ_GTK_RADIOBUTTON_CONTAINER,
 
125
  /* Paints the label of a GtkCheckButton (focus outline) */
 
126
  MOZ_GTK_CHECKBUTTON_LABEL,
 
127
  /* Paints the label of a GtkRadioButton (focus outline) */
 
128
  MOZ_GTK_RADIOBUTTON_LABEL,
 
129
  /* Paints the background of a GtkHandleBox. */
 
130
  MOZ_GTK_TOOLBAR,
 
131
  /* Paints a GtkToolTip */
 
132
  MOZ_GTK_TOOLTIP,
 
133
  /* Paints a GtkFrame (e.g. a status bar panel). */
 
134
  MOZ_GTK_FRAME,
 
135
  /* Paints a GtkProgressBar. */
 
136
  MOZ_GTK_PROGRESSBAR,
 
137
  /* Paints a progress chunk of a GtkProgressBar. */
 
138
  MOZ_GTK_PROGRESS_CHUNK,
 
139
  /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
 
140
  MOZ_GTK_TAB,
 
141
  /* Paints the background and border of a GtkNotebook. */
 
142
  MOZ_GTK_TABPANELS,
 
143
  /* Paints the background of the menu bar. */
 
144
  MOZ_GTK_MENUBAR,
 
145
  /* Paints the background of menus, context menus. */
 
146
  MOZ_GTK_MENUPOPUP,
 
147
  /* Paints items of menubar and popups. */
 
148
  MOZ_GTK_MENUITEM,
 
149
  /* Paints the background of a window, dialog or page. */
 
150
  MOZ_GTK_WINDOW
 
151
} GtkThemeWidgetType;
 
152
 
 
153
/*** General library functions ***/
 
154
/**
 
155
 * Initializes the drawing library.  You must call this function
 
156
 * prior to using any other functionality.
 
157
 * returns: MOZ_GTK_SUCCESS if there were no errors
 
158
 *          MOZ_GTK_UNSAFE_THEME if the current theme engine is known
 
159
 *                               to crash with gtkdrawing.
 
160
 */
 
161
gint moz_gtk_init();
 
162
 
 
163
/**
 
164
 * Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer
 
165
 * to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental".
 
166
 * styleGetProp:  pointer to gtk_style_get_prop_experimental
 
167
 * 
 
168
 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
169
 */
 
170
gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
 
171
 
 
172
/**
 
173
 * Perform cleanup of the drawing library. You should call this function
 
174
 * when your program exits, or you no longer need the library.
 
175
 *
 
176
 * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
177
 */
 
178
gint moz_gtk_shutdown();
 
179
 
 
180
 
 
181
/*** Widget drawing ***/
 
182
/**
 
183
 * Paint a widget in the current theme.
 
184
 * widget:   a constant giving the widget to paint
 
185
 * rect:     the bounding rectangle for the widget
 
186
 * cliprect: a clipprect rectangle for this painting operation
 
187
 * state:    the state of the widget.  ignored for some widgets.
 
188
 * flags:    widget-dependant flags; see the GtkThemeWidgetType definition.
 
189
 */
 
190
gint
 
191
moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
 
192
                     GdkRectangle* rect, GdkRectangle* cliprect,
 
193
                     GtkWidgetState* state, gint flags);
 
194
 
 
195
 
 
196
/*** Widget metrics ***/
 
197
/**
 
198
 * Get the border size of a widget
 
199
 * xthickness:  [OUT] the widget's left/right border
 
200
 * ythickness:  [OUT] the widget's top/bottom border
 
201
 *
 
202
 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
203
 */
 
204
gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
 
205
                               gint* ythickness);
 
206
 
 
207
/**
 
208
 * Get the desired size of a GtkCheckButton
 
209
 * indicator_size:     [OUT] the indicator size
 
210
 * indicator_spacing:  [OUT] the spacing between the indicator and its
 
211
 *                     container
 
212
 *
 
213
 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
214
 */
 
215
gint
 
216
moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing);
 
217
 
 
218
/**
 
219
 * Get the desired size of a GtkRadioButton
 
220
 * indicator_size:     [OUT] the indicator size
 
221
 * indicator_spacing:  [OUT] the spacing between the indicator and its
 
222
 *                     container
 
223
 *
 
224
 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
225
 */
 
226
gint
 
227
moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing);
 
228
 
 
229
/** Get the focus metrics for a button, checkbox, or radio button.
 
230
 * interior_focus:     [OUT] whether the focus is drawn around the
 
231
 *                           label (TRUE) or around the whole container (FALSE)
 
232
 * focus_width:        [OUT] the width of the focus line
 
233
 * focus_pad:          [OUT] the padding between the focus line and children
 
234
 *
 
235
 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
236
 */
 
237
gint
 
238
moz_gtk_button_get_focus(gboolean* interior_focus,
 
239
                         gint* focus_width, gint* focus_pad);
 
240
gint
 
241
moz_gtk_checkbox_get_focus(gboolean* interior_focus,
 
242
                           gint* focus_width, gint* focus_pad);
 
243
gint
 
244
moz_gtk_radio_get_focus(gboolean* interior_focus,
 
245
                        gint* focus_width, gint* focus_pad);
 
246
 
 
247
/**
 
248
 * Get the desired metrics for a GtkScrollbar
 
249
 * metrics:          [IN]  struct which will contain the metrics
 
250
 *
 
251
 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
252
 */
 
253
gint
 
254
moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
 
255
 
 
256
/**
 
257
 * Get the desired size of a dropdown arrow button
 
258
 * width:   [OUT] the desired width
 
259
 * height:  [OUT] the desired height
 
260
 *
 
261
 * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
 
262
 */
 
263
gint moz_gtk_get_dropdown_arrow_size(gint* width, gint* height);
 
264
 
 
265
#ifdef __cplusplus
 
266
}
 
267
#endif /* __cplusplus */
 
268
 
 
269
#endif