Mercurial > audlegacy
annotate src/audacious/ui_skinned_textbox.c @ 4119:9d4b5cdae3ba
oops, fix previous commit
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Tue, 25 Dec 2007 16:42:10 +0100 |
parents | 1112f53ecc18 |
children | 07c1639b110b |
rev | line source |
---|---|
2911 | 1 /* |
2 * Audacious - a cross-platform multimedia player | |
3840 | 3 * Copyright (c) 2007 Tomasz Moń |
2911 | 4 * |
5 * Based on: | |
6 * BMP - Cross-platform multimedia player | |
7 * Copyright (C) 2003-2004 BMP development team. | |
8 * XMMS: | |
9 * Copyright (C) 1998-2003 XMMS development team. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
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. |
2911 | 14 * |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
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. |
2911 | 25 */ |
26 | |
27 #include "ui_skinned_textbox.h" | |
28 #include "main.h" | |
29 #include "util.h" | |
30 #include "strings.h" | |
31 #include <string.h> | |
32 | |
3105 | 33 #define UI_SKINNED_TEXTBOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_textbox_get_type(), UiSkinnedTextboxPrivate)) |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
34 typedef struct _UiSkinnedTextboxPrivate UiSkinnedTextboxPrivate; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
35 |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
36 #define TEXTBOX_SCROLL_SMOOTH_TIMEOUT 30 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
37 #define TEXTBOX_SCROLL_WAIT 80 |
2965
f84d09bada0f
correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents:
2962
diff
changeset
|
38 |
2911 | 39 enum { |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
40 CLICKED, |
2911 | 41 DOUBLE_CLICKED, |
42 RIGHT_CLICKED, | |
43 DOUBLED, | |
44 REDRAW, | |
45 LAST_SIGNAL | |
46 }; | |
47 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
48 struct _UiSkinnedTextboxPrivate { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
49 SkinPixmapId skin_index; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
50 gboolean double_size; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
51 gboolean scroll_back; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
52 gint nominal_y, nominal_height; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
53 gint scroll_timeout; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
54 gint font_ascent, font_descent; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
55 PangoFontDescription *font; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
56 gchar *fontname; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
57 gchar *pixmap_text; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
58 gint skin_id; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
59 gint drag_x, drag_off, offset; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
60 gboolean is_scrollable, is_dragging; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
61 gint pixmap_width; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
62 GdkPixmap *pixmap; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
63 gboolean scroll_allowed, scroll_enabled; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
64 gint scroll_dummy; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
65 gint move_x, move_y; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
66 }; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
67 |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
68 static void ui_skinned_textbox_class_init (UiSkinnedTextboxClass *klass); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
69 static void ui_skinned_textbox_init (UiSkinnedTextbox *textbox); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
70 static void ui_skinned_textbox_destroy (GtkObject *object); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
71 static void ui_skinned_textbox_realize (GtkWidget *widget); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
72 static void ui_skinned_textbox_size_request (GtkWidget *widget, GtkRequisition *requisition); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
73 static void ui_skinned_textbox_size_allocate (GtkWidget *widget, GtkAllocation *allocation); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
74 static gboolean ui_skinned_textbox_expose (GtkWidget *widget, GdkEventExpose *event); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
75 static gboolean ui_skinned_textbox_button_press (GtkWidget *widget, GdkEventButton *event); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
76 static gboolean ui_skinned_textbox_button_release (GtkWidget *widget, GdkEventButton *event); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
77 static gboolean ui_skinned_textbox_motion_notify (GtkWidget *widget, GdkEventMotion *event); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
78 static void ui_skinned_textbox_toggle_doublesize (UiSkinnedTextbox *textbox); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
79 static void ui_skinned_textbox_redraw (UiSkinnedTextbox *textbox); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
80 static gboolean ui_skinned_textbox_should_scroll (UiSkinnedTextbox *textbox); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
81 static void textbox_generate_xfont_pixmap (UiSkinnedTextbox *textbox, const gchar *pixmaptext); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
82 static gboolean textbox_scroll (gpointer data); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
83 static void textbox_generate_pixmap (UiSkinnedTextbox *textbox); |
3038
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
84 static void textbox_handle_special_char (gchar *c, gint * x, gint * y); |
2911 | 85 |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
86 static GtkWidgetClass *parent_class = NULL; |
2911 | 87 static guint textbox_signals[LAST_SIGNAL] = { 0 }; |
88 | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
89 GType ui_skinned_textbox_get_type() { |
2911 | 90 static GType textbox_type = 0; |
91 if (!textbox_type) { | |
92 static const GTypeInfo textbox_info = { | |
93 sizeof (UiSkinnedTextboxClass), | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
94 NULL, |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
95 NULL, |
2911 | 96 (GClassInitFunc) ui_skinned_textbox_class_init, |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
97 NULL, |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
98 NULL, |
2911 | 99 sizeof (UiSkinnedTextbox), |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
100 0, |
2911 | 101 (GInstanceInitFunc) ui_skinned_textbox_init, |
102 }; | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
103 textbox_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedTextbox", &textbox_info, 0); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
104 } |
2911 | 105 |
106 return textbox_type; | |
107 } | |
108 | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
109 static void ui_skinned_textbox_class_init(UiSkinnedTextboxClass *klass) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
110 GObjectClass *gobject_class; |
2911 | 111 GtkObjectClass *object_class; |
112 GtkWidgetClass *widget_class; | |
113 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
114 gobject_class = G_OBJECT_CLASS(klass); |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
115 object_class = (GtkObjectClass*) klass; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
116 widget_class = (GtkWidgetClass*) klass; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
117 parent_class = gtk_type_class (gtk_widget_get_type ()); |
2911 | 118 |
119 object_class->destroy = ui_skinned_textbox_destroy; | |
120 | |
121 widget_class->realize = ui_skinned_textbox_realize; | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
122 widget_class->expose_event = ui_skinned_textbox_expose; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
123 widget_class->size_request = ui_skinned_textbox_size_request; |
2911 | 124 widget_class->size_allocate = ui_skinned_textbox_size_allocate; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
125 widget_class->button_press_event = ui_skinned_textbox_button_press; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
126 widget_class->button_release_event = ui_skinned_textbox_button_release; |
2911 | 127 widget_class->motion_notify_event = ui_skinned_textbox_motion_notify; |
128 | |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
129 klass->clicked = NULL; |
2911 | 130 klass->double_clicked = NULL; |
131 klass->right_clicked = NULL; | |
132 klass->doubled = ui_skinned_textbox_toggle_doublesize; | |
133 klass->redraw = ui_skinned_textbox_redraw; | |
134 | |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
135 textbox_signals[CLICKED] = |
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
136 g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
137 G_STRUCT_OFFSET (UiSkinnedTextboxClass, clicked), NULL, NULL, |
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
138 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
139 |
2911 | 140 textbox_signals[DOUBLE_CLICKED] = |
141 g_signal_new ("double-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, | |
142 G_STRUCT_OFFSET (UiSkinnedTextboxClass, double_clicked), NULL, NULL, | |
143 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); | |
144 | |
145 textbox_signals[RIGHT_CLICKED] = | |
146 g_signal_new ("right-clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, | |
147 G_STRUCT_OFFSET (UiSkinnedTextboxClass, right_clicked), NULL, NULL, | |
148 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); | |
149 | |
150 textbox_signals[DOUBLED] = | |
151 g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, | |
152 G_STRUCT_OFFSET (UiSkinnedTextboxClass, doubled), NULL, NULL, | |
153 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); | |
154 | |
155 textbox_signals[REDRAW] = | |
156 g_signal_new ("redraw", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, | |
157 G_STRUCT_OFFSET (UiSkinnedTextboxClass, redraw), NULL, NULL, | |
158 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
159 |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
160 g_type_class_add_private (gobject_class, sizeof (UiSkinnedTextboxPrivate)); |
2911 | 161 } |
162 | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
163 static void ui_skinned_textbox_init(UiSkinnedTextbox *textbox) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
164 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
165 priv->move_x = 0; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
166 priv->move_y = 0; |
2911 | 167 } |
168 | |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
169 GtkWidget* ui_skinned_textbox_new(GtkWidget *fixed, gint x, gint y, gint w, gboolean allow_scroll, SkinPixmapId si) { |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
170 UiSkinnedTextbox *textbox = g_object_new (ui_skinned_textbox_get_type (), NULL); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
171 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
2911 | 172 |
173 textbox->height = bmp_active_skin->properties.textbox_bitmap_font_height; | |
174 textbox->x = x; | |
175 textbox->y = y; | |
2957
c859aa1a1a4e
don't update text if it haven't changed
Tomasz Mon <desowin@gmail.com>
parents:
2956
diff
changeset
|
176 textbox->text = g_strdup(""); |
2947 | 177 textbox->width = w; |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
178 priv->scroll_allowed = allow_scroll; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
179 priv->scroll_enabled = TRUE; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
180 priv->skin_index = si; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
181 priv->nominal_y = y; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
182 priv->nominal_height = textbox->height; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
183 priv->scroll_timeout = 0; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
184 priv->scroll_dummy = 0; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
185 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
186 priv->double_size = FALSE; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
187 |
3939
d46d60247826
we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents:
3933
diff
changeset
|
188 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(textbox), textbox->x, textbox->y); |
2982 | 189 |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
190 return GTK_WIDGET(textbox); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
191 } |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
192 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
193 static void ui_skinned_textbox_destroy(GtkObject *object) { |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
194 UiSkinnedTextbox *textbox; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
195 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
196 g_return_if_fail (object != NULL); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
197 g_return_if_fail (UI_SKINNED_IS_TEXTBOX (object)); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
198 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
199 textbox = UI_SKINNED_TEXTBOX (object); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
200 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
201 if (GTK_OBJECT_CLASS (parent_class)->destroy) |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
202 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
203 } |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
204 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
205 static void ui_skinned_textbox_realize(GtkWidget *widget) { |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
206 UiSkinnedTextbox *textbox; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
207 GdkWindowAttr attributes; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
208 gint attributes_mask; |
2911 | 209 |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
210 g_return_if_fail (widget != NULL); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
211 g_return_if_fail (UI_SKINNED_IS_TEXTBOX(widget)); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
212 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
213 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
214 textbox = UI_SKINNED_TEXTBOX(widget); |
2911 | 215 |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
216 attributes.x = widget->allocation.x; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
217 attributes.y = widget->allocation.y; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
218 attributes.width = widget->allocation.width; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
219 attributes.height = widget->allocation.height; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
220 attributes.wclass = GDK_INPUT_OUTPUT; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
221 attributes.window_type = GDK_WINDOW_CHILD; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
222 attributes.event_mask = gtk_widget_get_events(widget); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
223 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
224 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
225 GDK_POINTER_MOTION_HINT_MASK; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
226 attributes.visual = gtk_widget_get_visual(widget); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
227 attributes.colormap = gtk_widget_get_colormap(widget); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
228 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
229 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
230 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
231 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
232 widget->style = gtk_style_attach(widget->style, widget->window); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
233 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
234 gdk_window_set_user_data(widget->window, widget); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
235 } |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
236 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
237 static void ui_skinned_textbox_size_request(GtkWidget *widget, GtkRequisition *requisition) { |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
238 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(widget); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
239 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
240 |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
241 requisition->width = textbox->width*(1+priv->double_size); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
242 requisition->height = textbox->height*(1+priv->double_size); |
2911 | 243 } |
244 | |
245 static void ui_skinned_textbox_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { | |
246 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
247 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
248 |
2911 | 249 widget->allocation = *allocation; |
3011
99865f696f13
don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
250 widget->allocation.x *= (1+priv->double_size); |
99865f696f13
don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
251 widget->allocation.y *= (1+priv->double_size); |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
252 if (GTK_WIDGET_REALIZED (widget)) |
3011
99865f696f13
don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
253 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); |
2911 | 254 |
3137
19908efce4e5
one mutex is enough for resizing
Tomasz Mon <desowin@gmail.com>
parents:
3123
diff
changeset
|
255 if (textbox->x + priv->move_x == widget->allocation.x/(priv->double_size ? 2 : 1)) |
19908efce4e5
one mutex is enough for resizing
Tomasz Mon <desowin@gmail.com>
parents:
3123
diff
changeset
|
256 priv->move_x = 0; |
19908efce4e5
one mutex is enough for resizing
Tomasz Mon <desowin@gmail.com>
parents:
3123
diff
changeset
|
257 if (textbox->y + priv->move_y == widget->allocation.y/(priv->double_size ? 2 : 1)) |
19908efce4e5
one mutex is enough for resizing
Tomasz Mon <desowin@gmail.com>
parents:
3123
diff
changeset
|
258 priv->move_y = 0; |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
259 textbox->x = widget->allocation.x/(priv->double_size ? 2 : 1); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
260 textbox->y = widget->allocation.y/(priv->double_size ? 2 : 1); |
2919 | 261 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
262 if (textbox->width != widget->allocation.width/(priv->double_size ? 2 : 1)) { |
3250
2d43219d2799
solve always broken ui_skinned_textbox_resize_relative
Tomasz Mon <desowin@gmail.com>
parents:
3230
diff
changeset
|
263 textbox->width = widget->allocation.width/(priv->double_size ? 2 : 1); |
3222
bb7f5adc1677
I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents:
3137
diff
changeset
|
264 if (priv->pixmap_text) g_free(priv->pixmap_text); |
bb7f5adc1677
I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents:
3137
diff
changeset
|
265 priv->pixmap_text = NULL; |
bb7f5adc1677
I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents:
3137
diff
changeset
|
266 priv->offset = 0; |
bb7f5adc1677
I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents:
3137
diff
changeset
|
267 gtk_widget_set_size_request(widget, textbox->width, textbox->height); |
bb7f5adc1677
I hope textbox_resize_relative is now working propertly
Tomasz Mon <desowin@gmail.com>
parents:
3137
diff
changeset
|
268 gtk_widget_queue_draw(GTK_WIDGET(textbox)); |
2919 | 269 } |
2911 | 270 } |
271 | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
272 static gboolean ui_skinned_textbox_expose(GtkWidget *widget, GdkEventExpose *event) { |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
273 g_return_val_if_fail (widget != NULL, FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
274 g_return_val_if_fail (UI_SKINNED_IS_TEXTBOX (widget), FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
275 g_return_val_if_fail (event != NULL, FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
276 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
277 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
278 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
4119 | 279 g_return_val_if_fail (textbox->width > 0 && textbox->height > 0, FALSE); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
280 |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
281 GdkPixmap *obj = NULL; |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
282 GdkGC *gc; |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
283 gint cw; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
284 |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
285 if (textbox->text && (!priv->pixmap_text || strcmp(textbox->text, priv->pixmap_text))) |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
286 textbox_generate_pixmap(textbox); |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
287 |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
288 if (priv->pixmap) { |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
289 if (skin_get_id() != priv->skin_id) { |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
290 priv->skin_id = skin_get_id(); |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
291 textbox_generate_pixmap(textbox); |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
292 } |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
293 obj = gdk_pixmap_new(NULL, textbox->width, textbox->height, gdk_rgb_get_visual()->depth); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
294 gc = gdk_gc_new(obj); |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
295 |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
296 if (cfg.twoway_scroll) { // twoway scroll |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
297 cw = priv->pixmap_width - priv->offset; |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
298 if (cw > textbox->width) |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
299 cw = textbox->width; |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
300 gdk_draw_drawable(obj, gc, priv->pixmap, priv->offset, 0, 0, 0, cw, textbox->height); |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
301 if (cw < textbox->width) |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
302 gdk_draw_drawable(obj, gc, priv->pixmap, 0, 0, |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
303 textbox->x + cw, textbox->y, |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
304 textbox->width - cw, textbox->height); |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
305 } else { // oneway scroll |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
306 int cw1, cw2; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
307 |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
308 if (priv->offset >= priv->pixmap_width) |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
309 priv->offset = 0; |
2911 | 310 |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
311 if (priv->pixmap_width - priv->offset > textbox->width) { // case1 |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
312 cw1 = textbox->width; |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
313 gdk_draw_drawable(obj, gc, priv->pixmap, priv->offset, 0, |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
314 0, 0, cw1, textbox->height); |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
315 } else { // case 2 |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
316 cw1 = priv->pixmap_width - priv->offset; |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
317 gdk_draw_drawable(obj, gc, priv->pixmap, priv->offset, 0, |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
318 0, 0, cw1, textbox->height); |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
319 cw2 = textbox->width - cw1; |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
320 gdk_draw_drawable(obj, gc, priv->pixmap, 0, 0, cw1, 0, cw2, textbox->height); |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
321 } |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
322 |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
323 } |
3031 | 324 |
3077
4b076ad636e6
use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents:
3038
diff
changeset
|
325 GdkPixmap *image = NULL; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
326 |
3077
4b076ad636e6
use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents:
3038
diff
changeset
|
327 if (priv->double_size) { |
4b076ad636e6
use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents:
3038
diff
changeset
|
328 image = create_dblsize_pixmap(obj); |
4b076ad636e6
use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents:
3038
diff
changeset
|
329 } else { |
4b076ad636e6
use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents:
3038
diff
changeset
|
330 image = gdk_pixmap_new(NULL, textbox->width, textbox->height, gdk_rgb_get_visual()->depth); |
4b076ad636e6
use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents:
3038
diff
changeset
|
331 gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, textbox->width, textbox->height); |
4b076ad636e6
use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents:
3038
diff
changeset
|
332 } |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
333 |
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
334 g_object_unref(obj); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
335 |
3031 | 336 gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0, |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
337 textbox->width*(1+priv->double_size), textbox->height*(1+priv->double_size)); |
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
338 g_object_unref(gc); |
3031 | 339 g_object_unref(image); |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
340 } |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
341 |
2998
c200d6764e91
fix expose events, thanks to giacomo
Tomasz Mon <desowin@gmail.com>
parents:
2997
diff
changeset
|
342 return FALSE; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
343 } |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
344 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
345 static gboolean ui_skinned_textbox_button_press(GtkWidget *widget, GdkEventButton *event) { |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
346 g_return_val_if_fail (widget != NULL, FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
347 g_return_val_if_fail (UI_SKINNED_IS_TEXTBOX (widget), FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
348 g_return_val_if_fail (event != NULL, FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
349 |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
350 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
351 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
352 |
2911 | 353 if (event->type == GDK_BUTTON_PRESS) { |
354 textbox = UI_SKINNED_TEXTBOX(widget); | |
3358
7f6787eac9aa
right click on textboxes without connected handler should bring up audacious menu
Tomasz Mon <desowin@gmail.com>
parents:
3293
diff
changeset
|
355 if (event->button == 3 && !g_signal_has_handler_pending(widget, textbox_signals[RIGHT_CLICKED], 0, TRUE)) |
7f6787eac9aa
right click on textboxes without connected handler should bring up audacious menu
Tomasz Mon <desowin@gmail.com>
parents:
3293
diff
changeset
|
356 return FALSE; |
7f6787eac9aa
right click on textboxes without connected handler should bring up audacious menu
Tomasz Mon <desowin@gmail.com>
parents:
3293
diff
changeset
|
357 else if (event->button == 1) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
358 if (priv->scroll_allowed) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
359 if ((priv->pixmap_width > textbox->width) && priv->is_scrollable) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
360 priv->is_dragging = TRUE; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
361 priv->drag_off = priv->offset; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
362 priv->drag_x = event->x; |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
363 } |
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
364 } else |
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
365 g_signal_emit(widget, textbox_signals[CLICKED], 0); |
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
366 |
3957
fed07be6b708
every other menu shows on button press..
Tomasz Mon <desowin@gmail.com>
parents:
3956
diff
changeset
|
367 } else if (event->button == 3) { |
fed07be6b708
every other menu shows on button press..
Tomasz Mon <desowin@gmail.com>
parents:
3956
diff
changeset
|
368 g_signal_emit(widget, textbox_signals[RIGHT_CLICKED], 0); |
3032
6e98eedead3a
little fix to ui_skinned_textbox_button_press()
Tomasz Mon <desowin@gmail.com>
parents:
3031
diff
changeset
|
369 } else |
6e98eedead3a
little fix to ui_skinned_textbox_button_press()
Tomasz Mon <desowin@gmail.com>
parents:
3031
diff
changeset
|
370 priv->is_dragging = FALSE; |
2911 | 371 } else if (event->type == GDK_2BUTTON_PRESS) { |
372 if (event->button == 1) { | |
3230
cfb76302b468
fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents:
3225
diff
changeset
|
373 if (g_signal_has_handler_pending(widget, textbox_signals[DOUBLE_CLICKED], 0, TRUE)) |
cfb76302b468
fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents:
3225
diff
changeset
|
374 g_signal_emit(widget, textbox_signals[DOUBLE_CLICKED], 0); |
cfb76302b468
fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents:
3225
diff
changeset
|
375 else |
cfb76302b468
fix unshading playlistwin when doubleclicking on textbox
Tomasz Mon <desowin@gmail.com>
parents:
3225
diff
changeset
|
376 return FALSE; |
2911 | 377 } |
378 } | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
379 |
2991
f7604f7d8e41
ui_skinned_textbox_button_release is no longer lost
Tomasz Mon <desowin@gmail.com>
parents:
2983
diff
changeset
|
380 return TRUE; |
2911 | 381 } |
382 | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
383 static gboolean ui_skinned_textbox_button_release(GtkWidget *widget, GdkEventButton *event) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
384 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget); |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
385 |
2911 | 386 if (event->button == 1) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
387 priv->is_dragging = FALSE; |
2911 | 388 } |
389 | |
2997
0adc8c00fc57
correct right-clicked signal
Tomasz Mon <desowin@gmail.com>
parents:
2996
diff
changeset
|
390 return TRUE; |
2911 | 391 } |
392 | |
393 static gboolean ui_skinned_textbox_motion_notify(GtkWidget *widget, GdkEventMotion *event) { | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
394 g_return_val_if_fail (widget != NULL, FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
395 g_return_val_if_fail (UI_SKINNED_IS_TEXTBOX (widget), FALSE); |
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
396 g_return_val_if_fail (event != NULL, FALSE); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
397 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(widget); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
398 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget); |
2911 | 399 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
400 if (priv->is_dragging) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
401 if (priv->scroll_allowed && |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
402 priv->pixmap_width > textbox->width) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
403 priv->offset = priv->drag_off - (event->x - priv->drag_x); |
2911 | 404 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
405 while (priv->offset < 0) |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
406 priv->offset = 0; |
2911 | 407 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
408 while (priv->offset > (priv->pixmap_width - textbox->width)) |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
409 priv->offset = (priv->pixmap_width - textbox->width); |
2911 | 410 |
2965
f84d09bada0f
correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents:
2962
diff
changeset
|
411 gtk_widget_queue_draw(widget); |
2911 | 412 } |
413 } | |
414 | |
2997
0adc8c00fc57
correct right-clicked signal
Tomasz Mon <desowin@gmail.com>
parents:
2996
diff
changeset
|
415 return TRUE; |
2911 | 416 } |
417 | |
418 static void ui_skinned_textbox_toggle_doublesize(UiSkinnedTextbox *textbox) { | |
419 GtkWidget *widget = GTK_WIDGET (textbox); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
420 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
421 |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
422 priv->double_size = !priv->double_size; |
2911 | 423 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
424 gtk_widget_set_size_request(widget, textbox->width*(1+priv->double_size), textbox->height*(1+priv->double_size)); |
2911 | 425 |
2962
ba45ef731cf1
don't call ui_skinned_textbox_paint() directly, use gtk_widget_queue_draw() instead; fix ui_skinned_textbox_expose()
Tomasz Mon <desowin@gmail.com>
parents:
2961
diff
changeset
|
426 gtk_widget_queue_draw(GTK_WIDGET(textbox)); |
2911 | 427 } |
428 | |
429 static void ui_skinned_textbox_redraw(UiSkinnedTextbox *textbox) { | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
430 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
431 |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
432 if (priv->move_x || priv->move_y) |
3939
d46d60247826
we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents:
3933
diff
changeset
|
433 gtk_fixed_move(GTK_FIXED(gtk_widget_get_parent(GTK_WIDGET(textbox))), GTK_WIDGET(textbox), |
d46d60247826
we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents:
3933
diff
changeset
|
434 textbox->x+priv->move_x, textbox->y+priv->move_y); |
2965
f84d09bada0f
correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents:
2962
diff
changeset
|
435 |
2962
ba45ef731cf1
don't call ui_skinned_textbox_paint() directly, use gtk_widget_queue_draw() instead; fix ui_skinned_textbox_expose()
Tomasz Mon <desowin@gmail.com>
parents:
2961
diff
changeset
|
436 gtk_widget_queue_draw(GTK_WIDGET(textbox)); |
2911 | 437 } |
438 | |
439 static gboolean ui_skinned_textbox_should_scroll(UiSkinnedTextbox *textbox) { | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
440 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
441 |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
442 if (!priv->scroll_allowed) |
2911 | 443 return FALSE; |
444 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
445 if (priv->font) { |
2911 | 446 gint width; |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
447 text_get_extents(priv->fontname, textbox->text, &width, NULL, NULL, NULL); |
2911 | 448 |
2947 | 449 if (width <= textbox->width) |
2911 | 450 return FALSE; |
451 else | |
452 return TRUE; | |
453 } | |
454 | |
2947 | 455 if (g_utf8_strlen(textbox->text, -1) * bmp_active_skin->properties.textbox_bitmap_font_width > textbox->width) |
2911 | 456 return TRUE; |
457 | |
458 return FALSE; | |
459 } | |
460 | |
461 void ui_skinned_textbox_set_xfont(GtkWidget *widget, gboolean use_xfont, const gchar * fontname) { | |
462 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
463 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
464 |
2911 | 465 gint ascent, descent; |
466 | |
467 g_return_if_fail(textbox != NULL); | |
468 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
469 if (priv->font) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
470 pango_font_description_free(priv->font); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
471 priv->font = NULL; |
2911 | 472 } |
473 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
474 textbox->y = priv->nominal_y; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
475 textbox->height = priv->nominal_height; |
2911 | 476 |
477 /* Make sure the pixmap is regenerated */ | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
478 if (priv->pixmap_text) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
479 g_free(priv->pixmap_text); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
480 priv->pixmap_text = NULL; |
2911 | 481 } |
482 | |
483 if (!use_xfont || strlen(fontname) == 0) | |
484 return; | |
485 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
486 priv->font = pango_font_description_from_string(fontname); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
487 priv->fontname = g_strdup(fontname); |
2911 | 488 |
489 text_get_extents(fontname, | |
490 "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz ", | |
491 NULL, NULL, &ascent, &descent); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
492 priv->font_ascent = ascent; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
493 priv->font_descent = descent; |
2911 | 494 |
495 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
496 if (priv->font == NULL) |
2911 | 497 return; |
498 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
499 textbox->height = priv->font_ascent; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
500 if (textbox->height > priv->nominal_height) |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
501 textbox->y -= (textbox->height - priv->nominal_height) / 2; |
2911 | 502 else |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
503 textbox->height = priv->nominal_height; |
2911 | 504 } |
505 | |
506 void ui_skinned_textbox_set_text(GtkWidget *widget, const gchar *text) { | |
507 g_return_if_fail(text != NULL); | |
508 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
509 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
2911 | 510 |
2957
c859aa1a1a4e
don't update text if it haven't changed
Tomasz Mon <desowin@gmail.com>
parents:
2956
diff
changeset
|
511 if (!strcmp(textbox->text, text)) |
c859aa1a1a4e
don't update text if it haven't changed
Tomasz Mon <desowin@gmail.com>
parents:
2956
diff
changeset
|
512 return; |
2951
4586c0951eab
Handle multibyte sequences properly when encountered.
William Pitcock <nenolod@atheme-project.org>
parents:
2949
diff
changeset
|
513 if (textbox->text) |
2911 | 514 g_free(textbox->text); |
515 | |
2952
cb15e12b6352
Preserve capitalization for xfont users.
William Pitcock <nenolod@atheme-project.org>
parents:
2951
diff
changeset
|
516 textbox->text = str_to_utf8(text); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
517 priv->scroll_back = FALSE; |
2981
3bd337a93c9d
oops, those shouldn't be commented
Tomasz Mon <desowin@gmail.com>
parents:
2980
diff
changeset
|
518 gtk_widget_queue_draw(GTK_WIDGET(textbox)); |
2911 | 519 } |
520 | |
521 static void textbox_generate_xfont_pixmap(UiSkinnedTextbox *textbox, const gchar *pixmaptext) { | |
522 gint length, i; | |
523 GdkGC *gc, *maskgc; | |
524 GdkColor *c, pattern; | |
525 GdkBitmap *mask; | |
526 PangoLayout *layout; | |
527 gint width; | |
528 | |
529 g_return_if_fail(textbox != NULL); | |
530 g_return_if_fail(pixmaptext != NULL); | |
4119 | 531 g_return_if_fail(textbox->height > 0); |
2911 | 532 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
533 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
534 |
2911 | 535 length = g_utf8_strlen(pixmaptext, -1); |
536 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
537 text_get_extents(priv->fontname, pixmaptext, &width, NULL, NULL, NULL); |
2911 | 538 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
539 priv->pixmap_width = MAX(width, textbox->width); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
540 priv->pixmap = gdk_pixmap_new(mainwin->window, priv->pixmap_width, |
2911 | 541 textbox->height, |
542 gdk_rgb_get_visual()->depth); | |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
543 gc = gdk_gc_new(priv->pixmap); |
2911 | 544 c = skin_get_color(bmp_active_skin, SKIN_TEXTBG); |
545 for (i = 0; i < textbox->height; i++) { | |
546 gdk_gc_set_foreground(gc, &c[6 * i / textbox->height]); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
547 gdk_draw_line(priv->pixmap, gc, 0, i, priv->pixmap_width, i); |
2911 | 548 } |
549 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
550 mask = gdk_pixmap_new(mainwin->window, priv->pixmap_width, textbox->height, 1); |
2911 | 551 maskgc = gdk_gc_new(mask); |
552 pattern.pixel = 0; | |
553 gdk_gc_set_foreground(maskgc, &pattern); | |
554 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
555 gdk_draw_rectangle(mask, maskgc, TRUE, 0, 0, priv->pixmap_width, textbox->height); |
2911 | 556 pattern.pixel = 1; |
557 gdk_gc_set_foreground(maskgc, &pattern); | |
558 | |
559 gdk_gc_set_foreground(gc, skin_get_color(bmp_active_skin, SKIN_TEXTFG)); | |
560 | |
561 layout = gtk_widget_create_pango_layout(mainwin, pixmaptext); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
562 pango_layout_set_font_description(layout, priv->font); |
2911 | 563 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
564 gdk_draw_layout(priv->pixmap, gc, 0, (priv->font_descent / 2), layout); |
2911 | 565 g_object_unref(layout); |
566 | |
567 g_object_unref(maskgc); | |
568 | |
569 gdk_gc_set_clip_mask(gc, mask); | |
570 c = skin_get_color(bmp_active_skin, SKIN_TEXTFG); | |
571 for (i = 0; i < textbox->height; i++) { | |
572 gdk_gc_set_foreground(gc, &c[6 * i / textbox->height]); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
573 gdk_draw_line(priv->pixmap, gc, 0, i, priv->pixmap_width, i); |
2911 | 574 } |
575 g_object_unref(mask); | |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
576 g_object_unref(gc); |
2911 | 577 } |
578 | |
579 static gboolean textbox_scroll(gpointer data) { | |
580 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(data); | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
581 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
2911 | 582 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
583 if (!priv->is_dragging) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
584 if (priv->scroll_dummy < TEXTBOX_SCROLL_WAIT) |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
585 priv->scroll_dummy++; |
2948
830fdbec31be
introduce scroll_dummy to stop scrolling when it reaches end
Tomasz Mon <desowin@gmail.com>
parents:
2947
diff
changeset
|
586 else { |
2968
83f03505f819
add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2967
diff
changeset
|
587 if(cfg.twoway_scroll) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
588 if (priv->scroll_back) |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
589 priv->offset -= 1; |
2968
83f03505f819
add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2967
diff
changeset
|
590 else |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
591 priv->offset += 1; |
2911 | 592 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
593 if (priv->offset >= (priv->pixmap_width - textbox->width)) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
594 priv->scroll_back = TRUE; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
595 priv->scroll_dummy = 0; |
3956
8be86c0b040e
fix possible glitch which could be triggered by switching skin while textbox was scrolling
Tomasz Mon <desowin@gmail.com>
parents:
3939
diff
changeset
|
596 priv->offset = priv->pixmap_width - textbox->width; |
2968
83f03505f819
add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2967
diff
changeset
|
597 } |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
598 if (priv->offset <= 0) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
599 priv->scroll_back = FALSE; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
600 priv->scroll_dummy = 0; |
3956
8be86c0b040e
fix possible glitch which could be triggered by switching skin while textbox was scrolling
Tomasz Mon <desowin@gmail.com>
parents:
3939
diff
changeset
|
601 priv->offset = 0; |
2968
83f03505f819
add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2967
diff
changeset
|
602 } |
2948
830fdbec31be
introduce scroll_dummy to stop scrolling when it reaches end
Tomasz Mon <desowin@gmail.com>
parents:
2947
diff
changeset
|
603 } |
2968
83f03505f819
add support for one-way text scroll.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2967
diff
changeset
|
604 else { // oneway scroll |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
605 priv->scroll_back = FALSE; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
606 priv->offset += 1; |
2948
830fdbec31be
introduce scroll_dummy to stop scrolling when it reaches end
Tomasz Mon <desowin@gmail.com>
parents:
2947
diff
changeset
|
607 } |
2965
f84d09bada0f
correct _move_relative() and _resize_relative()
Tomasz Mon <desowin@gmail.com>
parents:
2962
diff
changeset
|
608 gtk_widget_queue_draw(GTK_WIDGET(textbox)); |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2920
diff
changeset
|
609 } |
2911 | 610 } |
611 return TRUE; | |
612 } | |
613 | |
614 static void textbox_generate_pixmap(UiSkinnedTextbox *textbox) { | |
615 gint length, i, x, y, wl; | |
616 gchar *pixmaptext; | |
2953
80b6fc3f4d29
Fix invalid free.
William Pitcock <nenolod@atheme-project.org>
parents:
2952
diff
changeset
|
617 gchar *tmp, *stxt; |
2911 | 618 GdkGC *gc; |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
619 |
2911 | 620 g_return_if_fail(textbox != NULL); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
621 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
2911 | 622 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
623 if (priv->pixmap) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
624 g_object_unref(priv->pixmap); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
625 priv->pixmap = NULL; |
2911 | 626 } |
627 | |
628 /* | |
629 * Don't reset the offset if only text after the last '(' has | |
630 * changed. This is a hack to avoid visual noice on vbr files | |
631 * where we guess the length. | |
632 */ | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
633 if (!(priv->pixmap_text && strrchr(textbox->text, '(') && |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
634 !strncmp(priv->pixmap_text, textbox->text, |
2911 | 635 strrchr(textbox->text, '(') - textbox->text))) |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
636 priv->offset = 0; |
2911 | 637 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
638 g_free(priv->pixmap_text); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
639 priv->pixmap_text = g_strdup(textbox->text); |
2911 | 640 |
641 /* | |
642 * wl is the number of (partial) letters visible. Only makes | |
643 * sense when using skinned font. | |
644 */ | |
2947 | 645 wl = textbox->width / 5; |
646 if (wl * 5 != textbox->width) | |
2911 | 647 wl++; |
648 | |
649 length = g_utf8_strlen(textbox->text, -1); | |
650 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
651 priv->is_scrollable = FALSE; |
2911 | 652 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
653 priv->is_scrollable = ui_skinned_textbox_should_scroll(textbox); |
2916
3ef909ed3056
fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents:
2913
diff
changeset
|
654 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
655 if (priv->is_scrollable) { |
2971 | 656 if(!cfg.twoway_scroll) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
657 pixmaptext = g_strdup_printf("%s *** ", priv->pixmap_text); |
2971 | 658 length += 5; |
659 } else | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
660 pixmaptext = g_strdup(priv->pixmap_text); |
2971 | 661 } else |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
662 if (!priv->font && length <= wl) { |
2916
3ef909ed3056
fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents:
2913
diff
changeset
|
663 gint pad = wl - length; |
3ef909ed3056
fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents:
2913
diff
changeset
|
664 gchar *padchars = g_strnfill(pad, ' '); |
3ef909ed3056
fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents:
2913
diff
changeset
|
665 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
666 pixmaptext = g_strconcat(priv->pixmap_text, padchars, NULL); |
2916
3ef909ed3056
fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents:
2913
diff
changeset
|
667 g_free(padchars); |
3ef909ed3056
fix clearing textbox when short text is displayed
Tomasz Mon <desowin@gmail.com>
parents:
2913
diff
changeset
|
668 length += pad; |
2971 | 669 } else |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
670 pixmaptext = g_strdup(priv->pixmap_text); |
2911 | 671 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
672 if (priv->is_scrollable) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
673 if (priv->scroll_enabled && !priv->scroll_timeout) { |
2911 | 674 gint tag; |
675 tag = TEXTBOX_SCROLL_SMOOTH_TIMEOUT; | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
676 priv->scroll_timeout = g_timeout_add(tag, textbox_scroll, textbox); |
2911 | 677 } |
678 } else { | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
679 if (priv->scroll_timeout) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
680 g_source_remove(priv->scroll_timeout); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
681 priv->scroll_timeout = 0; |
2911 | 682 } |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
683 priv->offset = 0; |
2911 | 684 } |
685 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
686 if (priv->font) { |
2911 | 687 textbox_generate_xfont_pixmap(textbox, pixmaptext); |
688 g_free(pixmaptext); | |
689 return; | |
690 } | |
691 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
692 priv->pixmap_width = length * bmp_active_skin->properties.textbox_bitmap_font_width; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
693 priv->pixmap = gdk_pixmap_new(NULL, |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
694 priv->pixmap_width, bmp_active_skin->properties.textbox_bitmap_font_height, |
2911 | 695 gdk_rgb_get_visual()->depth); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
696 gc = gdk_gc_new(priv->pixmap); |
2911 | 697 |
2953
80b6fc3f4d29
Fix invalid free.
William Pitcock <nenolod@atheme-project.org>
parents:
2952
diff
changeset
|
698 for (tmp = stxt = g_utf8_strup(pixmaptext, -1), i = 0; |
2952
cb15e12b6352
Preserve capitalization for xfont users.
William Pitcock <nenolod@atheme-project.org>
parents:
2951
diff
changeset
|
699 tmp != NULL && i < length; i++, tmp = g_utf8_next_char(tmp)) { |
2951
4586c0951eab
Handle multibyte sequences properly when encountered.
William Pitcock <nenolod@atheme-project.org>
parents:
2949
diff
changeset
|
700 gchar c = *tmp; |
2911 | 701 x = y = -1; |
702 if (c >= 'A' && c <= 'Z') { | |
703 x = bmp_active_skin->properties.textbox_bitmap_font_width * (c - 'A'); | |
704 y = 0; | |
705 } | |
706 else if (c >= '0' && c <= '9') { | |
707 x = bmp_active_skin->properties.textbox_bitmap_font_width * (c - '0'); | |
708 y = bmp_active_skin->properties.textbox_bitmap_font_height; | |
709 } | |
710 else | |
3038
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
711 textbox_handle_special_char(tmp, &x, &y); |
2911 | 712 |
3933
5a4ef76b1f42
beggining of better dealing with substandard winamp skins - if it doesn't break anything, why not commit this?
Tomasz Mon <desowin@gmail.com>
parents:
3840
diff
changeset
|
713 skin_draw_pixmap(GTK_WIDGET(textbox), bmp_active_skin, |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
714 priv->pixmap, gc, priv->skin_index, |
2911 | 715 x, y, i * bmp_active_skin->properties.textbox_bitmap_font_width, 0, |
716 bmp_active_skin->properties.textbox_bitmap_font_width, | |
717 bmp_active_skin->properties.textbox_bitmap_font_height); | |
718 } | |
2953
80b6fc3f4d29
Fix invalid free.
William Pitcock <nenolod@atheme-project.org>
parents:
2952
diff
changeset
|
719 g_free(stxt); |
2911 | 720 g_free(pixmaptext); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
2998
diff
changeset
|
721 g_object_unref(gc); |
2911 | 722 } |
723 | |
724 void ui_skinned_textbox_set_scroll(GtkWidget *widget, gboolean scroll) { | |
725 g_return_if_fail(widget != NULL); | |
2980
d58560be5a4c
draw directly instead using embeded GtkImage
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
726 UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(widget); |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
727 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox); |
2911 | 728 |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
729 priv->scroll_enabled = scroll; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
730 if (priv->scroll_enabled && priv->is_scrollable && priv->scroll_allowed) { |
2911 | 731 gint tag; |
732 tag = TEXTBOX_SCROLL_SMOOTH_TIMEOUT; | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
733 if (priv->scroll_timeout) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
734 g_source_remove(priv->scroll_timeout); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
735 priv->scroll_timeout = 0; |
2911 | 736 } |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
737 priv->scroll_timeout = g_timeout_add(tag, textbox_scroll, textbox); |
2911 | 738 |
739 } else { | |
740 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
741 if (priv->scroll_timeout) { |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
742 g_source_remove(priv->scroll_timeout); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
743 priv->scroll_timeout = 0; |
2911 | 744 } |
745 | |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
746 priv->offset = 0; |
2981
3bd337a93c9d
oops, those shouldn't be commented
Tomasz Mon <desowin@gmail.com>
parents:
2980
diff
changeset
|
747 gtk_widget_queue_draw(GTK_WIDGET(textbox)); |
2911 | 748 } |
749 } | |
750 | |
3038
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
751 static void textbox_handle_special_char(gchar *c, gint * x, gint * y) { |
2911 | 752 gint tx, ty; |
753 | |
3038
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
754 switch (*c) { |
2911 | 755 case '"': |
756 tx = 26; | |
757 ty = 0; | |
758 break; | |
759 case '\r': | |
760 tx = 10; | |
761 ty = 1; | |
762 break; | |
763 case ':': | |
764 case ';': | |
765 tx = 12; | |
766 ty = 1; | |
767 break; | |
768 case '(': | |
769 tx = 13; | |
770 ty = 1; | |
771 break; | |
772 case ')': | |
773 tx = 14; | |
774 ty = 1; | |
775 break; | |
776 case '-': | |
777 tx = 15; | |
778 ty = 1; | |
779 break; | |
780 case '`': | |
781 case '\'': | |
782 tx = 16; | |
783 ty = 1; | |
784 break; | |
785 case '!': | |
786 tx = 17; | |
787 ty = 1; | |
788 break; | |
789 case '_': | |
790 tx = 18; | |
791 ty = 1; | |
792 break; | |
793 case '+': | |
794 tx = 19; | |
795 ty = 1; | |
796 break; | |
797 case '\\': | |
798 tx = 20; | |
799 ty = 1; | |
800 break; | |
801 case '/': | |
802 tx = 21; | |
803 ty = 1; | |
804 break; | |
805 case '[': | |
806 tx = 22; | |
807 ty = 1; | |
808 break; | |
809 case ']': | |
810 tx = 23; | |
811 ty = 1; | |
812 break; | |
813 case '^': | |
814 tx = 24; | |
815 ty = 1; | |
816 break; | |
817 case '&': | |
818 tx = 25; | |
819 ty = 1; | |
820 break; | |
821 case '%': | |
822 tx = 26; | |
823 ty = 1; | |
824 break; | |
825 case '.': | |
826 case ',': | |
827 tx = 27; | |
828 ty = 1; | |
829 break; | |
830 case '=': | |
831 tx = 28; | |
832 ty = 1; | |
833 break; | |
834 case '$': | |
835 tx = 29; | |
836 ty = 1; | |
837 break; | |
838 case '#': | |
839 tx = 30; | |
840 ty = 1; | |
841 break; | |
842 case '?': | |
843 tx = 3; | |
844 ty = 2; | |
845 break; | |
846 case '*': | |
847 tx = 4; | |
848 ty = 2; | |
849 break; | |
850 default: | |
851 tx = 29; | |
852 ty = 0; | |
853 break; | |
854 } | |
855 | |
3038
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
856 const gchar *change[] = {"Ą", "A", "Ę", "E", "Ć", "C", "Ł", "L", "Ó", "O", "Ś", "S", "Ż", "Z", "Ź", "Z", |
3293
910c9296d6b3
when using bitmap font display as N
Tomasz Mon <desowin@gmail.com>
parents:
3251
diff
changeset
|
857 "Ń", "N", "Ü", "U", NULL}; |
3038
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
858 int i; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
859 for (i = 0; change[i]; i+=2) { |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
860 if (!strncmp(c, change[i], strlen(change[i]))) { |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
861 tx = (*change[i+1] - 'A'); |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
862 break; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
863 } |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
864 } |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
865 |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
866 /* those are commonly included into skins */ |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
867 if (!strncmp(c, "Å", strlen("Å"))) { |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
868 tx = 0; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
869 ty = 2; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
870 } else if (!strncmp(c, "Ö", strlen("Ö"))) { |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
871 tx = 1; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
872 ty = 2; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
873 } else if (!strncmp(c, "Ä", strlen("Ä"))) { |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
874 tx = 2; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
875 ty = 2; |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
876 } |
ff886a3a2098
little tweak to handle_special_char()
Tomasz Mon <desowin@gmail.com>
parents:
3032
diff
changeset
|
877 |
2911 | 878 *x = tx * bmp_active_skin->properties.textbox_bitmap_font_width; |
879 *y = ty * bmp_active_skin->properties.textbox_bitmap_font_height; | |
880 } | |
2943
a8f2c99727eb
replace Textbox in playlistwin with UiSkinnedTextbox, textbox.c no longer needed, temporary comment out g_usleep in textbox_scroll as it needs to be run as new thread
Tomasz Mon <desowin@gmail.com>
parents:
2942
diff
changeset
|
881 |
a8f2c99727eb
replace Textbox in playlistwin with UiSkinnedTextbox, textbox.c no longer needed, temporary comment out g_usleep in textbox_scroll as it needs to be run as new thread
Tomasz Mon <desowin@gmail.com>
parents:
2942
diff
changeset
|
882 void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y) { |
2996
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
883 UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget); |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
884 priv->move_x += x; |
a2eb970ca669
bring back UiSkinnedTextboxPrivate
Tomasz Mon <desowin@gmail.com>
parents:
2991
diff
changeset
|
885 priv->move_y += y; |
2943
a8f2c99727eb
replace Textbox in playlistwin with UiSkinnedTextbox, textbox.c no longer needed, temporary comment out g_usleep in textbox_scroll as it needs to be run as new thread
Tomasz Mon <desowin@gmail.com>
parents:
2942
diff
changeset
|
886 } |