~ubuntu-branches/ubuntu/lucid/gnome-themes-extras/lucid

« back to all changes in this revision

Viewing changes to Smooth/smooth_gtk2_engine.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2004-06-23 20:28:52 UTC
  • Revision ID: james.westby@ubuntu.com-20040623202852-j7hu6zargn5hnban
Tags: upstream-0.7.debian.1
ImportĀ upstreamĀ versionĀ 0.7.debian.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <gmodule.h>
 
2
#include "smooth_rc_style.h"
 
3
#include "smooth_style.h"
 
4
 
 
5
/* Main Theme Functions */
 
6
 
 
7
G_MODULE_EXPORT void
 
8
theme_init (GTypeModule *module)
 
9
{
 
10
  smooth_rc_style_register_type (module);
 
11
  smooth_style_register_type (module);
 
12
}
 
13
 
 
14
G_MODULE_EXPORT void
 
15
theme_exit (void)
 
16
{
 
17
  cleanup_gdk_pixbuf_cache(TRUE);
 
18
}
 
19
 
 
20
G_MODULE_EXPORT GtkRcStyle *
 
21
theme_create_rc_style (void)
 
22
{
 
23
  void *ptr;
 
24
  
 
25
  ptr = GTK_RC_STYLE (g_object_new (SMOOTH_TYPE_RC_STYLE, NULL));  
 
26
  return (GtkRcStyle *)ptr;
 
27
}
 
28
 
 
29
/* The following function will be called by GTK+ when the module
 
30
 * is loaded and checks to see if we are compatible with the
 
31
 * version of GTK+ that loads us.
 
32
*/
 
33
G_MODULE_EXPORT const gchar *g_module_check_init (GModule * module);
 
34
 
 
35
const gchar *
 
36
 
 
37
g_module_check_init (GModule * module)
 
38
{
 
39
  return gtk_check_version (GTK_MAJOR_VERSION,
 
40
                            GTK_MINOR_VERSION,
 
41
                            GTK_MICRO_VERSION - GTK_INTERFACE_AGE);
 
42
}
 
43
 
 
44
/* Style Function Overrides */
 
45
 
 
46
static void
 
47
draw_shadow(GtkStyle * style,
 
48
            GdkWindow * window,
 
49
            GtkStateType state_type,
 
50
            GtkShadowType shadow_type,
 
51
            GdkRectangle * area,
 
52
            GtkWidget * widget,
 
53
            detail_char * detail,
 
54
            gint x,
 
55
            gint y,
 
56
            gint width,
 
57
            gint height)
 
58
{
 
59
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
60
 
 
61
  if (!(widget) || (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)) 
 
62
    smooth_draw_shadow(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height,  GTK_POS_RIGHT);
 
63
  else   
 
64
    smooth_draw_shadow(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height,  GTK_POS_LEFT);
 
65
}
 
66
 
 
67
static void
 
68
draw_hline(GtkStyle * style,
 
69
           GdkWindow * window,
 
70
           GtkStateType state_type,
 
71
           GdkRectangle * area,
 
72
           GtkWidget * widget,
 
73
           detail_char * detail,
 
74
           gint x1,
 
75
           gint x2,
 
76
           gint y)
 
77
{
 
78
  g_return_if_fail(sanitize_parameters(style, window, NULL, NULL));
 
79
 
 
80
  smooth_draw_line(style, window, state_type, area, widget, detail, x1, x2, y, GTK_ORIENTATION_HORIZONTAL);
 
81
}
 
82
 
 
83
 
 
84
static void
 
85
draw_vline(GtkStyle * style,
 
86
           GdkWindow * window,
 
87
           GtkStateType state_type,
 
88
           GdkRectangle * area,
 
89
           GtkWidget * widget,
 
90
           detail_char * detail,
 
91
           gint y1,
 
92
           gint y2,
 
93
           gint x)
 
94
{
 
95
  g_return_if_fail(sanitize_parameters(style, window, NULL, NULL));
 
96
 
 
97
  smooth_draw_line(style, window, state_type, area, widget, detail, y1, y2, x, GTK_ORIENTATION_VERTICAL);
 
98
}
 
99
 
 
100
static void
 
101
draw_polygon(GtkStyle * style,
 
102
             GdkWindow * window,
 
103
             GtkStateType state_type,
 
104
             GtkShadowType shadow_type,
 
105
             GdkRectangle * area,
 
106
             GtkWidget * widget,
 
107
             detail_char * detail,
 
108
             GdkPoint * points,
 
109
             gint npoints,
 
110
             gint fill)
 
111
{
 
112
  g_return_if_fail(sanitize_parameters(style, window, NULL, NULL));
 
113
 
 
114
  smooth_draw_polygon(style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
 
115
}
 
116
 
 
117
static void
 
118
draw_arrow(GtkStyle * style,
 
119
           GdkWindow * window,
 
120
           GtkStateType state_type,
 
121
           GtkShadowType shadow_type,
 
122
           GdkRectangle * area,
 
123
           GtkWidget * widget,
 
124
           detail_char * detail,
 
125
           GtkArrowType arrow_type,
 
126
           gint fill,
 
127
           gint x,
 
128
           gint y,
 
129
           gint width,
 
130
           gint height)
 
131
{
 
132
  gint alternate;
 
133
  
 
134
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
135
  
 
136
  reverse_engineer_arrow_box (widget, detail, arrow_type, &x, &y, &width, &height);
 
137
 
 
138
  x+=ARROW_XPADDING(style); 
 
139
  y+=ARROW_YPADDING(style); 
 
140
  width-=2*ARROW_XPADDING(style); 
 
141
  height-=2*ARROW_YPADDING(style);
 
142
 
 
143
  smooth_draw_arrow(style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
 
144
}
 
145
 
 
146
static void
 
147
draw_focus(GtkStyle *style,
 
148
           GdkWindow *window,
 
149
           GtkStateType state_type,
 
150
           GdkRectangle *area,
 
151
           GtkWidget *widget,
 
152
           detail_char *detail,
 
153
           gint x,
 
154
           gint y,
 
155
           gint width,
 
156
           gint height)
 
157
{
 
158
  gboolean free_dash_list = FALSE;
 
159
  gint line_width = 1;
 
160
  gint8 *dash_list = NULL;
 
161
  gint dash_len;
 
162
 
 
163
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
164
 
 
165
  if (widget)
 
166
    {
 
167
      if (FOCUS_USE_PATTERN(style, state_type))
 
168
        gtk_widget_style_get (widget,
 
169
                              "focus-line-width", &line_width,
 
170
                              NULL);
 
171
      else {
 
172
        gtk_widget_style_get (widget,
 
173
                              "focus-line-width", &line_width,
 
174
                              "focus-line-pattern", (gchar *)&dash_list,
 
175
                              NULL);
 
176
 
 
177
        free_dash_list = TRUE;
 
178
      }  
 
179
  }
 
180
  
 
181
  smooth_draw_focus(style, window, state_type, area, widget, detail, x, y, width, height, dash_list, line_width);
 
182
 
 
183
  
 
184
  if (free_dash_list)
 
185
    g_free (dash_list);
 
186
}
 
187
 
 
188
static void
 
189
draw_slider(GtkStyle * style,
 
190
            GdkWindow * window,
 
191
            GtkStateType state_type,
 
192
            GtkShadowType shadow_type,
 
193
            GdkRectangle * area,
 
194
            GtkWidget * widget,
 
195
            detail_char * detail,
 
196
            gint x,
 
197
            gint y,
 
198
            gint width,
 
199
            gint height,
 
200
            GtkOrientation orientation)
 
201
{
 
202
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
203
 
 
204
  smooth_draw_slider(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
 
205
}
 
206
 
 
207
static void
 
208
draw_extension(GtkStyle * style,
 
209
               GdkWindow * window,
 
210
               GtkStateType state_type,
 
211
               GtkShadowType shadow_type,
 
212
               GdkRectangle * area,
 
213
               GtkWidget * widget,
 
214
               detail_char * detail,
 
215
               gint x,
 
216
               gint y,
 
217
               gint width,
 
218
               gint height,
 
219
               GtkPositionType gap_side)
 
220
{
 
221
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
222
 
 
223
  smooth_draw_extension(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
 
224
}
 
225
 
 
226
static const GtkBorder default_default_border = { 1, 1, 1, 1 };
 
227
static const GtkBorder default_default_outside_border = { 0, 0, 0, 0 };
 
228
 
 
229
static void
 
230
gtk_button_get_props (GtkWidget *widget,
 
231
                      GtkBorder *default_border,
 
232
                      GtkBorder *default_outside_border,
 
233
                      gboolean  *interior_focus)
 
234
{
 
235
  GtkBorder *tmp_border;
 
236
 
 
237
  if (default_border)
 
238
    {
 
239
      gtk_widget_style_get (widget, "default_border", &tmp_border, NULL);
 
240
 
 
241
      if (tmp_border)
 
242
        {
 
243
          *default_border = *tmp_border;
 
244
          g_free (tmp_border);
 
245
        }
 
246
      else
 
247
        *default_border = default_default_border;
 
248
    }
 
249
 
 
250
  if (default_outside_border)
 
251
    {
 
252
      gtk_widget_style_get (widget, "default_outside_border", &tmp_border, NULL);
 
253
 
 
254
      if (tmp_border)
 
255
        {
 
256
          *default_outside_border = *tmp_border;
 
257
          g_free (tmp_border);
 
258
        }
 
259
      else
 
260
        *default_outside_border = default_default_outside_border;
 
261
    }
 
262
 
 
263
  if (interior_focus)
 
264
    gtk_widget_style_get (widget, "interior_focus", interior_focus, NULL);
 
265
}
 
266
 
 
267
static void
 
268
draw_box(GtkStyle * style,
 
269
         GdkWindow * window,
 
270
         GtkStateType state_type,
 
271
         GtkShadowType shadow_type,
 
272
         GdkRectangle * area,
 
273
         GtkWidget * widget,
 
274
         detail_char * detail,
 
275
         gint x,
 
276
         gint y,
 
277
         gint width,
 
278
         gint height)
 
279
{
 
280
  GtkOrientation orientation;
 
281
  
 
282
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
283
    
 
284
        if (DETAIL("buttondefault"))
 
285
        {
 
286
                GdkRectangle button;
 
287
 
 
288
                gint border_width = GTK_CONTAINER (widget)->border_width;
 
289
                GtkBorder default_border;
 
290
                GtkBorder default_outside_border;
 
291
                gboolean interior_focus;
 
292
                gint focus_width;
 
293
                gint focus_pad;
 
294
 
 
295
                gtk_button_get_props (widget, &default_border, &default_outside_border, &interior_focus);
 
296
                gtk_widget_style_get (widget,
 
297
                                        "focus-line-width", &focus_width,
 
298
                                        "focus-padding", &focus_pad,
 
299
                                        NULL); 
 
300
        
 
301
                button.x = widget->allocation.x + border_width + default_outside_border.left;
 
302
                button.y = widget->allocation.y + border_width + default_outside_border.top;
 
303
                button.width = (widget->allocation.width - border_width * 2) - (default_outside_border.left + default_outside_border.right);
 
304
                button.height = (widget->allocation.height - border_width * 2) - (default_outside_border.top + default_outside_border.bottom);
 
305
 
 
306
                if (!interior_focus)
 
307
                {
 
308
                        button.x += focus_width + focus_pad;
 
309
                        button.y += focus_width + focus_pad;
 
310
                        button.width -= 2 * (focus_width + focus_pad);
 
311
                        button.height -= 2 * (focus_width + focus_pad);
 
312
                }
 
313
 
 
314
                smooth_draw_button_default(style, window, state_type, area, &button, widget, x, y, width, height);
 
315
 
 
316
                return;
 
317
        }       
 
318
 
 
319
  if (DETAIL("togglebutton") || DETAIL("button") || DETAIL("spinbutton_up") || DETAIL("spinbutton_down") || GTK_IS_BUTTON(widget))
 
320
    orientation = GTK_ORIENTATION_HORIZONTAL;
 
321
  else if (DETAIL("hscrollbar"))
 
322
    orientation = GTK_ORIENTATION_HORIZONTAL;
 
323
  else if (DETAIL("vscrollbar"))
 
324
    orientation = GTK_ORIENTATION_VERTICAL;
 
325
  else if (DETAIL("menubar") || DETAIL("menuitem") || DETAIL("optionmenu") || DETAIL("optionmenutab") || DETAIL("metacity"))
 
326
    orientation = GTK_ORIENTATION_HORIZONTAL;
 
327
  else if (DETAIL("hruler"))
 
328
    orientation = GTK_ORIENTATION_HORIZONTAL;
 
329
  else if (DETAIL("vruler"))
 
330
    orientation = GTK_ORIENTATION_VERTICAL;
 
331
  else if (GTK_IS_PROGRESS_BAR(widget)) 
 
332
    {
 
333
      switch (GTK_PROGRESS_BAR(widget)->orientation) {
 
334
        case GTK_PROGRESS_LEFT_TO_RIGHT:
 
335
        case GTK_PROGRESS_RIGHT_TO_LEFT:
 
336
          orientation = GTK_ORIENTATION_HORIZONTAL;
 
337
          break;
 
338
        case GTK_PROGRESS_BOTTOM_TO_TOP:
 
339
        case GTK_PROGRESS_TOP_TO_BOTTOM:
 
340
          orientation = GTK_ORIENTATION_VERTICAL;
 
341
          break;
 
342
      }   
 
343
    }  
 
344
  else if (GTK_IS_SCROLLBAR(widget)) 
 
345
    orientation = (GTK_IS_VSCROLLBAR(widget))?GTK_ORIENTATION_VERTICAL:GTK_ORIENTATION_HORIZONTAL;
 
346
  else if (GTK_IS_SCALE(widget))
 
347
    orientation = (GTK_IS_VSCALE(widget))?GTK_ORIENTATION_VERTICAL:GTK_ORIENTATION_HORIZONTAL;
 
348
  else if (height > width)
 
349
    orientation = GTK_ORIENTATION_VERTICAL;
 
350
  else
 
351
    orientation = GTK_ORIENTATION_HORIZONTAL;     
 
352
 
 
353
  smooth_draw_box(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
 
354
}
 
355
 
 
356
static void
 
357
draw_box_gap (GtkStyle * style, 
 
358
              GdkWindow * window, 
 
359
              GtkStateType state_type, 
 
360
              GtkShadowType shadow_type, 
 
361
              GdkRectangle * area, 
 
362
              GtkWidget * widget, 
 
363
              detail_char * detail, 
 
364
              gint x, 
 
365
              gint y, 
 
366
              gint width, 
 
367
              gint height, 
 
368
              GtkPositionType gap_side, 
 
369
              gint gap_pos, 
 
370
              gint gap_width)
 
371
{
 
372
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
373
  
 
374
  smooth_draw_box_gap(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_pos-1, gap_width+1);
 
375
}
 
376
 
 
377
static void
 
378
draw_shadow_gap (GtkStyle * style, 
 
379
                 GdkWindow * window, 
 
380
                 GtkStateType state_type, 
 
381
                 GtkShadowType shadow_type, 
 
382
                 GdkRectangle * area, 
 
383
                 GtkWidget * widget, 
 
384
                 detail_char * detail, 
 
385
                 gint x, 
 
386
                 gint y, 
 
387
                 gint width, 
 
388
                 gint height, 
 
389
                 GtkPositionType gap_side, 
 
390
                 gint gap_pos, 
 
391
                 gint gap_width)
 
392
{
 
393
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
394
  
 
395
  smooth_draw_box_gap(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_pos, gap_width);
 
396
}
 
397
 
 
398
static void
 
399
draw_option(GtkStyle * style,
 
400
            GdkWindow * window,
 
401
            GtkStateType state_type,
 
402
            GtkShadowType shadow_type,
 
403
            GdkRectangle * area,
 
404
            GtkWidget * widget,
 
405
            detail_char *detail,
 
406
            gint x,
 
407
            gint y,
 
408
            gint width,
 
409
            gint height)
 
410
{
 
411
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
412
  
 
413
  smooth_draw_option(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 
414
}
 
415
 
 
416
static void
 
417
draw_check(GtkStyle * style,
 
418
           GdkWindow * window,
 
419
           GtkStateType state_type,
 
420
           GtkShadowType shadow_type,
 
421
           GdkRectangle * area,
 
422
           GtkWidget * widget,
 
423
           detail_char * detail,
 
424
           gint x,
 
425
           gint y,
 
426
           gint width,
 
427
           gint height)
 
428
{  
 
429
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
430
 
 
431
  smooth_draw_check(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 
432
}
 
433
 
 
434
static void
 
435
draw_diamond(GtkStyle * style,
 
436
             GdkWindow * window,
 
437
             GtkStateType state_type,
 
438
             GtkShadowType shadow_type,
 
439
             GdkRectangle * area,
 
440
             GtkWidget * widget,
 
441
             detail_char * detail,
 
442
             gint x,
 
443
             gint y,
 
444
             gint width,
 
445
             gint height)
 
446
{
 
447
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
448
 
 
449
  smooth_draw_diamond(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 
450
}
 
451
 
 
452
static void
 
453
draw_handle(GtkStyle * style,
 
454
            GdkWindow * window,
 
455
            GtkStateType state_type,
 
456
            GtkShadowType shadow_type,
 
457
            GdkRectangle * area,
 
458
            GtkWidget * widget,
 
459
            detail_char * detail,
 
460
            gint x,
 
461
            gint y,
 
462
            gint width,
 
463
            gint height,
 
464
            GtkOrientation orientation)
 
465
{
 
466
    GdkGC              *light_gc, *dark_gc;
 
467
    GdkRectangle        dest;
 
468
    smooth_grip_style  *grip;
 
469
    gint ax=x, ay=y, aw=width, ah=height;
 
470
    gboolean toolbar_overlap = (GRIP_OVERLAP_TOOLBAR(style) && (DETAIL("dockitem")));
 
471
    gboolean horiz=(DETAIL("handlebox") || (DETAIL("dockitem") && !IS_HANDLE_BOX_ITEM(widget)))?(orientation==GTK_ORIENTATION_HORIZONTAL):(orientation==GTK_ORIENTATION_VERTICAL);
 
472
    gint gap_size=(!horiz)?y+height:x+width;
 
473
    gboolean vert=(!horiz);
 
474
    g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
475
 
 
476
    aw=width; ah=height;
 
477
     
 
478
    grip = GRIP_PART(style);
 
479
    
 
480
    if (!GTK_IS_PANED(widget)) {
 
481
      gint thick = 0;
 
482
      if (toolbar_overlap)
 
483
        thick = EDGE_LINE_THICKNESS(style, NULL)*2;
 
484
      gradient_fill_background(style, window, state_type, area, widget, THEME_PART(grip), x, y, width+thick*horiz, height+thick*vert, shadow_type == GTK_SHADOW_IN, orientation);
 
485
    } else  {
 
486
      FLAT_FILL_BACKGROUND(style, window, state_type, area, widget, THEME_PART(grip), x, y, width, height);
 
487
    }
 
488
    switch (PART_STYLE(grip)) {
 
489
      case NO_GRIP:
 
490
        break;
 
491
      case BARS_IN_GRIP :
 
492
      case BARS_OUT_GRIP :
 
493
        {
 
494
          gint w=width, h=height;
 
495
                
 
496
          if (vert) {
 
497
             if (DETAIL("handlebox")) {
 
498
              h+=1;
 
499
              gap_size=x+width;
 
500
             }else
 
501
             if (DETAIL("dockitem")) {
 
502
                w+=1;
 
503
                h = MIN(height+1, width + height/7);
 
504
                y = y + (height - h)/2;
 
505
                orientation = GTK_ORIENTATION_HORIZONTAL;
 
506
                if (!toolbar_overlap) y -=1;
 
507
             } else 
 
508
             {
 
509
               h+=1;
 
510
               y-=1;
 
511
               w = MIN(width+1, width/7 + height);
 
512
               x = x + (width - w)/2;
 
513
             }
 
514
          } else {
 
515
             if (DETAIL("handlebox")) {
 
516
              w+=1;
 
517
              gap_size=y+height;
 
518
              orientation = GTK_ORIENTATION_VERTICAL;
 
519
             }else
 
520
             if (DETAIL("dockitem")) {
 
521
               h+=1;
 
522
               w = MIN(width+1, width/7 + height);
 
523
               x = x + (width - w)/2;
 
524
               orientation = GTK_ORIENTATION_VERTICAL;
 
525
               if (!toolbar_overlap) x -=1;
 
526
             } else {
 
527
               w+=1;
 
528
               x-=1;
 
529
               h = MIN(height+1, width + height/7);
 
530
               y = y + (height - h)/2;
 
531
             }
 
532
          }
 
533
                
 
534
          width = w;
 
535
          height = h;
 
536
        }
 
537
        break;
 
538
      case LINES_IN_GRIP :
 
539
      case LINES_OUT_GRIP :
 
540
        {
 
541
          gint w=width, h=height;
 
542
                
 
543
          if (vert) {
 
544
             w+=1;
 
545
             h = MIN(height+1, width + height/7);
 
546
             y = y + (height - h)/2;
 
547
             if ((GTK_IS_PANED(widget)) || (GTK_IS_RANGE(widget))) orientation = GTK_ORIENTATION_HORIZONTAL;
 
548
             if (!GRIP_OVERLAP_TOOLBAR(style) && DETAIL("dockitem")) y -=1;
 
549
          } else {
 
550
             w = MIN(width+1, width/7 + height);
 
551
             x = x + (width - w)/2;
 
552
             if ((GTK_IS_PANED(widget)) || (GTK_IS_RANGE(widget))) orientation = GTK_ORIENTATION_VERTICAL;
 
553
             if (!GRIP_OVERLAP_TOOLBAR(style) && DETAIL("dockitem")) x -=1;
 
554
          }
 
555
                
 
556
          if (DETAIL("dockitem") || DETAIL("handlebox"))
 
557
            orientation = GTK_ORIENTATION_VERTICAL;
 
558
          break;
 
559
 
 
560
          width = w;
 
561
          height = h;
 
562
        }
 
563
        break;
 
564
      case DOTS_OUT_GRIP:
 
565
      case DOTS_IN_GRIP:
 
566
      case SMALLDOTS_IN_GRIP :
 
567
      case SMALLDOTS_OUT_GRIP :
 
568
        if (DETAIL("dockitem") || DETAIL("handlebox"))
 
569
          orientation = GTK_ORIENTATION_VERTICAL;
 
570
        break;
 
571
      case FIXEDLINES_OUT_GRIP:
 
572
      case FIXEDLINES_IN_GRIP:
 
573
        if (DETAIL("dockitem") || DETAIL("handlebox"))
 
574
          orientation = GTK_ORIENTATION_VERTICAL;
 
575
        break;
 
576
      case MAC_BUDS_IN_GRIP:
 
577
      case MAC_BUDS_OUT_GRIP:
 
578
      case NS_BUDS_IN_GRIP:
 
579
      case NS_BUDS_OUT_GRIP:
 
580
        x += 3;
 
581
        y += 3;
 
582
        width -= 4;
 
583
        height -= 6;
 
584
        orientation = GTK_ORIENTATION_VERTICAL;
 
585
        break;
 
586
     }
 
587
 
 
588
    smooth_draw_grip(style, window, state_type, area, x+PART_XPADDING(grip), y+PART_YPADDING(grip), width-PART_XPADDING(grip)*2, height-PART_YPADDING(grip)*2, orientation);      
 
589
 
 
590
    switch (PART_STYLE(grip)) {
 
591
      case BARS_IN_GRIP :
 
592
      case BARS_OUT_GRIP :
 
593
      case LINES_IN_GRIP :
 
594
      case LINES_OUT_GRIP :
 
595
        x=ax; 
 
596
        y=ay; 
 
597
        width=aw; 
 
598
        height=ah;
 
599
        break;
 
600
        
 
601
      case MAC_BUDS_IN_GRIP:
 
602
      case MAC_BUDS_OUT_GRIP:
 
603
      case NS_BUDS_IN_GRIP:
 
604
      case NS_BUDS_OUT_GRIP:
 
605
        x -= 3;
 
606
        y -= 3;
 
607
        width += 4;
 
608
        height += 6;
 
609
        break;
 
610
    }
 
611
 
 
612
  if ((THEME_PART(grip)->use_line || THEME_PART(grip)->edge.use_line)) {
 
613
    gint thick = 0;
 
614
 
 
615
    if (toolbar_overlap)
 
616
      thick = EDGE_LINE_THICKNESS(style, grip)*2;
 
617
    else
 
618
      gap_size = 0;    
 
619
 
 
620
    smooth_draw_shadow_with_gap(style, window, state_type, shadow_type, area, widget, detail, THEME_PART(grip), x, y, width+horiz*thick, height+vert*thick, vert?GTK_POS_BOTTOM:GTK_POS_RIGHT, 0, gap_size);
 
621
  } else  {
 
622
    gint thick = 0;
 
623
 
 
624
    if (toolbar_overlap)
 
625
      thick = EDGE_LINE_THICKNESS(style, NULL)*2;
 
626
    else
 
627
      gap_size = 0;    
 
628
      
 
629
    smooth_draw_shadow_with_gap(style, window, state_type, shadow_type, area, widget, detail, NULL, x, y, width+horiz*thick, height+vert*thick, vert?GTK_POS_BOTTOM:GTK_POS_RIGHT, 0, gap_size);
 
630
  }
 
631
}
 
632
 
 
633
static void make_square(gint * value1, gint * value2) 
 
634
 
635
  if (*value1 < *value2) 
 
636
    *value2 = *value1;
 
637
}
 
638
 
 
639
static void make_square_offset(gint * value1, gint * value2, gint * value3) 
 
640
 
641
  if (*value1 < *value2) 
 
642
  {
 
643
    *value3 += (*value1 - *value2);
 
644
    *value2 = *value1;
 
645
  }
 
646
}
 
647
   
 
648
static void
 
649
draw_resize_grip (GtkStyle       *style,
 
650
                              GdkWindow      *window,
 
651
                              GtkStateType    state_type,
 
652
                              GdkRectangle   *area,
 
653
                              GtkWidget      *widget,
 
654
                              const gchar    *detail,
 
655
                              GdkWindowEdge   edge,
 
656
                              gint            x,
 
657
                              gint            y,
 
658
                              gint            width,
 
659
                              gint            height)
 
660
{
 
661
  g_return_if_fail (GTK_IS_STYLE (style));
 
662
  g_return_if_fail (window != NULL);
 
663
  
 
664
  if (widget && GTK_IS_STATUSBAR(widget) && !RESIZE_GRIP(style)) {
 
665
    gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(widget), FALSE);
 
666
    return;
 
667
  }
 
668
    
 
669
  if (area)
 
670
    {
 
671
      gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
 
672
      gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
 
673
      gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
 
674
    }
 
675
  
 
676
  switch (edge)
 
677
    {
 
678
    case GDK_WINDOW_EDGE_WEST:
 
679
    case GDK_WINDOW_EDGE_EAST:
 
680
      {
 
681
        gint xi;
 
682
 
 
683
        if (edge==GDK_WINDOW_EDGE_WEST) 
 
684
          make_square(&height, &width); 
 
685
        else 
 
686
          make_square_offset(&height, &width, &x);
 
687
        
 
688
        xi = x;
 
689
 
 
690
        while (xi < x + width)
 
691
          {
 
692
            gdk_draw_line (window,
 
693
                           style->light_gc[state_type],
 
694
                           xi, y,
 
695
                           xi, y + height);
 
696
 
 
697
            xi++;
 
698
            gdk_draw_line (window,
 
699
                           style->dark_gc[state_type],
 
700
                           xi, y,
 
701
                           xi, y + height);
 
702
 
 
703
            xi += 2;
 
704
          }
 
705
      }
 
706
      break;
 
707
    case GDK_WINDOW_EDGE_NORTH:
 
708
    case GDK_WINDOW_EDGE_SOUTH:
 
709
      {
 
710
        gint yi;
 
711
 
 
712
        if (edge==GDK_WINDOW_EDGE_NORTH) 
 
713
          make_square(&width, &height); 
 
714
        else 
 
715
          make_square_offset(&width, &height, &y);
 
716
 
 
717
        yi = y;
 
718
 
 
719
        while (yi < y + height)
 
720
          {
 
721
            gdk_draw_line (window,
 
722
                           style->light_gc[state_type],
 
723
                           x, yi,
 
724
                           x + width, yi);
 
725
 
 
726
            yi++;
 
727
            gdk_draw_line (window,
 
728
                           style->dark_gc[state_type],
 
729
                           x, yi,
 
730
                           x + width, yi);
 
731
 
 
732
            yi+= 2;
 
733
          }
 
734
      }
 
735
      break;
 
736
    case GDK_WINDOW_EDGE_NORTH_WEST:
 
737
      {
 
738
        gint xi, yi;
 
739
 
 
740
        make_square(&width, &height);
 
741
        make_square(&height, &width);
 
742
        
 
743
        xi = x + width;
 
744
        yi = y + height;
 
745
 
 
746
        while (xi > x + 3)
 
747
          {
 
748
            gdk_draw_line (window,
 
749
                           style->dark_gc[state_type],
 
750
                           xi, y,
 
751
                           x, yi);
 
752
 
 
753
            --xi;
 
754
            --yi;
 
755
 
 
756
            gdk_draw_line (window,
 
757
                           style->dark_gc[state_type],
 
758
                           xi, y,
 
759
                           x, yi);
 
760
 
 
761
            --xi;
 
762
            --yi;
 
763
 
 
764
            gdk_draw_line (window,
 
765
                           style->light_gc[state_type],
 
766
                           xi, y,
 
767
                           x, yi);
 
768
 
 
769
            xi -= 3;
 
770
            yi -= 3;
 
771
            
 
772
          }
 
773
      }
 
774
      break;
 
775
    case GDK_WINDOW_EDGE_NORTH_EAST:
 
776
      {
 
777
        gint xi, yi;
 
778
 
 
779
        make_square(&width, &height);
 
780
        make_square_offset(&height, &width, &x);
 
781
 
 
782
        xi = x;
 
783
        yi = y + height;
 
784
 
 
785
        while (xi < (x + width - 3))
 
786
          {
 
787
            gdk_draw_line (window,
 
788
                           style->light_gc[state_type],
 
789
                           xi, y,
 
790
                           x + width, yi);                           
 
791
 
 
792
            ++xi;
 
793
            --yi;
 
794
            
 
795
            gdk_draw_line (window,
 
796
                           style->dark_gc[state_type],
 
797
                           xi, y,
 
798
                           x + width, yi);                           
 
799
 
 
800
            ++xi;
 
801
            --yi;
 
802
            
 
803
            gdk_draw_line (window,
 
804
                           style->dark_gc[state_type],
 
805
                           xi, y,
 
806
                           x + width, yi);
 
807
 
 
808
            xi += 3;
 
809
            yi -= 3;
 
810
          }
 
811
      }
 
812
      break;
 
813
    case GDK_WINDOW_EDGE_SOUTH_WEST:
 
814
      {
 
815
        gint xi, yi;
 
816
 
 
817
        make_square_offset(&width, &height, &y);
 
818
        make_square(&height, &width);
 
819
        
 
820
        xi = x + width;
 
821
        yi = y;
 
822
 
 
823
        while (xi > x + 3)
 
824
          {
 
825
            gdk_draw_line (window,
 
826
                           style->dark_gc[state_type],
 
827
                           x, yi,
 
828
                           xi, y + height);
 
829
 
 
830
            --xi;
 
831
            ++yi;
 
832
 
 
833
            gdk_draw_line (window,
 
834
                           style->dark_gc[state_type],
 
835
                           x, yi,
 
836
                           xi, y + height);
 
837
 
 
838
            --xi;
 
839
            ++yi;
 
840
 
 
841
            gdk_draw_line (window,
 
842
                           style->light_gc[state_type],
 
843
                           x, yi,
 
844
                           xi, y + height);
 
845
 
 
846
            xi -= 3;
 
847
            yi += 3;
 
848
            
 
849
          }
 
850
      }
 
851
      break;
 
852
    case GDK_WINDOW_EDGE_SOUTH_EAST:
 
853
      {
 
854
        gint xi, yi;
 
855
 
 
856
        make_square_offset(&width, &height, &y);
 
857
        make_square_offset(&height, &width, &x);
 
858
     
 
859
        xi = x;
 
860
        yi = y;
 
861
 
 
862
        while (xi < (x + width - 3))
 
863
          {
 
864
            gdk_draw_line (window,
 
865
                           style->light_gc[state_type],
 
866
                           xi, y + height,
 
867
                           x + width, yi);                           
 
868
 
 
869
            ++xi;
 
870
            ++yi;
 
871
            
 
872
            gdk_draw_line (window,
 
873
                           style->dark_gc[state_type],
 
874
                           xi, y + height,
 
875
                           x + width, yi);                           
 
876
 
 
877
            ++xi;
 
878
            ++yi;
 
879
            
 
880
            gdk_draw_line (window,
 
881
                           style->dark_gc[state_type],
 
882
                           xi, y + height,
 
883
                           x + width, yi);
 
884
 
 
885
            xi += 3;
 
886
            yi += 3;
 
887
          }
 
888
      }
 
889
      break;
 
890
    default:
 
891
      return;
 
892
      break;
 
893
    }
 
894
  
 
895
  if (area)
 
896
    {
 
897
      gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
 
898
      gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
 
899
      gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
 
900
    }
 
901
}
 
902
 
 
903
static const GtkRequisition default_option_indicator_size = { 7, 13 };
 
904
static const GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
 
905
 
 
906
static void
 
907
option_menu_get_props (GtkWidget      *widget,
 
908
                       GtkRequisition *indicator_size,
 
909
                       GtkBorder      *indicator_spacing)
 
910
{
 
911
  GtkRequisition *tmp_size = NULL;
 
912
  GtkBorder *tmp_spacing = NULL;
 
913
  
 
914
  if (widget)
 
915
    gtk_widget_style_get (widget, 
 
916
                          "indicator_size", &tmp_size,
 
917
                          "indicator_spacing", &tmp_spacing,
 
918
                          NULL);
 
919
 
 
920
  if (tmp_size)
 
921
    {
 
922
      *indicator_size = *tmp_size;
 
923
      g_free (tmp_size);
 
924
    }
 
925
  else
 
926
    *indicator_size = default_option_indicator_size;
 
927
 
 
928
  if (tmp_spacing)
 
929
    {
 
930
      *indicator_spacing = *tmp_spacing;
 
931
      g_free (tmp_spacing);
 
932
    }
 
933
  else
 
934
    *indicator_spacing = default_option_indicator_spacing;
 
935
}
 
936
 
 
937
static void
 
938
draw_tab (GtkStyle      *style,
 
939
                      GdkWindow     *window,
 
940
                      GtkStateType   state_type,
 
941
                      GtkShadowType  shadow_type,
 
942
                      GdkRectangle  *area,
 
943
                      GtkWidget     *widget,
 
944
                      const gchar   *detail,
 
945
                      gint           x,
 
946
                      gint           y,
 
947
                      gint           width,
 
948
                      gint           height)
 
949
{
 
950
#define ARROW_SPACE 0
 
951
 
 
952
  GtkRequisition indicator_size;
 
953
  GtkBorder indicator_spacing;
 
954
  gint arrow_height;
 
955
  gboolean solid = SOLID_ARROW(style);
 
956
  GdkGC * border_gc = style->fg_gc[state_type], * fill_gc = style->fg_gc[state_type];
 
957
  gint alternate;
 
958
  
 
959
  g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
960
  
 
961
  alternate = ARROW_STYLE(style);
 
962
 
 
963
  if ((!solid))
 
964
    fill_gc = style->base_gc[state_type];
 
965
      
 
966
  option_menu_get_props (widget, &indicator_size, &indicator_spacing);
 
967
 
 
968
  indicator_size.width += 2;
 
969
  arrow_height = indicator_size.width;
 
970
 
 
971
  x += (width - indicator_size.width) / 2;
 
972
  y += (height - (2 * arrow_height + ARROW_SPACE)) / 2;
 
973
 
 
974
  if (state_type == GTK_STATE_INSENSITIVE)
 
975
    {
 
976
     solid=TRUE;
 
977
     border_gc = style->dark_gc[state_type];
 
978
     fill_gc = style->dark_gc[state_type];
 
979
     do_draw_arrow(window, area, GTK_ARROW_UP, style->light_gc[state_type], style->light_gc[state_type], x+1, y+1, indicator_size.width, arrow_height, alternate); 
 
980
     do_draw_arrow(window, area, GTK_ARROW_DOWN, style->light_gc[state_type], style->light_gc[state_type], x+1, y + arrow_height + ARROW_SPACE + 1, indicator_size.width, arrow_height, alternate); 
 
981
    }
 
982
  
 
983
  do_draw_arrow(window, area, GTK_ARROW_UP, fill_gc, border_gc, x, y, indicator_size.width, arrow_height, alternate); 
 
984
  do_draw_arrow(window, area, GTK_ARROW_DOWN, fill_gc, border_gc, x, y + arrow_height + ARROW_SPACE, indicator_size.width, arrow_height, alternate); 
 
985
}
 
986
 
 
987
static void 
 
988
draw_flat_box (GtkStyle * style,
 
989
               GdkWindow * window,
 
990
               GtkStateType state_type,
 
991
               GtkShadowType shadow_type,
 
992
               GdkRectangle * area,
 
993
               GtkWidget * widget,
 
994
               const gchar * detail,
 
995
               gint x, gint y, gint width, gint height)
 
996
{
 
997
   g_return_if_fail(sanitize_parameters(style, window, &width, &height));
 
998
 
 
999
   /* we always want call to the default for treeviews and such */  
 
1000
 
 
1001
   if ((DETAIL("text")) || (DETAIL("viewportbin")) || (DETAIL("entry_bg")) || ((DETAIL("cell_even")) || 
 
1002
      (DETAIL("cell_odd")) || (DETAIL("cell_even_ruled")) || (DETAIL("cell_odd_ruled")) || (DETAIL("cell_even_sorted")) ||
 
1003
      (DETAIL("cell_odd_sorted")) || (DETAIL("cell_even_ruled_sorted")) || (DETAIL("cell_odd_ruled_sorted"))))
 
1004
   {
 
1005
     parent_class->draw_flat_box (style, window, state_type, shadow_type,
 
1006
                                  area, widget, detail, x, y, width, height);
 
1007
  
 
1008
   } else {
 
1009
     FLAT_FILL_BACKGROUND(style, window, state_type, area, widget, NULL, x, y, width, height);
 
1010
 
 
1011
     if (DETAIL("tooltip")) 
 
1012
       gdk_draw_rectangle(window, style->dark_gc[state_type], FALSE, x, y, width - 1, height - 1);
 
1013
   }
 
1014
}                                             
 
1015
 
 
1016
static void
 
1017
smooth_style_class_init (SmoothStyleClass *klass)
 
1018
{
 
1019
  GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
 
1020
 
 
1021
  parent_class = g_type_class_peek_parent (klass);
 
1022
 
 
1023
  style_class->draw_hline = draw_hline;
 
1024
  style_class->draw_vline = draw_vline;
 
1025
  style_class->draw_shadow = draw_shadow;
 
1026
 
 
1027
  style_class->draw_polygon = draw_polygon;
 
1028
  style_class->draw_diamond = draw_diamond;
 
1029
 
 
1030
  style_class->draw_box = draw_box;
 
1031
  style_class->draw_flat_box = draw_flat_box;
 
1032
  style_class->draw_check = draw_check;
 
1033
  style_class->draw_option = draw_option;
 
1034
  style_class->draw_tab = draw_tab;
 
1035
  style_class->draw_shadow_gap = draw_shadow_gap;
 
1036
  style_class->draw_box_gap = draw_box_gap;
 
1037
  style_class->draw_extension = draw_extension;
 
1038
  style_class->draw_slider = draw_slider;
 
1039
  style_class->draw_handle = draw_handle;
 
1040
 
 
1041
  style_class->draw_focus = draw_focus;
 
1042
 
 
1043
  style_class->draw_arrow = draw_arrow;
 
1044
  style_class->draw_resize_grip = draw_resize_grip;
 
1045
}
 
1046
 
 
1047
GType smooth_type_style = 0;
 
1048
 
 
1049
void
 
1050
smooth_style_register_type (GTypeModule *module)
 
1051
{
 
1052
  static const GTypeInfo object_info =
 
1053
  {
 
1054
    sizeof (SmoothStyleClass),
 
1055
    (GBaseInitFunc) NULL,
 
1056
    (GBaseFinalizeFunc) NULL,
 
1057
    (GClassInitFunc) smooth_style_class_init,
 
1058
    NULL,           /* class_finalize */
 
1059
    NULL,           /* class_data */
 
1060
    sizeof (SmoothStyle),
 
1061
    0,              /* n_preallocs */
 
1062
    (GInstanceInitFunc) NULL,
 
1063
  };
 
1064
  
 
1065
  smooth_type_style = g_type_module_register_type (module,
 
1066
                                                           GTK_TYPE_STYLE,
 
1067
                                                           "SmoothStyle",
 
1068
                                                           &object_info, 0);
 
1069
}