4 * Private window definitions
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Glass.
13 * Glass is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Glass is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Glass. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 /*----- Common macros -----------------------------------------------------*/
42 * Macros describing parts of icons (as returned by window__pointerInfo)
46 * These have been redefined to be a bitfield (24/5/93):
47 * And then re-redefined to be a different bitfield (3/2/98):
49 * bit 24 set == drag moves top of icon
50 * bit 25 set == drag moves bottom of icon
51 * bit 26 set == drag moves left of icon
52 * bit 27 set == drag moves right of icon
54 * The values 3, b and c are not defined - They may be used for future
55 * expansion, but I doubt it somehow. d and e are used to describe
56 * guidelines - the magic number is ORred with the guide number.
59 #define window__TOP 0x01000000 /* The top edge drag box */
60 #define window__BOTTOM 0x02000000 /* The bottom edge drag box */
61 #define window__LEFT 0x04000000 /* The left edge drag box */
62 #define window__RIGHT 0x08000000 /* The right edge drag box */
63 #define window__MAIN 0x0f000000 /* The main part of the icon */
64 #define window__TOPLEFT 0x05000000 /* The top left corner drag box */
65 #define window__TOPRIGHT 0x09000000 /* The top right corner drag box */
66 #define window__BOTTOMLEFT 0x06000000 /* The bottom left corner drag box */
67 #define window__BOTTOMRIGHT 0x0a000000 /* The bottom right corner drag box */
69 #define window__HORGUIDE 0x0d000000 /* A horizontal guide */
70 #define window__VERGUIDE 0x0e000000 /* A vertical guide */
71 #define window__GRABICON 0x07000000 /* This is a drag of a grabbed icon */
72 #define window__SELECT 0x00000000 /* This is a drag to select icons */
74 #define window__ZONEMASK 0x0F000000 /* Mask for drag zones */
75 #define window__ICONMASK 0x00FFFFFF /* Mask for icon numbers */
81 #define window__SELBOXCOL (gPrefs_current()->sBColour)
82 #define window__HANDCOL (gPrefs_current()->sHColour)
83 #define window__MSELBOXCOL (gPrefs_current()->sSColour)
84 #define window__DRAGCOL 0x0b
85 #define window__GUIDECOL (gPrefs_current()->gGdeCol)
86 #define window__GDESELCOL (gPrefs_current()->gGdeSelCol)
92 #define window__HANDLEWIDTH gPrefs_current()->sHandSize
93 #define window__SNAPDIST 16
94 #define window__DRAGTIME 0
96 #define max2(a,b) ((a)>(b) ? (a) : (b))
97 #define min2(a,b) ((a)<(b) ? (a) : (b))
99 /*----- Low level graphics handling ---------------------------------------*/
102 * void window__colourChange(int col1,int col2)
105 * Sets up the current foreground colour so that when plotted over colour
106 * col1 it looks like col2 and vice-versa. The effects of plotting over
107 * other colours is defined to be psychedelically interesting, but not
110 * Basically, all it does is suss out what the colours really mean and XOR
114 * int col1,int col2 == the Wimp colour numbers to swap between
117 void window__colourChange(int col1,int col2);
120 * void window__setXORColour(glass_windPointer *w,int col)
123 * Sets up the current foreground colour so that it appears to be WIMP
124 * colour col on the specified window background. Lots of tedious
125 * ColourTransing to do on this, with no real reward, but at least it will
126 * look vaguely right in 256 colour modes.
129 * glass_windPointer *w == the window in which to set the colour
130 * int col == the colour to set
133 void window__setXORColour(glass_windPointer *w,int col);
136 * void window__makeDashPattern(int ptn)
139 * Sets the OS dash pattern to the given pattern (only the lowest byte
143 * int ptn == the LSB of this word contains the dash pattern as a bit
147 void window__makeDashPattern(int ptn);
150 * void window__setDash(void)
153 * Sets the dashed pattern so that it looks as if a 'rotating' box is being
154 * dragged, like the WIMP's, only better... The box is set up so that a
155 * SINGLE exclusive-or plot will move the dash round.
158 void window__setDash(void);
161 * void window__rotate(int by)
164 * Rotates the current rotating-dash pattern by a given amount. This is
165 * used to rotate the dash box while the box is moving.
168 * int by == the number of steps to rotate the dash pattern.
171 void window__rotate(int by);
174 * void window__rectangle(int x,int y,int w,int h)
177 * Draws a rectangle, using the current dotted line pattern
180 * int x == the left side of the rectangle
181 * int y == the right side of the rectangle
182 * int w == the width of the rectangle (may be <0)
183 * int h == the height of the rectangle (may be <0)
186 void window__rectangle(int x,int y,int w,int h);
188 /*----- Redrawing windows -------------------------------------------------*/
191 * void window__drawSelectBox(glass_windPointer *w,
197 * Draws the selection box around an icon
200 * glass_windPointer *w == the window
201 * int icon == the icon
202 * BOOL makesi == whether we're going between a selected and main selected
204 * wimp_redrawstr *r == the redraw structure
207 void window__drawSelectBox(glass_windPointer *w,
213 * void window__redrawDragBox(glass_windPointer *w,
219 * Redraws the screen during a drag operation, either to update the window
220 * during the drag, or to redraw the window should something silly happen
224 * glass_windPointer *w == pointer to the window owning drag
225 * wimp_redrawstr *r == pointer to current redraw
226 * int x,int y == coordinates to draw drag relative to...
229 void window__redrawDragBox(glass_windPointer *w,wimp_redrawstr *r,
233 * void window__redraw(glass_windPointer *w,wimp_redrawstr *r,BOOL *more)
236 * Redraws a window following a call to Wimp_UpdateWindow or
240 * glass_windPointer *w == the window to draw
241 * wimp_redrawstr *r == stuff about the redraw
242 * BOOL *more == whether there is more to do
245 void window__redraw(glass_windPointer *w,wimp_redrawstr *r,BOOL *more);
248 * void window__redrawGuide(glass_windPointer *w,int guide)
251 * Forces a redraw of the specified guideline.
254 * glass_windPointer *w == the window containing the guideline
255 * int guide == the number of the guideline.
258 void window__redrawGuide(glass_windPointer *w,int guide);
260 /*----- Grabbing icons ----------------------------------------------------*/
263 * void window__grabIcon(wimp_mousestr *m,void *handle)
266 * Grabs an icon from another application.
269 * wimp_mousestr *m == pointer to info about which icon to get
270 * void *handle == pointer to destination window
273 void window__grabIcon(wimp_mousestr *m,void *handle);
276 * void window__doGrabIcon(wimp_box *b,glass_windPointer *w)
279 * Actually does a window grab job after all the pallaver.
282 * wimp_box *b == the box in which the icon is contained
283 * glass_windPointer *w == the window into which the icon is to be created
286 * TRUE if the evtn has been successfully handled.
289 void window__doGrabIcon(wimp_box *b,glass_windPointer *w);
292 * wimp_icon *window__qGrabbedIcon(void)
295 * Returns a pointer to the icon being grabbed
298 wimp_icon *window__qGrabbedIcon(void);
300 /*----- Dragging icons around ---------------------------------------------*/
303 * void window__align(glass_windPointer *w,int *x,int *y)
306 * Aligns the given point to the *nearest* grid point. The point is
307 * fiddled in-situ. It does the Right Thing with negative points.
310 * glass_windPointer *w == the window we're using
311 * int *x == pass-by-reference x coord of point
312 * int *y == pass-by-reference y coord of point
315 void window__align(glass_windPointer *w,int *x,int *y);
318 * void window__startDrag(int type,
320 * glass_windPointer *w,
324 * Starts a drag operation in the specified window
327 * int type == what sort of drag this is
328 * wimp_box *box == the bounding box of the object we're dragging
329 * glass_windPointer *w == the window in which the drag is taking place
330 * int x,int y == the mouse position the drag will start from
333 void window__startDrag(int type,
335 glass_windPointer *w,
339 * glass_windPointer *window__dragWind(void)
342 * Returns the current dragging window
345 glass_windPointer *window__dragWind(void);
348 * void window__setDragWind(glass_windPointer *w)
351 * Claims the current drag operation for the given window
354 void window__setDragWind(glass_windPointer *w);
357 * int window__qDragType(void)
360 * Returns the current drag type
363 int window__qDragType(void);
366 * wimp_box window__qDragBox(void)
369 * Returns the bounding box of the things being dragged
372 wimp_box window__qDragBox(void);
375 * void window__dragCoords(int *x,int *y)
378 * Returns the current drag position
381 void window__dragCoords(int *x,int *y);
384 * void window__dragStart(int *x,int *y)
387 * Returns the initial drag position
390 void window__dragStart(int *x,int *y);
392 /*----- Mouse pointer shape and position ----------------------------------*/
395 * int window__pointerInfo(glass_windPointer *w,int from,BOOL zones)
398 * Returns the icon number of the icon which the pointer is over. Guides
399 * are also checked for.
402 * glass_windPointer *w == the window to use info from
403 * int from == number to search down from (or -1 for the top). This is
404 * useful for selection, multiple clicks moving down overlapping icons.
405 * BOOL zones == search for drag zones. If this is set, the routine
406 * searches for selected icons only. If it is clear, zones are not
410 * An icon number, or -1 for the background.
413 int window__pointerInfo(glass_windPointer *w,int from,BOOL zones);
416 * BOOL window__pointerOverIcon(glass_windPointer *w,int icon)
419 * Informs the caller if the pointer is over the bounding box of the icon
423 * glass_windPointer *w == window containing icon
424 * int icon == icon to check for
427 BOOL window__pointerOverIcon(glass_windPointer *w,int icon);
430 * void window__setPtrShape(int icon)
433 * Sets the pointer shape accoding to the 'drag zone' part of the given
437 * int icon == the icon number
440 void window__setPtrShape(int icon);
442 /*----- Selection handling ------------------------------------------------*/
445 * void window__select(glass_windPointer *w,int icon,BOOL sel)
448 * Selects or deselects the given icon.
451 * glass_windPointer *w == the window we're talking about
452 * int icon == the icon to select (or not)
453 * BOOL sel == TRUE to select, FALSE to deslect
456 void window__select(glass_windPointer *w,int icon,BOOL sel);
459 * void window__setSelectedIcon(int i)
462 * Makes the specified icon in the current selection owner highlighted.
465 * int i == the icon number to highlight
468 void window__setSelectedIcon(int i);
471 * void window__setSelectedIconDeselecting(int i)
474 * Sets up the currently selected icon, deselecting the old one.
477 * int i == the new icon to select
480 void window__setSelectedIconDeselecting(int i);
483 * int window__lowestSelected(glass_windPointer *w)
486 * Returns the selected icon with the lowest number in the specified window.
489 int window__lowestSelected(glass_windPointer *w);
492 * void window__gainSelection(glass_windPointer *w)
495 * Gives the specified window the input focus, tool and info bars, and the
496 * selection. If 0 is specified, then the tool bars are taken down, and no
500 * glass_windPointer *w == the new selection owner
503 void window__gainSelection(glass_windPointer *w);
506 * int window__selectedIcon(void)
509 * Returns the currently selected icon
512 int window__selectedIcon(void);
515 * void window__renumberSelectedIcon(int nsel)
518 * To be called when the selected icon is renumbered.
521 void window__renumberSelectedIcon(int nsel);
523 /*----- Icon manipulation -------------------------------------------------*/
526 * void window__bound(wimp_icon *i,wimp_box *box,BOOL force)
529 * Works out the bounding box (including 3D border) of the given pseudoicon.
532 * wimp_icon *i == pointer to an icon definition
533 * wimp_box *box == where to put the result
534 * BOOL force == force reading of the border, even if disabled in prefs
537 void window__bound(wimp_icon *i,wimp_box *box,BOOL force);
540 * void window__removeTrailingDeleted(glass_windPointer *w)
543 * Removes trailing deleted icons from a window (i.e. ones that can be
544 * safely deleted properly without messing up icon numbers).
547 * glass_windPointer *w == the window to blitz
550 void window__removeTrailingDeleted(glass_windPointer *w);
553 * int window__createIcon(glass_windPointer *w)
556 * Creates a slot for an icon in the window specified, according to current
557 * preferences. The contents of the icon array are unspecified (and
558 * probably not too useful).
561 * glass_windPointer *w == the window to create the icon in
564 * Icon number that can be used, or -1 if the operation failed.
567 int window__createIcon(glass_windPointer *w);
570 * void window__renumber(glass_windPointer *w,BOOL renum)
573 * Sets the renumber flag of the given window to the given state.
574 * Everything is set up properly according to the new state.
577 * glass_windPointer *w == the window to renumber
578 * BOOL renum == the new state of the flag
581 void window__renumber(glass_windPointer *w,BOOL renum);
584 * void window__copyIcons(glass_windPointer *w)
587 * Copies the selected icons into the given window. If the icons are
588 * already in the given window, they are duplicated and offset by a small
589 * quantity. If the icons are in a different window, then they are
590 * centred over the current visible area.
593 * glass_windPointer *w == the window to put the icons
596 void window__copyIcons(glass_windPointer *w);
599 * void window__nudgeIcons(glass_windPointer *w,wimp_box *nudge)
602 * Nudges the selected icons in the specified window, by adding the box
603 * given to each icon's bounding box. The nudge box is multiplied either by
604 * the current grid size (if grid lock is enabled) or by the pixel size (if
605 * it isn't) before addition. A nudge is considered to be a single
606 * alteration for the purposes of autosave-counting. If no icons are moved
607 * then the selected guidelines are moved instead.
610 * glass_windPointer *w == the window containing the icons to nudge
611 * wimp_box *nudge == the box to add to the coordinates of the icons
614 void window__nudgeIcons(glass_windPointer *w,wimp_box *nudge);
616 /*----- Window manipulation -----------------------------------------------*/
619 * wimp_w window__recreate(glass_windPointer *w)
622 * Recreates a window, getting all the fiddly bits right.
625 * glass_windPointer *w == the window
628 * The window handle, or 0 for failure
631 wimp_w window__recreate(glass_windPointer *w);
634 * void window__nudgeScroll(glass_windPointer *w,int x,int y)
637 * Scrolls the window a bit, by adding the x and y values given to the
638 * scroll offsets of the window. The values are multiplied up to give a
639 * sensible sized scroll.
642 * glass_windPointer *w == the window to scroll
643 * int x == the x scroll offset to add
644 * int y == the y scroll offset to add
647 void window__nudgeScroll(glass_windPointer *w,int x,int y);
649 /*----- The main menu -----------------------------------------------------*/
652 * glass_windPointer *window__menuOwner(void)
655 * Returns which window currently owns the menu.
658 * A pointer to the window's anchor block.
661 glass_windPointer *window__menuOwner(void);
664 * void window__updateMenu(glass_windPointer *w)
667 * Updates the menu attached to the main window.
670 * glass_windPointer *w == pointer to owning menu
673 void window__updateMenu(glass_windPointer *w);
676 * void window__simMenu(glass_windPointer *w,int hit1,int hit2)
679 * Simulates a menu hit on the specified item. Gives a beep if the item
680 * is unavailable. Otherwise, the hit is sent to the current selection
681 * owner. [fixed to allow which window is used rather than only the
682 * selection owner, 1 November 1993]
685 * glass_windPointer *w == the window in which to simulate the event
686 * int hit1 == first hit in the sequence
687 * int hit2 == second hit in the sequence
690 void window__simMenu(glass_windPointer *w,int hit1,int hit2);
693 * void window__showMenu(int x,int y,glass_windPointer *w)
696 * Displays the Template Window Menu
699 * int x,int y == the (window) position to display the menu
700 * glass_windPointer *w == the window to display the menu for
703 void window__showMenu(int x,int y,glass_windPointer *w);
706 * void window__menuInit(void)
709 * Initialises the create icon menu
712 void window__menuInit(void);
714 /*----- Handling the toolbars ---------------------------------------------*/
717 * void window__setToolBarPositions(wimp_openstr *o)
720 * Displays the tool and info bars according to current settings etc.
723 * wimp_openstr *o == the position of the selection owner window, or 0.
724 * This is updated to put the window somewhere nice without flicker.
727 void window__setToolBarPositions(wimp_openstr *o);
730 * void window__updateInfoBar(void)
733 * Updates the settings on the info bar. If a setting hasn't changed, then
734 * it isn't updated (reducing flicker).
737 * BOOL force == whether to force an update of everything.
740 void window__updateInfoBar(BOOL force);
743 * void window__toggleRenumber(glass_windPointer *w)
746 * Updates the info bar after entering or leaving renumber-mode. w is
747 * the currently selected window.
750 void window__toggleRenumber(glass_windPointer *w);
753 * void window__toggleTest(glass_windPointer *w)
756 * Updates the info bar after entering or leaving test-mode. w is the
757 * currently selected window.
761 void window__toggleTest(glass_windPointer *w);
765 * void window__updateInfoName(char *newname)
768 * Updates the name in the info bar
771 void window__updateInfoName(char *newname);
774 * void window__nextRenumber(glass_windPointer *w)
777 * Updates the next renumber icon number display.
780 void window__nextRenumber(glass_windPointer *w);
783 * void window__moveToolbars(glass_windPointer *w)
786 * Moves the toolbars and attaches them to a new window
789 * glass_windPointer *w == the window to attach the bars to
792 void window__moveToolbars(glass_windPointer *w);
795 * void window__tbarInit(void)
798 * Initialises the toolbar system
801 void window__tbarInit(void);
803 /*----- The icon palette --------------------------------------------------*/
806 * void window__showPalette(void)
809 * Displays the palette window, as set up in the Defaults template file.
812 void window__showPalette(void);
814 /*----- The main event handlers -------------------------------------------*/
817 * void window__winIdles(void *handle)
820 * Changes the pointer shape to something appropriate for what its over.
823 * void *handle == pointer to window containing pointer
826 void window__winIdles(void *handle);
829 * void window__testEvents(wimp_eventstr *e,void *handle)
832 * Handles all events for windows running in Test mode. Events handled
835 * Redraw Redraws the window using Interface/hatch pattern as requested.
836 * Open Moves the window around.
837 * Close Closes the window(!)
839 * Enter Turn off STEEL pointer changing
840 * Click Handled by WIMP or Interface, except for menu, which opens
842 * Key Handled by WIMP, WimpExtension, or ignored
845 * wimp_eventstr *e == the event
846 * void *handle == pointer to window info
850 void window__testEvents(wimp_eventstr *e,void *handle);
854 * void window__events(wimp_eventstr *e,void *handle)
857 * Handles all events for template windows (this is the first chance I've
858 * had to get my fingers *REALLY* mucky on this whole project!)
861 * wimp_eventstr *e == the event that I am meant to be inerested in
862 * void *handle == a pointer to the structural information for this window
865 void window__events(wimp_eventstr *e,void *handle);
867 /*----- THE END -----------------------------------------------------------*/