1 /* abstract base class for our UI widgets
2  */
3 
4 /*
5 
6     Copyright (C) 1991-2003 The National Gallery
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License along
19     with this program; if not, write to the Free Software Foundation, Inc.,
20     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 
22  */
23 
24 /*
25 
26     These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
27 
28  */
29 
30 #define TYPE_VIEW (view_get_type())
31 #define VIEW( obj ) (GTK_CHECK_CAST( (obj), TYPE_VIEW, View ))
32 #define VIEW_CLASS( klass ) \
33 	(GTK_CHECK_CLASS_CAST( (klass), TYPE_VIEW, ViewClass ))
34 #define IS_VIEW( obj ) (GTK_CHECK_TYPE( (obj), TYPE_VIEW ))
35 #define IS_VIEW_CLASS( klass ) \
36 	(GTK_CHECK_CLASS_TYPE( (klass), TYPE_VIEW ))
37 #define VIEW_GET_CLASS( obj ) \
38 	(GTK_CHECK_GET_CLASS( (obj), TYPE_VIEW, ViewClass ))
39 
40 /* We track all of the children of our model, listening to "changed", so we
41  * can lazily add or remove child views of us as the model requests.
42  */
43 typedef struct {
44 	View *parent_view;		/* Us */
45 	Model *child_model;		/* The child we are watching */
46 	guint child_model_changed_sid;	/* Listen to "changed" on child here */
47 	View *child_view;		/* The child view for this model */
48 } ViewChild;
49 
50 struct _View {
51 	vObject parent_object;
52 
53 	/* My instance vars.
54 	 */
55 	guint pos_changed_sid;		/* Signals we use to watch iObject */
56 	guint scrollto_sid;
57 	guint layout_sid;
58 	guint front_sid;
59 	guint reset_sid;
60 	guint child_add_sid;
61 	guint child_remove_sid;
62 	guint child_detach_sid;
63 	guint child_attach_sid;
64 
65 	View *parent;			/* Enclosing view (if any) */
66 	GSList *managed;		/* List of ViewChild for us */
67 
68 	gboolean scannable;		/* On scannable list */
69 	gboolean resettable;		/* On resettable list */
70 };
71 
72 typedef struct _ViewClass {
73 	vObjectClass parent_class;
74 
75 	/* Create/destroy
76 
77 		link 		this view is about to be linked to this model
78 				with this parent view
79 
80 		child_add	this view has just gained a child
81 
82 		child_remove	this view is about to lose a child
83 
84 		child_position	this child needs repositioning
85 
86 		child_front	pop this child to the front
87 
88 		display		should this child be displayed
89 
90 	 */
91 
92 	void (*link)( View *, Model *, View * );
93 	void (*child_add)( View *parent, View *child );
94 	void (*child_remove)( View *parent, View *child );
95 	void (*child_position)( View *parent, View *child );
96 	void (*child_front)( View *parent, View *child );
97 	gboolean (*display)( View *parent, Model *child );
98 
99 	/* State change
100 
101 		reset		reset edit mode ... eg. text pops back to
102 				value display
103 
104 		scan		scan widgets, reading any new text off the
105 				display
106 
107 		scrollto	try to make this view visible
108 
109 		layout		try to lay children out
110 
111 	 */
112 	void (*reset)( View * );
113 	void *(*scan)( View * );
114 	void (*scrollto)( View *, ModelScrollPosition );
115 	void (*layout)( View * );
116 } ViewClass;
117 
118 void view_scannable_register( View *view );
119 void view_scannable_unregister( View *view );
120 gboolean view_scan_all( void );
121 
122 void view_resettable_register( View *view );
123 void view_resettable_unregister( View *view );
124 void view_reset_all( void );
125 
126 gboolean view_hasmodel( View *view );
127 void *view_model_test( View *child, Model *model );
128 
129 GtkType view_get_type( void );
130 
131 void view_link( View *view, Model *model, View *parent );
132 void view_unlink( View *view );
133 void view_child_add( View *parent, View *child );
134 void view_child_remove( View *child );
135 void view_child_position( View *child );
136 void view_child_front( View *child );
137 
138 void *view_reset( View *view );
139 void *view_scan( View *view );
140 void *view_scrollto( View *view, ModelScrollPosition );
141 void *view_layout( View *view );
142 
143 void *view_map( View *view, view_map_fn fn, void *a, void *b );
144 void *view_map_all( View *view, view_map_fn fn, void *a );
145 
146 void view_save_as_cb( GtkWidget *menu, GtkWidget *host, View *view );
147 void view_save_cb( GtkWidget *menu, GtkWidget *host, View *view );
148 void view_close_cb( GtkWidget *menu, GtkWidget *host, View *view );
149 
150 void view_activate_cb( View *view );
151 void view_changed_cb( View *view );
152 
153 void view_not_implemented_cb( GtkWidget *menu, GtkWidget *host, View *view );
154 
155 GtkWidget *view_get_toplevel( View *view );
156 
157 Columnview *view_get_columnview( View *child );
158 void *view_resize( View *view );
159