Bug Summary

File:ctk/ctkstyle.c
Warning:line 4612, column 16
Out of bound memory access (accessed memory precedes memory block)

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ctkstyle.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.25.5" -D CTK_BINARY_VERSION="3.0.0" -D CTK_COMPILATION -D CTK_PRINT_BACKEND_ENABLE_UNSUPPORTED -D CTK_LIBDIR="/usr/lib" -D CTK_LOCALEDIR="/usr/share/locale" -D CTK_DATADIR="/usr/share" -D CTK_DATA_PREFIX="/usr" -D CTK_SYSCONFDIR="/usr/etc" -D CTK_HOST="x86_64-pc-linux-gnu" -D CTK_PRINT_BACKENDS="file,cups" -D X11_DATA_PREFIX="/usr" -D ISO_CODES_PREFIX="" -I .. -I ../ctk -I .. -I ../cdk -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/ctk -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-170037-43636-1 -x c ctkstyle.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the CTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * CTK+ at ftp://ftp.ctk.org/pub/ctk/.
23 */
24
25#include "config.h"
26
27#include <math.h>
28#include <stdlib.h>
29#include <string.h>
30#include <gobject/gvaluecollector.h>
31#include "ctkmarshalers.h"
32#include "ctkpango.h"
33#include "ctkrc.h"
34#include "ctkspinbutton.h"
35#include "ctkstyle.h"
36#include "ctkstylecontextprivate.h"
37#include "ctkwidget.h"
38#include "ctkwidgetprivate.h"
39#include "ctkiconfactory.h"
40#include "ctkintl.h"
41#include "ctkdebug.h"
42#include "ctkrender.h"
43#include "ctkborder.h"
44#include "ctkwidgetpath.h"
45
46/**
47 * SECTION:ctkstyle
48 * @Short_description: Object that holds style information
49 * for widgets
50 * @Title: CtkStyle
51 *
52 * A #CtkStyle object encapsulates the information that provides the look and
53 * feel for a widget.
54 *
55 * Each #CtkWidget has an associated #CtkStyle object that is used when
56 * rendering that widget. Also, a #CtkStyle holds information for the five
57 * possible widget states though not every widget supports all five
58 * states; see #CtkStateType.
59 *
60 * Usually the #CtkStyle for a widget is the same as the default style that
61 * is set by CTK+ and modified the theme engine.
62 *
63 * Usually applications should not need to use or modify the #CtkStyle of
64 * their widgets.
65 */
66
67
68#define LIGHTNESS_MULT1.3 1.3
69#define DARKNESS_MULT0.7 0.7
70
71/* --- typedefs & structures --- */
72typedef struct {
73 GType widget_type;
74 GParamSpec *pspec;
75 GValue value;
76} PropertyValue;
77
78typedef struct {
79 CtkStyleContext *context;
80 gulong context_changed_id;
81} CtkStylePrivate;
82
83#define CTK_STYLE_GET_PRIVATE(obj)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (obj)))
((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle *) (obj)))
84
85enum {
86 PROP_0,
87 PROP_CONTEXT
88};
89
90/* --- prototypes --- */
91static void ctk_style_finalize (GObject *object);
92static void ctk_style_constructed (GObject *object);
93static void ctk_style_set_property (GObject *object,
94 guint prop_id,
95 const GValue *value,
96 GParamSpec *pspec);
97static void ctk_style_get_property (GObject *object,
98 guint prop_id,
99 GValue *value,
100 GParamSpec *pspec);
101
102static void ctk_style_real_realize (CtkStyle *style);
103static void ctk_style_real_unrealize (CtkStyle *style);
104static void ctk_style_real_copy (CtkStyle *style,
105 CtkStyle *src);
106static void ctk_style_real_set_background (CtkStyle *style,
107 CdkWindow *window,
108 CtkStateType state_type);
109static CtkStyle *ctk_style_real_clone (CtkStyle *style);
110static void ctk_style_real_init_from_rc (CtkStyle *style,
111 CtkRcStyle *rc_style);
112static GdkPixbuf *ctk_default_render_icon (CtkStyle *style,
113 const CtkIconSource *source,
114 CtkTextDirection direction,
115 CtkStateType state,
116 CtkIconSize size,
117 CtkWidget *widget,
118 const gchar *detail);
119static void ctk_default_draw_hline (CtkStyle *style,
120 cairo_t *cr,
121 CtkStateType state_type,
122 CtkWidget *widget,
123 const gchar *detail,
124 gint x1,
125 gint x2,
126 gint y);
127static void ctk_default_draw_vline (CtkStyle *style,
128 cairo_t *cr,
129 CtkStateType state_type,
130 CtkWidget *widget,
131 const gchar *detail,
132 gint y1,
133 gint y2,
134 gint x);
135static void ctk_default_draw_shadow (CtkStyle *style,
136 cairo_t *cr,
137 CtkStateType state_type,
138 CtkShadowType shadow_type,
139 CtkWidget *widget,
140 const gchar *detail,
141 gint x,
142 gint y,
143 gint width,
144 gint height);
145static void ctk_default_draw_arrow (CtkStyle *style,
146 cairo_t *cr,
147 CtkStateType state_type,
148 CtkShadowType shadow_type,
149 CtkWidget *widget,
150 const gchar *detail,
151 CtkArrowType arrow_type,
152 gboolean fill,
153 gint x,
154 gint y,
155 gint width,
156 gint height);
157static void ctk_default_draw_diamond (CtkStyle *style,
158 cairo_t *cr,
159 CtkStateType state_type,
160 CtkShadowType shadow_type,
161 CtkWidget *widget,
162 const gchar *detail,
163 gint x,
164 gint y,
165 gint width,
166 gint height);
167static void ctk_default_draw_box (CtkStyle *style,
168 cairo_t *cr,
169 CtkStateType state_type,
170 CtkShadowType shadow_type,
171 CtkWidget *widget,
172 const gchar *detail,
173 gint x,
174 gint y,
175 gint width,
176 gint height);
177static void ctk_default_draw_flat_box (CtkStyle *style,
178 cairo_t *cr,
179 CtkStateType state_type,
180 CtkShadowType shadow_type,
181 CtkWidget *widget,
182 const gchar *detail,
183 gint x,
184 gint y,
185 gint width,
186 gint height);
187static void ctk_default_draw_check (CtkStyle *style,
188 cairo_t *cr,
189 CtkStateType state_type,
190 CtkShadowType shadow_type,
191 CtkWidget *widget,
192 const gchar *detail,
193 gint x,
194 gint y,
195 gint width,
196 gint height);
197static void ctk_default_draw_option (CtkStyle *style,
198 cairo_t *cr,
199 CtkStateType state_type,
200 CtkShadowType shadow_type,
201 CtkWidget *widget,
202 const gchar *detail,
203 gint x,
204 gint y,
205 gint width,
206 gint height);
207static void ctk_default_draw_tab (CtkStyle *style,
208 cairo_t *cr,
209 CtkStateType state_type,
210 CtkShadowType shadow_type,
211 CtkWidget *widget,
212 const gchar *detail,
213 gint x,
214 gint y,
215 gint width,
216 gint height);
217static void ctk_default_draw_shadow_gap (CtkStyle *style,
218 cairo_t *cr,
219 CtkStateType state_type,
220 CtkShadowType shadow_type,
221 CtkWidget *widget,
222 const gchar *detail,
223 gint x,
224 gint y,
225 gint width,
226 gint height,
227 CtkPositionType gap_side,
228 gint gap_x,
229 gint gap_width);
230static void ctk_default_draw_box_gap (CtkStyle *style,
231 cairo_t *cr,
232 CtkStateType state_type,
233 CtkShadowType shadow_type,
234 CtkWidget *widget,
235 const gchar *detail,
236 gint x,
237 gint y,
238 gint width,
239 gint height,
240 CtkPositionType gap_side,
241 gint gap_x,
242 gint gap_width);
243static void ctk_default_draw_extension (CtkStyle *style,
244 cairo_t *cr,
245 CtkStateType state_type,
246 CtkShadowType shadow_type,
247 CtkWidget *widget,
248 const gchar *detail,
249 gint x,
250 gint y,
251 gint width,
252 gint height,
253 CtkPositionType gap_side);
254static void ctk_default_draw_focus (CtkStyle *style,
255 cairo_t *cr,
256 CtkStateType state_type,
257 CtkWidget *widget,
258 const gchar *detail,
259 gint x,
260 gint y,
261 gint width,
262 gint height);
263static void ctk_default_draw_slider (CtkStyle *style,
264 cairo_t *cr,
265 CtkStateType state_type,
266 CtkShadowType shadow_type,
267 CtkWidget *widget,
268 const gchar *detail,
269 gint x,
270 gint y,
271 gint width,
272 gint height,
273 CtkOrientation orientation);
274static void ctk_default_draw_handle (CtkStyle *style,
275 cairo_t *cr,
276 CtkStateType state_type,
277 CtkShadowType shadow_type,
278 CtkWidget *widget,
279 const gchar *detail,
280 gint x,
281 gint y,
282 gint width,
283 gint height,
284 CtkOrientation orientation);
285static void ctk_default_draw_expander (CtkStyle *style,
286 cairo_t *cr,
287 CtkStateType state_type,
288 CtkWidget *widget,
289 const gchar *detail,
290 gint x,
291 gint y,
292 CtkExpanderStyle expander_style);
293static void ctk_default_draw_layout (CtkStyle *style,
294 cairo_t *cr,
295 CtkStateType state_type,
296 gboolean use_text,
297 CtkWidget *widget,
298 const gchar *detail,
299 gint x,
300 gint y,
301 PangoLayout *layout);
302static void ctk_default_draw_resize_grip (CtkStyle *style,
303 cairo_t *cr,
304 CtkStateType state_type,
305 CtkWidget *widget,
306 const gchar *detail,
307 CdkWindowEdge edge,
308 gint x,
309 gint y,
310 gint width,
311 gint height);
312static void ctk_default_draw_spinner (CtkStyle *style,
313 cairo_t *cr,
314 CtkStateType state_type,
315 CtkWidget *widget,
316 const gchar *detail,
317 guint step,
318 gint x,
319 gint y,
320 gint width,
321 gint height);
322
323static void rgb_to_hls (gdouble *r,
324 gdouble *g,
325 gdouble *b);
326static void hls_to_rgb (gdouble *h,
327 gdouble *l,
328 gdouble *s);
329
330static void transform_detail_string (const gchar *detail,
331 CtkStyleContext *context);
332
333/*
334 * Data for default check and radio buttons
335 */
336
337static const CtkRequisition default_option_indicator_size = { 7, 13 };
338static const CtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
339
340#define CTK_GRAY0xdcdc, 0xdada, 0xd5d5 0xdcdc, 0xdada, 0xd5d5
341#define CTK_DARK_GRAY0xc4c4, 0xc2c2, 0xbdbd 0xc4c4, 0xc2c2, 0xbdbd
342#define CTK_LIGHT_GRAY0xeeee, 0xebeb, 0xe7e7 0xeeee, 0xebeb, 0xe7e7
343#define CTK_WHITE0xffff, 0xffff, 0xffff 0xffff, 0xffff, 0xffff
344#define CTK_BLUE0x4b4b, 0x6969, 0x8383 0x4b4b, 0x6969, 0x8383
345#define CTK_VERY_DARK_GRAY0x9c9c, 0x9a9a, 0x9494 0x9c9c, 0x9a9a, 0x9494
346#define CTK_BLACK0x0000, 0x0000, 0x0000 0x0000, 0x0000, 0x0000
347#define CTK_WEAK_GRAY0x7530, 0x7530, 0x7530 0x7530, 0x7530, 0x7530
348
349/* --- variables --- */
350static const CdkColor ctk_default_normal_fg = { 0, CTK_BLACK0x0000, 0x0000, 0x0000 };
351static const CdkColor ctk_default_active_fg = { 0, CTK_BLACK0x0000, 0x0000, 0x0000 };
352static const CdkColor ctk_default_prelight_fg = { 0, CTK_BLACK0x0000, 0x0000, 0x0000 };
353static const CdkColor ctk_default_selected_fg = { 0, CTK_WHITE0xffff, 0xffff, 0xffff };
354static const CdkColor ctk_default_insensitive_fg = { 0, CTK_WEAK_GRAY0x7530, 0x7530, 0x7530 };
355
356static const CdkColor ctk_default_normal_bg = { 0, CTK_GRAY0xdcdc, 0xdada, 0xd5d5 };
357static const CdkColor ctk_default_active_bg = { 0, CTK_DARK_GRAY0xc4c4, 0xc2c2, 0xbdbd };
358static const CdkColor ctk_default_prelight_bg = { 0, CTK_LIGHT_GRAY0xeeee, 0xebeb, 0xe7e7 };
359static const CdkColor ctk_default_selected_bg = { 0, CTK_BLUE0x4b4b, 0x6969, 0x8383 };
360static const CdkColor ctk_default_insensitive_bg = { 0, CTK_GRAY0xdcdc, 0xdada, 0xd5d5 };
361static const CdkColor ctk_default_selected_base = { 0, CTK_BLUE0x4b4b, 0x6969, 0x8383 };
362static const CdkColor ctk_default_active_base = { 0, CTK_VERY_DARK_GRAY0x9c9c, 0x9a9a, 0x9494 };
363
364static GQuark quark_default_style;
365
366/* --- signals --- */
367static guint realize_signal = 0;
368static guint unrealize_signal = 0;
369
370G_DEFINE_TYPE_WITH_PRIVATE (CtkStyle, ctk_style, G_TYPE_OBJECT)static void ctk_style_init (CtkStyle *self); static void ctk_style_class_init
(CtkStyleClass *klass); static GType ctk_style_get_type_once
(void); static gpointer ctk_style_parent_class = ((void*)0);
static gint CtkStyle_private_offset; static void ctk_style_class_intern_init
(gpointer klass) { ctk_style_parent_class = g_type_class_peek_parent
(klass); if (CtkStyle_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkStyle_private_offset); ctk_style_class_init (
(CtkStyleClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ctk_style_get_instance_private (CtkStyle *self
) { return (((gpointer) ((guint8*) (self) + (glong) (CtkStyle_private_offset
)))); } GType ctk_style_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= ctk_style_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType ctk_style_get_type_once (void) {
GType g_define_type_id = g_type_register_static_simple (((GType
) ((20) << (2))), g_intern_static_string ("CtkStyle"), sizeof
(CtkStyleClass), (GClassInitFunc)(void (*)(void)) ctk_style_class_intern_init
, sizeof (CtkStyle), (GInstanceInitFunc)(void (*)(void)) ctk_style_init
, (GTypeFlags) 0); { {{ CtkStyle_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkStylePrivate)); };} } return g_define_type_id
; }
371
372/* --- functions --- */
373
374static void
375ctk_style_init (CtkStyle *style)
376{
377 gint i;
378
379 style->font_desc = pango_font_description_from_string ("Sans 10");
380
381 style->attach_count = 0;
382
383 style->black.red = 0;
384 style->black.green = 0;
385 style->black.blue = 0;
386
387 style->white.red = 65535;
388 style->white.green = 65535;
389 style->white.blue = 65535;
390
391 style->fg[CTK_STATE_NORMAL] = ctk_default_normal_fg;
392 style->fg[CTK_STATE_ACTIVE] = ctk_default_active_fg;
393 style->fg[CTK_STATE_PRELIGHT] = ctk_default_prelight_fg;
394 style->fg[CTK_STATE_SELECTED] = ctk_default_selected_fg;
395 style->fg[CTK_STATE_INSENSITIVE] = ctk_default_insensitive_fg;
396
397 style->bg[CTK_STATE_NORMAL] = ctk_default_normal_bg;
398 style->bg[CTK_STATE_ACTIVE] = ctk_default_active_bg;
399 style->bg[CTK_STATE_PRELIGHT] = ctk_default_prelight_bg;
400 style->bg[CTK_STATE_SELECTED] = ctk_default_selected_bg;
401 style->bg[CTK_STATE_INSENSITIVE] = ctk_default_insensitive_bg;
402
403 for (i = 0; i < 4; i++)
404 {
405 style->text[i] = style->fg[i];
406 style->base[i] = style->white;
407 }
408
409 style->base[CTK_STATE_SELECTED] = ctk_default_selected_base;
410 style->text[CTK_STATE_SELECTED] = style->white;
411 style->base[CTK_STATE_ACTIVE] = ctk_default_active_base;
412 style->text[CTK_STATE_ACTIVE] = style->white;
413 style->base[CTK_STATE_INSENSITIVE] = ctk_default_prelight_bg;
414 style->text[CTK_STATE_INSENSITIVE] = ctk_default_insensitive_fg;
415
416 style->rc_style = NULL((void*)0);
417
418 style->xthickness = 2;
419 style->ythickness = 2;
420
421 style->property_cache = NULL((void*)0);
422}
423
424static void
425ctk_style_class_init (CtkStyleClass *klass)
426{
427 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
428
429 object_class->finalize = ctk_style_finalize;
430 object_class->set_property = ctk_style_set_property;
431 object_class->get_property = ctk_style_get_property;
432 object_class->constructed = ctk_style_constructed;
433
434 klass->clone = ctk_style_real_clone;
435 klass->copy = ctk_style_real_copy;
436 klass->init_from_rc = ctk_style_real_init_from_rc;
437 klass->realize = ctk_style_real_realize;
438 klass->unrealize = ctk_style_real_unrealize;
439 klass->set_background = ctk_style_real_set_background;
440 klass->render_icon = ctk_default_render_icon;
441
442 klass->draw_hline = ctk_default_draw_hline;
443 klass->draw_vline = ctk_default_draw_vline;
444 klass->draw_shadow = ctk_default_draw_shadow;
445 klass->draw_arrow = ctk_default_draw_arrow;
446 klass->draw_diamond = ctk_default_draw_diamond;
447 klass->draw_box = ctk_default_draw_box;
448 klass->draw_flat_box = ctk_default_draw_flat_box;
449 klass->draw_check = ctk_default_draw_check;
450 klass->draw_option = ctk_default_draw_option;
451 klass->draw_tab = ctk_default_draw_tab;
452 klass->draw_shadow_gap = ctk_default_draw_shadow_gap;
453 klass->draw_box_gap = ctk_default_draw_box_gap;
454 klass->draw_extension = ctk_default_draw_extension;
455 klass->draw_focus = ctk_default_draw_focus;
456 klass->draw_slider = ctk_default_draw_slider;
457 klass->draw_handle = ctk_default_draw_handle;
458 klass->draw_expander = ctk_default_draw_expander;
459 klass->draw_layout = ctk_default_draw_layout;
460 klass->draw_resize_grip = ctk_default_draw_resize_grip;
461 klass->draw_spinner = ctk_default_draw_spinner;
462
463 g_object_class_install_property (object_class,
464 PROP_CONTEXT,
465 g_param_spec_object ("context",
466 P_("Style context")g_dgettext("ctk30" "-properties","Style context"),
467 P_("CtkStyleContext to get style from")g_dgettext("ctk30" "-properties","CtkStyleContext to get style from"
)
,
468 CTK_TYPE_STYLE_CONTEXT(ctk_style_context_get_type ()),
469 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
470
471 /**
472 * CtkStyle::realize:
473 * @style: the object which received the signal
474 *
475 * Emitted when the style has been initialized for a particular
476 * visual. Connecting to this signal is probably seldom
477 * useful since most of the time applications and widgets only
478 * deal with styles that have been already realized.
479 *
480 * Since: 2.4
481 */
482 realize_signal = g_signal_new (I_("realize")g_intern_static_string ("realize"),
483 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
484 G_SIGNAL_RUN_FIRST,
485 G_STRUCT_OFFSET (CtkStyleClass, realize)((glong) __builtin_offsetof(CtkStyleClass, realize)),
486 NULL((void*)0), NULL((void*)0),
487 NULL((void*)0),
488 G_TYPE_NONE((GType) ((1) << (2))), 0);
489 /**
490 * CtkStyle::unrealize:
491 * @style: the object which received the signal
492 *
493 * Emitted when the aspects of the style specific to a particular visual
494 * is being cleaned up. A connection to this signal can be useful
495 * if a widget wants to cache objects as object data on #CtkStyle.
496 * This signal provides a convenient place to free such cached objects.
497 *
498 * Since: 2.4
499 */
500 unrealize_signal = g_signal_new (I_("unrealize")g_intern_static_string ("unrealize"),
501 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
502 G_SIGNAL_RUN_FIRST,
503 G_STRUCT_OFFSET (CtkStyleClass, unrealize)((glong) __builtin_offsetof(CtkStyleClass, unrealize)),
504 NULL((void*)0), NULL((void*)0),
505 NULL((void*)0),
506 G_TYPE_NONE((GType) ((1) << (2))), 0);
507}
508
509static void
510ctk_style_finalize (GObject *object)
511{
512 CtkStyle *style = CTK_STYLE (object)((((CtkStyle*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_style_get_type ()))))))
;
513 CtkStylePrivate *priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
514 gint i;
515
516 g_return_if_fail (style->attach_count == 0)do { if ((style->attach_count == 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "style->attach_count == 0"
); return; } } while (0)
;
517
518 /* All the styles in the list have the same
519 * style->styles pointer. If we delete the
520 * *first* style from the list, we need to update
521 * the style->styles pointers from all the styles.
522 * Otherwise we simply remove the node from
523 * the list.
524 */
525 if (style->styles)
526 {
527 if (style->styles->data != style)
528 style->styles = g_slist_remove (style->styles, style);
529 else
530 {
531 GSList *tmp_list = style->styles->next;
532
533 while (tmp_list)
534 {
535 CTK_STYLE (tmp_list->data)((((CtkStyle*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tmp_list->data)), ((ctk_style_get_type ()))))))
->styles = style->styles->next;
536 tmp_list = tmp_list->next;
537 }
538 g_slist_free_1 (style->styles);
539 }
540 }
541
542 g_slist_free_full (style->icon_factories, g_object_unref);
543
544 pango_font_description_free (style->font_desc);
545
546 if (style->private_font_desc)
547 pango_font_description_free (style->private_font_desc);
548
549 if (style->rc_style)
550 g_object_unref (style->rc_style);
551
552 if (priv->context)
553 {
554 if (priv->context_changed_id)
555 g_signal_handler_disconnect (priv->context, priv->context_changed_id);
556
557 g_object_unref (priv->context);
558 }
559
560 for (i = 0; i < 5; i++)
561 {
562 if (style->background[i])
563 cairo_pattern_destroy (style->background[i]);
564 }
565
566 G_OBJECT_CLASS (ctk_style_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_style_parent_class)), (((GType) ((20) << (2)))
)))))
->finalize (object);
567}
568
569static void
570ctk_style_set_property (GObject *object,
571 guint prop_id,
572 const GValue *value,
573 GParamSpec *pspec)
574{
575 CtkStylePrivate *priv;
576
577 priv = CTK_STYLE_GET_PRIVATE (object)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (object)))
;
578
579 switch (prop_id)
580 {
581 case PROP_CONTEXT:
582 priv->context = g_value_dup_object (value);
583 break;
584 default:
585 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctkstyle.c", 585, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
586 break;
587 }
588}
589
590static void
591ctk_style_get_property (GObject *object,
592 guint prop_id,
593 GValue *value,
594 GParamSpec *pspec)
595{
596 CtkStylePrivate *priv;
597
598 priv = CTK_STYLE_GET_PRIVATE (object)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (object)))
;
599
600 switch (prop_id)
601 {
602 case PROP_CONTEXT:
603 g_value_set_object (value, priv->context);
604 break;
605 default:
606 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctkstyle.c", 606, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
607 break;
608 }
609}
610
611static gboolean
612set_color_from_context (CtkStyle *style,
613 CtkStateType state,
614 CtkStyleContext *context,
615 CtkRcFlags prop)
616{
617 CdkRGBA *color = NULL((void*)0);
618 CdkColor *dest = { 0 }; /* Shut up gcc */
619 CtkStateFlags flags;
620
621 flags = ctk_style_context_get_state (context);
622
623 switch (prop)
624 {
625 case CTK_RC_BG:
626 ctk_style_context_get (context, flags,
627 "background-color", &color,
628 NULL((void*)0));
629 dest = &style->bg[state];
630 break;
631 case CTK_RC_FG:
632 ctk_style_context_get (context, flags,
633 "color", &color,
634 NULL((void*)0));
635 dest = &style->fg[state];
636 break;
637 case CTK_RC_TEXT:
638 ctk_style_context_get (context, flags,
639 "color", &color,
640 NULL((void*)0));
641 dest = &style->text[state];
642 break;
643 case CTK_RC_BASE:
644 ctk_style_context_get (context, flags,
645 "background-color", &color,
646 NULL((void*)0));
647 dest = &style->base[state];
648 break;
649 }
650
651 if (!color)
652 return FALSE(0);
653
654 if (!(color->alpha > 0.01))
655 {
656 cdk_rgba_free (color);
657 return FALSE(0);
658 }
659
660 dest->pixel = 0;
661 dest->red = CLAMP ((guint) (color->red * 65535), 0, 65535)((((guint) (color->red * 65535)) > (65535)) ? (65535) :
((((guint) (color->red * 65535)) < (0)) ? (0) : ((guint
) (color->red * 65535))))
;
662 dest->green = CLAMP ((guint) (color->green * 65535), 0, 65535)((((guint) (color->green * 65535)) > (65535)) ? (65535)
: ((((guint) (color->green * 65535)) < (0)) ? (0) : ((
guint) (color->green * 65535))))
;
663 dest->blue = CLAMP ((guint) (color->blue * 65535), 0, 65535)((((guint) (color->blue * 65535)) > (65535)) ? (65535) :
((((guint) (color->blue * 65535)) < (0)) ? (0) : ((guint
) (color->blue * 65535))))
;
664 cdk_rgba_free (color);
665
666 return TRUE(!(0));
667}
668
669static void
670set_color (CtkStyle *style,
671 CtkStyleContext *context,
672 CtkStateType state,
673 CtkRcFlags prop)
674{
675 /* Try to fill in the values from the associated CtkStyleContext.
676 * Since fully-transparent black is a very common default (e.g. for
677 * background-color properties), and we must store the result in a CdkColor
678 * to retain API compatibility, in case the fetched color is fully transparent
679 * we give themes a fallback style class they can style, before using the
680 * hardcoded default values.
681 */
682 if (!set_color_from_context (style, state, context, prop))
683 {
684 ctk_style_context_save (context);
685 ctk_style_context_add_class (context, "ctkstyle-fallback");
686 set_color_from_context (style, state, context, prop);
687 ctk_style_context_restore (context);
688 }
689}
690
691static void
692ctk_style_update_from_context (CtkStyle *style)
693{
694 CtkStylePrivate *priv;
695 CtkStateType state;
696 CtkStateFlags flags;
697 CtkBorder padding;
698 gint i;
699
700 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
701
702 for (state = CTK_STATE_NORMAL; state <= CTK_STATE_INSENSITIVE; state++)
703 {
704 switch (state)
705 {
706 case CTK_STATE_ACTIVE:
707 flags = CTK_STATE_FLAG_ACTIVE;
708 break;
709 case CTK_STATE_PRELIGHT:
710 flags = CTK_STATE_FLAG_PRELIGHT;
711 break;
712 case CTK_STATE_SELECTED:
713 flags = CTK_STATE_FLAG_SELECTED;
714 break;
715 case CTK_STATE_INSENSITIVE:
716 flags = CTK_STATE_FLAG_INSENSITIVE;
717 break;
718 default:
719 flags = 0;
720 }
721
722 ctk_style_context_save (priv->context);
723 ctk_style_context_set_state (priv->context, flags);
724
725 if (ctk_style_context_has_class (priv->context, "entry"))
726 {
727 ctk_style_context_save (priv->context);
728 ctk_style_context_remove_class (priv->context, "entry");
729 set_color (style, priv->context, state, CTK_RC_BG);
730 set_color (style, priv->context, state, CTK_RC_FG);
731 ctk_style_context_restore (priv->context);
732
733 set_color (style, priv->context, state, CTK_RC_BASE);
734 set_color (style, priv->context, state, CTK_RC_TEXT);
735 }
736 else
737 {
738 ctk_style_context_save (priv->context);
739 ctk_style_context_add_class (priv->context, "entry");
740 set_color (style, priv->context, state, CTK_RC_BASE);
741 set_color (style, priv->context, state, CTK_RC_TEXT);
742 ctk_style_context_restore (priv->context);
743
744 set_color (style, priv->context, state, CTK_RC_BG);
745 set_color (style, priv->context, state, CTK_RC_FG);
746 }
747
748 ctk_style_context_restore (priv->context);
749 }
750
751 if (style->font_desc)
752 pango_font_description_free (style->font_desc);
753
754 flags = ctk_style_context_get_state (priv->context);
755 ctk_style_context_get (priv->context, flags,
756 "font", &style->font_desc,
757 NULL((void*)0));
758 ctk_style_context_get_padding (priv->context, flags, &padding);
759
760 style->xthickness = padding.left;
761 style->ythickness = padding.top;
762
763 for (i = 0; i < 5; i++)
764 {
765 _ctk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT1.3);
766 _ctk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT0.7);
767
768 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
769 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
770 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
771
772 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
773 style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
774 style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
775 }
776
777 style->black.red = 0x0000;
778 style->black.green = 0x0000;
779 style->black.blue = 0x0000;
780
781 style->white.red = 0xffff;
782 style->white.green = 0xffff;
783 style->white.blue = 0xffff;
784
785 for (i = 0; i < 5; i++)
786 {
787 if (style->background[i])
788 cairo_pattern_destroy (style->background[i]);
789
790 style->background[i] = cairo_pattern_create_rgb (style->bg[i].red / 65535.0,
791 style->bg[i].green / 65535.0,
792 style->bg[i].blue / 65535.0);
793 }
794}
795
796static void
797style_context_changed (CtkStyleContext *context G_GNUC_UNUSED__attribute__ ((__unused__)),
798 gpointer user_data)
799{
800 ctk_style_update_from_context (CTK_STYLE (user_data)((((CtkStyle*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((ctk_style_get_type ()))))))
);
801}
802
803static void
804ctk_style_constructed (GObject *object)
805{
806 CtkStylePrivate *priv;
807
808 priv = CTK_STYLE_GET_PRIVATE (object)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (object)))
;
809
810 if (priv->context)
811 {
812 ctk_style_update_from_context (CTK_STYLE (object)((((CtkStyle*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_style_get_type ()))))))
);
813
814 priv->context_changed_id = g_signal_connect (priv->context, "changed",g_signal_connect_data ((priv->context), ("changed"), (((GCallback
) (style_context_changed))), (object), ((void*)0), (GConnectFlags
) 0)
815 G_CALLBACK (style_context_changed), object)g_signal_connect_data ((priv->context), ("changed"), (((GCallback
) (style_context_changed))), (object), ((void*)0), (GConnectFlags
) 0)
;
816 }
817}
818
819/**
820 * ctk_style_copy:
821 * @style: a #CtkStyle
822 *
823 * Creates a copy of the passed in #CtkStyle object.
824 *
825 * Returns: (transfer full): a copy of @style
826 */
827CtkStyle*
828ctk_style_copy (CtkStyle *style)
829{
830 CtkStyle *new_style;
831
832 g_return_val_if_fail (CTK_IS_STYLE (style), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return (((void*)0)); } } while (
0)
;
833
834 new_style = CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->clone (style);
835 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->copy (new_style, style);
836
837 return new_style;
838}
839
840CtkStyle*
841_ctk_style_new_for_path (CdkScreen *screen,
842 CtkWidgetPath *path)
843{
844 CtkStyleContext *context;
845 CtkStyle *style;
846
847 context = ctk_style_context_new ();
848
849 if (screen)
850 ctk_style_context_set_screen (context, screen);
851
852 ctk_style_context_set_path (context, path);
853
854 style = g_object_new (CTK_TYPE_STYLE(ctk_style_get_type ()),
855 "context", context,
856 NULL((void*)0));
857
858 g_object_unref (context);
859
860 return style;
861}
862
863/**
864 * ctk_style_new:
865 *
866 * Creates a new #CtkStyle.
867 *
868 * Returns: a new #CtkStyle.
869 */
870CtkStyle*
871ctk_style_new (void)
872{
873 CtkWidgetPath *path;
874 CtkStyle *style;
875
876 path = ctk_widget_path_new ();
877 ctk_widget_path_append_type (path, CTK_TYPE_WIDGET(ctk_widget_get_type ()));
878
879 style = _ctk_style_new_for_path (cdk_screen_get_default (), path);
880
881 ctk_widget_path_free (path);
882
883 return style;
884}
885
886/**
887 * ctk_style_has_context:
888 * @style: a #CtkStyle
889 *
890 * Returns whether @style has an associated #CtkStyleContext.
891 *
892 * Returns: %TRUE if @style has a #CtkStyleContext
893 *
894 * Since: 3.0
895 */
896gboolean
897ctk_style_has_context (CtkStyle *style)
898{
899 CtkStylePrivate *priv;
900
901 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
902
903 return priv->context != NULL((void*)0);
904}
905
906/**
907 * ctk_style_attach: (skip)
908 * @style: a #CtkStyle.
909 * @window: a #CdkWindow.
910 *
911 * Attaches a style to a window; this process allocates the
912 * colors and creates the GC’s for the style - it specializes
913 * it to a particular visual. The process may involve the creation
914 * of a new style if the style has already been attached to a
915 * window with a different style and visual.
916 *
917 * Since this function may return a new object, you have to use it
918 * in the following way:
919 * `style = ctk_style_attach (style, window)`
920 *
921 * Returns: Either @style, or a newly-created #CtkStyle.
922 * If the style is newly created, the style parameter
923 * will be unref'ed, and the new style will have
924 * a reference count belonging to the caller.
925 */
926CtkStyle*
927ctk_style_attach (CtkStyle *style,
928 CdkWindow *window)
929{
930 g_return_val_if_fail (CTK_IS_STYLE (style), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return (((void*)0)); } } while (
0)
;
931 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "window != NULL"); return
(((void*)0)); } } while (0)
;
932
933 return style;
934}
935
936/**
937 * ctk_style_detach:
938 * @style: a #CtkStyle
939 *
940 * Detaches a style from a window. If the style is not attached
941 * to any windows anymore, it is unrealized. See ctk_style_attach().
942 */
943void
944ctk_style_detach (CtkStyle *style)
945{
946 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
947}
948
949/**
950 * ctk_style_lookup_icon_set:
951 * @style: a #CtkStyle
952 * @stock_id: an icon name
953 *
954 * Looks up @stock_id in the icon factories associated with @style
955 * and the default icon factory, returning an icon set if found,
956 * otherwise %NULL.
957 *
958 * Returns: (transfer none): icon set of @stock_id
959 */
960CtkIconSet*
961ctk_style_lookup_icon_set (CtkStyle *style,
962 const char *stock_id)
963{
964 CtkStylePrivate *priv;
965
966 g_return_val_if_fail (CTK_IS_STYLE (style), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return (((void*)0)); } } while (
0)
;
967 g_return_val_if_fail (stock_id != NULL, NULL)do { if ((stock_id != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "stock_id != NULL"); return
(((void*)0)); } } while (0)
;
968
969 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
970
971 if (priv->context)
972 return ctk_style_context_lookup_icon_set (priv->context, stock_id);
973
974 return ctk_icon_factory_lookup_default (stock_id);
975}
976
977/**
978 * ctk_style_lookup_color:
979 * @style: a #CtkStyle
980 * @color_name: the name of the logical color to look up
981 * @color: (out): the #CdkColor to fill in
982 *
983 * Looks up @color_name in the style’s logical color mappings,
984 * filling in @color and returning %TRUE if found, otherwise
985 * returning %FALSE. Do not cache the found mapping, because
986 * it depends on the #CtkStyle and might change when a theme
987 * switch occurs.
988 *
989 * Returns: %TRUE if the mapping was found.
990 *
991 * Since: 2.10
992 **/
993gboolean
994ctk_style_lookup_color (CtkStyle *style,
995 const char *color_name,
996 CdkColor *color)
997{
998 CtkStylePrivate *priv;
999 gboolean result;
1000 CdkRGBA rgba;
1001
1002 g_return_val_if_fail (CTK_IS_STYLE (style), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return ((0)); } } while (0)
;
1003 g_return_val_if_fail (color_name != NULL, FALSE)do { if ((color_name != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "color_name != NULL"); return
((0)); } } while (0)
;
1004 g_return_val_if_fail (color != NULL, FALSE)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "color != NULL"); return
((0)); } } while (0)
;
1005
1006 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1007
1008 if (!priv->context)
1009 return FALSE(0);
1010
1011 result = ctk_style_context_lookup_color (priv->context, color_name, &rgba);
1012
1013 if (color)
1014 {
1015 color->red = (guint16) (rgba.red * 65535);
1016 color->green = (guint16) (rgba.green * 65535);
1017 color->blue = (guint16) (rgba.blue * 65535);
1018 color->pixel = 0;
1019 }
1020
1021 return result;
1022}
1023
1024/**
1025 * ctk_style_set_background:
1026 * @style: a #CtkStyle
1027 * @window: a #CdkWindow
1028 * @state_type: a state
1029 *
1030 * Sets the background of @window to the background color or pixmap
1031 * specified by @style for the given state.
1032 */
1033void
1034ctk_style_set_background (CtkStyle *style,
1035 CdkWindow *window,
1036 CtkStateType state_type)
1037{
1038 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
1039 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "window != NULL"); return
; } } while (0)
;
1040
1041 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->set_background (style, window, state_type);
1042}
1043
1044/* Default functions */
1045static CtkStyle *
1046ctk_style_real_clone (CtkStyle *style)
1047{
1048 CtkStylePrivate *priv;
1049
1050 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1051
1052 return g_object_new (G_OBJECT_TYPE (style)(((((GTypeClass*) (((GTypeInstance*) (style))->g_class))->
g_type)))
,
1053 "context", priv->context,
1054 NULL((void*)0));
1055}
1056
1057static void
1058ctk_style_real_copy (CtkStyle *style,
1059 CtkStyle *src)
1060{
1061 gint i;
1062
1063 for (i = 0; i < 5; i++)
1064 {
1065 style->fg[i] = src->fg[i];
1066 style->bg[i] = src->bg[i];
1067 style->text[i] = src->text[i];
1068 style->base[i] = src->base[i];
1069
1070 if (style->background[i])
1071 cairo_pattern_destroy (style->background[i]),
1072 style->background[i] = src->background[i];
1073 if (style->background[i])
1074 cairo_pattern_reference (style->background[i]);
1075 }
1076
1077 if (style->font_desc)
1078 pango_font_description_free (style->font_desc);
1079 if (src->font_desc)
1080 style->font_desc = pango_font_description_copy (src->font_desc);
1081 else
1082 style->font_desc = NULL((void*)0);
1083
1084 style->xthickness = src->xthickness;
1085 style->ythickness = src->ythickness;
1086
1087 if (style->rc_style)
1088 g_object_unref (style->rc_style);
1089 style->rc_style = src->rc_style;
1090 if (src->rc_style)
1091 g_object_ref (src->rc_style)((__typeof__ (src->rc_style)) (g_object_ref) (src->rc_style
))
;
1092
1093 g_slist_free_full (style->icon_factories, g_object_unref);
1094 style->icon_factories = g_slist_copy (src->icon_factories);
1095 g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL((void*)0));
1096}
1097
1098static void
1099ctk_style_real_init_from_rc (CtkStyle *style G_GNUC_UNUSED__attribute__ ((__unused__)),
1100 CtkRcStyle *rc_style G_GNUC_UNUSED__attribute__ ((__unused__)))
1101{
1102}
1103
1104/**
1105 * ctk_style_get_style_property:
1106 * @style: a #CtkStyle
1107 * @widget_type: the #GType of a descendant of #CtkWidget
1108 * @property_name: the name of the style property to get
1109 * @value: (out): a #GValue where the value of the property being
1110 * queried will be stored
1111 *
1112 * Queries the value of a style property corresponding to a
1113 * widget class is in the given style.
1114 *
1115 * Since: 2.16
1116 */
1117void
1118ctk_style_get_style_property (CtkStyle *style,
1119 GType widget_type,
1120 const gchar *property_name,
1121 GValue *value)
1122{
1123 CtkStylePrivate *priv;
1124 CtkWidgetClass *klass;
1125 GParamSpec *pspec;
1126 const GValue *peek_value;
1127
1128 klass = g_type_class_ref (widget_type);
1129 pspec = ctk_widget_class_find_style_property (klass, property_name);
1130 g_type_class_unref (klass);
1131
1132 if (!pspec)
1133 {
1134 g_warning ("%s: widget class `%s' has no property named `%s'",
1135 G_STRLOC"ctkstyle.c" ":" "1135",
1136 g_type_name (widget_type),
1137 property_name);
1138 return;
1139 }
1140
1141 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1142 peek_value = _ctk_style_context_peek_style_property (priv->context,
1143 widget_type,
1144 pspec);
1145
1146 if (G_VALUE_TYPE (value)(((GValue*) (value))->g_type) == G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2))))))))->value_type
)
)
1147 g_value_copy (peek_value, value);
1148 else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2))))))))->value_type
)
, G_VALUE_TYPE (value)(((GValue*) (value))->g_type)))
1149 g_value_transform (peek_value, value);
1150 else
1151 g_warning ("can't retrieve style property `%s' of type `%s' as value of type `%s'",
1152 pspec->name,
1153 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2))))))))->value_type
)
),
1154 G_VALUE_TYPE_NAME (value)(g_type_name ((((GValue*) (value))->g_type))));
1155}
1156
1157/**
1158 * ctk_style_get_valist:
1159 * @style: a #CtkStyle
1160 * @widget_type: the #GType of a descendant of #CtkWidget
1161 * @first_property_name: the name of the first style property to get
1162 * @var_args: a va_list of pairs of property names and
1163 * locations to return the property values, starting with the
1164 * location for @first_property_name.
1165 *
1166 * Non-vararg variant of ctk_style_get().
1167 * Used primarily by language bindings.
1168 *
1169 * Since: 2.16
1170 */
1171void
1172ctk_style_get_valist (CtkStyle *style,
1173 GType widget_type,
1174 const gchar *first_property_name,
1175 va_list var_args)
1176{
1177 CtkStylePrivate *priv;
1178 const char *property_name;
1179 CtkWidgetClass *klass;
1180
1181 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
1182
1183 klass = g_type_class_ref (widget_type);
1184
1185 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1186 property_name = first_property_name;
1187 while (property_name)
1188 {
1189 GParamSpec *pspec;
1190 const GValue *peek_value;
1191 gchar *error;
1192
1193 pspec = ctk_widget_class_find_style_property (klass, property_name);
1194
1195 if (!pspec)
1196 {
1197 g_warning ("%s: widget class `%s' has no property named `%s'",
1198 G_STRLOC"ctkstyle.c" ":" "1198",
1199 g_type_name (widget_type),
1200 property_name);
1201 break;
1202 }
1203
1204 peek_value = _ctk_style_context_peek_style_property (priv->context, widget_type,
1205 pspec);
1206 G_VALUE_LCOPY (peek_value, var_args, 0, &error)do { const GValue *g_vl_value = (peek_value); guint g_vl_flags
= (0); GType g_vl_value_type = (((GValue*) (g_vl_value))->
g_type); GTypeValueTable *g_vl_vtable = g_type_value_table_peek
(g_vl_value_type); const gchar *g_vl_lcopy_format = g_vl_vtable
->lcopy_format; GTypeCValue g_vl_cvalues[(8)] = { { 0, }, }
; guint g_vl_n_values = 0; while (*g_vl_lcopy_format) { GTypeCValue
*g_vl_cvalue = g_vl_cvalues + g_vl_n_values++; switch (*g_vl_lcopy_format
++) { case G_VALUE_COLLECT_INT: g_vl_cvalue->v_int = __builtin_va_arg
((var_args), gint); break; case G_VALUE_COLLECT_LONG: g_vl_cvalue
->v_long = __builtin_va_arg((var_args), glong); break; case
G_VALUE_COLLECT_INT64: g_vl_cvalue->v_int64 = __builtin_va_arg
((var_args), gint64); break; case G_VALUE_COLLECT_DOUBLE: g_vl_cvalue
->v_double = __builtin_va_arg((var_args), gdouble); break;
case G_VALUE_COLLECT_POINTER: g_vl_cvalue->v_pointer = __builtin_va_arg
((var_args), gpointer); break; default: do { g_assertion_message_expr
("Ctk", "ctkstyle.c", 1206, ((const char*) (__func__)), ((void
*)0)); } while (0); } } *(&error) = g_vl_vtable->lcopy_value
(g_vl_value, g_vl_n_values, g_vl_cvalues, g_vl_flags); } while
(0)
;
1207 if (error)
1208 {
1209 g_warning ("%s: %s", G_STRLOC"ctkstyle.c" ":" "1209", error);
1210 g_free (error);
1211 break;
1212 }
1213
1214 property_name = va_arg (var_args, gchar*)__builtin_va_arg(var_args, gchar*);
1215 }
1216
1217 g_type_class_unref (klass);
1218}
1219
1220/**
1221 * ctk_style_get:
1222 * @style: a #CtkStyle
1223 * @widget_type: the #GType of a descendant of #CtkWidget
1224 * @first_property_name: the name of the first style property to get
1225 * @...: pairs of property names and locations to
1226 * return the property values, starting with the location for
1227 * @first_property_name, terminated by %NULL.
1228 *
1229 * Gets the values of a multiple style properties for @widget_type
1230 * from @style.
1231 *
1232 * Since: 2.16
1233 */
1234void
1235ctk_style_get (CtkStyle *style,
1236 GType widget_type,
1237 const gchar *first_property_name,
1238 ...)
1239{
1240 va_list var_args;
1241
1242 va_start (var_args, first_property_name)__builtin_va_start(var_args, first_property_name);
1243 ctk_style_get_valist (style, widget_type, first_property_name, var_args);
1244 va_end (var_args)__builtin_va_end(var_args);
1245}
1246
1247static void
1248ctk_style_real_realize (CtkStyle *style G_GNUC_UNUSED__attribute__ ((__unused__)))
1249{
1250}
1251
1252static void
1253ctk_style_real_unrealize (CtkStyle *style G_GNUC_UNUSED__attribute__ ((__unused__)))
1254{
1255}
1256
1257static void
1258ctk_style_real_set_background (CtkStyle *style,
1259 CdkWindow *window,
1260 CtkStateType state_type)
1261{
1262 cdk_window_set_background_pattern (window, style->background[state_type]);
1263}
1264
1265/**
1266 * ctk_style_render_icon:
1267 * @style: a #CtkStyle
1268 * @source: the #CtkIconSource specifying the icon to render
1269 * @direction: a text direction
1270 * @state: a state
1271 * @size: (type int): the size to render the icon at (#CtkIconSize). A size of
1272 * `(CtkIconSize)-1` means render at the size of the source and
1273 * don’t scale.
1274 * @widget: (allow-none): the widget
1275 * @detail: (allow-none): a style detail
1276 *
1277 * Renders the icon specified by @source at the given @size
1278 * according to the given parameters and returns the result in a
1279 * pixbuf.
1280 *
1281 * Returns: (transfer full): a newly-created #GdkPixbuf
1282 * containing the rendered icon
1283 */
1284GdkPixbuf *
1285ctk_style_render_icon (CtkStyle *style,
1286 const CtkIconSource *source,
1287 CtkTextDirection direction,
1288 CtkStateType state,
1289 CtkIconSize size,
1290 CtkWidget *widget,
1291 const gchar *detail)
1292{
1293 GdkPixbuf *pixbuf;
1294
1295 g_return_val_if_fail (CTK_IS_STYLE (style), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return (((void*)0)); } } while (
0)
;
1296 g_return_val_if_fail (CTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->render_icon != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->render_icon != NULL"
); return (((void*)0)); } } while (0)
;
1297
1298 pixbuf = CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->render_icon (style, source, direction, state,
1299 size, widget, detail);
1300
1301 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
1302
1303 return pixbuf;
1304}
1305
1306/* Default functions */
1307
1308/**
1309 * ctk_style_apply_default_background:
1310 * @style:
1311 * @cr:
1312 * @window:
1313 * @state_type:
1314 * @x:
1315 * @y:
1316 * @width:
1317 * @height:
1318 */
1319void
1320ctk_style_apply_default_background (CtkStyle *style,
1321 cairo_t *cr,
1322 CdkWindow *window,
1323 CtkStateType state_type,
1324 gint x,
1325 gint y,
1326 gint width,
1327 gint height)
1328{
1329 cairo_save (cr);
1330
1331 if (style->background[state_type] == NULL((void*)0))
1332 {
1333 CdkWindow *parent = cdk_window_get_parent (window);
1334 int x_offset, y_offset;
1335
1336 if (parent)
1337 {
1338 cdk_window_get_position (window, &x_offset, &y_offset);
1339 cairo_translate (cr, -x_offset, -y_offset);
1340 ctk_style_apply_default_background (style, cr,
1341 parent, state_type,
1342 x + x_offset, y + y_offset,
1343 width, height);
1344 goto out;
1345 }
1346 else
1347 cdk_cairo_set_source_color (cr, &style->bg[state_type]);
1348 }
1349 else
1350 cairo_set_source (cr, style->background[state_type]);
1351
1352 cairo_rectangle (cr, x, y, width, height);
1353 cairo_fill (cr);
1354
1355out:
1356 cairo_restore (cr);
1357}
1358
1359static GdkPixbuf *
1360ctk_default_render_icon (CtkStyle *style,
1361 const CtkIconSource *source,
1362 CtkTextDirection direction G_GNUC_UNUSED__attribute__ ((__unused__)),
1363 CtkStateType state,
1364 CtkIconSize size,
1365 CtkWidget *widget,
1366 const gchar *detail)
1367{
1368 CtkStyleContext *context;
1369 CtkStylePrivate *priv;
1370 CtkStateFlags flags = 0;
1371 GdkPixbuf *pixbuf;
1372
1373 if (widget)
1374 context = ctk_widget_get_style_context (widget);
1375 else
1376 {
1377 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1378 context = priv->context;
1379 }
1380
1381 if (!context)
1382 return NULL((void*)0);
1383
1384 ctk_style_context_save (context);
1385
1386 if (detail)
1387 transform_detail_string (detail, context);
1388
1389 switch (state)
1390 {
1391 case CTK_STATE_PRELIGHT:
1392 flags |= CTK_STATE_FLAG_PRELIGHT;
1393 break;
1394 case CTK_STATE_INSENSITIVE:
1395 flags |= CTK_STATE_FLAG_INSENSITIVE;
1396 break;
1397 default:
1398 break;
1399 }
1400
1401 ctk_style_context_set_state (context, flags);
1402
1403 pixbuf = ctk_render_icon_pixbuf (context, source, size);
1404
1405 ctk_style_context_restore (context);
1406
1407 return pixbuf;
1408}
1409
1410static void
1411_cairo_draw_line (cairo_t *cr,
1412 CdkColor *color,
1413 gint x1,
1414 gint y1,
1415 gint x2,
1416 gint y2)
1417{
1418 cairo_save (cr);
1419
1420 cdk_cairo_set_source_color (cr, color);
1421 cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
1422
1423 cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
1424 cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
1425 cairo_stroke (cr);
1426
1427 cairo_restore (cr);
1428}
1429
1430static void
1431transform_detail_string (const gchar *detail,
1432 CtkStyleContext *context)
1433{
1434 if (!detail)
1435 return;
1436
1437 if (strcmp (detail, "arrow") == 0)
1438 ctk_style_context_add_class (context, "arrow");
1439 else if (strcmp (detail, "button") == 0)
1440 ctk_style_context_add_class (context, "button");
1441 else if (strcmp (detail, "buttondefault") == 0)
1442 {
1443 ctk_style_context_add_class (context, "button");
1444 ctk_style_context_add_class (context, "default");
1445 }
1446 else if (strcmp (detail, "calendar") == 0)
1447 ctk_style_context_add_class (context, "calendar");
1448 else if (strcmp (detail, "cellcheck") == 0)
1449 {
1450 ctk_style_context_add_class (context, "cell");
1451 ctk_style_context_add_class (context, "check");
1452 }
1453 else if (strcmp (detail, "cellradio") == 0)
1454 {
1455 ctk_style_context_add_class (context, "cell");
1456 ctk_style_context_add_class (context, "radio");
1457 }
1458 else if (strcmp (detail, "checkbutton") == 0)
1459 ctk_style_context_add_class (context, "check");
1460 else if (strcmp (detail, "check") == 0)
1461 {
1462 ctk_style_context_add_class (context, "check");
1463 ctk_style_context_add_class (context, "menu");
1464 }
1465 else if (strcmp (detail, "radiobutton") == 0)
1466 {
1467 ctk_style_context_add_class (context, "radio");
1468 }
1469 else if (strcmp (detail, "option") == 0)
1470 {
1471 ctk_style_context_add_class (context, "radio");
1472 ctk_style_context_add_class (context, "menu");
1473 }
1474 else if (strcmp (detail, "entry") == 0 ||
1475 strcmp (detail, "entry_bg") == 0)
1476 ctk_style_context_add_class (context, "entry");
1477 else if (strcmp (detail, "expander") == 0)
1478 ctk_style_context_add_class (context, "expander");
1479 else if (strcmp (detail, "tooltip") == 0)
1480 ctk_style_context_add_class (context, "tooltip");
1481 else if (strcmp (detail, "frame") == 0)
1482 ctk_style_context_add_class (context, "frame");
1483 else if (strcmp (detail, "scrolled_window") == 0)
1484 ctk_style_context_add_class (context, "scrolled-window");
1485 else if (strcmp (detail, "viewport") == 0 ||
1486 strcmp (detail, "viewportbin") == 0)
1487 ctk_style_context_add_class (context, "viewport");
1488 else if (strncmp (detail, "trough", 6) == 0)
1489 ctk_style_context_add_class (context, "trough");
1490 else if (strcmp (detail, "spinbutton") == 0)
1491 ctk_style_context_add_class (context, "spinbutton");
1492 else if (strcmp (detail, "spinbutton_up") == 0)
1493 {
1494 ctk_style_context_add_class (context, "spinbutton");
1495 ctk_style_context_add_class (context, "button");
1496 ctk_style_context_set_junction_sides (context, CTK_JUNCTION_BOTTOM);
1497 }
1498 else if (strcmp (detail, "spinbutton_down") == 0)
1499 {
1500 ctk_style_context_add_class (context, "spinbutton");
1501 ctk_style_context_add_class (context, "button");
1502 ctk_style_context_set_junction_sides (context, CTK_JUNCTION_TOP);
1503 }
1504 else if ((detail[0] == 'h' || detail[0] == 'v') &&
1505 strncmp (&detail[1], "scrollbar_", 10) == 0)
1506 {
1507 ctk_style_context_add_class (context, "button");
1508 ctk_style_context_add_class (context, "scrollbar");
1509 }
1510 else if (strcmp (detail, "slider") == 0)
1511 {
1512 ctk_style_context_add_class (context, "slider");
1513 ctk_style_context_add_class (context, "scrollbar");
1514 }
1515 else if (strcmp (detail, "vscale") == 0 ||
1516 strcmp (detail, "hscale") == 0)
1517 {
1518 ctk_style_context_add_class (context, "slider");
1519 ctk_style_context_add_class (context, "scale");
1520 }
1521 else if (strcmp (detail, "menuitem") == 0)
1522 {
1523 ctk_style_context_add_class (context, "menuitem");
1524 ctk_style_context_add_class (context, "menu");
1525 }
1526 else if (strcmp (detail, "menu") == 0)
1527 {
1528 ctk_style_context_add_class (context, "popup");
1529 ctk_style_context_add_class (context, "menu");
1530 }
1531 else if (strcmp (detail, "accellabel") == 0)
1532 ctk_style_context_add_class (context, "accelerator");
1533 else if (strcmp (detail, "menubar") == 0)
1534 ctk_style_context_add_class (context, "menubar");
1535 else if (strcmp (detail, "base") == 0)
1536 ctk_style_context_add_class (context, "background");
1537 else if (strcmp (detail, "bar") == 0 ||
1538 strcmp (detail, "progressbar") == 0)
1539 ctk_style_context_add_class (context, "progressbar");
1540 else if (strcmp (detail, "toolbar") == 0)
1541 ctk_style_context_add_class (context, "toolbar");
1542 else if (strcmp (detail, "handlebox_bin") == 0)
1543 ctk_style_context_add_class (context, "dock");
1544 else if (strcmp (detail, "notebook") == 0)
1545 ctk_style_context_add_class (context, "notebook");
1546 else if (strcmp (detail, "tab") == 0)
1547 {
1548 ctk_style_context_add_class (context, "notebook");
1549 ctk_style_context_add_region (context, CTK_STYLE_REGION_TAB"tab", 0);
1550 }
1551 else if (g_str_has_prefix (detail, "cell")(__builtin_constant_p ("cell")? __extension__ ({ const char *
const __str = (detail); const char * const __prefix = ("cell"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (detail, "cell") )
)
1552 {
1553 CtkRegionFlags row, col;
1554 gboolean ruled = FALSE(0);
1555 GStrv tokens;
1556 guint i;
1557
1558 tokens = g_strsplit (detail, "_", -1);
1559 row = col = 0;
1560 i = 0;
1561
1562 while (tokens[i])
1563 {
1564 if (strcmp (tokens[i], "even") == 0)
1565 row |= CTK_REGION_EVEN;
1566 else if (strcmp (tokens[i], "odd") == 0)
1567 row |= CTK_REGION_ODD;
1568 else if (strcmp (tokens[i], "start") == 0)
1569 col |= CTK_REGION_FIRST;
1570 else if (strcmp (tokens[i], "end") == 0)
1571 col |= CTK_REGION_LAST;
1572 else if (strcmp (tokens[i], "ruled") == 0)
1573 ruled = TRUE(!(0));
1574 else if (strcmp (tokens[i], "sorted") == 0)
1575 col |= CTK_REGION_SORTED;
1576
1577 i++;
1578 }
1579
1580 if (!ruled)
1581 row &= ~(CTK_REGION_EVEN | CTK_REGION_ODD);
1582
1583 ctk_style_context_add_class (context, "cell");
1584 ctk_style_context_add_region (context, "row", row);
1585 ctk_style_context_add_region (context, "column", col);
1586
1587 g_strfreev (tokens);
1588 }
1589}
1590
1591static void
1592ctk_default_draw_hline (CtkStyle *style,
1593 cairo_t *cr,
1594 CtkStateType state_type G_GNUC_UNUSED__attribute__ ((__unused__)),
1595 CtkWidget *widget,
1596 const gchar *detail,
1597 gint x1,
1598 gint x2,
1599 gint y)
1600{
1601 CtkStyleContext *context;
1602 CtkStylePrivate *priv;
1603
1604 if (widget)
1605 context = ctk_widget_get_style_context (widget);
1606 else
1607 {
1608 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1609 context = priv->context;
1610 }
1611
1612 ctk_style_context_save (context);
1613
1614 if (detail)
1615 transform_detail_string (detail, context);
1616
1617 cairo_save (cr);
1618
1619 ctk_render_line (context, cr,
1620 x1, y, x2, y);
1621
1622 cairo_restore (cr);
1623
1624 ctk_style_context_restore (context);
1625}
1626
1627
1628static void
1629ctk_default_draw_vline (CtkStyle *style,
1630 cairo_t *cr,
1631 CtkStateType state_type G_GNUC_UNUSED__attribute__ ((__unused__)),
1632 CtkWidget *widget,
1633 const gchar *detail,
1634 gint y1,
1635 gint y2,
1636 gint x)
1637{
1638 CtkStyleContext *context;
1639 CtkStylePrivate *priv;
1640
1641 if (widget)
1642 context = ctk_widget_get_style_context (widget);
1643 else
1644 {
1645 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1646 context = priv->context;
1647 }
1648
1649 ctk_style_context_save (context);
1650
1651 if (detail)
1652 transform_detail_string (detail, context);
1653
1654 cairo_save (cr);
1655
1656 ctk_render_line (context, cr,
1657 x, y1, x, y2);
1658
1659 cairo_restore (cr);
1660 ctk_style_context_restore (context);
1661}
1662
1663static void
1664ctk_default_draw_shadow (CtkStyle *style,
1665 cairo_t *cr,
1666 CtkStateType state_type G_GNUC_UNUSED__attribute__ ((__unused__)),
1667 CtkShadowType shadow_type,
1668 CtkWidget *widget,
1669 const gchar *detail,
1670 gint x,
1671 gint y,
1672 gint width,
1673 gint height)
1674{
1675 CtkStyleContext *context;
1676 CtkStylePrivate *priv;
1677
1678 if (shadow_type == CTK_SHADOW_NONE)
1679 return;
1680
1681 if (widget)
1682 context = ctk_widget_get_style_context (widget);
1683 else
1684 {
1685 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1686 context = priv->context;
1687 }
1688
1689 ctk_style_context_save (context);
1690
1691 if (detail)
1692 transform_detail_string (detail, context);
1693
1694 cairo_save (cr);
1695
1696 ctk_render_frame (context, cr,
1697 (gdouble) x,
1698 (gdouble) y,
1699 (gdouble) width,
1700 (gdouble) height);
1701
1702 cairo_restore (cr);
1703 ctk_style_context_restore (context);
1704}
1705
1706static void
1707draw_arrow (cairo_t *cr,
1708 CdkColor *color,
1709 CtkArrowType arrow_type,
1710 gint x,
1711 gint y,
1712 gint width,
1713 gint height)
1714{
1715 cdk_cairo_set_source_color (cr, color);
1716 cairo_save (cr);
1717
1718 if (arrow_type == CTK_ARROW_DOWN)
1719 {
1720 cairo_move_to (cr, x, y);
1721 cairo_line_to (cr, x + width, y);
1722 cairo_line_to (cr, x + width / 2., y + height);
1723 }
1724 else if (arrow_type == CTK_ARROW_UP)
1725 {
1726 cairo_move_to (cr, x, y + height);
1727 cairo_line_to (cr, x + width / 2., y);
1728 cairo_line_to (cr, x + width, y + height);
1729 }
1730 else if (arrow_type == CTK_ARROW_LEFT)
1731 {
1732 cairo_move_to (cr, x + width, y);
1733 cairo_line_to (cr, x + width, y + height);
1734 cairo_line_to (cr, x, y + height / 2.);
1735 }
1736 else if (arrow_type == CTK_ARROW_RIGHT)
1737 {
1738 cairo_move_to (cr, x, y);
1739 cairo_line_to (cr, x + width, y + height / 2.);
1740 cairo_line_to (cr, x, y + height);
1741 }
1742
1743 cairo_close_path (cr);
1744 cairo_fill (cr);
1745
1746 cairo_restore (cr);
1747}
1748
1749static void
1750ctk_default_draw_arrow (CtkStyle *style,
1751 cairo_t *cr,
1752 CtkStateType state,
1753 CtkShadowType shadow G_GNUC_UNUSED__attribute__ ((__unused__)),
1754 CtkWidget *widget,
1755 const gchar *detail,
1756 CtkArrowType arrow_type,
1757 gboolean fill G_GNUC_UNUSED__attribute__ ((__unused__)),
1758 gint x,
1759 gint y,
1760 gint width,
1761 gint height)
1762{
1763 CtkStyleContext *context;
1764 CtkStylePrivate *priv;
1765 CtkStateFlags flags = 0;
1766 gdouble angle, size;
1767
1768 if (arrow_type == CTK_ARROW_NONE)
1769 return;
1770
1771 if (widget)
1772 context = ctk_widget_get_style_context (widget);
1773 else
1774 {
1775 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1776 context = priv->context;
1777 }
1778
1779 ctk_style_context_save (context);
1780
1781 if (detail)
1782 transform_detail_string (detail, context);
1783
1784 switch (arrow_type)
1785 {
1786 case CTK_ARROW_UP:
1787 angle = 0;
1788 size = width;
1789 break;
1790 case CTK_ARROW_RIGHT:
1791 angle = G_PI3.1415926535897932384626433832795028841971693993751 / 2;
1792 size = height;
1793 break;
1794 case CTK_ARROW_DOWN:
1795 angle = G_PI3.1415926535897932384626433832795028841971693993751;
1796 size = width;
1797 break;
1798 case CTK_ARROW_LEFT:
1799 angle = 3 * (G_PI3.1415926535897932384626433832795028841971693993751 / 2);
1800 size = height;
1801 break;
1802 default:
1803 g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkstyle.c", 1803, ((const
char*) (__func__)), ((void*)0)); } while (0)
;
1804 }
1805
1806 switch (state)
1807 {
1808 case CTK_STATE_PRELIGHT:
1809 flags |= CTK_STATE_FLAG_PRELIGHT;
1810 break;
1811 case CTK_STATE_SELECTED:
1812 flags |= CTK_STATE_FLAG_SELECTED;
1813 break;
1814 case CTK_STATE_INSENSITIVE:
1815 flags |= CTK_STATE_FLAG_INSENSITIVE;
1816 break;
1817 case CTK_STATE_ACTIVE:
1818 flags |= CTK_STATE_FLAG_ACTIVE;
1819 break;
1820 default:
1821 break;
1822 }
1823
1824 ctk_style_context_set_state (context, flags);
1825
1826 cairo_save (cr);
1827
1828 ctk_render_arrow (context,
1829 cr, angle,
1830 (gdouble) x,
1831 (gdouble) y,
1832 size);
1833
1834 cairo_restore (cr);
1835 ctk_style_context_restore (context);
1836}
1837
1838static void
1839ctk_default_draw_diamond (CtkStyle *style,
1840 cairo_t *cr,
1841 CtkStateType state_type,
1842 CtkShadowType shadow_type,
1843 CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
1844 const gchar *detail G_GNUC_UNUSED__attribute__ ((__unused__)),
1845 gint x,
1846 gint y,
1847 gint width,
1848 gint height)
1849{
1850 gint half_width;
1851 gint half_height;
1852 CdkColor *outer_nw = NULL((void*)0);
1853 CdkColor *outer_ne = NULL((void*)0);
1854 CdkColor *outer_sw = NULL((void*)0);
1855 CdkColor *outer_se = NULL((void*)0);
1856 CdkColor *middle_nw = NULL((void*)0);
1857 CdkColor *middle_ne = NULL((void*)0);
1858 CdkColor *middle_sw = NULL((void*)0);
1859 CdkColor *middle_se = NULL((void*)0);
1860 CdkColor *inner_nw = NULL((void*)0);
1861 CdkColor *inner_ne = NULL((void*)0);
1862 CdkColor *inner_sw = NULL((void*)0);
1863 CdkColor *inner_se = NULL((void*)0);
1864
1865 half_width = width / 2;
1866 half_height = height / 2;
1867
1868 switch (shadow_type)
1869 {
1870 case CTK_SHADOW_IN:
1871 inner_sw = inner_se = &style->bg[state_type];
1872 middle_sw = middle_se = &style->light[state_type];
1873 outer_sw = outer_se = &style->light[state_type];
1874 inner_nw = inner_ne = &style->black;
1875 middle_nw = middle_ne = &style->dark[state_type];
1876 outer_nw = outer_ne = &style->dark[state_type];
1877 break;
1878
1879 case CTK_SHADOW_OUT:
1880 inner_sw = inner_se = &style->dark[state_type];
1881 middle_sw = middle_se = &style->dark[state_type];
1882 outer_sw = outer_se = &style->black;
1883 inner_nw = inner_ne = &style->bg[state_type];
1884 middle_nw = middle_ne = &style->light[state_type];
1885 outer_nw = outer_ne = &style->light[state_type];
1886 break;
1887
1888 case CTK_SHADOW_ETCHED_IN:
1889 inner_sw = inner_se = &style->bg[state_type];
1890 middle_sw = middle_se = &style->dark[state_type];
1891 outer_sw = outer_se = &style->light[state_type];
1892 inner_nw = inner_ne = &style->bg[state_type];
1893 middle_nw = middle_ne = &style->light[state_type];
1894 outer_nw = outer_ne = &style->dark[state_type];
1895 break;
1896
1897 case CTK_SHADOW_ETCHED_OUT:
1898 inner_sw = inner_se = &style->bg[state_type];
1899 middle_sw = middle_se = &style->light[state_type];
1900 outer_sw = outer_se = &style->dark[state_type];
1901 inner_nw = inner_ne = &style->bg[state_type];
1902 middle_nw = middle_ne = &style->dark[state_type];
1903 outer_nw = outer_ne = &style->light[state_type];
1904 break;
1905
1906 default:
1907
1908 break;
1909 }
1910
1911 if (inner_sw)
1912 {
1913 _cairo_draw_line (cr, inner_sw,
1914 x + 2, y + half_height,
1915 x + half_width, y + height - 2);
1916 _cairo_draw_line (cr, inner_se,
1917 x + half_width, y + height - 2,
1918 x + width - 2, y + half_height);
1919 _cairo_draw_line (cr, middle_sw,
1920 x + 1, y + half_height,
1921 x + half_width, y + height - 1);
1922 _cairo_draw_line (cr, middle_se,
1923 x + half_width, y + height - 1,
1924 x + width - 1, y + half_height);
1925 _cairo_draw_line (cr, outer_sw,
1926 x, y + half_height,
1927 x + half_width, y + height);
1928 _cairo_draw_line (cr, outer_se,
1929 x + half_width, y + height,
1930 x + width, y + half_height);
1931
1932 _cairo_draw_line (cr, inner_nw,
1933 x + 2, y + half_height,
1934 x + half_width, y + 2);
1935 _cairo_draw_line (cr, inner_ne,
1936 x + half_width, y + 2,
1937 x + width - 2, y + half_height);
1938 _cairo_draw_line (cr, middle_nw,
1939 x + 1, y + half_height,
1940 x + half_width, y + 1);
1941 _cairo_draw_line (cr, middle_ne,
1942 x + half_width, y + 1,
1943 x + width - 1, y + half_height);
1944 _cairo_draw_line (cr, outer_nw,
1945 x, y + half_height,
1946 x + half_width, y);
1947 _cairo_draw_line (cr, outer_ne,
1948 x + half_width, y,
1949 x + width, y + half_height);
1950 }
1951}
1952
1953static void
1954option_menu_get_props (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
1955 CtkRequisition *indicator_size,
1956 CtkBorder *indicator_spacing)
1957{
1958 CtkRequisition *tmp_size = NULL((void*)0);
1959 CtkBorder *tmp_spacing = NULL((void*)0);
1960
1961 if (tmp_size)
1962 {
1963 *indicator_size = *tmp_size;
1964 ctk_requisition_free (tmp_size);
1965 }
1966 else
1967 *indicator_size = default_option_indicator_size;
1968
1969 if (tmp_spacing)
1970 {
1971 *indicator_spacing = *tmp_spacing;
1972 ctk_border_free (tmp_spacing);
1973 }
1974 else
1975 *indicator_spacing = default_option_indicator_spacing;
1976}
1977
1978static void
1979ctk_default_draw_box (CtkStyle *style,
1980 cairo_t *cr,
1981 CtkStateType state_type,
1982 CtkShadowType shadow_type,
1983 CtkWidget *widget,
1984 const gchar *detail,
1985 gint x,
1986 gint y,
1987 gint width,
1988 gint height)
1989{
1990 CtkStyleContext *context;
1991 CtkStylePrivate *priv;
1992 CtkStateFlags flags = 0;
1993
1994 if (widget)
1995 context = ctk_widget_get_style_context (widget);
1996 else
1997 {
1998 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
1999 context = priv->context;
2000 }
2001
2002 ctk_style_context_save (context);
2003
2004 if (detail)
2005 transform_detail_string (detail, context);
2006
2007 switch (state_type)
2008 {
2009 case CTK_STATE_ACTIVE:
2010 flags |= CTK_STATE_FLAG_ACTIVE;
2011 break;
2012 case CTK_STATE_PRELIGHT:
2013 flags |= CTK_STATE_FLAG_PRELIGHT;
2014 break;
2015 case CTK_STATE_SELECTED:
2016 flags |= CTK_STATE_FLAG_SELECTED;
2017 break;
2018 case CTK_STATE_INSENSITIVE:
2019 flags |= CTK_STATE_FLAG_INSENSITIVE;
2020 break;
2021 default:
2022 break;
2023 }
2024
2025 if (shadow_type == CTK_SHADOW_IN)
2026 flags |= CTK_STATE_FLAG_ACTIVE;
2027
2028 ctk_style_context_set_state (context, flags);
2029
2030 cairo_save (cr);
2031
2032 ctk_render_background (context, cr, x, y, width, height);
2033
2034 if (shadow_type != CTK_SHADOW_NONE)
2035 ctk_render_frame (context, cr, x, y, width, height);
2036
2037 cairo_restore (cr);
2038 ctk_style_context_restore (context);
2039}
2040
2041static void
2042ctk_default_draw_flat_box (CtkStyle *style,
2043 cairo_t *cr,
2044 CtkStateType state_type,
2045 CtkShadowType shadow_type G_GNUC_UNUSED__attribute__ ((__unused__)),
2046 CtkWidget *widget,
2047 const gchar *detail,
2048 gint x,
2049 gint y,
2050 gint width,
2051 gint height)
2052{
2053 CtkStyleContext *context;
2054 CtkStylePrivate *priv;
2055 CtkStateFlags flags = 0;
2056
2057 if (widget)
2058 context = ctk_widget_get_style_context (widget);
2059 else
2060 {
2061 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2062 context = priv->context;
2063 }
2064
2065 ctk_style_context_save (context);
2066
2067 if (detail)
2068 transform_detail_string (detail, context);
2069
2070 switch (state_type)
2071 {
2072 case CTK_STATE_PRELIGHT:
2073 flags |= CTK_STATE_FLAG_PRELIGHT;
2074 break;
2075 case CTK_STATE_SELECTED:
2076 flags |= CTK_STATE_FLAG_SELECTED;
2077 break;
2078 case CTK_STATE_INSENSITIVE:
2079 flags |= CTK_STATE_FLAG_INSENSITIVE;
2080 break;
2081 case CTK_STATE_ACTIVE:
2082 flags |= CTK_STATE_FLAG_ACTIVE;
2083 break;
2084 case CTK_STATE_FOCUSED:
2085 flags |= CTK_STATE_FLAG_FOCUSED;
2086 break;
2087 default:
2088 break;
2089 }
2090
2091 ctk_style_context_set_state (context, flags);
2092
2093 cairo_save (cr);
2094
2095 ctk_render_background (context, cr,
2096 (gdouble) x,
2097 (gdouble) y,
2098 (gdouble) width,
2099 (gdouble) height);
2100
2101 cairo_restore (cr);
2102 ctk_style_context_restore (context);
2103}
2104
2105static void
2106ctk_default_draw_check (CtkStyle *style,
2107 cairo_t *cr,
2108 CtkStateType state_type,
2109 CtkShadowType shadow_type,
2110 CtkWidget *widget,
2111 const gchar *detail,
2112 gint x,
2113 gint y,
2114 gint width,
2115 gint height)
2116{
2117 CtkStyleContext *context;
2118 CtkStylePrivate *priv;
2119 CtkStateFlags flags = 0;
2120
2121 if (widget)
2122 context = ctk_widget_get_style_context (widget);
2123 else
2124 {
2125 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2126 context = priv->context;
2127 }
2128
2129 ctk_style_context_save (context);
2130
2131 if (detail)
2132 transform_detail_string (detail, context);
2133
2134 switch (state_type)
2135 {
2136 case CTK_STATE_PRELIGHT:
2137 flags |= CTK_STATE_FLAG_PRELIGHT;
2138 break;
2139 case CTK_STATE_SELECTED:
2140 flags |= CTK_STATE_FLAG_SELECTED;
2141 break;
2142 case CTK_STATE_INSENSITIVE:
2143 flags |= CTK_STATE_FLAG_INSENSITIVE;
2144 break;
2145 default:
2146 break;
2147 }
2148
2149 if (shadow_type == CTK_SHADOW_IN)
2150 flags |= CTK_STATE_FLAG_ACTIVE;
2151 else if (shadow_type == CTK_SHADOW_ETCHED_IN)
2152 flags |= CTK_STATE_FLAG_INCONSISTENT;
2153
2154 ctk_style_context_set_state (context, flags);
2155
2156 cairo_save (cr);
2157
2158 ctk_render_check (context,
2159 cr, x, y,
2160 width, height);
2161
2162 cairo_restore (cr);
2163 ctk_style_context_restore (context);
2164}
2165
2166static void
2167ctk_default_draw_option (CtkStyle *style,
2168 cairo_t *cr,
2169 CtkStateType state_type,
2170 CtkShadowType shadow_type,
2171 CtkWidget *widget,
2172 const gchar *detail,
2173 gint x,
2174 gint y,
2175 gint width,
2176 gint height)
2177{
2178 CtkStyleContext *context;
2179 CtkStylePrivate *priv;
2180 CtkStateFlags flags = 0;
2181
2182 if (widget)
2183 context = ctk_widget_get_style_context (widget);
2184 else
2185 {
2186 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2187 context = priv->context;
2188 }
2189
2190 ctk_style_context_save (context);
2191
2192 if (detail)
2193 transform_detail_string (detail, context);
2194
2195 switch (state_type)
2196 {
2197 case CTK_STATE_PRELIGHT:
2198 flags |= CTK_STATE_FLAG_PRELIGHT;
2199 break;
2200 case CTK_STATE_SELECTED:
2201 flags |= CTK_STATE_FLAG_SELECTED;
2202 break;
2203 case CTK_STATE_INSENSITIVE:
2204 flags |= CTK_STATE_FLAG_INSENSITIVE;
2205 break;
2206 default:
2207 break;
2208 }
2209
2210 if (shadow_type == CTK_SHADOW_IN)
2211 flags |= CTK_STATE_FLAG_ACTIVE;
2212 else if (shadow_type == CTK_SHADOW_ETCHED_IN)
2213 flags |= CTK_STATE_FLAG_INCONSISTENT;
2214
2215 ctk_style_context_set_state (context, flags);
2216
2217 cairo_save (cr);
2218 ctk_render_option (context, cr,
2219 (gdouble) x,
2220 (gdouble) y,
2221 (gdouble) width,
2222 (gdouble) height);
2223
2224 cairo_restore (cr);
2225 ctk_style_context_restore (context);
2226}
2227
2228static void
2229ctk_default_draw_tab (CtkStyle *style,
2230 cairo_t *cr,
2231 CtkStateType state_type,
2232 CtkShadowType shadow_type G_GNUC_UNUSED__attribute__ ((__unused__)),
2233 CtkWidget *widget,
2234 const gchar *detail G_GNUC_UNUSED__attribute__ ((__unused__)),
2235 gint x,
2236 gint y,
2237 gint width,
2238 gint height)
2239{
2240#define ARROW_SPACE4 4
2241
2242 CtkRequisition indicator_size;
2243 CtkBorder indicator_spacing;
2244 gint arrow_height;
2245
2246 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2247
2248 indicator_size.width += (indicator_size.width % 2) - 1;
2249 arrow_height = indicator_size.width / 2 + 1;
2250
2251 x += (width - indicator_size.width) / 2;
2252 y += (height - (2 * arrow_height + ARROW_SPACE4)) / 2;
2253
2254 if (state_type == CTK_STATE_INSENSITIVE)
2255 {
2256 draw_arrow (cr, &style->white,
2257 CTK_ARROW_UP, x + 1, y + 1,
2258 indicator_size.width, arrow_height);
2259
2260 draw_arrow (cr, &style->white,
2261 CTK_ARROW_DOWN, x + 1, y + arrow_height + ARROW_SPACE4 + 1,
2262 indicator_size.width, arrow_height);
2263 }
2264
2265 draw_arrow (cr, &style->fg[state_type],
2266 CTK_ARROW_UP, x, y,
2267 indicator_size.width, arrow_height);
2268
2269
2270 draw_arrow (cr, &style->fg[state_type],
2271 CTK_ARROW_DOWN, x, y + arrow_height + ARROW_SPACE4,
2272 indicator_size.width, arrow_height);
2273}
2274
2275static void
2276ctk_default_draw_shadow_gap (CtkStyle *style,
2277 cairo_t *cr,
2278 CtkStateType state_type,
2279 CtkShadowType shadow_type,
2280 CtkWidget *widget,
2281 const gchar *detail,
2282 gint x,
2283 gint y,
2284 gint width,
2285 gint height,
2286 CtkPositionType gap_side,
2287 gint gap_x,
2288 gint gap_width)
2289{
2290 CtkStyleContext *context;
2291 CtkStylePrivate *priv;
2292 CtkStateFlags flags = 0;
2293
2294 if (shadow_type == CTK_SHADOW_NONE)
2295 return;
2296
2297 if (widget)
2298 context = ctk_widget_get_style_context (widget);
2299 else
2300 {
2301 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2302 context = priv->context;
2303 }
2304
2305 ctk_style_context_save (context);
2306
2307 if (detail)
2308 transform_detail_string (detail, context);
2309
2310 switch (state_type)
2311 {
2312 case CTK_STATE_ACTIVE:
2313 flags |= CTK_STATE_FLAG_ACTIVE;
2314 break;
2315 case CTK_STATE_PRELIGHT:
2316 flags |= CTK_STATE_FLAG_PRELIGHT;
2317 break;
2318 case CTK_STATE_SELECTED:
2319 flags |= CTK_STATE_FLAG_SELECTED;
2320 break;
2321 case CTK_STATE_INSENSITIVE:
2322 flags |= CTK_STATE_FLAG_INSENSITIVE;
2323 break;
2324 default:
2325 break;
2326 }
2327
2328 ctk_style_context_set_state (context, flags);
2329
2330 cairo_save (cr);
2331 ctk_render_frame_gap (context, cr,
2332 (gdouble) x,
2333 (gdouble) y,
2334 (gdouble) width,
2335 (gdouble) height,
2336 gap_side,
2337 (gdouble) gap_x,
2338 (gdouble) gap_x + gap_width);
2339
2340 cairo_restore (cr);
2341 ctk_style_context_restore (context);
2342}
2343
2344static void
2345ctk_default_draw_box_gap (CtkStyle *style,
2346 cairo_t *cr,
2347 CtkStateType state_type,
2348 CtkShadowType shadow_type,
2349 CtkWidget *widget,
2350 const gchar *detail,
2351 gint x,
2352 gint y,
2353 gint width,
2354 gint height,
2355 CtkPositionType gap_side,
2356 gint gap_x,
2357 gint gap_width)
2358{
2359 CtkStyleContext *context;
2360 CtkStylePrivate *priv;
2361 CtkStateFlags flags = 0;
2362
2363 if (widget)
2364 context = ctk_widget_get_style_context (widget);
2365 else
2366 {
2367 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2368 context = priv->context;
2369 }
2370
2371 ctk_style_context_save (context);
2372
2373 if (detail)
2374 transform_detail_string (detail, context);
2375
2376 switch (state_type)
2377 {
2378 case CTK_STATE_ACTIVE:
2379 flags |= CTK_STATE_FLAG_ACTIVE;
2380 break;
2381 case CTK_STATE_PRELIGHT:
2382 flags |= CTK_STATE_FLAG_PRELIGHT;
2383 break;
2384 case CTK_STATE_SELECTED:
2385 flags |= CTK_STATE_FLAG_SELECTED;
2386 break;
2387 case CTK_STATE_INSENSITIVE:
2388 flags |= CTK_STATE_FLAG_INSENSITIVE;
2389 break;
2390 default:
2391 break;
2392 }
2393
2394 ctk_style_context_set_state (context, flags);
2395
2396 cairo_save (cr);
2397 ctk_render_background (context, cr,
2398 (gdouble) x,
2399 (gdouble) y,
2400 (gdouble) width,
2401 (gdouble) height);
2402
2403
2404 if (shadow_type != CTK_SHADOW_NONE)
2405 ctk_render_frame_gap (context, cr,
2406 (gdouble) x,
2407 (gdouble) y,
2408 (gdouble) width,
2409 (gdouble) height,
2410 gap_side,
2411 (gdouble) gap_x,
2412 (gdouble) gap_x + gap_width);
2413
2414 cairo_restore (cr);
2415 ctk_style_context_restore (context);
2416}
2417
2418static void
2419ctk_default_draw_extension (CtkStyle *style,
2420 cairo_t *cr,
2421 CtkStateType state_type,
2422 CtkShadowType shadow_type G_GNUC_UNUSED__attribute__ ((__unused__)),
2423 CtkWidget *widget,
2424 const gchar *detail,
2425 gint x,
2426 gint y,
2427 gint width,
2428 gint height,
2429 CtkPositionType gap_side)
2430{
2431 CtkStyleContext *context;
2432 CtkStylePrivate *priv;
2433 CtkStateFlags flags = 0;
2434
2435 if (widget)
2436 context = ctk_widget_get_style_context (widget);
2437 else
2438 {
2439 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2440 context = priv->context;
2441 }
2442
2443 ctk_style_context_save (context);
2444
2445 if (detail)
2446 transform_detail_string (detail, context);
2447
2448 switch (state_type)
2449 {
2450 case CTK_STATE_ACTIVE:
2451 flags |= CTK_STATE_FLAG_ACTIVE;
2452 break;
2453 case CTK_STATE_PRELIGHT:
2454 flags |= CTK_STATE_FLAG_PRELIGHT;
2455 break;
2456 case CTK_STATE_SELECTED:
2457 flags |= CTK_STATE_FLAG_SELECTED;
2458 break;
2459 case CTK_STATE_INSENSITIVE:
2460 flags |= CTK_STATE_FLAG_INSENSITIVE;
2461 break;
2462 default:
2463 break;
2464 }
2465
2466 ctk_style_context_set_state (context, flags);
2467
2468 cairo_save (cr);
2469
2470 ctk_render_extension (context, cr,
2471 (gdouble) x,
2472 (gdouble) y,
2473 (gdouble) width,
2474 (gdouble) height,
2475 gap_side);
2476
2477 cairo_restore (cr);
2478 ctk_style_context_restore (context);
2479}
2480
2481static void
2482ctk_default_draw_focus (CtkStyle *style,
2483 cairo_t *cr,
2484 CtkStateType state_type G_GNUC_UNUSED__attribute__ ((__unused__)),
2485 CtkWidget *widget,
2486 const gchar *detail,
2487 gint x,
2488 gint y,
2489 gint width,
2490 gint height)
2491{
2492 CtkStyleContext *context;
2493 CtkStylePrivate *priv;
2494
2495 if (widget)
2496 context = ctk_widget_get_style_context (widget);
2497 else
2498 {
2499 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2500 context = priv->context;
2501 }
2502
2503 ctk_style_context_save (context);
2504
2505 if (detail)
2506 transform_detail_string (detail, context);
2507
2508 cairo_save (cr);
2509
2510 ctk_render_focus (context, cr,
2511 (gdouble) x,
2512 (gdouble) y,
2513 (gdouble) width,
2514 (gdouble) height);
2515
2516 cairo_restore (cr);
2517 ctk_style_context_restore (context);
2518}
2519
2520static void
2521ctk_default_draw_slider (CtkStyle *style,
2522 cairo_t *cr,
2523 CtkStateType state_type,
2524 CtkShadowType shadow_type G_GNUC_UNUSED__attribute__ ((__unused__)),
2525 CtkWidget *widget,
2526 const gchar *detail,
2527 gint x,
2528 gint y,
2529 gint width,
2530 gint height,
2531 CtkOrientation orientation)
2532{
2533 CtkStyleContext *context;
2534 CtkStylePrivate *priv;
2535 CtkStateFlags flags = 0;
2536
2537 if (widget)
2538 context = ctk_widget_get_style_context (widget);
2539 else
2540 {
2541 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2542 context = priv->context;
2543 }
2544
2545 ctk_style_context_save (context);
2546
2547 if (detail)
2548 transform_detail_string (detail, context);
2549
2550 switch (state_type)
2551 {
2552 case CTK_STATE_PRELIGHT:
2553 flags |= CTK_STATE_FLAG_PRELIGHT;
2554 break;
2555 case CTK_STATE_SELECTED:
2556 flags |= CTK_STATE_FLAG_SELECTED;
2557 break;
2558 case CTK_STATE_INSENSITIVE:
2559 flags |= CTK_STATE_FLAG_INSENSITIVE;
2560 break;
2561 default:
2562 break;
2563 }
2564
2565 ctk_style_context_set_state (context, flags);
2566
2567 cairo_save (cr);
2568
2569 ctk_render_slider (context, cr, x, y, width, height, orientation);
2570
2571 cairo_restore (cr);
2572 ctk_style_context_restore (context);
2573}
2574
2575static void
2576ctk_default_draw_handle (CtkStyle *style,
2577 cairo_t *cr,
2578 CtkStateType state_type,
2579 CtkShadowType shadow_type G_GNUC_UNUSED__attribute__ ((__unused__)),
2580 CtkWidget *widget,
2581 const gchar *detail,
2582 gint x,
2583 gint y,
2584 gint width,
2585 gint height,
2586 CtkOrientation orientation G_GNUC_UNUSED__attribute__ ((__unused__)))
2587{
2588 CtkStyleContext *context;
2589 CtkStylePrivate *priv;
2590 CtkStateFlags flags = 0;
2591
2592 if (widget)
2593 context = ctk_widget_get_style_context (widget);
2594 else
2595 {
2596 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2597 context = priv->context;
2598 }
2599
2600 ctk_style_context_save (context);
2601
2602 if (detail)
2603 transform_detail_string (detail, context);
2604
2605 switch (state_type)
2606 {
2607 case CTK_STATE_PRELIGHT:
2608 flags |= CTK_STATE_FLAG_PRELIGHT;
2609 break;
2610 case CTK_STATE_SELECTED:
2611 flags |= CTK_STATE_FLAG_SELECTED;
2612 break;
2613 case CTK_STATE_INSENSITIVE:
2614 flags |= CTK_STATE_FLAG_INSENSITIVE;
2615 break;
2616 default:
2617 break;
2618 }
2619
2620 ctk_style_context_set_state (context, flags);
2621
2622 cairo_save (cr);
2623
2624 ctk_render_handle (context, cr,
2625 (gdouble) x,
2626 (gdouble) y,
2627 (gdouble) width,
2628 (gdouble) height);
2629
2630 cairo_restore (cr);
2631 ctk_style_context_restore (context);
2632}
2633
2634static void
2635ctk_default_draw_expander (CtkStyle *style,
2636 cairo_t *cr,
2637 CtkStateType state_type,
2638 CtkWidget *widget,
2639 const gchar *detail,
2640 gint x,
2641 gint y,
2642 CtkExpanderStyle expander_style)
2643{
2644 CtkStyleContext *context;
2645 CtkStylePrivate *priv;
2646 CtkStateFlags flags = 0;
2647 gint size;
2648
2649 if (widget)
2650 context = ctk_widget_get_style_context (widget);
2651 else
2652 {
2653 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2654 context = priv->context;
2655 }
2656
2657 ctk_style_context_save (context);
2658
2659 if (detail)
2660 transform_detail_string (detail, context);
2661
2662 ctk_style_context_add_class (context, "expander");
2663
2664 switch (state_type)
2665 {
2666 case CTK_STATE_PRELIGHT:
2667 flags |= CTK_STATE_FLAG_PRELIGHT;
2668 break;
2669 case CTK_STATE_SELECTED:
2670 flags |= CTK_STATE_FLAG_SELECTED;
2671 break;
2672 case CTK_STATE_INSENSITIVE:
2673 flags |= CTK_STATE_FLAG_INSENSITIVE;
2674 break;
2675 default:
2676 break;
2677 }
2678
2679 if (widget &&
2680 ctk_widget_class_find_style_property (CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
,
2681 "expander-size"))
2682 ctk_widget_style_get (widget, "expander-size", &size, NULL((void*)0));
2683 else
2684 size = 12;
2685
2686 if (expander_style == CTK_EXPANDER_EXPANDED)
2687 flags |= CTK_STATE_FLAG_ACTIVE;
2688
2689 ctk_style_context_set_state (context, flags);
2690
2691 cairo_save (cr);
2692
2693 ctk_render_expander (context, cr,
2694 (gdouble) x - (size / 2),
2695 (gdouble) y - (size / 2),
2696 (gdouble) size,
2697 (gdouble) size);
2698
2699 cairo_restore (cr);
2700 ctk_style_context_restore (context);
2701}
2702
2703static void
2704ctk_default_draw_layout (CtkStyle *style,
2705 cairo_t *cr,
2706 CtkStateType state_type,
2707 gboolean use_text G_GNUC_UNUSED__attribute__ ((__unused__)),
2708 CtkWidget *widget,
2709 const gchar *detail,
2710 gint x,
2711 gint y,
2712 PangoLayout *layout)
2713{
2714 CtkStyleContext *context;
2715 CtkStylePrivate *priv;
2716 CtkStateFlags flags = 0;
2717
2718 if (widget)
2719 context = ctk_widget_get_style_context (widget);
2720 else
2721 {
2722 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2723 context = priv->context;
2724 }
2725
2726 ctk_style_context_save (context);
2727
2728 if (detail)
2729 transform_detail_string (detail, context);
2730
2731 switch (state_type)
2732 {
2733 case CTK_STATE_PRELIGHT:
2734 flags |= CTK_STATE_FLAG_PRELIGHT;
2735 break;
2736 case CTK_STATE_SELECTED:
2737 flags |= CTK_STATE_FLAG_SELECTED;
2738 break;
2739 case CTK_STATE_INSENSITIVE:
2740 flags |= CTK_STATE_FLAG_INSENSITIVE;
2741 break;
2742 default:
2743 break;
2744 }
2745
2746 ctk_style_context_set_state (context, flags);
2747
2748 cairo_save (cr);
2749
2750 ctk_render_layout (context, cr,
2751 (gdouble) x,
2752 (gdouble) y,
2753 layout);
2754
2755 cairo_restore (cr);
2756 ctk_style_context_restore (context);
2757}
2758
2759static void
2760ctk_default_draw_resize_grip (CtkStyle *style,
2761 cairo_t *cr,
2762 CtkStateType state_type,
2763 CtkWidget *widget,
2764 const gchar *detail,
2765 CdkWindowEdge edge,
2766 gint x,
2767 gint y,
2768 gint width,
2769 gint height)
2770{
2771 CtkStyleContext *context;
2772 CtkStylePrivate *priv;
2773 CtkStateFlags flags = 0;
2774 CtkJunctionSides sides = 0;
2775
2776 if (widget)
2777 context = ctk_widget_get_style_context (widget);
2778 else
2779 {
2780 priv = CTK_STYLE_GET_PRIVATE (style)((CtkStylePrivate *) ctk_style_get_instance_private ((CtkStyle
*) (style)))
;
2781 context = priv->context;
2782 }
2783
2784 ctk_style_context_save (context);
2785
2786 if (detail)
2787 transform_detail_string (detail, context);
2788
2789 ctk_style_context_add_class (context, "grip");
2790
2791 switch (state_type)
2792 {
2793 case CTK_STATE_PRELIGHT:
2794 flags |= CTK_STATE_FLAG_PRELIGHT;
2795 break;
2796 case CTK_STATE_SELECTED:
2797 flags |= CTK_STATE_FLAG_SELECTED;
2798 break;
2799 case CTK_STATE_INSENSITIVE:
2800 flags |= CTK_STATE_FLAG_INSENSITIVE;
2801 break;
2802 default:
2803 break;
2804 }
2805
2806 ctk_style_context_set_state (context, flags);
2807
2808 switch (edge)
2809 {
2810 case CDK_WINDOW_EDGE_NORTH_WEST:
2811 sides = CTK_JUNCTION_CORNER_TOPLEFT;
2812 break;
2813 case CDK_WINDOW_EDGE_NORTH:
2814 sides = CTK_JUNCTION_TOP;
2815 break;
2816 case CDK_WINDOW_EDGE_NORTH_EAST:
2817 sides = CTK_JUNCTION_CORNER_TOPRIGHT;
2818 break;
2819 case CDK_WINDOW_EDGE_WEST:
2820 sides = CTK_JUNCTION_LEFT;
2821 break;
2822 case CDK_WINDOW_EDGE_EAST:
2823 sides = CTK_JUNCTION_RIGHT;
2824 break;
2825 case CDK_WINDOW_EDGE_SOUTH_WEST:
2826 sides = CTK_JUNCTION_CORNER_BOTTOMLEFT;
2827 break;
2828 case CDK_WINDOW_EDGE_SOUTH:
2829 sides = CTK_JUNCTION_BOTTOM;
2830 break;
2831 case CDK_WINDOW_EDGE_SOUTH_EAST:
2832 sides = CTK_JUNCTION_CORNER_BOTTOMRIGHT;
2833 break;
2834 }
2835
2836 ctk_style_context_set_junction_sides (context, sides);
2837
2838 cairo_save (cr);
2839
2840 ctk_render_handle (context, cr,
2841 (gdouble) x,
2842 (gdouble) y,
2843 (gdouble) width,
2844 (gdouble) height);
2845
2846 cairo_restore (cr);
2847 ctk_style_context_restore (context);
2848}
2849
2850static void
2851ctk_default_draw_spinner (CtkStyle *style,
2852 cairo_t *cr,
2853 CtkStateType state_type,
2854 CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
2855 const gchar *detail G_GNUC_UNUSED__attribute__ ((__unused__)),
2856 guint step,
2857 gint x,
2858 gint y,
2859 gint width,
2860 gint height)
2861{
2862 CdkColor *color;
2863 guint num_steps;
2864 gdouble dx, dy;
2865 gdouble radius;
2866 gdouble half;
2867 gint i;
2868 guint real_step;
2869
2870 num_steps = 12;
2871 real_step = step % num_steps;
2872
2873 /* set a clip region for the expose event */
2874 cairo_rectangle (cr, x, y, width, height);
2875 cairo_clip (cr);
2876
2877 cairo_translate (cr, x, y);
2878
2879 /* draw clip region */
2880 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2881
2882 color = &style->fg[state_type];
2883 dx = width / 2;
2884 dy = height / 2;
2885 radius = MIN (width / 2, height / 2)(((width / 2) < (height / 2)) ? (width / 2) : (height / 2)
)
;
2886 half = num_steps / 2;
2887
2888 for (i = 0; i < num_steps; i++)
2889 {
2890 gint inset = 0.7 * radius;
2891
2892 /* transparency is a function of time and intial value */
2893 gdouble t = (gdouble) ((i + num_steps - real_step)
2894 % num_steps) / num_steps;
2895
2896 cairo_save (cr);
2897
2898 cairo_set_source_rgba (cr,
2899 color->red / 65535.,
2900 color->green / 65535.,
2901 color->blue / 65535.,
2902 t);
2903
2904 cairo_set_line_width (cr, 2.0);
2905 cairo_move_to (cr,
2906 dx + (radius - inset) * cos (i * G_PI3.1415926535897932384626433832795028841971693993751 / half),
2907 dy + (radius - inset) * sin (i * G_PI3.1415926535897932384626433832795028841971693993751 / half));
2908 cairo_line_to (cr,
2909 dx + radius * cos (i * G_PI3.1415926535897932384626433832795028841971693993751 / half),
2910 dy + radius * sin (i * G_PI3.1415926535897932384626433832795028841971693993751 / half));
2911 cairo_stroke (cr);
2912
2913 cairo_restore (cr);
2914 }
2915}
2916
2917void
2918_ctk_style_shade (const CdkColor *a,
2919 CdkColor *b,
2920 gdouble k)
2921{
2922 gdouble red;
2923 gdouble green;
2924 gdouble blue;
2925
2926 red = (gdouble) a->red / 65535.0;
2927 green = (gdouble) a->green / 65535.0;
2928 blue = (gdouble) a->blue / 65535.0;
2929
2930 rgb_to_hls (&red, &green, &blue);
2931
2932 green *= k;
2933 if (green > 1.0)
2934 green = 1.0;
2935 else if (green < 0.0)
2936 green = 0.0;
2937
2938 blue *= k;
2939 if (blue > 1.0)
2940 blue = 1.0;
2941 else if (blue < 0.0)
2942 blue = 0.0;
2943
2944 hls_to_rgb (&red, &green, &blue);
2945
2946 b->red = red * 65535.0;
2947 b->green = green * 65535.0;
2948 b->blue = blue * 65535.0;
2949}
2950
2951static void
2952rgb_to_hls (gdouble *r,
2953 gdouble *g,
2954 gdouble *b)
2955{
2956 gdouble min;
2957 gdouble max;
2958 gdouble red;
2959 gdouble green;
2960 gdouble blue;
2961 gdouble h, l, s;
2962 gdouble delta;
2963
2964 red = *r;
2965 green = *g;
2966 blue = *b;
2967
2968 if (red > green)
2969 {
2970 if (red > blue)
2971 max = red;
2972 else
2973 max = blue;
2974
2975 if (green < blue)
2976 min = green;
2977 else
2978 min = blue;
2979 }
2980 else
2981 {
2982 if (green > blue)
2983 max = green;
2984 else
2985 max = blue;
2986
2987 if (red < blue)
2988 min = red;
2989 else
2990 min = blue;
2991 }
2992
2993 l = (max + min) / 2;
2994 s = 0;
2995 h = 0;
2996
2997 if (max != min)
2998 {
2999 if (l <= 0.5)
3000 s = (max - min) / (max + min);
3001 else
3002 s = (max - min) / (2 - max - min);
3003
3004 delta = max -min;
3005 if (red == max)
3006 h = (green - blue) / delta;
3007 else if (green == max)
3008 h = 2 + (blue - red) / delta;
3009 else if (blue == max)
3010 h = 4 + (red - green) / delta;
3011
3012 h *= 60;
3013 if (h < 0.0)
3014 h += 360;
3015 }
3016
3017 *r = h;
3018 *g = l;
3019 *b = s;
3020}
3021
3022static void
3023hls_to_rgb (gdouble *h,
3024 gdouble *l,
3025 gdouble *s)
3026{
3027 gdouble hue;
3028 gdouble lightness;
3029 gdouble saturation;
3030 gdouble m1, m2;
3031 gdouble r, g, b;
3032
3033 lightness = *l;
3034 saturation = *s;
3035
3036 if (lightness <= 0.5)
3037 m2 = lightness * (1 + saturation);
3038 else
3039 m2 = lightness + saturation - lightness * saturation;
3040 m1 = 2 * lightness - m2;
3041
3042 if (saturation == 0)
3043 {
3044 *h = lightness;
3045 *l = lightness;
3046 *s = lightness;
3047 }
3048 else
3049 {
3050 hue = *h + 120;
3051 while (hue > 360)
3052 hue -= 360;
3053 while (hue < 0)
3054 hue += 360;
3055
3056 if (hue < 60)
3057 r = m1 + (m2 - m1) * hue / 60;
3058 else if (hue < 180)
3059 r = m2;
3060 else if (hue < 240)
3061 r = m1 + (m2 - m1) * (240 - hue) / 60;
3062 else
3063 r = m1;
3064
3065 hue = *h;
3066 while (hue > 360)
3067 hue -= 360;
3068 while (hue < 0)
3069 hue += 360;
3070
3071 if (hue < 60)
3072 g = m1 + (m2 - m1) * hue / 60;
3073 else if (hue < 180)
3074 g = m2;
3075 else if (hue < 240)
3076 g = m1 + (m2 - m1) * (240 - hue) / 60;
3077 else
3078 g = m1;
3079
3080 hue = *h - 120;
3081 while (hue > 360)
3082 hue -= 360;
3083 while (hue < 0)
3084 hue += 360;
3085
3086 if (hue < 60)
3087 b = m1 + (m2 - m1) * hue / 60;
3088 else if (hue < 180)
3089 b = m2;
3090 else if (hue < 240)
3091 b = m1 + (m2 - m1) * (240 - hue) / 60;
3092 else
3093 b = m1;
3094
3095 *h = r;
3096 *l = g;
3097 *s = b;
3098 }
3099}
3100
3101
3102/**
3103 * ctk_paint_hline:
3104 * @style: a #CtkStyle
3105 * @cr: a #caio_t
3106 * @state_type: a state
3107 * @widget: (allow-none): the widget
3108 * @detail: (allow-none): a style detail
3109 * @x1: the starting x coordinate
3110 * @x2: the ending x coordinate
3111 * @y: the y coordinate
3112 *
3113 * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @cr
3114 * using the given style and state.
3115 **/
3116void
3117ctk_paint_hline (CtkStyle *style,
3118 cairo_t *cr,
3119 CtkStateType state_type,
3120 CtkWidget *widget,
3121 const gchar *detail,
3122 gint x1,
3123 gint x2,
3124 gint y)
3125{
3126 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3127 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3128 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_hline != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_hline != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_hline != NULL"
); return; } } while (0)
;
3129
3130 cairo_save (cr);
3131
3132 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_hline (style, cr, state_type,
3133 widget, detail,
3134 x1, x2, y);
3135
3136 cairo_restore (cr);
3137}
3138
3139/**
3140 * ctk_paint_vline:
3141 * @style: a #CtkStyle
3142 * @cr: a #cairo_t
3143 * @state_type: a state
3144 * @widget: (allow-none): the widget
3145 * @detail: (allow-none): a style detail
3146 * @y1_: the starting y coordinate
3147 * @y2_: the ending y coordinate
3148 * @x: the x coordinate
3149 *
3150 * Draws a vertical line from (@x, @y1_) to (@x, @y2_) in @cr
3151 * using the given style and state.
3152 */
3153void
3154ctk_paint_vline (CtkStyle *style,
3155 cairo_t *cr,
3156 CtkStateType state_type,
3157 CtkWidget *widget,
3158 const gchar *detail,
3159 gint y1_,
3160 gint y2_,
3161 gint x)
3162{
3163 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3164 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3165 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_vline != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_vline != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_vline != NULL"
); return; } } while (0)
;
3166
3167 cairo_save (cr);
3168
3169 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_vline (style, cr, state_type,
3170 widget, detail,
3171 y1_, y2_, x);
3172
3173 cairo_restore (cr);
3174}
3175
3176/**
3177 * ctk_paint_shadow:
3178 * @style: a #CtkStyle
3179 * @cr: a #cairo_t
3180 * @state_type: a state
3181 * @shadow_type: type of shadow to draw
3182 * @widget: (allow-none): the widget
3183 * @detail: (allow-none): a style detail
3184 * @x: x origin of the rectangle
3185 * @y: y origin of the rectangle
3186 * @width: width of the rectangle
3187 * @height: width of the rectangle
3188 *
3189 * Draws a shadow around the given rectangle in @cr
3190 * using the given style and state and shadow type.
3191 */
3192void
3193ctk_paint_shadow (CtkStyle *style,
3194 cairo_t *cr,
3195 CtkStateType state_type,
3196 CtkShadowType shadow_type,
3197 CtkWidget *widget,
3198 const gchar *detail,
3199 gint x,
3200 gint y,
3201 gint width,
3202 gint height)
3203{
3204 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3205 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_shadow != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_shadow != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_shadow != NULL"
); return; } } while (0)
;
3206 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3207 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3208 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3209
3210 cairo_save (cr);
3211
3212 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_shadow (style, cr, state_type, shadow_type,
3213 widget, detail,
3214 x, y, width, height);
3215
3216 cairo_restore (cr);
3217}
3218
3219/**
3220 * ctk_paint_arrow:
3221 * @style: a #CtkStyle
3222 * @cr: a #cairo_t
3223 * @state_type: a state
3224 * @shadow_type: the type of shadow to draw
3225 * @widget: (allow-none): the widget
3226 * @detail: (allow-none): a style detail
3227 * @arrow_type: the type of arrow to draw
3228 * @fill: %TRUE if the arrow tip should be filled
3229 * @x: x origin of the rectangle to draw the arrow in
3230 * @y: y origin of the rectangle to draw the arrow in
3231 * @width: width of the rectangle to draw the arrow in
3232 * @height: height of the rectangle to draw the arrow in
3233 *
3234 * Draws an arrow in the given rectangle on @cr using the given
3235 * parameters. @arrow_type determines the direction of the arrow.
3236 */
3237void
3238ctk_paint_arrow (CtkStyle *style,
3239 cairo_t *cr,
3240 CtkStateType state_type,
3241 CtkShadowType shadow_type,
3242 CtkWidget *widget,
3243 const gchar *detail,
3244 CtkArrowType arrow_type,
3245 gboolean fill,
3246 gint x,
3247 gint y,
3248 gint width,
3249 gint height)
3250{
3251 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3252 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_arrow != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_arrow != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_arrow != NULL"
); return; } } while (0)
;
3253 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3254 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3255 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3256
3257 cairo_save (cr);
3258
3259 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_arrow (style, cr, state_type, shadow_type,
3260 widget, detail,
3261 arrow_type, fill, x, y, width, height);
3262
3263 cairo_restore (cr);
3264}
3265
3266/**
3267 * ctk_paint_diamond:
3268 * @style: a #CtkStyle
3269 * @cr: a #cairo_t
3270 * @state_type: a state
3271 * @shadow_type: the type of shadow to draw
3272 * @widget: (allow-none): the widget
3273 * @detail: (allow-none): a style detail
3274 * @x: x origin of the rectangle to draw the diamond in
3275 * @y: y origin of the rectangle to draw the diamond in
3276 * @width: width of the rectangle to draw the diamond in
3277 * @height: height of the rectangle to draw the diamond in
3278 *
3279 * Draws a diamond in the given rectangle on @window using the given
3280 * parameters.
3281 */
3282void
3283ctk_paint_diamond (CtkStyle *style,
3284 cairo_t *cr,
3285 CtkStateType state_type,
3286 CtkShadowType shadow_type,
3287 CtkWidget *widget,
3288 const gchar *detail,
3289 gint x,
3290 gint y,
3291 gint width,
3292 gint height)
3293{
3294 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3295 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_diamond != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_diamond != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_diamond != NULL"
); return; } } while (0)
;
3296 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3297 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3298 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3299
3300 cairo_save (cr);
3301
3302 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_diamond (style, cr, state_type, shadow_type,
3303 widget, detail,
3304 x, y, width, height);
3305
3306 cairo_restore (cr);
3307}
3308
3309/**
3310 * ctk_paint_box:
3311 * @style: a #CtkStyle
3312 * @cr: a #cairo_t
3313 * @state_type: a state
3314 * @shadow_type: the type of shadow to draw
3315 * @widget: (allow-none): the widget
3316 * @detail: (allow-none): a style detail
3317 * @x: x origin of the box
3318 * @y: y origin of the box
3319 * @width: the width of the box
3320 * @height: the height of the box
3321 *
3322 * Draws a box on @cr with the given parameters.
3323 */
3324void
3325ctk_paint_box (CtkStyle *style,
3326 cairo_t *cr,
3327 CtkStateType state_type,
3328 CtkShadowType shadow_type,
3329 CtkWidget *widget,
3330 const gchar *detail,
3331 gint x,
3332 gint y,
3333 gint width,
3334 gint height)
3335{
3336 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3337 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_box != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_box != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_box != NULL"
); return; } } while (0)
;
3338 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3339
3340 cairo_save (cr);
3341
3342 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_box (style, cr, state_type, shadow_type,
3343 widget, detail,
3344 x, y, width, height);
3345
3346 cairo_restore (cr);
3347}
3348
3349/**
3350 * ctk_paint_flat_box:
3351 * @style: a #CtkStyle
3352 * @cr: a #cairo_t
3353 * @state_type: a state
3354 * @shadow_type: the type of shadow to draw
3355 * @widget: (allow-none): the widget
3356 * @detail: (allow-none): a style detail
3357 * @x: x origin of the box
3358 * @y: y origin of the box
3359 * @width: the width of the box
3360 * @height: the height of the box
3361 *
3362 * Draws a flat box on @cr with the given parameters.
3363 */
3364void
3365ctk_paint_flat_box (CtkStyle *style,
3366 cairo_t *cr,
3367 CtkStateType state_type,
3368 CtkShadowType shadow_type,
3369 CtkWidget *widget,
3370 const gchar *detail,
3371 gint x,
3372 gint y,
3373 gint width,
3374 gint height)
3375{
3376 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3377 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_flat_box != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL"
); return; } } while (0)
;
3378 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3379 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3380 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3381
3382 cairo_save (cr);
3383
3384 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_flat_box (style, cr, state_type, shadow_type,
3385 widget, detail,
3386 x, y, width, height);
3387
3388 cairo_restore (cr);
3389}
3390
3391/**
3392 * ctk_paint_check:
3393 * @style: a #CtkStyle
3394 * @cr: a #cairo_t
3395 * @state_type: a state
3396 * @shadow_type: the type of shadow to draw
3397 * @widget: (allow-none): the widget
3398 * @detail: (allow-none): a style detail
3399 * @x: x origin of the rectangle to draw the check in
3400 * @y: y origin of the rectangle to draw the check in
3401 * @width: the width of the rectangle to draw the check in
3402 * @height: the height of the rectangle to draw the check in
3403 *
3404 * Draws a check button indicator in the given rectangle on @cr with
3405 * the given parameters.
3406 */
3407void
3408ctk_paint_check (CtkStyle *style,
3409 cairo_t *cr,
3410 CtkStateType state_type,
3411 CtkShadowType shadow_type,
3412 CtkWidget *widget,
3413 const gchar *detail,
3414 gint x,
3415 gint y,
3416 gint width,
3417 gint height)
3418{
3419 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3420 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_check != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_check != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_check != NULL"
); return; } } while (0)
;
3421 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3422
3423 cairo_save (cr);
3424
3425 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_check (style, cr, state_type, shadow_type,
3426 widget, detail,
3427 x, y, width, height);
3428
3429 cairo_restore (cr);
3430}
3431
3432/**
3433 * ctk_paint_option:
3434 * @style: a #CtkStyle
3435 * @cr: a #cairo_t
3436 * @state_type: a state
3437 * @shadow_type: the type of shadow to draw
3438 * @widget: (allow-none): the widget
3439 * @detail: (allow-none): a style detail
3440 * @x: x origin of the rectangle to draw the option in
3441 * @y: y origin of the rectangle to draw the option in
3442 * @width: the width of the rectangle to draw the option in
3443 * @height: the height of the rectangle to draw the option in
3444 *
3445 * Draws a radio button indicator in the given rectangle on @cr with
3446 * the given parameters.
3447 */
3448void
3449ctk_paint_option (CtkStyle *style,
3450 cairo_t *cr,
3451 CtkStateType state_type,
3452 CtkShadowType shadow_type,
3453 CtkWidget *widget,
3454 const gchar *detail,
3455 gint x,
3456 gint y,
3457 gint width,
3458 gint height)
3459{
3460 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3461 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_option != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_option != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_option != NULL"
); return; } } while (0)
;
3462 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3463
3464 cairo_save (cr);
3465
3466 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_option (style, cr, state_type, shadow_type,
3467 widget, detail,
3468 x, y, width, height);
3469
3470 cairo_restore (cr);
3471}
3472
3473/**
3474 * ctk_paint_tab:
3475 * @style: a #CtkStyle
3476 * @cr: a #cairo_t
3477 * @state_type: a state
3478 * @shadow_type: the type of shadow to draw
3479 * @widget: (allow-none): the widget
3480 * @detail: (allow-none): a style detail
3481 * @x: x origin of the rectangle to draw the tab in
3482 * @y: y origin of the rectangle to draw the tab in
3483 * @width: the width of the rectangle to draw the tab in
3484 * @height: the height of the rectangle to draw the tab in
3485 *
3486 * Draws an option menu tab (i.e. the up and down pointing arrows)
3487 * in the given rectangle on @cr using the given parameters.
3488 */
3489void
3490ctk_paint_tab (CtkStyle *style,
3491 cairo_t *cr,
3492 CtkStateType state_type,
3493 CtkShadowType shadow_type,
3494 CtkWidget *widget,
3495 const gchar *detail,
3496 gint x,
3497 gint y,
3498 gint width,
3499 gint height)
3500{
3501 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3502 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_tab != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_tab != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_tab != NULL"
); return; } } while (0)
;
3503 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3504
3505 cairo_save (cr);
3506
3507 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_tab (style, cr, state_type, shadow_type,
3508 widget, detail,
3509 x, y, width, height);
3510
3511 cairo_restore (cr);
3512}
3513
3514/**
3515 * ctk_paint_shadow_gap:
3516 * @style: a #CtkStyle
3517 * @cr: a #cairo_t
3518 * @state_type: a state
3519 * @shadow_type: type of shadow to draw
3520 * @widget: (allow-none): the widget
3521 * @detail: (allow-none): a style detail
3522 * @x: x origin of the rectangle
3523 * @y: y origin of the rectangle
3524 * @width: width of the rectangle
3525 * @height: width of the rectangle
3526 * @gap_side: side in which to leave the gap
3527 * @gap_x: starting position of the gap
3528 * @gap_width: width of the gap
3529 *
3530 * Draws a shadow around the given rectangle in @cr
3531 * using the given style and state and shadow type, leaving a
3532 * gap in one side.
3533 */
3534void
3535ctk_paint_shadow_gap (CtkStyle *style,
3536 cairo_t *cr,
3537 CtkStateType state_type,
3538 CtkShadowType shadow_type,
3539 CtkWidget *widget,
3540 const gchar *detail,
3541 gint x,
3542 gint y,
3543 gint width,
3544 gint height,
3545 CtkPositionType gap_side,
3546 gint gap_x,
3547 gint gap_width)
3548{
3549 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3550 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_shadow_gap != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL"
); return; } } while (0)
;
3551 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3552 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3553 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3554
3555 cairo_save (cr);
3556
3557 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_shadow_gap (style, cr, state_type, shadow_type,
3558 widget, detail,
3559 x, y, width, height, gap_side, gap_x, gap_width);
3560
3561 cairo_restore (cr);
3562}
3563
3564/**
3565 * ctk_paint_box_gap:
3566 * @style: a #CtkStyle
3567 * @cr: a #cairo_t
3568 * @state_type: a state
3569 * @shadow_type: type of shadow to draw
3570 * @widget: (allow-none): the widget
3571 * @detail: (allow-none): a style detail
3572 * @x: x origin of the rectangle
3573 * @y: y origin of the rectangle
3574 * @width: width of the rectangle
3575 * @height: width of the rectangle
3576 * @gap_side: side in which to leave the gap
3577 * @gap_x: starting position of the gap
3578 * @gap_width: width of the gap
3579 *
3580 * Draws a box in @cr using the given style and state and shadow type,
3581 * leaving a gap in one side.
3582 */
3583void
3584ctk_paint_box_gap (CtkStyle *style,
3585 cairo_t *cr,
3586 CtkStateType state_type,
3587 CtkShadowType shadow_type,
3588 CtkWidget *widget,
3589 const gchar *detail,
3590 gint x,
3591 gint y,
3592 gint width,
3593 gint height,
3594 CtkPositionType gap_side,
3595 gint gap_x,
3596 gint gap_width)
3597{
3598 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3599 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_box_gap != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL"
); return; } } while (0)
;
3600 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3601 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3602 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3603
3604 cairo_save (cr);
3605
3606 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_box_gap (style, cr, state_type, shadow_type,
3607 widget, detail,
3608 x, y, width, height, gap_side, gap_x, gap_width);
3609
3610 cairo_restore (cr);
3611}
3612
3613/**
3614 * ctk_paint_extension:
3615 * @style: a #CtkStyle
3616 * @cr: a #cairo_t
3617 * @state_type: a state
3618 * @shadow_type: type of shadow to draw
3619 * @widget: (allow-none): the widget
3620 * @detail: (allow-none): a style detail
3621 * @x: x origin of the extension
3622 * @y: y origin of the extension
3623 * @width: width of the extension
3624 * @height: width of the extension
3625 * @gap_side: the side on to which the extension is attached
3626 *
3627 * Draws an extension, i.e. a notebook tab.
3628 **/
3629void
3630ctk_paint_extension (CtkStyle *style,
3631 cairo_t *cr,
3632 CtkStateType state_type,
3633 CtkShadowType shadow_type,
3634 CtkWidget *widget,
3635 const gchar *detail,
3636 gint x,
3637 gint y,
3638 gint width,
3639 gint height,
3640 CtkPositionType gap_side)
3641{
3642 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3643 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_extension != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_extension != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_extension != NULL"
); return; } } while (0)
;
3644 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3645 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3646 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3647
3648 cairo_save (cr);
3649
3650 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_extension (style, cr, state_type, shadow_type,
3651 widget, detail,
3652 x, y, width, height, gap_side);
3653
3654 cairo_restore (cr);
3655}
3656
3657/**
3658 * ctk_paint_focus:
3659 * @style: a #CtkStyle
3660 * @cr: a #cairo_t
3661 * @state_type: a state
3662 * @widget: (allow-none): the widget
3663 * @detail: (allow-none): a style detail
3664 * @x: the x origin of the rectangle around which to draw a focus indicator
3665 * @y: the y origin of the rectangle around which to draw a focus indicator
3666 * @width: the width of the rectangle around which to draw a focus indicator
3667 * @height: the height of the rectangle around which to draw a focus indicator
3668 *
3669 * Draws a focus indicator around the given rectangle on @cr using the
3670 * given style.
3671 */
3672void
3673ctk_paint_focus (CtkStyle *style,
3674 cairo_t *cr,
3675 CtkStateType state_type,
3676 CtkWidget *widget,
3677 const gchar *detail,
3678 gint x,
3679 gint y,
3680 gint width,
3681 gint height)
3682{
3683 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3684 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_focus != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_focus != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_focus != NULL"
); return; } } while (0)
;
3685 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3686 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3687 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3688
3689 cairo_save (cr);
3690
3691 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_focus (style, cr, state_type,
3692 widget, detail,
3693 x, y, width, height);
3694
3695 cairo_restore (cr);
3696}
3697
3698/**
3699 * ctk_paint_slider:
3700 * @style: a #CtkStyle
3701 * @cr: a #cairo_t
3702 * @state_type: a state
3703 * @shadow_type: a shadow
3704 * @widget: (allow-none): the widget
3705 * @detail: (allow-none): a style detail
3706 * @x: the x origin of the rectangle in which to draw a slider
3707 * @y: the y origin of the rectangle in which to draw a slider
3708 * @width: the width of the rectangle in which to draw a slider
3709 * @height: the height of the rectangle in which to draw a slider
3710 * @orientation: the orientation to be used
3711 *
3712 * Draws a slider in the given rectangle on @cr using the
3713 * given style and orientation.
3714 **/
3715void
3716ctk_paint_slider (CtkStyle *style,
3717 cairo_t *cr,
3718 CtkStateType state_type,
3719 CtkShadowType shadow_type,
3720 CtkWidget *widget,
3721 const gchar *detail,
3722 gint x,
3723 gint y,
3724 gint width,
3725 gint height,
3726 CtkOrientation orientation)
3727{
3728 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3729 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_slider != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_slider != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_slider != NULL"
); return; } } while (0)
;
3730 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3731 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3732 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3733
3734 cairo_save (cr);
3735
3736 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_slider (style, cr, state_type, shadow_type,
3737 widget, detail,
3738 x, y, width, height, orientation);
3739
3740 cairo_restore (cr);
3741}
3742
3743/**
3744 * ctk_paint_handle:
3745 * @style: a #CtkStyle
3746 * @cr: a #cairo_t
3747 * @state_type: a state
3748 * @shadow_type: type of shadow to draw
3749 * @widget: (allow-none): the widget
3750 * @detail: (allow-none): a style detail
3751 * @x: x origin of the handle
3752 * @y: y origin of the handle
3753 * @width: with of the handle
3754 * @height: height of the handle
3755 * @orientation: the orientation of the handle
3756 *
3757 * Draws a handle as used in #CtkHandleBox and #CtkPaned.
3758 **/
3759void
3760ctk_paint_handle (CtkStyle *style,
3761 cairo_t *cr,
3762 CtkStateType state_type,
3763 CtkShadowType shadow_type,
3764 CtkWidget *widget,
3765 const gchar *detail,
3766 gint x,
3767 gint y,
3768 gint width,
3769 gint height,
3770 CtkOrientation orientation)
3771{
3772 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3773 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_handle != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_handle != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_handle != NULL"
); return; } } while (0)
;
3774 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3775 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
3776 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
3777
3778 cairo_save (cr);
3779
3780 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_handle (style, cr, state_type, shadow_type,
3781 widget, detail,
3782 x, y, width, height, orientation);
3783
3784 cairo_restore (cr);
3785}
3786
3787/**
3788 * ctk_paint_expander:
3789 * @style: a #CtkStyle
3790 * @cr: a #cairo_t
3791 * @state_type: a state
3792 * @widget: (allow-none): the widget
3793 * @detail: (allow-none): a style detail
3794 * @x: the x position to draw the expander at
3795 * @y: the y position to draw the expander at
3796 * @expander_style: the style to draw the expander in; determines
3797 * whether the expander is collapsed, expanded, or in an
3798 * intermediate state.
3799 *
3800 * Draws an expander as used in #CtkTreeView. @x and @y specify the
3801 * center the expander. The size of the expander is determined by the
3802 * “expander-size” style property of @widget. (If widget is not
3803 * specified or doesn’t have an “expander-size” property, an
3804 * unspecified default size will be used, since the caller doesn't
3805 * have sufficient information to position the expander, this is
3806 * likely not useful.) The expander is expander_size pixels tall
3807 * in the collapsed position and expander_size pixels wide in the
3808 * expanded position.
3809 **/
3810void
3811ctk_paint_expander (CtkStyle *style,
3812 cairo_t *cr,
3813 CtkStateType state_type,
3814 CtkWidget *widget,
3815 const gchar *detail,
3816 gint x,
3817 gint y,
3818 CtkExpanderStyle expander_style)
3819{
3820 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3821 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_expander != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_expander != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_expander != NULL"
); return; } } while (0)
;
3822 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3823
3824 cairo_save (cr);
3825
3826 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_expander (style, cr, state_type,
3827 widget, detail,
3828 x, y, expander_style);
3829
3830 cairo_restore (cr);
3831}
3832
3833/**
3834 * ctk_paint_layout:
3835 * @style: a #CtkStyle
3836 * @cr: a #cairo_t
3837 * @state_type: a state
3838 * @use_text: whether to use the text or foreground
3839 * graphics context of @style
3840 * @widget: (allow-none): the widget
3841 * @detail: (allow-none): a style detail
3842 * @x: x origin
3843 * @y: y origin
3844 * @layout: the layout to draw
3845 *
3846 * Draws a layout on @cr using the given parameters.
3847 **/
3848void
3849ctk_paint_layout (CtkStyle *style,
3850 cairo_t *cr,
3851 CtkStateType state_type,
3852 gboolean use_text,
3853 CtkWidget *widget,
3854 const gchar *detail,
3855 gint x,
3856 gint y,
3857 PangoLayout *layout)
3858{
3859 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3860 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_layout != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_layout != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_layout != NULL"
); return; } } while (0)
;
3861 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3862
3863 cairo_save (cr);
3864
3865 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_layout (style, cr, state_type, use_text,
3866 widget, detail,
3867 x, y, layout);
3868
3869 cairo_restore (cr);
3870}
3871
3872/**
3873 * ctk_paint_resize_grip:
3874 * @style: a #CtkStyle
3875 * @cr: a #cairo_t
3876 * @state_type: a state
3877 * @widget: (allow-none): the widget
3878 * @detail: (allow-none): a style detail
3879 * @edge: the edge in which to draw the resize grip
3880 * @x: the x origin of the rectangle in which to draw the resize grip
3881 * @y: the y origin of the rectangle in which to draw the resize grip
3882 * @width: the width of the rectangle in which to draw the resize grip
3883 * @height: the height of the rectangle in which to draw the resize grip
3884 *
3885 * Draws a resize grip in the given rectangle on @cr using the given
3886 * parameters.
3887 */
3888void
3889ctk_paint_resize_grip (CtkStyle *style,
3890 cairo_t *cr,
3891 CtkStateType state_type,
3892 CtkWidget *widget,
3893 const gchar *detail,
3894 CdkWindowEdge edge,
3895 gint x,
3896 gint y,
3897 gint width,
3898 gint height)
3899{
3900 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3901 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_resize_grip != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL"
); return; } } while (0)
;
3902 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3903
3904 cairo_save (cr);
3905
3906 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_resize_grip (style, cr, state_type,
3907 widget, detail,
3908 edge, x, y, width, height);
3909 cairo_restore (cr);
3910}
3911
3912/**
3913 * ctk_paint_spinner:
3914 * @style: a #CtkStyle
3915 * @cr: a #cairo_t
3916 * @state_type: a state
3917 * @widget: (allow-none): the widget (may be %NULL)
3918 * @detail: (allow-none): a style detail (may be %NULL)
3919 * @step: the nth step
3920 * @x: the x origin of the rectangle in which to draw the spinner
3921 * @y: the y origin of the rectangle in which to draw the spinner
3922 * @width: the width of the rectangle in which to draw the spinner
3923 * @height: the height of the rectangle in which to draw the spinner
3924 *
3925 * Draws a spinner on @window using the given parameters.
3926 */
3927void
3928ctk_paint_spinner (CtkStyle *style,
3929 cairo_t *cr,
3930 CtkStateType state_type,
3931 CtkWidget *widget,
3932 const gchar *detail,
3933 guint step,
3934 gint x,
3935 gint y,
3936 gint width,
3937 gint height)
3938{
3939 g_return_if_fail (CTK_IS_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_STYLE (style)"); return; } } while (0)
;
3940 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
3941 g_return_if_fail (CTK_STYLE_GET_CLASS (style)->draw_spinner != NULL)do { if ((((((CtkStyleClass*) (((GTypeInstance*) ((style)))->
g_class))))->draw_spinner != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_STYLE_GET_CLASS (style)->draw_spinner != NULL"
); return; } } while (0)
;
3942
3943 cairo_save (cr);
3944
3945 CTK_STYLE_GET_CLASS (style)((((CtkStyleClass*) (((GTypeInstance*) ((style)))->g_class
))))
->draw_spinner (style, cr, state_type,
3946 widget, detail,
3947 step, x, y, width, height);
3948
3949 cairo_restore (cr);
3950}
3951
3952static CtkStyle *
3953ctk_widget_get_default_style_for_screen (CdkScreen *screen)
3954{
3955 CtkStyle *default_style;
3956
3957 if G_UNLIKELY (quark_default_style == 0)(quark_default_style == 0)
3958 quark_default_style = g_quark_from_static_string ("ctk-legacy-default-style");
3959
3960 default_style = g_object_get_qdata (G_OBJECT (screen)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), (((GType) ((20) << (2))))))))
, quark_default_style);
3961 if (default_style == NULL((void*)0))
3962 {
3963 default_style = ctk_style_new ();
3964 g_object_set_qdata_full (G_OBJECT (screen)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), (((GType) ((20) << (2))))))))
,
3965 quark_default_style,
3966 default_style,
3967 g_object_unref);
3968 }
3969
3970 return default_style;
3971}
3972
3973/**
3974 * ctk_widget_get_default_style:
3975 *
3976 * Returns the default style used by all widgets initially.
3977 *
3978 * Returns: (transfer none): the default style. This #CtkStyle
3979 * object is owned by CTK+ and should not be modified or freed.
3980 */
3981CtkStyle *
3982ctk_widget_get_default_style (void)
3983{
3984 static CtkStyle *default_style = NULL((void*)0);
3985 CtkStyle *style = NULL((void*)0);
3986 CdkScreen *screen = cdk_screen_get_default ();
3987
3988 if (screen)
3989 style = ctk_widget_get_default_style_for_screen (screen);
3990 else
3991 {
3992 if (default_style == NULL((void*)0))
3993 default_style = ctk_style_new ();
3994 style = default_style;
3995 }
3996
3997 return style;
3998}
3999
4000/**
4001 * ctk_widget_style_attach:
4002 * @widget: a #CtkWidget
4003 *
4004 * This function attaches the widget’s #CtkStyle to the widget's
4005 * #CdkWindow. It is a replacement for
4006 *
4007 * |[
4008 * widget->style = ctk_style_attach (widget->style, widget->window);
4009 * ]|
4010 *
4011 * and should only ever be called in a derived widget’s “realize”
4012 * implementation which does not chain up to its parent class'
4013 * “realize” implementation, because one of the parent classes
4014 * (finally #CtkWidget) would attach the style itself.
4015 *
4016 * Since: 2.20
4017 **/
4018void
4019ctk_widget_style_attach (CtkWidget *widget)
4020{
4021 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4022 g_return_if_fail (ctk_widget_get_realized (widget))do { if ((ctk_widget_get_realized (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "ctk_widget_get_realized (widget)"
); return; } } while (0)
;
4023}
4024
4025/**
4026 * ctk_widget_has_rc_style:
4027 * @widget: a #CtkWidget
4028 *
4029 * Determines if the widget style has been looked up through the rc mechanism.
4030 *
4031 * Returns: %TRUE if the widget has been looked up through the rc
4032 * mechanism, %FALSE otherwise.
4033 *
4034 * Since: 2.20
4035 **/
4036gboolean
4037ctk_widget_has_rc_style (CtkWidget *widget)
4038{
4039 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
4040
4041 return FALSE(0);
4042}
4043
4044/**
4045 * ctk_widget_set_style:
4046 * @widget: a #CtkWidget
4047 * @style: (allow-none): a #CtkStyle, or %NULL to remove the effect
4048 * of a previous call to ctk_widget_set_style() and go back to
4049 * the default style
4050 *
4051 * Used to set the #CtkStyle for a widget (@widget->style). Since
4052 * CTK 3, this function does nothing, the passed in style is ignored.
4053 */
4054void
4055ctk_widget_set_style (CtkWidget *widget,
4056 CtkStyle *style G_GNUC_UNUSED__attribute__ ((__unused__)))
4057{
4058 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4059}
4060
4061/**
4062 * ctk_widget_ensure_style:
4063 * @widget: a #CtkWidget
4064 *
4065 * Ensures that @widget has a style (@widget->style).
4066 *
4067 * Not a very useful function; most of the time, if you
4068 * want the style, the widget is realized, and realized
4069 * widgets are guaranteed to have a style already.
4070 */
4071void
4072ctk_widget_ensure_style (CtkWidget *widget)
4073{
4074 CtkStyle *style;
4075 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4076
4077 style = _ctk_widget_get_style (widget);
4078 if (style == ctk_widget_get_default_style ())
4079 {
4080 g_object_unref (style);
4081 _ctk_widget_set_style (widget, NULL((void*)0));
4082 }
4083}
4084
4085/**
4086 * ctk_widget_get_style:
4087 * @widget: a #CtkWidget
4088 *
4089 * Simply an accessor function that returns @widget->style.
4090 *
4091 * Returns: (transfer none): the widget’s #CtkStyle
4092 */
4093CtkStyle*
4094ctk_widget_get_style (CtkWidget *widget)
4095{
4096 CtkStyle *style;
4097 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
4098
4099 style = _ctk_widget_get_style (widget);
4100
4101 if (style == NULL((void*)0))
4102 {
4103 style = g_object_new (CTK_TYPE_STYLE(ctk_style_get_type ()),
4104 "context", ctk_widget_get_style_context (widget),
4105 NULL((void*)0));
4106 _ctk_widget_set_style (widget, style);
4107 }
4108
4109 return style;
4110}
4111
4112/**
4113 * ctk_widget_modify_style:
4114 * @widget: a #CtkWidget
4115 * @style: the #CtkRcStyle-struct holding the style modifications
4116 *
4117 * Modifies style values on the widget.
4118 *
4119 * Modifications made using this technique take precedence over
4120 * style values set via an RC file, however, they will be overridden
4121 * if a style is explicitly set on the widget using ctk_widget_set_style().
4122 * The #CtkRcStyle-struct is designed so each field can either be
4123 * set or unset, so it is possible, using this function, to modify some
4124 * style values and leave the others unchanged.
4125 *
4126 * Note that modifications made with this function are not cumulative
4127 * with previous calls to ctk_widget_modify_style() or with such
4128 * functions as ctk_widget_modify_fg(). If you wish to retain
4129 * previous values, you must first call ctk_widget_get_modifier_style(),
4130 * make your modifications to the returned style, then call
4131 * ctk_widget_modify_style() with that style. On the other hand,
4132 * if you first call ctk_widget_modify_style(), subsequent calls
4133 * to such functions ctk_widget_modify_fg() will have a cumulative
4134 * effect with the initial modifications.
4135 */
4136void
4137ctk_widget_modify_style (CtkWidget *widget,
4138 CtkRcStyle *style)
4139{
4140 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4141 g_return_if_fail (CTK_IS_RC_STYLE (style))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((style)); GType __t = ((ctk_rc_style_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_RC_STYLE (style)"); return; } } while (0)
;
4142
4143 g_object_set_data_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
4144 "ctk-rc-style",
4145 ctk_rc_style_copy (style),
4146 (GDestroyNotify) g_object_unref);
4147}
4148
4149/**
4150 * ctk_widget_get_modifier_style:
4151 * @widget: a #CtkWidget
4152 *
4153 * Returns the current modifier style for the widget. (As set by
4154 * ctk_widget_modify_style().) If no style has previously set, a new
4155 * #CtkRcStyle will be created with all values unset, and set as the
4156 * modifier style for the widget. If you make changes to this rc
4157 * style, you must call ctk_widget_modify_style(), passing in the
4158 * returned rc style, to make sure that your changes take effect.
4159 *
4160 * Caution: passing the style back to ctk_widget_modify_style() will
4161 * normally end up destroying it, because ctk_widget_modify_style() copies
4162 * the passed-in style and sets the copy as the new modifier style,
4163 * thus dropping any reference to the old modifier style. Add a reference
4164 * to the modifier style if you want to keep it alive.
4165 *
4166 * Returns: (transfer none): the modifier style for the widget.
4167 * This rc style is owned by the widget. If you want to keep a
4168 * pointer to value this around, you must add a refcount using
4169 * g_object_ref().
4170 */
4171CtkRcStyle *
4172ctk_widget_get_modifier_style (CtkWidget *widget)
4173{
4174 CtkRcStyle *rc_style;
4175
4176 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
4177
4178 rc_style = g_object_get_data (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "ctk-rc-style");
4179
4180 if (!rc_style)
4181 {
4182 rc_style = ctk_rc_style_new ();
4183 g_object_set_data_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
4184 "ctk-rc-style",
4185 rc_style,
4186 (GDestroyNotify) g_object_unref);
4187 }
4188
4189 return rc_style;
4190}
4191
4192static void
4193ctk_widget_modify_color_component (CtkWidget *widget,
4194 CtkRcFlags component,
4195 CtkStateType state,
4196 const CdkColor *color)
4197{
4198 CtkRcStyle *rc_style = ctk_widget_get_modifier_style (widget);
4199
4200 if (color)
4201 {
4202 switch (component)
4203 {
4204 case CTK_RC_FG:
4205 rc_style->fg[state] = *color;
4206 break;
4207 case CTK_RC_BG:
4208 rc_style->bg[state] = *color;
4209 break;
4210 case CTK_RC_TEXT:
4211 rc_style->text[state] = *color;
4212 break;
4213 case CTK_RC_BASE:
4214 rc_style->base[state] = *color;
4215 break;
4216 default:
4217 g_assert_not_reached()do { g_assertion_message_expr ("Ctk", "ctkstyle.c", 4217, ((const
char*) (__func__)), ((void*)0)); } while (0)
;
4218 }
4219
4220 rc_style->color_flags[state] |= component;
4221 }
4222 else
4223 rc_style->color_flags[state] &= ~component;
4224
4225 ctk_widget_modify_style (widget, rc_style);
4226}
4227
4228/**
4229 * ctk_widget_modify_fg:
4230 * @widget: a #CtkWidget
4231 * @state: the state for which to set the foreground color
4232 * @color: (allow-none): the color to assign (does not need to be allocated),
4233 * or %NULL to undo the effect of previous calls to
4234 * of ctk_widget_modify_fg().
4235 *
4236 * Sets the foreground color for a widget in a particular state.
4237 *
4238 * All other style values are left untouched.
4239 * See also ctk_widget_modify_style().
4240 */
4241void
4242ctk_widget_modify_fg (CtkWidget *widget,
4243 CtkStateType state,
4244 const CdkColor *color)
4245{
4246 CtkStateFlags flags;
4247 CdkRGBA rgba;
4248
4249 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4250 g_return_if_fail (state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE)do { if ((state >= CTK_STATE_NORMAL && state <=
CTK_STATE_INSENSITIVE)) { } else { g_return_if_fail_warning (
"Ctk", ((const char*) (__func__)), "state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE"
); return; } } while (0)
;
4251
4252 switch (state)
4253 {
4254 case CTK_STATE_ACTIVE:
4255 flags = CTK_STATE_FLAG_ACTIVE;
4256 break;
4257 case CTK_STATE_PRELIGHT:
4258 flags = CTK_STATE_FLAG_PRELIGHT;
4259 break;
4260 case CTK_STATE_SELECTED:
4261 flags = CTK_STATE_FLAG_SELECTED;
4262 break;
4263 case CTK_STATE_INSENSITIVE:
4264 flags = CTK_STATE_FLAG_INSENSITIVE;
4265 break;
4266 case CTK_STATE_NORMAL:
4267 default:
4268 flags = 0;
4269 }
4270
4271 if (color)
4272 {
4273 rgba.red = color->red / 65535.;
4274 rgba.green = color->green / 65535.;
4275 rgba.blue = color->blue / 65535.;
4276 rgba.alpha = 1;
4277
4278 ctk_widget_override_color (widget, flags, &rgba);
4279 }
4280 else
4281 ctk_widget_override_color (widget, flags, NULL((void*)0));
4282}
4283
4284/**
4285 * ctk_widget_modify_bg:
4286 * @widget: a #CtkWidget
4287 * @state: the state for which to set the background color
4288 * @color: (allow-none): the color to assign (does not need
4289 * to be allocated), or %NULL to undo the effect of previous
4290 * calls to of ctk_widget_modify_bg().
4291 *
4292 * Sets the background color for a widget in a particular state.
4293 *
4294 * All other style values are left untouched.
4295 * See also ctk_widget_modify_style().
4296 *
4297 * > Note that “no window” widgets (which have the %CTK_NO_WINDOW
4298 * > flag set) draw on their parent container’s window and thus may
4299 * > not draw any background themselves. This is the case for e.g.
4300 * > #CtkLabel.
4301 * >
4302 * > To modify the background of such widgets, you have to set the
4303 * > background color on their parent; if you want to set the background
4304 * > of a rectangular area around a label, try placing the label in
4305 * > a #CtkEventBox widget and setting the background color on that.
4306 */
4307void
4308ctk_widget_modify_bg (CtkWidget *widget,
4309 CtkStateType state,
4310 const CdkColor *color)
4311{
4312 CtkStateFlags flags;
4313 CdkRGBA rgba;
4314
4315 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4316 g_return_if_fail (state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE)do { if ((state >= CTK_STATE_NORMAL && state <=
CTK_STATE_INSENSITIVE)) { } else { g_return_if_fail_warning (
"Ctk", ((const char*) (__func__)), "state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE"
); return; } } while (0)
;
4317
4318 switch (state)
4319 {
4320 case CTK_STATE_ACTIVE:
4321 flags = CTK_STATE_FLAG_ACTIVE;
4322 break;
4323 case CTK_STATE_PRELIGHT:
4324 flags = CTK_STATE_FLAG_PRELIGHT;
4325 break;
4326 case CTK_STATE_SELECTED:
4327 flags = CTK_STATE_FLAG_SELECTED;
4328 break;
4329 case CTK_STATE_INSENSITIVE:
4330 flags = CTK_STATE_FLAG_INSENSITIVE;
4331 break;
4332 case CTK_STATE_NORMAL:
4333 default:
4334 flags = 0;
4335 }
4336
4337 if (color)
4338 {
4339 rgba.red = color->red / 65535.;
4340 rgba.green = color->green / 65535.;
4341 rgba.blue = color->blue / 65535.;
4342 rgba.alpha = 1;
4343
4344 ctk_widget_override_background_color (widget, flags, &rgba);
4345 }
4346 else
4347 ctk_widget_override_background_color (widget, flags, NULL((void*)0));
4348}
4349
4350/**
4351 * ctk_widget_modify_text:
4352 * @widget: a #CtkWidget
4353 * @state: the state for which to set the text color
4354 * @color: (allow-none): the color to assign (does not need to
4355 * be allocated), or %NULL to undo the effect of previous
4356 * calls to of ctk_widget_modify_text().
4357 *
4358 * Sets the text color for a widget in a particular state.
4359 *
4360 * All other style values are left untouched.
4361 * The text color is the foreground color used along with the
4362 * base color (see ctk_widget_modify_base()) for widgets such
4363 * as #CtkEntry and #CtkTextView.
4364 * See also ctk_widget_modify_style().
4365 */
4366void
4367ctk_widget_modify_text (CtkWidget *widget,
4368 CtkStateType state,
4369 const CdkColor *color)
4370{
4371 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4372 g_return_if_fail (state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE)do { if ((state >= CTK_STATE_NORMAL && state <=
CTK_STATE_INSENSITIVE)) { } else { g_return_if_fail_warning (
"Ctk", ((const char*) (__func__)), "state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE"
); return; } } while (0)
;
4373
4374 ctk_widget_modify_color_component (widget, CTK_RC_TEXT, state, color);
4375}
4376
4377/**
4378 * ctk_widget_modify_base:
4379 * @widget: a #CtkWidget
4380 * @state: the state for which to set the base color
4381 * @color: (allow-none): the color to assign (does not need to
4382 * be allocated), or %NULL to undo the effect of previous
4383 * calls to of ctk_widget_modify_base().
4384 *
4385 * Sets the base color for a widget in a particular state.
4386 * All other style values are left untouched. The base color
4387 * is the background color used along with the text color
4388 * (see ctk_widget_modify_text()) for widgets such as #CtkEntry
4389 * and #CtkTextView. See also ctk_widget_modify_style().
4390 *
4391 * > Note that “no window” widgets (which have the %CTK_NO_WINDOW
4392 * > flag set) draw on their parent container’s window and thus may
4393 * > not draw any background themselves. This is the case for e.g.
4394 * > #CtkLabel.
4395 * >
4396 * > To modify the background of such widgets, you have to set the
4397 * > base color on their parent; if you want to set the background
4398 * > of a rectangular area around a label, try placing the label in
4399 * > a #CtkEventBox widget and setting the base color on that.
4400 */
4401void
4402ctk_widget_modify_base (CtkWidget *widget,
4403 CtkStateType state,
4404 const CdkColor *color)
4405{
4406 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4407 g_return_if_fail (state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE)do { if ((state >= CTK_STATE_NORMAL && state <=
CTK_STATE_INSENSITIVE)) { } else { g_return_if_fail_warning (
"Ctk", ((const char*) (__func__)), "state >= CTK_STATE_NORMAL && state <= CTK_STATE_INSENSITIVE"
); return; } } while (0)
;
4408
4409 ctk_widget_modify_color_component (widget, CTK_RC_BASE, state, color);
4410}
4411
4412/**
4413 * ctk_widget_modify_cursor:
4414 * @widget: a #CtkWidget
4415 * @primary: (nullable): the color to use for primary cursor (does not
4416 * need to be allocated), or %NULL to undo the effect of previous
4417 * calls to of ctk_widget_modify_cursor().
4418 * @secondary: (nullable): the color to use for secondary cursor (does
4419 * not need to be allocated), or %NULL to undo the effect of
4420 * previous calls to of ctk_widget_modify_cursor().
4421 *
4422 * Sets the cursor color to use in a widget, overriding the #CtkWidget
4423 * cursor-color and secondary-cursor-color
4424 * style properties.
4425 *
4426 * All other style values are left untouched.
4427 * See also ctk_widget_modify_style().
4428 *
4429 * Since: 2.12
4430 */
4431void
4432ctk_widget_modify_cursor (CtkWidget *widget,
4433 const CdkColor *primary,
4434 const CdkColor *secondary)
4435{
4436 CdkRGBA primary_rgba, secondary_rgba;
4437
4438 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4439
4440 primary_rgba.red = primary->red / 65535.;
4441 primary_rgba.green = primary->green / 65535.;
4442 primary_rgba.blue = primary->blue / 65535.;
4443 primary_rgba.alpha = 1;
4444
4445 secondary_rgba.red = secondary->red / 65535.;
4446 secondary_rgba.green = secondary->green / 65535.;
4447 secondary_rgba.blue = secondary->blue / 65535.;
4448 secondary_rgba.alpha = 1;
4449
4450 ctk_widget_override_cursor (widget, &primary_rgba, &secondary_rgba);
4451}
4452
4453/**
4454 * ctk_widget_modify_font:
4455 * @widget: a #CtkWidget
4456 * @font_desc: (allow-none): the font description to use, or %NULL
4457 * to undo the effect of previous calls to ctk_widget_modify_font()
4458 *
4459 * Sets the font to use for a widget.
4460 *
4461 * All other style values are left untouched.
4462 * See also ctk_widget_modify_style().
4463 */
4464void
4465ctk_widget_modify_font (CtkWidget *widget,
4466 PangoFontDescription *font_desc)
4467{
4468 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4469
4470 ctk_widget_override_font (widget, font_desc);
4471}
4472
4473/**
4474 * ctk_widget_reset_rc_styles:
4475 * @widget: a #CtkWidget.
4476 *
4477 * Reset the styles of @widget and all descendents, so when
4478 * they are looked up again, they get the correct values
4479 * for the currently loaded RC file settings.
4480 *
4481 * This function is not useful for applications.
4482 */
4483void
4484ctk_widget_reset_rc_styles (CtkWidget *widget)
4485{
4486 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4487
4488 ctk_widget_reset_style (widget);
4489}
4490
4491/**
4492 * ctk_widget_path:
4493 * @widget: a #CtkWidget
4494 * @path_length: (out) (allow-none): location to store length of the path,
4495 * or %NULL
4496 * @path: (out) (allow-none): location to store allocated path string,
4497 * or %NULL
4498 * @path_reversed: (out) (allow-none): location to store allocated reverse
4499 * path string, or %NULL
4500 *
4501 * Obtains the full path to @widget. The path is simply the name of a
4502 * widget and all its parents in the container hierarchy, separated by
4503 * periods. The name of a widget comes from
4504 * ctk_widget_get_name(). Paths are used to apply styles to a widget
4505 * in ctkrc configuration files. Widget names are the type of the
4506 * widget by default (e.g. “CtkButton”) or can be set to an
4507 * application-specific value with ctk_widget_set_name(). By setting
4508 * the name of a widget, you allow users or theme authors to apply
4509 * styles to that specific widget in their ctkrc
4510 * file. @path_reversed_p fills in the path in reverse order,
4511 * i.e. starting with @widget’s name instead of starting with the name
4512 * of @widget’s outermost ancestor.
4513 **/
4514void
4515ctk_widget_path (CtkWidget *widget,
4516 guint *path_length,
4517 gchar **path,
4518 gchar **path_reversed)
4519{
4520 static gchar *rev_path = NULL((void*)0);
4521 static guint tmp_path_len = 0;
4522 guint len;
4523
4524#define INIT_PATH_SIZE(512) (512)
4525
4526 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4527
4528 len = 0;
4529 do
4530 {
4531 const gchar *string;
4532 const gchar *s;
4533 gchar *d;
4534 guint l;
4535
4536 string = ctk_widget_get_name (widget);
4537 l = strlen (string);
4538 while (tmp_path_len <= len + l + 1)
4539 {
4540 tmp_path_len += INIT_PATH_SIZE(512);
4541 rev_path = g_realloc (rev_path, tmp_path_len);
4542 }
4543 s = string + l - 1;
4544 d = rev_path + len;
4545 while (s >= string)
4546 *(d++) = *(s--);
4547 len += l;
4548
4549 widget = ctk_widget_get_parent (widget);
4550
4551 if (widget)
4552 rev_path[len++] = '.';
4553 else
4554 rev_path[len++] = 0;
4555 }
4556 while (widget);
4557
4558 if (path_length)
4559 *path_length = len - 1;
4560 if (path_reversed)
4561 *path_reversed = g_strdup (rev_path)g_strdup_inline (rev_path);
4562 if (path)
4563 {
4564 *path = g_strdup (rev_path)g_strdup_inline (rev_path);
4565 g_strreverse (*path);
4566 }
4567}
4568
4569/**
4570 * ctk_widget_class_path:
4571 * @widget: a #CtkWidget
4572 * @path_length: (out) (optional): location to store the length of the
4573 * class path, or %NULL
4574 * @path: (out) (optional): location to store the class path as an
4575 * allocated string, or %NULL
4576 * @path_reversed: (out) (optional): location to store the reverse
4577 * class path as an allocated string, or %NULL
4578 *
4579 * Same as ctk_widget_path(), but always uses the name of a widget’s type,
4580 * never uses a custom name set with ctk_widget_set_name().
4581 **/
4582void
4583ctk_widget_class_path (CtkWidget *widget,
4584 guint *path_length,
4585 gchar **path,
4586 gchar **path_reversed)
4587{
4588 static gchar *rev_path = NULL((void*)0);
4589 static guint tmp_path_len = 0;
4590 guint len;
4591
4592 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
1
Assuming '__inst' is non-null
2
Taking false branch
3
Assuming field 'g_class' is non-null
4
Assuming '__t' is equal to field 'g_type'
5
Taking true branch
6
Taking true branch
7
Loop condition is false. Exiting loop
4593
4594 len = 0;
4595 do
14
Loop condition is true. Execution continues on line 4597
4596 {
4597 const gchar *string;
4598 const gchar *s;
4599 gchar *d;
4600 guint l;
4601
4602 string = g_type_name (G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
);
4603 l = strlen (string);
4604 while (tmp_path_len <= len + l + 1)
8
Loop condition is true. Entering loop body
9
Assuming the condition is false
10
Loop condition is false. Execution continues on line 4609
15
Assuming the condition is false
16
Loop condition is false. Execution continues on line 4609
4605 {
4606 tmp_path_len += INIT_PATH_SIZE(512);
4607 rev_path = g_realloc (rev_path, tmp_path_len);
4608 }
4609 s = string + l - 1;
4610 d = rev_path + len;
4611 while (s >= string)
11
Loop condition is false. Execution continues on line 4613
17
Loop condition is true. Entering loop body
4612 *(d++) = *(s--);
18
Out of bound memory access (accessed memory precedes memory block)
4613 len += l;
4614
4615 widget = ctk_widget_get_parent (widget);
4616
4617 if (widget)
12
Assuming 'widget' is non-null
13
Taking true branch
4618 rev_path[len++] = '.';
4619 else
4620 rev_path[len++] = 0;
4621 }
4622 while (widget);
4623
4624 if (path_length)
4625 *path_length = len - 1;
4626 if (path_reversed)
4627 *path_reversed = g_strdup (rev_path)g_strdup_inline (rev_path);
4628 if (path)
4629 {
4630 *path = g_strdup (rev_path)g_strdup_inline (rev_path);
4631 g_strreverse (*path);
4632 }
4633}
4634
4635/**
4636 * ctk_widget_render_icon:
4637 * @widget: a #CtkWidget
4638 * @stock_id: a stock ID
4639 * @size: (type int): a stock size (#CtkIconSize). A size of `(CtkIconSize)-1`
4640 * means render at the size of the source and don’t scale (if there are
4641 * multiple source sizes, CTK+ picks one of the available sizes).
4642 * @detail: (allow-none): render detail to pass to theme engine
4643 *
4644 * A convenience function that uses the theme settings for @widget
4645 * to look up @stock_id and render it to a pixbuf. @stock_id should
4646 * be a stock icon ID such as #CTK_STOCK_OPEN or #CTK_STOCK_OK. @size
4647 * should be a size such as #CTK_ICON_SIZE_MENU. @detail should be a
4648 * string that identifies the widget or code doing the rendering, so
4649 * that theme engines can special-case rendering for that widget or
4650 * code.
4651 *
4652 * The pixels in the returned #GdkPixbuf are shared with the rest of
4653 * the application and should not be modified. The pixbuf should be
4654 * freed after use with g_object_unref().
4655 *
4656 * Returns: (nullable) (transfer full): a new pixbuf, or %NULL if the
4657 * stock ID wasn’t known
4658 **/
4659GdkPixbuf*
4660ctk_widget_render_icon (CtkWidget *widget,
4661 const gchar *stock_id,
4662 CtkIconSize size,
4663 const gchar *detail G_GNUC_UNUSED__attribute__ ((__unused__)))
4664{
4665 ctk_widget_ensure_style (widget);
4666
4667 return ctk_widget_render_icon_pixbuf (widget, stock_id, size);
4668}