/* * wimpstruct.h * * All the many structures you need for the WIMP * * © 1994-1998 Straylight */ /*----- Licensing note ----------------------------------------------------* * * This file is part of Straylight's Steel library. * * Steel 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. * * Steel 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 Steel. If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __wimpstruct_h #define __wimpstruct_h #ifndef __os_h #include "os.h" #endif #ifndef __sprite_h #include "sprite.h" #endif /*----- Various handles ---------------------------------------------------*/ typedef int wimp_w; /* Normal window handle */ typedef int wimp_i; /* Icon `handle' */ typedef int wimp_t; /* Task handle */ /*----- Defining windows and icons ----------------------------------------*/ /* --- Window flags --- * * * Warning: The naming here is inconsistent. Be careful. The names are * the same as used in RISC_OSLib, so it's not my fault */ typedef enum { /* --- Basic window properties --- */ wimp_WMOVEABLE =(1<<1), /* Can be moved by user */ wimp_REDRAW_OK =(1<<4), /* Is redrawn only by WIMP */ wimp_WPANE =(1<<5), /* Is a pane of a window */ wimp_WTRESPASS =(1<<6), /* Can move off-screen */ wimp_WSCROLL_R1 =(1<<8), /* Scroll requests, auto-repeat */ wimp_SCROLL_R2 =(1<<9), /* Scroll requests, debounced */ wimp_REAL_COLOURS =(1<<10), /* Use real window colours */ wimp_BACK_WINDOW =(1<<11), /* Always stays at the back */ wimp_HOT_KEYS =(1<<12), /* Intercepts hotkeys */ /* --- Current window state (set by the WIMP) --- */ wimp_WOPEN =(1<<16), /* Is currently open */ wimp_WTOP =(1<<17), /* Is completely visible */ wimp_WFULL =(1<<18), /* Is as big as possible */ wimp_WCLICK_TOGGLE =(1<<19), /* Size has just been toggled */ wimp_WFOCUS =(1<<20), /* Owns the input focus */ /* --- Window `gadgets' --- */ wimp_WBACK =(1<<24), /* Send-to-back gadget */ wimp_WQUIT =(1<<25), /* Close window gadget */ wimp_WTITLE =(1<<26), /* Title bar */ wimp_WTOGGLE =(1<<27), /* Toggle size gadget */ wimp_WVSCR =(1<<28), /* Vertical scroll bar */ wimp_WSIZE =(1<<29), /* Adjust size gadget */ wimp_WHSCR =(1<<30), /* Horizontal scroll bar */ wimp_WNEW =~0x7FFFFFFF /* Use new gadget flags */ } wimp_wflags; /* --- Icon flags --- */ typedef enum { /* --- General flags --- */ wimp_ITEXT =(1<<0), /* Contains text */ wimp_ISPRITE =(1<<1), /* Contains a sprite */ wimp_IBORDER =(1<<2), /* Has a WIMP-drawn border */ wimp_IHCENTRE =(1<<3), /* Is horizontally centred */ wimp_IVCENTRE =(1<<4), /* Is vertically centred */ wimp_IFILLED =(1<<5), /* Has a filled background */ wimp_IFONT =(1<<6), /* Draw text anti-aliased */ wimp_IREDRAW =(1<<7), /* Force redraw on change */ wimp_INDIRECT =(1<<8), /* Icon data is indirected */ wimp_IRJUST =(1<<9), /* Is right-aligned */ wimp_IESG_NOC =(1<<10), /* Adjust clicks toggle selection */ wimp_IHALVESPRITE =(1<<11), /* Draw sprite half sized */ /* --- Larger fields --- */ wimp_IBTYPE =(1<<12), /* Button type (4 bits) */ wimp_IESG =(1<<16), /* ESG number (5 bits) */ /* --- Some more flags --- */ wimp_ISELECTED =(1<<21), /* Is selected (inverted) */ wimp_INOSELECT =(1<<22), /* Is shaded (unavailable) */ wimp_IDELETED =(1<<23), /* Is deleted (invisible) */ /* --- Colours/font information --- */ wimp_IFORECOL =(1<<24), /* Foreground colour (4 bits) */ wimp_IBACKCOL =(1<<28), /* Background colour (4 bits) */ wimp_IFONTH =(1<<24) /* Font handle (8 bits) */ } wimp_iconflags; /* --- Icon and window button types --- */ typedef enum { wimp_BIGNORE, /* Ignore all mouse clicks */ wimp_BNOTIFY, /* Always report pointer over icon */ wimp_BCLICKAUTO, /* Report mouse clicks, autorepeat */ wimp_BCLICKDEBOUNCE, /* Report mouse clicks, debounced */ wimp_BSELREL, /* Report mouse button release */ wimp_BSELDOUBLE, /* Report mouse double clicks */ wimp_BDEBOUNCEDRAG, /* Report clicks and drags */ wimp_BRELEASEDRAG, /* Report releases and drags */ wimp_BDOUBLEDRAG, /* Report double clicks and drags */ wimp_BSELNOTIFY, /* `Menu icon' (reports clicks) */ wimp_BCLICKDRAGDOUBLE, /* Clicks, double clicks and drags */ wimp_BCLICKSEL, /* `Radio icon' (clicks and drags) */ wimp_BTYPE12, /* Reserved for future exapansion */ wimp_BTYPE13, /* Reserved for future exapansion */ wimp_BCLICKWRITEDRAG, /* Writable; report clicks, drags */ wimp_BWRITABLE /* Writable; report nothing */ } wimp_ibtype; /* --- Window colours --- */ typedef enum { wimp_WCTITLEFORE, /* Title bar foreground (7) */ wimp_WCTITLEBACK, /* Title bar background (1) */ wimp_WCWKAREAFORE, /* Workarea default foreground (7) */ wimp_WCWKAREABACK, /* Workarea default background (0) */ wimp_WCSCROLLOUTER, /* Scroll bar `shoulder' area (3) */ wimp_WCSCROLLINNER, /* Scroll bar `thumb' area (1) */ wimp_WCTITLEHI, /* Highlight for input focus (12) */ wimp_WCRESERVED /* The non-existant useless colour */ } wimp_wcolours; /* --- Defining rectangles --- */ typedef struct { int x0,y0; /* Bottom left (inclusive) */ int x1,y1; /* Top right (exclusive) */ } wimp_box; /* --- Icon data --- */ typedef union { char text[12]; /* Non-indirected text string */ char sprite_name[12]; /* Non-indirected sprite name */ struct { char *name; /* Pointer to sprite name */ void *spritearea; /* Pointer to real sprite area */ BOOL nameisname; /* FALSE => name is sprite pointer */ } indirectsprite; /* Indirected sprite information */ struct { char *buffer; /* Pointer to text buffer */ char *validstring; /* Pointer to validation string */ int bufflen; /* Size of text buffer in bytes */ } indirecttext; /* Indirectted text information */ } wimp_icondata; /* --- Window definitions --- */ typedef struct { wimp_box box; /* Initial position on the screen */ int scx,scy; /* Initial scroll bar positions */ wimp_w behind; /* Window behind which to open */ wimp_wflags flags; /* Window flags word */ char colours[8]; /* Various colours for the window */ wimp_box ex; /* Initial window extent */ wimp_iconflags titleflags; /* Information about window title */ wimp_iconflags workflags; /* Work area button type */ void *spritearea; /* Sprite area for this window */ int minsize; /* Minimum size for the window */ wimp_icondata title; /* Title bar icon data info */ int nicons; /* Number of icons in the window */ } wimp_wind; /* --- Icon definitions --- */ typedef struct { wimp_box box; /* Position of icon within window */ wimp_iconflags flags; /* Icon flags word */ wimp_icondata data; /* Icon data information */ } wimp_icon; /*----- Manipulating windows and icons ------------------------------------*/ /* --- Creating an icon --- */ typedef struct { wimp_w w; /* Window in which to create icon */ wimp_icon i; /* Information about icon */ } wimp_icreate; /* --- Opening windows --- */ typedef struct { wimp_w w; /* Window handle to open */ wimp_box box; /* Position on screen to open at */ int x,y; /* Scroll bar positions to set */ wimp_w behind; /* Window behind which to open */ } wimp_openstr; /* --- Redrawing windows --- */ typedef struct { wimp_w w; /* The window handle to redraw */ wimp_box box; /* Where it is on the screen */ int scx,scy; /* Scroll bar positions */ wimp_box g; /* Graphics clipping rectangle */ } wimp_redrawstr; /* --- Finding information about a window --- */ typedef struct { wimp_openstr o; /* Where the window is on screen */ wimp_wflags flags; /* Anything else about the window */ } wimp_wstate; /* --- Reading a whole window definition --- */ typedef struct { wimp_w w; /* Window handle (fill this in) */ wimp_wind info; /* Window definition (Wimp fills) */ } wimp_winfo; /*----- Pointer and caret structures --------------------------------------*/ /* --- Mouse button status --- */ typedef enum { /* --- Button-type independent actions --- */ wimp_BMID =0x002, /* Menu button click */ /* --- Standard click codes --- * * * As returned by wimp_get_point_info, or for single clicks on button * types Always, Autorepeat, Debounced, Release, Click/Drag, Release/Drag, * Menu, Select/Drag or Click/Write/Drag, or double clicks on Double, * Double/Drag and Double/Click/Drag. */ wimp_BRIGHT =0x001, /* Adjust click or double click */ wimp_BLEFT =0x004, /* Select click or double click */ /* --- Drag codes --- * * * As returned by drags on button types Click/Drag, Release/Drag, * Double/Drag, Select/Drag, Double/Click/Drag and Click/Write/Drag. */ wimp_BDRAGRIGHT =0x010, /* Adjust drag */ wimp_BDRAGLEFT =0x040, /* Select drag */ /* --- Odd click codes --- * * * As returned by single clicks on button type Double/Click/Drag. */ wimp_BCLICKRIGHT =0x100, /* Adjust single click */ wimp_BCLICKLEFT =0x400, /* Select single click */ /* --- And nothing at all --- * * * As returned by wimp_get_point_info, or by just pointing at button type * Always. */ wimp_BNOTHING =0x000 /* Not doing anything at all */ } wimp_bbits; /* --- Current mouse status --- */ typedef struct { int x,y; /* Mouse position on the screen */ wimp_bbits bbits; /* Current mouse button state */ wimp_w w; /* Window under the mouse pointer */ wimp_w i; /* Icon under the mouse pointer */ } wimp_mousestr; /* --- Special caret flags --- */ typedef enum { wimp_CHEIGHT =(1<<0), /* The caret height (16 bits) */ wimp_CCOLOUR =(1<<16), /* The caret colour (8 bits) */ wimp_CVDUSTYLE =(1<<24), /* Plot VDU-5 caret, not Font one */ wimp_CINVISIBLE =(1<<25), /* Don't actually draw it at all */ wimp_CUSECOLOUR =(1<<26), /* Use the colour I've specified */ wimp_CNOTWIMPCOL =(1<<27) /* The colour is a GCOL, not a */ /* normal Wimp colour */ } wimp_caretflags; /* --- Current caret status --- */ typedef struct { wimp_w w; /* The window containing the caret */ wimp_w i; /* The icon containing the caret */ int x,y; /* Its position within the window */ wimp_caretflags height; /* Its height, and other things */ int index; /* Its index into the icon */ } wimp_caretstr; /*----- Wimp message structures -------------------------------------------*/ typedef enum { wimp_MCLOSEDOWN =0x00000, /* Task is being told to quit */ /* --- Data transfer protocol messages --- */ wimp_MDATASAVE =0x00001, /* Request to import some data */ wimp_MDATASAVEOK =0x00002, /* Import data by scrap file */ wimp_MDATALOAD =0x00003, /* Request to load data from file */ wimp_MDATALOADOK =0x00004, /* File loaded successfully */ wimp_MDATAOPEN =0x00005, /* File double-clicked in Filer */ wimp_MRAMFETCH =0x00006, /* Transfer data to by buffer */ wimp_MRAMTRANSMIT =0x00007, /* Data transferred, try again */ wimp_MDATASAVED =0x0000D, /* File has magically become safe */ /* --- Miscellaneous --- */ wimp_MPREQUIT =0x00008, /* Task will be asked to quit soon */ wimp_PALETTECHANGE =0x00009, /* Desktop palette has changed */ /* --- RISC OS 3 only --- */ wimp_SAVEDESK =0x0000A, /* Save application status to file */ wimp_MDEVICECLAIM =0x0000B, /* Broadcast before device claims */ wimp_MDEVICEINUSE =0x0000C, /* The device claimed is in use */ /* --- Filer messages --- */ wimp_FilerOpenDir =0x00400, /* Open a Filer window on screen */ wimp_FilerCloseDir =0x00401, /* Close a Filer window or two */ /* --- Help messages --- */ wimp_MHELPREQUEST =0x00502, /* `What does this thing do?' */ wimp_MHELPREPLY =0x00503, /* `Oh well, it does this, y'see' */ /* --- NetFiler messages --- */ wimp_Notify =0x40040, /* Someone else notified us */ /* --- WIMP messages --- */ wimp_MMENUWARN =0x400C0, /* A submenu needs opening */ wimp_MMODECHANGE =0x400C1, /* The screen mode has changed */ wimp_MINITTASK =0x400C2, /* A new application has started */ wimp_MCLOSETASK =0x400C3, /* An application has vanished */ wimp_MSLOTCHANGE =0x400C4, /* An application's slot changed */ wimp_MSETSLOT =0x400C5, /* Task's slot bar was dragged */ wimp_MTASKNAMERQ =0x400C6, /* Find out a task's name */ wimp_MTASKNAMEIS =0x400C7, /* Reply to TaskNameRq */ wimp_MTASKSTARTED =0x400C8, /* `I have initialised properly' */ /* --- Straylight messages --- */ wimp_MINTERNAL =0x427FF, /* For internal broadcast messages */ /* --- Messing about with printers --- */ wimp_MPrintFile =0x80140, /* Printer's response to DataSave */ wimp_MWillPrint =0x80141, /* Response: `I will print it' */ wimp_MPrintSave =0x80142, /* Task: `I want to print a file' */ wimp_MPrintInit =0x80143, /* Tell other drivers to hari-kiri */ wimp_MPrintError =0x80144, /* Printer is busy/something died */ wimp_MPrintTypeOdd =0x80145, /* Printer: `How do I print this?' */ wimp_MPrintTypeKnown =0x80146, /* Response: `Give it here...' */ wimp_MPrinterChange =0x80147 /* Printer driver settings changed */ } wimp_msgaction; /* --- The message header format --- */ typedef struct { int size; /* Size of the message (20-256) */ wimp_t task; /* Task handle of the sender */ int my_ref; /* The sender's reference */ int your_ref; /* Which message it's replying to */ wimp_msgaction action; /* What sort of message it is */ } wimp_msghdr; /* --- Lots of structures containing message information --- */ typedef struct { wimp_w w; /* Window handle to save to */ wimp_i i; /* Icon handle to save to */ int x,y; /* Position of mouse pointer */ int estsize; /* Estimated size of the file */ int type; /* Filetype of the file */ char leaf[12]; /* Leafname of the file */ } wimp_msgdatasave; typedef struct { wimp_w w; /* Window handle to save to */ wimp_i i; /* Icon handle to save to */ int x,y; /* Position of mouse pointer */ int estsize; /* Estimated size of the file */ int type; /* Filetype of the file */ char name[212]; /* The name of the file to save */ } wimp_msgdatasaveok; typedef struct { wimp_w w; /* Window handle to save to */ wimp_i i; /* Icon handle to save to */ int x,y; /* Position of mouse pointer */ int size; /* Actual size of the file */ int type; /* Filetype of the file */ char name[212]; /* The name of the file to save */ } wimp_msgdataload; typedef wimp_msgdataload wimp_msgdataopen; typedef struct { char *addr; /* Address in my workspace to fill */ int nbytes; /* The size of my buffer */ } wimp_msgramfetch; typedef struct { char *addr; /* Address in your workspace */ int nbyteswritten; /* How much I filled it up */ } wimp_msgramtransmit; typedef struct { int filehandle; /* RISC OS file handle to write to */ } wimp_msgsavedesk; typedef struct { int major,minor; /* Device idenitification numbers */ char information[228]; /* A string of stuff about it all */ } wimp_msgdevice; typedef struct { wimp_mousestr m; /* What it wants help about */ } wimp_msghelprequest; typedef struct { char text[200]; /* What it's all about */ } wimp_msghelpreply; typedef struct { int filler[5]; /* Nothing really interesting */ int type; /* File type of the file to print */ char name[212]; /* The full name of the file */ } wimp_msgprint; typedef struct { int errnum; /* The error number of the error */ char errmess[232]; /* The error's textual message */ } wimp_msgprinterror; /* --- An actual message structure --- */ typedef struct { wimp_msghdr hdr; /* The message's common header */ union { /* --- Standard forms --- */ char chars[236]; /* Information as a char string */ int words[59]; /* Information as array of words */ /* --- Data transfer --- */ wimp_msgdatasave datasave; wimp_msgdatasaveok datasaveok; wimp_msgdataload dataload; wimp_msgdataopen dataopen; wimp_msgramfetch ramfetch; wimp_msgramtransmit ramtransmit; /* --- Help messages --- */ wimp_msghelprequest helprequest; wimp_msghelpreply helpreply; /* --- Printer driver messages --- */ wimp_msgprint print; /* Printer message common format */ wimp_msgprinterror printerror; /* --- Other messages --- */ wimp_msgsavedesk savedesk; wimp_msgdevice device; } data; /* The message's individual data */ } wimp_msgstr; /*----- Defining WIMP events ----------------------------------------------*/ /* --- All the different types of event --- */ typedef enum { wimp_ENULL =0, /* Null_Reason_Code */ wimp_EREDRAW, /* Redraw_Window_Request */ wimp_EOPEN, /* Open_Window_Request */ wimp_ECLOSE, /* Close_Window_Request */ wimp_EPTRLEAVE, /* Pointer_Leaving_Window */ wimp_EPTRENTER, /* Pointer_Entering_Window */ wimp_EBUT, /* Mouse_Clicked */ wimp_EUSERDRAG, /* User_Drag_Box */ wimp_EKEY, /* Key_Pressed */ wimp_EMENU, /* Menu_Selection */ wimp_ESCROLL, /* Scroll_Request */ wimp_ELOSECARET, /* Lose_Caret */ wimp_EGAINCARET, /* Gain_Caret */ wimp_ESEND =17, /* User_Message */ wimp_ESENDWANTACK =18, /* User_Message_Recorded */ wimp_EACK =19 /* User_Message_Acknowledge */ } wimp_etype; /* --- Wimp event mask --- */ typedef enum { wimp_EMNULL =(1<