]> git.sur5r.net Git - glabels/blob - src/view-text.c
Imported Upstream version 3.0.0
[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 #include <gdk-pixbuf/gdk-pixdata.h>
27
28 #include "label-text.h"
29 #include "cursors/cursor_pixdata.h"
30
31 #include "debug.h"
32
33
34 /*========================================================*/
35 /* Private macros and constants.                          */
36 /*========================================================*/
37
38 #define X_HOTSPOT 7
39 #define Y_HOTSPOT 7
40
41
42 /*========================================================*/
43 /* Private types.                                         */
44 /*========================================================*/
45
46
47 /*========================================================*/
48 /* Private globals.                                       */
49 /*========================================================*/
50
51
52 /*========================================================*/
53 /* Private function prototypes.                           */
54 /*========================================================*/
55
56
57 /*****************************************************************************/
58 /* Return apropos cursor for create object mode.                             */
59 /*****************************************************************************/
60 GdkCursor *
61 gl_view_text_get_create_cursor (void)
62 {
63         GdkCursor       *cursor = NULL;
64         GdkPixbuf       *pixbuf;
65
66         gl_debug (DEBUG_VIEW, "START");
67
68         pixbuf = gdk_pixbuf_from_pixdata (&cursor_text_pixdata, FALSE, NULL);
69         cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT);
70         g_object_unref (pixbuf);
71
72         gl_debug (DEBUG_VIEW, "END");
73
74         return cursor;
75 }
76
77
78 /*****************************************************************************/
79 /* Object creation handler: button press event.                              */
80 /*****************************************************************************/
81 void
82 gl_view_text_create_button_press_event   (glView *view,
83                                           gdouble x,
84                                           gdouble y)
85 {
86         GObject             *object;
87         GList               *lines;
88
89         gl_label_unselect_all (view->label);
90
91         object = gl_label_text_new (view->label, TRUE);
92
93         gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y, FALSE);
94         lines = gl_text_node_lines_new_from_text (_("Text"));
95         gl_label_text_set_lines (GL_LABEL_TEXT(object), lines, FALSE);
96
97         view->create_object = GL_LABEL_OBJECT (object);
98         view->create_x0 = x;
99         view->create_y0 = y;
100 }
101
102
103 /*****************************************************************************/
104 /* Object creation handler: motion event.                                    */
105 /*****************************************************************************/
106 void
107 gl_view_text_create_motion_event     (glView *view,
108                                       gdouble x,
109                                       gdouble y)
110 {
111         gl_label_object_set_position (GL_LABEL_OBJECT(view->create_object), x, y, FALSE);
112 }
113
114
115 /*****************************************************************************/
116 /* Object creation handler: button relesase event.                           */
117 /*****************************************************************************/
118 void
119 gl_view_text_create_button_release_event (glView *view,
120                                           gdouble x,
121                                           gdouble y)
122 {
123         gl_label_object_set_position (GL_LABEL_OBJECT(view->create_object), x, y, FALSE);
124 }
125
126
127
128 /*
129  * Local Variables:       -- emacs
130  * mode: C                -- emacs
131  * c-basic-offset: 8      -- emacs
132  * tab-width: 8           -- emacs
133  * indent-tabs-mode: nil  -- emacs
134  * End:                   -- emacs
135  */