annotate audacious/tbutton.c @ 611:a2b151a53bca trunk

[svn] we never did anything here, removing for confusion
author nenolod
date Sat, 04 Feb 2006 11:30:06 -0800
parents cb178e5ad177
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #include "tbutton.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <gdk/gdk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include "widget.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 tbutton_draw(Widget * w)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 TButton *button = TBUTTON(w);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 GdkPixmap *obj;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 obj = button->tb_widget.parent;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 if (button->tb_pressed && button->tb_inside) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 if (button->tb_selected) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 button->tb_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 button->tb_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 button->tb_psx, button->tb_psy,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 button->tb_widget.x, button->tb_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 button->tb_widget.width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 button->tb_widget.height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 button->tb_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 button->tb_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 button->tb_pux, button->tb_puy,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 button->tb_widget.x, button->tb_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 button->tb_widget.width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 button->tb_widget.height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 if (button->tb_selected) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 button->tb_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 button->tb_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 button->tb_nsx, button->tb_nsy,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 button->tb_widget.x, button->tb_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 button->tb_widget.width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 button->tb_widget.height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 skin_draw_pixmap(bmp_active_skin, obj,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 button->tb_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 button->tb_skin_index,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 button->tb_nux, button->tb_nuy,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 button->tb_widget.x, button->tb_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 button->tb_widget.width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 button->tb_widget.height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 tbutton_button_press_cb(GtkWidget * widget, GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 TButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 if (event->button != 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 if (widget_contains(&button->tb_widget, event->x, event->y)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 button->tb_pressed = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 button->tb_inside = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 widget_draw(WIDGET(button));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 tbutton_button_release_cb(GtkWidget * widget, GdkEventButton * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 TButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 if (event->button != 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 if (button->tb_inside && button->tb_pressed) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 button->tb_inside = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 button->tb_selected = !button->tb_selected;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 widget_draw(WIDGET(button));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 if (button->tb_push_cb)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 button->tb_push_cb(button->tb_selected);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 if (button->tb_pressed)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 button->tb_pressed = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 tbutton_motion_cb(GtkWidget * widget, GdkEventMotion * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 TButton * button)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 gint inside;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 if (!button->tb_pressed)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 inside = widget_contains(&button->tb_widget, event->x, event->y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 if (inside != button->tb_inside) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 button->tb_inside = inside;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 widget_draw(WIDGET(button));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 TButton *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 create_tbutton(GList ** wlist, GdkPixmap * parent, GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 gint x, gint y, gint w, gint h, gint nux, gint nuy,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 gint pux, gint puy, gint nsx, gint nsy, gint psx,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 gint psy, void (*cb) (gboolean), SkinPixmapId si)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 TButton *b;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 b = g_new0(TButton, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 widget_init(&b->tb_widget, parent, gc, x, y, w, h, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 b->tb_widget.button_press_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 tbutton_button_press_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 b->tb_widget.button_release_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 (void (*)(GtkWidget *, GdkEventButton *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 tbutton_button_release_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 b->tb_widget.motion_cb =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 (void (*)(GtkWidget *, GdkEventMotion *, gpointer))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 tbutton_motion_cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 b->tb_widget.draw = tbutton_draw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 b->tb_nux = nux;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 b->tb_nuy = nuy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 b->tb_pux = pux;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 b->tb_puy = puy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 b->tb_nsx = nsx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 b->tb_nsy = nsy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 b->tb_psx = psx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 b->tb_psy = psy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 b->tb_push_cb = cb;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 b->tb_skin_index = si;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 widget_list_add(wlist, WIDGET(b));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 return b;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 tbutton_set_toggled(TButton * tb, gboolean toggled)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 tb->tb_selected = toggled;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 widget_draw(WIDGET(tb));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 free_tbutton(TButton * b)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 g_free(b);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 }