disable promotion of c++ warnings to errors if paranoia builds are enabled.
[AROS-Contrib.git] / dopus / Config / screen_fonts.c
blobde378b7fbfeeb3c5b23594f72e9ea6d64e6dd6fa
1 /*
3 Directory Opus 4
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.
31 #include "config.h"
33 #define ABS(x) ((x)<0?-(x):(x))
35 initfontlist(num,move,flags)
36 int num,move,flags;
38 int a,b,dist=0,one,val,size=-1;
39 char name[80],*ptr;
41 if (!fontlist) return(0);
42 if (!flags) fontlistview.items=fontlist;
43 else if (flags==FFLAG_8ONLY) fontlistview.items=only8list;
44 else if (flags==FFLAG_NOPROP) fontlistview.items=noproplist;
45 strcpy(name,config->fontbufs[num]);
46 if (ptr=strstri(name,".font")) *ptr=0;
47 for (a=0;;a++) {
48 if (!fontlistview.items[a]) break;
49 if (strcmp(name,fontlistview.items[a])==0) {
50 fontlistview.itemselected=a;
51 if (move) {
52 if (a<fontlistview.topitem || a>fontlistview.topitem+7)
53 fontlistview.topitem=a;
55 if (fontsizelist) {
56 if (!flags) fontsizelistview.items=fontsizelist[a];
57 else if (flags==FFLAG_8ONLY) fontsizelistview.items=only8sizelist;
58 else if (flags==FFLAG_NOPROP) fontsizelistview.items=nopropsizelist[a];
59 if (fontsizelistview.items) {
60 one=-1;
61 for (b=0;;b++) {
62 if (!fontsizelistview.items[b]) break;
63 if ((val=atoi(fontsizelistview.items[b]))==(int)config->fontsizes[num]) {
64 fontsizelistview.itemselected=b;
65 if (move) {
66 if (b<fontsizelistview.topitem ||
67 b>fontsizelistview.topitem+fontsizelistview.lines)
68 fontsizelistview.topitem=b;
70 one=-1;
71 break;
73 else if (one==-1 || ABS((val-(int)config->fontsizes[num]))<dist) {
74 dist=ABS((val-(int)config->fontsizes[num]));
75 one=b;
78 if (one!=-1) {
79 /*if (version2)*/ {
80 size=config->fontsizes[num];
81 lsprintf(fontsize_buf,"%ld",size);
82 RefreshStrGad(&fontsizegadget,Window);
83 fontsizelistview.itemselected=-1;
85 /* else {
86 size=atoi(fontsizelistview.items[one]);
87 fontsizelistview.itemselected=one;
88 if (move) {
89 if (one<fontsizelistview.topitem ||
90 one>fontsizelistview.topitem+fontsizelistview.lines-1)
91 fontsizelistview.topitem=one;
93 }*/
95 else size=(int)config->fontsizes[num];
98 break;
101 RefreshListView(&fontlistview,2);
102 if (size>-1) {
103 strcat(name,".font");
104 dofontdemo(name,size);
106 return(size);
109 void sortfontlist(avail,num,type)
110 struct AvailFonts *avail;
111 int num,type;
113 int gap,i,j,k;
115 for (gap=num/2;gap>0;gap/=2)
116 for (i=gap;i<num;i++)
117 for (j=i-gap;j>=0;j-=gap) {
118 k=j+gap;
119 if (type==0) {
120 if (LStrCmpI((char *)avail[j].af_Attr.ta_Name,
121 (char *)avail[k].af_Attr.ta_Name)<=0) break;
123 else {
124 if (LStrCmpI((char *)avail[j].af_Attr.ta_Name,
125 (char *)avail[k].af_Attr.ta_Name)) break;
126 if (avail[j].af_Attr.ta_YSize<=avail[k].af_Attr.ta_YSize) break;
128 SwapMem((char *)&avail[j],(char *)&avail[k],sizeof(struct AvailFonts));
132 void dofontdemo(name,size)
133 char *name;
134 int size;
136 struct TextFont *font;
137 struct Region *reg,*oldreg;
138 struct Rectangle clip;
139 char buf[2][256];
140 int y,c,l,a;
142 clip.MinX=x_off+146;
143 clip.MinY=y_off+93;
144 clip.MaxX=x_off+611;
145 clip.MaxY=y_off+167;
146 Do3DBox(rp,
147 x_off+146,y_off+93,
148 468,76,
149 screen_pens[config->gadgetbotcol].pen,screen_pens[config->gadgettopcol].pen);
150 SetAPen(rp,screen_pens[0].pen);
151 RectFill(rp,x_off+146,y_off+93,x_off+613,y_off+167);
152 SetAPen(rp,screen_pens[1].pen);
153 busy();
154 UScoreText(rp,
155 cfg_string[STR_LOADING_FONT],
156 x_off+329,y_off+133,
157 -1);
158 if (font=getfont(name,&size,0)) {
159 SetAPen(rp,screen_pens[0].pen);
160 RectFill(rp,
161 x_off+146,y_off+94,
162 x_off+613,y_off+167);
163 SetAPen(rp,screen_pens[1].pen);
164 SetFont(rp,font);
165 if (reg=NewRegion()) {
166 OrRectRegion(reg,&clip);
167 oldreg=InstallClipRegion(Window->WLayer,reg);
168 l=255;
170 else l=464/font->tf_XSize;
171 y=font->tf_Baseline;
172 c='a';
173 for (a=0;a<256;a++) {
174 buf[0][a]=c++;
175 if (c=='{') c='0';
177 for (a=0;a<256;a++) {
178 if (isupper(buf[0][a])) buf[1][a]=ToLower(buf[0][a]);
179 else buf[1][a]=ToUpper(buf[0][a]);
181 a=0;
182 while (y<76+font->tf_Baseline) {
183 Move(rp,x_off+148,y+y_off+94);
184 Text(rp,buf[a],l);
185 a=a?0:1;
186 y+=font->tf_YSize;
188 if (reg) {
189 InstallClipRegion(Window->WLayer,oldreg);
190 DisposeRegion(reg);
192 SetFont(rp,tfont);
193 CloseFont(font);
195 else UScoreText(rp,
196 cfg_string[STR_FONT_COULD_NOT_BE_LOADED],
197 x_off+289,y_off+133,
198 -1);
199 unbusy();