home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD1.img
/
d1xx
/
d168
/
src
/
files
/
gadget.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-11-22
|
6KB
|
211 lines
/*
* GADGET.C
*
* (c)Copyright 1987 Matthew Dillon, All Rights Reserved.
*
*/
#include "files.h"
#define NI 0
static BORDER Bdr[10];
static ITEXT BText[] = {
{ 3,0,JAM2,1,0,NULL,(ubyte *)"info"},
{ 3,0,JAM2,1,0,NULL,(ubyte *)"del" },
{ 3,0,JAM2,1,0,NULL,(ubyte *)"undo"},
{ 3,0,JAM2,1,0,NULL,(ubyte *)"all" }
};
static ITEXT SText[] = {
{ 3,0,JAM2,NI,-2,NULL,(ubyte *)"Volume: " },
{ 3,0,JAM2,NI,-2,NULL,(ubyte *)"Pattern: " },
{ 3,0,JAM2,NI,-2,NULL,(ubyte *)"Comment: " }
};
ubyte Buf1_vol[128]; ubyte Buf2_vol[128];
ubyte Buf1_pat[128]; ubyte Buf2_pat[128];
ubyte Buf1_com[128]; ubyte Buf2_com[128];
STRINGINFO Si_vol = { Buf1_vol,Buf2_vol,0,sizeof(Buf1_vol),0,0,0,0,0,0 };
STRINGINFO Si_pat = { Buf1_pat,Buf2_pat,0,sizeof(Buf2_pat),0,0,0,0,0,0 };
STRINGINFO Si_com = { Buf1_com,Buf2_com,0,sizeof(Buf2_com),0,0,0,0,0,0 };
GADGET Gad_vol = { NULL , NI, 0, NI, NI, GADGHCOMP|GRELWIDTH,GADGIMMEDIATE|RELVERIFY,STRGADGET,NI,NULL,&SText[0],NULL,(APTR)&Si_vol };
GADGET Gad_pat = { &Gad_vol , NI, 1, NI, NI, GADGHCOMP|GRELWIDTH,GADGIMMEDIATE|RELVERIFY,STRGADGET,NI,NULL,&SText[1],NULL,(APTR)&Si_pat };
GADGET Gad_com = { &Gad_pat , NI, 2, NI, NI, GADGHCOMP|GRELWIDTH,GADGIMMEDIATE|RELVERIFY,STRGADGET,NI,NULL,&SText[2],NULL,(APTR)&Si_com };
GADGET Gad_info= { &Gad_com , 5 ,-15, NI, NI, GADGHCOMP|GRELBOTTOM,GADGIMMEDIATE|RELVERIFY,BOOLGADGET,NI,NULL,&BText[0] };
GADGET Gad_del = { &Gad_info , 50,-15, NI, NI, GADGHCOMP|GRELBOTTOM,GADGIMMEDIATE|RELVERIFY,BOOLGADGET,NI,NULL,&BText[1] };
GADGET Gad_undo= { &Gad_del ,-110,-15, NI, NI,GADGHCOMP|GRELRIGHT|GRELBOTTOM,GADGIMMEDIATE|RELVERIFY,BOOLGADGET,NI,NULL,&BText[2] };
GADGET Gad_all = { &Gad_undo , -50,-15, NI, NI, GADGHCOMP|GRELRIGHT|GRELBOTTOM,GADGIMMEDIATE|RELVERIFY,BOOLGADGET,NI,NULL,&BText[3] };
GADGET *FirstGadget = &Gad_all;
GADGET Gad_box = { NULL , NI, NI, NI, NI, GADGHNONE|GRELWIDTH|GRELHEIGHT,GADGIMMEDIATE|RELVERIFY|FOLLOWMOUSE,BOOLGADGET,NULL,NULL,NULL };
PROPINFO Prop_slid = { AUTOKNOB|FREEVERT, 0, 0, 0x30, 0x30 };
IMAGE Imag_slid = { 0,0,2,1,1,NULL,1,0,NULL };
GADGET Gad_slid = { NULL, -20, 12, 20, -30, GADGHCOMP|GRELHEIGHT|GRELRIGHT,GADGIMMEDIATE|RELVERIFY|RIGHTBORDER|FOLLOWMOUSE,PROPGADGET,(APTR)&Imag_slid,NULL,NULL,0,(APTR)&Prop_slid };
initslider(nw)
NW *nw;
{
nw->FirstGadget = &Gad_slid;
}
initstructs()
{
register short i;
register GADGET *gad;
for (i = 0; i < sizeof(Bdr)/sizeof(Bdr[0]); ++i) {
register BORDER *b = &Bdr[i];
register short *xy= malloc(5 * 2 * sizeof(short));
/*b->LeftEdge = b->TopEdge = -2;*/
b->FrontPen = 1;
b->DrawMode = JAM2;
b->Count = 5;
b->XY = xy;
bzero(xy, 5 * 2 * sizeof(short));
xy[2] = i * Win->RPort->TxWidth + 4;
xy[4] = xy[2];
xy[5] = Win->RPort->TxHeight + 2;
xy[7] = Win->RPort->TxHeight + 2;
}
for (i = 0; i < sizeof(SText)/sizeof(SText[0]); ++i) {
register ITEXT *it = &SText[i];
it->LeftEdge = -strlen(it->IText) * Win->RPort->TxWidth + 2;
it->TopEdge += 2;
}
for (i = 0; i < sizeof(BText)/sizeof(BText[0]); ++i) {
register ITEXT *it = &BText[i];
it->LeftEdge+= 2;
it->TopEdge += 2;
}
for (gad = FirstGadget; gad; gad = gad->NextGadget) {
register ubyte *str = gad->GadgetText->IText;
gad->Height = Win->RPort->TxHeight + 3;
gad->Width = strlen(str) * Win->RPort->TxWidth + 5;
if (gad->GadgetType == STRGADGET) {
gad->LeftEdge = Win->BorderLeft + strlen(str) * Win->RPort->TxWidth + 2;
gad->Width = -gad->LeftEdge - Win->BorderRight;
gad->TopEdge = gad->TopEdge * (Win->RPort->TxHeight + 2) + Win->BorderTop;
gad->GadgetText->LeftEdge = -strlen(str) * Win->RPort->TxWidth;
} else {
gad->GadgetRender = (APTR)&Bdr[strlen(str)];
}
}
Gad_box.LeftEdge= Win->BorderLeft;
Gad_box.TopEdge = Gad_com.TopEdge + Win->RPort->TxHeight + 2;
Gad_box.Width = -Gad_box.LeftEdge - Win->BorderRight;
Gad_box.Height = -Gad_box.TopEdge + Gad_undo.TopEdge - 2;
}
addgadgets()
{
register GADGET *gad, *ngad;
int i = 0;
initstructs(Win);
for (gad = FirstGadget; gad; gad = ngad) {
ngad = gad->NextGadget;
AddGadget(Win, gad, i);
++i;
}
AddGadget(Win, &Gad_box, i);
RefreshGList(FirstGadget, Win, NULL, -1);
}
remgadgets()
{
}
fixgadgets()
{
}
getgadget(im, sel, str)
IMESS *im;
short *sel;
ubyte **str;
{
GADGET *gad = (GADGET *)im->IAddress;
*sel = gad->Flags & SELECTED;
if (gad == &Gad_info) return(GAD_INFO);
if (gad == &Gad_del) return(GAD_DEL);
if (gad == &Gad_undo) return(GAD_UNDO);
if (gad == &Gad_all) return(GAD_ALL);
if (gad == &Gad_slid) return(GAD_SLIDER);
if (gad == &Gad_box) return(GAD_BIGBOX);
if (gad == &Gad_vol || gad == &Gad_pat || gad == &Gad_com) {
*str = ((STRINGINFO *)gad->SpecialInfo)->Buffer;
if (gad == &Gad_vol) return(GAD_VOLUME);
if (gad == &Gad_pat) return(GAD_PATTERN);
if (gad == &Gad_com) return(GAD_COMMENT);
}
return(0);
}
bigboxbounds(xs,xe,ys,ye)
short *xs,*xe,*ys,*ye;
{
*xs = Gad_box.LeftEdge;
*xe = *xs + Gad_box.Width + Win->Width;
*ys = Gad_box.TopEdge;
*ye = *ys + Gad_box.Height+ Win->Height;
if (*xe <= *xs)
*xe = *xs + 1;
if (*ye <= *ys)
*ye = *ys + 1;
}
getsliderpos(pot, full)
short *pot, *full;
{
*pot = Prop_slid.VertPot;
*full= Prop_slid.VertBody;
}
getboxpos(im)
IMESS *im;
{
return(im->MouseY - Gad_box.TopEdge);
}
setslider(pos, fatness)
{
NewModifyProp(&Gad_slid, Win, NULL, AUTOKNOB|FREEVERT,0,pos,0,fatness,1);
}
setcomment(str)
char *str;
{
strcpy(Buf1_com, str);
RefreshGList(&Gad_com, Win, NULL, 1);
}
activate_vol()
{
ActivateGadget(&Gad_vol, Win, NULL);
}
activate_pat()
{
ActivateGadget(&Gad_pat, Win, NULL);
}
activate_com()
{
ActivateGadget(&Gad_com, Win, NULL);
}