39
panel_frame_size_request (GtkWidget *widget,
40
GtkRequisition *requisition)
42
PanelFrame *frame = (PanelFrame *) widget;
43
GtkBin *bin = (GtkBin *) widget;
48
style = gtk_widget_get_style (widget);
49
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
51
requisition->width = 1;
52
requisition->height = 1;
54
child = gtk_bin_get_child (bin);
55
if (child && gtk_widget_get_visible (child))
56
gtk_widget_size_request (child, requisition);
58
requisition->width += border_width;
59
requisition->height += border_width;
61
if (frame->edges & PANEL_EDGE_TOP)
62
requisition->height += style->xthickness;
63
if (frame->edges & PANEL_EDGE_BOTTOM)
64
requisition->height += style->xthickness;
65
if (frame->edges & PANEL_EDGE_LEFT)
66
requisition->width += style->ythickness;
67
if (frame->edges & PANEL_EDGE_RIGHT)
68
requisition->width += style->ythickness;
39
panel_frame_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width)
41
PanelFrame *frame = (PanelFrame *) widget;
42
GtkBin *bin = (GtkBin *) widget;
43
GtkStyleContext *context;
48
context = gtk_widget_get_style_context (widget);
49
gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding);
50
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
55
child = gtk_bin_get_child (bin);
56
if (child && gtk_widget_get_visible (child))
57
gtk_widget_get_preferred_width (child, minimal_width, natural_width);
59
*minimal_width += border_width;
60
*natural_width += border_width;
62
if (frame->edges & PANEL_EDGE_LEFT) {
63
*minimal_width += padding.left;
64
*natural_width += padding.left;
67
if (frame->edges & PANEL_EDGE_RIGHT) {
68
*minimal_width += padding.right;
69
*natural_width += padding.right;
74
panel_frame_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height)
76
PanelFrame *frame = (PanelFrame *) widget;
77
GtkBin *bin = (GtkBin *) widget;
78
GtkStyleContext *context;
83
context = gtk_widget_get_style_context (widget);
84
gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding);
85
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
90
child = gtk_bin_get_child (bin);
91
if (child && gtk_widget_get_visible (child))
92
gtk_widget_get_preferred_height (child, minimal_height, natural_height);
94
*minimal_height += border_width;
95
*natural_height += border_width;
97
if (frame->edges & PANEL_EDGE_TOP) {
98
*minimal_height += padding.top;
99
*natural_height += padding.top;
102
if (frame->edges & PANEL_EDGE_BOTTOM) {
103
*minimal_height += padding.bottom;
104
*natural_height += padding.bottom;
72
109
panel_frame_size_allocate (GtkWidget *widget,
73
110
GtkAllocation *allocation)
75
PanelFrame *frame = (PanelFrame *) widget;
76
GtkBin *bin = (GtkBin *) widget;
78
GtkAllocation child_allocation;
79
GtkAllocation child_allocation_current;
112
PanelFrame *frame = (PanelFrame *) widget;
113
GtkBin *bin = (GtkBin *) widget;
114
GtkStyleContext *context;
115
GtkAllocation child_allocation;
116
GtkAllocation child_allocation_current;
83
121
gtk_widget_set_allocation (widget, allocation);
85
style = gtk_widget_get_style (widget);
123
context = gtk_widget_get_style_context (widget);
124
gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding);
86
125
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
88
127
child_allocation.x = allocation->x + border_width;
124
panel_frame_draw (GtkWidget *widget,
125
PanelFrameEdge edges)
163
panel_frame_draw (GtkWidget *widget,
165
PanelFrameEdge edges)
130
GtkAllocation allocation;
131
GdkGC *dark, *light, *black;
132
int x, y, width, height;
133
int xthickness, ythickness;
167
PanelFrame *frame = (PanelFrame *) widget;
169
GtkStyleContext *context;
171
GdkRGBA bg, dark, light;
172
GtkSymbolicColor *c1, *c2;
173
int x, y, width, height;
135
176
if (edges == PANEL_EDGE_NONE)
138
179
window = gtk_widget_get_window (widget);
139
style = gtk_widget_get_style (widget);
140
state = gtk_widget_get_state (widget);
141
gtk_widget_get_allocation (widget, &allocation);
143
dark = style->dark_gc [state];
144
light = style->light_gc [state];
145
black = style->black_gc;
147
xthickness = style->xthickness;
148
ythickness = style->ythickness;
152
width = allocation.width;
153
height = allocation.height;
180
context = gtk_widget_get_style_context (widget);
181
state = gtk_widget_get_state_flags (widget);
182
width = gtk_widget_get_allocated_width (widget);
183
height = gtk_widget_get_allocated_height (widget);
185
gtk_style_context_get_background_color (context, state, &bg);
187
c1 = gtk_symbolic_color_new_literal (&bg);
189
c2 = gtk_symbolic_color_new_shade (c1, 0.7);
190
gtk_symbolic_color_resolve (c2, NULL, &dark);
191
gtk_symbolic_color_unref (c2);
193
c2 = gtk_symbolic_color_new_shade (c1, 1.3);
194
gtk_symbolic_color_resolve (c2, NULL, &light);
195
gtk_symbolic_color_unref (c2);
197
gtk_symbolic_color_unref (c1);
199
gtk_style_context_get_padding (context, state, &padding);
155
201
/* Copied from gtk_default_draw_shadow() */
157
if (edges & PANEL_EDGE_BOTTOM && ythickness > 0) {
158
if (ythickness > 1) {
159
gdk_draw_line (window, dark,
161
x + width - 1, y + height - 2);
162
gdk_draw_line (window, black,
164
x + width - 1, y + height - 1);
166
gdk_draw_line (window, dark,
168
x + width - 1, y + height - 1);
171
if (edges & PANEL_EDGE_RIGHT && xthickness > 0) {
172
if (xthickness > 1) {
173
gdk_draw_line (window, dark,
175
x + width - 2, y + height - 1);
177
gdk_draw_line (window, black,
179
x + width - 1, y + height - 1);
181
gdk_draw_line (window, dark,
183
x + width - 1, y + height - 1);
186
if (edges & PANEL_EDGE_TOP && ythickness > 0) {
187
gdk_draw_line (window, light,
188
x, y, x + width - 1, y);
191
gdk_draw_line (window,
192
style->bg_gc [state],
193
x, y + 1, x + width - 1, y + 1);
196
if (edges & PANEL_EDGE_LEFT && xthickness > 0) {
197
gdk_draw_line (window, light,
198
x, y, x, y + height - 1);
201
gdk_draw_line (window,
202
style->bg_gc [state],
203
x + 1, y, x + 1, y + height - 1);
205
cairo_set_line_width (cr, 1);
207
if (frame->edges & PANEL_EDGE_BOTTOM && padding.bottom > 0) {
208
if (padding.bottom > 1) {
209
gdk_cairo_set_source_rgba (cr, &dark);
210
cairo_move_to (cr, x + .5, y + height - 2 + .5);
211
cairo_line_to (cr, x + width - 1 - .5, y + height - 2 + .5);
214
cairo_set_source_rgb (cr, 0., 0., 0.);
215
cairo_move_to (cr, x + .5, y + height - 1 - .5);
216
cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
219
gdk_cairo_set_source_rgba (cr, &dark);
220
cairo_move_to (cr, x + .5, y + height - 1 - .5);
221
cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
226
if (frame->edges & PANEL_EDGE_RIGHT && padding.right > 0) {
227
if (padding.right > 1) {
228
gdk_cairo_set_source_rgba (cr, &dark);
229
cairo_move_to (cr, x + width - 2 - .5, y + .5);
230
cairo_line_to (cr, x + width - 2 - .5, y + height - 1 - .5);
233
cairo_set_source_rgb (cr, 0., 0., 0.);
234
cairo_move_to (cr, x + width - 1 - .5, y + .5);
235
cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
238
gdk_cairo_set_source_rgba (cr, &dark);
239
cairo_move_to (cr, x + width - 1 - .5, y + .5);
240
cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
245
if (frame->edges & PANEL_EDGE_TOP && padding.top > 0) {
246
gdk_cairo_set_source_rgba (cr, &light);
247
cairo_move_to (cr, x + .5, y + .5);
248
cairo_line_to (cr, x + width - 1 - .5, y + .5);
251
if (padding.right > 1) {
252
gdk_cairo_set_source_rgba (cr, &bg);
253
cairo_move_to (cr, x + .5, y + 1 + .5);
254
cairo_line_to (cr, x + width - 1 - .5, y + 1 + .5);
259
if (frame->edges & PANEL_EDGE_LEFT && padding.left > 0) {
260
gdk_cairo_set_source_rgba (cr, &light);
261
cairo_move_to (cr, x + .5, y + .5);
262
cairo_line_to (cr, x + .5, y + height - 1 - .5);
265
if (padding.left > 1) {
266
gdk_cairo_set_source_rgba (cr, &bg);
267
cairo_move_to (cr, x + 1 + .5, y + .5);
268
cairo_line_to (cr, x + 1 + .5, y + height - 1 - .5);
208
panel_frame_expose (GtkWidget *widget,
209
GdkEventExpose *event)
275
panel_frame_real_draw (GtkWidget *widget,
211
PanelFrame *frame = (PanelFrame *) widget;
212
gboolean retval = FALSE;
214
if (!gtk_widget_is_drawable (widget))
217
if (GTK_WIDGET_CLASS (panel_frame_parent_class)->expose_event)
218
retval = GTK_WIDGET_CLASS (panel_frame_parent_class)->expose_event (widget, event);
220
panel_frame_draw (widget, frame->edges);
278
gboolean retval = FALSE;
280
if (GTK_WIDGET_CLASS (panel_frame_parent_class)->draw)
281
retval = GTK_WIDGET_CLASS (panel_frame_parent_class)->draw (widget, cr);
283
panel_frame_draw (widget, cr, PANEL_FRAME (widget)->edges);