2 * SWitch (C) 1996 John M Haubrich Jr
3 * All Rights Under Copyright Reserved
7 * Written using SAS/C 6.56
9 * PROGRAM AND SOURCE CODE ARE FREELY (RE)DISTRIBUTABLE.
11 * By John M. Haubrich, Jr.
14 #include <aros/oldprograms.h>
16 #include <exec/types.h>
17 #include <exec/memory.h>
18 #include <exec/nodes.h>
19 #include <exec/libraries.h>
20 #include <libraries/commodities.h>
21 #include <intuition/intuition.h>
22 #include <intuition/intuitionbase.h>
23 #include <intuition/gadgetclass.h>
24 #include <libraries/gadtools.h>
26 #include <dos/rdargs.h>
28 #include <proto/dos.h>
29 #include <proto/exec.h>
30 #include <proto/alib.h>
31 #include <proto/graphics.h>
32 #include <proto/commodities.h>
33 #include <proto/intuition.h>
34 #include <proto/gadtools.h>
41 int CXBRK(void) { return(0); }
42 int chkabort(void) { return(0); }
46 * VERSION STRING ===================================
48 char *vers
="$VER: SWitch 1.0 (15.05.96)";
52 * DEFINES ------------------------------------------
54 #define BASENAME "SWitch"
56 #define GAD_LISTVIEW 101L
57 #define ID_MENU_HIDE 201L
58 #define ID_MENU_QUIT 202L
59 #define ID_MENU_SAVESETTINGS 203L
61 #define MAXINFOCHARS 128 // 'Information...' allows 128 chars max
66 * STRUCTURE DEFINITIONS ----------------------------
68 struct NewBroker newbroker
= {
71 "Pops up a screen/window list.",
72 "User selects which to activate.",
73 NBU_UNIQUE
| NBU_NOTIFY
,
78 struct MsgPort
*broker_mp
;
80 ULONG cxsigflag
; // our combined message port signal FLAG
85 struct Gadget
*listview
;
89 char szHotkeyDesc
[MAXINFOCHARS
];
107 * GLOBAL VARIABLES ---------------------------------
110 struct Gadget
*glist
= NULL
;
111 struct Window
*mywin
= NULL
;
112 struct Menu
*menu
= NULL
;
115 struct NewMenu mynewmenu
[] =
117 { NM_TITLE
, "Project", 0 , 0, 0, NULL
},
118 { NM_ITEM
, "Hide", "H", 0, 0, (APTR
)ID_MENU_HIDE
},
119 { NM_ITEM
, "Quit", "Q", 0, 0, (APTR
)ID_MENU_QUIT
},
121 // { NM_TITLE, "Prefs", 0 , 0, 0, NULL },
122 // { NM_ITEM, "Save Settings", 0 , 0, 0, (APTR)ID_MENU_SAVESETTINGS },
124 { NM_END
, NULL
, 0 , 0, 0, NULL
}
129 * FUNCTION PROTOTYPES ------------------------------
131 void ProcessMsg(void);
132 int JMH_EasyReq( char *, char *, char *);
133 void JMH_Complain(char *);
134 void JMH_Info(char *);
135 int JMH_Query(char *, char *);
136 void JMH_Quit(char *);
137 VOID
JMH_InitVars(void);
138 void JumpToIt( UWORD
, struct Screen
* );
139 BOOL
HandleEvents( void );
140 BOOL
fnPopupJumpList( void );
141 struct Gadget
*CreateAllGadgets( struct Gadget
**, void *, WORD
, WORD
, WORD
, WORD
);
145 * LIBRARY VARIABLES --------------------------------
147 struct Library
*CxBase
= NULL
;
148 struct IntuitionBase
*IntuitionBase
= NULL
;
149 struct Library
*IconBase
= NULL
;
150 struct DosBase
*DosBase
= NULL
;
151 struct GfxBase
*GfxBase
= NULL
;
152 struct Library
*GadToolsBase
= NULL
;
156 * FUNCTIONS ----------------------------------------
160 * JMH_EasyReq(): pop up JMH_EasyRequest() with a custom title bar, message and
162 -------------------------------------------------------------------------*/
163 int JMH_EasyReq( char *title
, char *text
, char *resp
) {
164 static struct EasyStruct es
= {
165 sizeof(struct EasyStruct
),
174 if ( MG
.fBeQuiet
== FALSE
)
176 if ( MG
.fRunFromWB
== TRUE
)
179 es
.es_TextFormat
= text
;
180 es
.es_GadgetFormat
= resp
;
182 stat
= EasyRequest(NULL
, &es
, NULL
, TAG_DONE
);
186 printf( "%s\n", text
);
194 * JMH_Complain(): pop up JMH_EasyRequest() with a JMH_Complaint message
195 -------------------------------------------------------------------------*/
196 void JMH_Complain(char *t
)
202 sprintf( buf
, "%s Complaint...", BASENAME
);
203 JMH_EasyReq( buf
, t
, "OK" );
208 * JMH_Info(): pop up JMH_EasyRequest() with a (nice) informative message
209 * if WB flag set else send output to stderr
210 -------------------------------------------------------------------------*/
211 void JMH_Info(char *t
)
217 sprintf( buf
, "%s Information...", BASENAME
);
218 JMH_EasyReq( buf
, t
, "OK" );
223 * JMH_Query(): are you sure... ? (1=yes, 0=no)
224 -------------------------------------------------------------------------*/
225 int JMH_Query(char *t
, char *response
) {
232 sprintf( buf
, "%s Request...", BASENAME
);
238 stat
= JMH_EasyReq( buf
, t
, resp
);
246 * JMH_Quit(): close down everything we've opened and JMH_Quit
247 -------------------------------------------------------------------------*/
248 void JMH_Quit( char *t
)
250 char szQuitBuf
[256+20];
255 ClearMenuStrip( mywin
);
256 CloseWindow( mywin
);
262 sprintf( szQuitBuf
, "%s\nExiting...", t
);
263 JMH_Complain( szQuitBuf
);
266 if ( MG
.broker
) DeleteCxObjAll( MG
.broker
);
267 if ( MG
.broker_mp
) DeletePort( MG
.broker_mp
);
269 if ( GfxBase
) CloseLibrary( (struct Library
*)GfxBase
);
272 if ( menu
) FreeMenus( menu
);
275 // Free list nodes, if any
276 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
277 if ( MG
.list
.lh_Head
->ln_Succ
)
279 struct SWNode
*swworknode
, *swnode
;
282 swworknode
= (struct SWNode
*)MG
.list
.lh_Head
;
283 while (( swnode
= (struct SWNode
*)( swworknode
->node
.ln_Succ
) ))
285 FreeVec( swworknode
);
293 FreeVisualInfo( vi
);
298 FreeGadgets( glist
);
301 CloseLibrary(GadToolsBase
);
303 if ( DosBase
) CloseLibrary( (struct Library
*)DosBase
);
304 if ( CxBase
) CloseLibrary( CxBase
);
305 if ( IconBase
) CloseLibrary( (struct Library
*)IconBase
);
306 if ( IntuitionBase
) CloseLibrary( (struct Library
*)IntuitionBase
);
308 exit( ( t
? TRUE
: FALSE
) );
313 * JMH_InitVars(): initialize variables to default values
314 -------------------------------------------------------------------------*/
318 // initialize variables...
319 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320 memset( &MG
, 0, sizeof( MG
) );
324 MG
.fRunFromWB
= TRUE
;
330 menu
= CreateMenus( mynewmenu
, TAG_DONE
);
335 ** M A I N P R O G R A M -----------------------
337 int main( int argc
, char *argv
[] )
348 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349 IntuitionBase
= (struct IntuitionBase
*)
350 OpenLibrary("intuition.library",37L);
351 if (!IntuitionBase
) JMH_Quit("Cannot open intuition.library 37+");
353 IconBase
= OpenLibrary("icon.library",37L);
354 if (!IconBase
) JMH_Quit("Cannot open icon.library 37+");
356 CxBase
= OpenLibrary("commodities.library",37L);
357 if (!CxBase
) JMH_Quit("Cannot open commodities.library 37+");
359 DosBase
= (struct DosBase
*)OpenLibrary("dos.library",37L);
360 if (!DosBase
) JMH_Quit("Cannot open dos.library 37+");
362 GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library",37L);
363 if (!GfxBase
) JMH_Quit("Cannot open graphics.library 37+");
365 GadToolsBase
= OpenLibrary("gadtools.library",37L);
366 if (!GadToolsBase
) JMH_Quit("Cannot open gadtools.library 37+");
369 // initialize variables
370 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373 if (!(MG
.broker_mp
= CreateMsgPort()))
374 JMH_Quit( "Cannot create broker message port." );
377 // user may only run from Workbench
378 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379 MG
.fRunFromWB
= TRUE
;
381 // get opts from TOOLTYPES in icon
382 ttypes
= ArgArrayInit( argc
, (STRPTR
*)argv
);
384 // user-specified priority for the commodity
385 newbroker
.nb_Pri
= (BYTE
)ArgInt( ttypes
, "CX_PRIORITY", 0 );
388 temp
= ArgString( ttypes
, "QUIET", "FALSE" );
389 if ( stricmp( temp
, "TRUE" ) == 0 )
399 temp
= ArgString( ttypes
, "HOTKEY", "rawkey lalt esc" );
400 strcpy( MG
.szHotkeyDesc
, temp
);
402 // read left/top/width/height
403 temp
= ArgString( ttypes
, "LEFTEDGE", "0" ); MG
.wLeftEdge
= atoi( temp
);
404 temp
= ArgString( ttypes
, "TOPEDGE" , "20" ); MG
.wTopEdge
= atoi( temp
);
405 temp
= ArgString( ttypes
, "WIDTH" , "300" ); MG
.wWidth
= atoi( temp
);
406 MG
.wWidth
= ( MG
.wWidth
< 100 ? 100 : MG
.wWidth
);
407 temp
= ArgString( ttypes
, "HEIGHT" , "150" ); MG
.wHeight
= atoi( temp
);
408 MG
.wHeight
= ( MG
.wHeight
< 80 ? 80 : MG
.wHeight
);
410 // popup jump window relative to mouse pointer?
411 temp
= ArgString( ttypes
, "POINTERRELATIVE", NULL
);
413 MG
.fPointerRel
= TRUE
;
415 MG
.fPointerRel
= FALSE
;
417 // read number of clicks to jump
418 temp
= ArgString( ttypes
, "JUMPCLICKS", "1" );
419 MG
.sJumpClicks
= atoi( temp
);
420 if ( MG
.sJumpClicks
< 1 ) MG
.sJumpClicks
= 1;
421 else if ( MG
.sJumpClicks
> 2 ) MG
.sJumpClicks
= 2;
425 newbroker
.nb_Port
= MG
.broker_mp
;
426 MG
.cxsigflag
= 1L << MG
.broker_mp
->mp_SigBit
;
428 if (( MG
.broker
= CxBroker(&newbroker
, &errorcode
) ))
431 // Establish hotkey filter
432 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
433 if (( filter
= HotKey( MG
.szHotkeyDesc
, MG
.broker_mp
, EVT_HOTKEY
) ))
435 AttachCxObj( MG
.broker
, filter
);
437 if ( CxObjError( filter
) )
439 JMH_Quit( "Error creating filter for hotkey." );
443 ActivateCxObj( MG
.broker
, TRUE
);
444 ProcessMsg(); // process msgs until user quits...
450 // an error has occured.. show user!
451 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455 JMH_Quit( "Broker SYSTEM error.\nNo memory?" );
459 // this message is shown in ProcessMsg(): 'already running...'
460 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463 JMH_Quit( "Broker VERSION error." );
469 // Empty message port of all remaining messages
470 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
471 while (( msg
= (CxMsg
*)GetMsg( MG
.broker_mp
) ))
472 ReplyMsg( (struct Message
*)msg
);
485 BOOL fKeepGoing
= TRUE
;
488 while ( fKeepGoing
== TRUE
)
490 sigrcvd
= Wait( SIGBREAKF_CTRL_C
| MG
.cxsigflag
);
492 while (( msg
= (CxMsg
*)GetMsg( MG
.broker_mp
) ))
494 msgid
= CxMsgID( msg
);
495 msgtype
= CxMsgType( msg
);
496 ReplyMsg( (struct Message
*)msg
);
501 if ( msgid
== EVT_HOTKEY
)
503 ActivateCxObj( MG
.broker
, FALSE
);
504 fKeepGoing
= ( fnPopupJumpList() ? FALSE
: TRUE
);
505 ActivateCxObj( MG
.broker
, TRUE
);
513 ActivateCxObj( MG
.broker
, FALSE
);
517 ActivateCxObj( MG
.broker
, TRUE
);
525 JMH_Complain( "SWitch is already running!" );
530 if ( fKeepGoing
== FALSE
) break;
532 if ( sigrcvd
& SIGBREAKF_CTRL_C
)
539 // -----------------------------------------------------------------------
540 // fnPopupJumpList(): prepare jump list and launch window
541 // -----------------------------------------------------------------------
542 BOOL
fnPopupJumpList( void )
544 BOOL fQuitCX
= FALSE
; // FALSE = keep going; TRUE = quit program
549 struct SWNode
*swnode
;
550 struct SWNode
*swworknode
;
554 // Free list nodes, if any
555 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
556 if ( MG
.list
.lh_Head
->ln_Succ
)
558 swworknode
= (struct SWNode
*)MG
.list
.lh_Head
;
559 while (( swnode
= (struct SWNode
*)( swworknode
->node
.ln_Succ
) ))
561 FreeVec( swworknode
);
568 // Fill the screen/window list
569 // scan screenlist...
570 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
571 lIBLock
= LockIBase(0);
573 for ( scr
= IntuitionBase
->FirstScreen
; scr
; scr
= scr
->NextScreen
)
575 // use Default Title if there's no on-screen title
576 if ( scr
->Title
== NULL
) pszTitle
= scr
->DefaultTitle
;
577 else pszTitle
= scr
->Title
;
579 swnode
= (struct SWNode
*)AllocVec( sizeof( struct SWNode
) + strlen( pszTitle
) + 1, MEMF_PUBLIC
| MEMF_CLEAR
);
583 swnode
->wdw
= NULL
; // no window yet...
584 pszTitle
= ( pszTitle
? pszTitle
: "Unnamed Screen" );
585 strcpy( (char *)( swnode
+ 1 ), pszTitle
); // copy screen name to ln_Name
586 swnode
->node
.ln_Name
= (char *)( swnode
+ 1 );
587 AddTail( &MG
.list
, (struct Node
*)swnode
);
592 // ...then windowlist
593 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
594 for ( wdw
= scr
->FirstWindow
; wdw
; wdw
= wdw
->NextWindow
)
598 pszTitle
= wdw
->Title
;
602 sprintf( szTitle
, "Unnamed Window at (%d,%d)", wdw
->LeftEdge
, wdw
->TopEdge
);
605 swnode
= (struct SWNode
*)AllocVec( sizeof( struct SWNode
) + 3 + strlen( pszTitle
) + 1, MEMF_PUBLIC
| MEMF_CLEAR
);
610 sprintf( (char *)( swnode
+ 1 ), " %s", pszTitle
); // copy window name to ln_Name (indented)
611 swnode
->node
.ln_Name
= (char *)( swnode
+ 1 );
612 AddTail( &MG
.list
, (struct Node
*)swnode
);
617 UnlockIBase( lIBLock
);
620 // Open the window and drop into the window event loop
621 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
622 fQuitCX
= HandleEvents();
628 void JumpToIt( UWORD imsgCode
, struct Screen
*currscr
)
631 struct SWNode
*swnode
;
636 // imsgCode contains index of selection
637 // walk thru LL for nth item
638 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
639 for ( swnode
= (struct SWNode
*)MG
.list
.lh_Head
, i
= 0;
641 i
++, swnode
= (struct SWNode
*)swnode
->node
.ln_Succ
);
643 // jump to screen/window
644 ScreenToFront( swnode
->scr
);
645 wdw
= ( swnode
->wdw
? swnode
->wdw
: swnode
->scr
->FirstWindow
);
646 WindowToFront( wdw
);
647 ActivateWindow( wdw
);
648 if ( IntuitionBase
->LibNode
.lib_Version
>= 39 )
650 ScreenPosition( currscr
,
651 SPOS_MAKEVISIBLE
| SPOS_FORCEDRAG
,
654 wdw
->LeftEdge
+ wdw
->Width
,
655 wdw
->TopEdge
+ wdw
->Height
);
660 BOOL
HandleEvents( void )
662 BOOL fQuitCX
= FALSE
; // FALSE = keep going; TRUE = quit program
663 struct IntuiMessage
*imsg
;
665 struct Screen
*currscr
= NULL
;
668 UWORD uwCode
= 0xFFFF;
669 UWORD uwListItem
= 0;
670 ULONG imsgSeconds
= 0;
671 ULONG imsgMicros
= 0;
675 struct MenuItem
*mitem
;
680 BOOL fTerminated
= FALSE
;
684 struct SWNode
*swnode
;
688 currscr
= IntuitionBase
->ActiveScreen
;
690 if ( !( vi
= GetVisualInfo( currscr
, TAG_DONE
) ) )
692 // can't get visual info... bail out!
698 // How tall is window's title bar?
699 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
700 topborder
= currscr
->WBorTop
+ (currscr
->Font
->ta_YSize
+ 1);
702 wWidth
= ( MG
.wWidth
> currscr
->Width
? currscr
->Width
: MG
.wWidth
);
703 wHeight
= ( MG
.wHeight
> currscr
->Height
? currscr
->Height
: MG
.wHeight
);
704 wLeftEdge
= ( MG
.wLeftEdge
> currscr
->Width
? currscr
->Width
- wWidth
: MG
.wLeftEdge
);
705 wTopEdge
= ( MG
.wTopEdge
> currscr
->Height
? currscr
->Height
- wHeight
- topborder
: MG
.wTopEdge
);
708 // override left/top if POINTERRELATIVE mode is being used
709 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
710 if ( MG
.fPointerRel
)
712 wLeftEdge
= currscr
->MouseX
;
713 wTopEdge
= currscr
->MouseY
;
716 if ( !( mywin
= OpenWindowTags( NULL
,
717 WA_CustomScreen
, currscr
,
720 WA_InnerWidth
, wWidth
,
721 WA_InnerHeight
, wHeight
,
725 WA_MaxHeight
, 32767,
726 WA_AutoAdjust
, TRUE
,
729 WA_DepthGadget
, TRUE
,
730 WA_CloseGadget
, TRUE
,
731 WA_SizeGadget
, TRUE
,
732 WA_SizeBBottom
, TRUE
,
733 WA_SimpleRefresh
, TRUE
,
734 WA_IDCMP
, CLOSEWINDOW
| REFRESHWINDOW
| MENUPICK
| IDCMP_NEWSIZE
|
735 IDCMP_RAWKEY
| IDCMP_INACTIVEWINDOW
| LISTVIEWIDCMP
,
736 WA_Title
, "SWitch List",
743 if ( !CreateAllGadgets( &glist
, vi
, mywin
->BorderLeft
, topborder
,
744 mywin
->Width
- mywin
->BorderLeft
- mywin
->BorderRight
,
745 mywin
->Height
- mywin
->BorderTop
- mywin
->BorderBottom
) )
750 AddGList( mywin
, glist
, -1, -1, NULL
);
751 RefreshGList( glist
, mywin
, NULL
, -1 );
752 GT_RefreshWindow( mywin
, NULL
);
753 LayoutMenus( menu
, vi
,
754 GTMN_NewLookMenus
, TRUE
,
756 SetMenuStrip( mywin
, menu
);
758 while ( !fTerminated
)
760 Wait ( 1 << mywin
->UserPort
->mp_SigBit
);
761 while ( ( !fTerminated
) && ( imsg
= GT_GetIMsg( mywin
->UserPort
) ) )
763 imsgClass
= imsg
->Class
;
764 imsgCode
= imsg
->Code
;
765 imsgSeconds
= imsg
->Seconds
;
766 imsgMicros
= imsg
->Micros
;
767 gad
= (struct Gadget
*)imsg
->IAddress
;
768 GT_ReplyIMsg( imsg
);
772 RemoveGList( mywin
, glist
, -1 );
773 FreeGadgets( glist
);
775 if ( !CreateAllGadgets( &glist
, vi
, mywin
->BorderLeft
, topborder
,
776 mywin
->Width
- mywin
->BorderLeft
- mywin
->BorderRight
,
777 mywin
->Height
- mywin
->BorderTop
- mywin
->BorderBottom
) )
783 AddGList( mywin
, glist
, -1, -1, NULL
);
784 SetRast( mywin
->RPort
, 0 );
785 RefreshWindowFrame( mywin
);
786 RefreshGList( glist
, mywin
, NULL
, -1 );
787 GT_RefreshWindow( mywin
, NULL
);
795 // LEFT or RIGHT SHIFT pressed
800 // LEFT or RIGHT SHIFT released
805 // LEFT or RIGHT ALT pressed
810 // LEFT or RIGHT ALT released
816 JumpToIt( uwListItem
, currscr
);
818 // close jump window and exit...
823 if ( fAlt
== FALSE
&& fShift
== FALSE
)
830 if ( uwListItem
<= 0 ) break;
832 if ( fShift
== TRUE
)
834 for ( swnode
= (struct SWNode
*)MG
.list
.lh_Head
, i
= 0;
835 ( ( i
< uwListItem
-1 ) && ( swnode
->node
.ln_Succ
) );
836 i
++, swnode
= (struct SWNode
*)swnode
->node
.ln_Succ
);
837 for ( fFound
= FALSE
; swnode
->node
.ln_Pred
; i
--, swnode
= (struct SWNode
*)swnode
->node
.ln_Pred
)
839 if ( swnode
->wdw
== NULL
)
848 GT_SetGadgetAttrs( MG
.listview
, mywin
, NULL
, GTLV_Selected
, uwListItem
,
849 GTLV_MakeVisible
, uwListItem
,
850 ( GadToolsBase
->lib_Version
< 39 ? GTLV_Top
: TAG_SKIP
), uwListItem
,
851 TAG_DONE
, TAG_DONE
);
854 else if ( fAlt
== TRUE
)
857 GT_SetGadgetAttrs( MG
.listview
, mywin
, NULL
, GTLV_Selected
, uwListItem
,
858 GTLV_MakeVisible
, uwListItem
,
859 ( GadToolsBase
->lib_Version
< 39 ? GTLV_Top
: TAG_SKIP
), uwListItem
,
860 TAG_DONE
, TAG_DONE
);
864 uwListItem
= ( uwListItem
-1 >= 0 ? uwListItem
-1 : 0 );
865 GT_SetGadgetAttrs( MG
.listview
, mywin
, NULL
, GTLV_Selected
, uwListItem
,
866 GTLV_MakeVisible
, uwListItem
,
867 ( GadToolsBase
->lib_Version
< 39 ? GTLV_Top
: TAG_SKIP
), uwListItem
,
868 TAG_DONE
, TAG_DONE
);
873 if ( uwListItem
>= MG
.uwNumItems
-1 ) break;
875 if ( fShift
== TRUE
)
877 for ( swnode
= (struct SWNode
*)MG
.list
.lh_Head
, i
= 0;
878 ( ( i
< uwListItem
+1 ) && ( swnode
->node
.ln_Succ
) );
879 i
++, swnode
= (struct SWNode
*)swnode
->node
.ln_Succ
);
880 for ( fFound
= FALSE
; swnode
->node
.ln_Succ
; i
++, swnode
= (struct SWNode
*)swnode
->node
.ln_Succ
)
882 if ( swnode
->wdw
== NULL
)
891 GT_SetGadgetAttrs( MG
.listview
, mywin
, NULL
, GTLV_Selected
, uwListItem
,
892 GTLV_MakeVisible
, uwListItem
,
893 ( GadToolsBase
->lib_Version
< 39 ? GTLV_Top
: TAG_SKIP
), uwListItem
,
894 TAG_DONE
, TAG_DONE
);
897 else if ( fAlt
== TRUE
)
899 uwListItem
= MG
.uwNumItems
- 1;
900 GT_SetGadgetAttrs( MG
.listview
, mywin
, NULL
, GTLV_Selected
, uwListItem
,
901 GTLV_MakeVisible
, uwListItem
,
902 ( GadToolsBase
->lib_Version
< 39 ? GTLV_Top
: TAG_SKIP
), uwListItem
,
903 TAG_DONE
, TAG_DONE
);
907 uwListItem
= ( uwListItem
+1 < MG
.uwNumItems
? uwListItem
+1 : MG
.uwNumItems
-1 );
908 GT_SetGadgetAttrs( MG
.listview
, mywin
, NULL
, GTLV_Selected
, uwListItem
,
909 GTLV_MakeVisible
, uwListItem
,
910 ( GadToolsBase
->lib_Version
< 39 ? GTLV_Top
: TAG_SKIP
), uwListItem
,
911 TAG_DONE
, TAG_DONE
);
918 while ( ( imsgCode
!= MENUNULL
) && ( !fTerminated
) )
920 mitem
= ItemAddress( menu
, imsgCode
);
921 switch( (IPTR
)GTMENUITEM_USERDATA( mitem
) )
930 case ID_MENU_SAVESETTINGS
:
931 // save settings here -- how replace existing tool types
934 imsgCode
= mitem
->NextSelect
;
939 if ( gad
->GadgetID
== GAD_LISTVIEW
)
941 uwListItem
= imsgCode
;
942 if ( ( MG
.sJumpClicks
== 1 ) ||
943 ( ( MG
.sJumpClicks
== 2 ) &&
944 DoubleClick( ulSeconds
, ulMicros
, imsgSeconds
, imsgMicros
) &&
945 ( imsgCode
== uwCode
) ) )
947 JumpToIt( imsgCode
, currscr
);
950 // close jump window and exit...
951 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
954 ulSeconds
= imsgSeconds
;
955 ulMicros
= imsgMicros
;
960 case IDCMP_INACTIVEWINDOW
:
964 GT_BeginRefresh( mywin
);
965 GT_EndRefresh( mywin
, TRUE
);
972 // Close the window and cleanup
973 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
977 ClearMenuStrip( mywin
);
978 CloseWindow( mywin
);
983 FreeVisualInfo( vi
);
988 FreeGadgets( glist
);
993 // Send back return code
994 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
998 struct Gadget
*CreateAllGadgets( struct Gadget
**glistptr
, void *vi
,
999 WORD wLeft
, WORD topborder
, WORD wWidth
, WORD wHeight
)
1001 struct NewGadget ng
;
1005 memset( &ng
, 0, sizeof( struct NewGadget
) );
1007 gad
= CreateContext(glistptr
);
1009 ng
.ng_LeftEdge
= wLeft
+ 1;
1010 ng
.ng_TopEdge
= topborder
+ 1;
1011 ng
.ng_Width
= wWidth
- 2;
1012 ng
.ng_Height
= wHeight
;
1013 ng
.ng_TextAttr
= NULL
;
1014 ng
.ng_VisualInfo
= vi
;
1015 ng
.ng_GadgetID
= GAD_LISTVIEW
;
1017 MG
.listview
= gad
= CreateGadget( LISTVIEW_KIND
, gad
, &ng
,
1018 GTLV_Labels
, &MG
.list
,
1020 GTLV_ShowSelected
, NULL
,
1021 LAYOUTA_Spacing
, 2,