home *** CD-ROM | disk | FTP | other *** search
- // **************************************************************************
- // Copyright 1996 David Allison
- //
- // VV VV IIIIII SSSSS TTTTTT AA
- // VV VV II SS TT AA AA
- // VV VV II SSSS TT AA AA
- // VV VV II SS TT AAAAAAAA
- // VV IIIIII SSSS TT AA AA
- //
- // MULTI-THREADED C++ WIMP CLASS LIBRARY
- // for RISC OS
- // **************************************************************************
- //
- // P U B L I C D O M A I N L I C E N C E
- // -------------------------------------------
- //
- // This library is copyright. You may not sell the library for
- // profit, but you may sell products which use it providing
- // those products are presented as executable code and are not
- // libraries themselves. The library is supplied without any
- // warranty and the copyright owner cannot be held responsible for
- // damage resulting from failure of any part of this library.
- //
- // See the User Manual for details of the licence.
- //
- // *************************************************************************
-
-
- #ifndef __icon_h
- #define __icon_h
-
- #include "Vista:defs.h"
-
- class Window ;
-
- struct Box
- {
- int x0 ;
- int y0 ;
- int x1 ;
- int y1 ;
- } ;
-
- union IconData
- {
- char text[12] ;
- char sprite_name[12] ;
- struct indirectsprite
- {
- char *name ;
- void *spritearea ;
- int nameisname ;
- } indirectsprite ;
- struct indirecttext
- {
- char *buffer ;
- char *validstring ;
- int bufflen;
- } indirecttext ;
- } ;
-
- #ifndef __menu_h
- #include "Vista:menu.h"
- #endif
-
- class Icon
- {
- friend class Window ;
-
- public:
- enum iconflags { /* icon flag set */
- ITEXT = 0x00000001, /* icon contains text */
- ISPRITE = 0x00000002, /* icon is a sprite */
- IBORDER = 0x00000004, /* icon has a border */
- IHCENTRE = 0x00000008, /* text is horizontally centred */
- IVCENTRE = 0x00000010, /* text is vertically centred */
- IFILLED = 0x00000020, /* icon has a filled background */
- IFONT = 0x00000040, /* text is an anti-aliased font */
- IREDRAW = 0x00000080, /* redraw needs application's help */
- INDIRECT = 0x00000100, /* icon data is 'indirected' */
- IRJUST = 0x00000200, /* text right justified in box */
- IESG_NOC = 0x00000400, /* if selected by right button, don't
- * cancel other icons in same ESG */
- IHALVESPRITE=0x00000800, /* plot sprites half-size */
- IBTYPE = 0x00001000, /* 4-bit field: button type */
- ISELECTED = 0x00200000, /* icon selected by user (inverted) */
- INOSELECT = 0x00400000, /* icon cannot be selected (shaded) */
- IDELETED = 0x00800000, /* icon has been deleted */
- IFORECOL = 0x01000000, /* 4-bit field: foreground colour */
- IBACKCOL = 0x10000000 /* 4-bit field: background colour */
- } ;
- enum buttontype { /* button types */
- BIGNORE, /* ignore all mouse ops */
- BNOTIFY,
- BCLICKAUTO,
- BCLICKDEBOUNCE,
- BSELREL,
- BSELDOUBLE,
- BDEBOUNCEDRAG,
- BRELEASEDRAG,
- BDOUBLEDRAG,
- BSELNOTIFY,
- BCLICKDRAGDOUBLE,
- BCLICKSEL, /* useful for on/off and radio buttons */
- BWRITABLE = 15
- } ;
- enum Direction
- {
- UP,
- DOWN,
- LEFT,
- RIGHT
- } ;
- enum ColourMask
- {
- ForeMask = (15 << 24),
- BackMask = (15 << 28)
- } ;
- public:
- Icon(int priority, int window, int x0, int y0, int x1, int y1, iconflags flags, IconData *data, void *ref = 0) ;
- Icon(Window *w, int iconnum = -1, void *ref = 0, char *menu = 0) ; // create an icon in a window
- Icon() ;
- Icon(Window *w,Icon *temp, Direction direction = DOWN, int gap = 0, void *ref = 0, char *menu = 0) ; // create using a template
- Icon(Window *w,Icon *temp, int x, int y, void *ref = 0, char *menu = 0) ; // create using a template
- virtual ~Icon() ; // delete the icon
-
- void attach (Window *w, int iconnum) ; // attach the icon to a window
- void move (int dx, int dy) ;
- void move (Direction direction, int dist) ;
- void move_to (int x, int y) ;
- void resize (int width, int height) ;
- void read_position (Box &pos) ;
- void plot() ;
- virtual void set_caret() ; // set the caret (if writeable)
- virtual void drag (int mx, int my, int buttons) ; // drag the icon
- virtual void redraw (int x0, int y0, int x1, int y1) ;
- virtual void click(int mx, int my, int button, int icon) ; // icon has been clicked
- virtual void key (int icon, int x, int y, int height, int index, int code) ;
- virtual void select() ; // select the icon
- virtual void unselect() ; // unselect the icon
- virtual void fade() ; // fade the icon to grey
- virtual void unfade() ; // unfade the icon
- virtual void set_fore_colour (int colour) ; // set foreground colour
- virtual void set_back_colour (int colour) ; // set background colour
- virtual int is_writeable() ; // is the icon writeable
- virtual int is_selected() ; // is the icon selected
- virtual void print (char *format,...) ; // print a string to an icon
- virtual void change_sprite (char *sprite_name, int area = 1) ;
- virtual void read_sprite (char *sprite_name) ;
- virtual void read (char *s) ;
- virtual void read (int &n) ;
- virtual void read (float &n) ;
- virtual void read (double &n) ;
- virtual void write (char *s) ;
- virtual void write (int n) ;
- virtual void write (float n) ;
- virtual void write (double n) ;
-
- virtual int compare(int icon) ; // compare icon handle
- virtual int compare (Icon *icon) ; // compare contents with icon
- virtual char *help (int mx, int my, int button) ; // give help
-
- Menu *display_menu (int x, int y, int button, int icon) ;
- virtual void pre_menu(Menu *m, int x, int y, int button, int icon) ;
- virtual char *get_menu (int x, int y, int button, int icon) ;
- virtual void menu(MenuItem items[]) ;
-
- public:
- int handle ; // WIMP icon handle
- Window *window ; // window I belong to
- Icon *next ; // next icon list
- Icon *prev ; // previous icon in list
- void *user_ref ; // user reference
- Menu *default_menu ; // default menu
- bool delete_wimp_icon ; // delete the wimp icon upon deletion
- } ;
-
-
- class IconSet
- {
- public:
- IconSet (int num_icons) ;
- ~IconSet() ;
- int compare(int icon) ;
- void add_icon(int icon) ;
- virtual void select (int icon) ;
- virtual void select();
- virtual void fade(int icon) ;
- virtual void fade() ;
- virtual void unselect (int icon) ;
- virtual void unselect();
- virtual void unfade(int icon) ;
- virtual void unfade() ;
- protected:
- int max_icons ;
- int num_icons ;
- int *icons ; // dynamic array
- } ;
-
-
- #endif
-