home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
594a.lha
/
maker_v0.1
/
itemlist.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-18
|
2KB
|
89 lines
#include "global.h"
#include <stdio.h>
#include <string.h>
#include <exec/memory.h>
#include <libraries/asl.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#include <proto/asl.h>
#include <proto/dos.h>
void WriteItems(USHORT code)
{
LinkNode *nodePtr;
USHORT itemNum, totItems;
char *cPtr, fileName[256];
FILE *filePtr;
totItems = NodeCount( (void **) &gObjList);
if (!totItems)
return;
if (!RequestFile(gFileRequest))
return;
strcpy(fileName, gFileRequest->rf_Dir);
if (!AddPart(fileName, gFileRequest->rf_File, 256))
{
printf("Error in file name\n");
return;
}
filePtr = fopen(fileName, "w");
if (!filePtr)
{
printf("Error: unable to open file '%s'\n");
return;
}
fprintf(filePtr, "Window is %d wide by %d high (%s)\n\n", gWindPtr->Width,
gWindPtr->Height, (gWindSizeable ? "Sizeable" : "Non-Sizeable") );
for (nodePtr=gObjList, itemNum=0; nodePtr; nodePtr=nodePtr->next, itemNum++)
{
fprintf(filePtr, "Item Number %2d (type is %s)\n", itemNum, gObjName[nodePtr->type]);
fprintf(filePtr, "\tLeft: %3d Top: %3d Width: %3d Height: %3d\n", nodePtr->rect.minX,
nodePtr->rect.minY, RectWidth(nodePtr->rect), RectHeight(nodePtr->rect) );
cPtr = GetItemText(nodePtr);
if (cPtr)
fprintf(filePtr, "\tLabel: %s PlaceText: %s\n", cPtr, gPlaceText[GetTextPlacement(nodePtr)] );
fprintf(filePtr, "\n");
}
fclose(filePtr);
}
char *GetItemText(LinkNode *nodePtr)
{
if (GetGadgetData(nodePtr, 0L, 0L, 0L, 0L, 0L ))
{
return ( (GadgetObj *) nodePtr)->label;
}
else if (nodePtr->type == OTYPE_IText)
{
return ( (ITextObj *) nodePtr)->label;
}
else
return 0L;
}
short GetTextPlacement(LinkNode *nodePtr)
{
short textPos;
textPos = ( (GadgetObj *) nodePtr )->flags & 0x1F;
if (textPos & PLACETEXT_LEFT)
textPos = 0;
else if (textPos & PLACETEXT_RIGHT)
textPos = 1;
else if (textPos & PLACETEXT_ABOVE)
textPos = 2;
else if (textPos & PLACETEXT_BELOW)
textPos = 3;
else
textPos = 4;
return textPos;
}