home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
514a.lha
/
TplEdit_v1.00_alpha
/
Src
/
region.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-08
|
2KB
|
120 lines
/*
* REGION.C
*/
#include "defs.h"
Prototype void UpdateTplRegion(TplRegion *);
Prototype TplRegion *AllocTplRegion(void);
Prototype void DeleteTplRegion(TplRegion *);
TplRegion *
AllocTplRegion()
{
TplRegion *rg = zalloc(sizeof(TplRegion));
NewList(&rg->rg_ListSet);
rg->rg_Id = ++IdNo;
rg->rg_TextAttr = *Scr->Font;
AddTail(&RegList, &rg->rg_Node);
return(rg);
}
void
UpdateTplRegion(rg)
TplRegion *rg;
{
if (rg->rg_Gad) {
GT_SetGadgetAttrs(rg->rg_Gad, Win, NULL,
GA_Disabled, 1,
TAG_END
);
}
if (NewType == RGT_ENTRY)
rg->rg_MaxBufLen = atoi(MaxName);
if (rg->rg_DefText)
free(rg->rg_DefText);
rg->rg_DefText = (DefName[0]) ? strdup(DefName) : (char *)NULL;
if (rg->rg_LabText)
free(rg->rg_LabText);
rg->rg_LabText = (LabName[0]) ? strdup(LabName) : (char *)NULL;
if (rg->rg_Node.ln_Name)
free(rg->rg_Node.ln_Name);
rg->rg_Node.ln_Name = strdup(RegName);
if (rg->rg_Gad && (rg->rg_Type == RGT_CYCLE || rg->rg_Type == RGT_SELLIST)) {
GT_SetGadgetAttrs(rg->rg_Gad, Win, NULL,
GTLV_Labels, -1,
TAG_END
);
}
{
MaxNode *mn;
while (mn = RemHead(&rg->rg_ListSet)) {
free(mn->ln_Name);
free(mn);
}
if (rg->rg_CycleAry) {
free(rg->rg_CycleAry);
rg->rg_CycleAry = NULL;
}
}
if (NewType == RGT_CYCLE || NewType == RGT_SELLIST) {
MaxNode *mn;
short cnt = 0;
for (mn = GetHead(&EList); mn; mn = GetSucc(mn)) {
AddNode(&rg->rg_ListSet, mn->ln_Name, 1);
++cnt;
}
rg->rg_CycleAry = zalloc(sizeof(char *) * (cnt + 1));
cnt = 0;
for (mn = GetHead(&rg->rg_ListSet); mn; mn = GetSucc(mn))
rg->rg_CycleAry[cnt++] = mn->ln_Name;
}
rg->rg_Flags = NewFlags;
rg->rg_Type = NewType;
}
void
DeleteTplRegion(rg)
TplRegion *rg;
{
Remove(&rg->rg_Node);
ClearLinks(rg);
if (rg->rg_Node.ln_Name)
free(rg->rg_Node.ln_Name);
if (rg->rg_Gad && (rg->rg_Type == RGT_CYCLE || rg->rg_Type == RGT_SELLIST)) {
GT_SetGadgetAttrs(rg->rg_Gad, Win, NULL,
GTLV_Labels, -1,
TAG_END
);
}
if (rg->rg_DataBase)
free(rg->rg_DataBase);
if (rg->rg_ListRef)
free(rg->rg_ListRef);
if (rg->rg_CycleAry)
free(rg->rg_CycleAry);
{
MaxNode *mn;
while (mn = RemHead(&rg->rg_ListSet)) {
free(mn->ln_Name);
free(mn);
}
}
if (rg->rg_DefText)
free(rg->rg_DefText);
if (rg->rg_LabText)
free(rg->rg_LabText);
free(rg);
SetCurRegion(NULL);
}