annotate src/audacious/ui_skinned_textbox.c @ 2983:048fa5c2b1db trunk

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