]> git.sur5r.net Git - glabels/blob - src/view.h
Imported Upstream version 3.4.0
[glabels] / src / view.h
1 /*
2  *  view.h
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 #ifndef __VIEW_H__
22 #define __VIEW_H__
23
24 #include <gtk/gtk.h>
25
26 #include "label-object.h"
27
28 typedef enum {
29         GL_VIEW_MODE_ARROW,
30         GL_VIEW_MODE_OBJECT_CREATE
31 } glViewMode;
32
33 typedef enum {
34         GL_VIEW_IDLE = 0,
35         GL_VIEW_ARROW_SELECT_REGION,
36         GL_VIEW_ARROW_MOVE,
37         GL_VIEW_ARROW_RESIZE,
38         GL_VIEW_CREATE_DRAG
39 } glViewState;
40
41 #define GL_TYPE_VIEW            (gl_view_get_type ())
42 #define GL_VIEW(obj) \
43         (G_TYPE_CHECK_INSTANCE_CAST((obj), GL_TYPE_VIEW, glView ))
44 #define GL_VIEW_CLASS(klass) \
45         (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_VIEW, glViewClass))
46 #define GL_IS_VIEW(obj) \
47         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_VIEW))
48 #define GL_IS_VIEW_CLASS(klass) \
49         (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_VIEW))
50
51 typedef struct _glView      glView;
52 typedef struct _glViewClass glViewClass;
53
54
55
56 struct _glView {
57         GtkVBox             parent_widget;
58
59         glLabel            *label;
60
61         GtkWidget          *canvas;
62         gdouble             zoom;
63         gboolean            zoom_to_fit_flag;
64         gdouble             home_scale;
65         gdouble             x0, y0;
66         gdouble             w, h;
67
68         gboolean            update_scheduled_flag;
69         gboolean            grid_visible;
70         gdouble             grid_spacing;
71
72         gboolean            markup_visible;
73
74         glViewMode          mode;
75         glLabelObjectType   create_type;
76         glViewState         state;
77         gboolean            grabbed_flag;
78
79         /* GL_VIEW_ARROW_MOVE state */
80         gdouble             move_last_x;
81         gdouble             move_last_y;
82         gdouble             saved_x;
83         gdouble             saved_y;
84
85         /* GL_VIEW_ARROW_SELECT_REGION state */
86         gboolean            select_region_visible;
87         glLabelRegion       select_region;
88
89         /* GL_VIEW_ARROW_RESIZE state */
90         glLabelObject      *resize_object;
91         glLabelObjectHandle resize_handle;
92         gdouble             saved_ratio;
93         gdouble             saved_w;
94         gdouble             saved_h;
95
96         /* GL_VIEW_CREATE_DRAG state */
97         glLabelObject      *create_object;
98         gdouble             create_x0;
99         gdouble             create_y0;
100 };
101
102 struct _glViewClass {
103         GtkVBoxClass      parent_class;
104
105         /* Signal to launch a context menu */
106         void (*context_menu_activate) (glView   *view,
107                                        gint      button,
108                                        guint32   activate_time,
109                                        gpointer  user_data);
110
111         /* Signals to support a status bar */
112         void (*zoom_changed)      (glView   *view,
113                                    gdouble   zoom,
114                                    gpointer  user_data);
115         void (*pointer_moved)     (glView   *view,
116                                    gdouble   x,
117                                    gdouble   y,
118                                    gpointer  user_data);
119         void (*pointer_exit)      (glView   *view,
120                                    gpointer  user_data);
121         void (*mode_changed)      (glView   *view,
122                                    gpointer  user_data);
123 };
124
125 G_BEGIN_DECLS
126
127 GType      gl_view_get_type                (void) G_GNUC_CONST;
128
129 GtkWidget *gl_view_new                     (glLabel           *label);
130
131
132 void       gl_view_update                  (glView            *view);
133
134 void       gl_view_update_region           (glView            *view,
135                                             cairo_t           *cr,
136                                             glLabelRegion     *region);
137
138 void       gl_view_show_grid               (glView            *view);
139
140 void       gl_view_hide_grid               (glView            *view);
141
142 void       gl_view_show_markup             (glView            *view);
143
144 void       gl_view_hide_markup             (glView            *view);
145
146 void       gl_view_arrow_mode              (glView            *view);
147
148 void       gl_view_object_create_mode      (glView            *view,
149                                             glLabelObjectType  type);
150
151
152 void       gl_view_zoom_in                 (glView            *view);
153
154 void       gl_view_zoom_out                (glView            *view);
155
156 void       gl_view_zoom_to_fit             (glView            *view);
157
158 void       gl_view_set_zoom                (glView            *view,
159                                             gdouble            zoom);
160
161 gdouble    gl_view_get_zoom                (glView            *view);
162
163 gboolean   gl_view_is_zoom_max             (glView            *view);
164
165 gboolean   gl_view_is_zoom_min             (glView            *view);
166
167
168
169
170 G_END_DECLS
171
172 #endif
173
174
175
176 /*
177  * Local Variables:       -- emacs
178  * mode: C                -- emacs
179  * c-basic-offset: 8      -- emacs
180  * tab-width: 8           -- emacs
181  * indent-tabs-mode: nil  -- emacs
182  * End:                   -- emacs
183  */