]> git.sur5r.net Git - glabels/blob - src/view-text.c
Allow user selection of barcode backend.
[glabels] / src / view-text.c
1 /*
2  *  view-text.c
3  *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
7  *  gLabels is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  gLabels is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22
23 #include "view-text.h"
24
25 #include <glib/gi18n.h>
26
27 #include "label-text.h"
28
29 #include "pixmaps/cursor_text.xbm"
30 #include "pixmaps/cursor_text_mask.xbm"
31
32 #include "debug.h"
33
34
35 /*========================================================*/
36 /* Private macros and constants.                          */
37 /*========================================================*/
38
39
40 /*========================================================*/
41 /* Private types.                                         */
42 /*========================================================*/
43
44
45 /*========================================================*/
46 /* Private globals.                                       */
47 /*========================================================*/
48
49
50 /*========================================================*/
51 /* Private function prototypes.                           */
52 /*========================================================*/
53
54
55 /*****************************************************************************/
56 /* Return apropos cursor for create object mode.                             */
57 /*****************************************************************************/
58 GdkCursor *
59 gl_view_text_get_create_cursor (void)
60 {
61         GdkCursor       *cursor = NULL;
62         GdkPixmap       *pixmap_data, *pixmap_mask;
63         GdkColor         fg = { 0, 0, 0, 0 };
64         GdkColor         bg = { 0, 65535, 65535, 65535 };
65
66         gl_debug (DEBUG_VIEW, "START");
67
68         pixmap_data = gdk_bitmap_create_from_data (NULL,
69                                                    (gchar *)cursor_text_bits,
70                                                    cursor_text_width,
71                                                    cursor_text_height);
72         pixmap_mask = gdk_bitmap_create_from_data (NULL,
73                                                    (gchar *)cursor_text_mask_bits,
74                                                    cursor_text_mask_width,
75                                                    cursor_text_mask_height);
76         cursor = gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg,
77                                              &bg, cursor_text_x_hot,
78                                              cursor_text_y_hot);
79
80         gl_debug (DEBUG_VIEW, "END");
81
82         return cursor;
83 }
84
85
86 /*****************************************************************************/
87 /* Object creation handler: button press event.                              */
88 /*****************************************************************************/
89 void
90 gl_view_text_create_button_press_event   (glView *view,
91                                           gdouble x,
92                                           gdouble y)
93 {
94         GObject             *object;
95         GList               *lines;
96
97         gl_label_unselect_all (view->label);
98
99         object = gl_label_text_new (view->label, TRUE);
100
101         gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y, FALSE);
102         lines = gl_text_node_lines_new_from_text (_("Text"));
103         gl_label_text_set_lines (GL_LABEL_TEXT(object), lines, FALSE);
104
105         view->create_object = GL_LABEL_OBJECT (object);
106         view->create_x0 = x;
107         view->create_y0 = y;
108 }
109
110
111 /*****************************************************************************/
112 /* Object creation handler: motion event.                                    */
113 /*****************************************************************************/
114 void
115 gl_view_text_create_motion_event     (glView *view,
116                                       gdouble x,
117                                       gdouble y)
118 {
119         gl_label_object_set_position (GL_LABEL_OBJECT(view->create_object), x, y, FALSE);
120 }
121
122
123 /*****************************************************************************/
124 /* Object creation handler: button relesase event.                           */
125 /*****************************************************************************/
126 void
127 gl_view_text_create_button_release_event (glView *view,
128                                           gdouble x,
129                                           gdouble y)
130 {
131         gl_label_object_set_position (GL_LABEL_OBJECT(view->create_object), x, y, FALSE);
132 }
133
134
135
136 /*
137  * Local Variables:       -- emacs
138  * mode: C                -- emacs
139  * c-basic-offset: 8      -- emacs
140  * tab-width: 8           -- emacs
141  * indent-tabs-mode: nil  -- emacs
142  * End:                   -- emacs
143  */