File: | tests/ctkoffscreenbox.c |
Warning: | line 602, column 7 Value stored to 'start_y' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * ctkoffscreenbox.c |
3 | */ |
4 | |
5 | #include "config.h" |
6 | |
7 | #include <math.h> |
8 | #include <ctk/ctk.h> |
9 | |
10 | #include "ctkoffscreenbox.h" |
11 | |
12 | static void ctk_offscreen_box_realize (CtkWidget *widget); |
13 | static void ctk_offscreen_box_unrealize (CtkWidget *widget); |
14 | static void ctk_offscreen_box_get_preferred_width (CtkWidget *widget, |
15 | gint *minimum, |
16 | gint *natural); |
17 | static void ctk_offscreen_box_get_preferred_height (CtkWidget *widget, |
18 | gint *minimum, |
19 | gint *natural); |
20 | static void ctk_offscreen_box_size_allocate (CtkWidget *widget, |
21 | CtkAllocation *allocation); |
22 | static gboolean ctk_offscreen_box_damage (CtkWidget *widget, |
23 | CdkEventExpose *event); |
24 | static gboolean ctk_offscreen_box_draw (CtkWidget *widget, |
25 | cairo_t *cr); |
26 | |
27 | static void ctk_offscreen_box_add (CtkContainer *container, |
28 | CtkWidget *child); |
29 | static void ctk_offscreen_box_remove (CtkContainer *container, |
30 | CtkWidget *widget); |
31 | static void ctk_offscreen_box_forall (CtkContainer *container, |
32 | gboolean include_internals, |
33 | CtkCallback callback, |
34 | gpointer callback_data); |
35 | static GType ctk_offscreen_box_child_type (CtkContainer *container); |
36 | |
37 | #define CHILD1_SIZE_SCALE1.0 1.0 |
38 | #define CHILD2_SIZE_SCALE1.0 1.0 |
39 | |
40 | G_DEFINE_TYPE (CtkOffscreenBox, ctk_offscreen_box, CTK_TYPE_CONTAINER)static void ctk_offscreen_box_init (CtkOffscreenBox *self); static void ctk_offscreen_box_class_init (CtkOffscreenBoxClass *klass ); static GType ctk_offscreen_box_get_type_once (void); static gpointer ctk_offscreen_box_parent_class = ((void*)0); static gint CtkOffscreenBox_private_offset; static void ctk_offscreen_box_class_intern_init (gpointer klass) { ctk_offscreen_box_parent_class = g_type_class_peek_parent (klass); if (CtkOffscreenBox_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkOffscreenBox_private_offset); ctk_offscreen_box_class_init ((CtkOffscreenBoxClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_offscreen_box_get_instance_private (CtkOffscreenBox *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkOffscreenBox_private_offset)))); } GType ctk_offscreen_box_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_offscreen_box_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_offscreen_box_get_type_once ( void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkOffscreenBox" ), sizeof (CtkOffscreenBoxClass), (GClassInitFunc)(void (*)(void )) ctk_offscreen_box_class_intern_init, sizeof (CtkOffscreenBox ), (GInstanceInitFunc)(void (*)(void)) ctk_offscreen_box_init , (GTypeFlags) 0); { {{};} } return g_define_type_id; }; |
41 | |
42 | static void |
43 | to_child_2 (CtkOffscreenBox *offscreen_box, |
44 | double widget_x, double widget_y, |
45 | double *x_out, double *y_out) |
46 | { |
47 | CtkAllocation child_area; |
48 | double x, y, xr, yr; |
49 | double cos_angle, sin_angle; |
50 | |
51 | x = widget_x; |
52 | y = widget_y; |
53 | |
54 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
55 | { |
56 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
57 | y -= child_area.height; |
58 | } |
59 | |
60 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
61 | |
62 | x -= child_area.width / 2; |
63 | y -= child_area.height / 2; |
64 | |
65 | cos_angle = cos (-offscreen_box->angle); |
66 | sin_angle = sin (-offscreen_box->angle); |
67 | |
68 | xr = x * cos_angle - y * sin_angle; |
69 | yr = x * sin_angle + y * cos_angle; |
70 | x = xr; |
71 | y = yr; |
72 | |
73 | x += child_area.width / 2; |
74 | y += child_area.height / 2; |
75 | |
76 | *x_out = x; |
77 | *y_out = y; |
78 | } |
79 | |
80 | static void |
81 | to_parent_2 (CtkOffscreenBox *offscreen_box, |
82 | double offscreen_x, double offscreen_y, |
83 | double *x_out, double *y_out) |
84 | { |
85 | CtkAllocation child_area; |
86 | double x, y, xr, yr; |
87 | double cos_angle, sin_angle; |
88 | |
89 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
90 | |
91 | x = offscreen_x; |
92 | y = offscreen_y; |
93 | |
94 | x -= child_area.width / 2; |
95 | y -= child_area.height / 2; |
96 | |
97 | cos_angle = cos (offscreen_box->angle); |
98 | sin_angle = sin (offscreen_box->angle); |
99 | |
100 | xr = x * cos_angle - y * sin_angle; |
101 | yr = x * sin_angle + y * cos_angle; |
102 | x = xr; |
103 | y = yr; |
104 | |
105 | x += child_area.width / 2; |
106 | y += child_area.height / 2; |
107 | |
108 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
109 | { |
110 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
111 | y += child_area.height; |
112 | } |
113 | |
114 | *x_out = x; |
115 | *y_out = y; |
116 | } |
117 | |
118 | static void |
119 | ctk_offscreen_box_class_init (CtkOffscreenBoxClass *klass) |
120 | { |
121 | CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_widget_get_type ())))))); |
122 | CtkContainerClass *container_class = CTK_CONTAINER_CLASS (klass)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_container_get_type ())))))); |
123 | |
124 | widget_class->realize = ctk_offscreen_box_realize; |
125 | widget_class->unrealize = ctk_offscreen_box_unrealize; |
126 | widget_class->get_preferred_width = ctk_offscreen_box_get_preferred_width; |
127 | widget_class->get_preferred_height = ctk_offscreen_box_get_preferred_height; |
128 | widget_class->size_allocate = ctk_offscreen_box_size_allocate; |
129 | widget_class->draw = ctk_offscreen_box_draw; |
130 | |
131 | g_signal_override_class_closure (g_signal_lookup ("damage-event", CTK_TYPE_WIDGET(ctk_widget_get_type ())), |
132 | CTK_TYPE_OFFSCREEN_BOX(ctk_offscreen_box_get_type ()), |
133 | g_cclosure_new (G_CALLBACK (ctk_offscreen_box_damage)((GCallback) (ctk_offscreen_box_damage)), |
134 | NULL((void*)0), NULL((void*)0))); |
135 | |
136 | container_class->add = ctk_offscreen_box_add; |
137 | container_class->remove = ctk_offscreen_box_remove; |
138 | container_class->forall = ctk_offscreen_box_forall; |
139 | container_class->child_type = ctk_offscreen_box_child_type; |
140 | } |
141 | |
142 | static void |
143 | ctk_offscreen_box_init (CtkOffscreenBox *offscreen_box) |
144 | { |
145 | ctk_widget_set_has_window (CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ())))))), TRUE(!(0))); |
146 | } |
147 | |
148 | CtkWidget * |
149 | ctk_offscreen_box_new (void) |
150 | { |
151 | return g_object_new (CTK_TYPE_OFFSCREEN_BOX(ctk_offscreen_box_get_type ()), NULL((void*)0)); |
152 | } |
153 | |
154 | static CdkWindow * |
155 | pick_offscreen_child (CdkWindow *offscreen_window, |
156 | double widget_x, double widget_y, |
157 | CtkOffscreenBox *offscreen_box) |
158 | { |
159 | CtkAllocation child_area; |
160 | double x, y; |
161 | |
162 | /* First check for child 2 */ |
163 | if (offscreen_box->child2 && |
164 | ctk_widget_get_visible (offscreen_box->child2)) |
165 | { |
166 | to_child_2 (offscreen_box, |
167 | widget_x, widget_y, |
168 | &x, &y); |
169 | |
170 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
171 | |
172 | if (x >= 0 && x < child_area.width && |
173 | y >= 0 && y < child_area.height) |
174 | return offscreen_box->offscreen_window2; |
175 | } |
176 | |
177 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
178 | { |
179 | x = widget_x; |
180 | y = widget_y; |
181 | |
182 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
183 | |
184 | if (x >= 0 && x < child_area.width && |
185 | y >= 0 && y < child_area.height) |
186 | return offscreen_box->offscreen_window1; |
187 | } |
188 | |
189 | return NULL((void*)0); |
190 | } |
191 | |
192 | static void |
193 | offscreen_window_to_parent1 (CdkWindow *offscreen_window, |
194 | double offscreen_x, |
195 | double offscreen_y, |
196 | double *parent_x, |
197 | double *parent_y, |
198 | CtkOffscreenBox *offscreen_box) |
199 | { |
200 | *parent_x = offscreen_x; |
201 | *parent_y = offscreen_y; |
202 | } |
203 | |
204 | static void |
205 | offscreen_window_from_parent1 (CdkWindow *window, |
206 | double parent_x, |
207 | double parent_y, |
208 | double *offscreen_x, |
209 | double *offscreen_y, |
210 | CtkOffscreenBox *offscreen_box) |
211 | { |
212 | *offscreen_x = parent_x; |
213 | *offscreen_y = parent_y; |
214 | } |
215 | |
216 | static void |
217 | offscreen_window_to_parent2 (CdkWindow *offscreen_window, |
218 | double offscreen_x, |
219 | double offscreen_y, |
220 | double *parent_x, |
221 | double *parent_y, |
222 | CtkOffscreenBox *offscreen_box) |
223 | { |
224 | to_parent_2 (offscreen_box, |
225 | offscreen_x, offscreen_y, |
226 | parent_x, parent_y); |
227 | } |
228 | |
229 | static void |
230 | offscreen_window_from_parent2 (CdkWindow *window, |
231 | double parent_x, |
232 | double parent_y, |
233 | double *offscreen_x, |
234 | double *offscreen_y, |
235 | CtkOffscreenBox *offscreen_box) |
236 | { |
237 | to_child_2 (offscreen_box, |
238 | parent_x, parent_y, |
239 | offscreen_x, offscreen_y); |
240 | } |
241 | |
242 | static cairo_surface_t * |
243 | cdk_offscreen_box_create_alpha_image_surface (CdkWindow *offscreen, |
244 | gint width, |
245 | gint height) |
246 | { |
247 | return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); |
248 | } |
249 | |
250 | static void |
251 | ctk_offscreen_box_realize (CtkWidget *widget) |
252 | { |
253 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
254 | CtkAllocation allocation, child_area; |
255 | CdkWindow *window; |
256 | CdkWindowAttr attributes; |
257 | gint attributes_mask; |
258 | guint border_width; |
259 | CtkRequisition child_requisition; |
260 | int start_y = 0; |
261 | |
262 | ctk_widget_set_realized (widget, TRUE(!(0))); |
263 | |
264 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
265 | |
266 | ctk_widget_get_allocation (widget, &allocation); |
267 | |
268 | attributes.x = allocation.x + border_width; |
269 | attributes.y = allocation.y + border_width; |
270 | attributes.width = allocation.width - 2 * border_width; |
271 | attributes.height = allocation.height - 2 * border_width; |
272 | attributes.window_type = CDK_WINDOW_CHILD; |
273 | attributes.event_mask = ctk_widget_get_events (widget) |
274 | | CDK_EXPOSURE_MASK |
275 | | CDK_POINTER_MOTION_MASK |
276 | | CDK_BUTTON_PRESS_MASK |
277 | | CDK_BUTTON_RELEASE_MASK |
278 | | CDK_SCROLL_MASK |
279 | | CDK_ENTER_NOTIFY_MASK |
280 | | CDK_LEAVE_NOTIFY_MASK; |
281 | |
282 | attributes.visual = ctk_widget_get_visual (widget); |
283 | attributes.wclass = CDK_INPUT_OUTPUT; |
284 | |
285 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; |
286 | |
287 | window = cdk_window_new (ctk_widget_get_parent_window (widget), |
288 | &attributes, attributes_mask); |
289 | ctk_widget_set_window (widget, window); |
290 | cdk_window_set_user_data (window, widget); |
291 | |
292 | g_signal_connect (window, "pick-embedded-child",g_signal_connect_data ((window), ("pick-embedded-child"), ((( GCallback) (pick_offscreen_child))), (offscreen_box), ((void* )0), (GConnectFlags) 0) |
293 | G_CALLBACK (pick_offscreen_child), offscreen_box)g_signal_connect_data ((window), ("pick-embedded-child"), ((( GCallback) (pick_offscreen_child))), (offscreen_box), ((void* )0), (GConnectFlags) 0); |
294 | |
295 | attributes.window_type = CDK_WINDOW_OFFSCREEN; |
296 | |
297 | /* Child 1 */ |
298 | attributes.x = attributes.y = 0; |
299 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
300 | { |
301 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
302 | |
303 | attributes.width = child_area.width; |
304 | attributes.height = child_area.height; |
305 | start_y += child_area.height; |
306 | } |
307 | offscreen_box->offscreen_window1 = cdk_window_new (cdk_screen_get_root_window (ctk_widget_get_screen (widget)), |
308 | &attributes, attributes_mask); |
309 | cdk_window_set_user_data (offscreen_box->offscreen_window1, widget); |
310 | if (offscreen_box->child1) |
311 | ctk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1); |
312 | |
313 | cdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1, |
314 | window); |
315 | |
316 | g_signal_connect (offscreen_box->offscreen_window1, "to-embedder",g_signal_connect_data ((offscreen_box->offscreen_window1), ("to-embedder"), (((GCallback) (offscreen_window_to_parent1) )), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
317 | G_CALLBACK (offscreen_window_to_parent1), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window1), ("to-embedder"), (((GCallback) (offscreen_window_to_parent1) )), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
318 | g_signal_connect (offscreen_box->offscreen_window1, "from-embedder",g_signal_connect_data ((offscreen_box->offscreen_window1), ("from-embedder"), (((GCallback) (offscreen_window_from_parent1 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
319 | G_CALLBACK (offscreen_window_from_parent1), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window1), ("from-embedder"), (((GCallback) (offscreen_window_from_parent1 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
320 | |
321 | /* Child 2 */ |
322 | attributes.y = start_y; |
323 | child_requisition.width = child_requisition.height = 0; |
324 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
325 | { |
326 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
327 | |
328 | attributes.width = child_area.width; |
329 | attributes.height = child_area.height; |
330 | } |
331 | offscreen_box->offscreen_window2 = cdk_window_new (cdk_screen_get_root_window (ctk_widget_get_screen (widget)), |
332 | &attributes, attributes_mask); |
333 | cdk_window_set_user_data (offscreen_box->offscreen_window2, widget); |
334 | if (offscreen_box->child2) |
335 | ctk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2); |
336 | cdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2, |
337 | window); |
338 | |
339 | g_signal_connect (offscreen_box->offscreen_window2, "create-surface",g_signal_connect_data ((offscreen_box->offscreen_window2), ("create-surface"), (((GCallback) (cdk_offscreen_box_create_alpha_image_surface ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
340 | G_CALLBACK (cdk_offscreen_box_create_alpha_image_surface),g_signal_connect_data ((offscreen_box->offscreen_window2), ("create-surface"), (((GCallback) (cdk_offscreen_box_create_alpha_image_surface ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
341 | offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window2), ("create-surface"), (((GCallback) (cdk_offscreen_box_create_alpha_image_surface ))), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
342 | g_signal_connect (offscreen_box->offscreen_window2, "to-embedder",g_signal_connect_data ((offscreen_box->offscreen_window2), ("to-embedder"), (((GCallback) (offscreen_window_to_parent2) )), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
343 | G_CALLBACK (offscreen_window_to_parent2), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window2), ("to-embedder"), (((GCallback) (offscreen_window_to_parent2) )), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
344 | g_signal_connect (offscreen_box->offscreen_window2, "from-embedder",g_signal_connect_data ((offscreen_box->offscreen_window2), ("from-embedder"), (((GCallback) (offscreen_window_from_parent2 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0) |
345 | G_CALLBACK (offscreen_window_from_parent2), offscreen_box)g_signal_connect_data ((offscreen_box->offscreen_window2), ("from-embedder"), (((GCallback) (offscreen_window_from_parent2 ))), (offscreen_box), ((void*)0), (GConnectFlags) 0); |
346 | |
347 | cdk_window_show (offscreen_box->offscreen_window1); |
348 | cdk_window_show (offscreen_box->offscreen_window2); |
349 | } |
350 | |
351 | static void |
352 | ctk_offscreen_box_unrealize (CtkWidget *widget) |
353 | { |
354 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
355 | |
356 | cdk_window_set_user_data (offscreen_box->offscreen_window1, NULL((void*)0)); |
357 | cdk_window_destroy (offscreen_box->offscreen_window1); |
358 | offscreen_box->offscreen_window1 = NULL((void*)0); |
359 | |
360 | cdk_window_set_user_data (offscreen_box->offscreen_window2, NULL((void*)0)); |
361 | cdk_window_destroy (offscreen_box->offscreen_window2); |
362 | offscreen_box->offscreen_window2 = NULL((void*)0); |
363 | |
364 | CTK_WIDGET_CLASS (ctk_offscreen_box_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_offscreen_box_parent_class)), ((ctk_widget_get_type ( )))))))->unrealize (widget); |
365 | } |
366 | |
367 | static GType |
368 | ctk_offscreen_box_child_type (CtkContainer *container) |
369 | { |
370 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
371 | |
372 | if (offscreen_box->child1 && offscreen_box->child2) |
373 | return G_TYPE_NONE((GType) ((1) << (2))); |
374 | |
375 | return CTK_TYPE_WIDGET(ctk_widget_get_type ()); |
376 | } |
377 | |
378 | static void |
379 | ctk_offscreen_box_add (CtkContainer *container, |
380 | CtkWidget *widget) |
381 | { |
382 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
383 | |
384 | if (!offscreen_box->child1) |
385 | ctk_offscreen_box_add1 (offscreen_box, widget); |
386 | else if (!offscreen_box->child2) |
387 | ctk_offscreen_box_add2 (offscreen_box, widget); |
388 | else |
389 | g_warning ("CtkOffscreenBox cannot have more than 2 children"); |
390 | } |
391 | |
392 | void |
393 | ctk_offscreen_box_add1 (CtkOffscreenBox *offscreen_box, |
394 | CtkWidget *child) |
395 | { |
396 | g_return_if_fail (CTK_IS_OFFSCREEN_BOX (offscreen_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((offscreen_box)); GType __t = ((ctk_offscreen_box_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 (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_OFFSCREEN_BOX (offscreen_box)" ); return; } } while (0); |
397 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (child)"); return; } } while (0 ); |
398 | |
399 | if (offscreen_box->child1 == NULL((void*)0)) |
400 | { |
401 | ctk_widget_set_parent_window (child, offscreen_box->offscreen_window1); |
402 | ctk_widget_set_parent (child, CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ()))))))); |
403 | offscreen_box->child1 = child; |
404 | } |
405 | } |
406 | |
407 | void |
408 | ctk_offscreen_box_add2 (CtkOffscreenBox *offscreen_box, |
409 | CtkWidget *child) |
410 | { |
411 | g_return_if_fail (CTK_IS_OFFSCREEN_BOX (offscreen_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((offscreen_box)); GType __t = ((ctk_offscreen_box_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 (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_OFFSCREEN_BOX (offscreen_box)" ); return; } } while (0); |
412 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (child)"); return; } } while (0 ); |
413 | |
414 | if (offscreen_box->child2 == NULL((void*)0)) |
415 | { |
416 | ctk_widget_set_parent_window (child, offscreen_box->offscreen_window2); |
417 | ctk_widget_set_parent (child, CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ()))))))); |
418 | offscreen_box->child2 = child; |
419 | } |
420 | } |
421 | |
422 | static void |
423 | ctk_offscreen_box_remove (CtkContainer *container, |
424 | CtkWidget *widget) |
425 | { |
426 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
427 | gboolean was_visible; |
428 | |
429 | was_visible = ctk_widget_get_visible (widget); |
430 | |
431 | if (offscreen_box->child1 == widget) |
432 | { |
433 | ctk_widget_unparent (widget); |
434 | |
435 | offscreen_box->child1 = NULL((void*)0); |
436 | |
437 | if (was_visible && ctk_widget_get_visible (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) |
438 | ctk_widget_queue_resize (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ()))))))); |
439 | } |
440 | else if (offscreen_box->child2 == widget) |
441 | { |
442 | ctk_widget_unparent (widget); |
443 | |
444 | offscreen_box->child2 = NULL((void*)0); |
445 | |
446 | if (was_visible && ctk_widget_get_visible (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) |
447 | ctk_widget_queue_resize (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ()))))))); |
448 | } |
449 | } |
450 | |
451 | static void |
452 | ctk_offscreen_box_forall (CtkContainer *container, |
453 | gboolean include_internals, |
454 | CtkCallback callback, |
455 | gpointer callback_data) |
456 | { |
457 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (container)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_offscreen_box_get_type ())))))); |
458 | |
459 | g_return_if_fail (callback != NULL)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "callback != NULL" ); return; } } while (0); |
460 | |
461 | if (offscreen_box->child1) |
462 | (*callback) (offscreen_box->child1, callback_data); |
463 | if (offscreen_box->child2) |
464 | (*callback) (offscreen_box->child2, callback_data); |
465 | } |
466 | |
467 | void |
468 | ctk_offscreen_box_set_angle (CtkOffscreenBox *offscreen_box, |
469 | gdouble angle) |
470 | { |
471 | g_return_if_fail (CTK_IS_OFFSCREEN_BOX (offscreen_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((offscreen_box)); GType __t = ((ctk_offscreen_box_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 (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_OFFSCREEN_BOX (offscreen_box)" ); return; } } while (0); |
472 | |
473 | offscreen_box->angle = angle; |
474 | ctk_widget_queue_draw (CTK_WIDGET (offscreen_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((offscreen_box)), ((ctk_widget_get_type ()))))))); |
475 | |
476 | /* TODO: Really needs to resent pointer events if over the rotated window */ |
477 | } |
478 | |
479 | |
480 | static void |
481 | ctk_offscreen_box_size_request (CtkWidget *widget, |
482 | CtkRequisition *requisition) |
483 | { |
484 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
485 | int w, h; |
486 | guint border_width; |
487 | |
488 | w = 0; |
489 | h = 0; |
490 | |
491 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
492 | { |
493 | CtkRequisition child_requisition; |
494 | |
495 | ctk_widget_get_preferred_size ( (offscreen_box->child1), |
496 | &child_requisition, NULL((void*)0)); |
497 | |
498 | w = MAX (w, CHILD1_SIZE_SCALE * child_requisition.width)(((w) > (1.0 * child_requisition.width)) ? (w) : (1.0 * child_requisition .width)); |
499 | h += CHILD1_SIZE_SCALE1.0 * child_requisition.height; |
500 | } |
501 | |
502 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
503 | { |
504 | CtkRequisition child_requisition; |
505 | |
506 | ctk_widget_get_preferred_size ( (offscreen_box->child2), |
507 | &child_requisition, NULL((void*)0)); |
508 | |
509 | w = MAX (w, CHILD2_SIZE_SCALE * child_requisition.width)(((w) > (1.0 * child_requisition.width)) ? (w) : (1.0 * child_requisition .width)); |
510 | h += CHILD2_SIZE_SCALE1.0 * child_requisition.height; |
511 | } |
512 | |
513 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
514 | requisition->width = border_width * 2 + w; |
515 | requisition->height = border_width * 2 + h; |
516 | } |
517 | |
518 | static void |
519 | ctk_offscreen_box_get_preferred_width (CtkWidget *widget, |
520 | gint *minimum, |
521 | gint *natural) |
522 | { |
523 | CtkRequisition requisition; |
524 | |
525 | ctk_offscreen_box_size_request (widget, &requisition); |
526 | |
527 | *minimum = *natural = requisition.width; |
528 | } |
529 | |
530 | static void |
531 | ctk_offscreen_box_get_preferred_height (CtkWidget *widget, |
532 | gint *minimum, |
533 | gint *natural) |
534 | { |
535 | CtkRequisition requisition; |
536 | |
537 | ctk_offscreen_box_size_request (widget, &requisition); |
538 | |
539 | *minimum = *natural = requisition.height; |
540 | } |
541 | |
542 | static void |
543 | ctk_offscreen_box_size_allocate (CtkWidget *widget, |
544 | CtkAllocation *allocation) |
545 | { |
546 | CtkOffscreenBox *offscreen_box; |
547 | gint start_y; |
548 | guint border_width; |
549 | |
550 | offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
551 | |
552 | ctk_widget_set_allocation (widget, allocation); |
553 | |
554 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); |
555 | |
556 | if (ctk_widget_get_realized (widget)) |
557 | cdk_window_move_resize (ctk_widget_get_window (widget), |
558 | allocation->x + border_width, |
559 | allocation->y + border_width, |
560 | allocation->width - border_width * 2, |
561 | allocation->height - border_width * 2); |
562 | |
563 | start_y = 0; |
564 | |
565 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
566 | { |
567 | CtkRequisition child_requisition; |
568 | CtkAllocation child_allocation; |
569 | |
570 | ctk_widget_get_preferred_size (offscreen_box->child1, |
571 | &child_requisition, NULL((void*)0)); |
572 | child_allocation.x = child_requisition.width * (CHILD1_SIZE_SCALE1.0 - 1.0) / 2; |
573 | child_allocation.y = start_y + child_requisition.height * (CHILD1_SIZE_SCALE1.0 - 1.0) / 2; |
574 | child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width)(((1) > ((gint) allocation->width - 2 * border_width)) ? (1) : ((gint) allocation->width - 2 * border_width)); |
575 | child_allocation.height = child_requisition.height; |
576 | |
577 | start_y += CHILD1_SIZE_SCALE1.0 * child_requisition.height; |
578 | |
579 | if (ctk_widget_get_realized (widget)) |
580 | cdk_window_move_resize (offscreen_box->offscreen_window1, |
581 | child_allocation.x, |
582 | child_allocation.y, |
583 | child_allocation.width, |
584 | child_allocation.height); |
585 | |
586 | child_allocation.x = child_allocation.y = 0; |
587 | ctk_widget_size_allocate (offscreen_box->child1, &child_allocation); |
588 | } |
589 | |
590 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
591 | { |
592 | CtkRequisition child_requisition; |
593 | CtkAllocation child_allocation; |
594 | |
595 | ctk_widget_get_preferred_size (offscreen_box->child2, |
596 | &child_requisition, NULL((void*)0)); |
597 | child_allocation.x = child_requisition.width * (CHILD2_SIZE_SCALE1.0 - 1.0) / 2; |
598 | child_allocation.y = start_y + child_requisition.height * (CHILD2_SIZE_SCALE1.0 - 1.0) / 2; |
599 | child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width)(((1) > ((gint) allocation->width - 2 * border_width)) ? (1) : ((gint) allocation->width - 2 * border_width)); |
600 | child_allocation.height = child_requisition.height; |
601 | |
602 | start_y += CHILD2_SIZE_SCALE1.0 * child_requisition.height; |
Value stored to 'start_y' is never read | |
603 | |
604 | if (ctk_widget_get_realized (widget)) |
605 | cdk_window_move_resize (offscreen_box->offscreen_window2, |
606 | child_allocation.x, |
607 | child_allocation.y, |
608 | child_allocation.width, |
609 | child_allocation.height); |
610 | |
611 | child_allocation.x = child_allocation.y = 0; |
612 | ctk_widget_size_allocate (offscreen_box->child2, &child_allocation); |
613 | } |
614 | } |
615 | |
616 | static gboolean |
617 | ctk_offscreen_box_damage (CtkWidget *widget, |
618 | CdkEventExpose *event) |
619 | { |
620 | cdk_window_invalidate_rect (ctk_widget_get_window (widget), |
621 | NULL((void*)0), FALSE(0)); |
622 | |
623 | return TRUE(!(0)); |
624 | } |
625 | |
626 | static gboolean |
627 | ctk_offscreen_box_draw (CtkWidget *widget, |
628 | cairo_t *cr) |
629 | { |
630 | CtkOffscreenBox *offscreen_box = CTK_OFFSCREEN_BOX (widget)((((CtkOffscreenBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_offscreen_box_get_type ())))))); |
631 | CdkWindow *window; |
632 | |
633 | window = ctk_widget_get_window (widget); |
634 | if (ctk_cairo_should_draw_window (cr, window)) |
635 | { |
636 | cairo_surface_t *surface; |
637 | CtkAllocation child_area; |
638 | |
639 | if (offscreen_box->child1 && ctk_widget_get_visible (offscreen_box->child1)) |
640 | { |
641 | surface = cdk_offscreen_window_get_surface (offscreen_box->offscreen_window1); |
642 | |
643 | cairo_set_source_surface (cr, surface, 0, 0); |
644 | cairo_paint (cr); |
645 | |
646 | ctk_widget_get_allocation (offscreen_box->child1, &child_area); |
647 | cairo_translate (cr, 0, child_area.height); |
648 | } |
649 | |
650 | if (offscreen_box->child2 && ctk_widget_get_visible (offscreen_box->child2)) |
651 | { |
652 | surface = cdk_offscreen_window_get_surface (offscreen_box->offscreen_window2); |
653 | |
654 | ctk_widget_get_allocation (offscreen_box->child2, &child_area); |
655 | |
656 | /* transform */ |
657 | cairo_translate (cr, child_area.width / 2, child_area.height / 2); |
658 | cairo_rotate (cr, offscreen_box->angle); |
659 | cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); |
660 | |
661 | /* paint */ |
662 | cairo_set_source_surface (cr, surface, 0, 0); |
663 | cairo_paint (cr); |
664 | } |
665 | } |
666 | else if (ctk_cairo_should_draw_window (cr, offscreen_box->offscreen_window1)) |
667 | { |
668 | ctk_render_background (ctk_widget_get_style_context (widget), cr, |
669 | 0, 0, |
670 | |
671 | cdk_window_get_width (offscreen_box->offscreen_window1), |
672 | cdk_window_get_height (offscreen_box->offscreen_window1)); |
673 | |
674 | if (offscreen_box->child1) |
675 | ctk_container_propagate_draw (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), |
676 | offscreen_box->child1, |
677 | cr); |
678 | } |
679 | else if (ctk_cairo_should_draw_window (cr, offscreen_box->offscreen_window2)) |
680 | { |
681 | ctk_render_background (ctk_widget_get_style_context (widget), cr, |
682 | 0, 0, |
683 | cdk_window_get_width (offscreen_box->offscreen_window2), |
684 | cdk_window_get_height (offscreen_box->offscreen_window2)); |
685 | |
686 | if (offscreen_box->child2) |
687 | ctk_container_propagate_draw (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), |
688 | offscreen_box->child2, |
689 | cr); |
690 | } |
691 | |
692 | return FALSE(0); |
693 | } |