1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // This file must be used under the terms of the CeCILL.
4 // This source file is licensed as described in the file COPYING, which
5 // you should have received as part of this distribution. The terms
6 // are also available at
7 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 function [fontId,fontSize]=getfont(S,v1)
12 //returns the clicked font id and font size.
13 fontId=[];fontSize=[];
15 warnobsolete('ged', '5.5.0');
17 if exists('S','local')==0 then S="a";end
19 error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"), "getfont", 1));
26 //fnts=xlfont();nf=size(find(fnts<>''),'*')-1
27 fontnames=['Courrier';'Symbol';'Times';'Times Italic';
28 'Times Bold';'Times Bold Italic';
29 'Helvetica';'Helvetica Italic';
30 'Helvetica Bold';'Helvetica Bold Italic'];
32 nf=size(fontnames,'*')
35 nz=size(font_sz,'*'); //number of font sizes
36 //Disabling standard menus
38 addmenu(win,'Ok',list(2,'menu_ok'));
39 addmenu(win,'Cancel',list(2,'menu_cancel'));
41 delmenu(win,_("&Edit"))
42 delmenu(win,_("&Tools"))
43 delmenu(win,_("&File"))
46 red=addcolor([1 0 0]);
47 W1=6 //first column width
48 H1=2 // first row height
55 deff('menu_ok(k,gwin)','done=%t;k=[-fontId,fontSize];')
56 deff('menu_cancel(k,gwin)','done=%t;k=[];')
58 if exists('font','local') then
59 fontId=max(0,min(nf,font(1)))
60 fontSize=max(0,min(5,font(2)))
61 selected=fontId+nf*fontSize+1;
62 t=Hdl(selected); t.foreground=red;
69 [c_i,cx,cy,cw,str]=xclick();
72 if strindex(str,"menu_ok")==1 then xdel(win);break,end
73 if strindex(str,"menu_cancel")==1 then xdel(win);break,end
75 elseif c_i==-1000 then
80 elseif c_i>=0 & c_i<=12 then
86 fontId=max(0,min(nf,floor((cy)/H)));
87 fontSize=max(0,min(nz,floor((cx-W1)/W)));
88 selected=fontId+nf*fontSize+1;
89 t=Hdl(selected);t.foreground=red;
91 xinfo('You have chosen fontId = '+string(fontId)+' , fontSize = '+string(fontSize))
93 elseif c_i>=32 & c_i<1032 then
95 drawlater();Hdl.text=S;drawnow()
98 drawlater();Hdl.text=S;;drawnow()
102 if strindex(str,"menu_cancel")==1 then
108 fontId=[fontId,fontSize];
113 function Hdl=drawchart()
117 a.margins([1:2 4])=0.1
118 a.data_bounds=[0 0;W1+nz*W H1+(nf)*H]
119 a.title.text=["Click to select font Id and font size";
120 "or press a key to select a character"];
122 // Drawing first column
124 xstringb(0,H*k,fontnames(k+1)+' ('+string(k)+')',W1,H)
125 xrect(0, H*(k+1), W1, H);
130 xstringb(W1+l*W,(nf)*H ,string(font_sz(l+1)),W,H1)
131 xrect(W1+l*W, H1+(nf)*H, W, H1);
134 // drawing top left corner
135 xrect(0,H1+(nf)*H,W1,H1);
136 xstringb(0, (nf)*H,"Id (index)\Size",W1,H1)
142 xstringb(W1+(x-1)*W,-H*k,S,W,H)
143 t=gce();t.font_size=font_sz(x);t.font_style=-k