home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kyūkyoku!! X68000 Emulator
/
X68000Book.dat
/
mac
/
OLS
/
X68000
/
Ko-Window
/
kow142s.lzh
/
parts
/
iconman.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-13
|
3KB
|
169 lines
/* Iconmanager +10 âTâôâvâï */
/* 1992 by H.Ogasawara (COR.) */
#include <corlib.h>
#include <winop.h>
/* ÄΦö▓é½âvâìâOâëâÇé╛é»é╟âTâôâvâïé┼é╖ */
#define HSIZE 80
#define VSIZE 80
#define XOFFSET 2
#define YOFFSET 2
#define C(msg) {ConsoleOpen();ConsolePrint(msg);}
typedef struct icontbl {
WindowID wp;
int x, y, h;
struct icontbl *next;
} IconTbl;
IconTbl *Top= NULL;
int GlobalX= 1;
int WindowHeapSize= 1024;
/* âeü[âuâïÆ╟ë┴ */
IconTbl *
alloc_tbl( wp, x, y, h )
WindowID wp;
{
IconTbl *it;
if( it= (IconTbl*)WindowMemoryAlloc( sizeof(IconTbl) ) ){
it->next= Top;
Top= it;
it->wp= wp;
it->x= x;
it->y= y;
it->h= h;
return it;
}
return NULL;
}
/* âeü[âuâïèJò· */
free_tbl( wp )
WindowID wp;
{
IconTbl *it= Top,
**pt= &Top;
for(; it ; pt= &it->next, it= it->next ){
if( wp == it->wp ){
*pt= it->next;
WindowMemoryFree( it );
break;
}
}
}
/* âeü[âuâïë≡Å£ */
free_tbl_all()
{
IconTbl *it= Top, *pt;
for(; it ; it= pt ){
pt= it->next;
WindowMemoryFree( it );
}
}
/* ï≤é½ÅΩÅèâ`âFâbâN */
check_tbl_width( x, h )
{
IconTbl *it= Top;
for(; it ; it= it->next ){
if( (it->x > x && it->x < x+h) ||
(it->x+it->h > x && it->x+it->h < x+h) )
return FALSE;
}
return TRUE;
}
/* ï≤é½ÅΩÅèé≡ÆTé╖ */
search_tbl_position( h )
{
IconTbl *it= Top;
for(; it ; it= it->next ){
if( check_tbl_width( it->x+it->h+ 2 , h ) )
return it->x+it->h+2;
}
return XOFFSET;
}
/* âAâCâRâôë╗âïü[â`âô */
IconifyExec( wp, h, v, exec, px, py )
WindowID wp;
int h, v;
int (*exec)();
int *px, *py;
{
int x;
C( "sono1\r\n" );
if( x= search_tbl_position( h ) ){
C( "sono2\r\n" );
*px= x;
*py= YOFFSET;
C( "sono3\r\n" );
alloc_tbl( wp, *px, *py, h );
C( "sono4\r\n" );
}
return FALSE;
}
/* âAâCâRâôâ}âEâXâïü[â`âô */
IconMouseExec( wp, info, f )
WindowID wp;
EventInfo *info;
int *f;
{
*f= TRUE;
free_tbl( wp );
return FALSE;
}
IconManagerInit()
{
IconMan *ip;
if( !WindowGetCommon( "IconManExec", 0 ) ){
if( ip= WindowGetCommon( "IconManExec", sizeof(IconMan) ) ){
ip->iconifyexec= IconifyExec;
ip->iconmouseexec= IconMouseExec;
}
return TRUE;
}else{
ConsoleOpen();
ConsolePrint( "iconman:é╖é┼é╔æ╝é╠iconmané¬æ╢ì▌é╡é▄é╖\r\n" );
return FALSE;
}
}
Exec( wp, info )
WindowID wp;
EventInfo *info;
{
DrawBuf dbuf[1];
switch( info->option ){
case EventRedraw:
DrawSetClear( dbuf, 1 );
WindowDraw( wp, dbuf, 1 );
return TRUE;
case EventClose: /* â}âlü[âWââé╠ëεôⁿé≡ë≡Å£ */
WindowResetCommon( "IconManExec" );
free_tbl_all();
return FALSE;
}
return FALSE;
}
WindowMain( argc, argv )
char **argv;
{
/* âTâôâvâïé╚é╠é┼üAÄΦö▓é½é╡é─ MgLIB é≡Ägé┴é─é▄é╖ */
if( IconManagerInit() )
MgWindowDefaultOpenArgs( 10, 10, HSIZE, VSIZE,
"IconMan", argc, argv, 0, Exec );
else
WindowSendSignal( WindowProcessID, SignalKill, 0 );
}