1 | /* ThinIce theme for gtk, based on raster's Motif theme and the Metal theme. |
---|
2 | Authors: Tim Gerla <timg@rrv.net> |
---|
3 | Tomas Ögren <stric@ing.umu.se> |
---|
4 | */ |
---|
5 | /* #define DEBUG 1 */ |
---|
6 | |
---|
7 | #include <math.h> |
---|
8 | #include <string.h> |
---|
9 | #include <gtk/gtknotebook.h> |
---|
10 | |
---|
11 | #include "thinice_style.h" |
---|
12 | #include "thinice_rc_style.h" |
---|
13 | |
---|
14 | #define DETAIL(xx) ((detail) && (!strcmp(xx, detail))) |
---|
15 | #ifndef max |
---|
16 | #define max(x,y) ((x)>=(y)?(x):(y)) |
---|
17 | #endif |
---|
18 | #ifndef min |
---|
19 | #define min(x,y) ((x)<=(y)?(x):(y)) |
---|
20 | #endif |
---|
21 | |
---|
22 | static void thinice_style_init (ThiniceStyle *style); |
---|
23 | static void thinice_style_class_init (ThiniceStyleClass *klass); |
---|
24 | |
---|
25 | static void |
---|
26 | thinice_slash_two(GdkWindow *window, |
---|
27 | GdkGC *gc1, |
---|
28 | GdkGC *gc2, |
---|
29 | gint x, |
---|
30 | gint y, |
---|
31 | gint width, |
---|
32 | gint height); |
---|
33 | |
---|
34 | static void |
---|
35 | thinice_slash_one(GdkWindow *window, |
---|
36 | GdkGC *gc1, |
---|
37 | GdkGC *gc2, |
---|
38 | gint x, |
---|
39 | gint y, |
---|
40 | gint width, |
---|
41 | gint height); |
---|
42 | |
---|
43 | static void |
---|
44 | thinice_dot(GdkWindow *window, |
---|
45 | GdkGC *gc1, |
---|
46 | GdkGC *gc2, |
---|
47 | gint x, |
---|
48 | gint y); |
---|
49 | |
---|
50 | |
---|
51 | static void |
---|
52 | thinice_tab(GtkStyle * style, |
---|
53 | GdkWindow * window, |
---|
54 | GtkStateType state_type, |
---|
55 | GtkShadowType shadow_type, |
---|
56 | GdkRectangle * area, |
---|
57 | GtkWidget * widget, |
---|
58 | const gchar *detail, |
---|
59 | gint x, |
---|
60 | gint y, |
---|
61 | gint width, |
---|
62 | gint height); |
---|
63 | |
---|
64 | #if 0 |
---|
65 | static void |
---|
66 | draw_harrow (GdkWindow *window, |
---|
67 | GdkGC *gc, |
---|
68 | GtkShadowType shadow_type, |
---|
69 | GdkRectangle *area, |
---|
70 | GtkArrowType arrow_type, |
---|
71 | gint x, |
---|
72 | gint y, |
---|
73 | gint width, |
---|
74 | gint height); |
---|
75 | static void |
---|
76 | draw_varrow (GdkWindow *window, |
---|
77 | GdkGC *gc, |
---|
78 | GtkShadowType shadow_type, |
---|
79 | GdkRectangle *area, |
---|
80 | GtkArrowType arrow_type, |
---|
81 | gint x, |
---|
82 | gint y, |
---|
83 | gint width, |
---|
84 | gint height); |
---|
85 | #endif |
---|
86 | |
---|
87 | static GtkStyleClass *parent_class = NULL; |
---|
88 | |
---|
89 | |
---|
90 | static GtkShadowType |
---|
91 | get_shadow_type (GtkStyle *style, const char *detail, GtkShadowType requested) |
---|
92 | { |
---|
93 | GtkShadowType retval = GTK_SHADOW_NONE; |
---|
94 | |
---|
95 | if (requested != GTK_SHADOW_NONE) { |
---|
96 | retval = GTK_SHADOW_ETCHED_IN; |
---|
97 | } |
---|
98 | |
---|
99 | if (DETAIL ("dockitem") || DETAIL ("handlebox_bin") || DETAIL ("spinbutton_up") || DETAIL ("spinbutton_down")) { |
---|
100 | retval = GTK_SHADOW_NONE; |
---|
101 | } else if (DETAIL ("button") || DETAIL ("togglebutton") || DETAIL ("notebook") || DETAIL ("optionmenu")) { |
---|
102 | retval = requested; |
---|
103 | } else if (DETAIL ("menu")) { |
---|
104 | retval = GTK_SHADOW_ETCHED_IN; |
---|
105 | } |
---|
106 | |
---|
107 | return retval; |
---|
108 | } |
---|
109 | |
---|
110 | static void |
---|
111 | calculate_arrow_geometry (GtkArrowType arrow_type, |
---|
112 | gint *x, |
---|
113 | gint *y, |
---|
114 | gint *width, |
---|
115 | gint *height) |
---|
116 | { |
---|
117 | gint w = *width; |
---|
118 | gint h = *height; |
---|
119 | |
---|
120 | switch (arrow_type) |
---|
121 | { |
---|
122 | case GTK_ARROW_UP: |
---|
123 | case GTK_ARROW_DOWN: |
---|
124 | w += (w % 2) - 1; |
---|
125 | h = (w / 2 + 1); |
---|
126 | |
---|
127 | if (h > *height) |
---|
128 | { |
---|
129 | h = *height; |
---|
130 | w = 2 * h - 1; |
---|
131 | } |
---|
132 | |
---|
133 | if (arrow_type == GTK_ARROW_DOWN) |
---|
134 | { |
---|
135 | if (*height % 2 == 1 || h % 2 == 0) |
---|
136 | *height += 1; |
---|
137 | } |
---|
138 | else |
---|
139 | { |
---|
140 | if (*height % 2 == 0 || h % 2 == 0) |
---|
141 | *height -= 1; |
---|
142 | } |
---|
143 | break; |
---|
144 | |
---|
145 | case GTK_ARROW_RIGHT: |
---|
146 | case GTK_ARROW_LEFT: |
---|
147 | h += (h % 2) - 1; |
---|
148 | w = (h / 2 + 1); |
---|
149 | |
---|
150 | if (w > *width) |
---|
151 | { |
---|
152 | w = *width; |
---|
153 | h = 2 * w - 1; |
---|
154 | } |
---|
155 | |
---|
156 | if (arrow_type == GTK_ARROW_RIGHT) |
---|
157 | { |
---|
158 | if (*width % 2 == 1 || w % 2 == 0) |
---|
159 | *width += 1; |
---|
160 | } |
---|
161 | else |
---|
162 | { |
---|
163 | if (*width % 2 == 0 || w % 2 == 0) |
---|
164 | *width -= 1; |
---|
165 | } |
---|
166 | break; |
---|
167 | |
---|
168 | default: |
---|
169 | /* should not be reached */ |
---|
170 | break; |
---|
171 | } |
---|
172 | |
---|
173 | *x += (*width - w) / 2; |
---|
174 | *y += (*height - h) / 2; |
---|
175 | *height = h; |
---|
176 | *width = w; |
---|
177 | } |
---|
178 | static void |
---|
179 | sanitize_size (GdkWindow *window, |
---|
180 | gint *width, |
---|
181 | gint *height) |
---|
182 | { |
---|
183 | if ((*width == -1) && (*height == -1)) |
---|
184 | gdk_window_get_size (window, width, height); |
---|
185 | else if (*width == -1) |
---|
186 | gdk_window_get_size (window, width, NULL); |
---|
187 | else if (*height == -1) |
---|
188 | gdk_window_get_size (window, NULL, height); |
---|
189 | } |
---|
190 | |
---|
191 | static void |
---|
192 | draw_hline(GtkStyle * style, |
---|
193 | GdkWindow * window, |
---|
194 | GtkStateType state_type, |
---|
195 | GdkRectangle * area, |
---|
196 | GtkWidget * widget, |
---|
197 | const gchar *detail, |
---|
198 | gint x1, |
---|
199 | gint x2, |
---|
200 | gint y) |
---|
201 | { |
---|
202 | gint thickness_light; |
---|
203 | gint thickness_dark; |
---|
204 | gint i; |
---|
205 | |
---|
206 | g_return_if_fail(style != NULL); |
---|
207 | g_return_if_fail(window != NULL); |
---|
208 | |
---|
209 | thickness_light = style->ythickness / 2; |
---|
210 | thickness_dark = style->ythickness - thickness_light; |
---|
211 | |
---|
212 | if (area) |
---|
213 | { |
---|
214 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], area); |
---|
215 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], area); |
---|
216 | } |
---|
217 | for (i = 0; i < thickness_dark; i++) |
---|
218 | { |
---|
219 | gdk_draw_line(window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i); |
---|
220 | gdk_draw_line(window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i); |
---|
221 | } |
---|
222 | |
---|
223 | y += thickness_dark; |
---|
224 | for (i = 0; i < thickness_light; i++) |
---|
225 | { |
---|
226 | gdk_draw_line(window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i); |
---|
227 | gdk_draw_line(window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i); |
---|
228 | } |
---|
229 | if (area) |
---|
230 | { |
---|
231 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL); |
---|
232 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL); |
---|
233 | } |
---|
234 | } |
---|
235 | |
---|
236 | static void |
---|
237 | draw_vline(GtkStyle * style, |
---|
238 | GdkWindow * window, |
---|
239 | GtkStateType state_type, |
---|
240 | GdkRectangle * area, |
---|
241 | GtkWidget * widget, |
---|
242 | const gchar *detail, |
---|
243 | gint y1, |
---|
244 | gint y2, |
---|
245 | gint x) |
---|
246 | { |
---|
247 | gint thickness_light; |
---|
248 | gint thickness_dark; |
---|
249 | gint i; |
---|
250 | |
---|
251 | g_return_if_fail(style != NULL); |
---|
252 | g_return_if_fail(window != NULL); |
---|
253 | |
---|
254 | thickness_light = style->xthickness / 2; |
---|
255 | thickness_dark = style->xthickness - thickness_light; |
---|
256 | |
---|
257 | if (area) |
---|
258 | { |
---|
259 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], area); |
---|
260 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], area); |
---|
261 | } |
---|
262 | for (i = 0; i < thickness_dark; i++) |
---|
263 | { |
---|
264 | gdk_draw_line(window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2); |
---|
265 | gdk_draw_line(window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1); |
---|
266 | } |
---|
267 | |
---|
268 | x += thickness_dark; |
---|
269 | for (i = 0; i < thickness_light; i++) |
---|
270 | { |
---|
271 | gdk_draw_line(window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i); |
---|
272 | gdk_draw_line(window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2); |
---|
273 | } |
---|
274 | if (area) |
---|
275 | { |
---|
276 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL); |
---|
277 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL); |
---|
278 | } |
---|
279 | } |
---|
280 | |
---|
281 | static void |
---|
282 | draw_shadow(GtkStyle *style, |
---|
283 | GdkWindow *window, |
---|
284 | GtkStateType state_type, |
---|
285 | GtkShadowType shadow_type, |
---|
286 | GdkRectangle *area, |
---|
287 | GtkWidget *widget, |
---|
288 | const gchar *detail, |
---|
289 | gint x, |
---|
290 | gint y, |
---|
291 | gint width, |
---|
292 | gint height) |
---|
293 | { |
---|
294 | GdkGC *gc1 = NULL; |
---|
295 | GdkGC *gc2 = NULL; |
---|
296 | |
---|
297 | g_return_if_fail(style != NULL); |
---|
298 | g_return_if_fail(window != NULL); |
---|
299 | |
---|
300 | sanitize_size(window, &width, &height); |
---|
301 | |
---|
302 | if (DETAIL("entry") || DETAIL("text")) { |
---|
303 | gint entry_width; |
---|
304 | gint entry_height; |
---|
305 | gdk_window_get_size (window, &entry_width, &entry_height); |
---|
306 | if (entry_width != width || entry_height != height) |
---|
307 | return; |
---|
308 | } |
---|
309 | |
---|
310 | switch (shadow_type) |
---|
311 | { |
---|
312 | case GTK_SHADOW_NONE: |
---|
313 | return; |
---|
314 | case GTK_SHADOW_IN: |
---|
315 | if (((x == 1) || (y == 1)) && (DETAIL("entry") || DETAIL("text"))) |
---|
316 | { |
---|
317 | gc1 = gc2 = style->base_gc[state_type]; |
---|
318 | break; |
---|
319 | } |
---|
320 | case GTK_SHADOW_ETCHED_IN: |
---|
321 | gc1 = style->light_gc[state_type]; |
---|
322 | gc2 = style->dark_gc[state_type]; |
---|
323 | break; |
---|
324 | case GTK_SHADOW_OUT: |
---|
325 | case GTK_SHADOW_ETCHED_OUT: |
---|
326 | gc1 = style->dark_gc[state_type]; |
---|
327 | gc2 = style->light_gc[state_type]; |
---|
328 | break; |
---|
329 | } |
---|
330 | |
---|
331 | if (area) |
---|
332 | { |
---|
333 | gdk_gc_set_clip_rectangle(gc1, area); |
---|
334 | gdk_gc_set_clip_rectangle(gc2, area); |
---|
335 | if ((shadow_type == GTK_SHADOW_IN) || |
---|
336 | (shadow_type == GTK_SHADOW_OUT)) |
---|
337 | { |
---|
338 | gdk_gc_set_clip_rectangle(style->black_gc, area); |
---|
339 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
340 | } |
---|
341 | } |
---|
342 | switch (shadow_type) |
---|
343 | { |
---|
344 | case GTK_SHADOW_NONE: |
---|
345 | break; |
---|
346 | |
---|
347 | case GTK_SHADOW_ETCHED_IN: |
---|
348 | gdk_draw_rectangle(window, gc1, FALSE, x+1, y+1, width-2, height-2); |
---|
349 | gdk_draw_rectangle(window, gc2, FALSE, x, y, width-2, height-2); |
---|
350 | |
---|
351 | break; |
---|
352 | case GTK_SHADOW_IN: |
---|
353 | gdk_draw_line(window, gc2, |
---|
354 | x, y, x + width-1, y); |
---|
355 | gdk_draw_line(window, gc2, |
---|
356 | x, y, x, y + height-1); |
---|
357 | |
---|
358 | gdk_draw_line(window, gc1, |
---|
359 | x, y + height-1, x + width-1, y + height-1); |
---|
360 | gdk_draw_line(window, gc1, |
---|
361 | x + width-1, y, x + width-1, y + height-1); |
---|
362 | break; |
---|
363 | |
---|
364 | case GTK_SHADOW_ETCHED_OUT: |
---|
365 | gdk_draw_rectangle(window, gc1, FALSE, x+1, y+1, width-2, height-2); |
---|
366 | gdk_draw_rectangle(window, gc2, FALSE, x, y, width-2, height-2); |
---|
367 | |
---|
368 | break; |
---|
369 | case GTK_SHADOW_OUT: |
---|
370 | gdk_draw_line(window, gc2, |
---|
371 | x, y, x + width-1, y); |
---|
372 | gdk_draw_line(window, gc2, |
---|
373 | x, y, x, y + height-1); |
---|
374 | |
---|
375 | gdk_draw_line(window, gc1, |
---|
376 | x, y + height-1, x + width-1, y + height-1); |
---|
377 | gdk_draw_line(window, gc1, |
---|
378 | x + width-1, y, x + width-1, y + height-1); |
---|
379 | |
---|
380 | break; |
---|
381 | } |
---|
382 | if (area) |
---|
383 | { |
---|
384 | gdk_gc_set_clip_rectangle(gc1, NULL); |
---|
385 | gdk_gc_set_clip_rectangle(gc2, NULL); |
---|
386 | if ((shadow_type == GTK_SHADOW_IN) || |
---|
387 | (shadow_type == GTK_SHADOW_OUT)) |
---|
388 | { |
---|
389 | gdk_gc_set_clip_rectangle(style->black_gc, NULL); |
---|
390 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
391 | } |
---|
392 | } |
---|
393 | } |
---|
394 | |
---|
395 | static void |
---|
396 | draw_polygon(GtkStyle * style, |
---|
397 | GdkWindow * window, |
---|
398 | GtkStateType state_type, |
---|
399 | GtkShadowType shadow_type, |
---|
400 | GdkRectangle * area, |
---|
401 | GtkWidget * widget, |
---|
402 | const gchar *detail, |
---|
403 | GdkPoint * points, |
---|
404 | gint npoints, |
---|
405 | gint fill) |
---|
406 | { |
---|
407 | #ifndef M_PI |
---|
408 | #define M_PI 3.14159265358979323846 |
---|
409 | #endif /* M_PI */ |
---|
410 | #ifndef M_PI_4 |
---|
411 | #define M_PI_4 0.78539816339744830962 |
---|
412 | #endif /* M_PI_4 */ |
---|
413 | |
---|
414 | static const gdouble pi_over_4 = M_PI_4; |
---|
415 | static const gdouble pi_3_over_4 = M_PI_4 * 3; |
---|
416 | |
---|
417 | GdkGC *gc1; |
---|
418 | GdkGC *gc2; |
---|
419 | GdkGC *gc3; |
---|
420 | GdkGC *gc4; |
---|
421 | gdouble angle; |
---|
422 | gint xadjust; |
---|
423 | gint yadjust; |
---|
424 | gint i; |
---|
425 | |
---|
426 | g_return_if_fail(style != NULL); |
---|
427 | g_return_if_fail(window != NULL); |
---|
428 | g_return_if_fail(points != NULL); |
---|
429 | |
---|
430 | switch (shadow_type) |
---|
431 | { |
---|
432 | case GTK_SHADOW_IN: |
---|
433 | gc1 = style->light_gc[state_type]; |
---|
434 | gc2 = style->dark_gc[state_type]; |
---|
435 | gc3 = style->light_gc[state_type]; |
---|
436 | gc4 = style->dark_gc[state_type]; |
---|
437 | break; |
---|
438 | case GTK_SHADOW_ETCHED_IN: |
---|
439 | gc1 = style->light_gc[state_type]; |
---|
440 | gc2 = style->dark_gc[state_type]; |
---|
441 | gc3 = style->dark_gc[state_type]; |
---|
442 | gc4 = style->light_gc[state_type]; |
---|
443 | break; |
---|
444 | case GTK_SHADOW_OUT: |
---|
445 | gc1 = style->dark_gc[state_type]; |
---|
446 | gc2 = style->light_gc[state_type]; |
---|
447 | gc3 = style->dark_gc[state_type]; |
---|
448 | gc4 = style->light_gc[state_type]; |
---|
449 | break; |
---|
450 | case GTK_SHADOW_ETCHED_OUT: |
---|
451 | gc1 = style->dark_gc[state_type]; |
---|
452 | gc2 = style->light_gc[state_type]; |
---|
453 | gc3 = style->light_gc[state_type]; |
---|
454 | gc4 = style->dark_gc[state_type]; |
---|
455 | break; |
---|
456 | default: |
---|
457 | return; |
---|
458 | } |
---|
459 | |
---|
460 | if (area) |
---|
461 | { |
---|
462 | gdk_gc_set_clip_rectangle(gc1, area); |
---|
463 | gdk_gc_set_clip_rectangle(gc2, area); |
---|
464 | gdk_gc_set_clip_rectangle(gc3, area); |
---|
465 | gdk_gc_set_clip_rectangle(gc4, area); |
---|
466 | } |
---|
467 | |
---|
468 | if (fill) |
---|
469 | gdk_draw_polygon(window, style->bg_gc[state_type], TRUE, points, npoints); |
---|
470 | |
---|
471 | npoints--; |
---|
472 | |
---|
473 | for (i = 0; i < npoints; i++) |
---|
474 | { |
---|
475 | if ((points[i].x == points[i + 1].x) && |
---|
476 | (points[i].y == points[i + 1].y)) |
---|
477 | { |
---|
478 | angle = 0; |
---|
479 | } |
---|
480 | else |
---|
481 | { |
---|
482 | angle = atan2(points[i + 1].y - points[i].y, |
---|
483 | points[i + 1].x - points[i].x); |
---|
484 | } |
---|
485 | |
---|
486 | if ((angle > -pi_3_over_4) && (angle < pi_over_4)) |
---|
487 | { |
---|
488 | if (angle > -pi_over_4) |
---|
489 | { |
---|
490 | xadjust = 0; |
---|
491 | yadjust = 1; |
---|
492 | } |
---|
493 | else |
---|
494 | { |
---|
495 | xadjust = 1; |
---|
496 | yadjust = 0; |
---|
497 | } |
---|
498 | |
---|
499 | gdk_draw_line(window, gc1, |
---|
500 | points[i].x - xadjust, points[i].y - yadjust, |
---|
501 | points[i + 1].x - xadjust, points[i + 1].y - yadjust); |
---|
502 | gdk_draw_line(window, gc3, |
---|
503 | points[i].x, points[i].y, |
---|
504 | points[i + 1].x, points[i + 1].y); |
---|
505 | } |
---|
506 | else |
---|
507 | { |
---|
508 | if ((angle < -pi_3_over_4) || (angle > pi_3_over_4)) |
---|
509 | { |
---|
510 | xadjust = 0; |
---|
511 | yadjust = 1; |
---|
512 | } |
---|
513 | else |
---|
514 | { |
---|
515 | xadjust = 1; |
---|
516 | yadjust = 0; |
---|
517 | } |
---|
518 | |
---|
519 | gdk_draw_line(window, gc4, |
---|
520 | points[i].x + xadjust, points[i].y + yadjust, |
---|
521 | points[i + 1].x + xadjust, points[i + 1].y + yadjust); |
---|
522 | gdk_draw_line(window, gc2, |
---|
523 | points[i].x, points[i].y, |
---|
524 | points[i + 1].x, points[i + 1].y); |
---|
525 | } |
---|
526 | } |
---|
527 | if (area) |
---|
528 | { |
---|
529 | gdk_gc_set_clip_rectangle(gc1, NULL); |
---|
530 | gdk_gc_set_clip_rectangle(gc2, NULL); |
---|
531 | gdk_gc_set_clip_rectangle(gc3, NULL); |
---|
532 | gdk_gc_set_clip_rectangle(gc4, NULL); |
---|
533 | } |
---|
534 | } |
---|
535 | |
---|
536 | #if 0 |
---|
537 | void |
---|
538 | draw_shadearrow(GtkStyle * style, |
---|
539 | GdkWindow * window, |
---|
540 | GtkStateType state_type, |
---|
541 | GtkShadowType shadow_type, |
---|
542 | GdkRectangle * area, |
---|
543 | GtkWidget * widget, |
---|
544 | const gchar *detail, |
---|
545 | GtkArrowType arrow_type, |
---|
546 | gint fill, |
---|
547 | gint x, gint y, |
---|
548 | gint width, gint height) |
---|
549 | { |
---|
550 | int awidth, aheight; |
---|
551 | GdkGC *gc1, *gc2, *gc3, *gc4; |
---|
552 | |
---|
553 | aheight = height + height % 2 - 1; |
---|
554 | awidth = width + width % 2 - 1; |
---|
555 | |
---|
556 | |
---|
557 | gc1 = style->dark_gc[state_type]; |
---|
558 | gc2 = style->light_gc[state_type]; |
---|
559 | if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) |
---|
560 | { |
---|
561 | if (state_type == GTK_STATE_INSENSITIVE || |
---|
562 | shadow_type == GTK_SHADOW_ETCHED_IN || |
---|
563 | shadow_type == GTK_SHADOW_ETCHED_OUT) |
---|
564 | { |
---|
565 | gc1 = style->bg_gc[GTK_STATE_ACTIVE]; |
---|
566 | } |
---|
567 | else |
---|
568 | { |
---|
569 | draw_varrow (window, gc2, shadow_type, area, arrow_type, |
---|
570 | x+1, y, awidth, aheight); |
---|
571 | draw_varrow (window, gc2, shadow_type, area, arrow_type, |
---|
572 | x, y+1, awidth, aheight); |
---|
573 | } |
---|
574 | draw_varrow (window, gc1, shadow_type, area, arrow_type, |
---|
575 | x, y, awidth, aheight); |
---|
576 | } |
---|
577 | else |
---|
578 | { |
---|
579 | |
---|
580 | if (state_type == GTK_STATE_INSENSITIVE || |
---|
581 | shadow_type == GTK_SHADOW_ETCHED_IN || |
---|
582 | shadow_type == GTK_SHADOW_ETCHED_OUT) |
---|
583 | { |
---|
584 | gc1 = style->bg_gc[GTK_STATE_ACTIVE]; |
---|
585 | } |
---|
586 | else |
---|
587 | { |
---|
588 | draw_harrow (window, gc2, shadow_type, area, arrow_type, |
---|
589 | x+1, y, awidth, aheight); |
---|
590 | draw_harrow (window, gc2, shadow_type, area, arrow_type, |
---|
591 | x, y+1, awidth, aheight); |
---|
592 | } |
---|
593 | draw_harrow (window, gc1, shadow_type, area, arrow_type, |
---|
594 | x, y, awidth, aheight); |
---|
595 | } |
---|
596 | |
---|
597 | } |
---|
598 | #endif |
---|
599 | |
---|
600 | static void |
---|
601 | draw_black_arrow (GdkWindow *window, |
---|
602 | GdkGC *gc, |
---|
603 | GdkRectangle *area, |
---|
604 | GtkArrowType arrow_type, |
---|
605 | gint x, |
---|
606 | gint y, |
---|
607 | gint width, |
---|
608 | gint height) |
---|
609 | { |
---|
610 | gint i, j; |
---|
611 | |
---|
612 | if (area) |
---|
613 | gdk_gc_set_clip_rectangle (gc, area); |
---|
614 | |
---|
615 | if (arrow_type == GTK_ARROW_DOWN) |
---|
616 | { |
---|
617 | for (i = 0, j = 0; i < height; i++, j++) |
---|
618 | gdk_draw_line (window, gc, x + j, y + i, x + width - j - 1, y + i); |
---|
619 | } |
---|
620 | else if (arrow_type == GTK_ARROW_UP) |
---|
621 | { |
---|
622 | for (i = height - 1, j = 0; i >= 0; i--, j++) |
---|
623 | gdk_draw_line (window, gc, x + j, y + i, x + width - j - 1, y + i); |
---|
624 | } |
---|
625 | else if (arrow_type == GTK_ARROW_LEFT) |
---|
626 | { |
---|
627 | for (i = width - 1, j = 0; i >= 0; i--, j++) |
---|
628 | gdk_draw_line (window, gc, x + i, y + j, x + i, y + height - j - 1); |
---|
629 | } |
---|
630 | else if (arrow_type == GTK_ARROW_RIGHT) |
---|
631 | { |
---|
632 | for (i = 0, j = 0; i < width; i++, j++) |
---|
633 | gdk_draw_line (window, gc, x + i, y + j, x + i, y + height - j - 1); |
---|
634 | } |
---|
635 | |
---|
636 | if (area) |
---|
637 | gdk_gc_set_clip_rectangle (gc, NULL); |
---|
638 | } |
---|
639 | |
---|
640 | #if 0 |
---|
641 | static void |
---|
642 | draw_arrow(GtkStyle * style, |
---|
643 | GdkWindow * window, |
---|
644 | GtkStateType state, |
---|
645 | GtkShadowType shadow, |
---|
646 | GdkRectangle * area, |
---|
647 | GtkWidget * widget, |
---|
648 | const gchar *detail, |
---|
649 | GtkArrowType arrow_type, |
---|
650 | gint fill, gint x, gint y, gint width, gint height) |
---|
651 | { |
---|
652 | gint original_width, original_x; |
---|
653 | |
---|
654 | sanitize_size (window, &width, &height); |
---|
655 | |
---|
656 | original_width = width; |
---|
657 | original_x = x; |
---|
658 | |
---|
659 | calculate_arrow_geometry (arrow_type, &x, &y, &width, &height); |
---|
660 | |
---|
661 | if (detail && strcmp (detail, "menuitem") == 0) |
---|
662 | x = original_x + original_width - width; |
---|
663 | |
---|
664 | if (state == GTK_STATE_INSENSITIVE) |
---|
665 | draw_black_arrow (window, style->white_gc, area, arrow_type, |
---|
666 | x + 1, y + 1, width, height); |
---|
667 | draw_black_arrow (window, style->fg_gc[state], area, arrow_type, |
---|
668 | x, y, width, height); |
---|
669 | } |
---|
670 | #endif |
---|
671 | static void |
---|
672 | draw_arrow(GtkStyle * style, |
---|
673 | GdkWindow * window, |
---|
674 | GtkStateType state_type, |
---|
675 | GtkShadowType shadow_type, |
---|
676 | GdkRectangle * area, |
---|
677 | GtkWidget * widget, |
---|
678 | const gchar *detail, |
---|
679 | GtkArrowType arrow_type, |
---|
680 | gint fill, gint x, gint y, gint width, gint height) |
---|
681 | { |
---|
682 | GdkGC *gc1; |
---|
683 | GdkGC *gc2; |
---|
684 | GdkGC *gc3; |
---|
685 | GdkGC *gc4; |
---|
686 | gint half_width; |
---|
687 | gint half_height; |
---|
688 | gint ax, ay, aw, ah; |
---|
689 | |
---|
690 | g_return_if_fail(style != NULL); |
---|
691 | g_return_if_fail(window != NULL); |
---|
692 | |
---|
693 | #ifdef DEBUG |
---|
694 | printf("arrow! state_type=%d shadow_type=%d, fill=%d, x,y=%d,%d width,height=%d,%d\n", |
---|
695 | state_type, shadow_type, fill, x, y, width, height); |
---|
696 | printf("\\-- detail=%s, arrow_type=%d\n", detail?detail:"<null>", arrow_type); |
---|
697 | #endif |
---|
698 | /* |
---|
699 | detail=scrollbar, |
---|
700 | arrow_type=0 -> ^ |
---|
701 | arrow_type=1 -> V |
---|
702 | arrow_type=2 -> < |
---|
703 | arrow_type=3 -> > |
---|
704 | */ |
---|
705 | |
---|
706 | |
---|
707 | switch (shadow_type) |
---|
708 | { |
---|
709 | case GTK_SHADOW_IN: |
---|
710 | gc1 = style->bg_gc[state_type]; |
---|
711 | gc2 = style->dark_gc[state_type]; |
---|
712 | gc3 = style->light_gc[state_type]; |
---|
713 | gc4 = style->black_gc; |
---|
714 | break; |
---|
715 | case GTK_SHADOW_OUT: |
---|
716 | gc1 = style->dark_gc[state_type]; |
---|
717 | gc2 = style->light_gc[state_type]; |
---|
718 | gc3 = style->black_gc; |
---|
719 | gc4 = style->bg_gc[state_type]; |
---|
720 | break; |
---|
721 | case GTK_SHADOW_ETCHED_IN: |
---|
722 | gc2 = style->light_gc[state_type]; |
---|
723 | gc1 = style->dark_gc[state_type]; |
---|
724 | gc3 = NULL; |
---|
725 | gc4 = NULL; |
---|
726 | break; |
---|
727 | case GTK_SHADOW_ETCHED_OUT: |
---|
728 | gc1 = style->dark_gc[state_type]; |
---|
729 | gc2 = style->light_gc[state_type]; |
---|
730 | gc3 = NULL; |
---|
731 | gc4 = NULL; |
---|
732 | break; |
---|
733 | default: |
---|
734 | return; |
---|
735 | } |
---|
736 | |
---|
737 | sanitize_size(window, &width, &height); |
---|
738 | ax = x; |
---|
739 | ay = y; |
---|
740 | aw = width; |
---|
741 | ah = height; |
---|
742 | calculate_arrow_geometry (arrow_type, &ax, &ay, &aw, &ah); |
---|
743 | |
---|
744 | half_width = width / 2; |
---|
745 | half_height = height / 2; |
---|
746 | |
---|
747 | if (area) |
---|
748 | { |
---|
749 | gdk_gc_set_clip_rectangle(gc1, area); |
---|
750 | gdk_gc_set_clip_rectangle(gc2, area); |
---|
751 | if ((gc3) && (gc4)) |
---|
752 | { |
---|
753 | gdk_gc_set_clip_rectangle(gc3, area); |
---|
754 | gdk_gc_set_clip_rectangle(gc4, area); |
---|
755 | } |
---|
756 | } |
---|
757 | |
---|
758 | if (DETAIL("vscrollbar") || DETAIL("hscrollbar")) |
---|
759 | { |
---|
760 | #ifdef DEBUG |
---|
761 | printf("Scrollbar of type (%s)!\n", detail); |
---|
762 | #endif |
---|
763 | #ifdef DEBUG |
---|
764 | printf("type = %p\n", thinice_type_rc_style); |
---|
765 | printf("style->rc_style = %p\n", style->rc_style); |
---|
766 | printf("theme_data = %p\n", THINICE_RC_STYLE (style->rc_style)); |
---|
767 | |
---|
768 | printf("mojj1=%d\n", THINICE_RC_STYLE (style->rc_style)->scrollbar_type); |
---|
769 | printf("mojj2=%d\n", THINICE_RC_STYLE (style->rc_style)->scrollbar_marks); |
---|
770 | printf("mojj3=%d\n", THINICE_RC_STYLE (style->rc_style)->scroll_button_marks); |
---|
771 | printf("mojj4=%d\n", THINICE_RC_STYLE (style->rc_style)->handlebox_marks); |
---|
772 | |
---|
773 | printf("mojj5=%d\n", THINICE_RC_STYLE (style->rc_style)->mark_type1); |
---|
774 | printf("mojj6=%d\n", THINICE_RC_STYLE (style->rc_style)->mark_type2); |
---|
775 | printf("rcstyle=%d\n", THINICE_RC_STYLE (style->rc_style)->mark_type2); |
---|
776 | printf("rcstyle2=%d\n", ((struct _ThiniceRcStyle*)(style->rc_style))->mark_type2); |
---|
777 | #endif |
---|
778 | switch (THINICE_RC_STYLE (style->rc_style)->mark_type2) |
---|
779 | { |
---|
780 | case MARKS_NOTHING: |
---|
781 | break; |
---|
782 | case MARKS_INVSLASH: |
---|
783 | thinice_slash_one(window, gc2, gc1, x, y, width, height); |
---|
784 | break; |
---|
785 | case MARKS_DOT: |
---|
786 | thinice_dot(window, gc2, gc1, x + half_width, y + half_height); |
---|
787 | break; |
---|
788 | case MARKS_INVDOT: |
---|
789 | thinice_dot(window, gc1, gc2, x + half_width, y + half_height); |
---|
790 | break; |
---|
791 | case MARKS_ARROW: |
---|
792 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
793 | draw_black_arrow (window, style->white_gc, area, arrow_type, |
---|
794 | ax + 1, ay + 1, aw, ah); |
---|
795 | draw_black_arrow (window, style->fg_gc[state_type], area, arrow_type, |
---|
796 | ax, ay, aw, ah); |
---|
797 | break; |
---|
798 | case MARKS_SLASH: |
---|
799 | default: |
---|
800 | thinice_slash_one(window, gc1, gc2, x, y, width - 1, height - 1); |
---|
801 | break; |
---|
802 | } |
---|
803 | } |
---|
804 | else if DETAIL("spinbutton") |
---|
805 | { |
---|
806 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
807 | draw_black_arrow (window, style->white_gc, area, arrow_type, |
---|
808 | ax + 1, ay + 1, aw, ah); |
---|
809 | draw_black_arrow (window, style->fg_gc[state_type], area, arrow_type, |
---|
810 | ax, ay, aw, ah); |
---|
811 | } |
---|
812 | else if (DETAIL("menuitem")) |
---|
813 | { |
---|
814 | ax = x + width - aw; |
---|
815 | |
---|
816 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
817 | draw_black_arrow (window, style->white_gc, area, arrow_type, |
---|
818 | ax + 1, ay + 1, aw, ah); |
---|
819 | draw_black_arrow (window, style->fg_gc[state_type], area, arrow_type, |
---|
820 | ax, ay, aw, ah); |
---|
821 | } |
---|
822 | else |
---|
823 | { |
---|
824 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
825 | draw_black_arrow (window, style->white_gc, area, arrow_type, |
---|
826 | ax + 1, ay + 1, aw, ah); |
---|
827 | draw_black_arrow (window, style->fg_gc[state_type], area, arrow_type, |
---|
828 | ax, ay, aw, ah); |
---|
829 | } |
---|
830 | |
---|
831 | if (area) |
---|
832 | { |
---|
833 | gdk_gc_set_clip_rectangle(gc1, NULL); |
---|
834 | gdk_gc_set_clip_rectangle(gc2, NULL); |
---|
835 | if (gc3) |
---|
836 | { |
---|
837 | gdk_gc_set_clip_rectangle(gc3, NULL); |
---|
838 | gdk_gc_set_clip_rectangle(gc4, NULL); |
---|
839 | } |
---|
840 | } |
---|
841 | } |
---|
842 | |
---|
843 | |
---|
844 | #if 0 |
---|
845 | static void |
---|
846 | draw_harrow (GdkWindow *window, |
---|
847 | GdkGC *gc, |
---|
848 | GtkShadowType shadow_type, |
---|
849 | GdkRectangle *area, |
---|
850 | GtkArrowType arrow_type, |
---|
851 | gint x, |
---|
852 | gint y, |
---|
853 | gint width, |
---|
854 | gint height) |
---|
855 | { |
---|
856 | gint steps, extra; |
---|
857 | gint x_start, x_increment; |
---|
858 | gint i; |
---|
859 | |
---|
860 | if (area) |
---|
861 | gdk_gc_set_clip_rectangle (gc, area); |
---|
862 | |
---|
863 | height = height + height % 2 - 1; /* Force odd */ |
---|
864 | |
---|
865 | steps = 1 + height / 2; |
---|
866 | |
---|
867 | extra = width - steps; |
---|
868 | |
---|
869 | if (arrow_type == GTK_ARROW_RIGHT) |
---|
870 | { |
---|
871 | x_start = x; |
---|
872 | x_increment = 1; |
---|
873 | } |
---|
874 | else |
---|
875 | { |
---|
876 | x_start = x + width - 1; |
---|
877 | x_increment = -1; |
---|
878 | } |
---|
879 | |
---|
880 | for (i = 0; i < extra; i++) |
---|
881 | { |
---|
882 | gdk_draw_line (window, gc, |
---|
883 | x_start + i * x_increment, y, |
---|
884 | x_start + i * x_increment, y + height - 1); |
---|
885 | } |
---|
886 | for (; i < width; i++) |
---|
887 | { |
---|
888 | gdk_draw_line (window, gc, |
---|
889 | x_start + i * x_increment, y + (i - extra), |
---|
890 | x_start + i * x_increment, y + height - (i - extra) - 1); |
---|
891 | } |
---|
892 | |
---|
893 | |
---|
894 | if (area) |
---|
895 | gdk_gc_set_clip_rectangle (gc, NULL); |
---|
896 | } |
---|
897 | |
---|
898 | |
---|
899 | static void |
---|
900 | draw_varrow (GdkWindow *window, |
---|
901 | GdkGC *gc, |
---|
902 | GtkShadowType shadow_type, |
---|
903 | GdkRectangle *area, |
---|
904 | GtkArrowType arrow_type, |
---|
905 | gint x, |
---|
906 | gint y, |
---|
907 | gint width, |
---|
908 | gint height) |
---|
909 | { |
---|
910 | gint steps, extra; |
---|
911 | gint y_start, y_increment; |
---|
912 | gint i; |
---|
913 | |
---|
914 | if (area) |
---|
915 | gdk_gc_set_clip_rectangle (gc, area); |
---|
916 | |
---|
917 | width = width + width % 2 - 1; /* Force odd */ |
---|
918 | |
---|
919 | steps = 1 + width / 2; |
---|
920 | |
---|
921 | extra = height - steps; |
---|
922 | |
---|
923 | if (arrow_type == GTK_ARROW_DOWN) |
---|
924 | { |
---|
925 | y_start = y; |
---|
926 | y_increment = 1; |
---|
927 | } |
---|
928 | else |
---|
929 | { |
---|
930 | y_start = y + height - 1; |
---|
931 | y_increment = -1; |
---|
932 | } |
---|
933 | |
---|
934 | for (i = 0; i < extra; i++) |
---|
935 | { |
---|
936 | gdk_draw_line (window, gc, |
---|
937 | x, y_start + i * y_increment, |
---|
938 | x + width - 1, y_start + i * y_increment); |
---|
939 | } |
---|
940 | for (; i < height; i++) |
---|
941 | { |
---|
942 | gdk_draw_line (window, gc, |
---|
943 | x + (i - extra), y_start + i * y_increment, |
---|
944 | x + width - (i - extra) - 1, y_start + i * y_increment); |
---|
945 | } |
---|
946 | |
---|
947 | |
---|
948 | if (area) |
---|
949 | gdk_gc_set_clip_rectangle (gc, NULL); |
---|
950 | } |
---|
951 | #endif |
---|
952 | |
---|
953 | static void |
---|
954 | draw_diamond(GtkStyle * style, |
---|
955 | GdkWindow * window, |
---|
956 | GtkStateType state_type, |
---|
957 | GtkShadowType shadow_type, |
---|
958 | GdkRectangle * area, |
---|
959 | GtkWidget * widget, |
---|
960 | const gchar *detail, |
---|
961 | gint x, |
---|
962 | gint y, |
---|
963 | gint width, |
---|
964 | gint height) |
---|
965 | { |
---|
966 | gint half_width; |
---|
967 | gint half_height; |
---|
968 | |
---|
969 | g_return_if_fail(style != NULL); |
---|
970 | g_return_if_fail(window != NULL); |
---|
971 | |
---|
972 | sanitize_size(window, &width, &height); |
---|
973 | |
---|
974 | half_width = width / 2; |
---|
975 | half_height = height / 2; |
---|
976 | |
---|
977 | if (area) |
---|
978 | { |
---|
979 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], area); |
---|
980 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
981 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], area); |
---|
982 | gdk_gc_set_clip_rectangle(style->black_gc, area); |
---|
983 | } |
---|
984 | switch (shadow_type) |
---|
985 | { |
---|
986 | case GTK_SHADOW_IN: |
---|
987 | gdk_draw_line(window, style->light_gc[state_type], |
---|
988 | x + 2, y + half_height, |
---|
989 | x + half_width, y + height - 2); |
---|
990 | gdk_draw_line(window, style->light_gc[state_type], |
---|
991 | x + half_width, y + height - 2, |
---|
992 | x + width - 2, y + half_height); |
---|
993 | gdk_draw_line(window, style->light_gc[state_type], |
---|
994 | x + 1, y + half_height, |
---|
995 | x + half_width, y + height - 1); |
---|
996 | gdk_draw_line(window, style->light_gc[state_type], |
---|
997 | x + half_width, y + height - 1, |
---|
998 | x + width - 1, y + half_height); |
---|
999 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1000 | x, y + half_height, |
---|
1001 | x + half_width, y + height); |
---|
1002 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1003 | x + half_width, y + height, |
---|
1004 | x + width, y + half_height); |
---|
1005 | |
---|
1006 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1007 | x + 2, y + half_height, |
---|
1008 | x + half_width, y + 2); |
---|
1009 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1010 | x + half_width, y + 2, |
---|
1011 | x + width - 2, y + half_height); |
---|
1012 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1013 | x + 1, y + half_height, |
---|
1014 | x + half_width, y + 1); |
---|
1015 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1016 | x + half_width, y + 1, |
---|
1017 | x + width - 1, y + half_height); |
---|
1018 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1019 | x, y + half_height, |
---|
1020 | x + half_width, y); |
---|
1021 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1022 | x + half_width, y, |
---|
1023 | x + width, y + half_height); |
---|
1024 | break; |
---|
1025 | case GTK_SHADOW_OUT: |
---|
1026 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1027 | x + 2, y + half_height, |
---|
1028 | x + half_width, y + height - 2); |
---|
1029 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1030 | x + half_width, y + height - 2, |
---|
1031 | x + width - 2, y + half_height); |
---|
1032 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1033 | x + 1, y + half_height, |
---|
1034 | x + half_width, y + height - 1); |
---|
1035 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1036 | x + half_width, y + height - 1, |
---|
1037 | x + width - 1, y + half_height); |
---|
1038 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1039 | x, y + half_height, |
---|
1040 | x + half_width, y + height); |
---|
1041 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1042 | x + half_width, y + height, |
---|
1043 | x + width, y + half_height); |
---|
1044 | |
---|
1045 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1046 | x + 2, y + half_height, |
---|
1047 | x + half_width, y + 2); |
---|
1048 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1049 | x + half_width, y + 2, |
---|
1050 | x + width - 2, y + half_height); |
---|
1051 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1052 | x + 1, y + half_height, |
---|
1053 | x + half_width, y + 1); |
---|
1054 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1055 | x + half_width, y + 1, |
---|
1056 | x + width - 1, y + half_height); |
---|
1057 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1058 | x, y + half_height, |
---|
1059 | x + half_width, y); |
---|
1060 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1061 | x + half_width, y, |
---|
1062 | x + width, y + half_height); |
---|
1063 | break; |
---|
1064 | default: |
---|
1065 | break; |
---|
1066 | } |
---|
1067 | if (area) |
---|
1068 | { |
---|
1069 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL); |
---|
1070 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
1071 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL); |
---|
1072 | gdk_gc_set_clip_rectangle(style->black_gc, NULL); |
---|
1073 | } |
---|
1074 | } |
---|
1075 | |
---|
1076 | #if 0 |
---|
1077 | static void |
---|
1078 | draw_string(GtkStyle * style, |
---|
1079 | GdkWindow * window, |
---|
1080 | GtkStateType state_type, |
---|
1081 | GdkRectangle * area, |
---|
1082 | GtkWidget * widget, |
---|
1083 | const gchar *detail, |
---|
1084 | gint x, |
---|
1085 | gint y, |
---|
1086 | const gchar * string) |
---|
1087 | { |
---|
1088 | g_return_if_fail(style != NULL); |
---|
1089 | g_return_if_fail(window != NULL); |
---|
1090 | |
---|
1091 | if (area) |
---|
1092 | { |
---|
1093 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
1094 | { |
---|
1095 | gdk_gc_set_clip_rectangle(style->base_gc[state_type], area); |
---|
1096 | } |
---|
1097 | gdk_gc_set_clip_rectangle(style->fg_gc[state_type], area); |
---|
1098 | } |
---|
1099 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
1100 | { |
---|
1101 | gdk_draw_string(window, gtk_style_get_font(style), style->base_gc[state_type], x + 1, y + 1, string); |
---|
1102 | } |
---|
1103 | gdk_draw_string(window, gtk_style_get_font(style), style->fg_gc[state_type], x, y, string); |
---|
1104 | if (area) |
---|
1105 | { |
---|
1106 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
1107 | { |
---|
1108 | gdk_gc_set_clip_rectangle(style->base_gc[state_type], NULL); |
---|
1109 | } |
---|
1110 | gdk_gc_set_clip_rectangle(style->fg_gc[state_type], NULL); |
---|
1111 | } |
---|
1112 | } |
---|
1113 | #endif |
---|
1114 | |
---|
1115 | static void |
---|
1116 | draw_box(GtkStyle * style, |
---|
1117 | GdkWindow * window, |
---|
1118 | GtkStateType state_type, |
---|
1119 | GtkShadowType shadow_type, |
---|
1120 | GdkRectangle * area, |
---|
1121 | GtkWidget * widget, |
---|
1122 | const gchar *detail, |
---|
1123 | gint x, |
---|
1124 | gint y, |
---|
1125 | gint width, |
---|
1126 | gint height) |
---|
1127 | { |
---|
1128 | GdkGC *light_gc, *dark_gc; |
---|
1129 | GtkOrientation orientation; |
---|
1130 | |
---|
1131 | g_return_if_fail(style != NULL); |
---|
1132 | g_return_if_fail(window != NULL); |
---|
1133 | |
---|
1134 | sanitize_size(window, &width, &height); |
---|
1135 | |
---|
1136 | light_gc = style->light_gc[state_type]; |
---|
1137 | dark_gc = style->dark_gc[state_type]; |
---|
1138 | |
---|
1139 | orientation = GTK_ORIENTATION_HORIZONTAL; |
---|
1140 | if (height > width) |
---|
1141 | orientation = GTK_ORIENTATION_VERTICAL; |
---|
1142 | |
---|
1143 | #ifdef DEBUG |
---|
1144 | printf("%p %s %i %i state_type = %d (%d)\n", detail, detail, width, height, state_type, orientation); |
---|
1145 | #endif |
---|
1146 | |
---|
1147 | if (DETAIL("optionmenutab")) |
---|
1148 | { |
---|
1149 | #ifdef DEBUG |
---|
1150 | printf("%p %s %ix%i @ +%i+%i state_type = %d (%d)\n", detail, detail, width, height, x, y, state_type, orientation); |
---|
1151 | #endif |
---|
1152 | if (area) |
---|
1153 | { |
---|
1154 | GdkPoint points[4]; |
---|
1155 | guint size, ydiff, xdiff; |
---|
1156 | |
---|
1157 | size = min(width, height); |
---|
1158 | gdk_gc_set_clip_rectangle(light_gc, area); |
---|
1159 | gdk_gc_set_clip_rectangle(dark_gc, area); |
---|
1160 | |
---|
1161 | #if 0 |
---|
1162 | /* DEBUG */ |
---|
1163 | points[0].x = x ; |
---|
1164 | points[0].y = y ; |
---|
1165 | points[1].x = x + width; |
---|
1166 | points[1].y = y ; |
---|
1167 | points[2].x = x + width; |
---|
1168 | points[2].y = y + height; |
---|
1169 | points[3].x = x ; |
---|
1170 | points[3].y = y + height; |
---|
1171 | |
---|
1172 | gdk_draw_polygon(window, light_gc, FALSE, points, 4); |
---|
1173 | /* DEBUG */ |
---|
1174 | #endif |
---|
1175 | |
---|
1176 | if (size % 2) |
---|
1177 | size++; |
---|
1178 | |
---|
1179 | ydiff = max(0, (height - size) / 2); |
---|
1180 | xdiff = max(0, (width - size) / 2); |
---|
1181 | points[0].x = x + size + xdiff; |
---|
1182 | points[0].y = y + ydiff; |
---|
1183 | points[1].x = x + xdiff; |
---|
1184 | points[1].y = y + ydiff; |
---|
1185 | points[2].x = x + size / 2 + xdiff; |
---|
1186 | points[2].y = y + size + ydiff; |
---|
1187 | gdk_draw_polygon(window, light_gc, FALSE, points, 3); |
---|
1188 | points[0].x--; |
---|
1189 | points[1].x--; |
---|
1190 | points[2].x--; |
---|
1191 | gdk_draw_polygon(window, dark_gc, FALSE, points, 3); |
---|
1192 | |
---|
1193 | gdk_gc_set_clip_rectangle(light_gc, NULL); |
---|
1194 | gdk_gc_set_clip_rectangle(dark_gc, NULL); |
---|
1195 | } |
---|
1196 | } |
---|
1197 | else if (DETAIL("trough")) |
---|
1198 | { |
---|
1199 | if (area) |
---|
1200 | { |
---|
1201 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
1202 | } |
---|
1203 | #ifdef DEBUG |
---|
1204 | printf("trough\n"); |
---|
1205 | #endif |
---|
1206 | gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, |
---|
1207 | x, y, width, height); |
---|
1208 | if (area) |
---|
1209 | { |
---|
1210 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
1211 | } |
---|
1212 | gtk_paint_shadow(style, window, state_type, shadow_type, area, widget, |
---|
1213 | detail, x, y, width, height); |
---|
1214 | } |
---|
1215 | else if (DETAIL("slider")) |
---|
1216 | { |
---|
1217 | } |
---|
1218 | else if (DETAIL("buttondefault")) |
---|
1219 | { |
---|
1220 | /* I don't want no background on default buttons.. |
---|
1221 | Let's add that cute triangle (see below) instead... */ |
---|
1222 | } |
---|
1223 | else if (DETAIL("button")) |
---|
1224 | { |
---|
1225 | GdkPoint points1[3]; /* dark */ |
---|
1226 | GdkPoint points2[3]; /* light */ |
---|
1227 | points1[0].x = x+2; points1[0].y = y+2; |
---|
1228 | points1[1].x = x+10; points1[1].y = y+2; |
---|
1229 | points1[2].x = x+2; points1[2].y = y+10; |
---|
1230 | points2[0].x = x+3; points2[0].y = y+3; |
---|
1231 | points2[1].x = x+10; points2[1].y = y+3; |
---|
1232 | points2[2].x = x+3; points2[2].y = y+10; |
---|
1233 | |
---|
1234 | if (area) |
---|
1235 | { |
---|
1236 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
1237 | } |
---|
1238 | if ((!style->bg_pixmap[state_type]) || GDK_IS_PIXMAP (window)) |
---|
1239 | { |
---|
1240 | gdk_draw_rectangle(window, style->bg_gc[state_type], |
---|
1241 | TRUE, x + 1, y + 1, width - 2, height - 2); |
---|
1242 | } |
---|
1243 | else |
---|
1244 | { |
---|
1245 | gtk_style_apply_default_background(style, window, |
---|
1246 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1247 | state_type, area, |
---|
1248 | x, y, width, height); |
---|
1249 | } |
---|
1250 | /* Paint a triangle here instead of in "buttondefault" |
---|
1251 | which is drawn _behind_ the current button */ |
---|
1252 | if (GTK_WIDGET_HAS_DEFAULT (widget)) |
---|
1253 | { |
---|
1254 | gdk_draw_polygon(window, dark_gc, |
---|
1255 | FALSE, points1, 3); |
---|
1256 | gdk_draw_polygon(window, light_gc, |
---|
1257 | FALSE, points2, 3); |
---|
1258 | gdk_draw_polygon(window, style->bg_gc[GTK_STATE_SELECTED], |
---|
1259 | TRUE, points2, 3); |
---|
1260 | } |
---|
1261 | if (area) |
---|
1262 | { |
---|
1263 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
1264 | } |
---|
1265 | gtk_paint_shadow(style, window, state_type, shadow_type, area, widget, |
---|
1266 | detail, x, y, width, height); |
---|
1267 | } |
---|
1268 | else if (DETAIL("bar")) |
---|
1269 | { |
---|
1270 | if ((height > 1) && (width > 1)) |
---|
1271 | { |
---|
1272 | if (area) |
---|
1273 | { |
---|
1274 | gdk_gc_set_clip_rectangle(style->bg_gc[GTK_STATE_SELECTED], area); |
---|
1275 | } |
---|
1276 | gdk_draw_rectangle(window, style->bg_gc[GTK_STATE_SELECTED], |
---|
1277 | TRUE, x + 1, y + 1, width - 2, height - 2); |
---|
1278 | if (area) |
---|
1279 | { |
---|
1280 | gdk_gc_set_clip_rectangle(style->bg_gc[GTK_STATE_SELECTED], NULL); |
---|
1281 | } |
---|
1282 | } |
---|
1283 | } |
---|
1284 | else if (DETAIL("handlebox_bin")) |
---|
1285 | { |
---|
1286 | if ((!style->bg_pixmap[state_type]) || GDK_IS_PIXMAP(window)) |
---|
1287 | { |
---|
1288 | if (area) |
---|
1289 | { |
---|
1290 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
1291 | } |
---|
1292 | gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, |
---|
1293 | x, y, width, height); |
---|
1294 | if (area) |
---|
1295 | { |
---|
1296 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
1297 | } |
---|
1298 | } |
---|
1299 | else |
---|
1300 | { |
---|
1301 | gtk_style_apply_default_background(style, window, |
---|
1302 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1303 | state_type, area, |
---|
1304 | x, y, width, height); |
---|
1305 | } |
---|
1306 | /* |
---|
1307 | gtk_paint_shadow(style, window, state_type, shadow_type, area, widget, |
---|
1308 | detail, x, y, width, height); |
---|
1309 | */ |
---|
1310 | } |
---|
1311 | else if (DETAIL("menubar")) |
---|
1312 | { |
---|
1313 | if ((!style->bg_pixmap[state_type]) || GDK_IS_PIXMAP(window)) |
---|
1314 | { |
---|
1315 | if (area) |
---|
1316 | { |
---|
1317 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
1318 | } |
---|
1319 | gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, |
---|
1320 | x, y, width, height); |
---|
1321 | if (area) |
---|
1322 | { |
---|
1323 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
1324 | } |
---|
1325 | } |
---|
1326 | else |
---|
1327 | { |
---|
1328 | gtk_style_apply_default_background(style, window, |
---|
1329 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1330 | state_type, area, |
---|
1331 | x, y, width, height); |
---|
1332 | } |
---|
1333 | gtk_paint_shadow(style, window, state_type, shadow_type, area, widget, |
---|
1334 | detail, x, y, width, height); |
---|
1335 | /* |
---|
1336 | } |
---|
1337 | else if (DETAIL("notebook")) |
---|
1338 | { |
---|
1339 | thinice_notebook(style, window, state_type, shadow_type, area, widget, |
---|
1340 | detail, x, y, width, height); |
---|
1341 | */ |
---|
1342 | } |
---|
1343 | else if (DETAIL("tab")) |
---|
1344 | { |
---|
1345 | thinice_tab(style, window, state_type, shadow_type, area, widget, |
---|
1346 | detail, x, y, width, height); |
---|
1347 | } |
---|
1348 | else |
---|
1349 | { |
---|
1350 | #ifdef DEBUG |
---|
1351 | printf("Unknown: [%d,%d] @ [%d,%d] - detail=(%s) shadow_type=%d state_type=%d\n", |
---|
1352 | height,width, x, y, detail, shadow_type, state_type); |
---|
1353 | #endif |
---|
1354 | if ((!style->bg_pixmap[state_type]) || GDK_IS_PIXMAP(window)) |
---|
1355 | { |
---|
1356 | if (area) |
---|
1357 | { |
---|
1358 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
1359 | } |
---|
1360 | gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, |
---|
1361 | x, y, width, height); |
---|
1362 | if (area) |
---|
1363 | { |
---|
1364 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
1365 | } |
---|
1366 | } |
---|
1367 | else |
---|
1368 | { |
---|
1369 | gtk_style_apply_default_background(style, window, |
---|
1370 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1371 | state_type, area, |
---|
1372 | x, y, width, height); |
---|
1373 | } |
---|
1374 | gtk_paint_shadow(style, window, state_type, shadow_type, area, widget, |
---|
1375 | detail, x, y, width, height); |
---|
1376 | } |
---|
1377 | } |
---|
1378 | |
---|
1379 | |
---|
1380 | |
---|
1381 | #if 0 |
---|
1382 | static void |
---|
1383 | draw_flat_box(GtkStyle * style, |
---|
1384 | GdkWindow * window, |
---|
1385 | GtkStateType state_type, |
---|
1386 | GtkShadowType shadow_type, |
---|
1387 | GdkRectangle * area, |
---|
1388 | GtkWidget * widget, |
---|
1389 | const gchar *detail, |
---|
1390 | gint x, |
---|
1391 | gint y, |
---|
1392 | gint width, |
---|
1393 | gint height) |
---|
1394 | { |
---|
1395 | GdkGC *gc1; |
---|
1396 | |
---|
1397 | g_return_if_fail(style != NULL); |
---|
1398 | g_return_if_fail(window != NULL); |
---|
1399 | |
---|
1400 | sanitize_size(window, &width, &height); |
---|
1401 | |
---|
1402 | gc1 = style->bg_gc[state_type]; |
---|
1403 | |
---|
1404 | if (DETAIL("text") && (state_type == GTK_STATE_SELECTED)) |
---|
1405 | gc1 = style->bg_gc[state_type]; |
---|
1406 | else if (DETAIL("viewportbin")) |
---|
1407 | gc1 = style->bg_gc[state_type]; |
---|
1408 | else if (DETAIL("entry_bg")) |
---|
1409 | gc1 = style->base_gc[state_type]; |
---|
1410 | |
---|
1411 | if ((!style->bg_pixmap[state_type]) || (gc1 != style->bg_gc[state_type]) || |
---|
1412 | GDK_IS_PIXMAP(window)) |
---|
1413 | { |
---|
1414 | if (area) |
---|
1415 | gdk_gc_set_clip_rectangle(gc1, area); |
---|
1416 | |
---|
1417 | gdk_draw_rectangle(window, gc1, TRUE, |
---|
1418 | x, y, width, height); |
---|
1419 | if (DETAIL("tooltip")) |
---|
1420 | gdk_draw_rectangle(window, style->black_gc, FALSE, |
---|
1421 | x, y, width - 1, height - 1); |
---|
1422 | if (area) |
---|
1423 | gdk_gc_set_clip_rectangle(gc1, NULL); |
---|
1424 | } |
---|
1425 | else |
---|
1426 | gtk_style_apply_default_background(style, window, |
---|
1427 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1428 | state_type, area, x, y, width, height); |
---|
1429 | } |
---|
1430 | #endif /* 0 */ |
---|
1431 | |
---|
1432 | static void |
---|
1433 | draw_check(GtkStyle * style, |
---|
1434 | GdkWindow * window, |
---|
1435 | GtkStateType state_type, |
---|
1436 | GtkShadowType shadow_type, |
---|
1437 | GdkRectangle * area, |
---|
1438 | GtkWidget * widget, |
---|
1439 | const gchar *detail, |
---|
1440 | gint x, |
---|
1441 | gint y, |
---|
1442 | gint width, |
---|
1443 | gint height) |
---|
1444 | { |
---|
1445 | |
---|
1446 | GdkGC *gc1 = NULL; |
---|
1447 | |
---|
1448 | if (shadow_type == GTK_SHADOW_IN) |
---|
1449 | { |
---|
1450 | gc1 = style->bg_gc[GTK_STATE_ACTIVE]; |
---|
1451 | } |
---|
1452 | |
---|
1453 | if (area && gc1) |
---|
1454 | { |
---|
1455 | gdk_gc_set_clip_rectangle(gc1, area); |
---|
1456 | } |
---|
1457 | |
---|
1458 | if (state_type == GTK_STATE_INSENSITIVE) |
---|
1459 | { |
---|
1460 | gdk_draw_rectangle(window, style->dark_gc[state_type], FALSE, |
---|
1461 | x, y, width, height); |
---|
1462 | } |
---|
1463 | else |
---|
1464 | { |
---|
1465 | gtk_paint_box(style, window, state_type, shadow_type, area, widget, |
---|
1466 | detail, x, y, width, height); |
---|
1467 | if (gc1) |
---|
1468 | { |
---|
1469 | gdk_draw_rectangle(window, gc1, TRUE, x+1, y+1, width-2, height-2); |
---|
1470 | } |
---|
1471 | } |
---|
1472 | |
---|
1473 | if (area && gc1) |
---|
1474 | { |
---|
1475 | gdk_gc_set_clip_rectangle(gc1, NULL); |
---|
1476 | } |
---|
1477 | } |
---|
1478 | |
---|
1479 | |
---|
1480 | /* Thanks to Evan Lawrence */ |
---|
1481 | static void |
---|
1482 | draw_option(GtkStyle * style, |
---|
1483 | GdkWindow * window, |
---|
1484 | GtkStateType state_type, |
---|
1485 | GtkShadowType shadow_type, |
---|
1486 | GdkRectangle * area, |
---|
1487 | GtkWidget * widget, |
---|
1488 | const gchar *detail, |
---|
1489 | gint x, |
---|
1490 | gint y, |
---|
1491 | gint width, |
---|
1492 | gint height) |
---|
1493 | { |
---|
1494 | GdkGC *gc1; |
---|
1495 | GdkGC *gc2; |
---|
1496 | GdkGC *gc3; |
---|
1497 | |
---|
1498 | if (shadow_type == GTK_SHADOW_IN || |
---|
1499 | shadow_type == GTK_SHADOW_ETCHED_IN) |
---|
1500 | { |
---|
1501 | gc1 = style->dark_gc[state_type]; |
---|
1502 | gc2 = style->light_gc[state_type]; |
---|
1503 | gc3 = style->bg_gc[GTK_STATE_ACTIVE]; |
---|
1504 | } |
---|
1505 | else |
---|
1506 | { |
---|
1507 | gc1 = style->light_gc[state_type]; |
---|
1508 | gc2 = style->dark_gc[state_type]; |
---|
1509 | gc3 = style->bg_gc[state_type]; |
---|
1510 | } |
---|
1511 | |
---|
1512 | if (area) |
---|
1513 | { |
---|
1514 | gdk_gc_set_clip_rectangle(gc1, area); |
---|
1515 | gdk_gc_set_clip_rectangle(gc2, area); |
---|
1516 | gdk_gc_set_clip_rectangle(gc3, area); |
---|
1517 | } |
---|
1518 | |
---|
1519 | switch (shadow_type) |
---|
1520 | { |
---|
1521 | case GTK_SHADOW_ETCHED_IN: |
---|
1522 | gdk_draw_arc(window, gc2, FALSE, x+1, y+1, width, height, 0, 360 * 64); |
---|
1523 | gdk_draw_arc(window, gc1, FALSE, x, y, width, height, 0, 360 * 64); |
---|
1524 | break; |
---|
1525 | case GTK_SHADOW_ETCHED_OUT: |
---|
1526 | gdk_draw_arc(window, gc1, FALSE, x-1, y-1, width, height, 0, 360 * 64); |
---|
1527 | gdk_draw_arc(window, gc2, FALSE, x, y, width, height, 0, 360 * 64); |
---|
1528 | break; |
---|
1529 | default: |
---|
1530 | gdk_draw_arc(window, gc3, TRUE, x, y, width, height, 0, 360 * 64); |
---|
1531 | gdk_draw_arc(window, gc1, FALSE, x, y, width, height, 45 * 64, 225 * 64); |
---|
1532 | gdk_draw_arc(window, gc2, FALSE, x, y, width, height, 225 * 64, 180 * 64); |
---|
1533 | break; |
---|
1534 | } |
---|
1535 | |
---|
1536 | if (area) |
---|
1537 | { |
---|
1538 | gdk_gc_set_clip_rectangle(gc1, NULL); |
---|
1539 | gdk_gc_set_clip_rectangle(gc2, NULL); |
---|
1540 | gdk_gc_set_clip_rectangle(gc3, NULL); |
---|
1541 | } |
---|
1542 | } |
---|
1543 | |
---|
1544 | |
---|
1545 | static void |
---|
1546 | draw_tab(GtkStyle * style, |
---|
1547 | GdkWindow * window, |
---|
1548 | GtkStateType state_type, |
---|
1549 | GtkShadowType shadow_type, |
---|
1550 | GdkRectangle * area, |
---|
1551 | GtkWidget * widget, |
---|
1552 | const gchar *detail, |
---|
1553 | gint x, |
---|
1554 | gint y, |
---|
1555 | gint width, |
---|
1556 | gint height) |
---|
1557 | { |
---|
1558 | g_return_if_fail(style != NULL); |
---|
1559 | g_return_if_fail(window != NULL); |
---|
1560 | |
---|
1561 | #ifdef DEBUG |
---|
1562 | printf("draw_tab(%d,%d,%d,%d) (detail = '%s')\n", x, y, width, height, detail?detail:"<null>"); |
---|
1563 | #endif |
---|
1564 | gtk_paint_box(style, window, state_type, shadow_type, area, widget, detail, |
---|
1565 | x, y, width, height); |
---|
1566 | } |
---|
1567 | |
---|
1568 | |
---|
1569 | |
---|
1570 | static void |
---|
1571 | draw_shadow_gap(GtkStyle * style, |
---|
1572 | GdkWindow * window, |
---|
1573 | GtkStateType state_type, |
---|
1574 | GtkShadowType shadow_type, |
---|
1575 | GdkRectangle * area, |
---|
1576 | GtkWidget * widget, |
---|
1577 | const gchar *detail, |
---|
1578 | gint x, |
---|
1579 | gint y, |
---|
1580 | gint width, |
---|
1581 | gint height, |
---|
1582 | GtkPositionType gap_side, |
---|
1583 | gint gap_x, |
---|
1584 | gint gap_width) |
---|
1585 | { |
---|
1586 | GdkGC *gc1 = NULL; |
---|
1587 | GdkGC *gc2 = NULL; |
---|
1588 | |
---|
1589 | g_return_if_fail (window != NULL); |
---|
1590 | |
---|
1591 | sanitize_size (window, &width, &height); |
---|
1592 | shadow_type = get_shadow_type (style, detail, shadow_type); |
---|
1593 | |
---|
1594 | switch (shadow_type) { |
---|
1595 | case GTK_SHADOW_NONE: |
---|
1596 | return; |
---|
1597 | case GTK_SHADOW_IN: |
---|
1598 | gc1 = style->dark_gc[state_type]; |
---|
1599 | gc2 = style->light_gc[state_type]; |
---|
1600 | break; |
---|
1601 | case GTK_SHADOW_OUT: |
---|
1602 | gc1 = style->light_gc[state_type]; |
---|
1603 | gc2 = style->dark_gc[state_type]; |
---|
1604 | break; |
---|
1605 | case GTK_SHADOW_ETCHED_IN: |
---|
1606 | case GTK_SHADOW_ETCHED_OUT: |
---|
1607 | gc1 = style->dark_gc[state_type]; |
---|
1608 | gc2 = style->dark_gc[state_type]; |
---|
1609 | } |
---|
1610 | |
---|
1611 | if (area) { |
---|
1612 | gdk_gc_set_clip_rectangle (gc1, area); |
---|
1613 | gdk_gc_set_clip_rectangle (gc2, area); |
---|
1614 | } |
---|
1615 | |
---|
1616 | switch (gap_side) { |
---|
1617 | case GTK_POS_TOP: |
---|
1618 | if (gap_x > 0) { |
---|
1619 | gdk_draw_line (window, gc1, |
---|
1620 | x, y, |
---|
1621 | x + gap_x, y); |
---|
1622 | } |
---|
1623 | if ((width - (gap_x + gap_width)) > 0) { |
---|
1624 | gdk_draw_line (window, gc1, |
---|
1625 | x + gap_x + gap_width - 1, y, |
---|
1626 | x + width - 1, y); |
---|
1627 | } |
---|
1628 | gdk_draw_line (window, gc1, |
---|
1629 | x, y, |
---|
1630 | x, y + height - 1); |
---|
1631 | gdk_draw_line (window, gc2, |
---|
1632 | x + width - 1, y, |
---|
1633 | x + width - 1, y + height - 1); |
---|
1634 | gdk_draw_line (window, gc2, |
---|
1635 | x, y + height - 1, |
---|
1636 | x + width - 1, y + height - 1); |
---|
1637 | break; |
---|
1638 | case GTK_POS_BOTTOM: |
---|
1639 | gdk_draw_line (window, gc1, |
---|
1640 | x, y, |
---|
1641 | x + width - 1, y); |
---|
1642 | gdk_draw_line (window, gc1, |
---|
1643 | x, y, |
---|
1644 | x, y + height - 1); |
---|
1645 | gdk_draw_line (window, gc2, |
---|
1646 | x + width - 1, y, |
---|
1647 | x + width - 1, y + height - 1); |
---|
1648 | |
---|
1649 | if (gap_x > 0) { |
---|
1650 | gdk_draw_line (window, gc2, |
---|
1651 | x, y + height - 1, |
---|
1652 | x + gap_x, y + height - 1); |
---|
1653 | } |
---|
1654 | if ((width - (gap_x + gap_width)) > 0) { |
---|
1655 | gdk_draw_line (window, gc2, |
---|
1656 | x + gap_x + gap_width - 1, y + height - 1, |
---|
1657 | x + width - 1, y + height - 1); |
---|
1658 | } |
---|
1659 | |
---|
1660 | break; |
---|
1661 | case GTK_POS_LEFT: |
---|
1662 | gdk_draw_line (window, gc1, |
---|
1663 | x, y, |
---|
1664 | x + width - 1, y); |
---|
1665 | if (gap_x > 0) { |
---|
1666 | gdk_draw_line (window, gc1, |
---|
1667 | x, y, |
---|
1668 | x, y + gap_x); |
---|
1669 | } |
---|
1670 | if ((height - (gap_x + gap_width)) > 0) { |
---|
1671 | gdk_draw_line (window, gc1, |
---|
1672 | x, y + gap_x + gap_width - 1, |
---|
1673 | x, y + height - 1); |
---|
1674 | } |
---|
1675 | gdk_draw_line (window, gc2, |
---|
1676 | x + width - 1, y, |
---|
1677 | x + width - 1, y + height - 1); |
---|
1678 | gdk_draw_line (window, gc2, |
---|
1679 | x, y + height - 1, |
---|
1680 | x + width - 1, y + height - 1); |
---|
1681 | break; |
---|
1682 | case GTK_POS_RIGHT: |
---|
1683 | gdk_draw_line (window, gc1, |
---|
1684 | x, y, |
---|
1685 | x + width - 1, y); |
---|
1686 | gdk_draw_line (window, gc1, |
---|
1687 | x, y, |
---|
1688 | x, y + height - 1); |
---|
1689 | |
---|
1690 | |
---|
1691 | if (gap_x > 0) { |
---|
1692 | gdk_draw_line (window, gc2, |
---|
1693 | x + width - 1, y, |
---|
1694 | x + width - 1, y + gap_x); |
---|
1695 | } |
---|
1696 | if ((height - (gap_x + gap_width)) > 0) { |
---|
1697 | gdk_draw_line (window, gc2, |
---|
1698 | x + width - 1, y + gap_x + gap_width - 1, |
---|
1699 | x + width - 1, y + height - 1); |
---|
1700 | } |
---|
1701 | gdk_draw_line (window, gc2, |
---|
1702 | x, y + height - 1, |
---|
1703 | x + width - 1, y + height - 1); |
---|
1704 | |
---|
1705 | } |
---|
1706 | |
---|
1707 | if (area) { |
---|
1708 | gdk_gc_set_clip_rectangle (gc1, NULL); |
---|
1709 | gdk_gc_set_clip_rectangle (gc2, NULL); |
---|
1710 | } |
---|
1711 | } |
---|
1712 | |
---|
1713 | |
---|
1714 | static void |
---|
1715 | draw_box_gap(GtkStyle * style, |
---|
1716 | GdkWindow * window, |
---|
1717 | GtkStateType state_type, |
---|
1718 | GtkShadowType shadow_type, |
---|
1719 | GdkRectangle * area, |
---|
1720 | GtkWidget * widget, |
---|
1721 | const gchar *detail, |
---|
1722 | gint x, |
---|
1723 | gint y, |
---|
1724 | gint width, |
---|
1725 | gint height, |
---|
1726 | GtkPositionType gap_side, |
---|
1727 | gint gap_x, |
---|
1728 | gint gap_width) |
---|
1729 | { |
---|
1730 | sanitize_size (window, &width, &height); |
---|
1731 | |
---|
1732 | gtk_style_apply_default_background(style, window, |
---|
1733 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1734 | state_type, area, |
---|
1735 | x, y, width, height); |
---|
1736 | draw_shadow_gap (style, window, state_type, shadow_type, |
---|
1737 | area, widget, detail, x, y, width, height, |
---|
1738 | gap_side, gap_x, gap_width); |
---|
1739 | } |
---|
1740 | |
---|
1741 | |
---|
1742 | static void |
---|
1743 | draw_extension(GtkStyle * style, |
---|
1744 | GdkWindow * window, |
---|
1745 | GtkStateType state_type, |
---|
1746 | GtkShadowType shadow_type, |
---|
1747 | GdkRectangle * area, |
---|
1748 | GtkWidget * widget, |
---|
1749 | const gchar *detail, |
---|
1750 | gint x, |
---|
1751 | gint y, |
---|
1752 | gint width, |
---|
1753 | gint height, |
---|
1754 | GtkPositionType gap_side) |
---|
1755 | { |
---|
1756 | GdkRectangle rect; |
---|
1757 | |
---|
1758 | g_return_if_fail(style != NULL); |
---|
1759 | g_return_if_fail(window != NULL); |
---|
1760 | |
---|
1761 | sanitize_size (window, &width, &height); |
---|
1762 | |
---|
1763 | gtk_paint_box(style, window, state_type, shadow_type, area, widget, detail, |
---|
1764 | x, y, width, height); |
---|
1765 | |
---|
1766 | switch (gap_side) |
---|
1767 | { |
---|
1768 | case GTK_POS_TOP: |
---|
1769 | rect.x = x + style->xthickness; |
---|
1770 | rect.y = y; |
---|
1771 | rect.width = width - style->xthickness * 2; |
---|
1772 | rect.height = style->ythickness; |
---|
1773 | break; |
---|
1774 | case GTK_POS_BOTTOM: |
---|
1775 | rect.x = x + style->xthickness; |
---|
1776 | rect.y = y + height - style->ythickness; |
---|
1777 | rect.width = width - style->xthickness * 2; |
---|
1778 | rect.height = style->ythickness; |
---|
1779 | break; |
---|
1780 | case GTK_POS_LEFT: |
---|
1781 | rect.x = x; |
---|
1782 | rect.y = y + style->ythickness; |
---|
1783 | rect.width = style->xthickness; |
---|
1784 | rect.height = height - style->ythickness * 2; |
---|
1785 | break; |
---|
1786 | case GTK_POS_RIGHT: |
---|
1787 | rect.x = x + width - style->xthickness; |
---|
1788 | rect.y = y + style->ythickness; |
---|
1789 | rect.width = style->xthickness; |
---|
1790 | rect.height = height - style->ythickness * 2; |
---|
1791 | break; |
---|
1792 | } |
---|
1793 | |
---|
1794 | gtk_style_apply_default_background(style, window, |
---|
1795 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1796 | state_type, area, rect.x, rect.y, rect.width, rect.height); |
---|
1797 | } |
---|
1798 | |
---|
1799 | #if 0 |
---|
1800 | static void |
---|
1801 | draw_focus(GtkStyle * style, |
---|
1802 | GdkWindow * window, |
---|
1803 | GdkRectangle * area, |
---|
1804 | GtkWidget * widget, |
---|
1805 | const gchar *detail, |
---|
1806 | gint x, |
---|
1807 | gint y, |
---|
1808 | gint width, |
---|
1809 | gint height) |
---|
1810 | { |
---|
1811 | g_return_if_fail(style != NULL); |
---|
1812 | g_return_if_fail(window != NULL); |
---|
1813 | |
---|
1814 | if ((width == -1) && (height == -1)) |
---|
1815 | { |
---|
1816 | gdk_window_get_size(window, &width, &height); |
---|
1817 | width--; |
---|
1818 | height--; |
---|
1819 | } |
---|
1820 | else if (width == -1) |
---|
1821 | { |
---|
1822 | gdk_window_get_size(window, &width, NULL); |
---|
1823 | width--; |
---|
1824 | } |
---|
1825 | else if (height == -1) |
---|
1826 | { |
---|
1827 | gdk_window_get_size(window, NULL, &height); |
---|
1828 | height--; |
---|
1829 | } |
---|
1830 | if (area) |
---|
1831 | { |
---|
1832 | gdk_gc_set_clip_rectangle(style->black_gc, area); |
---|
1833 | } |
---|
1834 | gdk_draw_rectangle(window, |
---|
1835 | style->black_gc, FALSE, |
---|
1836 | x, y, width, height); |
---|
1837 | if (area) |
---|
1838 | { |
---|
1839 | gdk_gc_set_clip_rectangle(style->black_gc, NULL); |
---|
1840 | } |
---|
1841 | } |
---|
1842 | #endif /* 0 */ |
---|
1843 | |
---|
1844 | static void |
---|
1845 | draw_slider(GtkStyle * style, |
---|
1846 | GdkWindow * window, |
---|
1847 | GtkStateType state_type, |
---|
1848 | GtkShadowType shadow_type, |
---|
1849 | GdkRectangle * area, |
---|
1850 | GtkWidget * widget, |
---|
1851 | const gchar *detail, |
---|
1852 | gint x, |
---|
1853 | gint y, |
---|
1854 | gint width, |
---|
1855 | gint height, |
---|
1856 | GtkOrientation orientation) |
---|
1857 | { |
---|
1858 | GdkPoint pointsh[7]; |
---|
1859 | GdkRegion *clipreg; |
---|
1860 | GdkRectangle rec; |
---|
1861 | int i, rect = FALSE, midlines = MARKS_SLASH; |
---|
1862 | int modx, mody; |
---|
1863 | |
---|
1864 | |
---|
1865 | g_return_if_fail(style != NULL); |
---|
1866 | g_return_if_fail(window != NULL); |
---|
1867 | |
---|
1868 | #ifdef DEBUG |
---|
1869 | printf("draw_slider(%s, %d, %d, %d)\n", detail, x, y, orientation); |
---|
1870 | #endif |
---|
1871 | |
---|
1872 | #ifdef DEBUG |
---|
1873 | printf("Slider... x,y=%d,%d width = %d, height = %d (%d)\n",x,y,width,height, state_type); |
---|
1874 | #endif |
---|
1875 | midlines = THINICE_RC_STYLE (style->rc_style)->mark_type1; |
---|
1876 | #ifdef DEBUG |
---|
1877 | printf("Midlines = %d\n", midlines); |
---|
1878 | #endif |
---|
1879 | |
---|
1880 | if (THINICE_RC_STYLE (style->rc_style)->scrollbar_type == SCROLL_RECT) |
---|
1881 | { |
---|
1882 | rect = TRUE; |
---|
1883 | } |
---|
1884 | |
---|
1885 | /* too small, use rect & no midlines */ |
---|
1886 | if ((width <= SMALLEST_HANDLE) && (height <= SMALLEST_HANDLE)) |
---|
1887 | { |
---|
1888 | midlines = MARKS_NOTHING; |
---|
1889 | rect = TRUE; |
---|
1890 | } |
---|
1891 | |
---|
1892 | if (rect) |
---|
1893 | { |
---|
1894 | pointsh[0].x = x; pointsh[0].y = y; |
---|
1895 | pointsh[1].x = x + width - 1; pointsh[1].y = y; |
---|
1896 | pointsh[2].x = x + width - 1; pointsh[2].y = y + height - 1; |
---|
1897 | pointsh[3].x = x; pointsh[3].y = y + height - 1; |
---|
1898 | pointsh[4].x = x; pointsh[4].y = y; |
---|
1899 | clipreg = gdk_region_polygon(pointsh, 5, GDK_WINDING_RULE); |
---|
1900 | gdk_region_shrink(clipreg, -1, -1); |
---|
1901 | } |
---|
1902 | else |
---|
1903 | { |
---|
1904 | int chopoff; |
---|
1905 | |
---|
1906 | if (orientation == GTK_ORIENTATION_HORIZONTAL) { |
---|
1907 | chopoff = max(0, min(6, width-SMALLEST_HANDLE)); |
---|
1908 | } else { |
---|
1909 | chopoff = max(0, min(6, height-SMALLEST_HANDLE)); |
---|
1910 | } |
---|
1911 | |
---|
1912 | pointsh[0].x = x; pointsh[0].y = y+height-1; |
---|
1913 | pointsh[1].x = x; pointsh[1].y = y+chopoff; |
---|
1914 | pointsh[2].x = x+chopoff; pointsh[2].y = y; |
---|
1915 | pointsh[3].x = x+width-1; pointsh[3].y = y; |
---|
1916 | pointsh[4].x = x+width-1; pointsh[4].y = y+height-1-chopoff; |
---|
1917 | pointsh[5].x = x+width-1-chopoff; pointsh[5].y = y+height-1; |
---|
1918 | pointsh[6].x = x; pointsh[6].y = y+height-1; |
---|
1919 | clipreg = gdk_region_polygon(pointsh, 7, GDK_WINDING_RULE); |
---|
1920 | gdk_region_shrink(clipreg, -1, -1); |
---|
1921 | } |
---|
1922 | |
---|
1923 | gdk_gc_set_clip_region(style->bg_gc[state_type], clipreg); |
---|
1924 | gdk_gc_set_clip_region(style->light_gc[state_type], clipreg); |
---|
1925 | gdk_gc_set_clip_region(style->dark_gc[state_type], clipreg); |
---|
1926 | |
---|
1927 | if (!rect) |
---|
1928 | { |
---|
1929 | rec.x = x; |
---|
1930 | rec.y = y; |
---|
1931 | rec.width = width; |
---|
1932 | rec.height = height; |
---|
1933 | gdk_gc_set_clip_rectangle(style->bg_gc[GTK_STATE_ACTIVE], &rec); |
---|
1934 | } |
---|
1935 | |
---|
1936 | if (rect) |
---|
1937 | { |
---|
1938 | /* Just a plain rectangle with shadow ... */ |
---|
1939 | if ((!style->bg_pixmap[state_type]) || GDK_IS_PIXMAP (window)) |
---|
1940 | { |
---|
1941 | gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, |
---|
1942 | x, y, width, height); |
---|
1943 | } |
---|
1944 | else |
---|
1945 | { |
---|
1946 | gtk_style_apply_default_background(style, window, |
---|
1947 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
1948 | state_type, area, |
---|
1949 | x, y, width, height); |
---|
1950 | } |
---|
1951 | gtk_paint_shadow(style, window, state_type, shadow_type, area, |
---|
1952 | widget, detail, x, y, width, height); |
---|
1953 | } |
---|
1954 | else |
---|
1955 | { |
---|
1956 | /* Fill the polygon */ |
---|
1957 | gdk_draw_polygon(window, style->bg_gc[state_type], |
---|
1958 | TRUE, pointsh, 6); |
---|
1959 | /* Draw the light border */ |
---|
1960 | for (i=0;i<3;i++) |
---|
1961 | { |
---|
1962 | gdk_draw_line(window, style->light_gc[state_type], |
---|
1963 | pointsh[i].x,pointsh[i].y, |
---|
1964 | pointsh[i+1].x,pointsh[i+1].y); |
---|
1965 | } |
---|
1966 | /* Draw the dark border */ |
---|
1967 | for (i=3;i<6;i++) |
---|
1968 | { |
---|
1969 | gdk_draw_line(window, style->dark_gc[state_type], |
---|
1970 | pointsh[i].x,pointsh[i].y, |
---|
1971 | pointsh[i+1].x,pointsh[i+1].y); |
---|
1972 | } |
---|
1973 | |
---|
1974 | } |
---|
1975 | if (orientation == GTK_ORIENTATION_HORIZONTAL) |
---|
1976 | { modx = 4; mody = 0; } |
---|
1977 | else |
---|
1978 | { modx = 0; mody = 4; } |
---|
1979 | switch (midlines) |
---|
1980 | { |
---|
1981 | case MARKS_NOTHING: |
---|
1982 | break; |
---|
1983 | case MARKS_INVSLASH: /* Inverse //:es */ |
---|
1984 | thinice_slash_two(window, |
---|
1985 | style->dark_gc[state_type], |
---|
1986 | style->light_gc[state_type], |
---|
1987 | x, y, width, height); |
---|
1988 | break; |
---|
1989 | case MARKS_DOT: |
---|
1990 | thinice_dot(window, |
---|
1991 | style->light_gc[state_type], |
---|
1992 | style->dark_gc[state_type], |
---|
1993 | x + width / 2 - modx, |
---|
1994 | y + height / 2 - mody); |
---|
1995 | thinice_dot(window, |
---|
1996 | style->light_gc[state_type], |
---|
1997 | style->dark_gc[state_type], |
---|
1998 | x + width / 2, |
---|
1999 | y + height / 2); |
---|
2000 | thinice_dot(window, |
---|
2001 | style->light_gc[state_type], |
---|
2002 | style->dark_gc[state_type], |
---|
2003 | x + width / 2 + modx, |
---|
2004 | y + height / 2 + mody); |
---|
2005 | break; |
---|
2006 | case MARKS_INVDOT: /* Inverted */ |
---|
2007 | thinice_dot(window, |
---|
2008 | style->dark_gc[state_type], |
---|
2009 | style->light_gc[state_type], |
---|
2010 | x + width / 2 - modx, |
---|
2011 | y + height / 2 - mody); |
---|
2012 | thinice_dot(window, |
---|
2013 | style->dark_gc[state_type], |
---|
2014 | style->light_gc[state_type], |
---|
2015 | x + width / 2, |
---|
2016 | y + height / 2); |
---|
2017 | thinice_dot(window, |
---|
2018 | style->dark_gc[state_type], |
---|
2019 | style->light_gc[state_type], |
---|
2020 | x + width / 2 + modx, |
---|
2021 | y + height / 2 + mody); |
---|
2022 | break; |
---|
2023 | case MARKS_SLASH: |
---|
2024 | default: |
---|
2025 | thinice_slash_two(window, |
---|
2026 | style->light_gc[state_type], |
---|
2027 | style->dark_gc[state_type], |
---|
2028 | x, y, width, height); |
---|
2029 | break; |
---|
2030 | } |
---|
2031 | /* |
---|
2032 | if (area) |
---|
2033 | { |
---|
2034 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
2035 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL); |
---|
2036 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL); |
---|
2037 | } |
---|
2038 | else |
---|
2039 | { |
---|
2040 | */ |
---|
2041 | gdk_gc_set_clip_region(style->bg_gc[state_type], NULL); |
---|
2042 | gdk_gc_set_clip_region(style->light_gc[state_type], NULL); |
---|
2043 | gdk_gc_set_clip_region(style->dark_gc[state_type], NULL); |
---|
2044 | /* |
---|
2045 | } |
---|
2046 | */ |
---|
2047 | if (!rect) |
---|
2048 | { |
---|
2049 | gdk_gc_set_clip_rectangle(style->bg_gc[GTK_STATE_ACTIVE], NULL); |
---|
2050 | } |
---|
2051 | } |
---|
2052 | |
---|
2053 | static void |
---|
2054 | draw_handle(GtkStyle * style, |
---|
2055 | GdkWindow * window, |
---|
2056 | GtkStateType state_type, |
---|
2057 | GtkShadowType shadow_type, |
---|
2058 | GdkRectangle * area, |
---|
2059 | GtkWidget * widget, |
---|
2060 | const gchar *detail, |
---|
2061 | gint x, |
---|
2062 | gint y, |
---|
2063 | gint width, |
---|
2064 | gint height, |
---|
2065 | GtkOrientation orientation) |
---|
2066 | { |
---|
2067 | GdkGC *light_gc, *dark_gc; |
---|
2068 | GdkRectangle dest; |
---|
2069 | // ThemeStyleData *data = NULL;//style->engine_data; |
---|
2070 | gint modx, mody; |
---|
2071 | |
---|
2072 | g_return_if_fail(style != NULL); |
---|
2073 | g_return_if_fail(window != NULL); |
---|
2074 | |
---|
2075 | #if DEBUG |
---|
2076 | printf("draw_handle(state=%d, shadow=%d, detail=%s, [%d,%d]@[%d,%d]\n", |
---|
2077 | state_type, shadow_type, detail?detail:"nul",width,height,x,y); |
---|
2078 | #endif |
---|
2079 | sanitize_size(window, &width, &height); |
---|
2080 | |
---|
2081 | if (DETAIL("paned")) |
---|
2082 | { |
---|
2083 | int i, w, h; |
---|
2084 | int start_i, end_i; |
---|
2085 | |
---|
2086 | dest.x = x; |
---|
2087 | dest.y = y; |
---|
2088 | dest.width = width; |
---|
2089 | dest.height = height; |
---|
2090 | |
---|
2091 | light_gc = style->light_gc[state_type]; |
---|
2092 | dark_gc = style->dark_gc[state_type]; |
---|
2093 | if (orientation == GTK_ORIENTATION_HORIZONTAL) |
---|
2094 | w = width; |
---|
2095 | else |
---|
2096 | w = height; |
---|
2097 | switch (THINICE_RC_STYLE (style->rc_style)->paned_dots) { |
---|
2098 | default: |
---|
2099 | case PANED_DOTSFULL: |
---|
2100 | start_i = 5; |
---|
2101 | end_i = w - 5; |
---|
2102 | break; |
---|
2103 | case PANED_DOTSSOME: |
---|
2104 | start_i = w/2 - 16; |
---|
2105 | end_i = w/2 + 16; |
---|
2106 | break; |
---|
2107 | case PANED_DOTSNONE: |
---|
2108 | start_i = w; |
---|
2109 | end_i = 0; |
---|
2110 | break; |
---|
2111 | } |
---|
2112 | gdk_gc_set_clip_rectangle(light_gc, &dest); |
---|
2113 | gdk_gc_set_clip_rectangle(dark_gc, &dest); |
---|
2114 | |
---|
2115 | if (orientation == GTK_ORIENTATION_HORIZONTAL) |
---|
2116 | { |
---|
2117 | for (i=x + start_i; i <= x + end_i; i+=8) |
---|
2118 | { |
---|
2119 | thinice_dot(window, light_gc, dark_gc, i, y + height / 2); |
---|
2120 | } |
---|
2121 | } |
---|
2122 | else |
---|
2123 | { |
---|
2124 | for (i=y + start_i; i <= y + end_i; i+=8) |
---|
2125 | { |
---|
2126 | thinice_dot(window, light_gc, dark_gc, x + width / 2, i); |
---|
2127 | } |
---|
2128 | } |
---|
2129 | gdk_gc_set_clip_rectangle(light_gc, NULL); |
---|
2130 | gdk_gc_set_clip_rectangle(dark_gc, NULL); |
---|
2131 | return; |
---|
2132 | } |
---|
2133 | gtk_paint_box(style, window, state_type, shadow_type, area, widget, |
---|
2134 | detail, x, y, width, height); |
---|
2135 | gdk_draw_line(window, style->light_gc[state_type], |
---|
2136 | x + width, y, x + width, y + height - 2); |
---|
2137 | |
---|
2138 | /* Draw something in the box if so wanted */ |
---|
2139 | if (THINICE_RC_STYLE (style->rc_style)->mark_type1 != MARKS_NOTHING) |
---|
2140 | { |
---|
2141 | light_gc = style->light_gc[state_type]; |
---|
2142 | dark_gc = style->dark_gc[state_type]; |
---|
2143 | |
---|
2144 | orientation = GTK_ORIENTATION_HORIZONTAL; |
---|
2145 | if (height > width) |
---|
2146 | orientation = GTK_ORIENTATION_VERTICAL; |
---|
2147 | |
---|
2148 | dest.x = x + style->xthickness; |
---|
2149 | dest.y = y + style->ythickness; |
---|
2150 | dest.width = width - (style->xthickness * 2); |
---|
2151 | dest.height = height - (style->ythickness * 2); |
---|
2152 | |
---|
2153 | if (orientation == GTK_ORIENTATION_HORIZONTAL) |
---|
2154 | { modx = 4; mody = 0; } |
---|
2155 | else |
---|
2156 | { modx = 0; mody = 4; } |
---|
2157 | |
---|
2158 | gdk_gc_set_clip_rectangle(light_gc, &dest); |
---|
2159 | gdk_gc_set_clip_rectangle(dark_gc, &dest); |
---|
2160 | |
---|
2161 | switch (THINICE_RC_STYLE (style->rc_style)->mark_type1) |
---|
2162 | { |
---|
2163 | case MARKS_INVSLASH: /* Inverse //:es */ |
---|
2164 | thinice_slash_two(window, dark_gc, light_gc, |
---|
2165 | x, y, width, height); |
---|
2166 | break; |
---|
2167 | case MARKS_DOT: /* Dots */ |
---|
2168 | thinice_dot(window, light_gc, dark_gc, |
---|
2169 | x + width / 2 - modx, |
---|
2170 | y + height / 2 - mody); |
---|
2171 | thinice_dot(window, light_gc, dark_gc, |
---|
2172 | x + width / 2, |
---|
2173 | y + height / 2); |
---|
2174 | thinice_dot(window, light_gc, dark_gc, |
---|
2175 | x + width / 2 + modx, |
---|
2176 | y + height / 2 + mody); |
---|
2177 | break; |
---|
2178 | case MARKS_INVDOT: /* Inverted dots */ |
---|
2179 | thinice_dot(window, dark_gc, light_gc, |
---|
2180 | x + width / 2 - modx, |
---|
2181 | y + height / 2 - mody); |
---|
2182 | thinice_dot(window, dark_gc, light_gc, |
---|
2183 | x + width / 2, |
---|
2184 | y + height / 2); |
---|
2185 | thinice_dot(window, dark_gc, light_gc, |
---|
2186 | x + width / 2 + modx, |
---|
2187 | y + height / 2 + mody); |
---|
2188 | break; |
---|
2189 | case MARKS_SLASH: |
---|
2190 | default: |
---|
2191 | thinice_slash_two(window, light_gc, dark_gc, |
---|
2192 | x, y, width, height); |
---|
2193 | break; |
---|
2194 | } |
---|
2195 | |
---|
2196 | gdk_gc_set_clip_rectangle(light_gc, NULL); |
---|
2197 | gdk_gc_set_clip_rectangle(dark_gc, NULL); |
---|
2198 | } |
---|
2199 | |
---|
2200 | } |
---|
2201 | |
---|
2202 | static void |
---|
2203 | thinice_slash_two(GdkWindow *window, |
---|
2204 | GdkGC *gc1, |
---|
2205 | GdkGC *gc2, |
---|
2206 | gint x, |
---|
2207 | gint y, |
---|
2208 | gint width, |
---|
2209 | gint height) |
---|
2210 | { |
---|
2211 | gint centerx, centery, thick; |
---|
2212 | gint ax1=0,ax2=0,ay1=0,ay2=0; |
---|
2213 | |
---|
2214 | centerx = (width - 1)/2 + x; |
---|
2215 | centery = (height - 1)/2 + y; |
---|
2216 | if (width > height) |
---|
2217 | { |
---|
2218 | ax1 = -2; ax2 = 1; |
---|
2219 | } |
---|
2220 | else |
---|
2221 | { |
---|
2222 | ay1 = -2; ay2 = 1; |
---|
2223 | } |
---|
2224 | |
---|
2225 | thick = ((width < height?width-1:height-1) >> 1) - 2; |
---|
2226 | gdk_draw_line(window, gc2, |
---|
2227 | centerx - thick + ax1, centery + thick + ay1, |
---|
2228 | centerx + thick + ax1, centery - thick + ay1); |
---|
2229 | gdk_draw_line(window, gc1, |
---|
2230 | centerx - thick + ax1 + ax2, centery + thick + ay1 + ay2, |
---|
2231 | centerx + thick + ax1 + ax2, centery - thick + ay1 + ay2); |
---|
2232 | if (width > height) |
---|
2233 | { |
---|
2234 | ax1 = 2; /* ax2 = 1; */ |
---|
2235 | } |
---|
2236 | else |
---|
2237 | { |
---|
2238 | ay1 = 2; /* ay2 = 1; */ |
---|
2239 | } |
---|
2240 | gdk_draw_line(window, gc2, |
---|
2241 | centerx - thick + ax1, centery + thick + ay1, |
---|
2242 | centerx + thick + ax1, centery - thick + ay1); |
---|
2243 | gdk_draw_line(window, gc1, |
---|
2244 | centerx - thick + ax1 + ax2, centery + thick + ay1 + ay2, |
---|
2245 | centerx + thick + ax1 + ax2, centery - thick + ay1 + ay2); |
---|
2246 | } |
---|
2247 | |
---|
2248 | |
---|
2249 | static void |
---|
2250 | thinice_slash_one(GdkWindow *window, |
---|
2251 | GdkGC *gc1, |
---|
2252 | GdkGC *gc2, |
---|
2253 | gint x, |
---|
2254 | gint y, |
---|
2255 | gint width, |
---|
2256 | gint height) |
---|
2257 | { |
---|
2258 | gint centerx, centery, thick; |
---|
2259 | |
---|
2260 | centerx = width/2 + x; |
---|
2261 | centery = height/2 + y; |
---|
2262 | |
---|
2263 | thick = ((width < height?width:height) >> 1); |
---|
2264 | gdk_draw_line(window, gc2, |
---|
2265 | centerx - thick, centery + thick, |
---|
2266 | centerx + thick, centery - thick); |
---|
2267 | gdk_draw_line(window, gc1, |
---|
2268 | centerx - thick, centery + thick - 1, |
---|
2269 | centerx + thick - 1, centery - thick); |
---|
2270 | } |
---|
2271 | |
---|
2272 | static void |
---|
2273 | thinice_dot(GdkWindow *window, |
---|
2274 | GdkGC *gc1, |
---|
2275 | GdkGC *gc2, |
---|
2276 | gint x, |
---|
2277 | gint y) |
---|
2278 | { |
---|
2279 | GdkPoint points[3]; |
---|
2280 | |
---|
2281 | points[0].x = x-1; points[0].y = y; |
---|
2282 | points[1].x = x-1; points[1].y = y-1; |
---|
2283 | points[2].x = x; points[2].y = y-1; |
---|
2284 | |
---|
2285 | gdk_draw_points(window, gc2, points, 3); |
---|
2286 | |
---|
2287 | points[0].x = x+1; points[0].y = y; |
---|
2288 | points[1].x = x+1; points[1].y = y+1; |
---|
2289 | points[2].x = x; points[2].y = y+1; |
---|
2290 | |
---|
2291 | gdk_draw_points(window, gc1, points, 3); |
---|
2292 | } |
---|
2293 | |
---|
2294 | static void |
---|
2295 | thinice_tab(GtkStyle * style, |
---|
2296 | GdkWindow * window, |
---|
2297 | GtkStateType state_type, |
---|
2298 | GtkShadowType shadow_type, |
---|
2299 | GdkRectangle * area, |
---|
2300 | GtkWidget * widget, |
---|
2301 | const gchar *detail, |
---|
2302 | gint x, |
---|
2303 | gint y, |
---|
2304 | gint width, |
---|
2305 | gint height) |
---|
2306 | { |
---|
2307 | GtkNotebook *notebook; |
---|
2308 | GdkGC *lightgc, *darkgc; |
---|
2309 | int orientation; |
---|
2310 | |
---|
2311 | |
---|
2312 | notebook = GTK_NOTEBOOK(widget); |
---|
2313 | orientation = notebook->tab_pos; |
---|
2314 | |
---|
2315 | lightgc = style->light_gc[state_type]; |
---|
2316 | darkgc = style->dark_gc[state_type]; |
---|
2317 | |
---|
2318 | if ((!style->bg_pixmap[state_type]) || GDK_IS_PIXMAP(window)) |
---|
2319 | { |
---|
2320 | if (area) |
---|
2321 | { |
---|
2322 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area); |
---|
2323 | } |
---|
2324 | gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, |
---|
2325 | x, y, width, height); |
---|
2326 | if (area) |
---|
2327 | { |
---|
2328 | gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL); |
---|
2329 | } |
---|
2330 | } |
---|
2331 | else |
---|
2332 | { |
---|
2333 | gtk_style_apply_default_background(style, window, |
---|
2334 | widget && !GTK_WIDGET_NO_WINDOW(widget), |
---|
2335 | state_type, area, x, y, width, height); |
---|
2336 | } |
---|
2337 | if (area) |
---|
2338 | { |
---|
2339 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], area); |
---|
2340 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], area); |
---|
2341 | } |
---|
2342 | switch(orientation) |
---|
2343 | { |
---|
2344 | case GTK_POS_TOP: |
---|
2345 | gdk_draw_line(window, lightgc, |
---|
2346 | x, y + height - 1, x, y); |
---|
2347 | gdk_draw_line(window, lightgc, |
---|
2348 | x, y, x + width - 1, y); |
---|
2349 | gdk_draw_line(window, darkgc, |
---|
2350 | x + width - 1, y, x + width - 1, y + height - 1); |
---|
2351 | break; |
---|
2352 | case GTK_POS_BOTTOM: |
---|
2353 | gdk_draw_line(window, lightgc, |
---|
2354 | x, y, x, y + height - 1); |
---|
2355 | gdk_draw_line(window, darkgc, |
---|
2356 | x, y + height - 1, x + width - 1, y + height - 1); |
---|
2357 | gdk_draw_line(window, darkgc, |
---|
2358 | x + width - 1, y + height - 1, x + width - 1, y); |
---|
2359 | break; |
---|
2360 | case GTK_POS_LEFT: |
---|
2361 | gdk_draw_line(window, lightgc, |
---|
2362 | x, y + height - 1, x, y); |
---|
2363 | gdk_draw_line(window, lightgc, |
---|
2364 | x, y, x + width - 1, y); |
---|
2365 | gdk_draw_line(window, darkgc, |
---|
2366 | x, y + height - 1, x + width - 1, y + height - 1); |
---|
2367 | break; |
---|
2368 | case GTK_POS_RIGHT: |
---|
2369 | gdk_draw_line(window, lightgc, |
---|
2370 | x, y, x + width - 1, y); |
---|
2371 | gdk_draw_line(window, darkgc, |
---|
2372 | x + width - 1, y, x + width - 1, y + height - 1); |
---|
2373 | gdk_draw_line(window, darkgc, |
---|
2374 | x, y + height - 1, x + width - 1, y + height - 1); |
---|
2375 | break; |
---|
2376 | } |
---|
2377 | if (area) |
---|
2378 | { |
---|
2379 | gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL); |
---|
2380 | gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL); |
---|
2381 | } |
---|
2382 | /*gtk_paint_shadow(style, window, state_type, shadow_type, area, widget, |
---|
2383 | detail, x, y, width, height); |
---|
2384 | */ |
---|
2385 | } |
---|
2386 | |
---|
2387 | GType thinice_type_style = 0; |
---|
2388 | |
---|
2389 | void |
---|
2390 | thinice_style_register_type (GTypeModule *module) |
---|
2391 | { |
---|
2392 | static const GTypeInfo object_info = |
---|
2393 | { |
---|
2394 | sizeof (ThiniceStyleClass), |
---|
2395 | (GBaseInitFunc) NULL, |
---|
2396 | (GBaseFinalizeFunc) NULL, |
---|
2397 | (GClassInitFunc) thinice_style_class_init, |
---|
2398 | NULL, /* class_finalize */ |
---|
2399 | NULL, /* class_data */ |
---|
2400 | sizeof (ThiniceStyle), |
---|
2401 | 0, /* n_preallocs */ |
---|
2402 | (GInstanceInitFunc) thinice_style_init, |
---|
2403 | }; |
---|
2404 | |
---|
2405 | thinice_type_style = g_type_module_register_type (module, |
---|
2406 | GTK_TYPE_STYLE, |
---|
2407 | "ThiniceStyle", |
---|
2408 | &object_info, 0); |
---|
2409 | } |
---|
2410 | |
---|
2411 | static void |
---|
2412 | thinice_style_init (ThiniceStyle *style) |
---|
2413 | { |
---|
2414 | } |
---|
2415 | |
---|
2416 | static void |
---|
2417 | thinice_style_class_init (ThiniceStyleClass *klass) |
---|
2418 | { |
---|
2419 | GtkStyleClass *style_class = GTK_STYLE_CLASS (klass); |
---|
2420 | |
---|
2421 | parent_class = g_type_class_peek_parent (klass); |
---|
2422 | |
---|
2423 | #if 0 |
---|
2424 | #endif |
---|
2425 | style_class->draw_hline = draw_hline; |
---|
2426 | style_class->draw_vline = draw_vline; |
---|
2427 | style_class->draw_shadow = draw_shadow; |
---|
2428 | style_class->draw_polygon = draw_polygon; |
---|
2429 | style_class->draw_arrow = draw_arrow; |
---|
2430 | style_class->draw_diamond = draw_diamond; |
---|
2431 | /*style_class->draw_string = draw_string;*/ |
---|
2432 | style_class->draw_box = draw_box; |
---|
2433 | /* style_class->draw_flat_box = draw_flat_box; */ |
---|
2434 | style_class->draw_check = draw_check; |
---|
2435 | style_class->draw_option = draw_option; |
---|
2436 | style_class->draw_tab = draw_tab; |
---|
2437 | style_class->draw_shadow_gap = draw_shadow_gap; |
---|
2438 | |
---|
2439 | /* box around notebooks */ |
---|
2440 | style_class->draw_box_gap = draw_box_gap; |
---|
2441 | /* the tab */ |
---|
2442 | style_class->draw_extension = draw_extension; |
---|
2443 | |
---|
2444 | /*style_class->draw_focus = draw_focus;*/ |
---|
2445 | style_class->draw_slider = draw_slider; |
---|
2446 | style_class->draw_handle = draw_handle; |
---|
2447 | } |
---|
2448 | |
---|
2449 | |
---|
2450 | /* |
---|
2451 | FIXME: file/font selector background OK |
---|
2452 | FIXME: radioknappar varierar storlek rätt bra.. OK |
---|
2453 | FIXME: scrollbars OK |
---|
2454 | FIXME: inconsistent-radioknappar OK |
---|
2455 | FIXME: paned-pluttarna OK |
---|
2456 | FIXME: spinbuttons, vid max OK |
---|
2457 | |
---|
2458 | FIXME: Blå triangeln vid RTL, WONTFIX? |
---|
2459 | */ |
---|
2460 | |
---|