home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
disk
/
misc
/
dcmp
/
source
/
source.lha
/
intuisup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-17
|
3KB
|
112 lines
/*--------------------------------------------*
$Id: intuisup.c,v 1.1 92/10/09 21:11:03 tf Exp $
Intuition support functions for dcmp.c,v
written 1991, slightly modified 04-Aug-1992
*--------------------------------------------*/
#include <exec/types.h>
#include <intuition/intuition.h>
#define POS_3D TRUE
#define NEG_3D FALSE
/*
* draw_3d() zeichnet einen Border im RastPort rp an der Stelle (x|y).
* Is bpen > -1, so wird der Inhalt dieses Rechtecks damit gel"oscht,
* posneg bestimmt ob der 3D-Effekt positiv oder negativ dargestellt wird.
*/
void draw_3d(struct RastPort *rp, UWORD x,UWORD y,UWORD w,UWORD h, int bpen, BOOL posneg)
{ if(rp != NULL) /* have we got a RastPort to work with ? */
{ w--;
h--;
if(bpen >= 0) /* fill region inside border */
{ SetAPen(rp,bpen);
RectFill(rp,x+2,y+1,x+w-2,y+h-1);
}
if(posneg == POS_3D) SetAPen(rp,1L);
else SetAPen(rp,2L);
Move(rp,x+w,y);
Draw(rp,x,y);
Draw(rp,x,y+h);
Move(rp,x+1,y);
Draw(rp,x+1,y+h-1);
if(posneg == POS_3D) SetAPen(rp,2L);
else SetAPen(rp,1L);
Move(rp,x+1,y+h);
Draw(rp,x+w,y+h);
Draw(rp,x+w,y);
Move(rp,x+w-1,y+h);
Draw(rp,x+w-1,y+1);
}
}
/*
* FUNCTION
*
* draw3dgb -- draw 3D borders around all gadgets glued to given one.
*
* SYNOPSIS
*
* draw_3dgb(rp, gadget);
*
* struct RastPort *rp;
* struct Gadget *gadget;
*
* DESCRIPTION
*
* Draw a OS2.0 box around all the gadgets chained to the given one.
* StringGadgets and BooleanGadgets border are not equal...
*
*/
draw_3dgb(struct RastPort *rp, struct Gadget *gadget)
{ if(rp != NULL && gadget != NULL)
{ if(gadget->GadgetType != STRGADGET)
{ draw_3d(rp, gadget->LeftEdge, gadget->TopEdge,
gadget->Width, gadget->Height, -1L,(gadget->Flags==SELECTED|GADGHCOMP));
}
else /* string gadgets look different */
{ draw_3d(rp, gadget->LeftEdge-4, gadget->TopEdge-2,
gadget->Width+6, gadget->Height+2, -1L, TRUE);
draw_3d(rp, gadget->LeftEdge-6, gadget->TopEdge-3,
gadget->Width+10, gadget->Height+4, -1L, FALSE);
}
draw_3dgb(rp,gadget->NextGadget);
}
}
/*
* This stuff down here sets the gadget flags propperly.
*/
void set_gflags(struct Gadget *gadget, struct Window *window, USHORT flags)
{ SHORT pos= RemoveGadget(window, gadget);
RefreshGList(gadget, window, NULL, 1L); /* tricky! */
gadget->Flags= flags;
if(pos>=0) /* => we really removed the gadget */
AddGadget(window, gadget, pos);
RefreshGList(gadget, window, NULL, 1L);
}
void on_3dg(struct Gadget *gadget, struct Window *window)
{ struct RastPort *rp= window->RPort;
if(rp != NULL && gadget != NULL)
{ OnGadget(gadget, window, NULL); /* just to please intuition */
UWORD gflags= gadget->Flags&~GADGDISABLED; /* enable gadget selection */
set_gflags(gadget,window,gflags&~SELECTED); /* unselect it */
if(gadget->GadgetType != STRGADGET)
{ draw_3d(rp, gadget->LeftEdge, gadget->TopEdge,gadget->Width, gadget->Height,
0L,FALSE); /* FALSE since our gadget is *NOT* selected */
}
else /* string gadgets look different */
{ draw_3d(rp, gadget->LeftEdge-4, gadget->TopEdge-2,
gadget->Width+6, gadget->Height+2, 0L, TRUE);
draw_3d(rp, gadget->LeftEdge-6, gadget->TopEdge-3,
gadget->Width+10, gadget->Height+4, -1L, FALSE);
}
set_gflags(gadget,window,gflags); /* restore old selection state */
}
}