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.
32 #include <libraries/amigaguide.h>
33 //#include <proto/powerpacker.h>
35 int showfont(name
,size
,np
)
39 int base
,y
,fred
,t
,len
;
41 struct TextFont
*font
;
42 char fontbuf
[256],*fontptr
;
43 static UWORD fcols
[2]={0xfff,0};
44 struct TextAttr sfattr
= { (STRPTR
)name
, size
, 0, 0 };
45 struct RastPort
*font_rp
;
47 font
= DiskfontBase
? OpenDiskFont(&sfattr
) : OpenFont(&sfattr
);
48 if (!font
|| !(setupfontdisplay(1,NULL
))) {
53 base
=font
->tf_Baseline
;
54 SetFont(font_rp
=fontwindow
->RPort
,font
);
56 SetDrMd(font_rp
,JAM1
);
66 len
+=TextLength(font_rp
,(char *)&a
,1);
67 if (len
>fontscreen
->Width
|| t
>254) {
68 Text(font_rp
,fontbuf
,t
);
71 len
=t
=0; fontptr
=fontbuf
;
72 if (y
-base
>fontscreen
->Height
) break;
75 if ((++a
)>font
->tf_HiChar
) a
=font
->tf_LoChar
;
78 ScreenToFront(fontscreen
);
79 ActivateWindow(fontwindow
);
80 FadeRGB4(fontscreen
,fcols
,2,1,config
->fadetime
);
81 show_global_font
=font
;
83 fred
=WaitForMouseClick(0,fontwindow
);
85 show_global_font
=NULL
;
86 if (fred
!=-3) FadeRGB4(fontscreen
,fcols
,2,-1,config
->fadetime
);
88 cleanup_fontdisplay();
91 return((fred
==0)?1:-1);
94 int setupfontdisplay(depth
,coltab
)
98 struct DimensionInfo dims
;
99 struct RastPort
*font_rp
;
101 font_scr
.Width
=GfxBase
->NormalDisplayColumns
;
102 font_scr
.Height
=STDSCREENHEIGHT
;
103 font_scr
.Depth
=depth
;
104 // if (system_version2 >= OSVER_39)
106 font_scr
.Extension
[0].ti_Data
= BestModeID(BIDTAG_DesiredWidth
, font_scr
.Width
,
107 BIDTAG_DesiredHeight
, font_scr
.Height
,
108 BIDTAG_Depth
, font_scr
.Depth
,
109 BIDTAG_MonitorID
, GetVPModeID(&Window
->WScreen
->ViewPort
) & MONITOR_ID_MASK
,
111 D(bug("Font screen ModeID: %lx\n",font_scr
.Extension
[0].ti_Data
));
112 if (font_scr
.Extension
[0].ti_Data
== INVALID_ID
) font_scr
.Extension
[0].ti_Data
= HIRES_KEY
;
113 if (GetDisplayInfoData(NULL
,(UBYTE
*)&dims
,sizeof(struct DimensionInfo
),DTAG_DIMS
,font_scr
.Extension
[0].ti_Data
))
115 font_scr
.Width
= dims
.Nominal
.MaxX
-dims
.Nominal
.MinX
+1;
116 font_scr
.Height
= dims
.Nominal
.MaxY
-dims
.Nominal
.MinY
+1;
119 if (!(fontscreen
=OpenScreen((struct NewScreen
*)&font_scr
))) return(0);
120 font_win
.Width
=fontscreen
->Width
;
121 font_win
.Height
=fontscreen
->Height
;
122 font_win
.Screen
=fontscreen
;
123 if (!(fontwindow
=OpenWindow(&font_win
))) {
124 CloseScreen(fontscreen
);
127 font_rp
=fontwindow
->RPort
;
132 // if (num>16) num=16;
133 for (a
=0;a
<num
;a
++) coltab
[a
]=GetRGB4(fontscreen
->ViewPort
.ColorMap
,a
);
135 LoadRGB4(&fontscreen
->ViewPort
,nullpalette
,1<<depth
);
136 setnullpointer(fontwindow
);
140 void cleanup_fontdisplay()
142 ScreenToFront(blankscreen
? blankscreen
: Window
->WScreen
);
144 CloseWindow(fontwindow
);
148 CloseScreen(fontscreen
);
151 ActivateWindow(Window
);
157 //D(bug("readhelp(%s)\n",file);Delay(50));
158 if (file
) doreadhelp(file
);
159 if (dopus_firsthelp
) screen_gadgets
[SCRGAD_TINYHELP
].Flags
&=~GFLG_DISABLED
;
160 else screen_gadgets
[SCRGAD_TINYHELP
].Flags
|=GFLG_DISABLED
;
161 if (Window
&& config
->generalscreenflags
&SCR_GENERAL_TINYGADS
)
162 dolittlegads(&screen_gadgets
[SCRGAD_TINYHELP
],&globstring
[STR_TINY_BUTTONS
][4],1);
165 void doreadhelp(file
)
168 int a
,b
,helpsize
,inmsg
;
170 struct Help
*temph
,*curhelp
;
172 //D(bug("doreadhelp(%s)\n",file);Delay(50));
174 if (!file
[0] || !(buf
=AllocMem(10000,MEMF_CLEAR
))) return;
175 if (readfile(file
,&helpbuf
,&helpsize
)) {
182 for (a
=0;a
<helpsize
;a
++) {
183 if (helpbuf
[a
]=='*' && !inmsg
) {
189 if (b
==9999 || helpbuf
[a
]=='\n') {
191 if (!(temph
=LAllocRemember(&help_key
,sizeof(struct Help
),MEMF_CLEAR
))) break;
192 if (!(temph
->lookup
=LAllocRemember(&help_key
,b
+1,MEMF_CLEAR
))) break;
193 CopyMem(buf
,temph
->lookup
,b
);
194 if (curhelp
) curhelp
->next
=temph
;
195 else dopus_firsthelp
=temph
;
205 if (b
==9999 || helpbuf
[a
]=='^') {
208 if (!(curhelp
->message
=LAllocRemember(&help_key
,b
+1,MEMF_CLEAR
))) break;
209 CopyMem(buf
,curhelp
->message
,b
);
224 static STRPTR helpcontext
[] = {
347 char *getAGnode(char *buf
,char *func
)
351 for (i
= 0; func
[i
] && func
[i
] != ' '; i
++) buf
[i
] = func
[i
];
354 for(i
= 0; helpcontext
[i
]; i
++) if (stricmp(buf
,helpcontext
[i
])==0) break;
356 if (helpcontext
[i
] == NULL
) strcpy(buf
,"Main");
361 void dohelp(name
,func
,key
,qual
,defmsg
)
368 char *msg
=NULL
,*buf
=NULL
,buf1
[40],buf2
[30];
369 struct Help
*help
=dopus_firsthelp
;
374 if (help
->lookup
[0]=='*' && func
) {
375 if (Stricmp(help
->lookup
,func
)==0) {
381 if (Stricmp(help
->lookup
,name
)==0) {
389 if (!msg
) msg
= (defmsg
? defmsg
: globstring
[STR_HELP_NOT_AVAILABLE
]);
392 RawkeyToStr(key
,qual
,buf2
,NULL
,30);
393 strcpy(buf1
,globstring
[STR_KEY
]); strcat(buf1
,buf2
); strcat(buf1
,"\n\n");
396 if ((buf
=AllocMem(s
+s1
,MEMF_CLEAR
))) {
397 CopyMem(buf1
,buf
,s1
);
398 CopyMem(msg
,&buf
[s1
],s
);
403 simplerequest(msg
,globstring
[STR_CONTINUE
],NULL
);
404 if (buf
) FreeMem(buf
,s
);
406 else if (AmigaGuideBase
&& func
)
408 struct NewAmigaGuide nag
= {0};
409 AMIGAGUIDECONTEXT agc
;
412 nag
.nag_Name
= "DirectoryOpus.guide";
413 nag
.nag_Screen
= Window
->WScreen
;
414 nag
.nag_Flags
= 0 /*HTF_NOACTIVATE*/;
415 nag
.nag_Context
= helpcontext
;
416 nag
.nag_Node
= getAGnode(buf
,func
[0]=='*'?func
+1:func
);
418 D(bug("Trying to display Amigaguide node \"%s\"\n",nag
.nag_Node
));
419 if ((agc
= OpenAmigaGuide(&nag
,NULL
)))
421 CloseAmigaGuide(agc
);
423 else simplerequest(defmsg
? defmsg
: globstring
[STR_HELP_NOT_AVAILABLE
],globstring
[STR_CONTINUE
],NULL
);
429 void checkstringgads(a
)
433 checkdir(str_pathbuffer
[a
],&path_strgadget
[a
]);
434 strcpy(dopus_curwin
[a
]->directory
,str_pathbuffer
[a
]);
437 void setdirsize(dir
,byte
,win
)
438 struct Directory
*dir
;
442 if (status_iconified
|| win
==-1) return;
445 dopus_curwin
[win
]->bytestot
-=dir
->size
;
446 if (dir
->selected
) dopus_curwin
[win
]->bytessel
-=dir
->size
;
448 if (byte
<-1) byte
=-1;
451 dopus_curwin
[win
]->bytestot
+=byte
;
452 if (dir
->selected
) dopus_curwin
[win
]->bytessel
+=byte
;