home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * Source machine generated by GadToolsBox V2.0b
- * which is (c) Copyright 1991-1993 Jaba Development
- *
- * GUI Designed by : Martin W Scott and Gaƫl Marziou
- */
-
-
-
-
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <intuition/classes.h>
- #include <intuition/classusr.h>
- #include <intuition/imageclass.h>
- #include <intuition/gadgetclass.h>
- #include <intuition/intuitionbase.h>
- #include <libraries/gadtools.h>
- #include <graphics/displayinfo.h>
- #include <graphics/gfxbase.h>
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/gadtools.h>
- #include <proto/graphics.h>
- #include <proto/locale.h>
- #include <proto/utility.h>
- #include <string.h>
-
-
- #include "code.h"
- #include "version.h"
- #include "hotkey_types.h"
- #include "yak.h"
- #include "gui.h"
-
- #define CATCOMP_NUMBERS
- #include "locale/yak_locale_strings.h"
-
-
- IMPORT struct Catalog *Catalog;
-
- extern LONG (*HandleIDCMP)(void);
-
- struct Window *HotKeyWnd = NULL;
- struct Gadget *HotKeyGList = NULL;
- struct Gadget *HotKeyGadgets[HotKey_CNT];
- UWORD HotKeyLeft = 0;
- UWORD HotKeyWidth = 530;
- UWORD HotKeyHeight = 159;
- UBYTE *HotKeyWdt = NULL;
-
- WORD HotkeysTop=0;
- WORD ActionsTop=0;
-
- UBYTE *Options1Labels[4];
-
- VOID
- InitOptions1Label()
- {
- Options1Labels[0] = getString(NO_SCREEN_CHANGE_STRING);
- Options1Labels[1] = getString(WORKBENCH_TO_FRONT_STRING);
- Options1Labels[2] = getString(DEFAULT_PUBSCR_TO_FRONT_STRING);
- Options1Labels[3] = NULL;
- }
-
-
- IMPORT struct MinList Actions1List;
-
- struct Node Actions1Nodes[] =
- {
- &Actions1Nodes[1] ,(struct Node *)&Actions1List.mlh_Head,0,0,NULL,
- &Actions1Nodes[2] ,&Actions1Nodes[0] ,0,0,NULL,
- &Actions1Nodes[3] ,&Actions1Nodes[1] ,0,0,NULL,
- &Actions1Nodes[4] ,&Actions1Nodes[2] ,0,0,NULL,
- &Actions1Nodes[5] ,&Actions1Nodes[3] ,0,0,NULL,
- &Actions1Nodes[6] ,&Actions1Nodes[5] ,0,0,NULL,
- &Actions1Nodes[7] ,&Actions1Nodes[6] ,0,0,NULL,
- &Actions1Nodes[8] ,&Actions1Nodes[7] ,0,0,NULL,
- &Actions1Nodes[9] ,&Actions1Nodes[8] ,0,0,NULL,
- &Actions1Nodes[10],&Actions1Nodes[9] ,0,0,NULL,
- &Actions1Nodes[11],&Actions1Nodes[10],0,0,NULL,
- &Actions1Nodes[12],&Actions1Nodes[11],0,0,NULL,
- &Actions1Nodes[13],&Actions1Nodes[12],0,0,NULL,
- &Actions1Nodes[14],&Actions1Nodes[13],0,0,NULL,
- &Actions1Nodes[15],&Actions1Nodes[14],0,0,NULL,
- &Actions1Nodes[16],&Actions1Nodes[15],0,0,NULL,
- &Actions1Nodes[17],&Actions1Nodes[16],0,0,NULL,
- (struct Node *)&Actions1List.mlh_Tail,&Actions1Nodes[16],0,0,NULL
- };
-
- VOID
- InitActions1Nodes()
- {
- Actions1Nodes[0].ln_Name = getString(DOS_Command_ACT);
- Actions1Nodes[1].ln_Name = getString(Close_Window_ACT);
- Actions1Nodes[2].ln_Name = getString(Zip_Window_ACT);
- Actions1Nodes[3].ln_Name = getString(Shrink_Window_ACT);
- Actions1Nodes[4].ln_Name = getString(Expand_Window_ACT);
- Actions1Nodes[5].ln_Name = getString(Cycle_Windows_ACT);
- Actions1Nodes[6].ln_Name = getString(Open_Palette_ACT);
- Actions1Nodes[7].ln_Name = getString(Screen_to_Front_ACT);
- Actions1Nodes[8].ln_Name = getString(Screen_to_Back_ACT);
- Actions1Nodes[9].ln_Name = getString(Activate_Workbench_ACT);
- Actions1Nodes[10].ln_Name = getString(Centre_Screen_ACT);
- Actions1Nodes[11].ln_Name = getString(Blank_Display_ACT);
- Actions1Nodes[12].ln_Name = getString(Insert_Text_ACT);
- Actions1Nodes[13].ln_Name = getString(Insert_Date_ACT);
- Actions1Nodes[14].ln_Name = getString(Show_Yak_Interface_ACT);
- Actions1Nodes[15].ln_Name = getString(Back_Cycle_Windows_ACT);
- Actions1Nodes[16].ln_Name = getString(SetDefaultPublicScreen);
- Actions1Nodes[17].ln_Name = getString(MenuShortcut);
- }
-
- struct MinList Actions1List = {
- (struct MinNode *)&Actions1Nodes[0],
- (struct MinNode *)NULL,
- (struct MinNode *)&Actions1Nodes[15] };
-
-
- UWORD HotKeyGTypes[] = {
- LISTVIEW_KIND,
- LISTVIEW_KIND,
- STRING_KIND,
- CYCLE_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND
- };
-
-
- struct NewGadget HotKeyNGad[] = {
- 234,15,290,80,NULL,NULL,GD_Hotkeys ,PLACETEXT_ABOVE|NG_HIGHLABEL,NULL,NULL,
- 6,15,224,96,NULL,NULL,GD_Actions ,PLACETEXT_ABOVE|NG_HIGHLABEL,NULL,NULL,
- 234,109,290,14,NULL,NULL,GD_Argument,PLACETEXT_LEFT ,NULL,NULL,
- 234,124,290,13,NULL,NULL,GD_Options ,PLACETEXT_LEFT ,NULL,NULL,
- 234,93,110,13,NULL,NULL,GD_Add ,PLACETEXT_IN ,NULL,NULL,
- 414,93,110,13,NULL,NULL,GD_Delete ,PLACETEXT_IN ,NULL,NULL,
- 215,143,100,13,NULL,NULL,GD_Return ,PLACETEXT_IN ,NULL,NULL
- };
-
- VOID InitHotKeyNGad (VOID)
- {
- HotKeyNGad[GD_Hotkeys].ng_GadgetText = getString(HOTKEYS_STRING);
- HotKeyNGad[GD_Actions].ng_GadgetText = getString(ACTIONS_STRING);
- HotKeyNGad[GD_Argument].ng_GadgetText = getString(ARGUMENT_STRING);
- HotKeyNGad[GD_Options].ng_GadgetText = getString(OPTIONS_STRING);
- HotKeyNGad[GD_Add].ng_GadgetText = getString(ADD_STRING);
- HotKeyNGad[GD_Delete].ng_GadgetText = getString(DELETE_STRING);
- HotKeyNGad[GD_Return].ng_GadgetText = getString(OK_STRING);
- }
-
-
-
- ULONG HotKeyGTags[] = {
- (GTLV_ShowSelected),NULL,(TAG_DONE),
- (GTLV_Labels),(ULONG)&Actions1List,(GTLV_ShowSelected),NULL,(TAG_DONE),
- (GTST_MaxChars),512,(TAG_DONE),
- (GTCY_Labels),(ULONG)&Options1Labels[ 0 ],(TAG_DONE),
- (TAG_DONE),
- (TAG_DONE),
- (TAG_DONE)
- };
-
-
-
-
- VOID
- HotKeyRender()
- {
- ComputeFont(HotKeyWidth,HotKeyHeight);
-
- DrawBevelBox(HotKeyWnd->RPort,OffX,
- OffY +ComputeY(140),
- ComputeX(530),
- ComputeY(HotKeyHeight) -ComputeY(140),
- GT_VisualInfo,VisualInfo,TAG_DONE);
- DrawBevelBox(HotKeyWnd->RPort,OffX,
- OffY,
- ComputeX(530),
- ComputeY(140),
- GT_VisualInfo,VisualInfo,TAG_DONE);
- }
-
-
-
-
- int
- OpenHotKeyWindow()
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc,tc;
- UWORD wleft = HotKeyLeft,wtop = WindowTop,ww,wh;
-
- ComputeFont(HotKeyWidth,HotKeyHeight);
-
- ww = ComputeX(HotKeyWidth);
- wh = ComputeY(HotKeyHeight);
-
- if ((wleft +ww +OffX +Scr->WBorRight) > Scr->Width) wleft = Scr->Width -ww;
- if ((wtop +wh +OffY +Scr->WBorBottom) > Scr->Height) wtop = Scr->Height -wh;
-
- if (! (g = CreateContext(&HotKeyGList)))
- return(1L);
-
- for(lc = 0,tc = 0; lc < HotKey_CNT; lc++) {
-
- CopyMem((char *)&HotKeyNGad[ lc ],(char *)&ng,(long)sizeof(struct NewGadget));
-
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = Font;
- ng.ng_LeftEdge = OffX +ComputeX(ng.ng_LeftEdge);
- ng.ng_TopEdge = OffY +ComputeY(ng.ng_TopEdge);
- ng.ng_Width = ComputeX(ng.ng_Width);
- ng.ng_Height = ComputeY(ng.ng_Height);
-
- HotKeyGadgets[ lc ] = g = CreateGadgetA((ULONG)HotKeyGTypes[ lc ],g,&ng,(struct TagItem *)&HotKeyGTags[ tc ]);
-
- while(HotKeyGTags[ tc ]) tc += 2;
- tc++;
-
- if (NOT g)
- return(2L);
- }
-
- if (! (HotKeyWnd = OpenWindowTags(NULL,
- WA_Left, wleft,
- WA_Top, wtop,
- WA_Width, ww +OffX +Scr->WBorRight,
- WA_Height, wh +OffY +Scr->WBorBottom,
- WA_IDCMP, LISTVIEWIDCMP|STRINGIDCMP|CYCLEIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH,
- WA_Gadgets, HotKeyGList,
- WA_Title, HotKeyWdt,
- WA_ScreenTitle,getString(COPYRIGHT_STRING),
- WA_PubScreen,TRUE,
- WA_PubScreenName,PubScreenName,
- TAG_DONE)))
- return(4L);
-
- GT_RefreshWindow(HotKeyWnd,NULL);
-
- HotKeyRender();
-
- return(0L);
- }
-
-
-
-
- VOID
- CloseHotKeyWindow()
- {
- CloseOneWindow (HotKeyWnd,NULL,HotKeyGList);
- HotKeyWnd = NULL;
- }
-
-
- /*******************************************************************************
- * HOTKEY SPECIFIC DATA/ROUTINES
- * perhaps move to another file?
- *******************************************************************************/
-
- /* prototypes */
- static struct Node *GetNode(struct List *lh, UWORD n);
- static UWORD GetNodeNum(struct List *lh, struct Node *node);
-
- /* external data */
- YakHotKey *curhk;
- UWORD curtype;
-
- /* get number of node in list - node MUST be there! */
- static UWORD
- GetNodeNum(struct List *lh, struct Node *node)
- {
- struct Node *ln;
- UWORD i;
-
- for (i = 0, ln = lh->lh_Head; ln != node; ln = ln->ln_Succ, i++)
- ;
- return i;
- }
-
- /* get nth node in list - list MUST have >= n nodes!!! */
- static struct Node *
- GetNode(struct List *lh, UWORD n)
- {
- struct Node *ln;
-
- for (ln = lh->lh_Head; n--; ln = ln->ln_Succ)
- ;
- return ln;
- }
-
-
-
- /* initialise all gadgets of hotkey window */
- static void
- InitHotKeyGadgets(void)
- {
- InitWindowGadget(GDX_Hotkeys, GTLV_Labels, (LONG)keylist(curtype), HOTKEY_WINDOW);
- InitWindowGadget(GDX_Actions, GTLV_Selected, curtype, HOTKEY_WINDOW);
-
- InitWindowGadget(GDX_Delete, GA_Disabled, !curhk, HOTKEY_WINDOW);
- /* something selected */
- if (curhk)
- {
- UWORD n = GetNodeNum(keylist(curtype), (struct Node *)curhk);
-
- if (YHK_Has_Options(curhk))
- {
- InitWindowGadget(GDX_Options, GA_Disabled, FALSE, HOTKEY_WINDOW);
- InitWindowGadget(GDX_Options, GTCY_Active, (LONG)curhk->yhk_Options, HOTKEY_WINDOW);
- }
- else
- InitWindowGadget(GDX_Options, GA_Disabled, TRUE, HOTKEY_WINDOW);
-
-
- if (YHK_Takes_Arg(curhk))
- {
- InitWindowGadget(GDX_Argument, GA_Disabled, FALSE, HOTKEY_WINDOW);
- InitWindowGadget(GDX_Argument, GTST_String, (LONG)curhk->yhk_ArgStr, HOTKEY_WINDOW);
- }
- else
- InitWindowGadget(GDX_Argument, GA_Disabled, TRUE, HOTKEY_WINDOW);
-
- InitWindowGadget(GDX_Actions, GTLV_Top, curtype, HOTKEY_WINDOW);
- InitWindowGadget(GDX_Hotkeys, GTLV_Top , n, HOTKEY_WINDOW);
- InitWindowGadget(GDX_Hotkeys, GTLV_Selected, n, HOTKEY_WINDOW);
- }
- else /* no current hotkey */
- {
- InitWindowGadget(GDX_Hotkeys, GTLV_Selected, -1, HOTKEY_WINDOW);
-
- InitWindowGadget(GDX_Options, GTCY_Active, 0, HOTKEY_WINDOW);
- InitWindowGadget(GDX_Options, GA_Disabled, TRUE, HOTKEY_WINDOW);
-
- InitWindowGadget(GDX_Argument, GTST_String, (LONG)"", HOTKEY_WINDOW);
- InitWindowGadget(GDX_Argument, GA_Disabled, TRUE, HOTKEY_WINDOW);
- }
- }
-
-
- /* handle hotkey window events */
- LONG
- HandleHotKeyIDCMP(void)
- {
- struct IntuiMessage *msg;
- struct Gadget *gadget;
- ULONG class;
- UWORD code;
- static ULONG savesec;
- static ULONG savemic;
- static YakHotKey *savehk;
-
-
- while (msg = GT_GetIMsg(HotKeyWnd->UserPort))
- {
- class = msg->Class;
- code = msg->Code;
- gadget = (struct Gadget *)msg->IAddress;
- GT_ReplyIMsg(msg);
-
- switch (class)
- {
- case CLOSEWINDOW:
- HideInterface();
- return ROOT_OKAY;
-
- case GADGETUP:
- case GADGETDOWN:
- switch (gadget->GadgetID)
- {
- case GD_Actions:
- if (code != curtype)
- {
- curtype = code;
- curhk = NULL;
-
- InitHotKeyGadgets();
- }
- break;
-
- case GD_Hotkeys:
- curhk = (YakHotKey *)GetNode(keylist(curtype), code);
- if (DoubleClick(savesec, savemic, msg->Seconds, msg->Micros) &&
- (curhk == savehk) )
- {
- savehk = NULL;
- savemic = savesec = 0;
-
- if (SwitchToKeyDefWindow())
- return ROOT_OKAY;
- else
- PostError(getString(Couldnt_open_other_window_ERR));
- }
- else
- {
- savesec = msg->Seconds;
- savemic = msg->Micros;
- savehk = curhk;
-
- InitWindowGadget(GDX_Delete, GA_Disabled, !curhk, HOTKEY_WINDOW);
- InitHotKeyGadgets();
- }
-
- break;
-
- case GD_Argument:
- if (!curhk) /* shouldn't happen */
- break;
- if (!(ModifyYHKArgStr(curhk, GetString(gadget))))
- InitHotKeyGadgets();
- break;
-
- case GD_Options:
- if (curhk)
- curhk->yhk_Options = code;
- break;
-
- case GD_Add:
- curhk = NewYakHotKey(curtype);
- if (!SwitchToKeyDefWindow())
- PostError(getString(Couldnt_open_other_window_ERR));
- return ROOT_OKAY;
-
- case GD_Delete:
- if (curhk)
- {
- DeleteYakHotKey(curhk);
- curhk = NULL;
- InitHotKeyGadgets();
- }
- break;
-
- case GD_Return:
- curhk = NULL; /* in case of reloading */
- UpdateWindowsPosition();
- CloseHotKeyWindow();
- if (!ShowRootWindow())
- PostError(getString(Couldnt_open_other_window_ERR));
- return ROOT_OKAY;
-
- } /* switch (gadget->GadgetID) */
- break;
-
- case REFRESHWINDOW:
- GT_BeginRefresh(HotKeyWnd);
- GT_EndRefresh(HotKeyWnd, TRUE);
- break;
-
- } /* switch (class) */
-
- } /* while more messages */
-
- return ROOT_OKAY;
- }
-
- /* show our hotkey window */
- BOOL
- ShowHotKeyWindow(void)
- {
- if (!OpenHotKeyWindow()) /* like the name says... */
- {
- InitHotKeyGadgets();
- wndsigflag = 1 << HotKeyWnd->UserPort->mp_SigBit;
- curwin = HotKeyWnd;
- HandleIDCMP = HandleHotKeyIDCMP;
- return TRUE;
- }
- CloseDownScreen();
- return FALSE;
- }
-