home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d534
/
term.lha
/
Term
/
Source.LZH
/
PhonePanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-07
|
38KB
|
1,331 lines
/* $Revision Header * Header built automatically - do not edit! *************
*
* (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
*
* Name .....: PhonePanel.c
* Created ..: Monday 21-Jan-91 20:12
* Revision .: 0
*
* Date Author Comment
* ========= ======== ====================
* 21-Jan-91 Olsen Created this file!
*
* $Revision Header ********************************************************/
#include "TermGlobal.h"
enum { GAD_NAME,GAD_NAMELIST,GAD_PHONENUMBER,GAD_PASSWORD,GAD_MACROFILE,
GAD_PAYUNIT1,GAD_MINUNIT1,GAD_STARTTIME1,GAD_PAYUNIT2,GAD_MINUNIT2,
GAD_STARTTIME2,GAD_SERIAL,GAD_MODEM,GAD_SCREEN,GAD_TERMINAL,
GAD_STARTUP,GAD_PATH,GAD_TRANSFER,GAD_UNUSED0,GAD_PLAY,
GAD_UNUSED2,GAD_UNUSED3,GAD_UNUSED4,GAD_DIAL,GAD_GET,GAD_NEW,
GAD_REMOVE,GAD_LOAD,GAD_SORT,GAD_SAVE };
enum { MEN_NEXT=1,MEN_PREV,MEN_LIST,MEN_WINDOW,MEN_SETSERIAL,MEN_SETMODEM,
MEN_SETSCREEN,MEN_SETTERMINAL,MEN_SETSTARTUP,
MEN_SETPATH,MEN_SETTRANSFER,MEN_PLAYNUMBER,MEN_DIALENTRY,MEN_GET,
MEN_NEWENTRY,MEN_REMENTRY,MEN_LOAD,MEN_SORT,MEN_SAVEPHONE,
MEN_QUITPANEL };
STATIC struct NewMenu PhoneMenu[] =
{
{ NM_TITLE, "Project", 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Next Entry", "N", 0, 0, (APTR)MEN_NEXT},
{ NM_ITEM, "Previous Entry", "P", 0, 0, (APTR)MEN_PREV},
{ NM_ITEM, "Insert Entry", "I", 0, 0, (APTR)MEN_LIST},
{ NM_ITEM, "Other Window", "W", 0, 0, (APTR)MEN_WINDOW},
{ NM_ITEM, NM_BARLABEL, 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Load", "L", 0, 0, (APTR)MEN_LOAD},
{ NM_ITEM, "Sort", "O", 0, 0, (APTR)MEN_SORT},
{ NM_ITEM, "Save", "S", 0, 0, (APTR)MEN_SAVEPHONE},
{ NM_ITEM, NM_BARLABEL, 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Quit", "Q", 0, 0, (APTR)MEN_QUITPANEL},
{ NM_TITLE, "Preferences", 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Serial...", "1", 0, 0, (APTR)MEN_SETSERIAL},
{ NM_ITEM, "Modem...", "2", 0, 0, (APTR)MEN_SETMODEM},
{ NM_ITEM, "Screen...", "3", 0, 0, (APTR)MEN_SETSCREEN},
{ NM_ITEM, "Terminal...", "4", 0, 0, (APTR)MEN_SETTERMINAL},
{ NM_ITEM, "Startup...", "5", 0, 0, (APTR)MEN_SETSTARTUP},
{ NM_ITEM, "Paths...", "6", 0, 0, (APTR)MEN_SETPATH},
{ NM_ITEM, "Transfer...", "7", 0, 0, (APTR)MEN_SETTRANSFER},
{ NM_TITLE, "Goodies", 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Play Number", "!", 0, 0, (APTR)MEN_PLAYNUMBER},
{ NM_ITEM, NM_BARLABEL, 0 , 0, 0, (APTR)0},
{ NM_ITEM, "Dial Entry", "D", 0, 0, (APTR)MEN_DIALENTRY},
{ NM_ITEM, "Get Settings", "G", 0, 0, (APTR)MEN_GET},
{ NM_ITEM, "New Entry", "E", 0, 0, (APTR)MEN_NEWENTRY},
{ NM_ITEM, "Remove Entry", "R", 0, 0, (APTR)MEN_REMENTRY},
{ NM_END, 0, 0 , 0, 0, (APTR)0}
};
#define WIDTH 640
#define HEIGHT 170
STATIC UBYTE * __saveds
ShowFraction(struct Gadget *SomeGadget,WORD Level)
{
STATIC UBYTE Buffer[6];
SPrintf(Buffer,"%ld.%02ld",Level / 100,Level % 100);
return(Buffer);
}
STATIC UBYTE * __saveds
ShowTime(struct Gadget *SomeGadget,WORD Level)
{
STATIC UBYTE Buffer[6];
SPrintf(Buffer,"%2ld.%02ld",Level / 60,Level % 60);
return(Buffer);
}
STATIC UBYTE * __saveds
ShowHour(struct Gadget *SomeGadget,WORD Level)
{
STATIC UBYTE Buffer[6];
SPrintf(Buffer,"%2ld:%02ld",Level / 6,(Level % 6) * 10);
return(Buffer);
}
STATIC struct Gadget *
CreateAllGadgets(struct Gadget **GadgetArray,struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD LeftEdge,Counter = 0,NewTopEdge;
if(Gadget = CreateContext(GadgetList))
{
NewGadget . ng_Width = 258;
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = "Name";
NewGadget . ng_TextAttr = &DefaultFont;
NewGadget . ng_VisualInfo = VisualInfo;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = NG_HIGHLABEL|PLACETEXT_LEFT;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 29,
TAG_DONE);
NewGadget . ng_Height = 44;
NewGadget . ng_GadgetText = " Name List";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = (strlen(NewGadget . ng_GadgetText) + 2) * 8 + 1;
NewGadget . ng_TopEdge = 1 + TopEdge;
GadgetArray[Counter++] = Gadget = CreateGadget(LISTVIEW_KIND,Gadget,&NewGadget,
GTLV_ShowSelected, Gadget,
TAG_DONE);
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = "Phone Number";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = GadgetArray[0] -> TopEdge + GadgetArray[0] -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 40,
TAG_DONE);
NewGadget . ng_GadgetText = "Password";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = NG_HIGHLABEL|PLACETEXT_LEFT;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 3;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 40,
TAG_DONE);
NewGadget . ng_GadgetText = "Macro File";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = NG_HIGHLABEL|PLACETEXT_LEFT;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 3;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
GTST_MaxChars, 40,
TAG_DONE);
LeftEdge = NewGadget . ng_LeftEdge;
NewTopEdge = Gadget -> TopEdge + Gadget -> Height + 4;
NewGadget . ng_GadgetText = "Pay/Unit (1) ";
NewGadget . ng_Width = 74;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = 1 + TopEdge;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 192;
GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
GTSL_Min, 0,
GTSL_Max, 500,
GTSL_DispFunc, ShowFraction,
GTSL_LevelFormat, "%s",
GTSL_MaxLevelLen, 4,
TAG_DONE);
NewGadget . ng_GadgetText = "Minutes/Unit (1) ";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 3;
GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
GTSL_Min, 0,
GTSL_Max, 1800,
GTSL_DispFunc, ShowTime,
GTSL_LevelFormat, "%s",
GTSL_MaxLevelLen, 5,
TAG_DONE);
NewGadget . ng_GadgetText = "Start Time (1) ";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 3;
GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
GTSL_Min, 0,
GTSL_Max, 143,
GTSL_DispFunc, ShowHour,
GTSL_LevelFormat, "%s",
GTSL_MaxLevelLen, 5,
TAG_DONE);
NewGadget . ng_GadgetText = "Pay/Unit (2) ";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 13;
GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
GTSL_Min, 0,
GTSL_Max, 500,
GTSL_DispFunc, ShowFraction,
GTSL_LevelFormat, "%s",
GTSL_MaxLevelLen, 4,
TAG_DONE);
NewGadget . ng_GadgetText = "Minutes/Unit (2) ";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 3;
GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
GTSL_Min, 0,
GTSL_Max, 1800,
GTSL_DispFunc, ShowTime,
GTSL_LevelFormat, "%s",
GTSL_MaxLevelLen, 5,
TAG_DONE);
NewGadget . ng_GadgetText = "Start Time (2) ";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 3;
GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
GTSL_Min, 0,
GTSL_Max, 143,
GTSL_DispFunc, ShowHour,
GTSL_LevelFormat, "%s",
GTSL_MaxLevelLen, 5,
TAG_DONE);
NewGadget . ng_GadgetText = "Serial _1";
NewGadget . ng_Width = 128;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = NG_HIGHLABEL;
NewGadget . ng_LeftEdge = LeftEdge;
NewGadget . ng_TopEdge = NewTopEdge;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "Modem _2";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "Screen _3";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "Terminal _4";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "Startup _5";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = LeftEdge;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "Paths _6";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "Transfer _7";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "-- Unused --";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
Gadget -> Flags |= GFLG_DISABLED;
NewGadget . ng_GadgetText = "Play Number_!";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = LeftEdge;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "-- Unused --";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
Gadget -> Flags |= GFLG_DISABLED;
NewGadget . ng_GadgetText = "-- Unused --";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
Gadget -> Flags |= GFLG_DISABLED;
NewGadget . ng_GadgetText = "-- Unused --";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
TAG_DONE);
Gadget -> Flags |= GFLG_DISABLED;
NewGadget . ng_GadgetText = "_Dial";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
NewGadget . ng_LeftEdge = LeftEdge;
NewGadget . ng_TopEdge = Gadget -> TopEdge + Gadget -> Height + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "_Get Settings";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "New _Entry";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "_Remove Entry";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = Gadget -> LeftEdge + Gadget -> Width + 2;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_Width = 52;
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = "_Load";
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 = "S_ort";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = (WIDTH - NewGadget . ng_Width) >> 1;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = "_Save";
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = WIDTH - 9 - NewGadget . ng_Width;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
DubGadList(GadgetArray[0]);
}
return(Gadget);
}
struct List *
PhonePanel(LONG *NumCalls)
{
STATIC WORD OffsetX = -1,OffsetY = -1;
struct Window *PanelWindow;
struct Menu *PanelMenu;
struct Gadget *GadgetList;
struct Gadget *GadgetArray[GAD_SAVE + 1];
ULONG Sec1,Mic1,Sec2,Mic2;
LONG HitItem = -1;
if(CreateAllGadgets(&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
{
if(PanelMenu = CreateMenus(PhoneMenu,
GTMN_FrontPen, 0,
TAG_DONE))
{
if(LayoutMenus(PanelMenu,VisualInfo,
GTMN_TextAttr,&DefaultFont,
TAG_DONE))
{
if(OffsetX == -1)
OffsetX = (Screen -> Width - WIDTH) >> 1;
if(OffsetY == -1)
OffsetY = (Screen -> Height - HEIGHT) >> 1;
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, OffsetX,
WA_Top, OffsetY,
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, "Phonebook",
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG Class,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
ULONG Mask;
UBYTE DummyBuffer[256],*DummyChar;
LONG Selected = ~0;
struct List *PhoneList = NULL;
struct FileRequest *FileRequest;
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;
if(Phonebook && NumPhoneEntries)
{
if(PhoneList = CreatePhoneList())
{
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,~0,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,PhoneList,
TAG_DONE);
}
}
if(SubList)
OpenSubWindow();
ActivateGadget(GadgetArray[GAD_NAME],PanelWindow,NULL);
ActiveGadget = GadgetArray[GAD_NAME];
while(!Terminated)
{
OuterLoop: Mask = (1 << PanelWindow -> UserPort -> mp_SigBit);
if(SubWindow)
Mask |= (1 << SubWindow -> UserPort -> mp_SigBit);
Wait(Mask);
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_GADGETDOWN)
{
if((Gadget -> GadgetType & GTYP_GTYPEMASK) == STRGADGET)
ActiveGadget = Gadget;
}
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_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_NEXT: if(NumPhoneEntries)
{
if(Selected == ~0)
Selected = 0;
else
{
if(Selected == NumPhoneEntries - 1)
Selected = 0;
else
Selected++;
}
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Selected,Selected,
TAG_DONE);
Code = Selected;
HitItem = -1;
goto SelectEntry;
}
break;
case MEN_PREV: if(NumPhoneEntries)
{
if(Selected == ~0)
Selected = 0;
else
{
if(Selected == 0)
Selected = NumPhoneEntries - 1;
else
Selected--;
}
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Selected,Selected,
TAG_DONE);
Code = Selected;
HitItem = -1;
goto SelectEntry;
}
break;
case MEN_LIST: if(Selected != ~0)
{
Code = HitItem = Selected;
CurrentTime(&Sec1,&Mic1);
goto SelectEntry;
}
break;
case MEN_WINDOW: if(SubWindow)
{
WindowToFront(SubWindow);
ActivateWindow(SubWindow);
}
break;
case MEN_SETSERIAL: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_SERIAL];
break;
case MEN_SETMODEM: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_MODEM];
break;
case MEN_SETSCREEN: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_SCREEN];
break;
case MEN_SETTERMINAL: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_TERMINAL];
break;
case MEN_SETSTARTUP: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_STARTUP];
break;
case MEN_SETPATH: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_PATH];
break;
case MEN_SETTRANSFER: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_TRANSFER];
break;
case MEN_PLAYNUMBER: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_PLAY];
break;
case MEN_DIALENTRY: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_DIAL];
break;
case MEN_NEWENTRY: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_NEW];
break;
case MEN_GET: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_GET];
break;
case MEN_REMENTRY: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_REMOVE];
break;
case MEN_LOAD: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_LOAD];
break;
case MEN_SORT: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_SORT];
break;
case MEN_SAVEPHONE: Class = IDCMP_GADGETUP;
Gadget = GadgetArray[GAD_SAVE];
break;
default: break;
}
Code = MenuItem -> NextSelect;
}
if(ActiveGadget)
ActivateGadget(ActiveGadget,PanelWindow,NULL);
}
if(Class == IDCMP_CLOSEWINDOW)
{
CloseSubWindow();
FreeSubList();
Terminated = TRUE;
}
if(Class == IDCMP_MOUSEMOVE && Selected != ~0)
{
switch(Gadget -> GadgetID)
{
case GAD_PAYUNIT1: Phonebook[Selected] -> PayPerUnit[0] = Code;
break;
case GAD_MINUNIT1: Phonebook[Selected] -> SecPerUnit[0] = Code;
break;
case GAD_STARTTIME1: Phonebook[Selected] -> TimeOfDay[0] = Code;
break;
case GAD_PAYUNIT2: Phonebook[Selected] -> PayPerUnit[1] = Code;
break;
case GAD_MINUNIT2: Phonebook[Selected] -> SecPerUnit[1] = Code;
break;
case GAD_STARTTIME2: Phonebook[Selected] -> TimeOfDay[1] = Code;
break;
default: break;
}
}
if(Class == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case GAD_PLAY:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
if(!ToneDial(Phonebook[Selected] -> Number))
MyEasyRequest(NULL,"term has a problem:\n%s!","Continue","Failed to allocate resources for playing.");
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_NAMELIST:
SelectEntry: if(HitItem != Code)
{
HitItem = Code;
CurrentTime(&Sec1,&Mic1);
}
else
{
CurrentTime(&Sec2,&Mic2);
if(DoubleClick(Sec1,Mic1,Sec2,Mic2))
{
HitItem = -1;
if(!SubWindow)
OpenSubWindow();
AddSubEntry(Code);
}
Sec1 = Sec2;
Mic1 = Mic2;
}
GT_SetGadgetAttrs(GadgetArray[GAD_PHONENUMBER],PanelWindow,NULL,
GTST_String,Phonebook[Code] -> Number,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PASSWORD],PanelWindow,NULL,
GTST_String,Phonebook[Code] -> Password,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MACROFILE],PanelWindow,NULL,
GTST_String,Phonebook[Code] -> Config . MacroFile,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PAYUNIT1],PanelWindow,NULL,
GTSL_Level,Phonebook[Code] -> PayPerUnit[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MINUNIT1],PanelWindow,NULL,
GTSL_Level,Phonebook[Code] -> SecPerUnit[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_STARTTIME1],PanelWindow,NULL,
GTSL_Level,Phonebook[Code] -> TimeOfDay[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PAYUNIT2],PanelWindow,NULL,
GTSL_Level,Phonebook[Code] -> PayPerUnit[1],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MINUNIT2],PanelWindow,NULL,
GTSL_Level,Phonebook[Code] -> SecPerUnit[1],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_STARTTIME2],PanelWindow,NULL,
GTSL_Level,Phonebook[Code] -> TimeOfDay[1],
TAG_DONE);
Selected = Code;
break;
case GAD_DIAL: if(SubWindow && Selected != ~0)
{
CloseSubWindow();
FreeSubList();
}
if(Selected != ~0)
{
if(SubList = (struct List *)AllocMem(sizeof(struct List),MEMF_PUBLIC | MEMF_CLEAR))
{
struct PhoneNode *SubNode;
NewList(SubList);
if(SubNode = (struct PhoneNode *)AllocMem(sizeof(struct PhoneNode),MEMF_PUBLIC|MEMF_CLEAR))
{
SubNode -> VanillaNode . ln_Name = Phonebook[Selected] -> Name;
SubNode -> Entry = Phonebook[Selected];
SubNode -> Number = Selected;
SubListNum = 1;
AddTail(SubList,&SubNode -> VanillaNode);
Terminated = TRUE;
}
else
{
FreeMem(SubList,sizeof(struct List));
SubList = NULL;
}
}
}
break;
case GAD_GET: if(Selected != ~0)
Phonebook[Selected] -> Config = Config;
break;
case GAD_NEW: GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,~0,
TAG_DONE);
if(PhoneList)
{
DeletePhoneList(PhoneList);
PhoneList = NULL;
}
if(NewPhoneEntry())
{
if(PhoneList = CreatePhoneList())
{
Selected = NumPhoneEntries - 1;
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,PhoneList,
GTLV_Selected,Selected,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PHONENUMBER],PanelWindow,NULL,
GTST_String,Phonebook[Selected] -> Number,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PASSWORD],PanelWindow,NULL,
GTST_String,Phonebook[Selected] -> Password,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MACROFILE],PanelWindow,NULL,
GTST_String,Phonebook[Selected] -> Config . MacroFile,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PAYUNIT1],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> PayPerUnit[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MINUNIT1],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> SecPerUnit[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_STARTTIME1],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> TimeOfDay[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PAYUNIT2],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> PayPerUnit[1],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MINUNIT2],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> SecPerUnit[1],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_STARTTIME2],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> TimeOfDay[1],
TAG_DONE);
}
else
goto ClearList;
}
else
goto ClearList;
break;
case GAD_REMOVE:if(!SubWindow)
{
if(Selected != ~0)
{
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,~0,
TAG_DONE);
if(PhoneList)
{
DeletePhoneList(PhoneList);
PhoneList = NULL;
}
RemPhoneEntry(Selected);
if(NumPhoneEntries > 0)
{
if(PhoneList = CreatePhoneList())
{
if(Selected == NumPhoneEntries)
Selected--;
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,PhoneList,
GTLV_Selected,Selected,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PHONENUMBER],PanelWindow,NULL,
GTST_String,Phonebook[Selected] -> Number,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PASSWORD],PanelWindow,NULL,
GTST_String,Phonebook[Selected] -> Password,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MACROFILE],PanelWindow,NULL,
GTST_String,Phonebook[Selected] -> Config . MacroFile,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PAYUNIT1],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> PayPerUnit[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MINUNIT1],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> SecPerUnit[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_STARTTIME1],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> TimeOfDay[0],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PAYUNIT2],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> PayPerUnit[1],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MINUNIT2],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> SecPerUnit[1],
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_STARTTIME2],PanelWindow,NULL,
GTSL_Level,Phonebook[Selected] -> TimeOfDay[1],
TAG_DONE);
}
else
goto ClearList;
}
else
{
ClearList: GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,&EmptyList,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PHONENUMBER],PanelWindow,NULL,
GTST_String,NULL,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PASSWORD],PanelWindow,NULL,
GTST_String,NULL,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MACROFILE],PanelWindow,NULL,
GTST_String,NULL,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_PAYUNIT1],PanelWindow,NULL,
GTIN_Number,NULL,
TAG_DONE);
GT_SetGadgetAttrs(GadgetArray[GAD_MINUNIT1],PanelWindow,NULL,
GTIN_Number,NULL,
TAG_DONE);
Selected = ~0;
}
}
}
break;
case GAD_NAME: if(Selected != ~0)
{
strcpy(Phonebook[Selected] -> Name,((struct StringInfo *)GadgetArray[GAD_NAME] -> SpecialInfo) -> Buffer);
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,~0,
TAG_DONE);
if(PhoneList)
DeletePhoneList(PhoneList);
if(PhoneList = CreatePhoneList())
{
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,PhoneList,
GTLV_Selected,Selected,
TAG_DONE);
}
}
break;
case GAD_PHONENUMBER:
if(Selected != ~0)
strcpy(Phonebook[Selected] -> Number,((struct StringInfo *)GadgetArray[GAD_PHONENUMBER] -> SpecialInfo) -> Buffer);
break;
case GAD_PASSWORD:
if(Selected != ~0)
strcpy(Phonebook[Selected] -> Password,((struct StringInfo *)GadgetArray[GAD_PASSWORD] -> SpecialInfo) -> Buffer);
break;
case GAD_MACROFILE:
if(Selected != ~0)
strcpy(Phonebook[Selected] -> Config . MacroFile,((struct StringInfo *)GadgetArray[GAD_MACROFILE] -> SpecialInfo) -> Buffer);
break;
case GAD_SERIAL:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
SerialPanel(&Phonebook[Selected] -> Config);
ActiveGadget = GadgetArray[GAD_NAME];
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_MODEM:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
ModemPanel(&Phonebook[Selected] -> Config);
ActiveGadget = GadgetArray[GAD_NAME];
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_SCREEN:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
LoadRGB4(VPort,&Phonebook[Selected] -> Config . Colours[0],(1 << Screen -> RastPort . BitMap -> Depth));
ScreenPanel(&Phonebook[Selected] -> Config);
ActiveGadget = GadgetArray[GAD_NAME];
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
LoadRGB4(VPort,&Config . Colours[0],(1 << Screen -> RastPort . BitMap -> Depth));
}
break;
case GAD_TERMINAL:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
TerminalPanel(&Phonebook[Selected] -> Config);
ActiveGadget = GadgetArray[GAD_NAME];
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_STARTUP:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
xpr_gets("Enter Startup (Login) Macro",&Phonebook[Selected] -> Config . StartupMacro[0]);
ActiveGadget = GadgetArray[GAD_NAME];
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_PATH:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
PathPanel(&Phonebook[Selected] -> Config);
ActiveGadget = GadgetArray[GAD_NAME];
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_TRANSFER:
if(Selected != ~0)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
strcpy(DummyBuffer,LastXprLibrary);
strcpy(LastXprLibrary,Phonebook[Selected] -> Config . Protocol);
xpr_options(0,NULL);
ActiveGadget = GadgetArray[GAD_NAME];
strcpy(Phonebook[Selected] -> Config . Protocol,LastXprLibrary);
strcpy(LastXprLibrary,DummyBuffer);
NewLibrary = FALSE;
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_LOAD: strcpy(DummyBuffer,LastPhone);
DummyChar = PathPart(DummyBuffer);
*DummyChar = 0;
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
if(FileRequest = GetFile("Load Phonebook...",DummyBuffer,FilePart(LastPhone),DummyBuffer,"#?.term",FALSE,FALSE))
{
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,~0,
TAG_DONE);
if(PhoneList)
DeletePhoneList(PhoneList);
PhoneList = NULL;
if(!LoadPhonebook(DummyBuffer))
MyEasyRequest(Window,"Couldn't load phonebook\n\"%s\"!","Continue",DummyBuffer);
if(PhoneList = CreatePhoneList())
{
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,PhoneList,
GTLV_Selected,~0,
TAG_DONE);
CloseSubWindow();
FreeSubList();
}
Selected = ~0;
}
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
break;
case GAD_SORT: if(NumPhoneEntries > 1 && !SubWindow)
{
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,~0,
TAG_DONE);
if(PhoneList)
DeletePhoneList(PhoneList);
SortPhoneEntries();
if(PhoneList = CreatePhoneList())
{
GT_SetGadgetAttrs(GadgetArray[GAD_NAMELIST],PanelWindow,NULL,
GTLV_Labels,PhoneList,
GTLV_Selected,~0,
TAG_DONE);
}
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
case GAD_SAVE: if(NumPhoneEntries)
{
strcpy(DummyBuffer,LastPhone);
DummyChar = PathPart(DummyBuffer);
*DummyChar = 0;
SetWait(PanelWindow);
PanelWindow -> Flags |= WFLG_RMBTRAP;
if(FileRequest = GetFile("Save Phonebook...",DummyBuffer,FilePart(LastPhone),DummyBuffer,"#?.term",TRUE,FALSE))
{
if(!SavePhonebook(DummyBuffer))
MyEasyRequest(Window,"Couldn't create phonebook\n\"%s\"!","Continue",DummyBuffer);
}
ClearPointer(PanelWindow);
PanelWindow -> Flags &= ~WFLG_RMBTRAP;
}
break;
default: break;
}
}
}
switch(HandleSubWindow(PanelWindow))
{
case 1: Terminated = TRUE;
break;
case 2: CloseSubWindow();
FreeSubList();
break;
default: break;
}
}
DeleteTone();
if(PhoneList)
DeletePhoneList(PhoneList);
CloseSubWindow();
PanelWindow -> Flags |= WFLG_RMBTRAP;
ClearMenuStrip(PanelWindow);
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
OffsetX = PanelWindow -> LeftEdge;
OffsetY = PanelWindow -> TopEdge;
CloseWindow(PanelWindow);
}
FreeMenus(PanelMenu);
}
}
FreeGadgets(GadgetList);
}
*NumCalls = SubListNum;
return(SubList);
}