home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User 2
/
AUCD2.iso
/
program
/
vista.arc
/
c
/
icon
< prev
next >
Wrap
Text File
|
1996-02-01
|
23KB
|
962 lines
// **************************************************************************
// 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.
//
// *************************************************************************
//
// c.icon
//
#include "Vista:icon.h"
#include "Vista:window.h"
#include <kernel.h>
#include <stdlib.h>
#include <swis.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "Vista:task.h"
#include <ctype.h>
Icon::Icon() // default constructor
{
}
Icon::Icon (int priority, int window, int x0, int y0, int x1, int y1, iconflags flags, IconData *data, void *ref)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int icon[9] ;
r.r[0] = priority ;
r.r[1] = (int)icon ;
icon[0] = window ;
icon[1] = x0 ;
icon[2] = y0 ;
icon[3] = x1 ;
icon[4] = y1 ;
icon[5] = (int)flags ;
memcpy (&icon[6], data, sizeof (IconData)) ;
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
delete_wimp_icon = true ;
window = NULL ;
handle = r.r[0] ;
prev = NULL ;
next = NULL ;
user_ref = ref ;
default_menu = NULL ;
}
Icon::Icon (Window *w, int iconnum, void *ref, char *menu)
{
prev = NULL ;
next = NULL ;
user_ref = ref ;
if (menu == NULL)
default_menu = NULL ;
else
{
default_menu = w->task->find_menu (menu) ;
if (default_menu == NULL)
throw ("Unknown menu") ;
}
delete_wimp_icon = false ;
attach (w,iconnum) ;
}
Icon::~Icon()
{
if (window != NULL)
{
if (delete_wimp_icon)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[2] ;
r.r[1] = (int)block ;
block[0] = window->handle ;
block[1] = handle ;
if ((e = _kernel_swi (Wimp_DeleteIcon, &r, &r)) != NULL)
throw (e) ;
}
window->remove_icon (this) ;
}
}
Icon::Icon (Window *w, Icon *temp, Direction direction, int gap, void *ref, char *menu)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
if (menu == NULL)
default_menu = NULL ;
else
{
default_menu = w->task->find_menu (menu) ;
if (default_menu == NULL)
throw ("Unknown menu") ;
}
block[0] = w->handle ;
block[1] = temp->handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
int size ;
Box *box = (Box*)&block[2] ;
IconData *data = (IconData*)&block[7] ;
switch (direction)
{
case UP:
size = box->y1 - box->y0 + gap ;
box->y0 += size ;
box->y1 += size ;
break ;
case DOWN:
size = box->y1 - box->y0 + gap ;
box->y0 -= size ;
box->y1 -= size ;
break ;
case LEFT:
size = box->x1 - box->x0 + gap ;
box->x0 -= size ;
box->x1 -= size ;
break ;
case RIGHT:
size = box->x1 - box->x0 + gap ;
box->x0 += size ;
box->x1 += size ;
break ;
}
if (block[6] & INDIRECT && block[6] & ITEXT)
{
char *p = (char*)malloc (data->indirecttext.bufflen) ;
if (p == NULL)
throw ("Out of Memory") ;
data->indirecttext.buffer = p ;
p[0] = 0 ;
}
block[1] = w->handle ; // copy window handle to right place
r.r[1] = (int)&block[1] ;
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
prev = NULL ;
next = NULL ;
user_ref = ref ;
delete_wimp_icon = true ;
attach (w,r.r[0]) ;
}
Icon::Icon (Window *w, Icon *temp, int x, int y, void *ref, char *menu)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
if (menu == NULL)
default_menu = NULL ;
else
{
default_menu = w->task->find_menu (menu) ;
if (default_menu == NULL)
throw ("Unknown menu") ;
}
block[0] = w->handle ;
block[1] = temp->handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
int xsize, ysize ;
Box *box = (Box*)&block[2] ;
IconData *data = (IconData*)&block[7] ;
xsize = box->x1 - box->x0 ;
ysize = box->y1 - box->y0 ;
box->x0 = x ;
box->x1 = box->x0 + xsize ;
box->y0 = y ;
box->y1 = box->y0 + ysize ;
if (block[6] & INDIRECT && block[6] & ITEXT)
{
char *p = (char*)malloc (data->indirecttext.bufflen) ;
if (p == NULL)
throw ("Out of Memory") ;
data->indirecttext.buffer = p ;
p[0] = 0 ;
}
block[1] = w->handle ; // copy window handle to right place
r.r[1] = (int)&block[1] ;
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
prev = NULL ;
next = NULL ;
user_ref = ref ;
delete_wimp_icon = true ;
attach (w,r.r[0]) ;
}
void Icon::attach (Window *w, int iconnum)
{
window = w ;
handle = iconnum ;
w->add_icon (this) ;
}
void Icon::move (int dx, int dy)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
int delblock[2] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
Box *box = (Box*)&block[2] ;
box->x0 += dx ;
box->x1 += dx ;
box->y0 += dy ;
box->y1 += dy ;
delblock[0] = window->handle ;
delblock[1] = handle ;
r.r[1] = (int)delblock ;
if ((e = _kernel_swi (Wimp_DeleteIcon, &r, &r)) != NULL)
throw (e) ;
r.r[1] = (int)&block[1] ;
r.r[0] = handle ;
block[1] = window->handle ; // set window handle
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
r.r[0] = window->handle ;
r.r[1] = block[2] ;
r.r[2] = block[3] ;
r.r[3] = block[4] ;
r.r[4] = block[5] ;
if ((e = _kernel_swi (Wimp_ForceRedraw, &r, &r)) != NULL)
throw (e) ;
}
void Icon::move (Direction direction, int dist)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
int delblock[2] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
Box *box = (Box*)&block[2] ;
switch (direction)
{
case UP:
box->y0 += dist ;
box->y1 += dist ;
break ;
case DOWN:
box->y0 -= dist ;
box->y1 -= dist ;
break ;
case LEFT:
box->x0 += dist ;
box->x1 += dist ;
break ;
case RIGHT:
box->x0 -= dist ;
box->x1 -= dist ;
break ;
}
delblock[0] = window->handle ;
delblock[1] = handle ;
r.r[1] = (int)delblock ;
if ((e = _kernel_swi (Wimp_DeleteIcon, &r, &r)) != NULL)
throw (e) ;
r.r[1] = (int)&block[1] ;
r.r[0] = handle ;
block[1] = window->handle ; // set window handle
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
r.r[0] = window->handle ;
r.r[1] = block[2] ;
r.r[2] = block[3] ;
r.r[3] = block[4] ;
r.r[4] = block[5] ;
if ((e = _kernel_swi (Wimp_ForceRedraw, &r, &r)) != NULL)
throw (e) ;
}
void Icon::move_to (int x, int y)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
int delblock[2] ;
// ::print ("moving icon to %d, %d",x,y) ;
// print ("%d,%d",x,y) ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
Box *box = (Box*)&block[2] ;
int xsize = box->x1 - box->x0 ;
int ysize = box->y1 - box->y0 ;
box->x0 = x ;
box->x1 = box->x0 + xsize ;
box->y0 = y ;
box->y1 = box->y0 + ysize ;
delblock[0] = window->handle ;
delblock[1] = handle ;
r.r[1] = (int)delblock ;
if ((e = _kernel_swi (Wimp_DeleteIcon, &r, &r)) != NULL)
throw (e) ;
r.r[1] = (int)&block[1] ;
r.r[0] = handle ;
block[1] = window->handle ; // set window handle
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
// r.r[0] = window->handle ;
// r.r[1] = block[2] ;
// r.r[2] = block[3] ;
// r.r[3] = block[4] ;
// r.r[4] = block[5] ;
// if ((e = _kernel_swi (Wimp_ForceRedraw, &r, &r)) != NULL)
// throw (e) ;
}
void Icon::resize (int width, int height)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
int delblock[2] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
Box *box = (Box*)&block[2] ;
box->x1 = box->x0 + width ;
box->y1 = box->y0 + height ;
delblock[0] = window->handle ;
delblock[1] = handle ;
r.r[1] = (int)delblock ;
if ((e = _kernel_swi (Wimp_DeleteIcon, &r, &r)) != NULL)
throw (e) ;
r.r[1] = (int)&block[1] ;
r.r[0] = handle ;
block[1] = window->handle ; // set window handle
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
}
void Icon::redraw (int x0, int y0, int x1, int y1)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
Box *box = (Box*)&block[2] ;
if (x0 <= box->x1 && x1 >= box->x0 && y1 >= box->y0 && y0 <= box->y1)
{
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_PlotIcon, &r, &r)) != NULL)
throw (e) ;
}
}
void Icon::plot ()
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_PlotIcon, &r, &r)) != NULL)
throw (e) ;
}
void Icon::drag(int mx, int my, int buttons)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
IconData *data ;
bool drag_sprite ;
char sprite_name[32] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
r.r[0] = 161 ;
r.r[1] = 28 ;
_kernel_swi (OS_Byte, &r, &r) ;
drag_sprite = false ;
if (r.r[2] & 2)
{
data = (IconData*)&block[7] ;
if (block[6] & ISPRITE)
{
if (block[6] & INDIRECT) // indirect
{
if (!(block[6] & ITEXT))
{
strcpy (sprite_name, data->indirectsprite.name) ;
drag_sprite = true ;
}
else
{
if (data->indirecttext.validstring[0] == 'S' || data->indirecttext.validstring[0] == 's')
{
strcpy (sprite_name, &data->indirecttext.validstring[1]) ;
drag_sprite = true ;
}
}
}
else
{
strncpy (sprite_name, data->sprite_name, 12) ;
sprite_name[12] = 0 ;
drag_sprite = true ;
}
}
}
if (drag_sprite)
window->do_drag (sprite_name, window->xtoscreen (block[2]), window->ytoscreen(block[3]),
window->xtoscreen (block[4]), window->ytoscreen(block[5]), 0xc5, 0,0,0,0) ;
else
window->do_drag (5, window->xtoscreen (block[2]), window->ytoscreen(block[3]),
window->xtoscreen (block[4]), window->ytoscreen(block[5])) ;
}
void Icon::read_position (Box &box)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
box = *(Box*)&block[2] ;
}
void Icon::click (int mx, int my, int button, int icon)
{
}
void Icon::key (int icon, int x, int y, int height, int index, int code)
{
}
void Icon::select ()
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[4] ;
block[0] = window->handle ;
block[1] = handle ;
block[2] = ISELECTED ;
block[3] = ISELECTED ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_SetIconState, &r, &r)) != NULL)
throw (e) ;
}
void Icon::unselect ()
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[4] ;
block[0] = window->handle ;
block[1] = handle ;
block[2] = 0 ;
block[3] = ISELECTED ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_SetIconState, &r, &r)) != NULL)
throw (e) ;
}
void Icon::fade ()
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[4] ;
block[0] = window->handle ;
block[1] = handle ;
block[2] = INOSELECT ;
block[3] = INOSELECT ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_SetIconState, &r, &r)) != NULL)
throw (e) ;
}
void Icon::unfade ()
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[4] ;
block[0] = window->handle ;
block[1] = handle ;
block[2] = 0 ;
block[3] = INOSELECT ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_SetIconState, &r, &r)) != NULL)
throw (e) ;
}
void Icon::set_fore_colour (int colour)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[4] ;
block[0] = window->handle ;
block[1] = handle ;
block[2] = colour << 24 ;
block[3] = ForeMask ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_SetIconState, &r, &r)) != NULL)
throw (e) ;
}
void Icon::set_back_colour (int colour)
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[4] ;
block[0] = window->handle ;
block[1] = handle ;
block[2] = colour << 28 ;
block[3] = BackMask ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_SetIconState, &r, &r)) != NULL)
throw (e) ;
}
int Icon::is_writeable ()
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
int btype = (block[6] >> 12) & 0x0f ;
return btype == BWRITABLE ;
}
int Icon::is_selected ()
{
_kernel_swi_regs r ;
_kernel_oserror *e ;
int block[40] ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
return (block[6] & ISELECTED) ;
}
int Icon::compare (int icon)
{
return icon == handle ;
}
int Icon::compare (Icon *icon)
{
int block[10] ;
_kernel_swi_regs r ;
_kernel_oserror *e ;
char *text1, *text2 ;
IconData *data ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
data = (IconData*)&block[7] ;
if (!(block[6] & INDIRECT))
throw ("Icon is not indirected") ;
text1 = data->indirecttext.buffer ;
block[0] = icon->window->handle ;
block[1] = icon->handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
data = (IconData*)&block[7] ;
if (!(block[6] & INDIRECT))
throw ("Icon is not indirected") ;
text2 = data->indirecttext.buffer ;
while (*text1 && *text2)
if (toupper(*text1) != toupper (*text2))
break ;
else
text1++, text2++ ;
return toupper(*text1) - toupper (*text2) ;
}
void Icon::print (char *format ...)
{
va_list arg ;
int block[10] ;
_kernel_swi_regs r ;
_kernel_oserror *e ;
IconData *data ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
data = (IconData*)&block[7] ;
if (!(block[6] & INDIRECT))
throw ("Icon is not indirected") ;
va_start (arg,format) ;
vsprintf (data->indirecttext.buffer, format, arg) ;
block[2] = 0 ;
block[3] = 0 ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_SetIconState, &r, &r)) != NULL)
throw (e) ;
}
void Icon::change_sprite (char *sprite_name, int area)
{
int block[10] ;
int delblock[2] ;
_kernel_swi_regs r ;
_kernel_oserror *e ;
IconData *data ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
data = (IconData*)&block[7] ;
if (!(block[6] & ISPRITE))
throw ("Icon doesn't contain a sprite") ;
if (block[6] & INDIRECT) // indirect
{
if (!(block[6] & ITEXT))
{
data->indirectsprite.nameisname = strlen (sprite_name) ;
data->indirectsprite.name = sprite_name ;
data->indirectsprite.spritearea = (void*)area ;
}
else
{
char *p = new char [strlen(sprite_name) + 2] ; // allow for s and 0
sprintf (p, "S%s",sprite_name) ;
data->indirecttext.validstring = p ; // possible memory leak if icon deleted
}
}
else
strncpy (data->sprite_name, sprite_name, 12) ;
delblock[0] = window->handle ;
delblock[1] = handle ;
r.r[1] = (int)delblock ;
if ((e = _kernel_swi (Wimp_DeleteIcon, &r, &r)) != NULL)
throw (e) ;
r.r[1] = (int)&block[1] ;
r.r[0] = handle ;
block[1] = window->handle ; // set window handle
if ((e = _kernel_swi (Wimp_CreateIcon, &r, &r)) != NULL)
throw (e) ;
}
void Icon::read_sprite (char *sprite_name)
{
int block[10] ;
int delblock[2] ;
_kernel_swi_regs r ;
_kernel_oserror *e ;
IconData *data ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
data = (IconData*)&block[7] ;
if (!(block[6] & ISPRITE))
throw ("Icon doesn't contain a sprite") ;
if (block[6] & INDIRECT) // indirect
{
if (!(block[6] & ITEXT))
strcpy (sprite_name, data->indirectsprite.name) ;
else
{
if (data->indirecttext.validstring[0] != 'S' && data->indirecttext.validstring[0] != 's')
throw ("Icon doesn't contain a sprite") ;
strcpy (sprite_name, &data->indirecttext.validstring[1]) ;
}
}
else
{
strncpy (sprite_name, data->sprite_name, 12) ;
sprite_name[12] = 0 ;
}
}
void Icon::set_caret()
{
int block[10] ;
_kernel_swi_regs r ;
_kernel_oserror *e ;
IconData *data ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
if (!(block[6] & (ITEXT|INDIRECT)))
throw ("Icon has no text or is not indirect") ;
if (!is_writeable())
throw ("Icon is not writeable") ;
data = (IconData*)&block[7] ;
r.r[0] = window->handle ;
r.r[1] = handle ;
r.r[2] = r.r[3] = 0 ;
r.r[4] = -1 ;
r.r[5] = strlen (data->indirecttext.buffer) ;
if ((e = _kernel_swi (Wimp_SetCaretPosition, &r, &r)) != NULL)
throw (e) ;
}
void Icon::read (char *s)
{
int block[10] ;
_kernel_swi_regs r ;
_kernel_oserror *e ;
IconData *data ;
block[0] = window->handle ;
block[1] = handle ;
r.r[1] = (int)block ;
if ((e = _kernel_swi (Wimp_GetIconState, &r, &r)) != NULL)
throw (e) ;
data = (IconData*)&block[7] ;
if (!(block[6] & INDIRECT))
throw ("Icon is not indirected") ;
strcpy (s, data->indirecttext.buffer) ;
char *cr = strchr (s,'\r') ; // overwrite CR by 0
if (cr != NULL)
*cr = 0 ;
}
void Icon::read (int &n)
{
char buffer[10] ;
read (buffer) ;
sscanf (buffer, "%d", &n) ;
}
void Icon::read (float &n)
{
char buffer[30] ;
read (buffer) ;
sscanf (buffer, "%f", &n) ;
}
void Icon::read (double &n)
{
char buffer[30] ;
read (buffer) ;
sscanf (buffer, "%lf", &n) ;
}
void Icon::write (char *s)
{
print (s) ;
}
void Icon::write (int n)
{
print ("%d",n) ;
}
void Icon::write (float n)
{
print ("%g",n) ;
}
void Icon::write (double n)
{
print ("%g",n) ;
}
Menu *Icon::display_menu (int x, int y, int button, int icon)
{
if (default_menu == NULL)
{
char *menu_name = get_menu(x, y, button, icon) ;
if (menu_name == NULL)
return NULL ;
Menu *m = window->task->find_menu (menu_name) ;
if (m != NULL)
{
m->open (x - 40, y) ;
return m ;
}
return NULL ; // no menu
}
else
{
pre_menu (default_menu, x, y, button, icon) ;
default_menu->open (x - 40, y) ;
return default_menu ;
}
}
//
// give user a chance to change the menu before display
//
void Icon::pre_menu (Menu *m, int x, int y, int button, int icon)
{
}
//
// this window doesn't have a default menu, ask the user to provide one
//
char *Icon::get_menu (int x, int y, int button, int icon)
{
return NULL ;
}
void Icon::menu (MenuItem item[])
{
}
char *Icon::help (int mx, int my, int buttons)
{
return NULL ;
}
//
// a set of icons
//
IconSet::IconSet (int nicons)
{
max_icons = nicons ;
if ((icons = (int*)malloc (max_icons * sizeof (int))) == NULL)
throw ("Out of memory") ;
num_icons = 0 ;
}
IconSet::~IconSet()
{
free (icons) ;
}
int IconSet::compare (int icon)
{
int i ;
for (i = 0 ; i < num_icons ; i++)
if (icons[i] == icon)
return 1 ;
return 0 ;
}
void IconSet::add_icon(int icon)
{
if (num_icons == max_icons)
throw ("Too many icons") ;
icons[num_icons++] = icon ;
}
void IconSet::select (int icon)
{
}
void IconSet::select ()
{
}
void IconSet::fade (int icon)
{
}
void IconSet::fade ()
{
}
void IconSet::unselect (int icon)
{
}
void IconSet::unselect ()
{
}
void IconSet::unfade (int icon)
{
}
void IconSet::unfade ()
{
}