annotate src/audacious/ui_skinned_textbox.c @ 2965:f84d09bada0f trunk

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