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.
39 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
40 void chkabort(void) { return; }
51 char portname
[50],rportname
[50],oldconfigname
[256]/*,oldlanguage[30]*/;
52 struct WBStartup
*wbmsg
;
53 struct ConfigUndo
*undo
;
56 if (sizeof(struct Config
)!=CONFIG_STRUCTURE_SIZE
) {
57 kprintf("invalid config size - %ld - should be %ld\n",sizeof(struct Config
),CONFIG_STRUCTURE_SIZE
);
62 if (!(DOpusBase
=(struct DOpusBase
*)OpenLibrary("dopus.library",LIB_VER
)) &&
63 !(DOpusBase
=(struct DOpusBase
*)OpenLibrary("dopus:libs/dopus.library",LIB_VER
)))
66 if (DOpusBase
->LibNode
.lib_Revision
< LIB_REV
)
68 CloseLibrary((struct Library
*)DOpusBase
);
72 GfxBase
=DOpusBase
->GfxBase
;
73 LayersBase
=(struct Library
*)DOpusBase
->LayersBase
;
74 IntuitionBase
=DOpusBase
->IntuitionBase
;
76 // WorkbenchBase=IconBase=NULL;
78 DiskfontBase
=OpenLibrary("diskfont.library",0);
79 WorkbenchBase
=OpenLibrary("workbench.library",37);
80 IconBase
=OpenLibrary("icon.library",0);
85 if (FindName(&SysBase
->LibList
,"services.library") || (FindName(&SysBase
->LibList
,"multiuser.library")))
88 formatgads
[8 /* HUX: was 7 */].NextGadget
=&formatgads
[9 /* HUX: was 8 */];
92 if (SysBase
->LibNode
.lib_Version
>=40) version2
=OSVER_40
;
93 else /*if (SysBase->LibNode.lib_Version==39)*/ version2
=OSVER_39
;
94 /* else if (SysBase->LibNode.lib_Version==38) version2=OSVER_38;
95 else if (SysBase->LibNode.lib_Version==37) version2=OSVER_37;
96 else version2=OSVER_34;
98 if (version2<OSVER_37) {
99 operationgadgets[OP_UPDATE][10].type=CTYPE_SKIP;
100 systemgadgets[SYS_CLOCK][18].type=CTYPE_SKIP;
101 scr_generalgadgets[7].type=CTYPE_SKIP;
103 if (version2<OSVER_39) {
104 scr_generalgadgets[6].type=CTYPE_SKIP;
105 systemgadgets[SYS_VIEWPLAY][4].type=CTYPE_SKIP;
106 systemgadgets[SYS_VIEWPLAY][5].type=CTYPE_SKIP;
108 else*/ if (!(GfxBase
->ChipRevBits0
&GFXF_AA_ALICE
)) {
109 systemgadgets
[SYS_VIEWPLAY
][4].type
=CTYPE_SKIP
;
114 if (version2
<OSVER_40
) {
115 systemgadgets
[SYS_DIRECTORIES
][11].type
=CTYPE_SKIP
;
117 /* Initialized in data.c */
119 conport=cmdport=appport=NULL;
121 mainkey=buttonkey=gadgetkey=tickkey=clipkey=fontkey=NULL;
122 firsttype=NULL; firstbank=curbank=NULL;
123 typekey=NULL; firsthotkey=NULL;
124 Screen=NULL; Window=NULL;
127 tickgad=maingad=gadgads=drivegads=menugads=NULL;
129 undoconfig=NULL; config=NULL;
130 changed=lchanged=clipcount=tickcount=0;
133 helpbuffer=NULL; helpkey=NULL;
135 stringdata.string_table=NULL;
136 stringdata.string_buffer=NULL;
138 free_colour_table(NULL
);
143 clip_port=NULL; clip_io=NULL;
145 currenthelpname
[0]=0;
147 if (!(FindSystemFile("DirectoryOpus.CFG",configname
,256,SYSFILE_DATA
))) {
148 if (CheckExist("DOpus:S",NULL
)) strcpy(configname
,"DOpus:S/DirectoryOpus.CFG");
149 else strcpy(configname
,"s:DirectoryOpus.CFG");
152 if(!(FindSystemFile("DirectoryOpus.CLA",classname
,256,SYSFILE_DATA
))) classname
[0]=0;
156 dropboxicon
= GetDiskObject(argv
[0]);
159 wbmsg
=(struct WBStartup
*)argv
;
161 dropboxicon
= GetDiskObject(wbmsg
->sm_ArgList
->wa_Name
);
163 if (wbmsg
->sm_NumArgs
>1) {
164 num
=atoi(wbmsg
->sm_ArgList
[1].wa_Name
);
165 lsprintf(portname
,"dopus4_config_port%ld",(long int)num
);
166 if (!(conport
=LCreatePort(portname
,20))) quit();
167 lsprintf(rportname
,"dopus4_config_reply%ld",(long int)num
);
169 if (!(cmdport
=FindPort(rportname
))) {
170 LDeletePort(conport
);
176 if (!dropboxicon
) dropboxicon
= &dropboxobj
;
178 myproc
=(struct Process
*)FindTask(0);
179 wsave
=myproc
->pr_WindowPtr
;
180 myproc
->pr_WindowPtr
=(APTR
)-1;
183 if (!(functypelist
[a
]=LAllocRemember(&mainkey
,40,MEMF_CLEAR
))) quit();
184 functypelist
[13]=NULL
;
186 if (!cmdport
&& !(config
=(struct Config
*)AllocMem(sizeof(struct Config
),MEMF_CLEAR
)))
189 strcpy(oldconfigname
,configname
);
191 appport
=LCreatePort(NULL
,0);
193 if (clip_port=LCreatePort(NULL,0))
194 clip_io=(struct IOClipReq *)LCreateExtIO(clip_port,sizeof(struct IOClipReq));
201 if (config
->scrdepth
<2) config
->scrdepth
+=2;
205 undo
=makeundo(UNDO_ALL
);
206 showconfigscreen(CFG_MAINMENU
);
210 Wait(1<<Window
->UserPort
->mp_SigBit
);
211 while (IMsg
=getintuimsg()) {
212 class=IMsg
->Class
; code
=IMsg
->Code
;
213 if (class==GADGETUP
|| class==GADGETDOWN
)
214 gadgetid
=((struct Gadget
*)IMsg
->IAddress
)->GadgetID
;
215 ReplyMsg((struct Message
*)IMsg
);
218 if (code
==MENUNULL
) break;
219 switch ((num
=ITEMNUM(code
))) {
222 if (lchanged
&& !request(cfg_string
[STR_REALLY_DISCARD_CONFIG
]))
224 // strcpy(oldlanguage,config->language);
225 if (doload(CFG_MAINMENU
,num
)) {
226 // if (strcmp(config->language,oldlanguage)) {
234 configmsg(CONFIG_NEW_HOTKEY
);
235 showconfigscreen(CFG_MAINMENU
);
241 curoperation
=gadgetid
;
244 if (dodriveconfig()) lchanged
=1;
245 showconfigscreen(CFG_MAINMENU
);
248 if (dofiletypeconfig()) lchanged
=1;
249 showconfigscreen(CFG_MAINMENU
);
252 if (dogadgetconfig()) lchanged
=1;
253 showconfigscreen(CFG_MAINMENU
);
256 if (dohotkeysconfig()) lchanged
=1;
257 showconfigscreen(CFG_MAINMENU
);
260 if (domenuconfig()) lchanged
=1;
261 showconfigscreen(CFG_MAINMENU
);
264 if (dooperationconfig()) lchanged
=1;
265 showconfigscreen(CFG_MAINMENU
);
268 if (doscreenconfig()) lchanged
=1;
269 showconfigscreen(CFG_MAINMENU
);
272 if (dosystemconfig()) lchanged
=1;
273 showconfigscreen(CFG_MAINMENU
);
282 if ((gadgetid
==CFG_CANCEL
|| !cmdport
) && lchanged
&&
283 !do_request(cfg_string
[STR_EXIT_WITHOUT_SAVING
],
284 cfg_string
[STR_OKAY_TO_QUIT
],cfg_string
[STR_CANCEL
]))
286 if (gadgetid
==CFG_CANCEL
) {
287 doundo(undo
,UNDO_ALL
);
288 strcpy(configname
,oldconfigname
);
303 if (Window
) SetBusyPointer(Window
);
306 configmsg(CONFIG_ALL_DONE
);
311 if (config
) FreeMem(config
,sizeof(struct Config
));
313 if (myproc
) myproc
->pr_WindowPtr
=wsave
;
314 if (firstclip
) save_clips();
315 if (Screen
&& !onworkbench
) ScreenToBack(Screen
);
317 FreeStringFile(&stringdata
);
318 if (conport
) LDeletePort(conport
);
319 if (appport
) LDeletePort(appport
);
320 if (tfont
) CloseFont(tfont
);
321 if (dropboxicon
!= &dropboxobj
) FreeDiskObject(dropboxicon
);
323 if (clip_io) LDeleteExtIO((struct IORequest *)clip_io);
324 if (clip_port) LDeletePort(clip_port);
326 LFreeRemember(&mainkey
);
327 LFreeRemember(&clipkey
);
328 LFreeRemember(&gadgetkey
);
329 LFreeRemember(&tickkey
);
330 LFreeRemember(&fontkey
);
331 LFreeRemember(&helpkey
);
332 LFreeRemember(&buttonkey
);
333 if (DiskfontBase
) CloseLibrary(DiskfontBase
);
334 if (WorkbenchBase
) CloseLibrary(WorkbenchBase
);
335 if (IconBase
) CloseLibrary(IconBase
);
336 if (muBase
) CloseLibrary((struct Library
*)muBase
);
337 CloseLibrary((struct Library
*)DOpusBase
);
343 struct configconfig
*cfg
;
346 configmsg(CONFIG_GET_CONFIG
);
347 cfg
=(struct configconfig
*)msg
.buffer
;
349 firsttype
=cfg
->firsttype
;
350 firstbank
=cfg
->firstbank
;
351 firsthotkey
=cfg
->firsthotkey
;
352 typekey
=cfg
->typekey
;
353 changed
=cfg
->changed
;
354 strcpy(configname
,cfg
->configname
);
355 StrConcat(configname
,".CFG",256);
356 strcpy(loadnamebuf
,configname
);
358 D(bug("getconfig: Screen = %lx\n",Screen
));
365 struct configconfig cfg
;
370 cfg
.firsttype
=firsttype
;
371 cfg
.firstbank
=firstbank
;
372 cfg
.firsthotkey
=firsthotkey
;
374 cfg
.changed
=((lchanged
|| changed
)?1:0);
375 if (lchanged
==2) cfg
.changed
=2;
376 strcpy(cfg
.configname
,configname
);
377 if (ptr
=strstri(cfg
.configname
,".CFG")) *ptr
=0;
380 msg
.buffer
=(char *)&cfg
;
381 configmsg(CONFIG_HERES_CONFIG
);
388 if ((ReadConfig(configname
,&cstuff
))!=1) DefaultConfig(&cstuff
);
389 strcpy(loadnamebuf
,configname
);
393 void configmsg(command
)
397 msg
.msg
.mn_Node
.ln_Type
=NT_MESSAGE
;
398 msg
.msg
.mn_ReplyPort
=conport
;
399 msg
.msg
.mn_Length
=(UWORD
)sizeof(struct dopusconfigmsg
);
401 PutMsg(cmdport
,(struct Message
*)&msg
);
407 void fixcstuff(cstuff
)
408 struct ConfigStuff
*cstuff
;
410 cstuff
->config
=config
;
411 cstuff
->typekey
=typekey
;
412 cstuff
->firsttype
=firsttype
;
413 cstuff
->firstbank
=firstbank
; cstuff
->curbank
=curbank
;
414 cstuff
->firsthotkey
=firsthotkey
;
415 if (!Screen
&& Window
) {
416 config
->config_x
=Window
->LeftEdge
;
417 config
->config_y
=Window
->TopEdge
;
421 void cstufffix(cstuff
)
422 struct ConfigStuff
*cstuff
;
424 config
=cstuff
->config
;
425 typekey
=cstuff
->typekey
;
426 firsttype
=cstuff
->firsttype
;
427 firstbank
=cstuff
->firstbank
; curbank
=cstuff
->curbank
;
428 firsthotkey
=cstuff
->firsthotkey
;
431 void cleanconfigscreen()
437 gad
=Window
->FirstGadget
;
439 if (!(gad
->GadgetType
>YP_SYSGADGET
)) {
440 RemoveGList(Window
,gad
,1);
449 SetAPen(rp
,screen_pens
[0].pen
);
454 SetBPen(rp
,screen_pens
[1].pen
);
455 SetBPen(rp
,screen_pens
[0].pen
);
457 LFreeRemember(&gadgetkey
);
460 while (msg
=GetMsg(Window
->UserPort
))
464 void showconfigscreen(scr
)
471 doscreentitle(cfg_string
[STR_CONFIGURATION_MAIN_SCREEN
]);
472 initsidegads(mainmenugads
,0,1);
476 initsidegads(operationgads
,1,1);
477 doscreentitle(cfg_string
[STR_OPERATION_SCREEN
]);
486 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
,1);
488 initsidegads(gadgetgads
,0,0);
489 maingad
[GAD_COPYGADGET
].Activation
|=GACT_TOGGLESELECT
;
490 maingad
[GAD_SWAPGADGET
].Activation
|=GACT_TOGGLESELECT
;
491 maingad
[GAD_DELETEGADGET
].Activation
|=GACT_TOGGLESELECT
;
492 SetAPen(rp
,screen_pens
[1].pen
);
493 UScoreText(rp
,cfg_string
[STR_LEFT_MOUSE_BUTTON
],x_off
+38,y_off
+71,-1);
494 BltTemplate((char *)uparrow_data
,0,2,rp
,x_off
+179,y_off
+66,12,6);
495 UScoreText(rp
,cfg_string
[STR_RIGHT_MOUSE_BUTTON
],x_off
+454,y_off
+75,-1);
496 BltTemplate((char *)downarrow_data
,0,2,rp
,x_off
+437,y_off
+70,12,6);
500 if (menugads
) AddGList(Window
,menugads
,-1,MENUCOUNT
+5-(HIDDENLINES
*5),NULL
);
501 initsidegads(menugadgets
,1,0);
502 maingad
[MENU_OKAY
].Activation
&=~GACT_TOGGLESELECT
;
503 maingad
[MENU_CANCEL
].Activation
&=~GACT_TOGGLESELECT
;
504 AddGList(Window
,menuslidergads
,-1,3,NULL
);
509 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
,0);
510 do3dbox(x_off
+612,y_off
+21,12,144-HIDDENLINES
*8);
514 screen_pens
[config
->arrowfg
].pen
,screen_pens
[config
->arrowbg
].pen
,0);
519 screen_pens
[config
->arrowfg
].pen
,screen_pens
[config
->arrowbg
].pen
,1);
520 menusliderimage
.PlaneOnOff
=config
->slidercol
;
521 FixSliderBody(Window
,&menuslidergads
[0],20,20-HIDDENLINES
,0);
522 FixSliderPot(Window
,&menuslidergads
[0],0,20,20-HIDDENLINES
,2);
523 do_menuscreen_title(STR_MENU_SCREEN
);
527 if (scr
==CFG_DRIVE
) {
528 if (drivegads
) AddGList(Window
,drivegads
,-1,DRIVECOUNT
,NULL
);
529 initsidegads(drivegadgets
,1,0);
530 maingad
[DRIVE_GETDRIVES
].Activation
&=~GACT_TOGGLESELECT
;
531 maingad
[DRIVE_OKAY
].Activation
&=~GACT_TOGGLESELECT
;
532 maingad
[DRIVE_CANCEL
].Activation
&=~GACT_TOGGLESELECT
;
533 do_menuscreen_title(STR_DRIVE_SCREEN
);
539 initsidegads(filetypeactiongadgets
,1,0);
540 maingad
[FILETYPE_NEW
].Activation
&=~GACT_TOGGLESELECT
;
541 maingad
[FILETYPE_OKAY
].Activation
&=~GACT_TOGGLESELECT
;
542 maingad
[FILETYPE_CANCEL
].Activation
&=~GACT_TOGGLESELECT
;
543 doscreentitle(cfg_string
[STR_FILETYPE_SCREEN
]);
544 setuplist(&filetypeactionlist
,12,14);
545 filetypeactionlist
.itemselected
=-1;
546 AddListView(&filetypeactionlist
,1);
551 initsidegads(screengadgets
,1,1);
552 /* if ((config->screenmode==MODE_WORKBENCHUSE ||
553 config->screenmode==MODE_PUBLICSCREENUSE) &&
555 DisableGadget(&maingad[SCREEN_PALETTE],rp,2,1);*/
556 doscreentitle(cfg_string
[STR_SCREEN_SCREEN
]);
560 initsidegads(systemgads
,1,1);
561 doscreentitle(cfg_string
[STR_SYSTEM_SCREEN
]);
565 initsidegads(hotkeysgadgets
,1,0);
566 maingad
[HOTKEYS_NEWHOTKEY
].Activation
&=~GACT_TOGGLESELECT
;
567 maingad
[HOTKEYS_OKAY
].Activation
&=~GACT_TOGGLESELECT
;
568 maingad
[HOTKEYS_CANCEL
].Activation
&=~GACT_TOGGLESELECT
;
569 doscreentitle(cfg_string
[STR_HOTKEYS_SCREEN
]);
570 setuplist(&hotkeyslist
,12,14);
571 hotkeyslist
.itemselected
=-1;
572 hotkeyslist
.items
=NULL
;
573 hotkeyslist
.topitem
=0;
574 AddListView(&hotkeyslist
,1);
578 if (scr
==CFG_MAINMENU
) strcpy(currenthelpname
,cfg_string
[STR_MAIN_MENU
]);
579 else strcpy(currenthelpname
,mainmenugads
[scr
]);
582 void initsidegads(gads
,toggle
,vert
)
586 int num
,a
,x
,y
,x1
,ac
,dn
,gnum
,rnum
,w
,h
;
587 struct Gadget
*gadbuf
;
591 for (num
=0,rnum
=0;;rnum
++) {
592 if (!gads
[rnum
]) break;
593 if (gads
[rnum
][0]) ++num
;
596 if (!(gadbuf
=LAllocRemember(&gadgetkey
,sizeof(struct Gadget
)*num
,MEMF_CLEAR
)))
607 if (dn
*5==rnum
) --dn
;
610 x1
=x
=((Window
->Width
-(ac
*(w
+12)))/2)-2;
611 y
=y_off
+172-(dn
*(h
+2));
614 for (a
=0;a
<rnum
;a
++) {
616 gadbuf
[gnum
].NextGadget
=(gnum
<num
-1)?&gadbuf
[gnum
+1]:NULL
;
617 gadbuf
[gnum
].LeftEdge
=x
; gadbuf
[gnum
].TopEdge
=y
;
618 gadbuf
[gnum
].Width
=w
; gadbuf
[gnum
].Height
=h
;
619 gadbuf
[gnum
].Flags
=GFLG_GADGHCOMP
;
620 gadbuf
[gnum
].Activation
=GACT_RELVERIFY
;
621 if (toggle
) gadbuf
[gnum
].Activation
|=GACT_TOGGLESELECT
;
622 gadbuf
[gnum
].GadgetType
=GTYP_BOOLGADGET
;
623 gadbuf
[gnum
].GadgetID
=gnum
;
629 if (x
>(Window
->Width
-10-w
)) {
635 SetAPen(rp
,screen_pens
[1].pen
);
636 AddGadgetBorders(&gadgetkey
,
639 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
);
644 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
,1);
648 void inittickgads(gads
,flag
,flag2
)
649 struct ConfigGadget
*gads
;
652 int num
,a
,y
,gad
,last
,lasty
,dy
,xp
,yp
,fl
,b
;
654 struct StringInfo
*sinfo
;
661 if (!gads
[a
].type
) break;
662 if (gads
[a
].type
!=CTYPE_TEXT
&& gads
[a
].type
!=CTYPE_SKIP
) ++num
;
667 if (!(tickgad
=LAllocRemember(&tickkey
,sizeof(struct Gadget
)*num
,MEMF_CLEAR
)) ||
668 !(namearray
=LAllocRemember(&tickkey
,num
*sizeof(APTR
),MEMF_CLEAR
))) return;
675 SetAPen(rp
,screen_pens
[1].pen
);
678 if (!gads
[a
].type
) break;
679 if (gads
[a
].type
==CTYPE_SKIP
) continue;
680 switch (gads
[a
].type
) {
682 y
=y_off
+(gads
[a
].x
-12); dy
=0;
688 if (gads
[a
].x
<0) xp
=x_off
+158;
689 else xp
=x_off
+(gads
[a
].x
-2);
694 yp
=y_off
+(gads
[a
].y
-12);
695 if (gads
[a
].value
==1) {
701 if (gads
[a
].nameentry
>-1) UScoreText(rp
,cfg_string
[gads
[a
].nameentry
],xp
,yp
,-1);
706 if (gads
[a
].nameentry
>-1) namearray
[gad
]=cfg_string
[gads
[a
].nameentry
];
707 else namearray
[gad
]=(char *)-1;
708 tickgad
[gad
].NextGadget
=(gad
<num
-1)?&tickgad
[gad
+1]:NULL
;
709 if (gads
[a
].type
==CTYPE_GAD
) {
710 if (gads
[a
].w
<0) tickgad
[gad
].Width
=26;
711 else tickgad
[gad
].Width
=gads
[a
].w
;
712 if (gads
[a
].h
<0) tickgad
[gad
].Height
=11;
713 else tickgad
[gad
].Height
=gads
[a
].h
;
714 tickgad
[gad
].GadgetRender
=checkoffimage
;
715 tickgad
[gad
].SelectRender
=checkonimage
;
716 tickgad
[gad
].MutualExclude
=GAD_CHECK
;
717 if (gads
[a
].x
<0) xp
=x_off
+156;
718 else xp
=x_off
+(gads
[a
].x
-2);
723 yp
=y_off
+(gads
[a
].y
-12); dy
=0;
725 tickgad
[gad
].Activation
=RELVERIFY
|TOGGLESELECT
;
728 if (gads
[a
].w
<0) tickgad
[gad
].Width
=15;
729 else tickgad
[gad
].Width
=gads
[a
].w
;
730 if (gads
[a
].h
<0) tickgad
[gad
].Height
=7;
731 else tickgad
[gad
].Height
=gads
[a
].h
;
732 tickgad
[gad
].GadgetRender
=(APTR
)buttonoffimage
;
733 tickgad
[gad
].SelectRender
=(APTR
)buttononimage
;
734 tickgad
[gad
].MutualExclude
=GAD_RADIO
;
735 if (gads
[a
].x
<0) xp
=x_off
+158;
736 else xp
=x_off
+(gads
[a
].x
-2);
741 yp
=y_off
+(gads
[a
].y
-12); dy
=0;
743 tickgad
[gad
].Activation
=GADGIMMEDIATE
|TOGGLESELECT
;
745 tickgad
[gad
].LeftEdge
=xp
; tickgad
[gad
].TopEdge
=yp
;
746 tickgad
[gad
].Flags
=GADGIMAGE
|GADGHIMAGE
;
747 if (gads
[a
].value
==0) fl
=flag
;
748 else if (gads
[a
].value
==1) fl
=flag2
;
749 if (gads
[a
].type
==CTYPE_MRAD
) {
750 b
=gads
[a
].mutualex
&(~gads
[a
].bit
);
751 if (!(fl
&b
)) tickgad
[gad
].Flags
|=SELECTED
;
753 else if (fl
&& fl
&gads
[a
].bit
) tickgad
[gad
].Flags
|=SELECTED
;
754 tickgad
[gad
].GadgetType
=BOOLGADGET
;
755 tickgad
[gad
].GadgetID
=GAD_BASE
+(gads
[a
].value
*4000)+gads
[a
].bit
;
756 tickgad
[gad
].UserData
=(APTR
)&gads
[a
];
757 gads
[a
].gad
=&tickgad
[gad
];
758 last
=gads
[a
].type
; ++gad
;
761 if (gads
[a
].y
==-2) y
=lasty
;
763 if (last
==CTYPE_GAD
|| gads
[a
].type
==CTYPE_RAD
|| gads
[a
].type
==CTYPE_MRAD
)
767 if (gads
[a
].bit
&4 || gads
[a
].nameentry
==-1) namearray
[gad
]=(char *)-1;
768 else namearray
[gad
]=cfg_string
[gads
[a
].nameentry
];
769 tickgad
[gad
].NextGadget
=(gad
<num
-1)?&tickgad
[gad
+1]:NULL
;
771 if (gads
[a
].x
<0) xp
=x_off
+338;
772 else xp
=x_off
+(gads
[a
].x
-2);
777 yp
=y_off
+(gads
[a
].y
-12); dy
=0;
781 if (gads
[a
].x
<0) xp
=x_off
+306;
782 else xp
=x_off
+(gads
[a
].x
-2);
787 yp
=y_off
+(gads
[a
].y
-12); dy
=0;
791 tickgad
[gad
].Width
=Window
->Width
-xp
-30;
792 if (gads
[a
].bit
&4) tickgad
[gad
].Width
-=2;
794 else tickgad
[gad
].Width
=gads
[a
].w
;
795 if (gads
[a
].h
<0) tickgad
[gad
].Height
=8;
796 else tickgad
[gad
].Height
=gads
[a
].h
;
797 tickgad
[gad
].LeftEdge
=xp
; tickgad
[gad
].TopEdge
=yp
;
798 tickgad
[gad
].Flags
=GFLG_GADGHCOMP
|GFLG_STRINGEXTEND
|GFLG_TABCYCLE
;
799 tickgad
[gad
].Activation
=GACT_RELVERIFY
|GACT_TOGGLESELECT
;
800 if (gads
[a
].bit
&1) tickgad
[gad
].Activation
|=GACT_LONGINT
;
802 tickgad
[gad
].MutualExclude
=1;
805 tickgad
[gad
].GadgetType
=GTYP_STRGADGET
;
806 if (sinfo
=(struct StringInfo
*)LAllocRemember(&tickkey
,sizeof(struct StringInfo
),MEMF_CLEAR
)) {
807 sinfo
->Buffer
=(STRPTR
)LAllocRemember(&tickkey
,gads
[a
].mutualex
,MEMF_CLEAR
);
808 sinfo
->MaxChars
=gads
[a
].mutualex
;
809 sinfo
->Extension
=&stringex
;
811 tickgad
[gad
].SpecialInfo
=(APTR
)sinfo
;
812 tickgad
[gad
].GadgetID
=STRING_BASE
+gad
;
813 tickgad
[gad
].UserData
=(APTR
)&gads
[a
];
814 gads
[a
].gad
=&tickgad
[gad
];
815 last
=gads
[a
].type
; ++gad
;
819 if (gads
[a
].x
<0) xp
=x_off
+302;
820 else xp
=x_off
+(gads
[a
].x
-2);
825 yp
=y_off
+(gads
[a
].y
-12); dy
=0;
827 if (gads
[a
].nameentry
>-1) namearray
[gad
]=cfg_string
[gads
[a
].nameentry
];
828 else namearray
[gad
]=(char *)-1;
829 tickgad
[gad
].NextGadget
=(gad
<num
-1)?&tickgad
[gad
+1]:NULL
;
830 tickgad
[gad
].LeftEdge
=xp
; tickgad
[gad
].TopEdge
=yp
;
831 if (gads
[a
].w
<0) tickgad
[gad
].Width
=28;
832 else tickgad
[gad
].Width
=gads
[a
].w
;
833 if (gads
[a
].h
<0) tickgad
[gad
].Height
=14;
834 else tickgad
[gad
].Height
=gads
[a
].h
;
835 tickgad
[gad
].Flags
=GADGHCOMP
;
836 tickgad
[gad
].Activation
=RELVERIFY
;
837 tickgad
[gad
].GadgetType
=BOOLGADGET
;
838 tickgad
[gad
].GadgetID
=REQ_BASE
+gad
;
839 tickgad
[gad
].MutualExclude
=GAD_GLASS
;
840 tickgad
[gad
].UserData
=(APTR
)&gads
[a
];
841 AddGadgetBorders(&tickkey
,
844 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
);
845 doglassimage(&tickgad
[gad
]);
846 gads
[a
].gad
=&tickgad
[gad
-1];
847 last
=gads
[a
].type
; ++gad
;
856 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
,1);
860 void removetickgads()
862 if (tickgad
&& tickcount
) {
863 RemoveGList(Window
,tickgad
,tickcount
);
864 tickgad
=NULL
; tickcount
=0;
866 LFreeRemember(&tickkey
);
867 SetAPen(rp
,screen_pens
[0].pen
);
873 int processtickgad(gads
,flag
,sel
,num
)
874 struct ConfigGadget
*gads
;
877 int a
,ref
=0,hitgad
=-1;
881 if (!gads
[a
].type
) break;
882 if (num
==-1 || gads
[a
].value
==num
) {
883 if (gads
[a
].type
==CTYPE_GAD
|| gads
[a
].type
==CTYPE_RAD
|| gads
[a
].type
==CTYPE_MRAD
) {
884 if (gads
[a
].bit
==sel
) {
894 if (!gads
[a
].type
) break;
895 if (num
==-1 || gads
[a
].value
==num
) {
897 if (gads
[a
].type
==CTYPE_GAD
|| gads
[a
].type
==CTYPE_RAD
|| gads
[a
].type
==CTYPE_MRAD
) {
899 if (!(gad
->Flags
&SELECTED
) && gads
[a
].mutualex
&sel
) {
900 gad
->Flags
|=SELECTED
;
905 if (gad
->Flags
&SELECTED
) {
906 if (gads
[a
].type
==CTYPE_MRAD
) {
907 if (gads
[a
].mutualex
&sel
) {
908 gad
->Flags
&=~SELECTED
;
912 else if (gads
[hitgad
].mutualex
&gads
[a
].bit
) {
913 gad
->Flags
&=~SELECTED
;
918 if (gads
[a
].type
!=CTYPE_MRAD
&& gad
->Flags
&SELECTED
) flag
|=gads
[a
].bit
;
920 else if (gads
[a
].type
==CTYPE_STR
) {
921 if (gads
[a
].buffer
) {
922 if (gads
[a
].bit
&2) CheckHexGad(gad
,Window
,0,0xff);
923 strcpy(gads
[a
].buffer
,(char *)((struct StringInfo
*)gad
->SpecialInfo
)->Buffer
);
928 if (ref
) RefreshGList(tickgad
,Window
,NULL
,tickcount
);
932 struct ConfigUndo
*makeundo(type
)
935 struct ConfigUndo
*undo
;
936 struct DOpusRemember
*key
;
937 struct dopusgadgetbanks
*bank
,*newbank
,*curbank
;
938 struct dopushotkey
*hotkey
,*newhotkey
,*curhotkey
;
942 if (!(undo
=LAllocRemember(&key
,sizeof(struct ConfigUndo
),MEMF_CLEAR
)))
945 undo
->config
=(struct Config
*)getcopy((char *)config
,sizeof(struct Config
),&key
);
946 if (type
&UNDO_GADGET
) {
947 bank
=firstbank
; curbank
=NULL
;
949 if (newbank
=(struct dopusgadgetbanks
*)
950 getcopy((char *)bank
,sizeof(struct dopusgadgetbanks
),&key
)) {
952 copygadgets(bank
,newbank
,&key
);
953 if (curbank
) curbank
->next
=newbank
;
954 else undo
->firstbank
=newbank
;
960 if (type
&UNDO_MENU
&&
961 (undo
->menu
=(struct newdopusfunction
*)
962 getcopy((char *)config
->menu
,sizeof(struct newdopusfunction
)*MENUCOUNT
,&key
))) {
963 for (a
=0;a
<MENUCOUNT
;a
++) {
964 undo
->menu
[a
].name
=getcopy(config
->menu
[a
].name
,-1,&key
);
965 undo
->menu
[a
].function
=getcopy(config
->menu
[a
].function
,-1,&key
);
967 for (a
=0;a
<5;a
++) strcpy(undo
->menutit
[a
],config
->menutit
[a
]);
969 if (type
&UNDO_DRIVE
&&
970 (undo
->drive
=(struct dopusfunction
*)
971 getcopy((char *)config
->drive
,sizeof(struct dopusfunction
)*DRIVECOUNT
,&key
))) {
972 for (a
=0;a
<DRIVECOUNT
;a
++)
973 undo
->drive
[a
].function
=getcopy(config
->drive
[a
].function
,-1,&key
);
975 if (type
&UNDO_FILETYPE
)
976 copyfiletypes(firsttype
,&undo
->firsttype
,&key
);
977 if (type
&UNDO_HOTKEYS
) {
978 hotkey
=firsthotkey
; curhotkey
=NULL
;
980 if (newhotkey
=(struct dopushotkey
*)
981 getcopy((char *)hotkey
,sizeof(struct dopushotkey
),&key
)) {
982 newhotkey
->func
.function
=getcopy(hotkey
->func
.function
,-1,&key
);
983 newhotkey
->next
=NULL
;
984 if (curhotkey
) curhotkey
->next
=newhotkey
;
985 else undo
->firsthotkey
=newhotkey
;
995 void copygadgets(bank1
,bank2
,key
)
996 struct dopusgadgetbanks
*bank1
,*bank2
;
997 struct DOpusRemember
**key
;
1001 for (a
=0;a
<84;a
++) {
1002 bank2
->gadgets
[a
].name
=getcopy(bank1
->gadgets
[a
].name
,-1,key
);
1003 bank2
->gadgets
[a
].function
=getcopy(bank1
->gadgets
[a
].function
,-1,key
);
1007 void copyfiletypes(oldfirst
,newfirst
,key
)
1008 struct dopusfiletype
*oldfirst
,**newfirst
;
1009 struct DOpusRemember
**key
;
1011 struct dopusfiletype
*type
,*newtype
,*curtype
=NULL
;
1017 if (newtype
=(struct dopusfiletype
*)
1018 getcopy((char *)type
,sizeof(struct dopusfiletype
),key
)) {
1019 for (a
=0;a
<FILETYPE_FUNCNUM
;a
++)
1020 newtype
->function
[a
]=getcopy(type
->function
[a
],-1,key
);
1021 newtype
->recognition
=getcopy(type
->recognition
,-1,key
);
1022 newtype
->iconpath
=getcopy(type
->iconpath
,-1,key
);
1023 if (curtype
) curtype
->next
=newtype
;
1024 else *newfirst
=newtype
;
1032 void doundo(undo
,type
)
1033 struct ConfigUndo
*undo
;
1036 struct DOpusRemember
*key
;
1037 struct dopusgadgetbanks
*bank
,*curbank
,*newbank
;
1038 struct dopushotkey
*hotkey
,*curhotkey
,*newhotkey
;
1044 LFreeRemember(&key
);
1047 if (type
&UNDO_MENU
) {
1048 for (a
=0;a
<MENUCOUNT
;a
++) freenewfunction(&config
->menu
[a
]);
1050 if (type
&UNDO_DRIVE
) for (a
=0;a
<DRIVECOUNT
;a
++) freefunction(&config
->drive
[a
]);
1051 if (type
&UNDO_MAIN
&& undo
->config
)
1052 copyconfigonly(undo
->config
,config
);
1053 if (type
&UNDO_GADGET
) {
1054 freegadgets(firstbank
); firstbank
=NULL
;
1055 bank
=undo
->firstbank
; curbank
=NULL
;
1057 if (newbank
=(struct dopusgadgetbanks
*)
1058 getcopy((char *)bank
,sizeof(struct dopusgadgetbanks
),NULL
)) {
1060 copygadgets(bank
,newbank
,NULL
);
1061 if (curbank
) curbank
->next
=newbank
;
1062 else firstbank
=newbank
;
1068 if (type
&UNDO_MENU
&& undo
->menu
) {
1069 CopyMem((char *)undo
->menu
,(char *)config
->menu
,sizeof(struct newdopusfunction
)*MENUCOUNT
);
1070 for (a
=0;a
<MENUCOUNT
;a
++) {
1071 config
->menu
[a
].name
=getcopy(undo
->menu
[a
].name
,-1,NULL
);
1072 config
->menu
[a
].function
=getcopy(undo
->menu
[a
].function
,-1,NULL
);
1074 for (a
=0;a
<5;a
++) strcpy(config
->menutit
[a
],undo
->menutit
[a
]);
1076 if (type
&UNDO_DRIVE
&& undo
->drive
) {
1077 CopyMem((char *)undo
->drive
,(char *)config
->drive
,sizeof(struct dopusfunction
)*DRIVECOUNT
);
1078 for (a
=0;a
<DRIVECOUNT
;a
++)
1079 config
->drive
[a
].function
=getcopy(undo
->drive
[a
].function
,-1,NULL
);
1081 if (type
&UNDO_FILETYPE
) {
1082 LFreeRemember(&typekey
); firsttype
=NULL
;
1083 copyfiletypes(undo
->firsttype
,&firsttype
,&typekey
);
1085 if (type
&UNDO_HOTKEYS
) {
1088 curhotkey
=hotkey
->next
;
1089 freestring(hotkey
->func
.function
);
1090 FreeMem(hotkey
,sizeof(struct dopushotkey
));
1093 firsthotkey
=NULL
; curhotkey
=NULL
;
1094 hotkey
=undo
->firsthotkey
;
1096 if (newhotkey
=(struct dopushotkey
*)
1097 getcopy((char *)hotkey
,sizeof(struct dopushotkey
),NULL
)) {
1098 newhotkey
->func
.function
=getcopy(hotkey
->func
.function
,-1,NULL
);
1099 newhotkey
->next
=NULL
;
1100 if (curhotkey
) curhotkey
->next
=newhotkey
;
1101 else firsthotkey
=newhotkey
;
1102 curhotkey
=newhotkey
;
1104 hotkey
=hotkey
->next
;
1110 void freegadgets(first
)
1111 struct dopusgadgetbanks
*first
;
1113 struct dopusgadgetbanks
*temp
;
1117 freegadgetbank(first
,1);
1122 void freegadgetbank(bank
,free
)
1123 struct dopusgadgetbanks
*bank
;
1129 for (a
=0;a
<GADCOUNT
;a
++) {
1130 freestring(bank
->gadgets
[a
].name
);
1131 freestring(bank
->gadgets
[a
].function
);
1133 if (free
) FreeMem(bank
,sizeof(struct dopusgadgetbanks
));
1137 void freefunction(func
)
1138 struct dopusfunction
*func
;
1140 freestring(func
->function
);
1141 func
->function
=NULL
;
1144 void freenewfunction(func
)
1145 struct newdopusfunction
*func
;
1147 freestring(func
->name
); func
->name
=NULL
;
1148 freestring(func
->function
); func
->function
=NULL
;
1151 char *getcopy(object
,size
,key
)
1154 struct DOpusRemember
**key
;
1158 if (!object
) return(NULL
);
1159 if (size
==-1) size
=strlen(object
)+1;
1160 if (key
) newobject
=(char *)LAllocRemember(key
,size
,MEMF_CLEAR
);
1161 else newobject
=AllocMem(size
,MEMF_CLEAR
);
1162 if (newobject
) CopyMem((char *)object
,(char *)newobject
,size
);
1166 void makestring(char *buf
,...)
1170 struct Gadget
*gad
,*first
=NULL
;
1171 struct ConfigGadget
*cgad
;
1173 if (!tickgad
) return;
1177 while (buf
&& gad
) {
1178 if (gad
->GadgetType
==STRGADGET
) {
1179 cgad
=(struct ConfigGadget
*)gad
->UserData
;
1181 ptr
=(char *)((struct StringInfo
*)gad
->SpecialInfo
)->Buffer
;
1183 RefreshStrGad(gad
,Window
);
1184 if (!first
) first
=gad
;
1185 buf
=(char *)va_arg(ap
,char *);
1187 gad
=gad
->NextGadget
;
1189 if (first
) ActivateStrGad(first
,Window
);
1192 int getstring(text
,buf
,len
,num
)
1196 struct DOpusSimpleRequest req
;
1198 static int rets
[2]={1,0};
1201 gads
[0]=cfg_string
[STR_OKAY
];
1202 gads
[1]=cfg_string
[STR_CANCEL
];
1208 req
.hi
=screen_pens
[config
->gadgettopcol
].pen
;
1209 req
.lo
=screen_pens
[config
->gadgetbotcol
].pen
;
1210 req
.fg
=screen_pens
[config
->requestfg
].pen
;
1211 req
.bg
=screen_pens
[config
->requestbg
].pen
;
1214 req
.flags
=num
|SRF_BORDERS
|SRF_RECESSHI
|SRF_EXTEND
;
1215 req
.value
=(long)&stringex
;
1217 req
.title
="ConfigOpus";
1219 a
=DoSimpleRequest(Window
,&req
);
1227 return(do_request(text
,cfg_string
[STR_OKAY
],cfg_string
[STR_CANCEL
]));
1230 int do_request(text
,pos
,neg
)
1231 char *text
,*pos
,*neg
;
1233 struct DOpusSimpleRequest req
;
1235 static int rets
[2]={1,0};
1245 req
.hi
=screen_pens
[config
->gadgettopcol
].pen
;
1246 req
.lo
=screen_pens
[config
->gadgetbotcol
].pen
;
1247 req
.fg
=screen_pens
[config
->requestfg
].pen
;
1248 req
.bg
=screen_pens
[config
->requestbg
].pen
;
1250 req
.flags
=SRF_BORDERS
|SRF_RECESSHI
;
1252 req
.title
="ConfigOpus";
1254 a
=DoSimpleRequest(Window
,&req
);
1259 void doglassimage(gad
)
1266 SetAPen(rp
,screen_pens
[config
->gadgetbotcol
].pen
);
1268 BltTemplate((char *)glass_data
[a
],0,4,rp
,gad
->LeftEdge
+4,gad
->TopEdge
+2,20,9);
1269 SetAPen(rp
,screen_pens
[config
->gadgettopcol
].pen
);
1275 void freestring(str
)
1278 if (str
) FreeMem(str
,strlen(str
)+1);
1281 static char lasttitle
[80];
1283 void doscreentitle(str
)
1286 if (str
&& str
!=(char *)-1) strcpy(lasttitle
,str
);
1287 SetWindowTitles(Window
,lasttitle
,(char *)-1);
1290 struct IntuiMessage
*getintuimsg()
1292 struct IntuiMessage
*msg
;
1293 struct MenuItem
*item
;
1297 if (msg
=(struct IntuiMessage
*)GetMsg(Window
->UserPort
)) {
1298 if (msg
->Class
==IDCMP_RAWKEY
) {
1299 D(bug("RAWKEY code: %lx\n",msg
->Code
));
1300 if (msg
->Code
==0x5f && help_ok
) {
1302 ReplyMsg((struct Message
*)msg
);
1305 else if (msg
->Qualifier
&IEQUALIFIER_RCOMMAND
&& Window
->MenuStrip
) {
1306 if (!(msg
->Code
&0x80)) {
1307 RawkeyToStr(msg
->Code
,0,NULL
,buf
,10); c
=LToUpper(buf
[0]);
1308 item
=Window
->MenuStrip
->FirstItem
;
1311 if (item
->Command
&& c
==item
->Command
) {
1312 msg
->Class
=MENUPICK
;
1316 item
=item
->NextItem
;
1322 else if (msg
->Class
==IDCMP_MENUPICK
) {
1323 doscreentitle((char *)-1);
1324 if (Window
->MenuStrip
==&projectmenu
&& MENUNUM(msg
->Code
)==0) {
1326 switch (ITEMNUM(msg
->Code
)) {
1327 case 3: dosave(0); a
=1; break;
1328 case 4: dosave(1); a
=1; break;
1331 ReplyMsg((struct Message
*)msg
);
1336 else if (msg
->Class
==IDCMP_MOUSEMOVE
&& Window
->MenuStrip
) {
1337 if (msg
->MouseY
>Window
->BorderTop
&& msg
->MouseY
<Window
->Height
&&
1338 msg
->MouseX
>=0 && msg
->MouseX
<Window
->Width
) Window
->Flags
|=RMBTRAP
;
1339 else Window
->Flags
&=~RMBTRAP
;
1345 struct TextFont
*getfont(font
,size
,flags
)
1350 struct TextFont
*tf
;
1351 static struct TextAttr sfont
={NULL
,0,0,0};
1353 sfont
.ta_Name
=(STRPTR
)font
; sfont
.ta_YSize
=*size
;
1354 if ((tf
=OpenFont(&sfont
)) && tf
->tf_YSize
==sfont
.ta_YSize
&&
1355 (!(tf
->tf_Flags
&FPF_PROPORTIONAL
) || flags
!=FFLAG_NOPROP
)) return(tf
);
1356 if (tf
) CloseFont(tf
);
1357 if (!(lock
=Lock("FONTS:",ACCESS_READ
))) {
1358 strcpy(font
,"topaz.font"); *size
=8; sfont
.ta_YSize
=8;
1359 return((OpenFont(&sfont
)));
1362 if (!DiskfontBase
|| !(tf
=OpenDiskFont(&sfont
))) {
1363 if ((tf
=OpenFont(&sfont
))) *size
=tf
->tf_YSize
;
1366 (!tf
&& flags
!=FFLAG_8ONLY
) ||
1367 (tf
&& flags
==FFLAG_NOPROP
&& tf
->tf_Flags
&FPF_PROPORTIONAL
)) {
1368 if (tf
) CloseFont(tf
);
1369 strcpy(font
,"topaz.font"); *size
=8; sfont
.ta_YSize
=8;
1370 tf
=OpenFont(&sfont
);
1375 void loadrgb4(scr
,pal
,num
)
1383 if (data
=AllocMem(num
*3*sizeof(ULONG
),0)) {
1384 for (a
=0,b
=0;a
<num
;a
++) {
1385 data
[b
++]=(((pal
[a
]>>8)&0xf)<<28)|0x0fffffff;
1386 data
[b
++]=(((pal
[a
]>>4)&0xf)<<28)|0x0fffffff;
1387 data
[b
++]=((pal
[a
]&0xf)<<28)|0x0fffffff;
1389 load_palette(scr
,data
,num
);
1390 FreeMem(data
,num
*3*sizeof(ULONG
));
1394 void load_palette(screen
,palette
,numcols
)
1395 struct Screen
*screen
;
1400 /*if (version2>=OSVER_39)*/ {
1403 for (a
=0,b
=0;a
<numcols
;a
++) {
1404 SetRGB32(&Window
->WScreen
->ViewPort
,
1406 palette
[b
],palette
[b
+1],palette
[b
+2]);
1411 else /*if (version2>=OSVER_39)*/ {
1412 ULONG
*backup_palette
;
1414 if (backup_palette
=AllocMem(((numcols
*3)+2)*sizeof(ULONG
),MEMF_CLEAR
)) {
1415 CopyMem((char *)palette
,(char *)&backup_palette
[1],(numcols
*3)*sizeof(ULONG
));
1416 backup_palette
[0]=numcols
<<16;
1417 backup_palette
[(numcols
*3)+1]=0;
1418 LoadRGB32(&screen
->ViewPort
,backup_palette
);
1419 FreeMem(backup_palette
,((numcols
*3)+2)*sizeof(ULONG
));
1423 UWORD backup_palette[16];
1426 for (a=0,b=0;a<numcols*3;b++) {
1427 backup_palette[b]=0;
1428 backup_palette[b]|=(palette[a++]&0xf0000000)>>20;
1429 backup_palette[b]|=(palette[a++]&0xf0000000)>>24;
1430 backup_palette[b]|=(palette[a++]&0xf0000000)>>28;
1433 LoadRGB4(&screen->ViewPort,backup_palette,numcols);
1437 void get_palette(screen
,palette
,numcols
)
1438 struct Screen
*screen
;
1443 /*if (version2>=OSVER_39)*/ {
1446 for (a
=0,b
=0;a
<numcols
;a
++,b
+=3) {
1447 GetRGB32(Window
->WScreen
->ViewPort
.ColorMap
,
1454 else /*if (version2>=OSVER_39)*/ {
1455 GetRGB32(screen
->ViewPort
.ColorMap
,0,numcols
,palette
);
1461 for (a=0,b=0;a<numcols;a++) {
1462 colour=GetRGB4(screen->ViewPort.ColorMap,a);
1463 palette[b++]=(((colour>>8)&0xf)<<28)|0x0fffffff;
1464 palette[b++]=(((colour>>4)&0xf)<<28)|0x0fffffff;
1465 palette[b++]=((colour&0xf)<<28)|0x0fffffff;
1474 struct Screen
*wbscreen
=NULL
,*usescreen
;
1478 if (tfont
) CloseFont(tfont
);
1480 tfont
=getfont(config
->fontbufs
[0],&a
,FFLAG_8ONLY
);
1481 strcpy(sfont
.ta_Name
,tfont
->tf_Message
.mn_Node
.ln_Name
);
1486 struct PubScreenNode
*psn
;
1488 if (psl
= LockPubScreenList())
1490 for (psn
= (struct PubScreenNode
*)psl
->lh_Head
; psn
->psn_Node
.ln_Succ
; psn
= (struct PubScreenNode
*)psn
->psn_Node
.ln_Succ
)
1492 D(bug("PubScreen name: %s\n",psn
->psn_Node
.ln_Name
));
1493 if (psn
->psn_Screen
== Screen
)
1495 psname
= psn
->psn_Node
.ln_Name
;
1499 UnlockPubScreenList();
1502 /*if (version2>=OSVER_39)*/ {
1503 if (wbscreen
=LockPubScreen(psname
)) {
1504 if (wbscreen
->Height
>wbscreen
->WBorTop
+wbscreen
->Font
->ta_YSize
+189) {
1506 struct ColorMap
*cm
;
1508 cm
=wbscreen
->ViewPort
.ColorMap
;
1509 num
=1<<((config
->scrdepth
> 4) ? 4 : config
->scrdepth
);
1511 for (pen
=0;pen
<num
;pen
++) {
1512 screen_pens
[pen
].red
=config
->new_palette
[(pen
*3)];
1513 screen_pens
[pen
].green
=config
->new_palette
[(pen
*3)+1];
1514 screen_pens
[pen
].blue
=config
->new_palette
[(pen
*3)+2];
1515 if ((screen_pens
[pen
].pen
=
1517 screen_pens
[pen
].red
,
1518 screen_pens
[pen
].green
,
1519 screen_pens
[pen
].blue
,
1520 PEN_EXCLUSIVE
))==(unsigned char)-1) break;
1521 screen_pens
[pen
].alloc
=1;
1524 if (pen
<num
) free_colour_table(cm
);
1530 configscr
.Depth
=config
->scrdepth
;
1532 /*if (version2 >= OSVER_39)*/ {
1533 scr_taglist
[1].ti_Data
= BestModeID(//BIDTAG_NominalWidth, configscr.Width,
1534 BIDTAG_DesiredWidth
, configscr
.Width
,
1535 //BIDTAG_NominalHeight, configscr.Height,
1536 BIDTAG_DesiredHeight
, configscr
.Height
,
1537 BIDTAG_Depth
, configscr
.Depth
,
1538 wbscreen
?BIDTAG_MonitorID
:TAG_IGNORE
, wbscreen
?GetVPModeID(&wbscreen
->ViewPort
) & MONITOR_ID_MASK
:0,
1540 D(bug("ConfigOpus wbscreen: %lx\tMonitorID: %lx\tModeID: %lx\n",wbscreen
,wbscreen
?GetVPModeID(&wbscreen
->ViewPort
) & MONITOR_ID_MASK
:-1,scr_taglist
[1].ti_Data
));
1541 if (scr_taglist
[1].ti_Data
== INVALID_ID
) scr_taglist
[1].ti_Data
= HIRES_KEY
;
1543 while (!(Screen
=OpenScreen((struct NewScreen
*)&configscr
))) {
1544 if (configscr
.Depth
<=2) quit();
1547 ShowTitle(Screen
,FALSE
);
1550 else usescreen
=wbscreen
;
1552 vp
=&usescreen
->ViewPort
;
1553 config
->scrdepth
=configscr
.Depth
;
1554 screen_depth
=configscr
.Depth
;
1556 configwin
.Screen
=usescreen
;
1557 configwin
.Height
=usescreen
->WBorTop
+usescreen
->Font
->ta_YSize
+1+192+4;
1559 configwin
.LeftEdge
=(usescreen
->Width
-configwin
.Width
)>>1;
1560 configwin
.TopEdge
=((usescreen
->Height
-configwin
.Height
-(usescreen
->Font
->ta_YSize
+1))>>1)+usescreen
->Font
->ta_YSize
+1;
1563 if (config
->config_x
>-1) configwin
.LeftEdge
=config
->config_x
;
1564 if (config
->config_y
>-1) configwin
.TopEdge
=config
->config_y
;
1567 if (configwin
.Width
+configwin
.LeftEdge
>usescreen
->Width
)
1568 configwin
.LeftEdge
=usescreen
->Width
-configwin
.Width
;
1570 if (configwin
.Height
+configwin
.TopEdge
>usescreen
->Height
)
1571 configwin
.TopEdge
=usescreen
->Height
-configwin
.Height
;
1573 if (!(Window
=OpenWindow(&configwin
))) quit();
1575 if (!Screen
) SetWindowTitles(Window
,(char *)-1,configscr
.DefaultTitle
);
1578 FSSetMenuStrip(Window
,&projectmenu
);
1580 x_off
=Window
->BorderLeft
;
1581 y_off
=Window
->BorderTop
;
1582 x_bot
=Window
->Width
-Window
->BorderRight
-1;
1583 y_bot
=Window
->Height
-Window
->BorderBottom
-1;
1585 if (tfont
) SetFont(rp
,tfont
);
1586 if (wbscreen
) UnlockPubScreen(NULL
,wbscreen
);
1589 load_palette(Screen
,config
->new_palette
,1<<((screen_depth
> 4) ? 4 : screen_depth
));
1592 fix_gadget_positions();
1593 if (Screen
|| cmdport
) ScreenToFront(Window
->WScreen
);
1598 free_colour_table((Window
)?Window
->WScreen
->ViewPort
.ColorMap
:NULL
);
1600 if (Window
->MenuStrip
) ClearMenuStrip(Window
);
1601 CloseWindow(Window
);
1605 CloseScreen(Screen
);
1611 void free_colour_table(cm
)
1612 struct ColorMap
*cm
;
1616 if (/*version2>=OSVER_39 &&*/ cm
) {
1617 for (a
=0;a
<16;a
++) {
1618 if (screen_pens
[a
].alloc
)
1619 ReleasePen(cm
,screen_pens
[a
].pen
);
1623 for (a
=0;a
<16;a
++) {
1624 screen_pens
[a
].pen
=a
;
1625 screen_pens
[a
].alloc
=0;
1629 unsigned char getkeyshortcut(const char *str
)
1633 if (c
= strchr(str
,'_')) return LToLower(c
[1]);