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