4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
33 static struct DOpusRemember
*hkey
;
34 static char **hotkeylist
;
40 struct ConfigUndo
*undo
;
41 struct DOpusListView
*view
;
42 struct dopushotkey hotkey
,*newhot
,*hot
,*swapfirst
=NULL
;
45 showconfigscreen(CFG_HOTKEYS
);
47 undo
=makeundo(UNDO_HOTKEYS
);
50 Wait(1<<Window
->UserPort
->mp_SigBit
);
51 while (IMsg
=getintuimsg()) {
52 if ((view
=ListViewIDCMP(&hotkeyslist
,IMsg
))==(struct DOpusListView
*)-1) {
53 class=IMsg
->Class
; code
=IMsg
->Code
;
54 if (class==GADGETUP
|| class==GADGETDOWN
)
55 gadgetid
=((struct Gadget
*)IMsg
->IAddress
)->GadgetID
;
56 ReplyMsg((struct Message
*)IMsg
);
59 if (code
==MENUNULL
) break;
61 select_gadget(&maingad
[mode
],0);
65 switch ((a
=ITEMNUM(code
))) {
68 if (doload(CFG_HOTKEYS
,a
)) {
70 if (a
) dogadgetinfo(cfg_string
[STR_NEW_HOTKEYS_MERGED
]);
71 else dogadgetinfo(cfg_string
[STR_DEFAULT_HOTKEYS_MERGED
]);
77 if (gadgetid
!=HOTKEYS_OKAY
&& gadgetid
!=HOTKEYS_CANCEL
) {
78 if (mode
==HOTKEYS_SWAP
&& swapfirst
) {
80 view
->itemselected
=-1;
89 select_gadget(&maingad
[mode
],0);
96 if (gadgetid
==HOTKEYS_CANCEL
) doundo(undo
,UNDO_HOTKEYS
);
98 RemoveListView(&hotkeyslist
,1);
100 return((gadgetid
==HOTKEYS_OKAY
));
101 case HOTKEYS_NEWHOTKEY
:
102 hotkey
.name
[0]=0; hotkey
.func
.function
=NULL
;
103 hotkey
.code
=hotkey
.qualifier
=0;
105 hotkey
.func
.stack
=4000;
106 hotkey
.func
.type
=1; hotkey
.func
.pri
=0;
107 hotkey
.func
.key
=hotkey
.func
.qual
=0;
110 if (doedithotkey(&hotkey
)) {
111 if (newhot
=(struct dopushotkey
*)
112 getcopy((char *)&hotkey
,sizeof(struct dopushotkey
),NULL
)) {
113 newhot
->func
.function
=getcopy(hotkey
.func
.function
,-1,NULL
);
116 if (!hot
->next
) break;
119 if (hot
) hot
->next
=newhot
;
120 else firsthotkey
=newhot
;
124 freefunction(&hotkey
.func
);
129 dogadgetinfo(cfg_string
[STR_SELECT_HOTKEY_TO_DELETE
]);
131 case HOTKEYS_DUPLICATE
:
132 mode
=HOTKEYS_DUPLICATE
;
133 dogadgetinfo(cfg_string
[STR_SELECT_HOTKEY_TO_DUPLICATE
]);
137 dogadgetinfo(cfg_string
[STR_SELECT_HOTKEY_TO_SWAP
]);
144 if (view
->itemselected
>-1) {
146 for (a
=0;a
<view
->itemselected
;a
++,hot
=hot
->next
) {
153 view
->itemselected
=-1;
158 if (request(cfg_string
[STR_REALLY_DELETE_HOTKEY
])) {
159 dogadgetinfo(cfg_string
[STR_HOTKEY_DELETED
]);
160 if (hot
==firsthotkey
) firsthotkey
=firsthotkey
->next
;
161 else newhot
->next
=hot
->next
;
162 freefunction(&hot
->func
);
163 FreeMem(hot
,sizeof(struct dopushotkey
));
165 else dogadgetinfo(cfg_string
[STR_SELECT_HOTKEY_TO_DELETE
]);
168 case HOTKEYS_DUPLICATE
:
169 CopyMem((char *)hot
,(char *)&hotkey
,sizeof(struct dopushotkey
));
170 hotkey
.func
.function
=getcopy(hot
->func
.function
,-1,NULL
);
176 SwapMem((char *)&swapfirst
->code
,
178 sizeof(struct dopushotkey
)-sizeof(struct dopushotkey
*));
179 view
->itemselected
=-1;
181 dogadgetinfo(cfg_string
[STR_SELECT_HOTKEY_TO_SWAP
]);
185 dogadgetinfo(cfg_string
[STR_SELECT_SECOND_HOTKEY_TO_SWAP
]);
197 void makehotkeylist()
199 struct dopushotkey
*hotkey
;
200 char *buf
,str
[40],name
[40];
203 LFreeRemember(&hkey
); hotkeylist
=NULL
;
205 for (count
=0;;count
++) {
210 (hotkeylist
=LAllocRemember(&hkey
,(count
+1)*sizeof(APTR
),MEMF_CLEAR
)) &&
211 (buf
=LAllocRemember(&hkey
,count
*80,MEMF_CLEAR
))) {
213 for (a
=0;a
<count
;a
++) {
214 hotkeylist
[a
]=&buf
[a
*80];
215 RawkeyToStr(hotkey
->code
,hotkey
->qualifier
,str
,NULL
,39); str
[39]=0;
216 strcpy(name
,hotkey
->name
); name
[36]=0;
217 lsprintf(hotkeylist
[a
],"%-36s %s",name
,str
);
221 else hotkeylist
=NULL
;
222 hotkeyslist
.items
=hotkeylist
; hotkeyslist
.itemselected
=-1;
223 RefreshListView(&hotkeyslist
,1);
226 int doedithotkey(hotkey
)
227 struct dopushotkey
*hotkey
;
231 RemoveListView(&hotkeyslist
,1);
233 doscreentitle(cfg_string
[STR_HOTKEY_EDIT_SCREEN
]);
234 a
=editfunction(&hotkey
->func
,CFG_HOTKEYS
,hotkey
);
235 showconfigscreen(CFG_HOTKEYS
);
239 void drawcornerimage(r
,x1
,y1
,bc
,tc
)
243 SetAPen(r
,screen_pens
[0].pen
);
244 RectFill(r
,x1
-5,y1
-1,x1
,y1
+3);
246 SetAPen(r
,screen_pens
[bc
].pen
);
247 BltTemplate((char *)pageflip_data1
,0,2,r
,x1
-6,y1
-1,6,5);
248 SetAPen(r
,screen_pens
[tc
].pen
);
249 BltTemplate((char *)pageflip_data2
,0,2,r
,x1
-6,y1
,6,3);
253 int fixrmbimage(rmb
,gad
,on
,x
,y
)
254 struct RMBGadget
*rmb
;
259 struct RMBGadget
*rmbgad
;
264 rmbgad
->high_bord
[0]=gadget_unsel_border
;
265 rmbgad
->high_bord
[1]=gadget_sel_border
;
266 rmbgad
->flags
|=RGF_ALTBORD
;
267 if (rmbgad
->flags
&RGF_ALTTEXT
) {
269 rmbgad
->txt
[a
].fg
=screen_pens
[1].pen
;
270 rmbgad
->txt
[a
].bg
=screen_pens
[0].pen
;
274 rmbgad
->x
=gad
->LeftEdge
;
275 rmbgad
->y
=gad
->TopEdge
;
278 (x
>=rmbgad
->x
&& x
<rmbgad
->x
+rmbgad
->w
&&
279 y
>=rmbgad
->y
&& y
<rmbgad
->y
+rmbgad
->h
)) {
281 drawcornerimage(rp
,rmbgad
->x
+rmbgad
->w
,rmbgad
->y
+1,config
->gadgetbotcol
,config
->gadgettopcol
);
282 else do3dbox(rmbgad
->x
+2,rmbgad
->y
+1,rmbgad
->w
-4,rmbgad
->h
-2);
287 gad
->GadgetRender
=gadget_dog_unsel_border
;
288 gad
->SelectRender
=gadget_dog_sel_border
;
289 gad
->Flags
|=GFLG_GADGHIMAGE
;
290 gad
->Flags
&=~GFLG_GADGHCOMP
;
294 if (gad
->LeftEdge
==rmbgad
->x
&& gad
->TopEdge
==rmbgad
->y
) break;
304 void doradiobuttons()
308 LFreeRemember(&buttonkey
);
312 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
,
313 screen_pens
[0].pen
,screen_pens
[0].pen
,&buttonkey
);
317 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
,
318 screen_pens
[3].pen
,screen_pens
[0].pen
,&buttonkey
);
321 GetCheckImage(screen_pens
[1].pen
,screen_pens
[0].pen
,0,&buttonkey
))
322 CopyMem((char *)checkoffimage
,(char *)©_checkoffimage
,sizeof(struct Image
));
323 else copy_checkoffimage
.ImageData
=NULL
;
326 GetCheckImage(screen_pens
[1].pen
,screen_pens
[0].pen
,1,&buttonkey
))
327 CopyMem((char *)checkonimage
,(char *)©_checkonimage
,sizeof(struct Image
));
328 else copy_checkonimage
.ImageData
=NULL
;
331 stringex
.Pens
[0]=screen_pens
[config
->stringfgcol
].pen
;
332 stringex
.Pens
[1]=screen_pens
[config
->stringbgcol
].pen
;
333 stringex
.ActivePens
[0]=screen_pens
[config
->stringselfgcol
].pen
;
334 stringex
.ActivePens
[1]=screen_pens
[config
->stringselbgcol
].pen
;
336 CreateGadgetBorders(&buttonkey
,
338 &gadget_dog_sel_border
,&gadget_dog_unsel_border
,
340 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
);
342 CreateGadgetBorders(&buttonkey
,
344 &gadget_sel_border
,&gadget_unsel_border
,
346 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
);
348 fix_gadget_border(&cmdcancelgad
);
349 fix_gadget_border(&helpcancelgad
);
350 for (a
=0;a
<3;a
++) fix_gadget_border(&listokaygad
[a
]);
353 void fix_gadget_border(gad
)
356 gad
->Flags
=(gadget_sel_border
)?GFLG_GADGHIMAGE
:GFLG_GADGHCOMP
;
357 gad
->GadgetRender
=gadget_unsel_border
;
358 gad
->SelectRender
=gadget_sel_border
;
361 void select_gadget(gad
,state
)
365 if ((state
&& !gad
->SelectRender
) || (!state
&& !gad
->GadgetRender
))
368 if (state
) DrawBorder(rp
,gad
->SelectRender
,gad
->LeftEdge
,gad
->TopEdge
);
369 else DrawBorder(rp
,gad
->GadgetRender
,gad
->LeftEdge
,gad
->TopEdge
);
371 if (gad
->Activation
&GACT_TOGGLESELECT
) {
372 if (state
) gad
->Flags
|=GFLG_SELECTED
;
373 else gad
->Flags
&=~GFLG_SELECTED
;
377 void fix_gadget_positions()
381 for (a
=0;a
<3;a
++) fix_gad_pos(&menuslidergads
[a
],menuslidergads_xy
[a
]);
383 fix_gad_pos(&editdrivegadgets
[a
],editdrivegadgets_xy
[a
]);
384 fix_gad_pos(&icongads
[a
],icongads_xy
[a
]);
386 for (a
=0;a
<6;a
++) fix_gad_pos(&palettegads
[a
],palettegads_xy
[a
]);
387 for (a
=0;a
<7;a
++) fix_gad_pos(&screenmodegads
[a
],screenmodegads_xy
[a
]);
388 for (a
=0;a
<8;a
++) fix_gad_pos(&arrowgadgets
[a
],arrowgadgets_xy
[a
]);
389 for (a
=0;a
<12/*HUX: was 10*/;a
++) fix_gad_pos(&formatgads
[a
],formatgads_xy
[a
]);
390 for (a
=0;a
<14;a
++) fix_gad_pos(&editclassgadgets
[a
],editclassgadgets_xy
[a
]);
391 for (a
=0;a
<15;a
++) fix_gad_pos(&editfuncgadgets
[a
],editfuncgadgets_xy
[a
]);
392 fix_gad_pos(&coloursgad
,coloursgad_xy
);
393 fix_gad_pos(&hotkeymmbgad
,hotkeymmbgad_xy
);
394 fix_gad_pos(&hotkeygad
,hotkeygad_xy
);
395 fix_gad_pos(&fontsizegadget
,fontsizegadget_xy
);
396 for (a
=0;a
<2;a
++) fix_gad_pos(&screen_sliders_gadgets
[a
],screen_sliders_gadgets_xy
[a
]);
399 void fix_gad_pos(gad
,pos
)
403 gad
->LeftEdge
=x_off
+pos
[0];
404 gad
->TopEdge
=y_off
+pos
[1];