home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d534
/
term.lha
/
Term
/
Source.LZH
/
PathPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-06
|
17KB
|
514 lines
/* $Revision Header * Header built automatically - do not edit! *************
*
* (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
*
* Name .....: PathPanel.c
* Created ..: Sunday 24-Mar-91 10:17
* Revision .: 0
*
* Date Author Comment
* ========= ======== ====================
* 24-Mar-91 Olsen Created this file!
*
* $Revision Header ********************************************************/
#include "TermGlobal.h"
enum { GAD_CONFIGSTORE,GAD_SELECT1,GAD_TUPLOAD,GAD_SELECT2,GAD_TDOWNLOAD,
GAD_SELECT3,GAD_AUPLOAD,GAD_SELECT4,GAD_ADOWNLOAD,GAD_SELECT5,
GAD_BUPLOAD,GAD_SELECT6,GAD_BDOWNLOAD,GAD_SELECT7,GAD_CAPTURE,
GAD_SELECT8,GAD_LOG,GAD_SELECT9,GAD_EDITOR,GAD_SELECT10,GAD_BEEP,
GAD_SELECT11,GAD_USE,GAD_CANCEL };
#define WIDTH 594
#define HEIGHT 171
enum { MEN_USE,MEN_CANCEL,MEN_QUITPANEL };
STATIC struct NewMenu PathMenu[] =
{
{ NM_TITLE, "Project", 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Use", "U", 0, 0, (APTR)MEN_USE},
{ NM_ITEM, "Cancel", "C", 0, 0, (APTR)MEN_CANCEL},
{ NM_ITEM, NM_BARLABEL, 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Quit", "Q", 0, 0, (APTR)MEN_QUITPANEL},
{ NM_END, 0, 0 , 0, 0, (APTR)0}
};
STATIC UBYTE *SelectText[] =
{
"Select Config Storage Directory...",
"Select Default Text Upload Path...",
"Select Default Text Download Path...",
"Select Default ASCII Upload Path...",
"Select Default ASCII Download Path...",
"Select Default Binary Upload Path...",
"Select Default Binary Download Path...",
"Select Default Capture Path...",
"Select Default Log File...",
"Select Default Text Editor...",
"Select Terminal `Beep' Sound..."
};
STATIC struct Gadget *
CreateAllGadgets(struct Configuration *Config,struct Gadget *GadgetArray[],struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter = 0;
if(Gadget = CreateContext(GadgetList))
{
NewGadget . ng_Width = 264;
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = "Configuration Storage Directory";
NewGadget . ng_TextAttr = &DefaultFont;
NewGadget . ng_VisualInfo = VisualInfo;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = NG_HIGHLABEL;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = 1 + TopEdge;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> DefaultStorage,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default Text Upload Path";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> TextUploadPath,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default Text Download Path";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> TextDownloadPath,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default ASCII Upload Path";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> ASCIIUploadPath,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default ASCII Download Path";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> ASCIIDownloadPath,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default Binary Upload Path";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> BinaryUploadPath,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default Binary Download Path";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> BinaryDownloadPath,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default Capture Path";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> CapturePath,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default Log File";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> LogFile,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Default Text Editor";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> Editor,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_GadgetText = "Terminal `Beep' Sound";
NewGadget . ng_Width = 264;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = 266;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 256,
GTST_String, Config -> BeepSound,
TAG_DONE);
NewGadget . ng_GadgetText = "Select";
NewGadget . ng_Width = 52;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 8;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
NewGadget . ng_Width = 52;
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = "_Use";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
NewGadget . ng_LeftEdge = 10;
NewGadget . ng_TopEdge = HEIGHT - 3 - NewGadget . ng_Height;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "_Cancel";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = WIDTH - 10 - NewGadget . ng_Width;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
}
DubGadList(GadgetArray[0]);
return(Gadget);
}
BYTE
PathPanel(struct Configuration *Config)
{
struct Window *PanelWindow;
struct Menu *PanelMenu;
struct Gadget *GadgetList;
struct Gadget *GadgetArray[GAD_CANCEL + 1];
CopyMem(Config,&PrivateConfig,sizeof(struct Configuration));
if(CreateAllGadgets(Config,&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
{
if(PanelMenu = CreateMenus(PathMenu,
GTMN_FrontPen, 0,
TAG_DONE))
{
if(LayoutMenus(PanelMenu,VisualInfo,
GTMN_TextAttr,&DefaultFont,
TAG_DONE))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, (Screen -> Width - WIDTH) >> 1,
WA_Top, (Screen -> Height - HEIGHT) >> 1,
WA_Width, WIDTH,
WA_Height, HEIGHT,
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Screen,
WA_IDCMP, IDCMP_GADGETDOWN | IDCMP_ACTIVEWINDOW | IDCMP_CLOSEWINDOW | SLIDERIDCMP | CHECKBOXIDCMP | LISTVIEWIDCMP | IDCMP_MENUPICK | IDCMP_RAWKEY,
WA_Title, "Path Preferences",
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG Class,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
SetMenuStrip(PanelWindow,PanelMenu);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
ActivateGadget(GadgetArray[GAD_CONFIGSTORE],PanelWindow,NULL);
ActiveGadget = GadgetArray[GAD_CONFIGSTORE];
while(!Terminated)
{
WaitPort(PanelWindow -> UserPort);
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
Class = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
if(Class == IDCMP_ACTIVEWINDOW && ActiveGadget)
ActivateGadget(ActiveGadget,PanelWindow,NULL);
if(Class == IDCMP_RAWKEY)
{
if(Code == IECODE_UP_PREFIX|103 && CommandWindow == PanelWindow)
ActivateGadget(CommandGadget,PanelWindow,NULL);
}
if(Class == IDCMP_GADGETDOWN)
{
if((Gadget -> GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET)
ActiveGadget = Gadget;
}
if(Class == IDCMP_MENUPICK)
{
struct MenuItem *MenuItem;
while(Code != MENUNULL)
{
MenuItem = ItemAddress(PanelMenu,Code);
switch((ULONG)MENU_USERDATA(MenuItem))
{
case MEN_QUITPANEL: Class = IDCMP_CLOSEWINDOW;
break;
case MEN_USE: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_USE];
break;
case MEN_CANCEL: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_CANCEL];
break;
default: break;
}
Code = MenuItem -> NextSelect;
}
}
if(Class == IDCMP_CLOSEWINDOW)
Terminated = TRUE;
GadCheck: if(Class == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case GAD_USE: Terminated = TRUE;
strcpy(Config -> DefaultStorage,((struct StringInfo *)GadgetArray[GAD_CONFIGSTORE] -> SpecialInfo) -> Buffer);
strcpy(Config -> TextUploadPath,((struct StringInfo *)GadgetArray[GAD_TUPLOAD] -> SpecialInfo) -> Buffer);
strcpy(Config -> TextDownloadPath,((struct StringInfo *)GadgetArray[GAD_TDOWNLOAD] -> SpecialInfo) -> Buffer);
strcpy(Config -> ASCIIUploadPath,((struct StringInfo *)GadgetArray[GAD_AUPLOAD] -> SpecialInfo) -> Buffer);
strcpy(Config -> ASCIIDownloadPath,((struct StringInfo *)GadgetArray[GAD_ADOWNLOAD] -> SpecialInfo) -> Buffer);
strcpy(Config -> BinaryUploadPath,((struct StringInfo *)GadgetArray[GAD_BUPLOAD] -> SpecialInfo) -> Buffer);
strcpy(Config -> BinaryDownloadPath,((struct StringInfo *)GadgetArray[GAD_BDOWNLOAD] -> SpecialInfo) -> Buffer);
strcpy(Config -> CapturePath,((struct StringInfo *)GadgetArray[GAD_CAPTURE] -> SpecialInfo) -> Buffer);
strcpy(Config -> LogFile,((struct StringInfo *)GadgetArray[GAD_LOG] -> SpecialInfo) -> Buffer);
strcpy(Config -> Editor,((struct StringInfo *)GadgetArray[GAD_EDITOR] -> SpecialInfo) -> Buffer);
strcpy(Config -> BeepSound,((struct StringInfo *)GadgetArray[GAD_BEEP] -> SpecialInfo) -> Buffer);
break;
case GAD_CANCEL: Terminated = TRUE;
CopyMem(&PrivateConfig,Config,sizeof(struct Configuration));
break;
default: if(Gadget -> GadgetID & 1)
{
UBYTE DummyBuffer[256],*DummyChar;
struct FileRequester *FileRequest;
LONG Selection = (Gadget -> GadgetID - 1);
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
strcpy(DummyBuffer,((struct StringInfo *)GadgetArray[Selection] -> SpecialInfo) -> Buffer);
if(Gadget -> GadgetID >= GAD_SELECT9)
{
if(DummyBuffer[0])
{
DummyChar = FilePart(DummyBuffer);
*DummyChar = 0;
DummyChar = FilePart(((struct StringInfo *)GadgetArray[Selection] -> SpecialInfo) -> Buffer);
}
else
DummyChar = "";
}
else
DummyChar = "";
if(FileRequest = GetFile(SelectText[Selection >> 1],DummyBuffer,DummyChar,DummyBuffer,NULL,FALSE,FALSE))
{
GT_SetGadgetAttrs(GadgetArray[Selection],PanelWindow,NULL,
GTST_String,(Gadget -> GadgetID < GAD_SELECT9 ? FileRequest -> rf_Dir : DummyBuffer),
TAG_DONE);
FreeAslRequest(FileRequest);
}
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
}
}
}
}
PanelWindow -> Flags |= WFLG_RMBTRAP;
ClearMenuStrip(PanelWindow);
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
CloseWindow(PanelWindow);
}
}
FreeMenus(PanelMenu);
}
FreeGadgets(GadgetList);
}
return((BYTE)strcmp(Config -> BeepSound,PrivateConfig . BeepSound));
}