Clean-up (debug features)
[scilab.git] / scilab / modules / graphics / macros / getlinestyle.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA
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.1-en.txt
8
9
10 function k=getlinestyle()
11     [lhs,rhs]=argn(0)
12
13     warnobsolete("ged", "5.5.0");
14
15     win=max(winsid()+1)
16     scf(win);
17
18     toolbar(win, "off");
19     delmenu(win,_("&File"));
20     delmenu(win,_("&Edit"));
21     delmenu(win,_("&Tools"));
22     delmenu(win,_("&?"));
23
24     //Event handler and menu definition
25     deff("evh(gwin,x,y,ibut)",..
26     ["global pos done"
27     "if or(ibut==(0:5)) then "
28     "   [x,y]=xchange(x,y,''i2f'')"
29     "   pos=[x,y],done=0,"
30     "end"
31     "if ibut==-1000 then ,done=3,end"
32     ])
33     deff("menu_ok(k,gwin)","global done;done=1")
34     deff("menu_cancel(k,gwin)","global done;done=2")
35
36
37     f=gcf();
38     cur_draw_mode = f.immediate_drawing;
39     f.immediate_drawing="off"
40     a=gca();
41     a.axes_visible="off";
42     a.data_bounds=[0 0;5 12];
43     a.font_size=3;
44     a.title.text = "Select line style k by clicking in rectangle or line";
45     a.title.font_size=3;
46
47     x=(1:5)';
48     R=[]
49     for k=1:6
50         xstringb(0,2*k-2,"k = "+string(k),1,2);
51         s=gce();
52         s.font_size=3;
53         xrect(0, 2*k, 1, 2);R=[R,gce()]
54     end
55     a.thickness=2
56     for k=1:6
57         xpoly(x,2*k*ones(x) - 1);
58         p=gce();
59         p.mark_mode = "off";
60         p.line_style=k;
61     end
62     f.immediate_drawing=cur_draw_mode;
63
64     global pos done;done=-1;
65     ksel=1;
66     seteventhandler("evh")
67     addmenu(win,"Ok",list(2,"menu_ok"));
68     addmenu(win,"Cancel",list(2,"menu_cancel"));
69
70     k1=[]; //default
71
72     while %t
73         select done
74         case 0 then //click somehere
75             cx = pos(1);
76             cy = pos(2);
77             k1 = ceil(cy/2);k1=min(k1,6);k1=max(1,k1);
78             drawlater();
79             R(ksel).thickness=1;
80             R(k1).thickness=3;
81             ksel=k1
82             drawnow();
83         case 1 then  // ok button clicked
84             k=k1;break,
85         case 2 then   // cancel button clicked
86             k=[];break,
87         case 3 then //the window has been blosed
88             k=[],
89             clearglobal pos done
90             return
91         end
92         xpause(100)
93     end
94     seteventhandler("")
95     delete(f);
96     clearglobal pos done
97 endfunction