OSDN Git Service

Check that the view is not null in GraphicsLayerAndroid::updateFixedPosition()
[android-x86/external-webkit.git] / Source / WebCore / platform / gtk / gtkdrawing.h
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 #undef GTK_DISABLE_DEPRECATED
52
53 #include <gtk/gtk.h>
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif /* __cplusplus */
58
59 /*** type definitions ***/
60 typedef struct {
61   guint8 active;
62   guint8 focused;
63   guint8 inHover;
64   guint8 disabled;
65   guint8 isDefault;
66   guint8 canDefault;
67   /* The depressed state is for buttons which remain active for a longer period:
68    * activated toggle buttons or buttons showing a popup menu. */
69   guint8 depressed;
70   gint32 curpos; /* curpos and maxpos are used for scrollbars */
71   gint32 maxpos;
72 } GtkWidgetState;
73
74 typedef struct {
75   gint slider_width;
76   gint trough_border;
77   gint stepper_size;
78   gint stepper_spacing;
79   gint min_slider_size;
80   gboolean trough_under_steppers;
81   gboolean has_secondary_forward_stepper;
82   gboolean has_secondary_backward_stepper;
83 } MozGtkScrollbarMetrics;
84
85 typedef struct _GtkThemeParts {
86     GdkColormap* colormap;
87     GtkWidget* protoWindow;
88     GtkWidget* protoLayout;
89     GtkWidget* horizScrollbarWidget;
90     GtkWidget* vertScrollbarWidget;
91     GtkWidget* scrolledWindowWidget;
92 } GtkThemeParts;
93
94 typedef enum {
95   MOZ_GTK_STEPPER_DOWN        = 1 << 0,
96   MOZ_GTK_STEPPER_BOTTOM      = 1 << 1,
97   MOZ_GTK_STEPPER_VERTICAL    = 1 << 2
98 } GtkScrollbarButtonFlags;
99
100 /* function type for moz_gtk_enable_style_props */
101 typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
102
103 /*** result/error codes ***/
104 #define MOZ_GTK_SUCCESS 0
105 #define MOZ_GTK_UNKNOWN_WIDGET -1
106 #define MOZ_GTK_UNSAFE_THEME -2
107
108 /*** widget type constants ***/
109 typedef enum {
110   /* Paints a GtkButton. flags is a GtkReliefStyle. */
111   MOZ_GTK_BUTTON,
112   /**
113    * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
114    * the arrow direction.
115    */
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;
126
127 /*** General library functions ***/
128 /**
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.
134  */
135 gint moz_gtk_init();
136
137 /**
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.
141  */
142 void
143 moz_gtk_use_theme_parts(GtkThemeParts* parts);
144
145 /**
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
149  * 
150  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
151  */
152 gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
153
154 /**
155  * Perform cleanup of the drawing library. You should call this function
156  * when your program exits, or you no longer need the library.
157  *
158  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
159  */
160 gint moz_gtk_shutdown();
161
162 /**
163  * Destroy the widgets in the given GtkThemeParts, which should
164  * be destroyed before the GtkThemeParts can be freed.
165  */
166 void moz_gtk_destroy_theme_parts_widgets(GtkThemeParts* parts);
167
168 /*** Widget drawing ***/
169 /**
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.
177  */
178 gint
179 moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
180                      GdkRectangle* rect, GdkRectangle* cliprect,
181                      GtkWidgetState* state, gint flags,
182                      GtkTextDirection direction);
183
184 /*** Widget metrics ***/
185 /**
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)
192  *
193  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
194  */
195 gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, 
196                                gint* right, gint* bottom, GtkTextDirection direction,
197                                gboolean inhtml);
198 /**
199  * Get the desired metrics for a GtkScrollbar
200  * metrics:          [IN]  struct which will contain the metrics
201  *
202  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
203  */
204 gint
205 moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
206
207 /**
208  * Retrieve an actual GTK scrollbar widget for style analysis. It will not
209  * be modified.
210  */
211 GtkWidget* moz_gtk_get_scrollbar_widget(void);
212
213 #ifdef __cplusplus
214 }
215 #endif /* __cplusplus */
216
217 #endif