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
- */
-
-
- #define __USE_SYSBASE
-
- #include <exec/execbase.h>
- #include <exec/memory.h>
- #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 <libraries/gadtools.h>
- #include <workbench/workbench.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/intuition.h>
- #include <proto/gadtools.h>
- #include <proto/wb.h>
- #include <string.h>
- #include <stdlib.h>
-
- #include "code.h"
- #include "version.h"
- #include "yak.h"
- #include "hotkey_types.h"
- #include "MouseCycling_Window.h"
- #include "KeyDef_Window.h"
- #include "gui.h"
- #include "Handlers.h"
- #include "Requesters.h"
-
-
- #define CATCOMP_NUMBERS
- #include "yak_locale_strings.h"
-
-
- IMPORT LONG (*HandleIDCMP)(VOID);
-
- struct Window *MouseCyclingWnd = NULL;
- struct Gadget *MouseCyclingGList = NULL;
- struct Gadget *MouseCyclingGadgets[MouseCycling_CNT];
- UWORD MouseCyclingWidth = 532;
- UWORD MouseCyclingHeight = 185;
- UBYTE *MouseCyclingWdt = NULL;
- BOOL MouseCyclingWdi = FALSE;
-
- struct AppWindow *MouseCyclingAppWin; /* AppWindow pointer */
- IMPORT struct MsgPort *AppMsgPort;
-
- UBYTE *Click1Labels[4];
-
- /* Online help system */
- IMPORT void ShowYakHelp(char *, char *);
- IMPORT void CloseYakHelp(void);
- IMPORT char *PrefsHelp;
-
-
- struct IntuiText MouseCyclingIText[] = {
- 2, 0, JAM1,69, 9, NULL, NULL, NULL,
- 2, 0, JAM1,62, 76, NULL, NULL, NULL,
- 2, 0, JAM1,63, 131, NULL, NULL, NULL };
-
- #define MouseCycling_TNUM 3
-
- UWORD MouseCyclingGTypes[] = {
- CHECKBOX_KIND,
- CHECKBOX_KIND,
- CHECKBOX_KIND,
- CHECKBOX_KIND,
- CHECKBOX_KIND,
- CYCLE_KIND,
- CHECKBOX_KIND,
- STRING_KIND,
- STRING_KIND,
- STRING_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- BUTTON_KIND,
- CYCLE_KIND,
- CYCLE_KIND,
- BUTTON_KIND
- };
-
- struct NewGadget MouseCyclingNGad[] = {
- 6, 15, 26, 13, NULL, NULL, GD_WindowToFrontActive, PLACETEXT_RIGHT, NULL, STATE_ACTIVE_STRING,
- 6, 75, 26, 13, NULL, NULL, GD_WindowToBackActive, PLACETEXT_RIGHT, NULL, STATE_ACTIVE_STRING,
- 6, 135, 26, 13, NULL, NULL, GD_ScreenCyclingActive, PLACETEXT_RIGHT, NULL, STATE_ACTIVE_STRING,
- 6, 29, 26, 13, NULL, NULL, GD_ScreenToFront_Check, PLACETEXT_RIGHT, NULL, ScreenToFront_ACT,
- 6, 89, 26, 13, NULL, NULL, GD_ScreenToBack_Check, PLACETEXT_RIGHT, NULL, ScreenToBack_ACT,
- 6, 43, 146, 13, NULL, NULL, GD_WindowToFrontClicks, 0, NULL, NULL,
- 180, 15, 26, 13, NULL, NULL, GD_ExcludeWbWindow, PLACETEXT_RIGHT, NULL, EXCLUDE_WB_WINDOW,
- 325, 29, 200, 13, NULL, NULL, GD_WindowToFrontPattern,PLACETEXT_LEFT, NULL, INCLUDE_SCREENS,
- 325, 89, 200, 13, NULL, NULL, GD_WindowToBackPattern, PLACETEXT_LEFT, NULL, INCLUDE_SCREENS,
- 325, 135, 200, 13, NULL, NULL, GD_ScreenCyclingPattern,PLACETEXT_LEFT, NULL, INCLUDE_SCREENS,
- 180, 149, 140, 13, NULL, NULL, GD_HotkeyScreenCycling, PLACETEXT_IN, NULL, DEFINITION_STRING,
- 180, 103, 140, 13, NULL, NULL, GD_HotkeyWindowToBack, PLACETEXT_IN, NULL, DEFINITION_STRING,
- 180, 43, 140, 13, NULL, NULL, GD_HotkeyWindowToFront, PLACETEXT_IN, NULL, DEFINITION_STRING,
- 6, 103, 146, 13, NULL, NULL, GD_WindowToBackClicks, 0, NULL, NULL,
- 6, 149, 146, 13, NULL, NULL, GD_ScreenCyclingClicks, 0, NULL, NULL,
- 215, 169, 100, 13, NULL, NULL, GD_Return5, PLACETEXT_IN ,NULL ,OK_STRING
- };
-
- ULONG MouseCyclingGTags[] = {
- (GTCB_Scaled),TRUE,(TAG_DONE),
- (GTCB_Scaled),TRUE,(TAG_DONE),
- (GTCB_Scaled),TRUE,(TAG_DONE),
- (GTCB_Scaled),TRUE,(TAG_DONE),
- (GTCB_Scaled),TRUE,(TAG_DONE),
- (GTCY_Labels), (ULONG)&Click1Labels[ 0 ], (TAG_DONE),
- (GTCB_Scaled),TRUE,(TAG_DONE),
- (GTST_MaxChars), 256, (TAG_DONE),
- (GTST_MaxChars), 256, (TAG_DONE),
- (GTST_MaxChars), 256, (TAG_DONE),
- (TAG_DONE),
- (TAG_DONE),
- (TAG_DONE),
- (GTCY_Labels), (ULONG)&Click1Labels[ 0 ], (TAG_DONE),
- (GTCY_Labels), (ULONG)&Click1Labels[ 0 ], (TAG_DONE),
- (TAG_DONE)
- };
-
-
-
-
- VOID
- InitClick1Labels(VOID)
- {
- Click1Labels[0] = getString(SIMPLE_CLICK_STRING);
- Click1Labels[1] = getString(DOUBLE_CLICK_STRING);
- Click1Labels[2] = getString(TRIPLE_CLICK_STRING);
- Click1Labels[3] = NULL;
- }
-
-
- VOID
- InitMouseCyclingITexts(VOID)
- {
- MouseCyclingIText[0].IText = getString(WINDOW_TO_FRONT);
- MouseCyclingIText[1].IText = getString(WINDOW_TO_BACK);
- MouseCyclingIText[2].IText = getString(SCREENS_CYCLING);
- }
-
- void
- MouseCyclingRender( void )
- {
- struct IntuiText it;
- UWORD cnt;
- UWORD Y, Width, Height;
-
- ComputeFont( MouseCyclingWidth, MouseCyclingHeight );
-
- Width = ComputeX( MouseCyclingWidth );
- Y = 0;
- Height = ComputeY(60);
- MouseCyclingIText[0].TopEdge = Y+3;
-
- DrawThinBevelBox(Scr, MouseCyclingWnd->RPort, OffX,
- OffY+Y,
- Width,
- Height,
- FALSE );
-
- Y = Height;
- Height = ComputeY(120) - Y;
- MouseCyclingIText[1].TopEdge = Y+3;
-
- DrawThinBevelBox(Scr, MouseCyclingWnd->RPort, OffX,
- OffY+Y,
- Width,
- Height,
- FALSE );
-
- Y += Height;
- Height = ComputeY(166) - Y;
- MouseCyclingIText[2].TopEdge = Y+3;
-
- DrawThinBevelBox(Scr, MouseCyclingWnd->RPort, OffX,
- OffY+Y,
- Width,
- Height,
- FALSE );
-
- Y += Height;
- Height = ComputeY(MouseCyclingHeight) - Y;
- DrawThinBevelBox(Scr, MouseCyclingWnd->RPort, OffX,
- OffY+Y,
- Width,
- Height,
- FALSE );
-
- for ( cnt = 0; cnt < MouseCycling_TNUM; cnt++ ) {
- CopyMem(( char * )&MouseCyclingIText[ cnt ], ( char * )&it, (long)sizeof( struct IntuiText ));
- it.ITextFont = Font;
- it.LeftEdge = 5;
- PrintIText( MouseCyclingWnd->RPort, &it, OffX, OffY );
- }
- }
-
- int
- OpenMouseCyclingWindow(VOID)
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc, tc;
- WORD wleft=WindowLeft, wtop=WindowTop;
- UWORD ww, wh;
-
- ComputeFont( MouseCyclingWidth, MouseCyclingHeight );
-
- ww = OffX + ComputeX( MouseCyclingWidth ) + Scr->WBorRight;
- wh = OffY + ComputeY( MouseCyclingHeight ) + Scr->WBorBottom;
-
- SetUpWindowCoordinates(ww, wh, &wleft, &wtop);
-
- if ( ! ( g = CreateContext( &MouseCyclingGList )))
- return( 1L );
-
- for( lc = 0, tc = 0; lc < MouseCycling_CNT; lc++ ) {
-
- CopyMem((char * )&MouseCyclingNGad[ 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);
-
- MouseCyclingGadgets[ lc ] = g = CreateGadgetA((ULONG)MouseCyclingGTypes[ lc ], g, &ng, ( struct TagItem * )&MouseCyclingGTags[ tc ] );
-
- while( MouseCyclingGTags[ tc ] ) tc += 2;
- tc++;
-
- if ( NOT g )
- return( 2L );
- }
-
- if ( ! ( MouseCyclingWnd = OpenWindowTags( NULL,
- WA_Left, wleft,
- WA_Top, wtop,
- WA_Width, ww,
- WA_Height, wh,
- WA_IDCMP, CHECKBOXIDCMP|CYCLEIDCMP|STRINGIDCMP|BUTTONIDCMP|IDCMP_REFRESHWINDOW|IDCMP_RAWKEY,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH,
- WA_Gadgets, MouseCyclingGList,
- WA_Title, MouseCyclingWdt,
- WA_ScreenTitle, getString(COPYRIGHT_STRING),
- WA_PubScreenName,PubScreenName,
- TAG_DONE )))
- return( 4L );
-
- MouseCyclingAppWin = AddAppWindowA(0, 0, MouseCyclingWnd, AppMsgPort, NULL);
-
- GT_RefreshWindow( MouseCyclingWnd, NULL );
-
- MouseCyclingRender();
-
- return( 0L );
- }
-
- void
- CloseMouseCyclingWindow( void )
- {
- CloseOneWindow (MouseCyclingWnd, NULL, MouseCyclingGList, MouseCyclingAppWin);
- MouseCyclingWnd = NULL;
- }
-
-
-
-
- static void
- InitMouseCyclingGad(UWORD num, LONG tagtype, LONG tagvalue, UWORD state)
- {
- InitWindowGadget(num, tagtype, tagvalue, MCYCLING_WINDOW);
- InitWindowGadget(num, GA_Disabled, !state, MCYCLING_WINDOW);
- }
-
- static void
- InitWindowToFrontGads(VOID)
- {
- UWORD state;
-
- state = Window_To_Front.State;
- InitMouseCyclingGad(GDX_WindowToFrontActive , GTCB_Checked, state, TRUE);
- InitMouseCyclingGad(GDX_WindowToFrontClicks , GTCY_Active , Window_To_Front.RequiredClicks-1, state);
- InitMouseCyclingGad(GDX_ScreenToFront_Check , GTCB_Checked, Window_To_Front.Options & Opt_ScreenToFront, state);
- InitMouseCyclingGad(GDX_ExcludeWbWindow , GTCB_Checked, Window_To_Front.Options & Opt_ExcludeWbWindow, state);
- InitMouseCyclingGad(GDX_WindowToFrontPattern, GTST_String , (LONG)Window_To_Front.ScreenPatternData.patstr, state);
- InitWindowGadget(GDX_HotkeyWindowToFront , GA_Disabled , !state, MCYCLING_WINDOW);
- }
-
- static void
- InitWindowToBackGads(VOID)
- {
- UWORD state;
-
- state = Window_To_Back.State;
- InitMouseCyclingGad(GDX_WindowToBackActive , GTCB_Checked, state, TRUE);
- InitMouseCyclingGad(GDX_WindowToBackClicks , GTCY_Active , Window_To_Back.RequiredClicks-1, state);
- InitMouseCyclingGad(GDX_ScreenToBack_Check , GTCB_Checked, Window_To_Back.Options & Opt_ScreenToBack, state);
- InitMouseCyclingGad(GDX_WindowToBackPattern, GTST_String , (LONG)Window_To_Back.ScreenPatternData.patstr, state);
- InitWindowGadget(GDX_HotkeyWindowToBack , GA_Disabled , !state, MCYCLING_WINDOW);
- }
-
- static void
- InitScreenCyclingGads(VOID)
- {
- UWORD state;
-
- state = ScreenCycling.State;
- InitMouseCyclingGad(GDX_ScreenCyclingActive , GTCB_Checked, state, TRUE);
- InitMouseCyclingGad(GDX_ScreenCyclingClicks , GTCY_Active , ScreenCycling.RequiredClicks-1, state);
- InitMouseCyclingGad(GDX_ScreenCyclingPattern, GTST_String , (LONG)ScreenCycling.ScreenPatternData.patstr, state);
- InitWindowGadget(GDX_HotkeyScreenCycling , GA_Disabled , !state, MCYCLING_WINDOW);
- }
-
- static void
- InitMouseCyclingGadgets(VOID)
- {
- /* Window To Front gadgets */
- InitWindowToFrontGads();
-
- /* Window To Back gadgets */
- InitWindowToBackGads();
-
- /* Screen Cycling gadgets */
- InitScreenCyclingGads();
- }
-
-
- /* handle Blank window events */
- LONG
- HandleMouseCyclingIDCMP(VOID)
- {
- struct IntuiMessage *msg;
- struct Gadget *gadget;
- ULONG class;
- UWORD code;
- BOOL close=FALSE;
- LONG ret=RET_OKAY;
-
- while (!close && (msg=GT_GetIMsg(MouseCyclingWnd->UserPort)))
- {
- class = msg->Class;
- code = msg->Code;
- gadget = (struct Gadget *)msg->IAddress;
- GT_ReplyIMsg(msg);
-
- switch (class)
- {
- case REFRESHWINDOW:
- GT_BeginRefresh(MouseCyclingWnd);
- GT_EndRefresh(MouseCyclingWnd, TRUE);
- break;
-
- case GADGETUP:
- case GADGETDOWN:
- switch (gadget->GadgetID)
- {
- case GD_Return5:
- CloseMouseCyclingWindow();
- if (!ShowWindowID(ROOT_WINDOW))
- ret = RET_QUIT;
- close = TRUE;
- break;
-
- /*******************/
- /* Window To Front */
- /* Gadgets */
- /*******************/
-
- case GD_WindowToFrontActive:
- Window_To_Front.State ^= YKHK_ACTIVE;
- InitWindowToFrontGads();
- break;
-
- case GD_ScreenToFront_Check:
- Window_To_Front.Options ^= Opt_ScreenToFront;
- break;
-
- case GD_ExcludeWbWindow:
- Window_To_Front.Options ^= Opt_ExcludeWbWindow;
- break;
-
- case GD_WindowToFrontClicks:
- Window_To_Front.RequiredClicks = code + 1;
- break;
-
- case GD_HotkeyWindowToFront:
- if (!SwitchToKeyDefWindow(MCYCLING_WINDOW,
- &Window_To_Front,
- getString(WINDOW_TO_FRONT)))
- {
- PostError(getString(Couldnt_open_other_window_ERR));
- ret = RET_QUIT;
- }
- close = TRUE;
- break;
-
-
- case GD_WindowToFrontPattern:
- NewPattern(GDX_WindowToFrontPattern, &Window_To_Front.ScreenPatternData, gadget, MCYCLING_WINDOW);
- break;
-
- /******************/
- /* Window To Back */
- /* Gadgets */
- /******************/
-
- case GD_WindowToBackActive:
- Window_To_Back.State ^= YKHK_ACTIVE;
- InitWindowToBackGads();
- break;
-
- case GD_ScreenToBack_Check:
- Window_To_Back.Options ^= Opt_ScreenToBack;
- break;
-
- case GD_WindowToBackClicks:
- Window_To_Back.RequiredClicks = code + 1;
- break;
-
- case GD_HotkeyWindowToBack:
- if (!SwitchToKeyDefWindow(MCYCLING_WINDOW,
- &Window_To_Back,
- getString(WINDOW_TO_BACK)))
- {
- PostError(getString(Couldnt_open_other_window_ERR));
- ret = RET_QUIT;
- }
- close = TRUE;
- break;
-
- case GD_WindowToBackPattern:
- NewPattern(GDX_WindowToBackPattern, &Window_To_Back.ScreenPatternData, gadget, MCYCLING_WINDOW);
- break;
-
- /******************/
- /* Screen Cycling */
- /* Gadgets */
- /******************/
-
- case GD_ScreenCyclingActive:
- ScreenCycling.State ^= YKHK_ACTIVE;
- InitScreenCyclingGads();
- break;
-
- case GD_ScreenCyclingClicks:
- ScreenCycling.RequiredClicks = code + 1;
- break;
-
- case GD_HotkeyScreenCycling:
- if (!SwitchToKeyDefWindow(MCYCLING_WINDOW,
- &ScreenCycling,
- getString(SCREENS_CYCLING)))
- {
- PostError(getString(Couldnt_open_other_window_ERR));
- ret = RET_QUIT;
- }
- close = TRUE;
- break;
-
- case GD_ScreenCyclingPattern:
- NewPattern(GDX_ScreenCyclingPattern, &ScreenCycling.ScreenPatternData, gadget, MCYCLING_WINDOW);
- break;
-
- } /* switch (gadget->GadgetID) */
- break;
-
- case IDCMP_RAWKEY:
- /* Help key pressed */
- if (code == 95)
- {
- /* Display the node */
- ShowYakHelp(PrefsHelp, "MouseCycling");
- }
- break;
- } /* switch (class) */
- } /* while more messages */
- return ret;
- }
-
-
- /* show our MouseCycling window */
- BOOL
- ShowMouseCyclingWindow(VOID)
- {
- if (!MouseCyclingWdi)
- {
- MouseCyclingWdi = TRUE;
-
- MouseCyclingWdt = getString(MOUSECYCLING_STRING);
- InitMouseCyclingITexts();
- LocalizeNGadLabels (MouseCycling_CNT, MouseCyclingNGad);
- InitClick1Labels ();
- }
-
- if (!OpenMouseCyclingWindow()) /* like the name says... */
- {
- InitMouseCyclingGadgets();
- wndsigflag = 1 << MouseCyclingWnd->UserPort->mp_SigBit;
- curwin = MouseCyclingWnd;
- curwinID = MCYCLING_WINDOW;
- HandleIDCMP = HandleMouseCyclingIDCMP;
- return TRUE;
- }
-
- FreeGadgets(MouseCyclingGList);
- CloseDownScreen();
- curwin = NULL;
- wndsigflag = 0L;
- return FALSE;
- }
-
-