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