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 dopusfunction
*seldrive
;
38 UWORD code
,gadgetid
,qual
;
39 struct ConfigUndo
*undo
;
40 struct DOpusRemember
*gadkey
;
41 struct dopusfunction
*seconddrive
;
43 struct Border
*unselborder
,*selborder
;
44 int a
,b
,x
,y
,mode
=-1,editon
=0,dnum
=-1,odnum
;
49 if (!(drivegads
=(struct Gadget
*)LAllocRemember(&gadkey
,sizeof(struct Gadget
)*USEDRIVECOUNT
,
50 MEMF_CLEAR
))) return(0);
52 CreateGadgetBorders(&gadkey
,
54 &selborder
,&unselborder
,
56 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
);
58 seldrive
=NULL
; seligad
=NULL
;
62 for (a
=0;a
<USEDRIVECOUNT
;a
++) {
63 drivegads
[a
].NextGadget
=(a
<USEDRIVECOUNT
-1)?&drivegads
[a
+1]:NULL
;
64 drivegads
[a
].LeftEdge
=x
;
65 drivegads
[a
].TopEdge
=y
;
66 drivegads
[a
].Width
=80;
67 drivegads
[a
].Height
=10;
68 drivegads
[a
].Flags
=(selborder
)?GFLG_GADGHIMAGE
:GFLG_GADGHCOMP
;
69 drivegads
[a
].Activation
=GACT_RELVERIFY
;
70 drivegads
[a
].GadgetType
=GTYP_BOOLGADGET
;
71 drivegads
[a
].GadgetID
=a
+100;
72 drivegads
[a
].GadgetRender
=unselborder
;
73 drivegads
[a
].SelectRender
=selborder
;
74 if ((y
+=10)>=y_off
+62) {
80 namesinfo
.MaxChars
=16;
81 showconfigscreen(CFG_DRIVE
);
84 ClearMenuStrip(Window
);
85 projectmenu
.NextMenu
=&neatstuffmenu
;
86 neatstuffitem
.Flags
&=~CHECKED
;
87 neatstuffmenu
.LeftEdge
=140;
88 FSSetMenuStrip(Window
,&projectmenu
);
89 undo
=makeundo(UNDO_DRIVE
);
94 Wait(1<<Window
->UserPort
->mp_SigBit
);
95 while (IMsg
=getintuimsg()) {
96 class=IMsg
->Class
; code
=IMsg
->Code
; x
=IMsg
->MouseX
; y
=IMsg
->MouseY
;
98 if (class==GADGETUP
|| class==GADGETDOWN
) {
99 gad
=(struct Gadget
*)IMsg
->IAddress
;
100 gadgetid
=gad
->GadgetID
;
102 ReplyMsg((struct Message
*)IMsg
);
105 if (code
==MENUNULL
) break;
107 select_gadget(seligad
,0);
108 seligad
=NULL
; seldrive
=NULL
;
115 select_gadget(&maingad
[mode
],0);
119 switch (MENUNUM(code
)) {
121 switch ((a
=ITEMNUM(code
))) {
124 if (doload(CFG_DRIVE
,a
)) {
126 if (a
) dogadgetinfo(cfg_string
[STR_NEW_DRIVE_BANKS_LOADED
]);
127 else dogadgetinfo(cfg_string
[STR_DEFAULT_DRIVE_BANKS_RESET
]);
133 if (ITEMNUM(code
)==0) {
134 if (neatstuffitem
.Flags
&CHECKED
) {
135 if (!(paint_state
=get_paint_colours(&paint_fg
,&paint_bg
,CFG_GADGET
))) {
136 ClearMenuStrip(Window
);
137 neatstuffitem
.Flags
&=~CHECKED
;
138 FSSetMenuStrip(Window
,&projectmenu
);
142 do_menuscreen_title(STR_DRIVE_SCREEN
);
149 if (!seldrive
|| !editon
|| (code
>=0x60 && code
<=0x67) || code
&0x80)
151 if (editdrivegadgets
[1].Flags
&SELECTED
) {
152 qual
&=IEQUALIFIER_LCOMMAND
|IEQUALIFIER_RCOMMAND
|
153 IEQUALIFIER_CONTROL
|IEQUALIFIER_LSHIFT
|IEQUALIFIER_RSHIFT
|
154 IEQUALIFIER_LALT
|IEQUALIFIER_RALT
;
155 showkey(seldrive
->key
=code
,seldrive
->qual
=qual
,x_off
+150,y_off
+129,331,10);
159 RawkeyToStr(code
,qual
,NULL
,buf
,10);
160 c
= LToLower(buf
[0]);
161 if (c
== getkeyshortcut(cfg_string
[STR_EDIT_NAME
]))
162 ActivateStrGad(&editdrivegadgets
[0],Window
);
163 else if (c
== getkeyshortcut(cfg_string
[STR_SHORTCUT_KEY
]))
165 fixrmbimage(&sampleclearrmb
,NULL
,0,-1,-1);
166 editdrivegadgets
[1].Flags
|=SELECTED
;
167 select_gadget(&editdrivegadgets
[1],1);
168 fixrmbimage(&sampleclearrmb
,NULL
,1,-1,-1);
170 else if (c
== getkeyshortcut(cfg_string
[STR_PATH
]))
171 ActivateStrGad(&editdrivegadgets
[3],Window
);
174 case IDCMP_MOUSEBUTTONS
:
175 if (code
==SELECTDOWN
) {
176 if (seldrive
&& editon
) {
177 a
=seldrive
->fpen
; b
=seldrive
->bpen
;
178 if (docolourgad(rp
,x_off
+150,y_off
+76,x
,y
,seldrive
->name
,&a
,&b
,CFG_DRIVE
)) {
179 seldrive
->fpen
=a
; seldrive
->bpen
=b
;
180 showdrivename(seldrive
,seligad
);
184 else if (code
==MENUDOWN
) {
185 if (!seldrive
|| !editon
) break;
186 if (fixrmbimage(&sampleclearrmb
,NULL
,0,x
,y
)) {
187 a
=DoRMBGadget(&sampleclearrmb
,Window
);
188 fixrmbimage(&sampleclearrmb
,NULL
,1,-1,-1);
189 if (a
==0) showkey(seldrive
->key
=0xFF,seldrive
->qual
=0,x_off
+150,y_off
+129,331,10);
190 editdrivegadgets
[1].Flags
&=~SELECTED
;
197 if (gadgetid
<DRIVE_OKAY
) {
199 select_gadget(seligad
,0);
200 seligad
=NULL
; seldrive
=NULL
;
206 if (mode
==gadgetid
) {
212 select_gadget(&maingad
[mode
],0);
216 else if (gadgetid
>=100) {
218 odnum
=dnum
; dnum
=a
/6;
220 if (mode
==DRIVE_DELETEDRIVE
) {
221 deletedrive(&config
->drive
[a
]);
223 dogadgetinfo(cfg_string
[STR_DRIVE_GADGET_DELETED
]);
224 showdrivename(seldrive
,gad
);
226 else if (!seldrive
) {
227 seldrive
=&config
->drive
[a
];
229 select_gadget(gad
,1);
231 case DRIVE_COPYDRIVE
:
232 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_TO_COPY_TO
]);
234 case DRIVE_SWAPDRIVE
:
235 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_TO_SWAP_WITH_FIRST
]);
238 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_BANK_TO_COPY_TO
]);
241 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_BANK_TO_SWAP_WITH_FIRST
]);
243 case DRIVE_DELETEBANK
:
244 if (request(cfg_string
[STR_REALLY_DELETE_DRIVE_BANK
])) {
246 for (a
=x
;a
<b
;a
++) deletedrive(&config
->drive
[a
]);
250 doinitdrivetext(mode
);
256 doinitdrivetext(mode
);
261 seconddrive
=&config
->drive
[a
];
262 if (seldrive
==seconddrive
) select_gadget(gad
,0);
265 case DRIVE_COPYDRIVE
:
266 CopyMem((char *)seldrive
,(char *)seconddrive
,sizeof(struct dopusfunction
));
267 seconddrive
->function
=getcopy(seldrive
->function
,-1,NULL
);
269 case DRIVE_SWAPDRIVE
:
270 SwapMem((char *)seldrive
,(char *)seconddrive
,sizeof(struct dopusfunction
));
275 CopyMem((char *)&config
->drive
[(odnum
*6)+a
],
276 (char *)&config
->drive
[(dnum
*6)+a
],sizeof(struct dopusfunction
));
277 config
->drive
[(dnum
*6)+a
].function
=getcopy(config
->drive
[(odnum
*6)+a
].function
,-1,NULL
);
283 SwapMem((char *)&config
->drive
[odnum
*6],
284 (char *)&config
->drive
[dnum
*6],sizeof(struct dopusfunction
)*6);
290 seldrive
=NULL
; seligad
=NULL
;
291 doinitdrivetext(mode
);
296 config
->drive
[a
].fpen
=paint_fg
;
297 config
->drive
[a
].bpen
=paint_bg
;
298 showdrivename(&config
->drive
[a
],gad
);
301 if (seldrive
&& editon
) select_gadget(seligad
,0);
302 if (seldrive
==&config
->drive
[a
]) {
307 seligad
=gad
; seldrive
=&config
->drive
[a
];
308 showdrivename(seldrive
,gad
);
309 setupcolourbox(rp
,x_off
+150,y_off
+76,seldrive
->fpen
,seldrive
->bpen
);
310 strcpy(edit_namebuf
,seldrive
->name
);
311 if (seldrive
->function
) strcpy(edit_pathbuf
,seldrive
->function
);
312 else edit_pathbuf
[0]=0;
313 SetAPen(rp
,screen_pens
[1].pen
);
315 do_gad_label(cfg_string
[STR_SHORTCUT_KEY
],x_off
+139,y_off
+136);
316 do_gad_label(cfg_string
[STR_PATH
],x_off
+139,y_off
+122);
317 editdrivegadgets
[1].Flags
&=~SELECTED
;
322 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
,1);
323 fixrmbimage(&sampleclearrmb
,&editdrivegadgets
[1],2,-1,-1);
324 doglassimage(&editdrivegadgets
[2]);
327 RefreshStrGad(&editdrivegadgets
[0],Window
);
328 RefreshStrGad(&editdrivegadgets
[3],Window
);
330 if (editdrivegadgets
[1].Flags
&SELECTED
) {
331 fixrmbimage(&sampleclearrmb
,NULL
,0,-1,-1);
332 editdrivegadgets
[1].Flags
&=~SELECTED
;
333 select_gadget(&editdrivegadgets
[1],0);
334 fixrmbimage(&sampleclearrmb
,NULL
,1,-1,-1);
336 showfuncob(rp
,seldrive
->name
,seldrive
->fpen
,seldrive
->bpen
,CFG_DRIVE
,x_off
+244,y_off
+66);
337 showkey(seldrive
->key
,seldrive
->qual
,x_off
+150,y_off
+129,331,10);
344 case DRIVE_GETDRIVES
:
346 char fpen_back
[USEDRIVECOUNT
],bpen_back
[USEDRIVECOUNT
];
349 for (a
=0;a
<USEDRIVECOUNT
;a
++) {
350 fpen_back
[a
]=config
->drive
[a
].fpen
;
351 bpen_back
[a
]=config
->drive
[a
].bpen
;
356 for (a
=0;a
<USEDRIVECOUNT
;a
++) {
357 config
->drive
[a
].fpen
=fpen_back
[a
];
358 config
->drive
[a
].bpen
=bpen_back
[a
];
361 dogadgetinfo(cfg_string
[STR_SYSTEM_DEVICES_LISTED
]);
366 strcpy(seldrive
->name
,edit_namebuf
);
367 showfuncob(rp
,seldrive
->name
,seldrive
->fpen
,seldrive
->bpen
,CFG_DRIVE
,x_off
+244,y_off
+66);
368 showdrivename(seldrive
,seligad
);
369 if (code
!=0x9) getnextgadget(gad
);
373 freestring(seldrive
->function
);
374 seldrive
->function
=getcopy(edit_pathbuf
,-1,NULL
);
375 if (code
!=0x9) getnextgadget(gad
);
379 strcpy(dirbuf
,edit_pathbuf
);
380 if (funcrequester(FREQ_PATHREQ
,buf
,NULL
)) {
381 LStrnCpy(edit_pathbuf
,buf
,FILEBUF_SIZE
); edit_pathbuf
[FILEBUF_SIZE
]=0;
382 b
=strlen(edit_pathbuf
);
384 if (edit_pathbuf
[a
]=='/' || edit_pathbuf
[a
]==':') {
389 freestring(seldrive
->function
);
390 seldrive
->function
=getcopy(edit_pathbuf
,-1,NULL
);
391 RefreshStrGad(&editdrivegadgets
[3],Window
);
395 case DRIVE_EDITSAMPLE
:
396 help_ok
=(editdrivegadgets
[1].Flags
&SELECTED
)?0:1;
400 doundo(undo
,UNDO_DRIVE
);
403 RemoveGList(Window
,drivegads
,USEDRIVECOUNT
);
404 LFreeRemember(&gadkey
); drivegads
=NULL
;
405 ClearMenuStrip(Window
); projectmenu
.NextMenu
=NULL
;
406 FSSetMenuStrip(Window
,&projectmenu
);
409 return((gadgetid
==DRIVE_OKAY
));
411 mode
=doinitdrivetext(gadgetid
);
422 for (a
=0;a
<USEDRIVECOUNT
;a
++)
423 showdrivename(&config
->drive
[a
],&drivegads
[a
]);
426 void showdrivename(drive
,gadget
)
427 struct dopusfunction
*drive
;
428 struct Gadget
*gadget
;
435 if (drive
) SetAPen(rp
,screen_pens
[drive
->bpen
].pen
);
436 else SetAPen(rp
,screen_pens
[0].pen
);
437 RectFill(rp
,x
+2,y
+1,x
+77,y
+8);
438 do3dbox(x
+2,y
+1,76,8);
440 SetAPen(rp
,screen_pens
[drive
->fpen
].pen
);
441 SetBPen(rp
,screen_pens
[drive
->bpen
].pen
);
442 strcpy(showname
,drive
->name
);
443 l
= (80-8)/rp
->Font
->tf_XSize
;
445 UScoreText(rp
,showname
,x
+((80-((a
=strlen(showname
))*rp
->Font
->tf_XSize
))/2),y
+7,-1);
446 SetBPen(rp
,screen_pens
[0].pen
);
447 if (seldrive
==drive
) select_gadget(seligad
,1);
451 int doinitdrivetext(id
)
459 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_BANK_TO_COPY
]);
463 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_BANK_TO_SWAP
]);
465 case DRIVE_DELETEBANK
:
466 mode
=DRIVE_DELETEBANK
;
467 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_BANK_TO_DELETE
]);
471 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_BANK_TO_SORT
]);
473 case DRIVE_COPYDRIVE
:
474 mode
=DRIVE_COPYDRIVE
;
475 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_GADGET_TO_COPY
]);
477 case DRIVE_SWAPDRIVE
:
478 mode
=DRIVE_SWAPDRIVE
;
479 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_GADGET_TO_SWAP
]);
481 case DRIVE_DELETEDRIVE
:
482 mode
=DRIVE_DELETEDRIVE
;
483 dogadgetinfo(cfg_string
[STR_SELECT_DRIVE_GADGET_TO_DELETE
]);
489 int docolourgad(r
,x
,y
,mx
,my
,name
,fp
,bp
,type
)
497 if (my
>y
&& my
<y
+21) {
498 for (box
=0;box
<2;box
++) {
499 for (num
=0;num
<colour_box_num
;num
++) {
500 if (mx
>=colour_box_xy
[box
][num
][0] && mx
<=colour_box_xy
[box
][num
][2] &&
501 my
>=colour_box_xy
[box
][num
][1] && my
<=colour_box_xy
[box
][num
][3]) {
502 if ((box
==0 && *fp
!=num
) || (box
==1 && *bp
!=num
)) {
503 docoloursel(r
,x
+(box
*248),y
,(box
==0)?*fp
:*bp
);
504 docoloursel(r
,x
+(box
*248),y
,num
);
507 if (name
) showfuncob(r
,name
,*fp
,*bp
,type
,x
+94,y
-10);
520 seldrive
=NULL
; seligad
=NULL
;
521 SetAPen(rp
,screen_pens
[0].pen
);
525 RemoveGList(Window
,editdrivegadgets
,4);
528 void deletedrive(drive
)
529 struct dopusfunction
*drive
;
532 freestring(drive
->function
); drive
->function
=NULL
;
536 drive
->fpen
=paint_fg
;
537 drive
->bpen
=paint_bg
;
545 void sortdrivebank(m
)
549 char *ptr1
,*ptr2
,*zstr
="\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f";
552 for (gap
=3;gap
>0;gap
/=2)
554 for (j
=i
-gap
;j
>=0;j
-=gap
) {
556 ptr1
=(config
->drive
[j
+m
].name
[0])?config
->drive
[j
+m
].name
:zstr
;
557 ptr2
=(config
->drive
[k
+m
].name
[0])?config
->drive
[k
+m
].name
:zstr
;
558 if (LStrCmpI(ptr1
,ptr2
)<=0) break;
559 SwapMem((char *)&config
->drive
[j
+m
],(char *)&config
->drive
[k
+m
],
560 sizeof(struct dopusfunction
));