]> Pileus Git - ~andy/gtk/blob - gtk/gtkstyle.c
Add back as wrapper function to restore source/binary compatibility.
[~andy/gtk] / gtk / gtkstyle.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 #include <math.h>
20 #include "gtkgc.h"
21 #include "gtkrc.h"
22 #include "gtkstyle.h"
23 #include "gtkthemes.h"
24 #include "gtkwidget.h"
25 #include "gtkthemes.h"
26 #include "gdk/gdkprivate.h"
27
28
29 #define LIGHTNESS_MULT  1.3
30 #define DARKNESS_MULT   0.7
31
32 static void         gtk_style_init         (GtkStyle    *style,
33                                             GdkColormap *colormap,
34                                             gint         depth);
35 static void         gtk_style_destroy      (GtkStyle    *style);
36
37 static void gtk_default_draw_hline   (GtkStyle      *style,
38                                       GdkWindow     *window,
39                                       GtkStateType   state_type,
40                                       GdkRectangle  *area,
41                                       GtkWidget     *widget,
42                                       gchar         *detail,
43                                       gint           x1,
44                                       gint           x2,
45                                       gint           y);
46 static void gtk_default_draw_vline   (GtkStyle      *style,
47                                       GdkWindow     *window,
48                                       GtkStateType   state_type,
49                                       GdkRectangle  *area,
50                                       GtkWidget     *widget,
51                                       gchar         *detail,
52                                       gint           y1,
53                                       gint           y2,
54                                       gint           x);
55 static void gtk_default_draw_shadow  (GtkStyle      *style,
56                                       GdkWindow     *window,
57                                       GtkStateType   state_type,
58                                       GtkShadowType  shadow_type,
59                                       GdkRectangle  *area,
60                                       GtkWidget     *widget,
61                                       gchar         *detail,
62                                       gint           x,
63                                       gint           y,
64                                       gint           width,
65                                       gint           height);
66 static void gtk_default_draw_shadow  (GtkStyle      *style,
67                                       GdkWindow     *window,
68                                       GtkStateType   state_type,
69                                       GtkShadowType  shadow_type,
70                                       GdkRectangle  *area,
71                                       GtkWidget     *widget,
72                                       gchar         *detail,
73                                       gint           x,
74                                       gint           y,
75                                       gint           width,
76                                       gint           height);
77 static void gtk_default_draw_polygon (GtkStyle      *style,
78                                       GdkWindow     *window,
79                                       GtkStateType   state_type,
80                                       GtkShadowType  shadow_type,
81                                       GdkRectangle  *area,
82                                       GtkWidget     *widget,
83                                       gchar         *detail,
84                                       GdkPoint      *points,
85                                       gint           npoints,
86                                       gboolean       fill);
87 static void gtk_default_draw_arrow   (GtkStyle      *style,
88                                       GdkWindow     *window,
89                                       GtkStateType   state_type,
90                                       GtkShadowType  shadow_type,
91                                       GdkRectangle  *area,
92                                       GtkWidget     *widget,
93                                       gchar         *detail,
94                                       GtkArrowType   arrow_type,
95                                       gboolean       fill,
96                                       gint           x,
97                                       gint           y,
98                                       gint           width,
99                                       gint           height);
100 static void gtk_default_draw_diamond (GtkStyle      *style,
101                                       GdkWindow     *window,
102                                       GtkStateType   state_type,
103                                       GtkShadowType  shadow_type,
104                                       GdkRectangle  *area,
105                                       GtkWidget     *widget,
106                                       gchar         *detail,
107                                       gint           x,
108                                       gint           y,
109                                       gint           width,
110                                       gint           height);
111 static void gtk_default_draw_oval    (GtkStyle      *style,
112                                       GdkWindow     *window,
113                                       GtkStateType   state_type,
114                                       GtkShadowType  shadow_type,
115                                       GdkRectangle  *area,
116                                       GtkWidget     *widget,
117                                       gchar         *detail,
118                                       gint           x,
119                                       gint           y,
120                                       gint           width,
121                                       gint           height);
122 static void gtk_default_draw_string  (GtkStyle      *style,
123                                       GdkWindow     *window,
124                                       GtkStateType   state_type,
125                                       GdkRectangle  *area,
126                                       GtkWidget     *widget,
127                                       gchar         *detail,
128                                       gint           x,
129                                       gint           y,
130                                       const gchar   *string);
131 static void gtk_default_draw_box     (GtkStyle      *style,
132                                       GdkWindow     *window,
133                                       GtkStateType   state_type,
134                                       GtkShadowType  shadow_type,
135                                       GdkRectangle  *area,
136                                       GtkWidget     *widget,
137                                       gchar         *detail,
138                                       gint           x,
139                                       gint           y,
140                                       gint           width,
141                                       gint           height);
142 static void gtk_default_draw_flat_box (GtkStyle      *style,
143                                        GdkWindow     *window,
144                                        GtkStateType   state_type,
145                                        GtkShadowType  shadow_type,
146                                        GdkRectangle  *area,
147                                        GtkWidget     *widget,
148                                        gchar         *detail,
149                                        gint           x,
150                                        gint           y,
151                                        gint           width,
152                                        gint           height);
153 static void gtk_default_draw_check   (GtkStyle      *style,
154                                       GdkWindow     *window,
155                                       GtkStateType   state_type,
156                                       GtkShadowType  shadow_type,
157                                       GdkRectangle  *area,
158                                       GtkWidget     *widget,
159                                       gchar         *detail,
160                                       gint           x,
161                                       gint           y,
162                                       gint           width,
163                                       gint           height);
164 static void gtk_default_draw_option  (GtkStyle      *style,
165                                       GdkWindow     *window,
166                                       GtkStateType   state_type,
167                                       GtkShadowType  shadow_type,
168                                       GdkRectangle  *area,
169                                       GtkWidget     *widget,
170                                       gchar         *detail,
171                                       gint           x,
172                                       gint           y,
173                                       gint           width,
174                                       gint           height);
175 static void gtk_default_draw_cross   (GtkStyle      *style,
176                                       GdkWindow     *window,
177                                       GtkStateType   state_type,
178                                       GtkShadowType  shadow_type,
179                                       GdkRectangle  *area,
180                                       GtkWidget     *widget,
181                                       gchar         *detail,
182                                       gint           x,
183                                       gint           y,
184                                       gint           width,
185                                       gint           height);
186 static void gtk_default_draw_ramp    (GtkStyle      *style,
187                                       GdkWindow     *window,
188                                       GtkStateType   state_type,
189                                       GtkShadowType  shadow_type,
190                                       GdkRectangle  *area,
191                                       GtkWidget     *widget,
192                                       gchar         *detail,
193                                       GtkArrowType   arrow_type,
194                                       gint           x,
195                                       gint           y,
196                                       gint           width,
197                                       gint           height);
198 static void gtk_default_draw_tab     (GtkStyle      *style,
199                                       GdkWindow     *window,
200                                       GtkStateType   state_type,
201                                       GtkShadowType  shadow_type,
202                                       GdkRectangle  *area,
203                                       GtkWidget     *widget,
204                                       gchar         *detail,
205                                       gint           x,
206                                       gint           y,
207                                       gint           width,
208                                       gint           height);
209 static void gtk_default_draw_shadow_gap (GtkStyle       *style,
210                                          GdkWindow      *window,
211                                          GtkStateType    state_type,
212                                          GtkShadowType   shadow_type,
213                                          GdkRectangle   *area,
214                                          GtkWidget      *widget,
215                                          gchar          *detail,
216                                          gint            x,
217                                          gint            y,
218                                          gint            width,
219                                          gint            height,
220                                          GtkPositionType gap_side,
221                                          gint            gap_x,
222                                          gint            gap_width);
223 static void gtk_default_draw_box_gap (GtkStyle       *style,
224                                       GdkWindow      *window,
225                                       GtkStateType    state_type,
226                                       GtkShadowType   shadow_type,
227                                       GdkRectangle   *area,
228                                       GtkWidget      *widget,
229                                       gchar          *detail,
230                                       gint            x,
231                                       gint            y,
232                                       gint            width,
233                                       gint            height,
234                                       GtkPositionType gap_side,
235                                       gint            gap_x,
236                                       gint            gap_width);
237 static void gtk_default_draw_extension (GtkStyle       *style,
238                                         GdkWindow      *window,
239                                         GtkStateType    state_type,
240                                         GtkShadowType   shadow_type,
241                                         GdkRectangle   *area,
242                                         GtkWidget      *widget,
243                                         gchar          *detail,
244                                         gint            x,
245                                         gint            y,
246                                         gint            width,
247                                         gint            height,
248                                         GtkPositionType gap_side);
249 static void gtk_default_draw_focus   (GtkStyle      *style,
250                                       GdkWindow     *window,
251                                       GdkRectangle  *area,
252                                       GtkWidget     *widget,
253                                       gchar         *detail,
254                                       gint           x,
255                                       gint           y,
256                                       gint           width,
257                                       gint           height);
258 static void gtk_default_draw_slider  (GtkStyle      *style,
259                                       GdkWindow     *window,
260                                       GtkStateType   state_type,
261                                       GtkShadowType  shadow_type,
262                                       GdkRectangle  *area,
263                                       GtkWidget     *widget,
264                                       gchar         *detail,
265                                       gint           x,
266                                       gint           y,
267                                       gint           width,
268                                       gint           height,
269                                       GtkOrientation orientation);
270 static void gtk_default_draw_handle  (GtkStyle      *style,
271                                       GdkWindow     *window,
272                                       GtkStateType   state_type,
273                                       GtkShadowType  shadow_type,
274                                       GdkRectangle  *area,
275                                       GtkWidget     *widget,
276                                       gchar         *detail,
277                                       gint           x,
278                                       gint           y,
279                                       gint           width,
280                                       gint           height,
281                                       GtkOrientation orientation);
282
283
284 static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
285 static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
286 static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
287
288
289 static const GtkStyleClass default_class =
290 {
291   2,
292   2,
293   gtk_default_draw_hline,
294   gtk_default_draw_vline,
295   gtk_default_draw_shadow,
296   gtk_default_draw_polygon,
297   gtk_default_draw_arrow,
298   gtk_default_draw_diamond,
299   gtk_default_draw_oval,
300   gtk_default_draw_string,
301   gtk_default_draw_box,
302   gtk_default_draw_flat_box,
303   gtk_default_draw_check,
304   gtk_default_draw_option,
305   gtk_default_draw_cross,
306   gtk_default_draw_ramp,
307   gtk_default_draw_tab,
308   gtk_default_draw_shadow_gap,
309   gtk_default_draw_box_gap,
310   gtk_default_draw_extension,
311   gtk_default_draw_focus,
312   gtk_default_draw_slider,
313   gtk_default_draw_handle
314 };
315 GdkFont *default_font = NULL;
316
317 static GdkColor gtk_default_normal_fg =      { 0,      0,      0,      0 };
318 static GdkColor gtk_default_active_fg =      { 0,      0,      0,      0 };
319 static GdkColor gtk_default_prelight_fg =    { 0,      0,      0,      0 };
320 static GdkColor gtk_default_selected_fg =    { 0, 0xffff, 0xffff, 0xffff };
321 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
322
323 static GdkColor gtk_default_normal_bg =      { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
324 static GdkColor gtk_default_active_bg =      { 0, 0xc350, 0xc350, 0xc350 };
325 static GdkColor gtk_default_prelight_bg =    { 0, 0xea60, 0xea60, 0xea60 };
326 static GdkColor gtk_default_selected_bg =    { 0,      0,      0, 0x9c40 };
327 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
328
329 GtkStyle*
330 gtk_style_copy (GtkStyle     *style)
331 {
332   GtkStyle *new_style;
333   guint i;
334   
335   g_return_val_if_fail (style != NULL, NULL);
336   
337   new_style = gtk_style_new ();
338   
339   for (i = 0; i < 5; i++)
340     {
341       new_style->fg[i] = style->fg[i];
342       new_style->bg[i] = style->bg[i];
343       new_style->text[i] = style->text[i];
344       new_style->base[i] = style->base[i];
345       
346       new_style->bg_pixmap[i] = style->bg_pixmap[i];
347     }
348   
349   new_style->font = style->font;
350   gdk_font_ref (new_style->font);
351   
352   return new_style;
353 }
354
355 static GtkStyle*
356 gtk_style_duplicate (GtkStyle     *style)
357 {
358   GtkStyle *new_style;
359   
360   g_return_val_if_fail (style != NULL, NULL);
361   
362   new_style = gtk_style_copy (style);
363   
364   style->styles = g_slist_append (style->styles, new_style);
365   new_style->styles = style->styles;  
366   
367   if (style->rc_style)
368     {
369       new_style->rc_style = style->rc_style;
370       gtk_rc_style_ref (style->rc_style);
371     }
372   
373   if (style->engine)
374     {
375       new_style->engine = style->engine;
376       new_style->engine->duplicate_style (new_style, style);
377     }
378   
379   return new_style;
380 }
381
382 GtkStyle*
383 gtk_style_new (void)
384 {
385   GtkStyle *style;
386   gint i;
387   
388   style = g_new0 (GtkStyle, 1);
389   
390   if (!default_font)
391     default_font =
392       gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
393   
394   style->font = default_font;
395   gdk_font_ref (style->font);
396   
397   style->ref_count = 1;
398   style->attach_count = 0;
399   style->colormap = NULL;
400   style->depth = -1;
401   style->klass = &default_class;
402   
403   style->black.red = 0;
404   style->black.green = 0;
405   style->black.blue = 0;
406   
407   style->white.red = 65535;
408   style->white.green = 65535;
409   style->white.blue = 65535;
410   
411   style->black_gc = NULL;
412   style->white_gc = NULL;
413   
414   style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
415   style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
416   style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
417   style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
418   style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
419   
420   style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
421   style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
422   style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
423   style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
424   style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
425   
426   for (i = 0; i < 4; i++)
427     {
428       style->text[i] = style->fg[i];
429       style->base[i] = style->white;
430     }
431   
432   style->base[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
433   style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
434   
435   for (i = 0; i < 5; i++)
436     style->bg_pixmap[i] = NULL;
437   
438   style->engine = NULL;
439   style->engine_data = NULL;
440   
441   style->rc_style = NULL;
442   
443   for (i = 0; i < 5; i++)
444     {
445       style->fg_gc[i] = NULL;
446       style->bg_gc[i] = NULL;
447       style->light_gc[i] = NULL;
448       style->dark_gc[i] = NULL;
449       style->mid_gc[i] = NULL;
450       style->text_gc[i] = NULL;
451       style->base_gc[i] = NULL;
452     }
453   
454   return style;
455 }
456
457 GtkStyle *
458 gtk_style_attach (GtkStyle  *style,
459                   GdkWindow *window)
460 {
461   GSList *styles;
462   GtkStyle *new_style = NULL;
463   GdkColormap *colormap;
464   gint depth;
465   
466   g_return_val_if_fail (style != NULL, NULL);
467   g_return_val_if_fail (window != NULL, NULL);
468   
469   colormap = gdk_window_get_colormap (window);
470   depth = gdk_window_get_visual (window)->depth;
471   
472   if (!style->styles)
473     style->styles = g_slist_append (NULL, style);
474   
475   styles = style->styles;
476   while (styles)
477     {
478       new_style = styles->data;
479       
480       if (new_style->attach_count == 0)
481         {
482           gtk_style_init (new_style, colormap, depth);
483           break;
484         }
485       else if ((new_style->colormap == colormap) &&
486                (new_style->depth == depth))
487         break;
488       
489       new_style = NULL;
490       styles = styles->next;
491     }
492   
493   if (!new_style)
494     {
495       new_style = gtk_style_duplicate (style);
496       gtk_style_init (new_style, colormap, depth);
497     }
498   
499   if (new_style->attach_count == 0)
500     gtk_style_ref (new_style);
501   
502   
503   
504   new_style->attach_count++;
505   
506   return new_style;
507 }
508
509 void
510 gtk_style_detach (GtkStyle *style)
511 {
512   gint i;
513   
514   g_return_if_fail (style != NULL);
515   
516   style->attach_count -= 1;
517   if (style->attach_count == 0)
518     {
519       if (style->engine)
520         style->engine->unrealize_style (style);
521       
522       gtk_gc_release (style->black_gc);
523       gtk_gc_release (style->white_gc);
524       
525       for (i = 0; i < 5; i++)
526         {
527           gtk_gc_release (style->fg_gc[i]);
528           gtk_gc_release (style->bg_gc[i]);
529           gtk_gc_release (style->light_gc[i]);
530           gtk_gc_release (style->dark_gc[i]);
531           gtk_gc_release (style->mid_gc[i]);
532           gtk_gc_release (style->text_gc[i]);
533           gtk_gc_release (style->base_gc[i]);
534         }
535       
536       gtk_style_unref (style);
537     }
538 }
539
540 GtkStyle*
541 gtk_style_ref (GtkStyle *style)
542 {
543   g_return_val_if_fail (style != NULL, NULL);
544   
545   style->ref_count += 1;
546   return style;
547 }
548
549 void
550 gtk_style_unref (GtkStyle *style)
551 {
552   g_return_if_fail (style != NULL);
553   
554   style->ref_count -= 1;
555   if (style->ref_count == 0)
556     gtk_style_destroy (style);
557 }
558
559 static void
560 gtk_style_init (GtkStyle *style,
561                 GdkColormap *colormap,
562                 gint         depth)
563 {
564   GdkGCValues gc_values;
565   GdkGCValuesMask gc_values_mask;
566   gint i;
567   
568   g_return_if_fail (style != NULL);
569   
570   style->colormap = colormap;
571   style->depth = depth;
572   
573   for (i = 0; i < 5; i++)
574     {
575       gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
576       gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
577       
578       style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
579       style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
580       style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
581     }
582   
583   gdk_color_black (colormap, &style->black);
584   gdk_color_white (colormap, &style->white);
585   
586   gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
587   if (style->font->type == GDK_FONT_FONT)
588     {
589       gc_values.font = style->font;
590     }
591   else if (style->font->type == GDK_FONT_FONTSET)
592     {
593       gc_values.font = default_font;
594     }
595   
596   gc_values.foreground = style->black;
597   style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
598   
599   gc_values.foreground = style->white;
600   style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
601   
602   for (i = 0; i < 5; i++)
603     {
604       if (style->rc_style && style->rc_style->bg_pixmap_name[i])
605         style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
606                                                  &style->bg[i],
607                                                  style->rc_style->bg_pixmap_name[i]);
608       
609       if (!gdk_color_alloc (colormap, &style->fg[i]))
610         g_warning ("unable to allocate color: ( %d %d %d )",
611                    style->fg[i].red, style->fg[i].green, style->fg[i].blue);
612       if (!gdk_color_alloc (colormap, &style->bg[i]))
613         g_warning ("unable to allocate color: ( %d %d %d )",
614                    style->bg[i].red, style->bg[i].green, style->bg[i].blue);
615       if (!gdk_color_alloc (colormap, &style->light[i]))
616         g_warning ("unable to allocate color: ( %d %d %d )",
617                    style->light[i].red, style->light[i].green, style->light[i].blue);
618       if (!gdk_color_alloc (colormap, &style->dark[i]))
619         g_warning ("unable to allocate color: ( %d %d %d )",
620                    style->dark[i].red, style->dark[i].green, style->dark[i].blue);
621       if (!gdk_color_alloc (colormap, &style->mid[i]))
622         g_warning ("unable to allocate color: ( %d %d %d )",
623                    style->mid[i].red, style->mid[i].green, style->mid[i].blue);
624       if (!gdk_color_alloc (colormap, &style->text[i]))
625         g_warning ("unable to allocate color: ( %d %d %d )",
626                    style->text[i].red, style->text[i].green, style->text[i].blue);
627       if (!gdk_color_alloc (colormap, &style->base[i]))
628         g_warning ("unable to allocate color: ( %d %d %d )",
629                    style->base[i].red, style->base[i].green, style->base[i].blue);
630       
631       gc_values.foreground = style->fg[i];
632       style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
633       
634       gc_values.foreground = style->bg[i];
635       style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
636       
637       gc_values.foreground = style->light[i];
638       style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
639       
640       gc_values.foreground = style->dark[i];
641       style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
642       
643       gc_values.foreground = style->mid[i];
644       style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
645       
646       gc_values.foreground = style->text[i];
647       style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
648       
649       gc_values.foreground = style->base[i];
650       style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
651     }
652   if (style->engine)
653     style->engine->realize_style (style);
654 }
655
656 static void
657 gtk_style_destroy (GtkStyle *style)
658 {
659   g_return_if_fail (style->attach_count == 0);
660   
661   if (style->styles)
662     {
663       if (style->styles->data != style)
664         g_slist_remove (style->styles, style);
665       else
666         {
667           GSList *tmp_list = style->styles->next;
668           while (tmp_list)
669             {
670               ((GtkStyle *)tmp_list->data)->styles = style->styles->next;
671               tmp_list = tmp_list->next;
672             }
673           g_slist_free_1 (style->styles);
674         }
675     }
676   
677   if (style->engine)
678     {
679       style->engine->destroy_style (style);
680       gtk_theme_engine_unref (style->engine);
681     }
682   
683   gdk_font_unref (style->font);
684   if (style->rc_style)
685     gtk_rc_style_unref (style->rc_style);
686   
687   g_free (style);
688 }
689
690 void
691 gtk_draw_hline (GtkStyle     *style,
692                 GdkWindow    *window,
693                 GtkStateType  state_type,
694                 gint          x1,
695                 gint          x2,
696                 gint          y)
697 {
698   g_return_if_fail (style != NULL);
699   g_return_if_fail (style->klass != NULL);
700   g_return_if_fail (style->klass->draw_hline != NULL);
701   
702   (*style->klass->draw_hline) (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
703 }
704
705
706 void
707 gtk_draw_vline (GtkStyle     *style,
708                 GdkWindow    *window,
709                 GtkStateType  state_type,
710                 gint          y1,
711                 gint          y2,
712                 gint          x)
713 {
714   g_return_if_fail (style != NULL);
715   g_return_if_fail (style->klass != NULL);
716   g_return_if_fail (style->klass->draw_vline != NULL);
717   
718   (*style->klass->draw_vline) (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
719 }
720
721
722 void
723 gtk_draw_shadow (GtkStyle      *style,
724                  GdkWindow     *window,
725                  GtkStateType   state_type,
726                  GtkShadowType  shadow_type,
727                  gint           x,
728                  gint           y,
729                  gint           width,
730                  gint           height)
731 {
732   g_return_if_fail (style != NULL);
733   g_return_if_fail (style->klass != NULL);
734   g_return_if_fail (style->klass->draw_shadow != NULL);
735   
736   (*style->klass->draw_shadow) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
737 }
738
739 void
740 gtk_draw_polygon (GtkStyle      *style,
741                   GdkWindow     *window,
742                   GtkStateType   state_type,
743                   GtkShadowType  shadow_type,
744                   GdkPoint      *points,
745                   gint           npoints,
746                   gboolean       fill)
747 {
748   g_return_if_fail (style != NULL);
749   g_return_if_fail (style->klass != NULL);
750   g_return_if_fail (style->klass->draw_shadow != NULL);
751   
752   (*style->klass->draw_polygon) (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
753 }
754
755 void
756 gtk_draw_arrow (GtkStyle      *style,
757                 GdkWindow     *window,
758                 GtkStateType   state_type,
759                 GtkShadowType  shadow_type,
760                 GtkArrowType   arrow_type,
761                 gboolean       fill,
762                 gint           x,
763                 gint           y,
764                 gint           width,
765                 gint           height)
766 {
767   g_return_if_fail (style != NULL);
768   g_return_if_fail (style->klass != NULL);
769   g_return_if_fail (style->klass->draw_arrow != NULL);
770   
771   (*style->klass->draw_arrow) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
772 }
773
774
775 void
776 gtk_draw_diamond (GtkStyle      *style,
777                   GdkWindow     *window,
778                   GtkStateType   state_type,
779                   GtkShadowType  shadow_type,
780                   gint           x,
781                   gint           y,
782                   gint           width,
783                   gint           height)
784 {
785   g_return_if_fail (style != NULL);
786   g_return_if_fail (style->klass != NULL);
787   g_return_if_fail (style->klass->draw_diamond != NULL);
788   
789   (*style->klass->draw_diamond) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
790 }
791
792
793 void
794 gtk_draw_oval (GtkStyle      *style,
795                GdkWindow     *window,
796                GtkStateType   state_type,
797                GtkShadowType  shadow_type,
798                gint           x,
799                gint           y,
800                gint           width,
801                gint           height)
802 {
803   g_return_if_fail (style != NULL);
804   g_return_if_fail (style->klass != NULL);
805   g_return_if_fail (style->klass->draw_oval != NULL);
806   
807   (*style->klass->draw_oval) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
808 }
809
810 void
811 gtk_draw_string (GtkStyle      *style,
812                  GdkWindow     *window,
813                  GtkStateType   state_type,
814                  gint           x,
815                  gint           y,
816                  const gchar   *string)
817 {
818   g_return_if_fail (style != NULL);
819   g_return_if_fail (style->klass != NULL);
820   g_return_if_fail (style->klass->draw_oval != NULL);
821   
822   (*style->klass->draw_string) (style, window, state_type, NULL, NULL, NULL, x, y, string);
823 }
824
825 void
826 gtk_draw_box (GtkStyle      *style,
827               GdkWindow     *window,
828               GtkStateType   state_type,
829               GtkShadowType  shadow_type,
830               gint           x,
831               gint           y,
832               gint           width,
833               gint           height)
834 {
835   g_return_if_fail (style != NULL);
836   g_return_if_fail (style->klass != NULL);
837   g_return_if_fail (style->klass->draw_box != NULL);
838   
839   (*style->klass->draw_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
840 }
841
842 void
843 gtk_draw_flat_box (GtkStyle      *style,
844                    GdkWindow     *window,
845                    GtkStateType   state_type,
846                    GtkShadowType  shadow_type,
847                    gint           x,
848                    gint           y,
849                    gint           width,
850                    gint           height)
851 {
852   g_return_if_fail (style != NULL);
853   g_return_if_fail (style->klass != NULL);
854   g_return_if_fail (style->klass->draw_flat_box != NULL);
855   
856   (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
857 }
858
859 void
860 gtk_draw_check   (GtkStyle      *style,
861                   GdkWindow     *window,
862                   GtkStateType   state_type,
863                   GtkShadowType  shadow_type,
864                   gint           x,
865                   gint           y,
866                   gint           width,
867                   gint           height)
868 {
869   g_return_if_fail (style != NULL);
870   g_return_if_fail (style->klass != NULL);
871   g_return_if_fail (style->klass->draw_check != NULL);
872   
873   (*style->klass->draw_check) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
874 }
875
876 void
877 gtk_draw_option  (GtkStyle      *style,
878                   GdkWindow     *window,
879                   GtkStateType   state_type,
880                   GtkShadowType  shadow_type,
881                   gint           x,
882                   gint           y,
883                   gint           width,
884                   gint           height)
885 {
886   g_return_if_fail (style != NULL);
887   g_return_if_fail (style->klass != NULL);
888   g_return_if_fail (style->klass->draw_option != NULL);
889   
890   (*style->klass->draw_option) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
891 }
892
893 void
894 gtk_draw_cross   (GtkStyle      *style,
895                   GdkWindow     *window,
896                   GtkStateType   state_type,
897                   GtkShadowType  shadow_type,
898                   gint           x,
899                   gint           y,
900                   gint           width,
901                   gint           height)
902 {
903   g_return_if_fail (style != NULL);
904   g_return_if_fail (style->klass != NULL);
905   g_return_if_fail (style->klass->draw_cross != NULL);
906   
907   (*style->klass->draw_cross) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
908 }
909
910 void
911 gtk_draw_ramp    (GtkStyle      *style,
912                   GdkWindow     *window,
913                   GtkStateType   state_type,
914                   GtkShadowType  shadow_type,
915                   GtkArrowType   arrow_type,
916                   gint           x,
917                   gint           y,
918                   gint           width,
919                   gint           height)
920 {
921   g_return_if_fail (style != NULL);
922   g_return_if_fail (style->klass != NULL);
923   g_return_if_fail (style->klass->draw_ramp != NULL);
924   
925   (*style->klass->draw_ramp) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
926 }
927
928 void
929 gtk_draw_tab     (GtkStyle      *style,
930                   GdkWindow     *window,
931                   GtkStateType   state_type,
932                   GtkShadowType  shadow_type,
933                   gint           x,
934                   gint           y,
935                   gint           width,
936                   gint           height)
937 {
938   g_return_if_fail (style != NULL);
939   g_return_if_fail (style->klass != NULL);
940   g_return_if_fail (style->klass->draw_tab != NULL);
941   
942   (*style->klass->draw_tab) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
943 }
944
945 void
946 gtk_draw_shadow_gap (GtkStyle       *style,
947                      GdkWindow      *window,
948                      GtkStateType    state_type,
949                      GtkShadowType   shadow_type,
950                      gint            x,
951                      gint            y,
952                      gint            width,
953                      gint            height,
954                      GtkPositionType gap_side,
955                      gint            gap_x,
956                      gint            gap_width)
957 {
958   g_return_if_fail (style != NULL);
959   g_return_if_fail (style->klass != NULL);
960   g_return_if_fail (style->klass->draw_shadow_gap != NULL);
961   
962   (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
963 }
964
965 void
966 gtk_draw_box_gap (GtkStyle       *style,
967                   GdkWindow      *window,
968                   GtkStateType    state_type,
969                   GtkShadowType   shadow_type,
970                   gint            x,
971                   gint            y,
972                   gint            width,
973                   gint            height,
974                   GtkPositionType gap_side,
975                   gint            gap_x,
976                   gint            gap_width)
977 {
978   g_return_if_fail (style != NULL);
979   g_return_if_fail (style->klass != NULL);
980   g_return_if_fail (style->klass->draw_box_gap != NULL);
981   
982   (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
983 }
984
985 void
986 gtk_draw_extension (GtkStyle       *style,
987                     GdkWindow      *window,
988                     GtkStateType    state_type,
989                     GtkShadowType   shadow_type,
990                     gint            x,
991                     gint            y,
992                     gint            width,
993                     gint            height,
994                     GtkPositionType gap_side)
995 {
996   g_return_if_fail (style != NULL);
997   g_return_if_fail (style->klass != NULL);
998   g_return_if_fail (style->klass->draw_extension != NULL);
999   
1000   (*style->klass->draw_extension) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1001 }
1002
1003 void
1004 gtk_draw_focus  (GtkStyle      *style,
1005                  GdkWindow     *window,
1006                  gint           x,
1007                  gint           y,
1008                  gint           width,
1009                  gint           height)
1010 {
1011   g_return_if_fail (style != NULL);
1012   g_return_if_fail (style->klass != NULL);
1013   g_return_if_fail (style->klass->draw_focus != NULL);
1014   
1015   (*style->klass->draw_focus) (style, window, NULL, NULL, NULL, x, y, width, height);
1016 }
1017
1018 void 
1019 gtk_draw_slider  (GtkStyle      *style,
1020                   GdkWindow     *window,
1021                   GtkStateType   state_type,
1022                   GtkShadowType  shadow_type,
1023                   gint           x,
1024                   gint           y,
1025                   gint           width,
1026                   gint           height,
1027                   GtkOrientation orientation)
1028 {
1029   g_return_if_fail (style != NULL);
1030   g_return_if_fail (style->klass != NULL);
1031   g_return_if_fail (style->klass->draw_slider != NULL);
1032   
1033   (*style->klass->draw_slider) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1034 }
1035
1036 void 
1037 gtk_draw_handle  (GtkStyle      *style,
1038                   GdkWindow     *window,
1039                   GtkStateType   state_type,
1040                   GtkShadowType  shadow_type,
1041                   gint           x,
1042                   gint           y,
1043                   gint           width,
1044                   gint           height,
1045                   GtkOrientation orientation)
1046 {
1047   g_return_if_fail (style != NULL);
1048   g_return_if_fail (style->klass != NULL);
1049   g_return_if_fail (style->klass->draw_handle != NULL);
1050   
1051   (*style->klass->draw_handle) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1052 }
1053
1054 void
1055 gtk_style_set_background (GtkStyle     *style,
1056                           GdkWindow    *window,
1057                           GtkStateType  state_type)
1058 {
1059   GdkPixmap *pixmap;
1060   gint parent_relative;
1061   
1062   if (style->engine && style->engine->set_background)
1063     {
1064       (*style->engine->set_background) (style, window, state_type);
1065       return;
1066     }
1067   
1068   g_return_if_fail (style != NULL);
1069   g_return_if_fail (window != NULL);
1070   
1071   if (style->bg_pixmap[state_type])
1072     {
1073       if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1074         {
1075           pixmap = NULL;
1076           parent_relative = TRUE;
1077         }
1078       else
1079         {
1080           pixmap = style->bg_pixmap[state_type];
1081           parent_relative = FALSE;
1082         }
1083       
1084       gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1085     }
1086   else
1087     gdk_window_set_background (window, &style->bg[state_type]);
1088 }
1089
1090
1091 /* Default functions */
1092 void
1093 gtk_style_apply_default_background (GtkStyle     *style,
1094                                     GdkWindow    *window,
1095                                     gboolean      copy_area,
1096                                     GtkStateType  state_type, 
1097                                     GdkRectangle *area, 
1098                                     gint          x, 
1099                                     gint          y, 
1100                                     gint          width, 
1101                                     gint          height)
1102 {
1103   GdkRectangle new_rect, old_rect;
1104   GdkGC       *gc;
1105   
1106   if (!style->bg_pixmap[state_type] ||
1107       gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
1108     {
1109       gc = style->bg_gc[state_type];
1110       
1111       old_rect.x = x;
1112       old_rect.y = y;
1113       old_rect.width = width;
1114       old_rect.height = height;
1115       
1116       if (area)
1117         {
1118           if (gdk_rectangle_intersect (area, &old_rect, &new_rect))
1119             gdk_draw_rectangle (window, gc, TRUE, 
1120                                 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1121         }
1122       else
1123         gdk_draw_rectangle (window, gc, TRUE, 
1124                             x, y, width, height);
1125     }
1126   else if (!copy_area || style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1127     {
1128       if (!copy_area)
1129         {
1130           if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1131             gdk_window_set_back_pixmap (window, NULL, TRUE);
1132           else
1133             gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1134         }
1135       
1136       old_rect.x = x;
1137       old_rect.y = y;
1138       old_rect.width = width;
1139       old_rect.height = height;
1140       
1141       if (area && gdk_rectangle_intersect (area, &old_rect, &new_rect))
1142         gdk_window_clear_area (window, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1143       else
1144         gdk_window_clear_area (window, x, y, width, height);
1145     }
1146   else
1147     {
1148       old_rect.x = x;
1149       old_rect.y = y;
1150       old_rect.width = width;
1151       old_rect.height = height;
1152
1153       if (area && gdk_rectangle_intersect (area, &old_rect, &new_rect))
1154         gdk_window_copy_area (window, style->bg_gc[state_type], new_rect.x, new_rect.y,
1155                               style->bg_pixmap[state_type], 0, 0, new_rect.width, new_rect.height);
1156       else
1157         {
1158           gdk_window_clear_area (window, x, y, width, height);
1159           gdk_window_copy_area (window, style->bg_gc[state_type], x, y,
1160                                 style->bg_pixmap[state_type], 0, 0, width, height);
1161         }
1162     }
1163 }
1164
1165 void 
1166 gtk_style_apply_default_pixmap (GtkStyle     *style,
1167                                 GdkWindow    *window,
1168                                 GtkStateType  state_type, 
1169                                 GdkRectangle *area, 
1170                                 gint          x, 
1171                                 gint          y, 
1172                                 gint          width, 
1173                                 gint          height)
1174 {
1175   gtk_style_apply_default_background (style, window, FALSE, state_type,
1176                                       area, x, y, width, height);
1177 }
1178
1179 static void
1180 gtk_default_draw_hline (GtkStyle     *style,
1181                         GdkWindow    *window,
1182                         GtkStateType  state_type,
1183                         GdkRectangle  *area,
1184                         GtkWidget     *widget,
1185                         gchar         *detail,
1186                         gint          x1,
1187                         gint          x2,
1188                         gint          y)
1189 {
1190   gint thickness_light;
1191   gint thickness_dark;
1192   gint i;
1193   
1194   g_return_if_fail (style != NULL);
1195   g_return_if_fail (window != NULL);
1196   
1197   thickness_light = style->klass->ythickness / 2;
1198   thickness_dark = style->klass->ythickness - thickness_light;
1199   
1200   if (area)
1201     {
1202       gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1203       gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1204     }
1205   
1206   if (detail && !strcmp (detail, "label"))
1207     {
1208       if (state_type == GTK_STATE_INSENSITIVE)
1209         gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);   
1210       gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);     
1211     }
1212   else
1213     {
1214       for (i = 0; i < thickness_dark; i++)
1215         {
1216           gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1217           gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1218         }
1219       
1220       y += thickness_dark;
1221       for (i = 0; i < thickness_light; i++)
1222         {
1223           gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1224           gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1225         }
1226     }
1227   
1228   if (area)
1229     {
1230       gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1231       gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1232     }
1233 }
1234
1235
1236 static void
1237 gtk_default_draw_vline (GtkStyle     *style,
1238                         GdkWindow    *window,
1239                         GtkStateType  state_type,
1240                         GdkRectangle  *area,
1241                         GtkWidget     *widget,
1242                         gchar         *detail,
1243                         gint          y1,
1244                         gint          y2,
1245                         gint          x)
1246 {
1247   gint thickness_light;
1248   gint thickness_dark;
1249   gint i;
1250   
1251   g_return_if_fail (style != NULL);
1252   g_return_if_fail (window != NULL);
1253   
1254   thickness_light = style->klass->xthickness / 2;
1255   thickness_dark = style->klass->xthickness - thickness_light;
1256   
1257   if (area)
1258     {
1259       gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1260       gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1261     }
1262   for (i = 0; i < thickness_dark; i++)
1263     {
1264       gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1265       gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1266     }
1267   
1268   x += thickness_dark;
1269   for (i = 0; i < thickness_light; i++)
1270     {
1271       gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1272       gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1273     }
1274   if (area)
1275     {
1276       gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1277       gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1278     }
1279 }
1280
1281
1282 static void
1283 gtk_default_draw_shadow (GtkStyle      *style,
1284                          GdkWindow     *window,
1285                          GtkStateType   state_type,
1286                          GtkShadowType  shadow_type,
1287                          GdkRectangle  *area,
1288                          GtkWidget     *widget,
1289                          gchar         *detail,
1290                          gint           x,
1291                          gint           y,
1292                          gint           width,
1293                          gint           height)
1294 {
1295   GdkGC *gc1 = NULL;
1296   GdkGC *gc2 = NULL;
1297   gint thickness_light;
1298   gint thickness_dark;
1299   gint i;
1300   
1301   g_return_if_fail (style != NULL);
1302   g_return_if_fail (window != NULL);
1303   
1304   if ((width == -1) && (height == -1))
1305     gdk_window_get_size (window, &width, &height);
1306   else if (width == -1)
1307     gdk_window_get_size (window, &width, NULL);
1308   else if (height == -1)
1309     gdk_window_get_size (window, NULL, &height);
1310   
1311   switch (shadow_type)
1312     {
1313     case GTK_SHADOW_NONE:
1314       return;
1315     case GTK_SHADOW_IN:
1316     case GTK_SHADOW_ETCHED_IN:
1317       gc1 = style->light_gc[state_type];
1318       gc2 = style->dark_gc[state_type];
1319       break;
1320     case GTK_SHADOW_OUT:
1321     case GTK_SHADOW_ETCHED_OUT:
1322       gc1 = style->dark_gc[state_type];
1323       gc2 = style->light_gc[state_type];
1324       break;
1325     }
1326   
1327   if (area)
1328     {
1329       gdk_gc_set_clip_rectangle (gc1, area);
1330       gdk_gc_set_clip_rectangle (gc2, area);
1331       if (shadow_type == GTK_SHADOW_IN || 
1332           shadow_type == GTK_SHADOW_OUT)
1333         {
1334           gdk_gc_set_clip_rectangle (style->black_gc, area);
1335           gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1336         }
1337     }
1338   
1339   switch (shadow_type)
1340     {
1341     case GTK_SHADOW_NONE:
1342       break;
1343       
1344     case GTK_SHADOW_IN:
1345       gdk_draw_line (window, gc1,
1346                      x, y + height - 1, x + width - 1, y + height - 1);
1347       gdk_draw_line (window, gc1,
1348                      x + width - 1, y, x + width - 1, y + height - 1);
1349       
1350       gdk_draw_line (window, style->bg_gc[state_type],
1351                      x + 1, y + height - 2, x + width - 2, y + height - 2);
1352       gdk_draw_line (window, style->bg_gc[state_type],
1353                      x + width - 2, y + 1, x + width - 2, y + height - 2);
1354       
1355       gdk_draw_line (window, style->black_gc,
1356                      x + 1, y + 1, x + width - 2, y + 1);
1357       gdk_draw_line (window, style->black_gc,
1358                      x + 1, y + 1, x + 1, y + height - 2);
1359       
1360       gdk_draw_line (window, gc2,
1361                      x, y, x + width - 1, y);
1362       gdk_draw_line (window, gc2,
1363                      x, y, x, y + height - 1);
1364       break;
1365       
1366     case GTK_SHADOW_OUT:
1367       gdk_draw_line (window, gc1,
1368                      x + 1, y + height - 2, x + width - 2, y + height - 2);
1369       gdk_draw_line (window, gc1,
1370                      x + width - 2, y + 1, x + width - 2, y + height - 2);
1371       
1372       gdk_draw_line (window, gc2,
1373                      x, y, x + width - 1, y);
1374       gdk_draw_line (window, gc2,
1375                      x, y, x, y + height - 1);
1376       
1377       gdk_draw_line (window, style->bg_gc[state_type],
1378                      x + 1, y + 1, x + width - 2, y + 1);
1379       gdk_draw_line (window, style->bg_gc[state_type],
1380                      x + 1, y + 1, x + 1, y + height - 2);
1381       
1382       gdk_draw_line (window, style->black_gc,
1383                      x, y + height - 1, x + width - 1, y + height - 1);
1384       gdk_draw_line (window, style->black_gc,
1385                      x + width - 1, y, x + width - 1, y + height - 1);
1386       break;
1387       
1388     case GTK_SHADOW_ETCHED_IN:
1389     case GTK_SHADOW_ETCHED_OUT:
1390       thickness_light = 1;
1391       thickness_dark = 1;
1392       
1393       for (i = 0; i < thickness_dark; i++)
1394         {
1395           gdk_draw_line (window, gc1,
1396                          x + i,
1397                          y + height - i - 1,
1398                          x + width - i - 1,
1399                          y + height - i - 1);
1400           gdk_draw_line (window, gc1,
1401                          x + width - i - 1,
1402                          y + i,
1403                          x + width - i - 1,
1404                          y + height - i - 1);
1405           
1406           gdk_draw_line (window, gc2,
1407                          x + i,
1408                          y + i,
1409                          x + width - i - 2,
1410                          y + i);
1411           gdk_draw_line (window, gc2,
1412                          x + i,
1413                          y + i,
1414                          x + i,
1415                          y + height - i - 2);
1416         }
1417       
1418       for (i = 0; i < thickness_light; i++)
1419         {
1420           gdk_draw_line (window, gc1,
1421                          x + thickness_dark + i,
1422                          y + thickness_dark + i,
1423                          x + width - thickness_dark - i - 1,
1424                          y + thickness_dark + i);
1425           gdk_draw_line (window, gc1,
1426                          x + thickness_dark + i,
1427                          y + thickness_dark + i,
1428                          x + thickness_dark + i,
1429                          y + height - thickness_dark - i - 1);
1430           
1431           gdk_draw_line (window, gc2,
1432                          x + thickness_dark + i,
1433                          y + height - thickness_light - i - 1,
1434                          x + width - thickness_light - 1,
1435                          y + height - thickness_light - i - 1);
1436           gdk_draw_line (window, gc2,
1437                          x + width - thickness_light - i - 1,
1438                          y + thickness_dark + i,
1439                          x + width - thickness_light - i - 1,
1440                          y + height - thickness_light - 1);
1441         }
1442       break;
1443     }
1444   if (area)
1445     {
1446       gdk_gc_set_clip_rectangle (gc1, NULL);
1447       gdk_gc_set_clip_rectangle (gc2, NULL);
1448       if (shadow_type == GTK_SHADOW_IN || 
1449           shadow_type == GTK_SHADOW_OUT)
1450         {
1451           gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1452           gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1453         }
1454     }
1455 }
1456
1457
1458 static void
1459 gtk_default_draw_polygon (GtkStyle      *style,
1460                           GdkWindow     *window,
1461                           GtkStateType   state_type,
1462                           GtkShadowType  shadow_type,
1463                           GdkRectangle  *area,
1464                           GtkWidget     *widget,
1465                           gchar         *detail,
1466                           GdkPoint      *points,
1467                           gint           npoints,
1468                           gboolean       fill)
1469 {
1470 #ifndef M_PI
1471 #define M_PI    3.14159265358979323846
1472 #endif /* M_PI */
1473 #ifndef M_PI_4
1474 #define M_PI_4  0.78539816339744830962
1475 #endif /* M_PI_4 */
1476   
1477   static const gdouble pi_over_4 = M_PI_4;
1478   static const gdouble pi_3_over_4 = M_PI_4 * 3;
1479   
1480   GdkGC *gc1;
1481   GdkGC *gc2;
1482   GdkGC *gc3;
1483   GdkGC *gc4;
1484   gdouble angle;
1485   gint xadjust;
1486   gint yadjust;
1487   gint i;
1488   
1489   g_return_if_fail (style != NULL);
1490   g_return_if_fail (window != NULL);
1491   g_return_if_fail (points != NULL);
1492   
1493   switch (shadow_type)
1494     {
1495     case GTK_SHADOW_IN:
1496       gc1 = style->bg_gc[state_type];
1497       gc2 = style->dark_gc[state_type];
1498       gc3 = style->light_gc[state_type];
1499       gc4 = style->black_gc;
1500       break;
1501     case GTK_SHADOW_ETCHED_IN:
1502       gc1 = style->light_gc[state_type];
1503       gc2 = style->dark_gc[state_type];
1504       gc3 = style->dark_gc[state_type];
1505       gc4 = style->light_gc[state_type];
1506       break;
1507     case GTK_SHADOW_OUT:
1508       gc1 = style->dark_gc[state_type];
1509       gc2 = style->light_gc[state_type];
1510       gc3 = style->black_gc;
1511       gc4 = style->bg_gc[state_type];
1512       break;
1513     case GTK_SHADOW_ETCHED_OUT:
1514       gc1 = style->dark_gc[state_type];
1515       gc2 = style->light_gc[state_type];
1516       gc3 = style->light_gc[state_type];
1517       gc4 = style->dark_gc[state_type];
1518       break;
1519     default:
1520       return;
1521     }
1522   
1523   if (area)
1524     {
1525       gdk_gc_set_clip_rectangle (gc1, area);
1526       gdk_gc_set_clip_rectangle (gc2, area);
1527       gdk_gc_set_clip_rectangle (gc3, area);
1528       gdk_gc_set_clip_rectangle (gc4, area);
1529     }
1530   
1531   if (fill)
1532     gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1533   
1534   npoints--;
1535   
1536   for (i = 0; i < npoints; i++)
1537     {
1538       if ((points[i].x == points[i+1].x) &&
1539           (points[i].y == points[i+1].y))
1540         {
1541           angle = 0;
1542         }
1543       else
1544         {
1545           angle = atan2 (points[i+1].y - points[i].y,
1546                          points[i+1].x - points[i].x);
1547         }
1548       
1549       if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1550         {
1551           if (angle > -pi_over_4)
1552             {
1553               xadjust = 0;
1554               yadjust = 1;
1555             }
1556           else
1557             {
1558               xadjust = 1;
1559               yadjust = 0;
1560             }
1561           
1562           gdk_draw_line (window, gc1,
1563                          points[i].x-xadjust, points[i].y-yadjust,
1564                          points[i+1].x-xadjust, points[i+1].y-yadjust);
1565           gdk_draw_line (window, gc3,
1566                          points[i].x, points[i].y,
1567                          points[i+1].x, points[i+1].y);
1568         }
1569       else
1570         {
1571           if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1572             {
1573               xadjust = 0;
1574               yadjust = 1;
1575             }
1576           else
1577             {
1578               xadjust = 1;
1579               yadjust = 0;
1580             }
1581           
1582           gdk_draw_line (window, gc4,
1583                          points[i].x+xadjust, points[i].y+yadjust,
1584                          points[i+1].x+xadjust, points[i+1].y+yadjust);
1585           gdk_draw_line (window, gc2,
1586                          points[i].x, points[i].y,
1587                          points[i+1].x, points[i+1].y);
1588         }
1589     }
1590   if (area)
1591     {
1592       gdk_gc_set_clip_rectangle (gc1, NULL);
1593       gdk_gc_set_clip_rectangle (gc2, NULL);
1594       gdk_gc_set_clip_rectangle (gc3, NULL);
1595       gdk_gc_set_clip_rectangle (gc4, NULL);
1596     }
1597 }
1598
1599 static void
1600 gtk_default_draw_arrow (GtkStyle      *style,
1601                         GdkWindow     *window,
1602                         GtkStateType   state_type,
1603                         GtkShadowType  shadow_type,
1604                         GdkRectangle  *area,
1605                         GtkWidget     *widget,
1606                         gchar         *detail,
1607                         GtkArrowType   arrow_type,
1608                         gboolean       fill,
1609                         gint           x,
1610                         gint           y,
1611                         gint           width,
1612                         gint           height)
1613 {
1614   GdkGC *gc1;
1615   GdkGC *gc2;
1616   GdkGC *gc3;
1617   GdkGC *gc4;
1618   gint half_width;
1619   gint half_height;
1620   GdkPoint points[3];
1621   
1622   g_return_if_fail (style != NULL);
1623   g_return_if_fail (window != NULL);
1624   
1625   switch (shadow_type)
1626     {
1627     case GTK_SHADOW_IN:
1628       gc1 = style->bg_gc[state_type];
1629       gc2 = style->dark_gc[state_type];
1630       gc3 = style->light_gc[state_type];
1631       gc4 = style->black_gc;
1632       break;
1633     case GTK_SHADOW_OUT:
1634       gc1 = style->dark_gc[state_type];
1635       gc2 = style->light_gc[state_type];
1636       gc3 = style->black_gc;
1637       gc4 = style->bg_gc[state_type];
1638       break;
1639     case GTK_SHADOW_ETCHED_IN:
1640       gc1 = style->light_gc[state_type];
1641       gc2 = style->dark_gc[state_type];
1642       gc3 = NULL;
1643       gc4 = NULL;
1644       break;
1645     case GTK_SHADOW_ETCHED_OUT:
1646       gc1 = style->dark_gc[state_type];
1647       gc2 = style->light_gc[state_type];
1648       gc3 = NULL;
1649       gc4 = NULL;
1650       break;
1651     default:
1652       return;
1653     }
1654   
1655   if ((width == -1) && (height == -1))
1656     gdk_window_get_size (window, &width, &height);
1657   else if (width == -1)
1658     gdk_window_get_size (window, &width, NULL);
1659   else if (height == -1)
1660     gdk_window_get_size (window, NULL, &height);
1661   
1662   half_width = width / 2;
1663   half_height = height / 2;
1664   
1665   if (area)
1666     {
1667       gdk_gc_set_clip_rectangle (gc1, area);
1668       gdk_gc_set_clip_rectangle (gc2, area);
1669       if ((gc3) && (gc4))
1670         {
1671           gdk_gc_set_clip_rectangle (gc3, area);
1672           gdk_gc_set_clip_rectangle (gc4, area);
1673         }
1674     }
1675   
1676   switch (arrow_type)
1677     {
1678     case GTK_ARROW_UP:
1679       if (fill)
1680         {
1681           points[0].x = x + half_width;
1682           points[0].y = y;
1683           points[1].x = x;
1684           points[1].y = y + height - 1;
1685           points[2].x = x + width - 1;
1686           points[2].y = y + height - 1;
1687           
1688           gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1689         }
1690       
1691       switch (shadow_type)
1692         {
1693         case GTK_SHADOW_IN:
1694         case GTK_SHADOW_OUT:
1695           
1696           gdk_draw_line (window, gc1,
1697                          x + 1, y + height - 2,
1698                          x + width - 2, y + height - 2);
1699           gdk_draw_line (window, gc3,
1700                          x + 0, y + height - 1,
1701                          x + width - 1, y + height - 1);
1702           
1703           gdk_draw_line (window, gc1,
1704                          x + width - 2, y + height - 1,
1705                          x + half_width, y + 1);
1706           gdk_draw_line (window, gc3,
1707                          x + width - 1, y + height - 1,
1708                          x + half_width, y);
1709           
1710           gdk_draw_line (window, gc4,
1711                          x + half_width, y + 1,
1712                          x + 1, y + height - 1);
1713           gdk_draw_line (window, gc2,
1714                          x + half_width, y,
1715                          x, y + height - 1);
1716           break;
1717           
1718         case GTK_SHADOW_ETCHED_IN:
1719         case GTK_SHADOW_ETCHED_OUT:
1720           gdk_draw_line (window, gc1,
1721                          x + half_width, y + 1,
1722                          x + 1, y + height - 1);
1723           gdk_draw_line (window, gc1,
1724                          x + 1, y + height - 1,
1725                          x + width - 1, y + height - 1);
1726           gdk_draw_line (window, gc1,
1727                          x + width - 1, y + height - 1,
1728                          x + half_width + 1, y + 1);
1729           
1730           points[0].x = x + half_width;
1731           points[0].y = y;
1732           points[1].x = x;
1733           points[1].y = y + height - 2;
1734           points[2].x = x + width - 2;
1735           points[2].y = y + height - 2;
1736           
1737           gdk_draw_polygon (window, gc2, FALSE, points, 3);
1738           break;
1739           
1740         default:
1741           break;
1742         }
1743       break;
1744       
1745     case GTK_ARROW_DOWN:
1746       if (fill)
1747         {
1748           points[0].x = x + width - 1;
1749           points[0].y = y;
1750           points[1].x = x;
1751           points[1].y = y;
1752           points[2].x = x + half_width;
1753           points[2].y = y + height - 1;
1754           
1755           gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1756         }
1757       switch (shadow_type)
1758         {
1759         case GTK_SHADOW_IN:
1760         case GTK_SHADOW_OUT:
1761           gdk_draw_line (window, gc4,
1762                          x + width - 2,
1763                          y + 1, x + 1, y + 1);
1764           gdk_draw_line (window, gc2,
1765                          x + width - 1, y,
1766                          x, y);
1767           
1768           gdk_draw_line (window, gc4,
1769                          x + 1, y,
1770                          x + half_width, y + height - 2);
1771           gdk_draw_line (window, gc2,
1772                          x, y,
1773                          x + half_width, y + height - 1);
1774           
1775           gdk_draw_line (window, gc1,
1776                          x + half_width, y + height - 2,
1777                          x + width - 2, y);
1778           gdk_draw_line (window, gc3,
1779                          x + half_width, y + height - 1,
1780                          x + width - 1, y);
1781           break;
1782           
1783         case GTK_SHADOW_ETCHED_IN:
1784         case GTK_SHADOW_ETCHED_OUT:
1785           gdk_draw_line (window, gc1,
1786                          x + width - 1, y + 1,
1787                          x + 1, y + 1);
1788           gdk_draw_line (window, gc1,
1789                          x + 1, y + 1,
1790                          x + half_width + 1, y + height - 1);
1791           gdk_draw_line (window, gc1,
1792                          x + half_width + 1, y + height - 2,
1793                          x + width - 1, y);
1794           
1795           points[0].x = x + width - 2;
1796           points[0].y = y;
1797           points[1].x = x;
1798           points[1].y = y;
1799           points[2].x = x + half_width;
1800           points[2].y = y + height - 2;
1801           
1802           gdk_draw_polygon (window, gc2, FALSE, points, 3);
1803           break;
1804           
1805         default:
1806           break;
1807         }
1808       break;
1809     case GTK_ARROW_LEFT:
1810       if (fill)
1811         {
1812           points[0].x = x;
1813           points[0].y = y + half_height;
1814           points[1].x = x + width - 1;
1815           points[1].y = y + height - 1;
1816           points[2].x = x + width - 1;
1817           points[2].y = y;
1818           
1819           gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1820         }
1821       
1822       switch (shadow_type)
1823         {
1824         case GTK_SHADOW_IN:
1825         case GTK_SHADOW_OUT:
1826           gdk_draw_line (window, gc1,
1827                          x + 1, y + half_height,
1828                          x + width - 1, y + height - 1);
1829           gdk_draw_line (window, gc3,
1830                          x, y + half_height,
1831                          x + width - 1, y + height - 1);
1832           
1833           gdk_draw_line (window, gc1,
1834                          x + width - 2, y + height - 1,
1835                          x + width - 2, y + 1);
1836           gdk_draw_line (window, gc3,
1837                          x + width - 1, y + height - 1,
1838                          x + width - 1, y);
1839           
1840           gdk_draw_line (window, gc4,
1841                          x + width - 1, y + 1,
1842                          x + 1, y + half_height);
1843           gdk_draw_line (window, gc2,
1844                          x + width - 1, y,
1845                          x, y + half_height);
1846           break;
1847           
1848         case GTK_SHADOW_ETCHED_IN:
1849         case GTK_SHADOW_ETCHED_OUT:
1850           gdk_draw_line (window, gc1,
1851                          x + width - 1, y + 1,
1852                          x + 1, y + half_height);
1853           gdk_draw_line (window, gc1,
1854                          x + 1, y + half_height + 1,
1855                          x + width - 1, y + height - 1);
1856           gdk_draw_line (window, gc1,
1857                          x + width - 1, y + height - 1,
1858                          x + width - 1, y + 1);
1859           
1860           points[0].x = x + width - 2;
1861           points[0].y = y;
1862           points[1].x = x;
1863           points[1].y = y + half_height;
1864           points[2].x = x + width - 2;
1865           points[2].y = y + height - 2;
1866           
1867           gdk_draw_polygon (window, gc2, FALSE, points, 3);
1868           break;
1869           
1870         default:
1871           break;
1872         }
1873       break;
1874     case GTK_ARROW_RIGHT:
1875       if (fill)
1876         {
1877           points[0].x = x + width - 1;
1878           points[0].y = y + half_height;
1879           points[1].x = x;
1880           points[1].y = y;
1881           points[2].x = x;
1882           points[2].y = y + height - 1;
1883           
1884           gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1885         }
1886       
1887       switch (shadow_type)
1888         {
1889         case GTK_SHADOW_IN:
1890         case GTK_SHADOW_OUT:
1891           gdk_draw_line (window, gc4,
1892                          x + width - 1, y + half_height,
1893                          x + 1, y + 1);
1894           gdk_draw_line (window, gc2,
1895                          x + width - 1, y + half_height,
1896                          x, y);
1897           gdk_draw_line (window, gc4,
1898                          x + 1, y + 1,
1899                          x + 1, y + height - 2);
1900           gdk_draw_line (window, gc2,
1901                          x, y,
1902                          x, y + height - 1);
1903           
1904           gdk_draw_line (window, gc1,
1905                          x + 1, y + height - 2,
1906                          x + width - 1, y + half_height);
1907           gdk_draw_line (window, gc3,
1908                          x, y + height - 1,
1909                          x + width - 1, y + half_height);
1910           break;
1911           
1912         case GTK_SHADOW_ETCHED_IN:
1913         case GTK_SHADOW_ETCHED_OUT:
1914           gdk_draw_line (window, gc1,
1915                          x + width - 1, y + half_height + 1,
1916                          x + 1, y + 1);
1917           gdk_draw_line (window, gc1,
1918                          x + 1, y + 1,
1919                          x + 1, y + height - 1);
1920           gdk_draw_line (window, gc1,
1921                          x + 1, y + height - 1,
1922                          x + width - 1, y + half_height + 1);
1923           
1924           points[0].x = x + width - 2;
1925           points[0].y = y + half_height;
1926           points[1].x = x;
1927           points[1].y = y;
1928           points[2].x = x;
1929           points[2].y = y + height - 1;
1930           
1931           gdk_draw_polygon (window, gc2, FALSE, points, 3);
1932           break;
1933           
1934         default:
1935           break;
1936         }
1937       break;
1938     }
1939   if (area)
1940     {
1941       gdk_gc_set_clip_rectangle (gc1, NULL);
1942       gdk_gc_set_clip_rectangle (gc2, NULL);
1943       if (gc3)
1944         {
1945           gdk_gc_set_clip_rectangle (gc3, NULL);
1946           gdk_gc_set_clip_rectangle (gc4, NULL);
1947         }
1948     }
1949 }
1950
1951 static void
1952 gtk_default_draw_diamond (GtkStyle      *style,
1953                           GdkWindow     *window,
1954                           GtkStateType   state_type,
1955                           GtkShadowType  shadow_type,
1956                           GdkRectangle  *area,
1957                           GtkWidget     *widget,
1958                           gchar         *detail,
1959                           gint           x,
1960                           gint           y,
1961                           gint           width,
1962                           gint           height)
1963 {
1964   gint half_width;
1965   gint half_height;
1966   
1967   g_return_if_fail (style != NULL);
1968   g_return_if_fail (window != NULL);
1969   
1970   if ((width == -1) && (height == -1))
1971     gdk_window_get_size (window, &width, &height);
1972   else if (width == -1)
1973     gdk_window_get_size (window, &width, NULL);
1974   else if (height == -1)
1975     gdk_window_get_size (window, NULL, &height);
1976   
1977   half_width = width / 2;
1978   half_height = height / 2;
1979   
1980   if (area)
1981     {
1982       gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1983       gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1984       gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1985       gdk_gc_set_clip_rectangle (style->black_gc, area);
1986     }
1987   switch (shadow_type)
1988     {
1989     case GTK_SHADOW_IN:
1990       gdk_draw_line (window, style->bg_gc[state_type],
1991                      x + 2, y + half_height,
1992                      x + half_width, y + height - 2);
1993       gdk_draw_line (window, style->bg_gc[state_type],
1994                      x + half_width, y + height - 2,
1995                      x + width - 2, y + half_height);
1996       gdk_draw_line (window, style->light_gc[state_type],
1997                      x + 1, y + half_height,
1998                      x + half_width, y + height - 1);
1999       gdk_draw_line (window, style->light_gc[state_type],
2000                      x + half_width, y + height - 1,
2001                      x + width - 1, y + half_height);
2002       gdk_draw_line (window, style->light_gc[state_type],
2003                      x, y + half_height,
2004                      x + half_width, y + height);
2005       gdk_draw_line (window, style->light_gc[state_type],
2006                      x + half_width, y + height,
2007                      x + width, y + half_height);
2008       
2009       gdk_draw_line (window, style->black_gc,
2010                      x + 2, y + half_height,
2011                      x + half_width, y + 2);
2012       gdk_draw_line (window, style->black_gc,
2013                      x + half_width, y + 2,
2014                      x + width - 2, y + half_height);
2015       gdk_draw_line (window, style->dark_gc[state_type],
2016                      x + 1, y + half_height,
2017                      x + half_width, y + 1);
2018       gdk_draw_line (window, style->dark_gc[state_type],
2019                      x + half_width, y + 1,
2020                      x + width - 1, y + half_height);
2021       gdk_draw_line (window, style->dark_gc[state_type],
2022                      x, y + half_height,
2023                      x + half_width, y);
2024       gdk_draw_line (window, style->dark_gc[state_type],
2025                      x + half_width, y,
2026                      x + width, y + half_height);
2027       break;
2028     case GTK_SHADOW_OUT:
2029       gdk_draw_line (window, style->dark_gc[state_type],
2030                      x + 2, y + half_height,
2031                      x + half_width, y + height - 2);
2032       gdk_draw_line (window, style->dark_gc[state_type],
2033                      x + half_width, y + height - 2,
2034                      x + width - 2, y + half_height);
2035       gdk_draw_line (window, style->dark_gc[state_type],
2036                      x + 1, y + half_height,
2037                      x + half_width, y + height - 1);
2038       gdk_draw_line (window, style->dark_gc[state_type],
2039                      x + half_width, y + height - 1,
2040                      x + width - 1, y + half_height);
2041       gdk_draw_line (window, style->black_gc,
2042                      x, y + half_height,
2043                      x + half_width, y + height);
2044       gdk_draw_line (window, style->black_gc,
2045                      x + half_width, y + height,
2046                      x + width, y + half_height);
2047       
2048       gdk_draw_line (window, style->bg_gc[state_type],
2049                      x + 2, y + half_height,
2050                      x + half_width, y + 2);
2051       gdk_draw_line (window, style->bg_gc[state_type],
2052                      x + half_width, y + 2,
2053                      x + width - 2, y + half_height);
2054       gdk_draw_line (window, style->light_gc[state_type],
2055                      x + 1, y + half_height,
2056                      x + half_width, y + 1);
2057       gdk_draw_line (window, style->light_gc[state_type],
2058                      x + half_width, y + 1,
2059                      x + width - 1, y + half_height);
2060       gdk_draw_line (window, style->light_gc[state_type],
2061                      x, y + half_height,
2062                      x + half_width, y);
2063       gdk_draw_line (window, style->light_gc[state_type],
2064                      x + half_width, y,
2065                      x + width, y + half_height);
2066       break;
2067     default:
2068       break;
2069     }
2070   if (area)
2071     {
2072       gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2073       gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2074       gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2075       gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2076     }
2077 }
2078
2079
2080 static void
2081 gtk_default_draw_oval (GtkStyle      *style,
2082                        GdkWindow     *window,
2083                        GtkStateType   state_type,
2084                        GtkShadowType  shadow_type,
2085                        GdkRectangle  *area,
2086                        GtkWidget     *widget,
2087                        gchar         *detail,
2088                        gint           x,
2089                        gint           y,
2090                        gint           width,
2091                        gint           height)
2092 {
2093   g_return_if_fail (style != NULL);
2094   g_return_if_fail (window != NULL);
2095 }
2096
2097 static void
2098 gtk_default_draw_string (GtkStyle      *style,
2099                          GdkWindow     *window,
2100                          GtkStateType   state_type,
2101                          GdkRectangle  *area,
2102                          GtkWidget     *widget,
2103                          gchar         *detail,
2104                          gint           x,
2105                          gint           y,
2106                          const gchar   *string)
2107 {
2108   g_return_if_fail (style != NULL);
2109   g_return_if_fail (window != NULL);
2110   
2111   if (area)
2112     {
2113       gdk_gc_set_clip_rectangle (style->white_gc, area);
2114       gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2115     }
2116   if (state_type == GTK_STATE_INSENSITIVE)
2117     gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2118   gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2119   if (area)
2120     {
2121       gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2122       gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2123     }
2124 }
2125
2126 static void 
2127 gtk_default_draw_box     (GtkStyle      *style,
2128                           GdkWindow     *window,
2129                           GtkStateType   state_type,
2130                           GtkShadowType  shadow_type,
2131                           GdkRectangle  *area,
2132                           GtkWidget     *widget,
2133                           gchar         *detail,
2134                           gint           x,
2135                           gint           y,
2136                           gint           width,
2137                           gint           height)
2138 {
2139   g_return_if_fail (style != NULL);
2140   g_return_if_fail (window != NULL);
2141   
2142   if ((width == -1) && (height == -1))
2143     gdk_window_get_size (window, &width, &height);
2144   else if (width == -1)
2145     gdk_window_get_size (window, &width, NULL);
2146   else if (height == -1)
2147     gdk_window_get_size (window, NULL, &height);
2148   
2149   if (!style->bg_pixmap[state_type] || 
2150       gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2151     {
2152       if (area)
2153         {
2154           gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2155         }
2156       gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2157                           x, y, width, height);
2158       if (area)
2159         {
2160           gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2161         }
2162     }
2163   else
2164     gtk_style_apply_default_background (style, window,
2165                                         widget && GTK_WIDGET_NO_WINDOW (widget),
2166                                         state_type, area, x, y, width, height);
2167   
2168   gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2169                     x, y, width, height);
2170 }
2171
2172 static void 
2173 gtk_default_draw_flat_box (GtkStyle      *style,
2174                            GdkWindow     *window,
2175                            GtkStateType   state_type,
2176                            GtkShadowType  shadow_type,
2177                            GdkRectangle  *area,
2178                            GtkWidget     *widget,
2179                            gchar         *detail,
2180                            gint           x,
2181                            gint           y,
2182                            gint           width,
2183                            gint           height)
2184 {
2185   GdkGC *gc1;
2186   
2187   g_return_if_fail (style != NULL);
2188   g_return_if_fail (window != NULL);
2189   
2190   if ((width == -1) && (height == -1))
2191     gdk_window_get_size (window, &width, &height);
2192   else if (width == -1)
2193     gdk_window_get_size (window, &width, NULL);
2194   else if (height == -1)
2195     gdk_window_get_size (window, NULL, &height);
2196   
2197   if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED))
2198     gc1 = style->bg_gc[GTK_STATE_SELECTED];
2199   else if ((detail) && (!strcmp("viewportbin",detail)))
2200     gc1 = style->bg_gc[GTK_STATE_NORMAL];
2201   else if ((detail) && (!strcmp("entry_bg",detail)))
2202     gc1 = style->base_gc[state_type];
2203   else
2204     gc1 = style->bg_gc[state_type];
2205   
2206   if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2207       gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2208     {
2209       if (area)
2210         {
2211           gdk_gc_set_clip_rectangle (gc1, area);
2212         }
2213       gdk_draw_rectangle (window, gc1, TRUE,
2214                           x, y, width, height);
2215       if ((detail) && (!strcmp("tooltip",detail)))
2216         gdk_draw_rectangle (window, style->black_gc, FALSE,
2217                             x, y, width - 1, height - 1);
2218       if (area)
2219         {
2220           gdk_gc_set_clip_rectangle (gc1, NULL);
2221         }
2222     }
2223   else
2224     gtk_style_apply_default_background (style, window,
2225                                         widget && GTK_WIDGET_NO_WINDOW (widget),
2226                                         state_type, area, x, y, width, height);
2227 }
2228
2229 static void 
2230 gtk_default_draw_check   (GtkStyle      *style,
2231                           GdkWindow     *window,
2232                           GtkStateType   state_type,
2233                           GtkShadowType  shadow_type,
2234                           GdkRectangle  *area,
2235                           GtkWidget     *widget,
2236                           gchar         *detail,
2237                           gint           x,
2238                           gint           y,
2239                           gint           width,
2240                           gint           height)
2241 {
2242   gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2243                  x, y, width, height);
2244 }
2245
2246 static void 
2247 gtk_default_draw_option  (GtkStyle      *style,
2248                           GdkWindow     *window,
2249                           GtkStateType   state_type,
2250                           GtkShadowType  shadow_type,
2251                           GdkRectangle  *area,
2252                           GtkWidget     *widget,
2253                           gchar         *detail,
2254                           gint           x,
2255                           gint           y,
2256                           gint           width,
2257                           gint           height)
2258 {
2259   gtk_paint_diamond (style, window, state_type, shadow_type, area, widget, 
2260                      detail, x, y, width, height);
2261 }
2262
2263 static void 
2264 gtk_default_draw_cross   (GtkStyle      *style,
2265                           GdkWindow     *window,
2266                           GtkStateType   state_type,
2267                           GtkShadowType  shadow_type,
2268                           GdkRectangle  *area,
2269                           GtkWidget     *widget,
2270                           gchar         *detail,
2271                           gint           x,
2272                           gint           y,
2273                           gint           width,
2274                           gint           height)
2275 {
2276   g_return_if_fail (style != NULL);
2277   g_return_if_fail (window != NULL);
2278 }
2279
2280 static void 
2281 gtk_default_draw_ramp    (GtkStyle      *style,
2282                           GdkWindow     *window,
2283                           GtkStateType   state_type,
2284                           GtkShadowType  shadow_type,
2285                           GdkRectangle  *area,
2286                           GtkWidget     *widget,
2287                           gchar         *detail,
2288                           GtkArrowType   arrow_type,
2289                           gint           x,
2290                           gint           y,
2291                           gint           width,
2292                           gint           height)
2293 {
2294   g_return_if_fail (style != NULL);
2295   g_return_if_fail (window != NULL);
2296 }
2297
2298 static void gtk_default_draw_tab     (GtkStyle      *style,
2299                                       GdkWindow     *window,
2300                                       GtkStateType   state_type,
2301                                       GtkShadowType  shadow_type,
2302                                       GdkRectangle  *area,
2303                                       GtkWidget     *widget,
2304                                       gchar         *detail,
2305                                       gint           x,
2306                                       gint           y,
2307                                       gint           width,
2308                                       gint           height)
2309 {
2310   g_return_if_fail (style != NULL);
2311   g_return_if_fail (window != NULL);
2312   
2313   gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2314                  x, y, width, height);
2315 }
2316
2317 static void 
2318 gtk_default_draw_shadow_gap (GtkStyle       *style,
2319                              GdkWindow      *window,
2320                              GtkStateType    state_type,
2321                              GtkShadowType   shadow_type,
2322                              GdkRectangle   *area,
2323                              GtkWidget      *widget,
2324                              gchar          *detail,
2325                              gint            x,
2326                              gint            y,
2327                              gint            width,
2328                              gint            height,
2329                              GtkPositionType gap_side,
2330                              gint            gap_x,
2331                              gint            gap_width)
2332 {
2333   GdkGC *gc1 = NULL;
2334   GdkGC *gc2 = NULL;
2335   GdkGC *gc3 = NULL;
2336   GdkGC *gc4 = NULL;
2337   
2338   g_return_if_fail (style != NULL);
2339   g_return_if_fail (window != NULL);
2340   
2341   if ((width == -1) && (height == -1))
2342     gdk_window_get_size (window, &width, &height);
2343   else if (width == -1)
2344     gdk_window_get_size (window, &width, NULL);
2345   else if (height == -1)
2346     gdk_window_get_size (window, NULL, &height);
2347   
2348   switch (shadow_type)
2349     {
2350     case GTK_SHADOW_NONE:
2351       return;
2352     case GTK_SHADOW_IN:
2353       gc1 = style->dark_gc[state_type];
2354       gc2 = style->black_gc;
2355       gc3 = style->bg_gc[state_type];
2356       gc4 = style->light_gc[state_type];
2357       break;
2358     case GTK_SHADOW_ETCHED_IN:
2359       gc1 = style->dark_gc[state_type];
2360       gc2 = style->light_gc[state_type];
2361       gc3 = style->dark_gc[state_type];
2362       gc4 = style->light_gc[state_type];
2363       break;
2364     case GTK_SHADOW_OUT:
2365       gc1 = style->light_gc[state_type];
2366       gc2 = style->bg_gc[state_type];
2367       gc3 = style->dark_gc[state_type];
2368       gc4 = style->black_gc;
2369       break;
2370     case GTK_SHADOW_ETCHED_OUT:
2371       gc1 = style->light_gc[state_type];
2372       gc2 = style->dark_gc[state_type];
2373       gc3 = style->light_gc[state_type];
2374       gc4 = style->dark_gc[state_type];
2375       break;
2376     }
2377   if (area)
2378     {
2379       gdk_gc_set_clip_rectangle (gc1, area);
2380       gdk_gc_set_clip_rectangle (gc2, area);
2381       gdk_gc_set_clip_rectangle (gc3, area);
2382       gdk_gc_set_clip_rectangle (gc4, area);
2383     }
2384   
2385   switch (shadow_type)
2386     {
2387     case GTK_SHADOW_NONE:
2388     case GTK_SHADOW_IN:
2389     case GTK_SHADOW_OUT:
2390     case GTK_SHADOW_ETCHED_IN:
2391     case GTK_SHADOW_ETCHED_OUT:
2392       switch (gap_side)
2393         {
2394         case GTK_POS_TOP:
2395           gdk_draw_line (window, gc1,
2396                          x, y, x, y + height - 1);
2397           gdk_draw_line (window, gc2,
2398                          x + 1, y, x + 1, y + height - 2);
2399           
2400           gdk_draw_line (window, gc3,
2401                          x + 1, y + height - 2, x + width - 2, y + height - 2);
2402           gdk_draw_line (window, gc3,
2403                          x + width - 2, y, x + width - 2, y + height - 2);
2404           gdk_draw_line (window, gc4,
2405                          x, y + height - 1, x + width - 1, y + height - 1);
2406           gdk_draw_line (window, gc4,
2407                          x + width - 1, y, x + width - 1, y + height - 1);
2408           if (gap_x > 0)
2409             {
2410               gdk_draw_line (window, gc1,
2411                              x, y, x + gap_x - 1, y);
2412               gdk_draw_line (window, gc2,
2413                              x + 1, y + 1, x + gap_x - 1, y + 1);
2414               gdk_draw_line (window, gc2,
2415                              x + gap_x, y, x + gap_x, y);
2416             }
2417           if ((width - (gap_x + gap_width)) > 0)
2418             {
2419               gdk_draw_line (window, gc1,
2420                              x + gap_x + gap_width, y, x + width - 2, y);
2421               gdk_draw_line (window, gc2,
2422                              x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2423               gdk_draw_line (window, gc2,
2424                              x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2425             }
2426           break;
2427         case GTK_POS_BOTTOM:
2428           gdk_draw_line (window, gc1,
2429                          x, y, x + width - 1, y);
2430           gdk_draw_line (window, gc1,
2431                          x, y, x, y + height - 1);
2432           gdk_draw_line (window, gc2,
2433                          x + 1, y + 1, x + width - 2, y + 1);
2434           gdk_draw_line (window, gc2,
2435                          x + 1, y + 1, x + 1, y + height - 1);
2436           
2437           gdk_draw_line (window, gc3,
2438                          x + width - 2, y + 1, x + width - 2, y + height - 1);
2439           gdk_draw_line (window, gc4,
2440                          x + width - 1, y, x + width - 1, y + height - 1);
2441           if (gap_x > 0)
2442             {
2443               gdk_draw_line (window, gc4,
2444                              x, y + height - 1, x + gap_x - 1, y + height - 1);
2445               gdk_draw_line (window, gc3,
2446                              x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2447               gdk_draw_line (window, gc3,
2448                              x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2449             }
2450           if ((width - (gap_x + gap_width)) > 0)
2451             {
2452               gdk_draw_line (window, gc4,
2453                              x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2454               gdk_draw_line (window, gc3,
2455                              x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2456               gdk_draw_line (window, gc3,
2457                              x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2458             }
2459           break;
2460         case GTK_POS_LEFT:
2461           gdk_draw_line (window, gc1,
2462                          x, y, x + width - 1, y);
2463           gdk_draw_line (window, gc2,
2464                          x, y + 1, x + width - 2, y + 1);
2465           
2466           gdk_draw_line (window, gc3,
2467                          x, y + height - 2, x + width - 2, y + height - 2);
2468           gdk_draw_line (window, gc3,
2469                          x + width - 2, y + 1, x + width - 2, y + height - 2);
2470           gdk_draw_line (window, gc4,
2471                          x, y + height - 1, x + width - 1, y + height - 1);
2472           gdk_draw_line (window, gc4,
2473                          x + width - 1, y, x + width - 1, y + height - 1);
2474           if (gap_x > 0)
2475             {
2476               gdk_draw_line (window, gc1,
2477                              x, y, x, y + gap_x - 1);
2478               gdk_draw_line (window, gc2,
2479                              x + 1, y + 1, x + 1, y + gap_x - 1);
2480               gdk_draw_line (window, gc2,
2481                              x, y + gap_x, x, y + gap_x);
2482             }
2483           if ((width - (gap_x + gap_width)) > 0)
2484             {
2485               gdk_draw_line (window, gc1,
2486                              x, y + gap_x + gap_width, x, y + height - 2);
2487               gdk_draw_line (window, gc2,
2488                              x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2489               gdk_draw_line (window, gc2,
2490                              x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2491             }
2492           break;
2493         case GTK_POS_RIGHT:
2494           gdk_draw_line (window, gc1,
2495                          x, y, x + width - 1, y);
2496           gdk_draw_line (window, gc1,
2497                          x, y, x, y + height - 1);
2498           gdk_draw_line (window, gc2,
2499                          x + 1, y + 1, x + width - 1, y + 1);
2500           gdk_draw_line (window, gc2,
2501                          x + 1, y + 1, x + 1, y + height - 2);
2502           
2503           gdk_draw_line (window, gc3,
2504                          x + 1, y + height - 2, x + width - 1, y + height - 2);
2505           gdk_draw_line (window, gc4,
2506                          x, y + height - 1, x + width - 1, y + height - 1);
2507           if (gap_x > 0)
2508             {
2509               gdk_draw_line (window, gc4,
2510                              x + width - 1, y, x + width - 1, y + gap_x - 1);
2511               gdk_draw_line (window, gc3,
2512                              x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2513               gdk_draw_line (window, gc3,
2514                              x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2515             }
2516           if ((width - (gap_x + gap_width)) > 0)
2517             {
2518               gdk_draw_line (window, gc4,
2519                              x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2520               gdk_draw_line (window, gc3,
2521                              x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2522               gdk_draw_line (window, gc3,
2523                              x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2524             }
2525           break;
2526         }
2527     }
2528   if (area)
2529     {
2530       gdk_gc_set_clip_rectangle (gc1, NULL);
2531       gdk_gc_set_clip_rectangle (gc2, NULL);
2532       gdk_gc_set_clip_rectangle (gc3, NULL);
2533       gdk_gc_set_clip_rectangle (gc4, NULL);
2534     }
2535 }
2536
2537 static void 
2538 gtk_default_draw_box_gap (GtkStyle       *style,
2539                           GdkWindow      *window,
2540                           GtkStateType    state_type,
2541                           GtkShadowType   shadow_type,
2542                           GdkRectangle   *area,
2543                           GtkWidget      *widget,
2544                           gchar          *detail,
2545                           gint            x,
2546                           gint            y,
2547                           gint            width,
2548                           gint            height,
2549                           GtkPositionType gap_side,
2550                           gint            gap_x,
2551                           gint            gap_width)
2552 {
2553   GdkGC *gc1 = NULL;
2554   GdkGC *gc2 = NULL;
2555   GdkGC *gc3 = NULL;
2556   GdkGC *gc4 = NULL;
2557   
2558   g_return_if_fail (style != NULL);
2559   g_return_if_fail (window != NULL);
2560   
2561   gtk_style_apply_default_background (style, window,
2562                                       widget && GTK_WIDGET_NO_WINDOW (widget),
2563                                       state_type, area, x, y, width, height);
2564   
2565   if ((width == -1) && (height == -1))
2566     gdk_window_get_size (window, &width, &height);
2567   else if (width == -1)
2568     gdk_window_get_size (window, &width, NULL);
2569   else if (height == -1)
2570     gdk_window_get_size (window, NULL, &height);
2571   
2572   switch (shadow_type)
2573     {
2574     case GTK_SHADOW_NONE:
2575       return;
2576     case GTK_SHADOW_IN:
2577       gc1 = style->dark_gc[state_type];
2578       gc2 = style->black_gc;
2579       gc3 = style->bg_gc[state_type];
2580       gc4 = style->light_gc[state_type];
2581       break;
2582     case GTK_SHADOW_ETCHED_IN:
2583       gc1 = style->dark_gc[state_type];
2584       gc2 = style->light_gc[state_type];
2585       gc3 = style->dark_gc[state_type];
2586       gc4 = style->light_gc[state_type];
2587       break;
2588     case GTK_SHADOW_OUT:
2589       gc1 = style->light_gc[state_type];
2590       gc2 = style->bg_gc[state_type];
2591       gc3 = style->dark_gc[state_type];
2592       gc4 = style->black_gc;
2593       break;
2594     case GTK_SHADOW_ETCHED_OUT:
2595       gc1 = style->light_gc[state_type];
2596       gc2 = style->dark_gc[state_type];
2597       gc3 = style->light_gc[state_type];
2598       gc4 = style->dark_gc[state_type];
2599       break;
2600     }
2601   if (area)
2602     {
2603       gdk_gc_set_clip_rectangle (gc1, area);
2604       gdk_gc_set_clip_rectangle (gc2, area);
2605       gdk_gc_set_clip_rectangle (gc3, area);
2606       gdk_gc_set_clip_rectangle (gc4, area);
2607     }
2608   
2609   switch (shadow_type)
2610     {
2611     case GTK_SHADOW_NONE:
2612     case GTK_SHADOW_IN:
2613     case GTK_SHADOW_OUT:
2614     case GTK_SHADOW_ETCHED_IN:
2615     case GTK_SHADOW_ETCHED_OUT:
2616       switch (gap_side)
2617         {
2618         case GTK_POS_TOP:
2619           gdk_draw_line (window, gc1,
2620                          x, y, x, y + height - 1);
2621           gdk_draw_line (window, gc2,
2622                          x + 1, y, x + 1, y + height - 2);
2623           
2624           gdk_draw_line (window, gc3,
2625                          x + 1, y + height - 2, x + width - 2, y + height - 2);
2626           gdk_draw_line (window, gc3,
2627                          x + width - 2, y, x + width - 2, y + height - 2);
2628           gdk_draw_line (window, gc4,
2629                          x, y + height - 1, x + width - 1, y + height - 1);
2630           gdk_draw_line (window, gc4,
2631                          x + width - 1, y, x + width - 1, y + height - 1);
2632           if (gap_x > 0)
2633             {
2634               gdk_draw_line (window, gc1,
2635                              x, y, x + gap_x - 1, y);
2636               gdk_draw_line (window, gc2,
2637                              x + 1, y + 1, x + gap_x - 1, y + 1);
2638               gdk_draw_line (window, gc2,
2639                              x + gap_x, y, x + gap_x, y);
2640             }
2641           if ((width - (gap_x + gap_width)) > 0)
2642             {
2643               gdk_draw_line (window, gc1,
2644                              x + gap_x + gap_width, y, x + width - 2, y);
2645               gdk_draw_line (window, gc2,
2646                              x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2647               gdk_draw_line (window, gc2,
2648                              x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2649             }
2650           break;
2651         case  GTK_POS_BOTTOM:
2652           gdk_draw_line (window, gc1,
2653                          x, y, x + width - 1, y);
2654           gdk_draw_line (window, gc1,
2655                          x, y, x, y + height - 1);
2656           gdk_draw_line (window, gc2,
2657                          x + 1, y + 1, x + width - 2, y + 1);
2658           gdk_draw_line (window, gc2,
2659                          x + 1, y + 1, x + 1, y + height - 1);
2660           
2661           gdk_draw_line (window, gc3,
2662                          x + width - 2, y + 1, x + width - 2, y + height - 1);
2663           gdk_draw_line (window, gc4,
2664                          x + width - 1, y, x + width - 1, y + height - 1);
2665           if (gap_x > 0)
2666             {
2667               gdk_draw_line (window, gc4,
2668                              x, y + height - 1, x + gap_x - 1, y + height - 1);
2669               gdk_draw_line (window, gc3,
2670                              x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2671               gdk_draw_line (window, gc3,
2672                              x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2673             }
2674           if ((width - (gap_x + gap_width)) > 0)
2675             {
2676               gdk_draw_line (window, gc4,
2677                              x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2678               gdk_draw_line (window, gc3,
2679                              x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2680               gdk_draw_line (window, gc3,
2681                              x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2682             }
2683           break;
2684         case GTK_POS_LEFT:
2685           gdk_draw_line (window, gc1,
2686                          x, y, x + width - 1, y);
2687           gdk_draw_line (window, gc2,
2688                          x, y + 1, x + width - 2, y + 1);
2689           
2690           gdk_draw_line (window, gc3,
2691                          x, y + height - 2, x + width - 2, y + height - 2);
2692           gdk_draw_line (window, gc3,
2693                          x + width - 2, y + 1, x + width - 2, y + height - 2);
2694           gdk_draw_line (window, gc4,
2695                          x, y + height - 1, x + width - 1, y + height - 1);
2696           gdk_draw_line (window, gc4,
2697                          x + width - 1, y, x + width - 1, y + height - 1);
2698           if (gap_x > 0)
2699             {
2700               gdk_draw_line (window, gc1,
2701                              x, y, x, y + gap_x - 1);
2702               gdk_draw_line (window, gc2,
2703                              x + 1, y + 1, x + 1, y + gap_x - 1);
2704               gdk_draw_line (window, gc2,
2705                              x, y + gap_x, x, y + gap_x);
2706             }
2707           if ((width - (gap_x + gap_width)) > 0)
2708             {
2709               gdk_draw_line (window, gc1,
2710                              x, y + gap_x + gap_width, x, y + height - 2);
2711               gdk_draw_line (window, gc2,
2712                              x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2713               gdk_draw_line (window, gc2,
2714                              x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2715             }
2716           break;
2717         case GTK_POS_RIGHT:
2718           gdk_draw_line (window, gc1,
2719                          x, y, x + width - 1, y);
2720           gdk_draw_line (window, gc1,
2721                          x, y, x, y + height - 1);
2722           gdk_draw_line (window, gc2,
2723                          x + 1, y + 1, x + width - 1, y + 1);
2724           gdk_draw_line (window, gc2,
2725                          x + 1, y + 1, x + 1, y + height - 2);
2726           
2727           gdk_draw_line (window, gc3,
2728                          x + 1, y + height - 2, x + width - 1, y + height - 2);
2729           gdk_draw_line (window, gc4,
2730                          x, y + height - 1, x + width - 1, y + height - 1);
2731           if (gap_x > 0)
2732             {
2733               gdk_draw_line (window, gc4,
2734                              x + width - 1, y, x + width - 1, y + gap_x - 1);
2735               gdk_draw_line (window, gc3,
2736                              x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2737               gdk_draw_line (window, gc3,
2738                              x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2739             }
2740           if ((width - (gap_x + gap_width)) > 0)
2741             {
2742               gdk_draw_line (window, gc4,
2743                              x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2744               gdk_draw_line (window, gc3,
2745                              x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2746               gdk_draw_line (window, gc3,
2747                              x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2748             }
2749           break;
2750         }
2751     }
2752   if (area)
2753     {
2754       gdk_gc_set_clip_rectangle (gc1, NULL);
2755       gdk_gc_set_clip_rectangle (gc2, NULL);
2756       gdk_gc_set_clip_rectangle (gc3, NULL);
2757       gdk_gc_set_clip_rectangle (gc4, NULL);
2758     }
2759 }
2760
2761 static void 
2762 gtk_default_draw_extension (GtkStyle       *style,
2763                             GdkWindow      *window,
2764                             GtkStateType    state_type,
2765                             GtkShadowType   shadow_type,
2766                             GdkRectangle   *area,
2767                             GtkWidget      *widget,
2768                             gchar          *detail,
2769                             gint            x,
2770                             gint            y,
2771                             gint            width,
2772                             gint            height,
2773                             GtkPositionType gap_side)
2774 {
2775   GdkGC *gc1 = NULL;
2776   GdkGC *gc2 = NULL;
2777   GdkGC *gc3 = NULL;
2778   GdkGC *gc4 = NULL;
2779   
2780   g_return_if_fail (style != NULL);
2781   g_return_if_fail (window != NULL);
2782   
2783   gtk_style_apply_default_background (style, window,
2784                                       widget && GTK_WIDGET_NO_WINDOW (widget),
2785                                       GTK_STATE_NORMAL, area, x, y, width, height);
2786   
2787   if ((width == -1) && (height == -1))
2788     gdk_window_get_size (window, &width, &height);
2789   else if (width == -1)
2790     gdk_window_get_size (window, &width, NULL);
2791   else if (height == -1)
2792     gdk_window_get_size (window, NULL, &height);
2793   
2794   switch (shadow_type)
2795     {
2796     case GTK_SHADOW_NONE:
2797       return;
2798     case GTK_SHADOW_IN:
2799       gc1 = style->dark_gc[state_type];
2800       gc2 = style->black_gc;
2801       gc3 = style->bg_gc[state_type];
2802       gc4 = style->light_gc[state_type];
2803       break;
2804     case GTK_SHADOW_ETCHED_IN:
2805       gc1 = style->dark_gc[state_type];
2806       gc2 = style->light_gc[state_type];
2807       gc3 = style->dark_gc[state_type];
2808       gc4 = style->light_gc[state_type];
2809       break;
2810     case GTK_SHADOW_OUT:
2811       gc1 = style->light_gc[state_type];
2812       gc2 = style->bg_gc[state_type];
2813       gc3 = style->dark_gc[state_type];
2814       gc4 = style->black_gc;
2815       break;
2816     case GTK_SHADOW_ETCHED_OUT:
2817       gc1 = style->light_gc[state_type];
2818       gc2 = style->dark_gc[state_type];
2819       gc3 = style->light_gc[state_type];
2820       gc4 = style->dark_gc[state_type];
2821       break;
2822     }
2823   if (area)
2824     {
2825       gdk_gc_set_clip_rectangle (gc1, area);
2826       gdk_gc_set_clip_rectangle (gc2, area);
2827       gdk_gc_set_clip_rectangle (gc3, area);
2828       gdk_gc_set_clip_rectangle (gc4, area);
2829     }
2830   switch (shadow_type)
2831     {
2832     case GTK_SHADOW_NONE:
2833     case GTK_SHADOW_IN:
2834     case GTK_SHADOW_OUT:
2835     case GTK_SHADOW_ETCHED_IN:
2836     case GTK_SHADOW_ETCHED_OUT:
2837       switch (gap_side)
2838         {
2839         case GTK_POS_TOP:
2840           gtk_style_apply_default_background (style, window,
2841                                               widget && GTK_WIDGET_NO_WINDOW (widget),
2842                                               state_type, area,
2843                                               x + style->klass->xthickness, 
2844                                               y, 
2845                                               width - (2 * style->klass->xthickness), 
2846                                               height - (style->klass->ythickness));
2847           gdk_draw_line (window, gc1,
2848                          x, y, x, y + height - 2);
2849           gdk_draw_line (window, gc2,
2850                          x + 1, y, x + 1, y + height - 2);
2851           
2852           gdk_draw_line (window, gc3,
2853                          x + 2, y + height - 2, x + width - 2, y + height - 2);
2854           gdk_draw_line (window, gc3,
2855                          x + width - 2, y, x + width - 2, y + height - 2);
2856           gdk_draw_line (window, gc4,
2857                          x + 1, y + height - 1, x + width - 2, y + height - 1);
2858           gdk_draw_line (window, gc4,
2859                          x + width - 1, y, x + width - 1, y + height - 2);
2860           break;
2861         case GTK_POS_BOTTOM:
2862           gtk_style_apply_default_background (style, window,
2863                                               widget && GTK_WIDGET_NO_WINDOW (widget),
2864                                               state_type, area,
2865                                               x + style->klass->xthickness, 
2866                                               y + style->klass->ythickness, 
2867                                               width - (2 * style->klass->xthickness), 
2868                                               height - (style->klass->ythickness));
2869           gdk_draw_line (window, gc1,
2870                          x + 1, y, x + width - 2, y);
2871           gdk_draw_line (window, gc1,
2872                          x, y + 1, x, y + height - 1);
2873           gdk_draw_line (window, gc2,
2874                          x + 1, y + 1, x + width - 2, y + 1);
2875           gdk_draw_line (window, gc2,
2876                          x + 1, y + 1, x + 1, y + height - 1);
2877           
2878           gdk_draw_line (window, gc3,
2879                          x + width - 2, y + 2, x + width - 2, y + height - 1);
2880           gdk_draw_line (window, gc4,
2881                          x + width - 1, y + 1, x + width - 1, y + height - 1);
2882           break;
2883         case GTK_POS_LEFT:
2884           gtk_style_apply_default_background (style, window,
2885                                               widget && GTK_WIDGET_NO_WINDOW (widget),
2886                                               state_type, area,
2887                                               x, 
2888                                               y + style->klass->ythickness, 
2889                                               width - (style->klass->xthickness), 
2890                                               height - (2 * style->klass->ythickness));
2891           gdk_draw_line (window, gc1,
2892                          x, y, x + width - 2, y);
2893           gdk_draw_line (window, gc2,
2894                          x + 1, y + 1, x + width - 2, y + 1);
2895           
2896           gdk_draw_line (window, gc3,
2897                          x, y + height - 2, x + width - 2, y + height - 2);
2898           gdk_draw_line (window, gc3,
2899                          x + width - 2, y + 2, x + width - 2, y + height - 2);
2900           gdk_draw_line (window, gc4,
2901                          x, y + height - 1, x + width - 2, y + height - 1);
2902           gdk_draw_line (window, gc4,
2903                          x + width - 1, y + 1, x + width - 1, y + height - 2);
2904           break;
2905         case GTK_POS_RIGHT:
2906           gtk_style_apply_default_background (style, window,
2907                                               widget && GTK_WIDGET_NO_WINDOW (widget),
2908                                               state_type, area,
2909                                               x + style->klass->xthickness, 
2910                                               y + style->klass->ythickness, 
2911                                               width - (style->klass->xthickness), 
2912                                               height - (2 * style->klass->ythickness));
2913           gdk_draw_line (window, gc1,
2914                          x + 1, y, x + width - 1, y);
2915           gdk_draw_line (window, gc1,
2916                          x, y + 1, x, y + height - 2);
2917           gdk_draw_line (window, gc2,
2918                          x + 1, y + 1, x + width - 1, y + 1);
2919           gdk_draw_line (window, gc2,
2920                          x + 1, y + 1, x + 1, y + height - 2);
2921           
2922           gdk_draw_line (window, gc3,
2923                          x + 2, y + height - 2, x + width - 1, y + height - 2);
2924           gdk_draw_line (window, gc4,
2925                          x + 1, y + height - 1, x + width - 1, y + height - 1);
2926           break;
2927         }
2928     }
2929   if (area)
2930     {
2931       gdk_gc_set_clip_rectangle (gc1, NULL);
2932       gdk_gc_set_clip_rectangle (gc2, NULL);
2933       gdk_gc_set_clip_rectangle (gc3, NULL);
2934       gdk_gc_set_clip_rectangle (gc4, NULL);
2935     }
2936 }
2937
2938 static void 
2939 gtk_default_draw_focus (GtkStyle      *style,
2940                         GdkWindow     *window,
2941                         GdkRectangle  *area,
2942                         GtkWidget     *widget,
2943                         gchar         *detail,
2944                         gint           x,
2945                         gint           y,
2946                         gint           width,
2947                         gint           height)
2948 {
2949   g_return_if_fail (style != NULL);
2950   g_return_if_fail (window != NULL);
2951   
2952   if ((width == -1) && (height == -1))
2953     {
2954       gdk_window_get_size (window, &width, &height);
2955       width -= 1;
2956       height -= 1;
2957     }
2958   else if (width == -1)
2959     {
2960       gdk_window_get_size (window, &width, NULL);
2961       width -= 1;
2962     }
2963   else if (height == -1)
2964     {
2965       gdk_window_get_size (window, NULL, &height);
2966       height -= 1;
2967     }
2968   if (area)
2969     {
2970       gdk_gc_set_clip_rectangle (style->black_gc, area);
2971     }
2972   if (detail && !strcmp (detail, "add-mode"))
2973     {
2974       gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
2975       gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
2976       
2977       gdk_draw_rectangle (window,
2978                           style->black_gc, FALSE,
2979                           x, y, width, height);
2980       
2981       gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
2982     }
2983   else
2984     {
2985       gdk_draw_rectangle (window,
2986                           style->black_gc, FALSE,
2987                           x, y, width, height);
2988     }
2989   if (area)
2990     {
2991       gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2992     }
2993 }
2994
2995 static void 
2996 gtk_default_draw_slider (GtkStyle      *style,
2997                          GdkWindow     *window,
2998                          GtkStateType   state_type,
2999                          GtkShadowType  shadow_type,
3000                          GdkRectangle  *area,
3001                          GtkWidget     *widget,
3002                          gchar         *detail,
3003                          gint           x,
3004                          gint           y,
3005                          gint           width,
3006                          gint           height,
3007                          GtkOrientation orientation)
3008 {
3009   g_return_if_fail (style != NULL);
3010   g_return_if_fail (window != NULL);
3011   
3012   if ((width == -1) && (height == -1))
3013     gdk_window_get_size (window, &width, &height);
3014   else if (width == -1)
3015     gdk_window_get_size (window, &width, NULL);
3016   else if (height == -1)
3017     gdk_window_get_size (window, NULL, &height);
3018   
3019   gtk_paint_box (style, window, state_type, shadow_type,
3020                  area, widget, detail, x, y, width, height);
3021   if (orientation == GTK_ORIENTATION_HORIZONTAL)
3022     gtk_paint_vline (style, window, state_type, area, widget, detail, 
3023                      style->klass->ythickness, 
3024                      height - style->klass->ythickness - 1, width / 2);
3025   else
3026     gtk_paint_hline (style, window, state_type, area, widget, detail, 
3027                      style->klass->xthickness, 
3028                      width - style->klass->xthickness - 1, height / 2);
3029 }
3030
3031 static void 
3032 gtk_default_draw_handle  (GtkStyle      *style,
3033                           GdkWindow     *window,
3034                           GtkStateType   state_type,
3035                           GtkShadowType  shadow_type,
3036                           GdkRectangle  *area,
3037                           GtkWidget     *widget,
3038                           gchar         *detail,
3039                           gint           x,
3040                           gint           y,
3041                           gint           width,
3042                           gint           height,
3043                           GtkOrientation orientation)
3044 {
3045   gint xx, yy;
3046   gint xthick, ythick;
3047   GdkGC *light_gc, *dark_gc;
3048   GdkRectangle dest;
3049   
3050   g_return_if_fail (style != NULL);
3051   g_return_if_fail (window != NULL);
3052   
3053   if ((width == -1) && (height == -1))
3054     gdk_window_get_size (window, &width, &height);
3055   else if (width == -1)
3056     gdk_window_get_size (window, &width, NULL);
3057   else if (height == -1)
3058     gdk_window_get_size (window, NULL, &height);
3059   
3060   gtk_paint_box (style, window, state_type, shadow_type, area, widget, 
3061                  detail, x, y, width, height);
3062   
3063   light_gc = style->light_gc[state_type];
3064   dark_gc = style->dark_gc[state_type];
3065   
3066   xthick = style->klass->xthickness;
3067   ythick = style->klass->ythickness;
3068   
3069   dest.x = x + xthick;
3070   dest.y = y + ythick;
3071   dest.width = width - (xthick * 2);
3072   dest.height = height - (ythick * 2);
3073   
3074   gdk_gc_set_clip_rectangle (light_gc, &dest);
3075   gdk_gc_set_clip_rectangle (dark_gc, &dest);
3076   
3077   for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3078     for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3079       {
3080         gdk_draw_point (window, light_gc, xx, yy);
3081         gdk_draw_point (window, dark_gc, xx + 1, yy + 1);
3082         
3083         gdk_draw_point (window, light_gc, xx + 3, yy + 1);
3084         gdk_draw_point (window, dark_gc, xx + 4, yy + 2);
3085       }
3086   gdk_gc_set_clip_rectangle (light_gc, NULL);
3087   gdk_gc_set_clip_rectangle (dark_gc, NULL);
3088 }
3089
3090 static void
3091 gtk_style_shade (GdkColor *a,
3092                  GdkColor *b,
3093                  gdouble   k)
3094 {
3095   gdouble red;
3096   gdouble green;
3097   gdouble blue;
3098   
3099   red = (gdouble) a->red / 65535.0;
3100   green = (gdouble) a->green / 65535.0;
3101   blue = (gdouble) a->blue / 65535.0;
3102   
3103   rgb_to_hls (&red, &green, &blue);
3104   
3105   green *= k;
3106   if (green > 1.0)
3107     green = 1.0;
3108   else if (green < 0.0)
3109     green = 0.0;
3110   
3111   blue *= k;
3112   if (blue > 1.0)
3113     blue = 1.0;
3114   else if (blue < 0.0)
3115     blue = 0.0;
3116   
3117   hls_to_rgb (&red, &green, &blue);
3118   
3119   b->red = red * 65535.0;
3120   b->green = green * 65535.0;
3121   b->blue = blue * 65535.0;
3122 }
3123
3124 static void
3125 rgb_to_hls (gdouble *r,
3126             gdouble *g,
3127             gdouble *b)
3128 {
3129   gdouble min;
3130   gdouble max;
3131   gdouble red;
3132   gdouble green;
3133   gdouble blue;
3134   gdouble h, l, s;
3135   gdouble delta;
3136   
3137   red = *r;
3138   green = *g;
3139   blue = *b;
3140   
3141   if (red > green)
3142     {
3143       if (red > blue)
3144         max = red;
3145       else
3146         max = blue;
3147       
3148       if (green < blue)
3149         min = green;
3150       else
3151         min = blue;
3152     }
3153   else
3154     {
3155       if (green > blue)
3156         max = green;
3157       else
3158         max = blue;
3159       
3160       if (red < blue)
3161         min = red;
3162       else
3163         min = blue;
3164     }
3165   
3166   l = (max + min) / 2;
3167   s = 0;
3168   h = 0;
3169   
3170   if (max != min)
3171     {
3172       if (l <= 0.5)
3173         s = (max - min) / (max + min);
3174       else
3175         s = (max - min) / (2 - max - min);
3176       
3177       delta = max -min;
3178       if (red == max)
3179         h = (green - blue) / delta;
3180       else if (green == max)
3181         h = 2 + (blue - red) / delta;
3182       else if (blue == max)
3183         h = 4 + (red - green) / delta;
3184       
3185       h *= 60;
3186       if (h < 0.0)
3187         h += 360;
3188     }
3189   
3190   *r = h;
3191   *g = l;
3192   *b = s;
3193 }
3194
3195 static void
3196 hls_to_rgb (gdouble *h,
3197             gdouble *l,
3198             gdouble *s)
3199 {
3200   gdouble hue;
3201   gdouble lightness;
3202   gdouble saturation;
3203   gdouble m1, m2;
3204   gdouble r, g, b;
3205   
3206   lightness = *l;
3207   saturation = *s;
3208   
3209   if (lightness <= 0.5)
3210     m2 = lightness * (1 + saturation);
3211   else
3212     m2 = lightness + saturation - lightness * saturation;
3213   m1 = 2 * lightness - m2;
3214   
3215   if (saturation == 0)
3216     {
3217       *h = lightness;
3218       *l = lightness;
3219       *s = lightness;
3220     }
3221   else
3222     {
3223       hue = *h + 120;
3224       while (hue > 360)
3225         hue -= 360;
3226       while (hue < 0)
3227         hue += 360;
3228       
3229       if (hue < 60)
3230         r = m1 + (m2 - m1) * hue / 60;
3231       else if (hue < 180)
3232         r = m2;
3233       else if (hue < 240)
3234         r = m1 + (m2 - m1) * (240 - hue) / 60;
3235       else
3236         r = m1;
3237       
3238       hue = *h;
3239       while (hue > 360)
3240         hue -= 360;
3241       while (hue < 0)
3242         hue += 360;
3243       
3244       if (hue < 60)
3245         g = m1 + (m2 - m1) * hue / 60;
3246       else if (hue < 180)
3247         g = m2;
3248       else if (hue < 240)
3249         g = m1 + (m2 - m1) * (240 - hue) / 60;
3250       else
3251         g = m1;
3252       
3253       hue = *h - 120;
3254       while (hue > 360)
3255         hue -= 360;
3256       while (hue < 0)
3257         hue += 360;
3258       
3259       if (hue < 60)
3260         b = m1 + (m2 - m1) * hue / 60;
3261       else if (hue < 180)
3262         b = m2;
3263       else if (hue < 240)
3264         b = m1 + (m2 - m1) * (240 - hue) / 60;
3265       else
3266         b = m1;
3267       
3268       *h = r;
3269       *l = g;
3270       *s = b;
3271     }
3272 }
3273
3274 void 
3275 gtk_paint_hline (GtkStyle      *style,
3276                  GdkWindow     *window,
3277                  GtkStateType   state_type,
3278                  GdkRectangle  *area,
3279                  GtkWidget     *widget,
3280                  gchar         *detail,
3281                  gint          x1,
3282                  gint          x2,
3283                  gint          y)
3284 {
3285   g_return_if_fail (style != NULL);
3286   g_return_if_fail (style->klass != NULL);
3287   g_return_if_fail (style->klass->draw_hline != NULL);
3288   
3289   (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y);
3290 }
3291
3292 void
3293 gtk_paint_vline (GtkStyle      *style,
3294                  GdkWindow     *window,
3295                  GtkStateType   state_type,
3296                  GdkRectangle  *area,
3297                  GtkWidget     *widget,
3298                  gchar         *detail,
3299                  gint          y1,
3300                  gint          y2,
3301                  gint          x)
3302 {
3303   g_return_if_fail (style != NULL);
3304   g_return_if_fail (style->klass != NULL);
3305   g_return_if_fail (style->klass->draw_vline != NULL);
3306   
3307   (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x);
3308 }
3309
3310 void
3311 gtk_paint_shadow (GtkStyle     *style,
3312                   GdkWindow    *window,
3313                   GtkStateType  state_type,
3314                   GtkShadowType shadow_type,
3315                   GdkRectangle  *area,
3316                   GtkWidget     *widget,
3317                   gchar         *detail,
3318                   gint         x,
3319                   gint         y,
3320                   gint         width,
3321                   gint         height)
3322 {
3323   g_return_if_fail (style != NULL);
3324   g_return_if_fail (style->klass != NULL);
3325   g_return_if_fail (style->klass->draw_shadow != NULL);
3326   
3327   (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3328 }
3329
3330 void
3331 gtk_paint_polygon (GtkStyle      *style,
3332                    GdkWindow     *window,
3333                    GtkStateType   state_type,
3334                    GtkShadowType  shadow_type,
3335                    GdkRectangle  *area,
3336                    GtkWidget     *widget,
3337                    gchar         *detail,
3338                    GdkPoint      *points,
3339                    gint           npoints,
3340                    gboolean       fill)
3341 {
3342   g_return_if_fail (style != NULL);
3343   g_return_if_fail (style->klass != NULL);
3344   g_return_if_fail (style->klass->draw_shadow != NULL);
3345   
3346   (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3347 }
3348
3349 void
3350 gtk_paint_arrow (GtkStyle      *style,
3351                  GdkWindow     *window,
3352                  GtkStateType   state_type,
3353                  GtkShadowType  shadow_type,
3354                  GdkRectangle  *area,
3355                  GtkWidget     *widget,
3356                  gchar         *detail,
3357                  GtkArrowType   arrow_type,
3358                  gboolean       fill,
3359                  gint           x,
3360                  gint           y,
3361                  gint           width,
3362                  gint           height)
3363 {
3364   g_return_if_fail (style != NULL);
3365   g_return_if_fail (style->klass != NULL);
3366   g_return_if_fail (style->klass->draw_arrow != NULL);
3367   
3368   (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3369 }
3370
3371 void
3372 gtk_paint_diamond (GtkStyle      *style,
3373                    GdkWindow     *window,
3374                    GtkStateType   state_type,
3375                    GtkShadowType  shadow_type,
3376                    GdkRectangle  *area,
3377                    GtkWidget     *widget,
3378                    gchar         *detail,
3379                    gint        x,
3380                    gint        y,
3381                    gint        width,
3382                    gint        height)
3383 {
3384   g_return_if_fail (style != NULL);
3385   g_return_if_fail (style->klass != NULL);
3386   g_return_if_fail (style->klass->draw_diamond != NULL);
3387   
3388   (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3389 }
3390
3391 void
3392 gtk_paint_oval (GtkStyle      *style,
3393                 GdkWindow     *window,
3394                 GtkStateType   state_type,
3395                 GtkShadowType  shadow_type,
3396                 GdkRectangle  *area,
3397                 GtkWidget     *widget,
3398                 gchar         *detail,
3399                 gint           x,
3400                 gint           y,
3401                 gint           width,
3402                 gint           height)
3403 {
3404   g_return_if_fail (style != NULL);
3405   g_return_if_fail (style->klass != NULL);
3406   g_return_if_fail (style->klass->draw_oval != NULL);
3407   
3408   (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3409 }
3410
3411 void
3412 gtk_paint_string (GtkStyle      *style,
3413                   GdkWindow     *window,
3414                   GtkStateType   state_type,
3415                   GdkRectangle  *area,
3416                   GtkWidget     *widget,
3417                   gchar         *detail,
3418                   gint         x,
3419                   gint         y,
3420                   const gchar   *string)
3421 {
3422   g_return_if_fail (style != NULL);
3423   g_return_if_fail (style->klass != NULL);
3424   g_return_if_fail (style->klass->draw_oval != NULL);
3425   
3426   (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string);
3427 }
3428
3429 void
3430 gtk_paint_box (GtkStyle      *style,
3431                GdkWindow     *window,
3432                GtkStateType   state_type,
3433                GtkShadowType  shadow_type,
3434                GdkRectangle  *area,
3435                GtkWidget     *widget,
3436                gchar         *detail,
3437                gint            x,
3438                gint            y,
3439                gint            width,
3440                gint            height)
3441 {
3442   g_return_if_fail (style != NULL);
3443   g_return_if_fail (style->klass != NULL);
3444   g_return_if_fail (style->klass->draw_box != NULL);
3445   
3446   (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3447 }
3448
3449 void
3450 gtk_paint_flat_box (GtkStyle      *style,
3451                     GdkWindow     *window,
3452                     GtkStateType   state_type,
3453                     GtkShadowType  shadow_type,
3454                     GdkRectangle  *area,
3455                     GtkWidget     *widget,
3456                     gchar         *detail,
3457                     gint           x,
3458                     gint           y,
3459                     gint           width,
3460                     gint           height)
3461 {
3462   g_return_if_fail (style != NULL);
3463   g_return_if_fail (style->klass != NULL);
3464   g_return_if_fail (style->klass->draw_flat_box != NULL);
3465   
3466   (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3467 }
3468
3469 void
3470 gtk_paint_check (GtkStyle      *style,
3471                  GdkWindow     *window,
3472                  GtkStateType   state_type,
3473                  GtkShadowType  shadow_type,
3474                  GdkRectangle  *area,
3475                  GtkWidget     *widget,
3476                  gchar         *detail,
3477                  gint           x,
3478                  gint           y,
3479                  gint           width,
3480                  gint           height)
3481 {
3482   g_return_if_fail (style != NULL);
3483   g_return_if_fail (style->klass != NULL);
3484   g_return_if_fail (style->klass->draw_check != NULL);
3485   
3486   (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3487 }
3488
3489 void
3490 gtk_paint_option (GtkStyle      *style,
3491                   GdkWindow     *window,
3492                   GtkStateType   state_type,
3493                   GtkShadowType  shadow_type,
3494                   GdkRectangle  *area,
3495                   GtkWidget     *widget,
3496                   gchar         *detail,
3497                   gint           x,
3498                   gint           y,
3499                   gint           width,
3500                   gint           height)
3501 {
3502   g_return_if_fail (style != NULL);
3503   g_return_if_fail (style->klass != NULL);
3504   g_return_if_fail (style->klass->draw_option != NULL);
3505   
3506   (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3507 }
3508
3509 void
3510 gtk_paint_cross (GtkStyle      *style,
3511                  GdkWindow     *window,
3512                  GtkStateType   state_type,
3513                  GtkShadowType  shadow_type,
3514                  GdkRectangle  *area,
3515                  GtkWidget     *widget,
3516                  gchar         *detail,
3517                  gint           x,
3518                  gint           y,
3519                  gint           width,
3520                  gint           height)
3521 {
3522   g_return_if_fail (style != NULL);
3523   g_return_if_fail (style->klass != NULL);
3524   g_return_if_fail (style->klass->draw_cross != NULL);
3525   
3526   (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3527 }
3528
3529 void
3530 gtk_paint_ramp (GtkStyle      *style,
3531                 GdkWindow     *window,
3532                 GtkStateType   state_type,
3533                 GtkShadowType  shadow_type,
3534                 GdkRectangle  *area,
3535                 GtkWidget     *widget,
3536                 gchar         *detail,
3537                 GtkArrowType   arrow_type,
3538                 gint           x,
3539                 gint           y,
3540                 gint           width,
3541                 gint           height)
3542 {
3543   g_return_if_fail (style != NULL);
3544   g_return_if_fail (style->klass != NULL);
3545   g_return_if_fail (style->klass->draw_ramp != NULL);
3546   
3547   (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3548 }
3549
3550 void
3551 gtk_paint_tab (GtkStyle      *style,
3552                GdkWindow     *window,
3553                GtkStateType   state_type,
3554                GtkShadowType  shadow_type,
3555                GdkRectangle  *area,
3556                GtkWidget     *widget,
3557                gchar         *detail,
3558                gint           x,
3559                gint           y,
3560                gint           width,
3561                gint           height)
3562 {
3563   g_return_if_fail (style != NULL);
3564   g_return_if_fail (style->klass != NULL);
3565   g_return_if_fail (style->klass->draw_tab != NULL);
3566   
3567   (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3568 }
3569
3570 void
3571 gtk_paint_shadow_gap (GtkStyle       *style,
3572                       GdkWindow      *window,
3573                       GtkStateType    state_type,
3574                       GtkShadowType   shadow_type,
3575                       GdkRectangle   *area,
3576                       GtkWidget      *widget,
3577                       gchar          *detail,
3578                       gint            x,
3579                       gint            y,
3580                       gint            width,
3581                       gint            height,
3582                       GtkPositionType gap_side,
3583                       gint            gap_x,
3584                       gint            gap_width)
3585 {
3586   g_return_if_fail (style != NULL);
3587   g_return_if_fail (style->klass != NULL);
3588   g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3589   
3590   (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3591 }
3592
3593
3594 void
3595 gtk_paint_box_gap (GtkStyle       *style,
3596                    GdkWindow      *window,
3597                    GtkStateType    state_type,
3598                    GtkShadowType   shadow_type,
3599                    GdkRectangle   *area,
3600                    GtkWidget      *widget,
3601                    gchar          *detail,
3602                    gint            x,
3603                    gint            y,
3604                    gint            width,
3605                    gint            height,
3606                    GtkPositionType gap_side,
3607                    gint            gap_x,
3608                    gint            gap_width)
3609 {
3610   g_return_if_fail (style != NULL);
3611   g_return_if_fail (style->klass != NULL);
3612   g_return_if_fail (style->klass->draw_box_gap != NULL);
3613   
3614   (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3615 }
3616
3617 void
3618 gtk_paint_extension (GtkStyle       *style,
3619                      GdkWindow      *window,
3620                      GtkStateType    state_type,
3621                      GtkShadowType   shadow_type,
3622                      GdkRectangle   *area,
3623                      GtkWidget      *widget,
3624                      gchar          *detail,
3625                      gint            x,
3626                      gint            y,
3627                      gint            width,
3628                      gint            height,
3629                      GtkPositionType gap_side)
3630 {
3631   g_return_if_fail (style != NULL);
3632   g_return_if_fail (style->klass != NULL);
3633   g_return_if_fail (style->klass->draw_extension != NULL);
3634   
3635   (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3636 }
3637
3638 void
3639 gtk_paint_focus (GtkStyle      *style,
3640                  GdkWindow     *window,
3641                  GdkRectangle  *area,
3642                  GtkWidget     *widget,
3643                  gchar         *detail,
3644                  gint           x,
3645                  gint           y,
3646                  gint           width,
3647                  gint           height)
3648 {
3649   g_return_if_fail (style != NULL);
3650   g_return_if_fail (style->klass != NULL);
3651   g_return_if_fail (style->klass->draw_focus != NULL);
3652   
3653   (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height);
3654 }
3655
3656 void
3657 gtk_paint_slider (GtkStyle      *style,
3658                   GdkWindow     *window,
3659                   GtkStateType   state_type,
3660                   GtkShadowType  shadow_type,
3661                   GdkRectangle  *area,
3662                   GtkWidget     *widget,
3663                   gchar         *detail,
3664                   gint           x,
3665                   gint           y,
3666                   gint           width,
3667                   gint           height,
3668                   GtkOrientation orientation)
3669 {
3670   g_return_if_fail (style != NULL);
3671   g_return_if_fail (style->klass != NULL);
3672   g_return_if_fail (style->klass->draw_slider != NULL);
3673   
3674   (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3675 }
3676
3677 void
3678 gtk_paint_handle (GtkStyle      *style,
3679                   GdkWindow     *window,
3680                   GtkStateType   state_type,
3681                   GtkShadowType  shadow_type,
3682                   GdkRectangle  *area,
3683                   GtkWidget     *widget,
3684                   gchar         *detail,
3685                   gint           x,
3686                   gint           y,
3687                   gint           width,
3688                   gint           height,
3689                   GtkOrientation orientation)
3690 {
3691   g_return_if_fail (style != NULL);
3692   g_return_if_fail (style->klass != NULL);
3693   g_return_if_fail (style->klass->draw_handle != NULL);
3694   
3695   (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3696 }