annotate src/skins/ui_skinned_number.c @ 3032:6baa6eaf8290

Don't use deprecated gtk_type_class()
author Tomasz Mon <desowin@gmail.com>
date Fri, 10 Apr 2009 11:02:41 +0200
parents 963796db51ea
children ab8771a5f654
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2007 Tomasz Moń
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; under version 3 of the License.
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses>.
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 *
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 * The Audacious team does not consider modular code linking to
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24 * Audacious or using our public API to be a derived work.
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 */
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_skinned_number.h"
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "skins_cfg.h"
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 #include "strings.h"
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include <string.h>
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include <ctype.h>
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include <gtk/gtkmain.h>
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 #include <gtk/gtkmarshal.h>
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 #define UI_TYPE_SKINNED_NUMBER (ui_skinned_number_get_type())
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 enum {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 DOUBLED,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 LAST_SIGNAL
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 };
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 static void ui_skinned_number_class_init (UiSkinnedNumberClass *klass);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 static void ui_skinned_number_init (UiSkinnedNumber *number);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 static void ui_skinned_number_destroy (GtkObject *object);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 static void ui_skinned_number_realize (GtkWidget *widget);
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
46 static void ui_skinned_number_unrealize (GtkWidget *widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
47 static void ui_skinned_number_map (GtkWidget *widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
48 static void ui_skinned_number_unmap (GtkWidget *widget);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 static void ui_skinned_number_size_request (GtkWidget *widget, GtkRequisition *requisition);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 static void ui_skinned_number_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 static gboolean ui_skinned_number_expose (GtkWidget *widget, GdkEventExpose *event);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static void ui_skinned_number_toggle_scaled (UiSkinnedNumber *number);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 static GtkWidgetClass *parent_class = NULL;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static guint number_signals[LAST_SIGNAL] = { 0 };
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 GType ui_skinned_number_get_type() {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static GType number_type = 0;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 if (!number_type) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 static const GTypeInfo number_info = {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 sizeof (UiSkinnedNumberClass),
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 NULL,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 NULL,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 (GClassInitFunc) ui_skinned_number_class_init,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 NULL,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 NULL,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 sizeof (UiSkinnedNumber),
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 0,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 (GInstanceInitFunc) ui_skinned_number_init,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 };
2590
Tomasz Mon <desowin@gmail.com>
parents: 2588
diff changeset
71 number_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedNumber", &number_info, 0);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 return number_type;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 static void ui_skinned_number_class_init(UiSkinnedNumberClass *klass) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 GtkObjectClass *object_class;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 GtkWidgetClass *widget_class;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 object_class = (GtkObjectClass*) klass;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 widget_class = (GtkWidgetClass*) klass;
3032
6baa6eaf8290 Don't use deprecated gtk_type_class()
Tomasz Mon <desowin@gmail.com>
parents: 3017
diff changeset
83 parent_class = g_type_class_peek_parent(klass);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 object_class->destroy = ui_skinned_number_destroy;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 widget_class->realize = ui_skinned_number_realize;
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
88 widget_class->unrealize = ui_skinned_number_unrealize;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
89 widget_class->map = ui_skinned_number_map;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
90 widget_class->unmap = ui_skinned_number_unmap;
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 widget_class->expose_event = ui_skinned_number_expose;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 widget_class->size_request = ui_skinned_number_size_request;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 widget_class->size_allocate = ui_skinned_number_size_allocate;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 klass->scaled = ui_skinned_number_toggle_scaled;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 number_signals[DOUBLED] =
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 G_STRUCT_OFFSET (UiSkinnedNumberClass, scaled), NULL, NULL,
3017
963796db51ea Don't use deprecated gtk macros and types
Tomasz Mon <desowin@gmail.com>
parents: 2888
diff changeset
100 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 static void ui_skinned_number_init(UiSkinnedNumber *number) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 number->width = 9;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105 number->height = 13;
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
106
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
107 number->event_window = NULL;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
108 GTK_WIDGET_SET_FLAGS(number, GTK_NO_WINDOW);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 GtkWidget* ui_skinned_number_new(GtkWidget *fixed, gint x, gint y, SkinPixmapId si) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 UiSkinnedNumber *number = g_object_new (ui_skinned_number_get_type (), NULL);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 number->x = x;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 number->y = y;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 number->num = 0;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 number->skin_index = si;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 number->scaled = FALSE;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(number), number->x, number->y);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 return GTK_WIDGET(number);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 static void ui_skinned_number_destroy(GtkObject *object) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 UiSkinnedNumber *number;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129 g_return_if_fail (object != NULL);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 g_return_if_fail (UI_SKINNED_IS_NUMBER (object));
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 number = UI_SKINNED_NUMBER (object);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 if (GTK_OBJECT_CLASS (parent_class)->destroy)
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138 static void ui_skinned_number_realize(GtkWidget *widget) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 UiSkinnedNumber *number;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 GdkWindowAttr attributes;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 gint attributes_mask;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 g_return_if_fail (widget != NULL);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 g_return_if_fail (UI_SKINNED_IS_NUMBER(widget));
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
146 if (GTK_WIDGET_CLASS (parent_class)->realize)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
147 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 number = UI_SKINNED_NUMBER(widget);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 attributes.x = widget->allocation.x;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 attributes.y = widget->allocation.y;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 attributes.width = widget->allocation.width;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 attributes.height = widget->allocation.height;
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
154 attributes.wclass = GDK_INPUT_ONLY;
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 attributes.window_type = GDK_WINDOW_CHILD;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 attributes.event_mask = gtk_widget_get_events(widget);
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
157 attributes.event_mask |= GDK_BUTTON_PRESS_MASK;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
158
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
159 attributes_mask = GDK_WA_X | GDK_WA_Y;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
160 number->event_window = gdk_window_new (widget->window, &attributes, attributes_mask);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
161
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
162 gdk_window_set_user_data(number->event_window, widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
163 }
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
164
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
165 static void ui_skinned_number_unrealize(GtkWidget *widget) {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
166 UiSkinnedNumber *number = UI_SKINNED_NUMBER(widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
167
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
168 if ( number->event_window != NULL )
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
169 {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
170 gdk_window_set_user_data( number->event_window , NULL );
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
171 gdk_window_destroy( number->event_window );
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
172 number->event_window = NULL;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
173 }
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
175 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
176 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
177 }
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
178
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
179 static void ui_skinned_number_map (GtkWidget *widget)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
180 {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
181 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
182
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
183 if (number->event_window != NULL)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
184 gdk_window_show (number->event_window);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
186 if (GTK_WIDGET_CLASS (parent_class)->map)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
187 (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
188 }
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
190 static void ui_skinned_number_unmap (GtkWidget *widget)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
191 {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
192 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
193
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
194 if (number->event_window != NULL)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
195 gdk_window_hide (number->event_window);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
196
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
197 if (GTK_WIDGET_CLASS (parent_class)->unmap)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
198 (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 static void ui_skinned_number_size_request(GtkWidget *widget, GtkRequisition *requisition) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 UiSkinnedNumber *number = UI_SKINNED_NUMBER(widget);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204 requisition->width = number->width * ( number->scaled ? config.scale_factor : 1 );
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205 requisition->height = number->height*( number->scaled ? config.scale_factor : 1);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 static void ui_skinned_number_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 widget->allocation = *allocation;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 widget->allocation.x *= (number->scaled ? config.scale_factor: 1 );
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 widget->allocation.y *= (number->scaled ? config.scale_factor: 1 );
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 if (GTK_WIDGET_REALIZED (widget))
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
215 if (number->event_window)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
216 gdk_window_move_resize(number->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 number->x = widget->allocation.x/(number->scaled ? config.scale_factor : 1);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 number->y = widget->allocation.y/(number->scaled ? config.scale_factor : 1);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 static gboolean ui_skinned_number_expose(GtkWidget *widget, GdkEventExpose *event) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 g_return_val_if_fail (widget != NULL, FALSE);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 g_return_val_if_fail (UI_SKINNED_IS_NUMBER (widget), FALSE);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 g_return_val_if_fail (event != NULL, FALSE);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228 g_return_val_if_fail (number->width > 0 && number->height > 0, FALSE);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 GdkPixbuf *obj;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, number->width, number->height);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 if (number->num > 11 || number->num < 0)
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234 number->num = 10;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 skin_draw_pixbuf(widget, aud_active_skin, obj,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 number->skin_index, number->num * 9, 0,
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 0, 0, number->width, number->height);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
240 ui_skinned_widget_draw_with_coordinates(widget, obj, number->width, number->height,
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
241 widget->allocation.x,
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
242 widget->allocation.y,
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
243 number->scaled);
2588
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 g_object_unref(obj);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 return FALSE;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 static void ui_skinned_number_toggle_scaled(UiSkinnedNumber *number) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 GtkWidget *widget = GTK_WIDGET (number);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 number->scaled = !number->scaled;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 gtk_widget_set_size_request(widget, number->width * ( number->scaled ? config.scale_factor : 1),
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 number->height * ( number->scaled ? config.scale_factor : 1) );
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 gtk_widget_queue_draw(GTK_WIDGET(number));
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 void ui_skinned_number_set_number(GtkWidget *widget, gint num) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 g_return_if_fail(UI_SKINNED_IS_NUMBER(widget));
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 if (number->num == num)
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 return;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 number->num = num;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268 gtk_widget_queue_draw(GTK_WIDGET(number));
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269 }
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 void ui_skinned_number_set_size(GtkWidget *widget, gint width, gint height) {
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272 g_return_if_fail(UI_SKINNED_IS_NUMBER(widget));
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 number->width = width;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 number->height = height;
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 gtk_widget_set_size_request(widget, width*(number->scaled ? config.scale_factor : 1 ),
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 height*(number->scaled ? config.scale_factor : 1 ));
fa798fbd5fe9 add ui_skinned_number
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 }