Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
gxkscrollcanvas.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __GXK_SCROLL_CANVAS_H__
3 #define __GXK_SCROLL_CANVAS_H__
4 
5 #include <gxk/gxkutils.hh>
6 
7 /* --- type macros --- */
8 #define GXK_TYPE_SCROLL_CANVAS (gxk_scroll_canvas_get_type ())
9 #define GXK_SCROLL_CANVAS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GXK_TYPE_SCROLL_CANVAS, GxkScrollCanvas))
10 #define GXK_SCROLL_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXK_TYPE_SCROLL_CANVAS, GxkScrollCanvasClass))
11 #define GXK_IS_SCROLL_CANVAS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GXK_TYPE_SCROLL_CANVAS))
12 #define GXK_IS_SCROLL_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXK_TYPE_SCROLL_CANVAS))
13 #define GXK_SCROLL_CANVAS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GXK_TYPE_SCROLL_CANVAS, GxkScrollCanvasClass))
14 
15 
16 /* --- typedefs, enums & structures --- */
17 typedef enum /*< skip >*/
18 {
19  GXK_DRAG_AREA_RESIZE = 1 << 0,
20  GXK_DRAG_AREA_ENRICH = 1 << 1,
21  GXK_DRAG_AREA_REDUCE = 1 << 2,
22  GXK_DRAG_AREA_XOR = 1 << 3,
23  GXK_DRAG_RATIO_FIXED = 1 << 8,
24  GXK_DRAG_OFFSET_CENTERED = 1 << 9,
25 } GxkDragMode;
26 GxkDragMode gxk_drag_modifier_start (GdkModifierType key_mods);
27 GxkDragMode gxk_drag_modifier_next (GdkModifierType key_mods,
28  GxkDragMode last_drag_mods);
29 typedef enum /*< skip >*/
30 {
31  /* drag emission state */
32  GXK_DRAG_START, /* initial drag event */
33  GXK_DRAG_MOTION, /* drag motion, pointer moved */
34  GXK_DRAG_DONE, /* final drag motion */
35  GXK_DRAG_ABORT, /* drag abortion requested */
36  /* drag-action requests */
37  GXK_DRAG_UNHANDLED = GXK_DRAG_START, /* continue with button-press or similar */
38  GXK_DRAG_CONTINUE = GXK_DRAG_MOTION, /* request drag-motion emissions */
39  GXK_DRAG_HANDLED = GXK_DRAG_DONE, /* no further emissions */
40  GXK_DRAG_ERROR = GXK_DRAG_ABORT /* request abortion */
41 } GxkDragStatus;
42 typedef struct _GxkScrollCanvas GxkScrollCanvas;
43 typedef struct {
44 #define GXK_SCROLL_CANVAS_DRAG_FIELDS \
45  GtkWidget *widget; \
46  GdkWindow *drawable; \
47  /* modifier & config determined mode */ \
48  GxkDragMode mode : 16; \
49  /* mouse button */ \
50  guint button : 16; \
51  /* emission type: start/motion/done/abort */ \
52  GxkDragStatus type : 16; \
53  guint window_drag : 1; \
54  guint canvas_drag : 1; \
55  guint top_panel_drag : 1; \
56  guint left_panel_drag : 1; \
57  guint right_panel_drag : 1; \
58  guint bottom_panel_drag : 1; \
59  guint ___dummy1 : 2; \
60  /* whether start_x/start_y are in window */ \
61  guint start_confined : 1; \
62  /* whether current_x/current_y are in window */ \
63  guint current_confined : 1; \
64  gint start_x, start_y; \
65  gint current_x, current_y; \
66  /* user data: unhandled/continue/handled/error */ \
67  GxkDragStatus state : 16; \
68  guint ___dummy2 : 16;
69  /* the fields are expanded here via a macro, to allow
70  * "derived" structures with exactly the same field
71  * layout without field prefixes.
72  */
73  GXK_SCROLL_CANVAS_DRAG_FIELDS;
75 typedef struct {
76  guint index;
77  guint mtype;
78  GdkRectangle extends;
79  GdkWindow **windowp;
80  GdkDrawable *pixmap; /* backing store */
81  GdkRectangle coords; /* user coordinates */
82  gpointer user_data;
84 typedef struct {
85  gint top_panel_height;
86  gint left_panel_width;
87  gint right_panel_width;
88  gint bottom_panel_height;
89  gint canvas_width, max_canvas_width;
90  gint canvas_height, max_canvas_height;
93 {
94  GtkContainer parent_instance;
95  GxkScrollCanvasLayout layout;
96  GdkWindow *canvas, *top_panel, *left_panel, *right_panel, *bottom_panel;
97  GdkPixmap *canvas_pixmap;
98  GdkGC **color_gc; /* array of size class->n_colors */
99  guint n_pango_layouts;
100  PangoLayout **pango_layouts;
101  guint n_markers;
102  GxkScrollMarker *markers;
103  /* scroll offset */
104  gint x_offset, y_offset;
105  GtkAdjustment *hadjustment, *vadjustment;
106  guint scroll_timer;
107 };
108 typedef struct
109 {
110  GtkContainerClass parent_class;
111  /* widget config */
112  GdkEventMask canvas_events, top_panel_events, left_panel_events, right_panel_events, bottom_panel_events;
113  guint double_buffer_window : 1, double_buffer_canvas : 1;
114  guint double_buffer_top_panel : 1, double_buffer_left_panel : 1;
115  guint double_buffer_right_panel : 1, double_buffer_bottom_panel : 1;
116  guint auto_clear : 1; /* automatically clear non-double-buffered areas */
117  guint grab_focus : 1; /* automatically grab focus on button-press */
118  guint hscrollable : 1;
119  guint vscrollable : 1;
120  /* skin config */
121  guint n_colors; /* must be const across skin changes */
122  const GdkColor *colors;
123  gchar *image_file_name;
124  GdkColor image_tint;
125  gdouble image_saturation;
126  GSList *realized_widgets;
127  /* virtual methods */
128  void (*get_layout) (GxkScrollCanvas *self,
129  GxkScrollCanvasLayout *layout);
130  void (*set_scroll_adjustments) (GxkScrollCanvas *self,
131  GtkAdjustment *hadjustment,
132  GtkAdjustment *vadjustment);
133  void (*update_adjustments) (GxkScrollCanvas *self,
134  gboolean hadj,
135  gboolean vadj);
136  void (*adjustment_changed) (GxkScrollCanvas *self,
137  GtkAdjustment *adj);
138  void (*reallocate_contents) (GxkScrollCanvas *self,
139  gint xdiff,
140  gint ydiff);
141  void (*draw_window) (GxkScrollCanvas *self,
142  GdkWindow *drawable,
143  GdkRectangle *area);
144  void (*draw_canvas) (GxkScrollCanvas *self,
145  GdkWindow *drawable,
146  GdkRectangle *area);
147  void (*draw_top_panel) (GxkScrollCanvas *self,
148  GdkWindow *drawable,
149  GdkRectangle *area);
150  void (*draw_left_panel) (GxkScrollCanvas *self,
151  GdkWindow *drawable,
152  GdkRectangle *area);
153  void (*draw_right_panel) (GxkScrollCanvas *self,
154  GdkWindow *drawable,
155  GdkRectangle *area);
156  void (*draw_bottom_panel) (GxkScrollCanvas *self,
157  GdkWindow *drawable,
158  GdkRectangle *area);
159  void (*draw_marker) (GxkScrollCanvas *self,
160  GdkWindow *drawable,
161  GdkRectangle *area,
162  GxkScrollMarker *marker);
163  void (*handle_drag) (GxkScrollCanvas *self,
164  GxkScrollCanvasDrag *drag,
165  GdkEvent *event);
167 
168 
169 /* --- prototypes --- */
170 GType gxk_scroll_canvas_get_type (void);
171 void gxk_scroll_canvas_get_layout (GxkScrollCanvas *self,
172  GxkScrollCanvasLayout *layout);
173 void gxk_scroll_canvas_get_canvas_size (GxkScrollCanvas *self,
174  gint *width,
175  gint *height);
176 void gxk_scroll_canvas_set_hadjustment (GxkScrollCanvas *self,
177  GtkAdjustment *adjustment);
178 void gxk_scroll_canvas_set_vadjustment (GxkScrollCanvas *self,
179  GtkAdjustment *adjustment);
180 void gxk_scroll_canvas_update_adjustments (GxkScrollCanvas *self,
181  gboolean hadj,
182  gboolean vadj);
183 void gxk_scroll_canvas_scroll_to (GxkScrollCanvas *self,
184  gint scroll_area_x,
185  gint scroll_area_y);
186 void gxk_scroll_canvas_make_visible (GxkScrollCanvas *self,
187  gint scroll_area_x,
188  gint scroll_area_y,
189  gint scroll_area_width,
190  gint scroll_area_height);
191 void gxk_scroll_canvas_reset_pango_layouts (GxkScrollCanvas *self);
192 void gxk_scroll_canvas_reallocate (GxkScrollCanvas *self);
193 gboolean gxk_scroll_canvas_dragging (GxkScrollCanvas *self);
194 void gxk_scroll_canvas_drag_abort (GxkScrollCanvas *self);
195 void gxk_scroll_canvas_set_window_cursor (GxkScrollCanvas *self,
196  GdkCursorType cursor);
197 void gxk_scroll_canvas_set_canvas_cursor (GxkScrollCanvas *self,
198  GdkCursorType cursor);
199 void gxk_scroll_canvas_set_top_panel_cursor (GxkScrollCanvas *self,
200  GdkCursorType cursor);
201 void gxk_scroll_canvas_set_left_panel_cursor (GxkScrollCanvas *self,
202  GdkCursorType cursor);
203 void gxk_scroll_canvas_set_right_panel_cursor (GxkScrollCanvas *self,
204  GdkCursorType cursor);
205 void gxk_scroll_canvas_set_bottom_panel_cursor (GxkScrollCanvas *self,
206  GdkCursorType cursor);
207 PangoLayout* gxk_scroll_canvas_get_pango_layout (GxkScrollCanvas *self,
208  guint nth);
209 PangoLayout* gxk_scroll_canvas_peek_pango_layout (GxkScrollCanvas *self,
210  guint nth);
211 GxkScrollMarker* gxk_scroll_canvas_lookup_marker (GxkScrollCanvas *self,
212  guint index,
213  guint *count);
214 GxkScrollMarker* gxk_scroll_canvas_add_marker (GxkScrollCanvas *self,
215  guint index);
216 void gxk_scroll_canvas_remove_marker (GxkScrollCanvas *self,
217  GxkScrollMarker *marker);
218 void gxk_scroll_canvas_setup_marker (GxkScrollCanvas *self,
219  GxkScrollMarker *marker,
220  GdkWindow **windowp,
221  guint x,
222  guint y,
223  guint width,
224  guint height);
225 void gxk_scroll_canvas_move_marker (GxkScrollCanvas *self,
226  GxkScrollMarker *marker,
227  guint x,
228  guint y);
229 void gxk_scroll_canvas_class_skin_changed (GxkScrollCanvasClass*);
230 
231 #endif /* __GXK_SCROLL_CANVAS_H__ */
Definition: gxkscrollcanvas.hh:84
int width() const
Definition: gxkscrollcanvas.hh:75
Definition: gxkscrollcanvas.hh:92
int height() const
Definition: gxkscrollcanvas.hh:108
Definition: gxkscrollcanvas.hh:43