]> git.sur5r.net Git - glabels/blob - src/view.h
Imported Upstream version 3.0.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
83         /* GL_VIEW_ARROW_SELECT_REGION state */
84         gboolean           select_region_visible;
85         glLabelRegion      select_region;
86
87         /* GL_VIEW_ARROW_RESIZE state */
88         glLabelObject      *resize_object;
89         glLabelObjectHandle resize_handle;
90         gboolean            resize_honor_aspect;
91
92         /* GL_VIEW_CREATE_DRAG state */
93         glLabelObject     *create_object;
94         gdouble            create_x0;
95         gdouble            create_y0;
96
97 };
98
99 struct _glViewClass {
100         GtkVBoxClass      parent_class;
101
102         /* Signal to launch a context menu */
103         void (*context_menu_activate) (glView   *view,
104                                        gint      button,
105                                        guint32   activate_time,
106                                        gpointer  user_data);
107
108         /* Signals to support a status bar */
109         void (*zoom_changed)      (glView   *view,
110                                    gdouble   zoom,
111                                    gpointer  user_data);
112         void (*pointer_moved)     (glView   *view,
113                                    gdouble   x,
114                                    gdouble   y,
115                                    gpointer  user_data);
116         void (*pointer_exit)      (glView   *view,
117                                    gpointer  user_data);
118         void (*mode_changed)      (glView   *view,
119                                    gpointer  user_data);
120 };
121
122 G_BEGIN_DECLS
123
124 GType      gl_view_get_type                (void) G_GNUC_CONST;
125
126 GtkWidget *gl_view_new                     (glLabel           *label);
127
128
129 void       gl_view_update                  (glView            *view);
130
131 void       gl_view_update_region           (glView            *view,
132                                             cairo_t           *cr,
133                                             glLabelRegion     *region);
134
135 void       gl_view_show_grid               (glView            *view);
136
137 void       gl_view_hide_grid               (glView            *view);
138
139 void       gl_view_show_markup             (glView            *view);
140
141 void       gl_view_hide_markup             (glView            *view);
142
143 void       gl_view_arrow_mode              (glView            *view);
144
145 void       gl_view_object_create_mode      (glView            *view,
146                                             glLabelObjectType  type);
147
148
149 void       gl_view_zoom_in                 (glView            *view);
150
151 void       gl_view_zoom_out                (glView            *view);
152
153 void       gl_view_zoom_to_fit             (glView            *view);
154
155 void       gl_view_set_zoom                (glView            *view,
156                                             gdouble            zoom);
157
158 gdouble    gl_view_get_zoom                (glView            *view);
159
160 gboolean   gl_view_is_zoom_max             (glView            *view);
161
162 gboolean   gl_view_is_zoom_min             (glView            *view);
163
164
165
166
167 G_END_DECLS
168
169 #endif
170
171
172
173 /*
174  * Local Variables:       -- emacs
175  * mode: C                -- emacs
176  * c-basic-offset: 8      -- emacs
177  * tab-width: 8           -- emacs
178  * indent-tabs-mode: nil  -- emacs
179  * End:                   -- emacs
180  */