home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
514a.lha
/
TplEdit_v1.00_alpha
/
Src
/
gad.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-08
|
3KB
|
168 lines
/*
* GAD.C
*
* Gadget [re]construction
*/
#include "defs.h"
Prototype void ReMakeEverything(void);
Prototype Gadget *MakeGadget(TplRegion *, Gadget *);
Prototype Gadget *MakeAllGadgets(void);
Prototype void DisableGadgets(void);
Prototype void EnableGadgets(void);
Prototype short GadDisabled;
short GadDisabled;
void
ReMakeEverything()
{
MakeAllGadgets();
RefreshGList(GList, Win, NULL, -1);
GT_RefreshWindow(Win, NULL);
}
Gadget *
MakeAllGadgets()
{
TplRegion *rg;
Gadget *gad;
if (GList) {
if (Win) {
short cnt = 0;
for (gad = GList; gad; ++cnt, gad = gad->NextGadget) {
if (gad->GadgetType & GTYP_SYSGADGET)
break;
}
RemoveGList(Win, GList, cnt);
SetRast(Win->RPort, 0);
RefreshWindowFrame(Win);
}
FreeGadgets(GList);
GList = NULL;
}
if (gad = CreateContext(&GList)) {
if (DDebug)
printf("GLIST %08lx gad %08lx\n", GList, gad);
for (rg = GetHead(&RegList); rg; rg = GetSucc(&rg->rg_Node))
rg->rg_Flags &= ~RGF_DEFERED;
for (rg = GetHead(&RegList); rg; rg = GetSucc(&rg->rg_Node)) {
if (rg->rg_LockedTo && rg->rg_Type == RGT_SELLIST)
rg->rg_Flags |= RGF_DEFERED;
else
gad = MakeGadget(rg, gad);
}
for (rg = GetHead(&RegList); rg; rg = GetSucc(&rg->rg_Node)) {
if (rg->rg_Flags & RGF_DEFERED)
gad = MakeGadget(rg, gad);
}
}
if (Win) {
AddGList(Win, GList, 0, -1, NULL);
if (GadDisabled)
DisableGadgets();
}
return(gad);
}
Gadget *
MakeGadget(rg, gad)
TplRegion *rg;
Gadget *gad;
{
if (rg->rg_Type == 0)
return(gad);
Ng.ng_LeftEdge = rg->rg_Box.bo_Xs;
Ng.ng_TopEdge = rg->rg_Box.bo_Ys;
Ng.ng_Width = rg->rg_Box.bo_Xe - rg->rg_Box.bo_Xs + 1;
Ng.ng_Height = rg->rg_Box.bo_Ye - rg->rg_Box.bo_Ys + 1;
Ng.ng_GadgetText= rg->rg_LabText;
Ng.ng_TextAttr = &rg->rg_TextAttr;
Ng.ng_GadgetID = rg->rg_Id;
Ng.ng_Flags = rg->rg_Flags;
Ng.ng_UserData = rg;
if (Ng.ng_Width < 8 || Ng.ng_Height < 8) {
printf("Size Error %d %d\n", Ng.ng_Width, Ng.ng_Height);
return;
}
if (DDebug)
printf("TYPE %d\n", rg->rg_Type);
switch(rg->rg_Type) {
case RGT_INVISIBLE:
break;
case RGT_BUTTON:
rg->rg_Gad = CreateGadget(BUTTON_KIND, gad, &Ng,
TAG_END
);
break;
case RGT_ENTRY:
rg->rg_Gad = CreateGadget(STRING_KIND, gad, &Ng,
GTST_MaxChars, rg->rg_MaxBufLen,
GTST_String, rg->rg_DefText,
TAG_END
);
break;
case RGT_SELLIST:
rg->rg_Gad = CreateGadget(LISTVIEW_KIND, gad, &Ng,
GTLV_Labels, &rg->rg_ListSet,
GTLV_Selected, (rg->rg_DefText ? atoi(rg->rg_DefText) : 0),
((rg->rg_LockedTo) ? GTLV_ShowSelected : TAG_IGNORE), rg->rg_LockedTo->rg_Gad,
TAG_END
);
break;
case RGT_CYCLE:
rg->rg_Gad = CreateGadget(CYCLE_KIND, gad, &Ng,
GTCY_Labels, rg->rg_CycleAry,
GTCY_Active, (rg->rg_DefText ? atoi(rg->rg_DefText) : 0),
TAG_END
);
break;
default:
break;
}
return(rg->rg_Gad);
}
void
DisableGadgets()
{
TplRegion *rg;
GadDisabled = 1;
for (rg = GetHead(&RegList); rg; rg = GetSucc(&rg->rg_Node)) {
if (rg->rg_Gad) {
GT_SetGadgetAttrs(rg->rg_Gad, Win, NULL,
GA_Disabled, 1,
TAG_END
);
}
}
}
void
EnableGadgets()
{
TplRegion *rg;
GadDisabled = 0;
for (rg = GetHead(&RegList); rg; rg = GetSucc(&rg->rg_Node)) {
if (rg->rg_Gad) {
GT_SetGadgetAttrs(rg->rg_Gad, Win, NULL,
GA_Disabled, 0,
TAG_END
);
}
}
GT_RefreshWindow(Win, NULL);
}