1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 
12 
13 #ifndef _WorkspaceP_h
14 #define _WorkspaceP_h
15 #define LTOL 2	/* number of line thicknesses between lines */
16 #define WTOL 1	/* number of line thicknesses between lines and a widget */
17 
18 #define POLICY(ww) ww->workspace.placement_policy
19 
20 #if (XmVersion >= 1002)
21 #include <Xm/PrimitiveP.h>
22 #include <Xm/ManagerP.h>
23 #include <Xm/BulletinBP.h>
24 #include <Xm/FormP.h>
25 #endif
26 
27 #include "WorkspaceCallback.h"
28 
29 /*
30  *  Structure for building lines in the Manhattan algorithm
31  */
32 typedef struct _LineElement
33 	{
34 	int x;
35 	int y;
36 	struct _LineElement *next;
37 	}LineElement;
38 
39 typedef struct _MyWidgetList {
40     short xmin, xmax, ymin, ymax;
41     Widget w;
42     struct _MyWidgetList *next;
43 } MyWidgetList;
44 
45 typedef struct _CollideList {
46     int min;
47     int max;
48     Widget child;
49 	 XmWorkspaceLine line;
50 	 int type;					/* Line or Widget */
51     struct _CollideList *next;
52 } CollideList;
53 
54 /*
55  *  Structure for line management (one struct per line segment)
56  */
57 typedef struct _XmWorkspaceLine {
58     struct _XmWorkspaceLine *next;	/*  For main link list		      */
59     struct _XmWorkspaceLine *src_next;  /*  For source widget constraints     */
60     struct _XmWorkspaceLine *dst_next;	/*  For destination constraints list  */
61     struct _XmWorkspaceLine *temp_next;	/*  For main link list		      */
62     Widget	source;			/*  Widgets to which line attaches    */
63     Widget	destination;
64     Pixel	color;			/*  Color of line		      */
65     short	src_x;			/*  Line drawing coords		      */
66     short	src_y;
67     short	dst_x;
68     short	dst_y;
69     short	src_x_offset;
70     short	dst_x_offset;
71     short	x_left;			/*  Rectangular bounding limits	      */
72     short	x_right;
73     short	y_upper;
74     short	y_lower;
75     XPoint	point[50];		/*  Array of x,y for drawing 50 lines */
76     short	num_points;		/*  Number of points used	      */
77     Boolean	is_to_be_moved;		/*  Flag between deciding and doing   */
78     Boolean	is_to_be_drawn;		/*  Flag to identify yet to be drawn  */
79     Boolean	is_to_be_collapsed;	/*  Flag to identify to be collapsed  */
80     Boolean 	reverse_on_copy;     /*  Used by CopyPointsToLine          */
81     Boolean 	two_phase_draw;	     /*  Used by RefreshLines          */
82 } XmWorkspaceLineRec;
83 
84 /*
85  *  Contents of constraint field hung off each child
86  */
87 typedef struct _XmWorkspaceConstraintPart {
88     WsCallbackList  resizing_callbacks;
89     WsCallbackList  select_callbacks;
90     WsCallbackList  accent_callbacks;
91     XmWorkspaceLineRec *source_lines;
92     XmWorkspaceLineRec *destination_lines;
93     Pixel	accent_uncolor;
94     short	x_left;
95     short	x_right;
96     short	y_upper;
97     short	y_lower;
98     short	x_center;
99     short	y_center;
100     short	x_delta;		/*  Provisional parameters for move   	*/
101     short	y_delta;
102     short	x_index;		/*  x coordinate for sort order       	*/
103     Boolean	is_selectable;		/*  Can make child insensitive	      	*/
104     Boolean	is_selected;		/*  Last callback had selection True  	*/
105     Boolean	is_accented;		/*  Last highlight action was on      	*/
106     Boolean	will_be_selected;	/*  Would be selected if action ended 	*/
107     Boolean	is_within_band;		/*  Is within current rubber_band     	*/
108     Boolean	is_managed;		/*  Reference to detect change	      	*/
109     Boolean	is_newly_managed;
110     char	id;			/*  Used as debug val for easier ID   	*/
111     Boolean	is_v_resizable;		/*  Is this child resizable verti.    	*/
112     Boolean	is_h_resizable;		/*  Is this child resizable horiz.    		*/
113     XRectangle  orig_base;		/*  size before changing modes		*/
114     Boolean	pin_to_sides_lr;/* true -> widget always attached to left/right sides */
115     Boolean	pin_to_sides_tb;/* true -> widget always attached to top/bottom sides */
116     XmFormAttachmentRec att[4]; /* store form attachments when !autoArrange	*/
117     Boolean     line_invisibility;
118 } XmWorkspaceConstraintPart;
119 
120 typedef struct _XmWorkspaceConstraintRec {
121     XmManagerConstraintPart	manager;
122     XmFormConstraintPart	form;
123     XmWorkspaceConstraintPart	workspace;
124 } XmWorkspaceConstraintRec, * XmWorkspaceConstraints;
125 
126 #define WORKSPACE_CONSTRAINT(w) \
127  ((XmWorkspaceConstraints)((w)->core.constraints))
128 
129 
130 typedef struct {
131     GC		lineGC;			/* GC for drawing managed lines	      */
132     GC		lineGC2;		/* GC for drawing managed lines	      */
133     Cursor	hour_glass;		/* Cursor to indicate wait state      */
134     Cursor	move_cursor;
135     Cursor	size_cursor[4];		/* 4 corners of rubber banding	      */
136     XtPointer	extension;
137 } XmWorkspaceClassPart;
138 
139 typedef struct _XmWorkspaceClassRec {
140     CoreClassPart	    core_class;
141     CompositeClassPart	    composite_class;	/* Needed to have children */
142     ConstraintClassPart     constraint_class;	/* Needed by manager	   */
143     XmManagerClassPart      manager_class;	/* Needed to use gadgets   */
144     XmBulletinBoardClassPart bulletin_board_class;
145     XmFormClassPart	    form_class;
146     XmWorkspaceClassPart    workspace_class;
147 } XmWorkspaceClassRec;
148 
149 extern XmWorkspaceClassRec XmworkspaceClassRec;
150 
151 
152 typedef struct _XmWorkspacePart {
153     XtCallbackList position_change_callback;
154     XtCallbackList error_callback;
155     XtCallbackList background_callback;
156     XtCallbackList action_callback;
157     XtCallbackList selection_change_callback;
158     XtCallbackList resize_callback; 	/* anything you want - see transltn tbl */
159     XtEventHandler button_tracker;	/* Client's event handler to call     */
160     Widget	track_widget;		/* Client's widget for event handler  */
161     short	track_x;		/* Offsets for handled button event   */
162     short	track_y;
163     void *	track_client_data;	/* Pointer to pass with call	      */
164     XmWorkspaceLineRec *lines;		/* Link list of managed lines	      */
165     int		num_lines;		/* Number of managed lines	      */
166     int		double_click_interval;	/* Max millisecs between button press */
167     Time	time;			/* Unsigned long of last event time   */
168     GC		gridGC;			/* GC for drawing grid lines (dots)   */
169     GC		bandGC;			/* GC for drawing rubber band (Xor)   */
170     GC		badBandGC;		/* GC for drawing rubber band (Xor)   */
171     int		num_selected;		/* # of children currently selected   */
172     Pixel	accent_color;
173     XRectangle	rubberband[2];		/* Static space for rubberband	      */
174     XRectangle* surrogates;		/* Array of rectangles when moving    */
175     int		num_surrogates;
176     short	base_x;			/* Reference point for rubberbanding  */
177     short	base_y;			/*   and moving with mouse	      */
178     short	grab_x;			/* Reference point of pointer move    */
179     short	grab_y;
180     short	min_x;			/* Limits of displaced children used  */
181     short	max_x;			/*   to check need to resize	      */
182     short	min_y;
183     short	max_y;
184     short	expose_left;		/* Limits of displaced lines used     */
185     short	expose_right;		/*   to restrict effect of clearing   */
186     short	expose_upper;
187     short	expose_lower;
188     short	grid_width;		/* Grid spacing */
189     short	grid_height;
190     short	line_thickness;
191     unsigned char accent_policy;	/* Mode to accent selected children   */
192     unsigned char selection_policy;
193     unsigned char inclusion_policy;	/* When rubberband captures child     */
194     unsigned char surrogate_type;	/* What to draw when moving children  */
195     unsigned char placement_policy;	/* Which rule set applies to overlaps */
196     unsigned char horizontal_alignment;	/* Mode of grid alignment of child    */
197     unsigned char horizontal_draw_grid;	/* XmDRAW_ NONE, HASH, LINE, OUTLINE  */
198     unsigned char vertical_alignment;
199     unsigned char vertical_draw_grid;	/* XmDRAW_ NONE, HASH, LINE, OUTLINE  */
200     unsigned char sort_policy;		/* Part of child to determine x order */
201     Boolean	snap_to_grid;		/* Force children placement as moved  */
202     Boolean	manhattan_route;	/* Draw lines in orthogonal channels  */
203     Boolean	overlap_is_allowed;	/* Allow children to overlap 1another */
204     Boolean	movement_is_allowed;	/* Allow user to move children	      */
205     Boolean	is_rubberbanding;	/* ButtonMotion means resize band     */
206     Boolean	is_moving;		/* ButtonMotion means move selected   */
207     Boolean	is_resizing;		/* ButtonMotion means resize selected */
208     Boolean	band_is_visible;	/* Rubberand last draw as visible     */
209     Boolean	surrogate_is_visible;	/* Surrogates last drawn as visible   */
210     Boolean	shift_is_applied;	/* Action started with shift key down */
211     Boolean	move_cursor_installed;	/* Fleur cursor is installed	      */
212     unsigned char size_xx_installed;	/* Rubberbanding cursor is installed  */
213     int         collide_width;		/* allocated entries in collide_list_x 	*/
214     int         collide_height;		/* allocated entries in collide_list_x 	*/
215     CollideList **collide_list_x;	/* Bins of occupied x positions       	*/
216     CollideList **collide_list_y;	/* Bins of occupied y positions       	*/
217     MyWidgetList  *widget_list;		/* A list of all children for collision
218 					   detection 				*/
219     Boolean	button1_press_mode;	/* Either Rubberbanding (0) or calling
220 					   background callback (1)	      	*/
221     int		wtol;			/* Min dist between line and a widget 	*/
222     int		ltol;			/* Min dist between two lines 		*/
223     Boolean	line_drawing_enabled;	/* Draw lines upon their creaation?	*/
224     Boolean	force_route;		/* Force a manhattan route if it is
225 					   un-routable				*/
226     int		halo_thickness;
227     int		collision_spacing;	/* Inter-widget spacing in
228 					   MoveAToRightofB		     	*/
229     Boolean	suppress_callbacks;
230     Boolean	is_selectable;		/* Selectability for the whole
231 					   workspace			     	*/
232     Boolean	auto_arrange;		/* True if I should repack children if
233 					   one of them resizes himself.      	*/
234     Dimension   orig_width;		/* "redunant" versions widget size	*/
235     Dimension   orig_height;		/* used by Resize method to determine	*/
236 					/* wether we're growing or shrinking	*/
237     XPoint	start;
238     XPoint	corner;
239     Boolean	overlaps;		/* were overlapping children detected	*/
240     Boolean	check_overlap;		/* should we check for collisions	*/
241 } XmWorkspacePart;
242 
243 
244 typedef struct _XmWorkspaceRec {
245     CorePart		core;
246     CompositePart	composite;
247     ConstraintPart	constraint;
248     XmManagerPart	manager;
249     XmBulletinBoardPart bulletin_board;
250     XmFormPart		form;
251     XmWorkspacePart	workspace;
252 } XmWorkspaceRec;
253 
254 extern void FreeLineElementList(LineElement *list);
255 
256 #if (OLD_LESSTIF == 1)
257 typedef struct _XmFormConstraintPart *XmFormConstraint;
258 typedef struct _XmFormConstraintRec *XmFormConstraintPtr;
259 #endif
260 
261 #endif
262