1 /*  Part of XPCE --- The SWI-Prolog GUI toolkit
2 
3     Author:        Jan Wielemaker and Anjo Anjewierden
4     E-mail:        jan@swi.psy.uva.nl
5     WWW:           http://www.swi.psy.uva.nl/projects/xpce/
6     Copyright (c)  1985-2002, University of Amsterdam
7     All rights reserved.
8 
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions
11     are met:
12 
13     1. Redistributions of source code must retain the above copyright
14        notice, this list of conditions and the following disclaimer.
15 
16     2. Redistributions in binary form must reproduce the above copyright
17        notice, this list of conditions and the following disclaimer in
18        the documentation and/or other materials provided with the
19        distribution.
20 
21     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25     COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32     POSSIBILITY OF SUCH DAMAGE.
33 */
34 
35 #ifndef _PCE_GRA_INCLUDED
36 #define _PCE_GRA_INCLUDED
37 
38 		 /*******************************
39 		 *     STRETCHABLE OBJECTS	*
40 		 *******************************/
41 
42 typedef struct
43 { int	ideal;				/* ideal size */
44   int   minimum;			/* minimum size */
45   int	maximum;			/* maximum size */
46   int	stretch;			/* stretch handicap */
47   int	shrink;				/* shrink handicap */
48   int	size;				/* resulting size */
49 } stretch, *Stretch;
50 
51 		 /*******************************
52 		 *	    TABLES, ETC.	*
53 		 *******************************/
54 
55 #include <h/layout.h>
56 
57 #define MAX_WRAP_LINES	100		/* line-wraps in text-objects */
58 
59 typedef struct update_area *UpdateArea;	/* Window changes data  */
60 typedef struct colour_context *ColourContext; /* for selection/inactive */
61 
62 #define ABSTRACT_GRAPHICAL \
63   ABSTRACT_VISUAL \
64   Device	device;			/* device on which displayed */ \
65   Area		area;			/* area (bounding box) */ \
66   BoolObj	displayed;		/* is graphical object displayed? */ \
67   Int		pen;			/* pen thickness for this object */ \
68   Name		texture;		/* dash pattern for lines */ \
69   Any		colour;			/* colour of the graphical */ \
70   Chain		handles;		/* handles connected to graphical */ \
71   Chain		connections;		/* Available connections */ \
72   Name		name;			/* name to find it */ \
73   BoolObj	selected;		/* is graphical selected? */ \
74   BoolObj	inverted;		/* inverted image */ \
75   BoolObj	active;			/* (de)activated */ \
76   CursorObj	cursor;			/* cursor of the graphical */ \
77   LayoutInterface layout_interface;	/* Interface to layout manager */ \
78   Any		request_compute;	/* graphical needs recomputed */
79 
80 #define ABSTRACT_DEVICE \
81   ABSTRACT_GRAPHICAL \
82   Int	        level;			/* Level from root */ \
83   Point	        offset;			/* Origin offset */ \
84   Area	        clip_area;		/* Visible subarea */ \
85   Chain	        graphicals;		/* Displayed graphicals */ \
86   Chain	        pointed;		/* Graphicals on last event */ \
87   LayoutManager layout_manager;		/* Manage graphicals layout */ \
88   Format        format;			/* Row/Column formatting */ \
89   BoolObj       badFormat;		/* Formats needs to be recomputed */ \
90   BoolObj       badBoundingBox;		/* BoundingBox needs recomputed */ \
91   Chain	        recompute;		/* Graphicals requesting recompute */
92 
93 #define ABSTRACT_FIGURE \
94   ABSTRACT_DEVICE \
95   Name		status;			/* Which members are displayed? */ \
96   Image		background;		/* Pattern for background */ \
97   Int		border;			/* border around graphicals */ \
98   Int		radius;			/* radius of outline */ \
99   Elevation	elevation;		/* elevation of outline */
100 
101 #define ABSTRACT_DIALOGITEM \
102   ABSTRACT_GRAPHICAL \
103   Any	     label;			/* Label of the item */ \
104   FontObj    label_font;		/* Font used for the label */ \
105   Int	     label_width;		/* Width of the label */ \
106   Name	     label_format;		/* Alignment of label in box */ \
107   Any	     background;		/* Colour or Image for background */ \
108   Name	     status;			/* inactive, focus, preview, execute*/\
109   Code	     message;			/* Execution message */ \
110   PopupObj   popup;			/* Popup associated with item */ \
111   Name	     look;			/* Look and feel switch */ \
112   BoolObj    auto_align;		/* Item is automatically aligned */ \
113   Point	     reference;			/* Reference point of item */ \
114   DialogItem above;			/* Item above me */ \
115   DialogItem below;			/* Item below me */ \
116   DialogItem right;			/* Item right of me */ \
117   DialogItem left;			/* Item left of me */ \
118   Name	     alignment;			/* Align in the column? */ \
119   BoolObj    auto_label_align;		/* Automatically align label? */ \
120   BoolObj    auto_value_align;		/* Automatically align value? */ \
121   Name	     accelerator;		/* Associated accelerator */
122 
123 
124 #define ABSTRACT_JOINT \
125   ABSTRACT_GRAPHICAL \
126   Graphical	first_arrow;		/* arrow on start point */ \
127   Graphical	second_arrow;		/* arrow on end point */
128 
129 #define ABSTRACT_LINE \
130   ABSTRACT_JOINT \
131   Int		start_x;		/* X-start point */ \
132   Int		start_y;		/* Y-start point */ \
133   Int		end_x;			/* X-end point */ \
134   Int		end_y;			/* Y-end point */
135 
136 
137 		/********************************
138 		*         DEVICE CLASSES	*
139 		********************************/
140 
141 NewClass(graphical)
142   ABSTRACT_GRAPHICAL
143 End;
144 
145 NewClass(device)
146   ABSTRACT_DEVICE
147 End;
148 
149 NewClass(figure)
150   ABSTRACT_FIGURE
151 End;
152 
153 #define ABSTRACT_DIALOG_GROUP \
154   ABSTRACT_DEVICE \
155   Any		label;			/* Displayed textual-label */ \
156   FontObj	label_font;		/* Font used for label */ \
157   Name		label_format;		/* Alignment of the label */ \
158   Elevation	elevation;		/* Elevation for the box */ \
159   Int		radius;			/* corners rounding radius */ \
160   Size		size;			/* Size of the drawing area */ \
161   Size		gap;			/* Layout gap for items (dialog) */ \
162   Size		border;			/* Border around graphicals */ \
163   BoolObj	auto_align;		/* Align in dialog window? */ \
164   Name		alignment;		/* Row alignment */
165 
166 NewClass(dialog_group)
167   ABSTRACT_DIALOG_GROUP
168 End;
169 
170 NewClass(tab)
171   ABSTRACT_DIALOG_GROUP
172   Size		label_size;		/* Size of the label-box */
173   Int		label_offset;		/* X-Offset of the label-box */
174   Name		status;			/* {on_top, hidden} */
175   Name		previous_top;		/* Name of element on top before me */
176 End;
177 
178 NewClass(label_box)
179   ABSTRACT_DIALOG_GROUP
180   Int		label_width;		/* Width of box holding the label */
181   BoolObj	auto_label_align;	/* Automatically align label */
182   Code		message;		/* associated message */
183   Any		default_value;		/* default */
184   BoolObj	modified;		/* item has been modified */
185 End;
186 
187 NewClass(tab_stack)
188   ABSTRACT_DEVICE
189 End;
190 
191 		/********************************
192 		*           RELATIONS		*
193 		********************************/
194 
195 NewClass(format)
196   Name		direction;	/* horizontal, vertical */
197   Int		width;		/* Width/Height */
198   BoolObj	columns;	/* W/H in columns (@on)/pixels (@off) */
199   Int		column_sep;	/* separation between columns */
200   Int		row_sep;	/* separation between rows */
201   Vector	adjustment;	/* left/center/right vector for comlumn mode */
202 End;
203 
204 NewClass(tileobj)
205   Int		idealWidth;		/* Desired width of the tile */
206   Int		idealHeight;		/* Idem for height */
207   Int		horStretch;		/* Horizontal stretchability */
208   Int		horShrink;		/* Horizontal shrinkability */
209   Int		verStretch;		/* Vertical stretchability */
210   Int		verShrink;		/* Vertical shrinkability */
211   BoolObj	canResize;		/* Can be resized by user? */
212   TileAdjuster	adjuster;		/* Object that resizes me */
213   Int		border;			/* Border between subtiles */
214   Name		orientation;		/* none, horizontal, vertical */
215   Chain		members;		/* subtiles */
216   TileObj	super;			/* Super tile */
217   Any		object;			/* Object managed */
218   Area		area;			/* Current area of the tile */
219   BoolObj		enforced;		/* Enfore layout */
220 End;
221 
222 NewClass(tree)
223   ABSTRACT_FIGURE
224   Node		root;			/* the real root root node */
225   Node		displayRoot;		/* node displayed as root */
226   BoolObj	auto_layout;		/* Enforce automatic layout? */
227   Int		levelGap;		/* distance parent/son */
228   Int		neighbourGap;		/* distance sons */
229   Int		linkGap;		/* distance link and graphical */
230   Name		direction;		/* NAME_horizonal/vertical/list */
231   Link		link;			/* link  between son/parent */
232   Handle	parentHandle;		/* connection parent handle */
233   Handle	sonHandle;		/* connection son handle */
234   Chain		rootHandlers;		/* handlers for root node */
235   Chain		leafHandlers;		/* handlers for leaf nodes */
236   Chain		nodeHandlers;		/* handlers for other nodes */
237   Chain		collapsedHandlers;	/* handlers for collapsed nodes */
238 End;
239 
240 NewClass(connection)
241   ABSTRACT_LINE
242   Link		link;			/* link description of connection */
243   Graphical	from;			/* `from' side graphical */
244   Graphical	to;			/* `to' side graphical */
245   Name		from_handle;		/* Handle-name `from' */
246   Name		to_handle;		/* Handle-name `to' */
247   BoolObj	fixed_from;		/* From is fixed */
248   BoolObj	fixed_to;		/* To is fixed */
249 End;
250 
251 NewClass(link)
252   Line		line;			/* line to connect objects with */
253   Name		from;			/* handle kind 'from' */
254   Name		to;			/* handle kind 'to' */
255   Class		connection_class;	/* Class to create connection from */
256 End;
257 
258 		/********************************
259 		*      PRIMITIVE GRAPHICALS	*
260 		********************************/
261 
262 NewClass(arc)
263   ABSTRACT_JOINT
264   Point		position;		/* Center of the arc */
265   Size		size;			/* width and height */
266   Real		start_angle;		/* Start angle */
267   Real		size_angle;		/* Size angle */
268   Name		close;			/* {none,chord,pie_slice} */
269   Image		fill_pattern;		/* Filled with this pattern */
270 End;
271 
272 NewClass(circle)
273   ABSTRACT_GRAPHICAL
274   Image		fill_pattern;		/* image to fill the circle */
275 End;
276 
277 NewClass(ellipse)
278   ABSTRACT_GRAPHICAL
279   Int		shadow;			/* shadow displayed around ellipse */
280   Image		fill_pattern;		/* fill pattern  */
281 End;
282 
283 NewClass(bezier)
284   ABSTRACT_JOINT
285   Point	start;
286   Point end;
287   Point control1;			/* Quadratic Bezier Curve */
288   Point control2;			/* Cubic Bezier Curve */
289 End;
290 
291 NewClass(box)
292   ABSTRACT_GRAPHICAL
293   Int        radius;			/* if displayed as a rounded box */
294   Int	     shadow;			/* shadow displayed around box */
295   Image	     fill_pattern;		/* fill box with this */
296   Point	     fill_offset;		/* Offset for filling */
297 End;
298 
299 NewClass(arrow)
300   ABSTRACT_GRAPHICAL
301   Point      tip;		/* tip of the arrow head */
302   Point      reference;		/* reference point for the arrow */
303   Int        length;		/* length of the arrow head */
304   Int        wing;		/* wing (width) of the arrow head */
305   Image	     fill_pattern;	/* bitmap used to fill the arrow head */
306   Name       style;		/* open or closed arrow */
307   Point      left;
308   Point      right;		/* together with tip make up the arrow head */
309 End;
310 
311 NewClass(textobj)
312   ABSTRACT_GRAPHICAL
313   CharArray  string;		/* the string itself */
314   FontObj    font;		/* font */
315   Name       format;		/* NAME_left, NAME_center, NAME_right */
316   Int	     margin;		/* Right margin (pixels) */
317   BoolObj    underline;		/* Underline the text? */
318   Point	     position;		/* reference position of text */
319   Int        caret;		/* current insertion/deletion point */
320   Any	     show_caret;	/* show the caret (default OFF) */
321   Any	     background;	/* Background of text */
322   Int	     border;		/* Border around actual text */
323   Name	     wrap;		/* Clip to width */
324   Int	     x_offset;		/* Shift in X-direction (length > 0) */
325   Int	     x_caret;		/* Caret X, relative to graphical */
326   Int	     y_caret;		/* Caret Y, relative to graphical */
327   Int	     selection;		/* Represented selection */
328 End;
329 
330 NewClass(joint)
331   ABSTRACT_JOINT
332 End;
333 
334 NewClass(line)
335   ABSTRACT_LINE
336 End;
337 
338 NewClass(path)
339   ABSTRACT_JOINT
340   Point	     offset;			/* offset of the points */
341   Name	     kind;			/* poly_line, smooth_line */
342   Int	     radius;			/* Round corners of poly-line */
343   Int	     intervals;			/* Number of iteration intervals */
344   Chain	     points;			/* Points of the poly-line */
345   Image	     fill_pattern;		/* Fill the path with this pattern */
346   Image	     mark;			/* Mark used for points */
347   BoolObj    closed;			/* Line from end back to start */
348   Chain	     interpolation;		/* interpolated points */
349 End;
350 
351 
352 		/********************************
353 		*          MENU CLASSES		*
354 		********************************/
355 
356 NewClass(dialog_item)
357   ABSTRACT_DIALOGITEM
358 End;
359 
360 NewClass(label)
361   ABSTRACT_DIALOGITEM
362   FontObj    font;			/* Font of the text */
363   Name	     wrap;			/* How to handle long text */
364   Int	     length;			/* Length in characters */
365   Int	     width;			/* Width of field in pixels */
366   Any	     selection;			/* Currently displayed value */
367   Int	     border;			/* additional space */
368   Elevation  elevation;			/* Elevation of the area */
369 End;
370 
371 #define GTK_BUTTON_MARGIN 5		/* Lowered region of default button */
372 
373 NewClass(button)
374   ABSTRACT_DIALOGITEM
375   Int	     radius;			/* Rounding radius */
376   Int	     shadow;			/* shadow around button */
377   Image	     popup_image;		/* Image to indicate popup */
378   BoolObj    default_button;		/* Button is the default button */
379   BoolObj    show_focus_border;		/* Show wide border around focus */
380 End;
381 
382 #define ABSTRACT_TEXTITEM \
383   ABSTRACT_DIALOGITEM \
384   Any	     selection;			/* Current selection */ \
385   Any	     default_value;		/* The default (initial) value */ \
386   StringObj  print_name;		/* Print-name of selection */ \
387   Type	     type;			/* Type of the value */ \
388   Any	     value_set;			/* Set of possible values */ \
389   Name	     advance;			/* Clear value after return? */ \
390   Int	     length;			/* Length in x's */ \
391   FontObj    value_font;		/* Font for entry-field */ \
392   BoolObj    show_label;		/* Show the label */ \
393   TextObj    value_text;		/* Displayed text value */ \
394   BoolObj    editable;			/* TextItem is editable */ \
395   Int	     value_width;		/* Width of value-field in pixels */ \
396   Int	     hor_stretch;		/* Horizontal stretchability */ \
397   Name	     style;			/* normal, combo_box */
398 
399 NewClass(textitem)
400   ABSTRACT_TEXTITEM
401 End;
402 
403 NewClass(slider)
404   ABSTRACT_DIALOGITEM
405   Any	     selection;			/* Current value (selection) */
406   Any	     default_value;		/* Default valur (or function) */
407   Any	     displayed_value;		/* Currently displayed value */
408   FontObj    value_font;		/* Font of the value */
409   BoolObj    show_label;		/* Display the label */
410   BoolObj    show_value;		/* Display the value numerical */
411   Name	     format;			/* format for the value */
412   Any	     low;
413   Any	     high;			/* Low and high values */
414   Int	     width;			/* Width in pixels */
415   BoolObj    drag;			/* Dragging gives messages */
416 End;
417 
418 #define ABSTRACT_MENU \
419   ABSTRACT_DIALOGITEM \
420   Any	     selection;			/* Current selection */ \
421   Chain	     members;			/* Chain of menu-items */ \
422   Any	     default_value;		/* Function or default value */ \
423   Name	     kind;			/* Kind of menu */ \
424   MenuItem   preview;			/* Item in preview state */ \
425   Name	     preview_feedback;		/* Feedback given for this */ \
426   Name	     feedback;			/* Visual feedback */ \
427   BoolObj    multiple_selection;	/* radio-button? */ \
428   BoolObj    show_label;		/* Show label of menu? */ \
429   FontObj    value_font;		/* Font of the value */ \
430   Int	     value_width;		/* Minimum width for a value */ \
431   Name	     layout;			/* Horizontal or vertical */ \
432   Int	     columns;			/* Number of columns */ \
433   Name	     format;			/* {left,center,right} */ \
434   Name	     vertical_format;		/* {top,center,bottom} */ \
435   Size	     gap;			/* Space between items */ \
436   Int	     border;			/* Space around item */ \
437   Image	     on_image;			/* Image if selected == @on */ \
438   Image	     off_image;			/* Image if selected == @off */ \
439   Image	     popup_image;		/* Image if popup != @nil */ \
440   FontObj    accelerator_font;		/* Font for accelerators */ \
441   Int	     margin;			/* Margin at the left/right */ \
442   Int	     left_offset;		/* Space box and item-image */ \
443   Int	     right_offset;		/* Same at right side */ \
444   Point	     item_offset;		/* Offset of first item */ \
445   Size	     item_size;			/* Size of each item */ \
446   Area	     label_area;		/* Area for the label */
447 
448 #define PULLRIGHT_GAP 3			/* gap between item and => in popup */
449 
450 NewClass(menu)
451   ABSTRACT_MENU
452 End;
453 
454 NewClass(popupobj)
455   ABSTRACT_MENU
456   Any	     context;			/* Invoking context */
457   Code	     update_message;		/* Message sent to allow for update */
458   PopupObj   pullright;			/* Currently shown pullright menu */
459   Any	     selected_item;		/* What has been selected? */
460   Name	     button;			/* Invoking button */
461   Name	     default_item;		/* Initial previewed item */
462   BoolObj    show_current;		/* Show current selection? */
463 End;
464 
465 NewClass(menu_bar)
466   ABSTRACT_DIALOGITEM
467   Chain	     members;			/* The popups */
468   Name	     format;			/* format of labels in their box */
469   PopupObj   current;			/* Currently visible popup */
470   Name	     button;			/* Button that activated me */
471   Chain	     buttons;			/* Chain of buttons */
472   Int	     gap;			/* distance between buttons */
473   Int	     radius;			/* radius for the buttons */
474 End;
475 
476 NewClass(pen)
477   Int		thickness;		/* drawing pen thickness */
478   Name		texture;		/* dash-pattern */
479   Any		colour;			/* look */
480 End;
481 
482 NewClass(node)
483   ABSTRACT_VISUAL
484   Graphical	image;			/* image displayed as the node */
485   Tree		tree;			/* tree in which node resides */
486   Int		level;			/* distance from the root */
487   Chain		sons;			/* chain of son nodes */
488   Chain		parents;		/* chain of parent nodes */
489   BoolObj	collapsed;		/* greyed out and collapsed */
490   BoolObj	displayed;		/* Non-visible node */
491   Int		sons_size;		/* total height of sub-tree */
492   Int		my_size;		/* size of my graphical */
493   Name		computed;		/* height has been computed */
494 End;
495 
496 NewClass(scrollbar)
497   ABSTRACT_GRAPHICAL
498   Code		message;		/* Message executed */
499   Graphical	object;			/* Scrolling this graphical */
500   Chain		placement;		/* Relative placement */
501   Int		distance;		/* Distance to <-object */
502   Name		status;			/* {inactive, active, running} */
503   Name		orientation;		/* {horizontal, vertical} */
504   Int		view;			/* length of visual part of object */
505   Int		start;			/* start of visual part of object */
506   Int		length;			/* Total length of object */
507   Int		bubble_start;		/* Start of bubble in pixels */
508   Int		bubble_length;		/* Length of bubble in pixels */
509   Name		look;			/* NAME_mac or NAME_sun or NAME_x */
510   BoolObj	drag;			/* Issue dragging updates? */
511   Int		amount;			/* Amount to scroll */
512   Name		direction;		/* Direction in which to scroll */
513   Name		unit;			/* Unit to scroll */
514   Int		offset;			/* offset of down from bubble-start */
515   BoolObj		auto_hide;		/* if @on, hide automatically */
516 End;
517 
518 #define SCROLL_PAGE_PROM 900		/* Scroll one page */
519 
520 NewClass(menu_item)
521   ABSTRACT_VISUAL
522   Menu	     menu;			/* Menu I'm part of */
523   Any	     value;			/* Value represented */
524   Code	     message;			/* Message send */
525   Any        label;			/* Label of the item */
526   FontObj    font;			/* Font of the label */
527   Colour     colour;			/* Colour to use */
528   Colour     background;		/* Colour for the background */
529   BoolObj    selected;			/* Currently selected */
530   BoolObj    active;			/* Can be selected? */
531   Code	     condition;			/* Determines <->active */
532   BoolObj    end_group;			/* Ends logical group of items */
533   PopupObj   popup;			/* Popup (sub-popups and menu-bars) */
534   Name	     accelerator;		/* activate on this key */
535 End;
536 
537 		/********************************
538 		*            GESTURES		*
539 		********************************/
540 
541 NewClass(popup_gesture)
542   ABSTRACT_GESTURE
543   PopupObj	popup;			/* Popup shown */
544   PopupObj	current;		/* Currently visible popup */
545   Any		context;		/* Execution context parameter */
546   Int		max_drag_distance;	/* Cancel after dragging this far */
547 End;
548 
549 #define ABSTRACT_MOVEGESTURE \
550   ABSTRACT_GESTURE \
551   Point		offset;			/* Offset of down to graphical */
552 
553 NewClass(move_gesture)
554   ABSTRACT_MOVEGESTURE
555 End;
556 
557 NewClass(move_outline_gesture)
558   ABSTRACT_MOVEGESTURE
559   Box		outline;		/* Outline dragged */
560 End;
561 
562 #define ABSTRACT_RESIZEGESTURE \
563   ABSTRACT_GESTURE \
564   Name		h_mode;			/* Horizontal resize mode */ \
565   Name		v_mode;			/* Vertical resize mode */ \
566   Size		min_size;		/* Minimum size */ \
567   Size		max_size;		/* Maximum size */
568 
569 
570 NewClass(resize_gesture)
571   ABSTRACT_RESIZEGESTURE
572 End;
573 
574 NewClass(resize_outline_gesture)
575   ABSTRACT_RESIZEGESTURE
576   Box		outline;		/* Outline dragged */
577   ResizeGesture outline_gesture;	/* Recoigniser of the outline */
578 End;
579 
580 NewClass(click_gesture)
581   ABSTRACT_GESTURE
582   Name		multiclick;		/* {single,double,tripple} */
583   Point		down_position;		/* Position of the ->down event */
584   Code		execute_message;	/* Message sent on up inside area */
585   Code		preview_message;	/* Message sent on down */
586   Code		cancel_message;		/* Message sent on up outside area */
587   CursorObj	execute_cursor;		/* Cursor while executing */
588   Int		max_drag_distance;	/* Cancel after dragging this far */
589 End;
590 
591 NewClass(connect_gesture)
592   ABSTRACT_GESTURE
593   Device	device;			/* Device used for feedback */
594   Line		line;			/* Line for feedback (cf. outline) */
595   Image		mark;			/* Bitmap used to mark handles */
596   Link		link;			/* Link to realise connection */
597   Chain		from_indicators;	/* Indicator bitmaps at from side */
598   Chain		to_indicators;		/* Indicator bitmaps at to side */
599   Name		from_handle;		/* Handle at from side */
600   Name		to_handle;		/* Handle at to side */
601   Graphical	to;			/* Graphical at to side */
602 End;
603 
604 NewClass(edit_text_gesture)
605   ABSTRACT_GESTURE
606   Int		selection_origin;	/* Start of the selection */
607   Int		max_drag_distance;	/* Max distance for dragging */
608   BoolObj	activate;		/* @on: focus on ->terminate */
609 End;
610 
611 NewClass(key_binding)
612   ABSTRACT_RECOGNISER
613   Name		name;			/* Global name of this table */
614   Sheet		bindings;		/* Key-name --> function */
615   Chain		defaults;		/* Default tables to be used */
616   Any		default_function;	/* Function if not defined */
617   Name		prefix;			/* Parsed prefix */
618   Int		argument;		/* Universal argument */
619   Name		status;			/* {universal_argument}* */
620   Int		saved_column;		/* {next,previous}_line column */
621   Code		condition;		/* General condition for activation */
622 End;
623 
624 		/********************************
625 		*          BROWSERS		*
626 		********************************/
627 
628 NewClass(list_browser)
629   ABSTRACT_DEVICE
630   Dict		dict;			/* dict in which items reside */
631   TextImage	image;			/* The text area */
632   ScrollBar	scroll_bar;		/* The scrollbar */
633   TextObj	label_text;		/* Text to display the label */
634   Name		status;			/* active/inactive */
635   KeyBinding	key_binding;		/* Keybinding table */
636   Any		selection;		/* DictItem (Chain) of selected */
637   Style		selection_style;	/* Style object for selection */
638   BoolObj	multiple_selection;	/* Multiple selections (def: OFF) */
639   Code		select_message;		/* Message on left button click */
640   Code		open_message;		/* Message on left-double click */
641   Code		cancel_message;		/* Send on drag with `up' outside */
642   PopupObj	popup;			/* Associated popup */
643   FontObj	font;			/* Font for text */
644   Sheet		styles;			/* Name --> style mapping */
645   Size		size;			/* Size in characters */
646   Int		start;			/* Index of first item shown */
647   Int		search_origin;		/* Origin of incremental search */
648   Int		search_hit;		/* Current item found */
649   StringObj	search_string;		/* Incremental search string */
650   Int		caret;			/* Index of `caret' item */
651   Int		selection_origin;	/* Origin of select-range */
652 					/* Start private data */
653   Cell		start_cell;		/* Cell corresponding to <-start */
654 End;
655 
656 
657 		 /*******************************
658 		 *	       WINDOWS		*
659 		 *******************************/
660 
661 #define ABSTRACT_WINDOW \
662   ABSTRACT_DEVICE \
663   FrameObj	frame;			/* Frame we are member of */ \
664   PceWindow	decoration;		/* Window holding decorations */ \
665   Area		bounding_box;		/* Union of graphicals */ \
666   TileObj	tile;			/* Area managing tile */ \
667   Code		resize_message;		/* Message send after a resize */ \
668   CursorObj	displayed_cursor;	/* Currently displayed cursor */ \
669   BoolObj	input_focus;		/* Window has the input focus */ \
670   Graphical	keyboard_focus;		/* Graphical in focus of keyboard */ \
671   Graphical	focus;			/* Graphical in focus */ \
672   Recogniser	focus_recogniser;	/* Recorniser in focus */ \
673   CursorObj	focus_cursor;		/* Cursor during focus */ \
674   Name		focus_button;		/* Button that initiated focus */ \
675   EventObj	focus_event;		/* Event that grabbed the focus */ \
676   Point		scroll_offset;		/* Amount scrolled */ \
677   PopupObj	popup;			/* Associated popup */ \
678   EventObj	current_event;		/* Currently processed event */ \
679   BoolObj	sensitive;		/* Sensitive to events */ \
680   Any		background;		/* Background colour of the window */ \
681   BoolObj	has_pointer;		/* We own the pointer */ \
682   Any		selection_feedback;	/* Feedback for selection */ \
683   BoolObj	buffered_update;	/* Buffered update? */ \
684 					/* Alien stuff */ \
685   UpdateArea	changes_data;		/* Recorded changes */ \
686   WsRef		ws_ref;			/* Window system reference */
687 
688 NewClass(colour_map)
689   Name		name;			/* name of the map */
690   Vector	colours;		/* colours in the map */
691   BoolObj	read_only;		/* colourmap cannot be changed */
692   WsRef		ws_ref;			/* Window system reference */
693 End;
694 
695 typedef struct
696 { enum
697   { XBM_DATA,
698     XPM_DATA
699   } type;
700   union
701   { unsigned char *xbm;
702     char **xpm;
703   } bits;
704 } builtin_image_data;
705 
706 #define ABSTRACT_IMAGE \
707   ABSTRACT_VISUAL \
708   Name		name;			/* Name of the image */ \
709   Name		kind;			/* {pixmap,bitmap} */ \
710   SourceSink	file;			/* Resolved file */ \
711   Name		access;			/* {read,both} */ \
712   Colour	background;		/* Background-colour (pixmap) */ \
713   Colour	foreground;		/* Foreground-colour (pixmap) */ \
714   Int		depth;			/* Bits/pixel */ \
715   Size		size;			/* Size of the image */ \
716   DisplayObj	display;		/* Display of read-write's */ \
717   BitmapObj	bitmap;			/* Bitmap for read-write's */ \
718   Point		hot_spot;		/* Indication of hot-spot */ \
719   Image		mask;			/* Masking image */ \
720   WsRef		ws_ref;			/* Window system reference */ \
721   builtin_image_data *bits;		/* Data for built-in images */
722 
723 NewClass(image)
724   ABSTRACT_IMAGE
725 End;
726 
727 NewClass(pixmapobj)
728   ABSTRACT_IMAGE
729 End;
730 
731 NewClass(bitmapobj)
732   ABSTRACT_GRAPHICAL
733   Image		image;			/* Image of the bitmap */
734   BoolObj	transparent;		/* Just stipple pattern */
735 End;
736 
737 
738 NewClass(cursorobj)
739   Name		name;			/* Name of the cursor */
740   Int		font_id;		/* Identifier in X-cursor-font */
741   Image		image;			/* User-defined image */
742   Image		mask;			/* User-defined mask */
743   Point		hot_spot;		/* User-defined hot_spot */
744   Colour	foreground;		/* User-defined foreground */
745   Colour	background;		/* User-defined background */
746 End;
747 
748 
749 NewClass(colour)
750   Name		name;			/* Name of the colour (red, ...) */
751   Name		kind;			/* `named' or `rgb' */
752   Int		red;			/* Red intensity */
753   Int		green;			/* Green intensity */
754   Int		blue;			/* Blue intensity */
755 End;
756 
757 
758 NewClass(elevation)
759   Name		name;			/* logical name */
760   Int		height;			/* Height of the top */
761   Any		colour;			/* Colour of the top */
762   Any		background;		/* Colour when down */
763   Any		relief;			/* Relief colour/pixmap */
764   Any		shadow;			/* Shadow colour/pixmap */
765   Name		kind;			/* How elevation is painted */
766 End;
767 
768 
769 NewClass(fontobj)
770   Name		family;			/* Font family */
771   Name		style;			/* Style */
772   Int		points;			/* Point size */
773   Int		ex;			/* Width of an x in this font */
774   Name          x_name;			/* X-Name of the font */
775   BoolObj	fixed_width;		/* Is this a fixed width font? */
776   BoolObj	iswide;			/* Font is 16-bit font */
777   Name		postscript_font;	/* Name of PostScript font */
778   Int		postscript_size;	/* Size in PostScript */
779 End;
780 
781 
782 NewClass(displayobj)
783   ABSTRACT_VISUAL
784   Size		size;			/* size of the display in pixels */
785   Name		address;		/* Display address specification */
786   HashTable	font_table;		/* Table holding font-mappings */
787   Chain		frames;			/* Created frames on this display */
788   Chain		monitors;		/* Physical monitors attached */
789   Chain		inspect_handlers;	/* Event-handlers for inspector */
790   Colour	foreground;		/* Window default foreground */
791   Colour	background;		/* Window default background */
792   ColourMap	colour_map;		/* Default colour_map for frames */
793   BoolObj	quick_and_dirty;	/* Use quick_and_dirty drawing */
794   Image		cache;			/* Graphics cache */
795   Name		window_manager;		/* name of the window manager */
796   DisplayManager display_manager;	/* Global display manager */
797   Int		busy_locks;		/* Lock count of ->busy_cursor */
798   WsRef		ws_ref;			/* Window System Reference */
799 End;
800 
801 
802 NewClass(display_manager)
803   ABSTRACT_VISUAL
804   Chain		members;		/* Available displays */
805   Chain		current;		/* Stack for current display */
806   BoolObj	test_queue;		/* Test queue during redraw */
807 End;
808 
809 
810 NewClass(application)
811   ABSTRACT_VISUAL
812   Name		name;			/* name of the application */
813   FrameObj	leader;			/* Leader of the app */
814   Chain		members;		/* its member frames */
815   Name		kind;			/* {user,service} */
816   Chain		modal;			/* Stack of modal frames */
817   Image		icon_image;		/* Image of the icon */
818 End;
819 
820 
821 NewClass(frameobj)
822   ABSTRACT_VISUAL
823   Name		name;			/* Name of the frame */
824   Name		label;			/* Label of the frame */
825   Name		icon_label;		/* Label of the icon */
826   Image		icon_image;		/* Image of the icon */
827   Point		icon_position;		/* Position of the icon */
828   Application	application;		/* Application it belongs too */
829   DisplayObj	display;		/* Display it is displayed on */
830   Int		border;			/* Border width */
831   Any		background;		/* Frames background */
832   ColourMap	colour_map;		/* Attached colourmap */
833   Area		area;			/* Area of the frame */
834   Name		geometry;		/* X-Window geometry spec */
835   Chain		members;		/* Windows displayed */
836   Name		kind;			/* Kind of frame */
837   FrameObj	transient_for;		/* Sub frame of who? */
838   Chain		transients;		/* Sub frames */
839   Name		modal;			/* Modal operation */
840   Any		return_value;		/* ->return saved value */
841   BoolObj	input_focus;		/* @on: focus for keyboard events */
842   BoolObj	sensitive;		/* @on: accept user input */
843   Name		status;			/* {unmapped,iconic,open} */
844   BoolObj	can_delete;		/* User can delete the frame */
845   BoolObj	can_resize;		/* User can resize the frame */
846   BoolObj	confirm_done;		/* User must confirm delete */
847   BoolObj	fitting;		/* We are running ->fit */
848   Sheet		wm_protocols;		/* WM protocols understood */
849   BoolObj	wm_protocols_attached;	/* Have the protocols been attached */
850 					/* start private data */
851   WsRef		ws_ref;			/* Window-System reference */
852 End;
853 
854 
855 NewClass(eventobj)
856   Any		window;			/* Original window */
857   Any		receiver;		/* Receiver of the event */
858   Any		id;			/* Event identifier */
859   Int		buttons;		/* Bit mask of button positions */
860   Int		x;			/* X coordinate relative to window */
861   Int		y;			/* Y coordinate relative to window */
862   Point		position;		/* Computed Position */
863   unsigned long time;			/* Time of event in milliseconds */
864 End;
865 
866 
867 NewClass(event_nodeobj)
868   Name		value;			/* value of the event_node */
869   EventNodeObj	parent;			/* Super event_node */
870   Chain		sons;			/* Sub event_nodes */
871 End;
872 
873 
874 NewClass(event_treeobj)
875   EventNodeObj	root;			/* Root of the event_tree */
876   HashTable	table;			/* Value -> EventNodeObj */
877 End;
878 
879 
880 NewClass(windowobj)
881   ABSTRACT_WINDOW
882 End;
883 
884 NewClass(window_decorator)
885   ABSTRACT_WINDOW
886   PceWindow	window;			/* Client (decorated) window */
887   ScrollBar	horizontal_scrollbar;	/* Horizontal scrollbar */
888   ScrollBar	vertical_scrollbar;	/* Vertical scrollbar */
889   TextObj	label_text;		/* Text object to display label */
890 End;
891 
892 NewClass(picture)
893   ABSTRACT_WINDOW
894 End;
895 
896 NewClass(tile_adjuster)
897   ABSTRACT_WINDOW
898   TileObj	client;			/* Tile I adjust */
899   Name		orientation;		/* Direction of resize */
900   Int		down_offset;		/* Offset when processing */
901 End;
902 
903 NewClass(dialog)
904   ABSTRACT_WINDOW
905   Size		gap;			/* X-Y gap between items */
906   Size		border;			/* border around objects */
907   Name		size_given;		/* Size given by user: no recompute */
908 End;
909 
910 NewClass(view)
911   ABSTRACT_WINDOW
912   Editor	editor;			/* Editor implementing view */
913 End;
914 
915 NewClass(browser)
916   ABSTRACT_WINDOW
917   ListBrowser	list_browser;		/* ListBrowser implementing browser */
918 End;
919 
920 NewClass(timer)
921   Real		interval;		/* interval as a real value */
922   Code		message;		/* message when timer fires */
923   Name		status;			/* {idle,interval,once} */
924   BoolObj		service;		/* Operating in service mode? */
925   WsRef		ws_ref;			/* Window System Reference */
926 End;
927 
928 NewClass(monitor)
929   Any		name;			/* Name of the physical monitor */
930   Area		area;			/* Area on the display */
931   Area		work_area;		/* Application area */
932   BoolObj	primary;		/* Monitor is primary */
933 End;
934 
935 		 /*******************************
936 		 *	      EVENTS		*
937 		 *******************************/
938 
939 #define BUTTON_mask		(0x0ff)
940 #define BUTTON_control		(0x001)
941 #define BUTTON_shift		(0x002)
942 #define BUTTON_meta		(0x004)
943 #define BUTTON_ms_left		(0x008)
944 #define BUTTON_ms_middle	(0x010)
945 #define BUTTON_ms_right		(0x020)
946 #define BUTTON_ms_button4	(0x040)
947 #define BUTTON_ms_button5	(0x080)
948 					/* buttons bit mask */
949 #define CLICK_TYPE_mask		(0x700)
950 #define CLICK_TYPE_single	(0x100)
951 #define CLICK_TYPE_double	(0x200)
952 #define CLICK_TYPE_triple	(0x400)
953 
954 		/********************************
955 		*      X-WINDOW REFERENCES	*
956 		********************************/
957 
958 struct xref
959 { Any		object;			/* Object (Cursor, Font, ...) */
960   DisplayObj    display;		/* Display for which to get ref */
961   void *	xref;			/* X-window reference */
962   Xref		next;			/* Next entry of table */
963 };
964 
965 
966 		/********************************
967 		*            COLOURS		*
968 		********************************/
969 
970 #define BRIGHT	toInt(65535)		/* full on */
971 #define NoPixel (1L << 30)		/* no pixel value */
972 
973 		/********************************
974 		*            CHANGES		*
975 		********************************/
976 
977 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
978 This macro is to be called to change a graphical object.  It will pass
979 the appropriate  changes to its  device, so the  device can figure out
980 the optimal redisplay behaviour.
981 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
982 
983 
984 #define CHANGING_GRAPHICAL(gr, code) \
985   { Int _x, _y, _w, _h;					\
986     Device _device;					\
987 							\
988     _x = (gr)->area->x; _y = (gr)->area->y;		\
989     _w = (gr)->area->w; _h = (gr)->area->h;		\
990     _device = (gr)->device;				\
991 							\
992     code;						\
993 							\
994     if ( (_x != (gr)->area->x || _y != (gr)->area->y ||	\
995           _w != (gr)->area->w || _h != (gr)->area->h)&& \
996 	 _device == (gr)->device)			\
997       changedAreaGraphical((gr), _x, _y, _w, _h);	\
998   }
999 
1000 		/********************************
1001 		*            DRAWING		*
1002 		********************************/
1003 
1004 #define DRAW_3D_DOWN	0x1		/* r_3d_rectangular_polygon() flags */
1005 #define DRAW_3D_CLOSED	0x2
1006 #define DRAW_3D_FILLED	0x4
1007 
1008 typedef struct
1009 { int x, y;
1010 } ipoint, *IPoint;
1011 
1012 
1013 typedef struct
1014 { int x, y, w, h;
1015 } iarea, *IArea;
1016 
1017 
1018 typedef struct
1019 { int x1, y1, x2, y2;
1020 } isegment, *ISegment;
1021 
1022 
1023 struct update_area
1024 { iarea		area;			/* Concerned area */
1025   int		clear;			/* needs to be cleared */
1026   int		deleted;		/* area is deleted */
1027   int		size;			/* width * height */
1028   UpdateArea    next;			/* next in chain */
1029 };
1030 
1031 struct colour_context
1032 { Any		foreground;		/* saved foreground */
1033   Any		background;		/* saved background */
1034   int		lock;			/* lock nesting count */
1035 };
1036 
1037 typedef struct
1038 { Int	x;
1039   Int	y;
1040   Int	w;
1041   Int	h;
1042 } device_draw_context, *DeviceDrawContext;
1043 
1044 typedef struct
1045 { int   x;				/* fill-offset-x */
1046   int   y;				/* fill-offset-y */
1047 } fill_state;
1048 
1049 
1050 		/********************************
1051 		*           OVERLAP		*
1052 		********************************/
1053 
1054 #define OverlapArea(ax, ay, aw, ah, bx, by, bw, bh) \
1055 	    (!((by > ay+ah || by+bh < ay || bx > ax+aw || bx+bw < ax)))
1056 
1057 
1058 		/********************************
1059 		*           GLOBALS		*
1060 		********************************/
1061 
1062 #ifndef GLOBAL
1063 #define GLOBAL extern
1064 #endif
1065 
1066 GLOBAL Image BLACK_IMAGE;
1067 GLOBAL Image WHITE_IMAGE;
1068 GLOBAL Image GREY12_IMAGE;
1069 GLOBAL Image GREY25_IMAGE;
1070 GLOBAL Image GREY50_IMAGE;
1071 GLOBAL Image GREY75_IMAGE;
1072 
1073 GLOBAL Colour BLACK_COLOUR;
1074 GLOBAL Colour WHITE_COLOUR;
1075 
1076 GLOBAL Image CYCLE_IMAGE;		/* image of a cycle */
1077 GLOBAL Image MARK_IMAGE;		/* images for toggle and marked */
1078 GLOBAL Image NOMARK_IMAGE;
1079 GLOBAL Image MS_MARK_IMAGE;		/* MS images for toggle and marked */
1080 GLOBAL Image MS_NOMARK_IMAGE;
1081 GLOBAL Image PULLRIGHT_IMAGE;		/* Popup menu pullright marker */
1082 GLOBAL Image MARK_HANDLE_IMAGE;		/* connect_gesture */
1083 GLOBAL Image NULL_IMAGE;		/* empty image */
1084 GLOBAL Image INT_ITEM_IMAGE;
1085 GLOBAL Image SCROLL_UP_IMAGE;
1086 GLOBAL Image SCROLL_DOWN_IMAGE;
1087 GLOBAL Image SCROLL_LEFT_IMAGE;
1088 GLOBAL Image SCROLL_RIGHT_IMAGE;
1089 GLOBAL Image EXCLAMATION_IMAGE;
1090 
1091 GLOBAL Modifier MODIFIER_shift;		/* Demands `shift-is-down' */
1092 GLOBAL Modifier MODIFIER_control;	/* Demands `control-is-down' */
1093 GLOBAL Modifier MODIFIER_allup;		/* Demands all modifiers up */
1094 
1095 GLOBAL PopupGesture GESTURE_popup;	/* Displays a popup menu */
1096 GLOBAL ClickGesture GESTURE_button;	/* Gesture for handling buttons */
1097 GLOBAL Recogniser   GESTURE_wheelMouse;	/* Wheelmouse translation */
1098 
1099 GLOBAL Chain ChangedWindows;		/* Windows that have changed */
1100 
1101 GLOBAL  int XrefsResolved;		/* succesful getXrefObject()'s */
1102 GLOBAL	HashTable ColourTable;		/* ColourName --> Colour */
1103 GLOBAL  HashTable CursorTable;		/* CursorName --> Cursor */
1104 GLOBAL	HashTable FontTable;		/* FontName --> Font */
1105 GLOBAL	HashTable ImageTable;		/* ImageName --> Image */
1106 GLOBAL  HashTable WindowTable;		/* X-Window --> PceWindow|FrameObj */
1107 GLOBAL  Class ClassImage;		/* @image_class */
1108 
1109 GLOBAL  EventTreeObj  EventTree;	/* @event_tree */
1110 GLOBAL  Chain grabbedWindows;		/* @grabbed_windows */
1111 
1112 		 /*******************************
1113 		 *     MENU LAYER CONSTANTS	*
1114 		 *******************************/
1115 
1116 #define TEXTFIELD_EDITABLE	0x01	/* if editable field */
1117 #define TEXTFIELD_COMBO		0x02	/* if combo-box displayed */
1118 #define TEXTFIELD_COMBO_DOWN	0x04	/* after combo-box has been clicked */
1119 #define TEXTFIELD_STEPPER	0x08	/* up/down stepper */
1120 #define TEXTFIELD_INCREMENT	0x10	/* stepper in `increment' mode */
1121 #define TEXTFIELD_DECREMENT	0x20	/* stepper in `increment' mode */
1122 
1123 #define LABEL_INACTIVE		0x1	/* str_label() flags */
1124 
1125 #define CHECKBOX_SELECTED	0x1	/* item is selected */
1126 #define CHECKBOX_ACTIVE		0x2	/* item is active */
1127 #define CHECKBOX_MULTIPLE	0x4	/* more than one may be selected */
1128 
1129 #define MBX_INFORM		0x1	/* infomational message */
1130 #define MBX_CONFIRM		0x2	/* confirm action */
1131 #define MBX_ERROR		0x4	/* error message */
1132 
1133 #define MBX_NOTHANDLED		0x0	/* not handled by virtual controller */
1134 #define MBX_OK			0x1	/* user confirmed */
1135 #define MBX_CANCEL		0x2	/* user canceled */
1136 
1137 
1138 		 /*******************************
1139 		 *	    IMAGE TYPES		*
1140 		 *******************************/
1141 
1142 COMMON(int) image_type_from_data(char *data, int size);
1143 
1144 #define IMG_IS_UNKNOWN	0
1145 #define IMG_IS_JPEG	1
1146 #define IMG_IS_XBM	2		/* Old monochrome X11 icons */
1147 #define IMG_IS_SUNICON	3		/* Very old: SunView icons */
1148 #define IMG_IS_XPM	4
1149 #define IMG_IS_GIF	5
1150 #define IMG_IS_PNM	6		/* PBMPLUS image formats */
1151 #define IMG_IS_PNG	7
1152 #define IMG_IS_BMP	8		/* MS-Windows .BMP */
1153 #define IMG_IS_ICO	9		/* MS-Windows .ICO */
1154 
1155 
1156 		/********************************
1157 		*          PROTOTYPES		*
1158 		********************************/
1159 
1160 #include	"wst.h"
1161 #include	"../gra/proto.h"
1162 #include	"../win/proto.h"
1163 #include	"../evt/proto.h"
1164 
1165 #endif /*_PCE_GRA_INCLUDED*/
1166 
1167 
1168