/* * _window.h * * Private window definitions * * © 1994-1998 Straylight */ /*----- Licensing note ----------------------------------------------------* * * This file is part of Straylight's Glass. * * Glass is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Glass is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Glass. If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef ___window_h #define ___window_h #ifndef __gPrefs_h #include "gPrefs.h" #endif #ifndef __gStruct #include "gStruct.h" #endif /*----- Common macros -----------------------------------------------------*/ /* * Macros describing parts of icons (as returned by window__pointerInfo) */ /* * These have been redefined to be a bitfield (24/5/93): * And then re-redefined to be a different bitfield (3/2/98): * * bit 24 set == drag moves top of icon * bit 25 set == drag moves bottom of icon * bit 26 set == drag moves left of icon * bit 27 set == drag moves right of icon * * The values 3, b and c are not defined - They may be used for future * expansion, but I doubt it somehow. d and e are used to describe * guidelines - the magic number is ORred with the guide number. */ #define window__TOP 0x01000000 /* The top edge drag box */ #define window__BOTTOM 0x02000000 /* The bottom edge drag box */ #define window__LEFT 0x04000000 /* The left edge drag box */ #define window__RIGHT 0x08000000 /* The right edge drag box */ #define window__MAIN 0x0f000000 /* The main part of the icon */ #define window__TOPLEFT 0x05000000 /* The top left corner drag box */ #define window__TOPRIGHT 0x09000000 /* The top right corner drag box */ #define window__BOTTOMLEFT 0x06000000 /* The bottom left corner drag box */ #define window__BOTTOMRIGHT 0x0a000000 /* The bottom right corner drag box */ #define window__HORGUIDE 0x0d000000 /* A horizontal guide */ #define window__VERGUIDE 0x0e000000 /* A vertical guide */ #define window__GRABICON 0x07000000 /* This is a drag of a grabbed icon */ #define window__SELECT 0x00000000 /* This is a drag to select icons */ #define window__ZONEMASK 0x0F000000 /* Mask for drag zones */ #define window__ICONMASK 0x00FFFFFF /* Mask for icon numbers */ /* * Colours for things */ #define window__SELBOXCOL (gPrefs_current()->sBColour) #define window__HANDCOL (gPrefs_current()->sHColour) #define window__MSELBOXCOL (gPrefs_current()->sSColour) #define window__DRAGCOL 0x0b #define window__GUIDECOL (gPrefs_current()->gGdeCol) #define window__GDESELCOL (gPrefs_current()->gGdeSelCol) /* * Other things */ #define window__HANDLEWIDTH gPrefs_current()->sHandSize #define window__SNAPDIST 16 #define window__DRAGTIME 0 #define max2(a,b) ((a)>(b) ? (a) : (b)) #define min2(a,b) ((a)<(b) ? (a) : (b)) /*----- Low level graphics handling ---------------------------------------*/ /* * void window__colourChange(int col1,int col2) * * Use * Sets up the current foreground colour so that when plotted over colour * col1 it looks like col2 and vice-versa. The effects of plotting over * other colours is defined to be psychedelically interesting, but not * pretty. * * Basically, all it does is suss out what the colours really mean and XOR * them together. * * Parameters * int col1,int col2 == the Wimp colour numbers to swap between */ void window__colourChange(int col1,int col2); /* * void window__setXORColour(glass_windPointer *w,int col) * * Use * Sets up the current foreground colour so that it appears to be WIMP * colour col on the specified window background. Lots of tedious * ColourTransing to do on this, with no real reward, but at least it will * look vaguely right in 256 colour modes. * * Parameters * glass_windPointer *w == the window in which to set the colour * int col == the colour to set */ void window__setXORColour(glass_windPointer *w,int col); /* * void window__makeDashPattern(int ptn) * * Use * Sets the OS dash pattern to the given pattern (only the lowest byte * is considered). * * Parameters * int ptn == the LSB of this word contains the dash pattern as a bit * pattern */ void window__makeDashPattern(int ptn); /* * void window__setDash(void) * * Use * Sets the dashed pattern so that it looks as if a 'rotating' box is being * dragged, like the WIMP's, only better... The box is set up so that a * SINGLE exclusive-or plot will move the dash round. */ void window__setDash(void); /* * void window__rotate(int by) * * Use * Rotates the current rotating-dash pattern by a given amount. This is * used to rotate the dash box while the box is moving. * * Parameters * int by == the number of steps to rotate the dash pattern. */ void window__rotate(int by); /* * void window__rectangle(int x,int y,int w,int h) * * Use * Draws a rectangle, using the current dotted line pattern * * Parameters * int x == the left side of the rectangle * int y == the right side of the rectangle * int w == the width of the rectangle (may be <0) * int h == the height of the rectangle (may be <0) */ void window__rectangle(int x,int y,int w,int h); /*----- Redrawing windows -------------------------------------------------*/ /* * void window__drawSelectBox(glass_windPointer *w, * int icon, * BOOL makesi, * wimp_redrawstr *r) * * Use * Draws the selection box around an icon * * Parameters * glass_windPointer *w == the window * int icon == the icon * BOOL makesi == whether we're going between a selected and main selected * icon. * wimp_redrawstr *r == the redraw structure */ void window__drawSelectBox(glass_windPointer *w, int icon, BOOL makesi, wimp_redrawstr *r); /* * void window__redrawDragBox(glass_windPointer *w, * wimp_redrawstr *r, * int x, * int y) * * Use * Redraws the screen during a drag operation, either to update the window * during the drag, or to redraw the window should something silly happen * to it. * * Parameters * glass_windPointer *w == pointer to the window owning drag * wimp_redrawstr *r == pointer to current redraw * int x,int y == coordinates to draw drag relative to... */ void window__redrawDragBox(glass_windPointer *w,wimp_redrawstr *r, int x,int y); /* * void window__redraw(glass_windPointer *w,wimp_redrawstr *r,BOOL *more) * * Use * Redraws a window following a call to Wimp_UpdateWindow or * Wimp_RedrawWindow. * * Parameters * glass_windPointer *w == the window to draw * wimp_redrawstr *r == stuff about the redraw * BOOL *more == whether there is more to do */ void window__redraw(glass_windPointer *w,wimp_redrawstr *r,BOOL *more); /* * void window__redrawGuide(glass_windPointer *w,int guide) * * Use * Forces a redraw of the specified guideline. * * Parameters * glass_windPointer *w == the window containing the guideline * int guide == the number of the guideline. */ void window__redrawGuide(glass_windPointer *w,int guide); /*----- Grabbing icons ----------------------------------------------------*/ /* * void window__grabIcon(wimp_mousestr *m,void *handle) * * Use * Grabs an icon from another application. * * Parameters * wimp_mousestr *m == pointer to info about which icon to get * void *handle == pointer to destination window */ void window__grabIcon(wimp_mousestr *m,void *handle); /* * void window__doGrabIcon(wimp_box *b,glass_windPointer *w) * * Use * Actually does a window grab job after all the pallaver. * * Parameters * wimp_box *b == the box in which the icon is contained * glass_windPointer *w == the window into which the icon is to be created * * Returns * TRUE if the evtn has been successfully handled. */ void window__doGrabIcon(wimp_box *b,glass_windPointer *w); /* * wimp_icon *window__qGrabbedIcon(void) * * Use * Returns a pointer to the icon being grabbed */ wimp_icon *window__qGrabbedIcon(void); /*----- Dragging icons around ---------------------------------------------*/ /* * void window__align(glass_windPointer *w,int *x,int *y) * * Use * Aligns the given point to the *nearest* grid point. The point is * fiddled in-situ. It does the Right Thing with negative points. * * Parameters * glass_windPointer *w == the window we're using * int *x == pass-by-reference x coord of point * int *y == pass-by-reference y coord of point */ void window__align(glass_windPointer *w,int *x,int *y); /* * void window__startDrag(int type, * wimp_box *box, * glass_windPointer *w, * int x,int y) * * Use * Starts a drag operation in the specified window * * Parameters * int type == what sort of drag this is * wimp_box *box == the bounding box of the object we're dragging * glass_windPointer *w == the window in which the drag is taking place * int x,int y == the mouse position the drag will start from */ void window__startDrag(int type, wimp_box *box, glass_windPointer *w, int x,int y); /* * glass_windPointer *window__dragWind(void) * * Use * Returns the current dragging window */ glass_windPointer *window__dragWind(void); /* * void window__setDragWind(glass_windPointer *w) * * Use * Claims the current drag operation for the given window */ void window__setDragWind(glass_windPointer *w); /* * int window__qDragType(void) * * Use * Returns the current drag type */ int window__qDragType(void); /* * wimp_box window__qDragBox(void) * * Use * Returns the bounding box of the things being dragged */ wimp_box window__qDragBox(void); /* * void window__dragCoords(int *x,int *y) * * Use * Returns the current drag position */ void window__dragCoords(int *x,int *y); /* * void window__dragStart(int *x,int *y) * * Use * Returns the initial drag position */ void window__dragStart(int *x,int *y); /*----- Mouse pointer shape and position ----------------------------------*/ /* * int window__pointerInfo(glass_windPointer *w,int from,BOOL zones) * * Use * Returns the icon number of the icon which the pointer is over. Guides * are also checked for. * * Parameters * glass_windPointer *w == the window to use info from * int from == number to search down from (or -1 for the top). This is * useful for selection, multiple clicks moving down overlapping icons. * BOOL zones == search for drag zones. If this is set, the routine * searches for selected icons only. If it is clear, zones are not * checked. * * Returns * An icon number, or -1 for the background. */ int window__pointerInfo(glass_windPointer *w,int from,BOOL zones); /* * BOOL window__pointerOverIcon(glass_windPointer *w,int icon) * * Use * Informs the caller if the pointer is over the bounding box of the icon * specified. * * Parameters * glass_windPointer *w == window containing icon * int icon == icon to check for */ BOOL window__pointerOverIcon(glass_windPointer *w,int icon); /* * void window__setPtrShape(int icon) * * Use * Sets the pointer shape accoding to the 'drag zone' part of the given * icon number. * * Parameters * int icon == the icon number */ void window__setPtrShape(int icon); /*----- Selection handling ------------------------------------------------*/ /* * void window__select(glass_windPointer *w,int icon,BOOL sel) * * Use * Selects or deselects the given icon. * * Parameters * glass_windPointer *w == the window we're talking about * int icon == the icon to select (or not) * BOOL sel == TRUE to select, FALSE to deslect */ void window__select(glass_windPointer *w,int icon,BOOL sel); /* * void window__setSelectedIcon(int i) * * Use * Makes the specified icon in the current selection owner highlighted. * * Parameters * int i == the icon number to highlight */ void window__setSelectedIcon(int i); /* * void window__setSelectedIconDeselecting(int i) * * Use * Sets up the currently selected icon, deselecting the old one. * * Parameters * int i == the new icon to select */ void window__setSelectedIconDeselecting(int i); /* * int window__lowestSelected(glass_windPointer *w) * * Use * Returns the selected icon with the lowest number in the specified window. */ int window__lowestSelected(glass_windPointer *w); /* * void window__gainSelection(glass_windPointer *w) * * Use * Gives the specified window the input focus, tool and info bars, and the * selection. If 0 is specified, then the tool bars are taken down, and no * selection is set. * * Parameters * glass_windPointer *w == the new selection owner */ void window__gainSelection(glass_windPointer *w); /* * int window__selectedIcon(void) * * Use * Returns the currently selected icon */ int window__selectedIcon(void); /* * void window__renumberSelectedIcon(int nsel) * * Use * To be called when the selected icon is renumbered. */ void window__renumberSelectedIcon(int nsel); /*----- Icon manipulation -------------------------------------------------*/ /* * void window__bound(wimp_icon *i,wimp_box *box,BOOL force) * * Use * Works out the bounding box (including 3D border) of the given pseudoicon. * * Parameters * wimp_icon *i == pointer to an icon definition * wimp_box *box == where to put the result * BOOL force == force reading of the border, even if disabled in prefs */ void window__bound(wimp_icon *i,wimp_box *box,BOOL force); /* * void window__removeTrailingDeleted(glass_windPointer *w) * * Use * Removes trailing deleted icons from a window (i.e. ones that can be * safely deleted properly without messing up icon numbers). * * Parameters * glass_windPointer *w == the window to blitz */ void window__removeTrailingDeleted(glass_windPointer *w); /* * int window__createIcon(glass_windPointer *w) * * Use * Creates a slot for an icon in the window specified, according to current * preferences. The contents of the icon array are unspecified (and * probably not too useful). * * Parameters * glass_windPointer *w == the window to create the icon in * * Returns * Icon number that can be used, or -1 if the operation failed. */ int window__createIcon(glass_windPointer *w); /* * void window__renumber(glass_windPointer *w,BOOL renum) * * Use * Sets the renumber flag of the given window to the given state. * Everything is set up properly according to the new state. * * Parameters * glass_windPointer *w == the window to renumber * BOOL renum == the new state of the flag */ void window__renumber(glass_windPointer *w,BOOL renum); /* * void window__copyIcons(glass_windPointer *w) * * Use * Copies the selected icons into the given window. If the icons are * already in the given window, they are duplicated and offset by a small * quantity. If the icons are in a different window, then they are * centred over the current visible area. * * Parameters * glass_windPointer *w == the window to put the icons */ void window__copyIcons(glass_windPointer *w); /* * void window__nudgeIcons(glass_windPointer *w,wimp_box *nudge) * * Use * Nudges the selected icons in the specified window, by adding the box * given to each icon's bounding box. The nudge box is multiplied either by * the current grid size (if grid lock is enabled) or by the pixel size (if * it isn't) before addition. A nudge is considered to be a single * alteration for the purposes of autosave-counting. If no icons are moved * then the selected guidelines are moved instead. * * Parameters * glass_windPointer *w == the window containing the icons to nudge * wimp_box *nudge == the box to add to the coordinates of the icons */ void window__nudgeIcons(glass_windPointer *w,wimp_box *nudge); /*----- Window manipulation -----------------------------------------------*/ /* * wimp_w window__recreate(glass_windPointer *w) * * Use * Recreates a window, getting all the fiddly bits right. * * Parameters * glass_windPointer *w == the window * * Returns * The window handle, or 0 for failure */ wimp_w window__recreate(glass_windPointer *w); /* * void window__nudgeScroll(glass_windPointer *w,int x,int y) * * Use * Scrolls the window a bit, by adding the x and y values given to the * scroll offsets of the window. The values are multiplied up to give a * sensible sized scroll. * * Parameters * glass_windPointer *w == the window to scroll * int x == the x scroll offset to add * int y == the y scroll offset to add */ void window__nudgeScroll(glass_windPointer *w,int x,int y); /*----- The main menu -----------------------------------------------------*/ /* * glass_windPointer *window__menuOwner(void) * * Use * Returns which window currently owns the menu. * * Returns * A pointer to the window's anchor block. */ glass_windPointer *window__menuOwner(void); /* * void window__updateMenu(glass_windPointer *w) * * Use * Updates the menu attached to the main window. * * Parameters * glass_windPointer *w == pointer to owning menu */ void window__updateMenu(glass_windPointer *w); /* * void window__simMenu(glass_windPointer *w,int hit1,int hit2) * * Use * Simulates a menu hit on the specified item. Gives a beep if the item * is unavailable. Otherwise, the hit is sent to the current selection * owner. [fixed to allow which window is used rather than only the * selection owner, 1 November 1993] * * Use * glass_windPointer *w == the window in which to simulate the event * int hit1 == first hit in the sequence * int hit2 == second hit in the sequence */ void window__simMenu(glass_windPointer *w,int hit1,int hit2); /* * void window__showMenu(int x,int y,glass_windPointer *w) * * Use * Displays the Template Window Menu * * Parameters * int x,int y == the (window) position to display the menu * glass_windPointer *w == the window to display the menu for */ void window__showMenu(int x,int y,glass_windPointer *w); /* * void window__menuInit(void) * * Use * Initialises the create icon menu */ void window__menuInit(void); /*----- Handling the toolbars ---------------------------------------------*/ /* * void window__setToolBarPositions(wimp_openstr *o) * * Use * Displays the tool and info bars according to current settings etc. * * Parameters * wimp_openstr *o == the position of the selection owner window, or 0. * This is updated to put the window somewhere nice without flicker. */ void window__setToolBarPositions(wimp_openstr *o); /* * void window__updateInfoBar(void) * * Use * Updates the settings on the info bar. If a setting hasn't changed, then * it isn't updated (reducing flicker). * * Parameters * BOOL force == whether to force an update of everything. */ void window__updateInfoBar(BOOL force); /* * void window__toggleRenumber(glass_windPointer *w) * * Use * Updates the info bar after entering or leaving renumber-mode. w is * the currently selected window. */ void window__toggleRenumber(glass_windPointer *w); /* * void window__toggleTest(glass_windPointer *w) * * Use * Updates the info bar after entering or leaving test-mode. w is the * currently selected window. */ #ifndef glass_DEMO void window__toggleTest(glass_windPointer *w); #endif /* * void window__updateInfoName(char *newname) * * Use * Updates the name in the info bar */ void window__updateInfoName(char *newname); /* * void window__nextRenumber(glass_windPointer *w) * * Use * Updates the next renumber icon number display. */ void window__nextRenumber(glass_windPointer *w); /* * void window__moveToolbars(glass_windPointer *w) * * Use * Moves the toolbars and attaches them to a new window * * Parameters * glass_windPointer *w == the window to attach the bars to */ void window__moveToolbars(glass_windPointer *w); /* * void window__tbarInit(void) * * Use * Initialises the toolbar system */ void window__tbarInit(void); /*----- The icon palette --------------------------------------------------*/ /* * void window__showPalette(void) * * Use * Displays the palette window, as set up in the Defaults template file. */ void window__showPalette(void); /*----- The main event handlers -------------------------------------------*/ /* * void window__winIdles(void *handle) * * Use * Changes the pointer shape to something appropriate for what its over. * * Parameters * void *handle == pointer to window containing pointer */ void window__winIdles(void *handle); /* * void window__testEvents(wimp_eventstr *e,void *handle) * * Use * Handles all events for windows running in Test mode. Events handled * are: * * Redraw Redraws the window using Interface/hatch pattern as requested. * Open Moves the window around. * Close Closes the window(!) * Leave Ignored * Enter Turn off STEEL pointer changing * Click Handled by WIMP or Interface, except for menu, which opens * the menu(!) * Key Handled by WIMP, WimpExtension, or ignored * * Parameters * wimp_eventstr *e == the event * void *handle == pointer to window info */ #ifndef glass_DEMO void window__testEvents(wimp_eventstr *e,void *handle); #endif /* * void window__events(wimp_eventstr *e,void *handle) * * Use * Handles all events for template windows (this is the first chance I've * had to get my fingers *REALLY* mucky on this whole project!) * * Parameters * wimp_eventstr *e == the event that I am meant to be inerested in * void *handle == a pointer to the structural information for this window */ void window__events(wimp_eventstr *e,void *handle); /*----- THE END -----------------------------------------------------------*/ #endif