3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
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.
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.
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/>.
23 #include "view-image.h"
25 #include <gdk-pixbuf/gdk-pixdata.h>
27 #include "label-image.h"
28 #include "cursors/cursor_pixdata.h"
33 /*========================================================*/
34 /* Private macros and constants. */
35 /*========================================================*/
41 /*========================================================*/
43 /*========================================================*/
46 /*========================================================*/
47 /* Private globals. */
48 /*========================================================*/
51 /*========================================================*/
52 /* Private function prototypes. */
53 /*========================================================*/
55 /*****************************************************************************/
56 /* Return apropos cursor for create object mode. */
57 /*****************************************************************************/
59 gl_view_image_get_create_cursor (void)
61 GdkCursor *cursor = NULL;
64 gl_debug (DEBUG_VIEW, "START");
66 pixbuf = gdk_pixbuf_from_pixdata (&cursor_image_pixdata, FALSE, NULL);
67 cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), pixbuf, X_HOTSPOT, Y_HOTSPOT);
68 g_object_unref (pixbuf);
70 gl_debug (DEBUG_VIEW, "END");
76 /*****************************************************************************/
77 /* Object creation handler: button press event. */
78 /*****************************************************************************/
80 gl_view_image_create_button_press_event (glView *view,
86 gl_label_unselect_all (view->label);
88 object = gl_label_image_new (view->label, TRUE);
90 gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y, FALSE);
91 gl_label_object_set_size (GL_LABEL_OBJECT(object), 0.0, 0.0, FALSE);
93 view->create_object = GL_LABEL_OBJECT (object);
99 /*****************************************************************************/
100 /* Object creation handler: motion event. */
101 /*****************************************************************************/
103 gl_view_image_create_motion_event (glView *view,
109 gl_label_object_set_position (GL_LABEL_OBJECT(view->create_object),
110 MIN (x, view->create_x0), MIN (y, view->create_y0),
113 w = MAX (x, view->create_x0) - MIN (x, view->create_x0);
114 h = MAX (y, view->create_y0) - MIN (y, view->create_y0);
115 gl_label_object_set_size (GL_LABEL_OBJECT(view->create_object), w, h, FALSE);
119 /*****************************************************************************/
120 /* Object creation handler: button relesase event. */
121 /*****************************************************************************/
123 gl_view_image_create_button_release_event (glView *view,
129 if ((view->create_x0 == x) && (view->create_y0 == y)) {
130 x = view->create_x0 + 36.0;
131 y = view->create_y0 + 36.0;
133 gl_label_object_set_position (GL_LABEL_OBJECT(view->create_object),
134 MIN (x, view->create_x0), MIN (y, view->create_y0),
137 w = MAX (x, view->create_x0) - MIN (x, view->create_x0);
138 h = MAX (y, view->create_y0) - MIN (y, view->create_y0);
139 gl_label_object_set_size (GL_LABEL_OBJECT(view->create_object), w, h, FALSE);
145 * Local Variables: -- emacs
147 * c-basic-offset: 8 -- emacs
148 * tab-width: 8 -- emacs
149 * indent-tabs-mode: nil -- emacs