annotate src/audacious/ui_skinned_horizontal_slider.c @ 3294:2c167f1fbbe9 trunk

oops, I haven't noticed that credits are sorted alphabetically by surname
author Tomasz Mon <desowin@gmail.com>
date Fri, 10 Aug 2007 10:43:27 +0200
parents f02623377013
children 6cadc2ddf4cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2007 Audacious development team.
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3105
diff changeset
13 * the Free Software Foundation; under version 3 of the License.
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3105
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
22 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
23 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
24 * Audacious or using our public API to be a derived work.
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 */
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_skinned_horizontal_slider.h"
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "main.h"
3059
f58cbfe8df1b use create_dblsize_image for doueblesizing
Tomasz Mon <desowin@gmail.com>
parents: 3053
diff changeset
29 #include "util.h"
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30
3105
1912eba1004b cleaning
Tomasz Mon <desowin@gmail.com>
parents: 3103
diff changeset
31 #define UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_horizontal_slider_get_type(), UiSkinnedHorizontalSliderPrivate))
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 typedef struct _UiSkinnedHorizontalSliderPrivate UiSkinnedHorizontalSliderPrivate;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 enum {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 MOTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 RELEASE,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 DOUBLED,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 LAST_SIGNAL
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 struct _UiSkinnedHorizontalSliderPrivate {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 GtkWidget *fixed;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 SkinPixmapId skin_index;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 gboolean double_size;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 gint frame, frame_offset, frame_height, min, max;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 gint knob_width, knob_height;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 gint position;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 gint width, height;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 gint (*frame_cb) (gint);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static void ui_skinned_horizontal_slider_class_init (UiSkinnedHorizontalSliderClass *klass);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 static void ui_skinned_horizontal_slider_init (UiSkinnedHorizontalSlider *horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 static void ui_skinned_horizontal_slider_destroy (GtkObject *object);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static void ui_skinned_horizontal_slider_realize (GtkWidget *widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 static void ui_skinned_horizontal_slider_size_request (GtkWidget *widget, GtkRequisition *requisition);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 static void ui_skinned_horizontal_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static gboolean ui_skinned_horizontal_slider_expose (GtkWidget *widget, GdkEventExpose *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 static gboolean ui_skinned_horizontal_slider_button_press (GtkWidget *widget, GdkEventButton *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 static gboolean ui_skinned_horizontal_slider_button_release (GtkWidget *widget, GdkEventButton *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 static gboolean ui_skinned_horizontal_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 static void ui_skinned_horizontal_slider_toggle_doublesize (UiSkinnedHorizontalSlider *horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 static GtkWidgetClass *parent_class = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 static guint horizontal_slider_signals[LAST_SIGNAL] = { 0 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 GType ui_skinned_horizontal_slider_get_type() {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 static GType horizontal_slider_type = 0;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 if (!horizontal_slider_type) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 static const GTypeInfo horizontal_slider_info = {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 sizeof (UiSkinnedHorizontalSliderClass),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 (GClassInitFunc) ui_skinned_horizontal_slider_class_init,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 sizeof (UiSkinnedHorizontalSlider),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 0,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 (GInstanceInitFunc) ui_skinned_horizontal_slider_init,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 horizontal_slider_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedHorizontalSlider", &horizontal_slider_info, 0);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 return horizontal_slider_type;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 static void ui_skinned_horizontal_slider_class_init(UiSkinnedHorizontalSliderClass *klass) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 GObjectClass *gobject_class;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 GtkObjectClass *object_class;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 GtkWidgetClass *widget_class;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 gobject_class = G_OBJECT_CLASS(klass);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 object_class = (GtkObjectClass*) klass;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 widget_class = (GtkWidgetClass*) klass;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 parent_class = gtk_type_class (gtk_widget_get_type ());
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 object_class->destroy = ui_skinned_horizontal_slider_destroy;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 widget_class->realize = ui_skinned_horizontal_slider_realize;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 widget_class->expose_event = ui_skinned_horizontal_slider_expose;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 widget_class->size_request = ui_skinned_horizontal_slider_size_request;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102 widget_class->size_allocate = ui_skinned_horizontal_slider_size_allocate;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 widget_class->button_press_event = ui_skinned_horizontal_slider_button_press;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 widget_class->button_release_event = ui_skinned_horizontal_slider_button_release;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105 widget_class->motion_notify_event = ui_skinned_horizontal_slider_motion_notify;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 klass->motion = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 klass->release = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 klass->doubled = ui_skinned_horizontal_slider_toggle_doublesize;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 horizontal_slider_signals[MOTION] =
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 g_signal_new ("motion", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, motion), NULL, NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 horizontal_slider_signals[RELEASE] =
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 g_signal_new ("release", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, release), NULL, NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 horizontal_slider_signals[DOUBLED] =
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, doubled), NULL, NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 g_type_class_add_private (gobject_class, sizeof (UiSkinnedHorizontalSliderPrivate));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129 static void ui_skinned_horizontal_slider_init(UiSkinnedHorizontalSlider *horizontal_slider) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 horizontal_slider->pressed = FALSE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 GtkWidget* ui_skinned_horizontal_slider_new(GtkWidget *fixed, gint x, gint y, gint w, gint h, gint knx, gint kny,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 gint kpx, gint kpy, gint kw, gint kh, gint fh,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 gint fo, gint min, gint max, gint(*fcb) (gint), SkinPixmapId si) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 UiSkinnedHorizontalSlider *hs = g_object_new (ui_skinned_horizontal_slider_get_type (), NULL);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 hs->x = x;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 hs->y = y;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 priv->width = w;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 priv->height = h;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 priv->fixed = fixed;
3042
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
145 hs->knob_nx = knx;
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
146 hs->knob_ny = kny;
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
147 hs->knob_px = kpx;
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
148 hs->knob_py = kpy;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 priv->knob_width = kw;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 priv->knob_height = kh;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 priv->frame_height = fh;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 priv->frame_offset = fo;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 priv->min = min;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 priv->position = min;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 priv->max = max;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 priv->frame_cb = fcb;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 if (priv->frame_cb)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 priv->frame = priv->frame_cb(0);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 priv->skin_index = si;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 gtk_fixed_put(GTK_FIXED(priv->fixed), GTK_WIDGET(hs), hs->x, hs->y);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163 return GTK_WIDGET(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 static void ui_skinned_horizontal_slider_destroy(GtkObject *object) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 UiSkinnedHorizontalSlider *horizontal_slider;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 g_return_if_fail (object != NULL);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (object));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (object);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 if (GTK_OBJECT_CLASS (parent_class)->destroy)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178 static void ui_skinned_horizontal_slider_realize(GtkWidget *widget) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 UiSkinnedHorizontalSlider *horizontal_slider;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 GdkWindowAttr attributes;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 gint attributes_mask;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
182
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183 g_return_if_fail (widget != NULL);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER(widget));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187 horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189 attributes.x = widget->allocation.x;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 attributes.y = widget->allocation.y;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 attributes.width = widget->allocation.width;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192 attributes.height = widget->allocation.height;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 attributes.wclass = GDK_INPUT_OUTPUT;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 attributes.window_type = GDK_WINDOW_CHILD;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195 attributes.event_mask = gtk_widget_get_events(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
3051
befb8b7df9e6 correct sliders
Tomasz Mon <desowin@gmail.com>
parents: 3042
diff changeset
197 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 attributes.visual = gtk_widget_get_visual(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199 attributes.colormap = gtk_widget_get_colormap(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203
3052
b1b48ea20c16 Hooray, fix BadMatches
Tomasz Mon <desowin@gmail.com>
parents: 3051
diff changeset
204 widget->style = gtk_style_attach(widget->style, widget->window);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205 gdk_window_set_user_data(widget->window, widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 static void ui_skinned_horizontal_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 requisition->width = priv->width*(1+priv->double_size);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 requisition->height = priv->height*(1+priv->double_size);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 static void ui_skinned_horizontal_slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216 UiSkinnedHorizontalSlider *horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 widget->allocation = *allocation;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 widget->allocation.x *= (1+priv->double_size);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 widget->allocation.y *= (1+priv->double_size);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 if (GTK_WIDGET_REALIZED (widget))
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 horizontal_slider->x = widget->allocation.x/(priv->double_size ? 2 : 1);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 horizontal_slider->y = widget->allocation.y/(priv->double_size ? 2 : 1);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229 static gboolean ui_skinned_horizontal_slider_expose(GtkWidget *widget, GdkEventExpose *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 g_return_val_if_fail (widget != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232 g_return_val_if_fail (event != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 GdkPixmap *obj = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 GdkGC *gc;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239
3053
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
240 if (priv->position > priv->max) priv->position = priv->max;
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
241 else if (priv->position < priv->min) priv->position = priv->min;
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
242
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244 gc = gdk_gc_new(obj);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246 skin_draw_pixmap(bmp_active_skin, obj, gc,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 priv->skin_index, priv->frame_offset,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 priv->frame * priv->frame_height,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 0, 0, priv->width, priv->height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 if (hs->pressed)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 skin_draw_pixmap(bmp_active_skin, obj, gc,
3042
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
252 priv->skin_index, hs->knob_px,
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
253 hs->knob_py, priv->position,
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 ((priv->height - priv->knob_height) / 2),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 priv->knob_width, priv->knob_height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256 else
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 skin_draw_pixmap(bmp_active_skin, obj, gc,
3042
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
258 priv->skin_index, hs->knob_nx,
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
259 hs->knob_ny, priv->position,
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 ((priv->height - priv->knob_height) / 2),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 priv->knob_width, priv->knob_height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262
3077
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
263 GdkPixmap *image = NULL;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 if (priv->double_size) {
3077
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
266 image = create_dblsize_pixmap(obj);
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
267 } else {
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
268 image = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269 gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, priv->width, priv->height);
3077
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
270 }
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272 g_object_unref(obj);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 priv->width*(1+priv->double_size), priv->height*(1+priv->double_size));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 g_object_unref(gc);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277 g_object_unref(image);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 return FALSE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282 static gboolean ui_skinned_horizontal_slider_button_press(GtkWidget *widget, GdkEventButton *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 g_return_val_if_fail (widget != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285 g_return_val_if_fail (event != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290 if (event->type == GDK_BUTTON_PRESS) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 if (event->button == 1) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 gint x;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293
3053
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
294 x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2));
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 hs->pressed = TRUE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296
3053
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
297 priv->position = x/(1+priv->double_size);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 if (priv->position < priv->min)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 priv->position = priv->min;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300 if (priv->position > priv->max)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301 priv->position = priv->max;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302 if (priv->frame_cb)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 priv->frame = priv->frame_cb(priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
304
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
305 g_signal_emit_by_name(widget, "motion", priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306 gtk_widget_queue_draw(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 return TRUE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
310 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
312 static gboolean ui_skinned_horizontal_slider_button_release(GtkWidget *widget, GdkEventButton *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
313 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
314 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
315
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316 if (event->button == 1) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317 hs->pressed = FALSE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 g_signal_emit_by_name(widget, "release", priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 gtk_widget_queue_draw(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321 return TRUE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 static gboolean ui_skinned_horizontal_slider_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 g_return_val_if_fail (widget != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 g_return_val_if_fail (event != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 if (hs->pressed) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 gint x;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333
3053
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
334 x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2));
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
335 priv->position = x/(1+priv->double_size);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 if (priv->position < priv->min)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 priv->position = priv->min;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 if (priv->position > priv->max)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 priv->position = priv->max;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343 if (priv->frame_cb)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 priv->frame = priv->frame_cb(priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 g_signal_emit_by_name(widget, "motion", priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 gtk_widget_queue_draw(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 return TRUE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 static void ui_skinned_horizontal_slider_toggle_doublesize(UiSkinnedHorizontalSlider *horizontal_slider) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 GtkWidget *widget = GTK_WIDGET (horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 priv->double_size = !priv->double_size;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 gtk_widget_set_size_request(widget, priv->width*(1+priv->double_size), priv->height*(1+priv->double_size));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 gtk_widget_queue_draw(GTK_WIDGET(horizontal_slider));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 void ui_skinned_horizontal_slider_set_position(GtkWidget *widget, gint pos) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369 if (pos == priv->position || hs->pressed)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 return;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372 priv->position = pos;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374 if (priv->frame_cb)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 priv->frame = priv->frame_cb(priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 gtk_widget_queue_draw(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
379
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 gint ui_skinned_horizontal_slider_get_position(GtkWidget *widget) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), -1);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
383 return priv->position;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384 }