2 #include <exec/types.h>
3 #include <intuition/intuition.h>
4 #include <intuition/gadgetclass.h>
5 #include <libraries/gadtools.h>
6 #include <graphics/displayinfo.h>
7 #include <proto/exec.h>
8 #include <proto/intuition.h>
9 #include <proto/gadtools.h>
10 #include <aros/debug.h>
22 #define GD_Gadget10 10
23 #define GD_Gadget11 11
24 #define GD_GadgetSave 50 /* Save */
25 #define GD_GadgetHide 51 /* Hide */
26 #define GD_GadgetQuit 52 /* Quit */
27 #define GD_GadgetCancel 53 /* Cancel */
30 extern char keys
[KEYNUMMER
][256];
33 char windowtitle
[80]="WindowTool 1.0 : Hotkey = "; /* 25 */
35 struct Window
*Wnd
= 0l;
36 struct Screen
*Scr
= 0l;
38 struct Gadget
*GList
= 0l;
39 struct Gadget
*Gadgets
[16];
40 struct Menu
*Menus
= 0l;
41 UWORD Zoom
[4] = { 0, 0, 200, 11 };
43 struct TextAttr topaz8
= {
44 ( STRPTR
)"topaz.font", 8, 0x00, 0x01 };
46 struct TagItem WindowTags
[] = {
51 {WA_IDCMP
, IDCMP_GADGETUP
|IDCMP_MENUPICK
|IDCMP_VANILLAKEY
|IDCMP_CLOSEWINDOW
|IDCMP_REFRESHWINDOW
|IDCMP_CHANGEWINDOW
},
52 {WA_Flags
, WFLG_DRAGBAR
|WFLG_DEPTHGADGET
|WFLG_CLOSEGADGET
|WFLG_SMART_REFRESH
|WFLG_ACTIVATE
},
54 {WA_Title
, (IPTR
)windowtitle
},
59 {WA_Zoom
, (IPTR
)Zoom
},
62 struct IntuiText IText
[] = { {
63 2, 0, JAM1
,45, 17, &topaz8
, (UBYTE
*)"Hotkeys:", NULL
} };
65 struct NewMenu NewMenu
[] = {
66 {NM_TITLE
, "Project", 0l, 0, 0, 0l},
67 {NM_ITEM
, "New", "N", 0, 0, 0l},
68 {NM_ITEM
, "Open...", "O", 0, 0, 0l},
69 {NM_ITEM
, "Open .Info", 0, 0, 0, 0l},
70 {NM_ITEM
, NM_BARLABEL
, 0l, 0, 0l, 0l},
71 {NM_ITEM
, "Save", "S", 0, 0, 0l},
72 {NM_ITEM
, "Save As...", "A", 0, 0, 0l},
73 {NM_ITEM
, "Save As .info",0, 0, 0, 0l},
74 {NM_ITEM
, NM_BARLABEL
, 0l, 0, 0l, 0l},
75 {NM_ITEM
, "About...", 0, 0, 0, 0l},
76 {NM_ITEM
, NM_BARLABEL
, 0l, 0, 0l, 0l},
77 {NM_ITEM
, "Hide", "H", 0, 0, 0l},
78 {NM_ITEM
, "Cancel", "C", 0, 0, 0l},
79 {NM_ITEM
, NM_BARLABEL
, 0l, 0, 0l, 0l},
80 {NM_ITEM
, "Quit...", "Q", 0, 0, 0l},
81 {NM_END
, 0l, 0l, 0, 0l, 0l }};
83 long InitStuff( void )
95 if ( NOT( Scr
= LockPubScreen( "Workbench" )))
98 if ( NOT( VisualInfo
= GetVisualInfo( Scr
, TAG_DONE
)))
101 if ( NOT( g
= CreateContext( &GList
)))
104 ng
.ng_LeftEdge
= 110;
108 ng
.ng_GadgetText
= "St_op";
109 ng
.ng_TextAttr
= &topaz8
;
110 ng
.ng_GadgetID
= GD_Gadget0
;
111 ng
.ng_Flags
= PLACETEXT_LEFT
;
112 ng
.ng_VisualInfo
= VisualInfo
;
114 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[0], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
119 ng
.ng_GadgetText
= "_Newshell";
120 ng
.ng_GadgetID
= GD_Gadget1
;
122 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[1], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
127 ng
.ng_GadgetText
= "Q_uit";
128 ng
.ng_GadgetID
= GD_Gadget2
;
130 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[2], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
135 ng
.ng_GadgetText
= "C_ycle";
136 ng
.ng_GadgetID
= GD_Gadget3
;
138 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[3], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
143 ng
.ng_GadgetText
= "Wo_rkbench";
144 ng
.ng_GadgetID
= GD_Gadget4
;
146 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[4], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
151 ng
.ng_GadgetText
= "C_loseWindow";
152 ng
.ng_GadgetID
= GD_Gadget5
;
154 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[5], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
158 ng
.ng_LeftEdge
= 409;
160 ng
.ng_GadgetText
= "_ActivateFront";
161 ng
.ng_GadgetID
= GD_Gadget6
;
163 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[6], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
168 ng
.ng_GadgetText
= "Make_Big";
169 ng
.ng_GadgetID
= GD_Gadget7
;
171 g
= CreateGadget( STRING_KIND
, g
, &ng
, GTST_String
,keys
[7],GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
176 ng
.ng_GadgetText
= "MakeS_mall";
177 ng
.ng_GadgetID
= GD_Gadget8
;
179 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[8], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
184 ng
.ng_GadgetText
= "_Zip";
185 ng
.ng_GadgetID
= GD_Gadget9
;
187 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[9], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
192 ng
.ng_GadgetText
= "Sho_w";
193 ng
.ng_GadgetID
= GD_Gadget10
;
195 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[10], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
199 ng
.ng_GadgetText
= "Ac_tiveToFront";
201 ng
.ng_GadgetID
= GD_Gadget11
;
203 g
= CreateGadget( STRING_KIND
, g
, &ng
,GTST_String
,keys
[11], GTST_MaxChars
, 256, GT_Underscore
, '_', TAG_DONE
);
207 ng
.ng_LeftEdge
= 110;
210 ng
.ng_GadgetText
= "_Save";
211 ng
.ng_GadgetID
= GD_GadgetSave
;
212 ng
.ng_Flags
= PLACETEXT_IN
;
214 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, '_', TAG_DONE
);
218 ng
.ng_LeftEdge
= 201;
219 ng
.ng_GadgetText
= "_Hide";
220 ng
.ng_GadgetID
= GD_GadgetHide
;
222 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, '_', TAG_DONE
);
226 ng
.ng_LeftEdge
= 381;
227 ng
.ng_GadgetText
= "_Quit";
228 ng
.ng_GadgetID
= GD_GadgetQuit
;
230 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, '_', TAG_DONE
);
234 ng
.ng_LeftEdge
= 292;
235 ng
.ng_GadgetText
= "_Cancel";
236 ng
.ng_GadgetID
= GD_GadgetCancel
;
238 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, '_', TAG_DONE
);
245 WindowTags
[ 6 ].ti_Data
= (IPTR
)GList
;
247 if ( NOT( Menus
= CreateMenus( NewMenu
, GTMN_FrontPen
, 0l, TAG_DONE
)))
250 LayoutMenus( Menus
, VisualInfo
, GTMN_TextAttr
, &topaz8
, TAG_DONE
);
252 if(WindowTags
[0].ti_Data
==-10) /* Bei -10 1.Aufruf und in die mitte */
254 WindowTags
[0].ti_Data
=(Scr
->Width
-WindowTags
[2].ti_Data
)/2;
255 WindowTags
[1].ti_Data
=(Scr
->Height
-WindowTags
[3].ti_Data
)/2;
258 strcpy(&windowtitle
[26],keys
[10]);
260 if ( NOT( Wnd
= OpenWindowTagList( 0l, WindowTags
)))
263 SetMenuStrip( Wnd
, Menus
);
264 GT_RefreshWindow( Wnd
, 0l );
266 PrintIText( Wnd
->RPort
, IText
, 0l, 0l );
273 void CleanStuff( void )
275 if(windowopen
==FALSE
)return;
278 ClearMenuStrip( Wnd
);
284 WindowTags
[0].ti_Data
= (LONG
)Wnd
->LeftEdge
;
285 WindowTags
[1].ti_Data
= (LONG
)Wnd
->TopEdge
;
286 WindowTags
[2].ti_Data
= (LONG
)Wnd
->Width
;
287 WindowTags
[3].ti_Data
= (LONG
)Wnd
->Height
;
293 FreeGadgets( GList
);
296 FreeVisualInfo( VisualInfo
);
299 UnlockPubScreen( 0l, Scr
);