annotate src/audacious/ui_skinned_textbox.c @ 3018:6a9fdd5aee3a trunk

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