* Bug 15067 fixed: adds D&D of XMI files
[scilab.git] / scilab / modules / graphics / macros / datatips / datatipsGUI.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
12
13 function datatipsGUI(curve_handle)
14     global datatipGUIwin
15     if datatipGUIwin<>[]&or(datatipGUIwin==winsid()) then //the gui window is already opened
16         global  datatipGUICurve
17         datatipGUICurve= curve_handle
18         datatipSetGUI()
19         return
20     end
21
22
23     global datatipGUIHandles datatipGUICurve datatipGUIwin
24     margin_x     = 5;      // Horizontal margin between each elements
25     margin_y     = 5;      // Vertical margin between each elements
26     button_w     = 150;
27     button_h     = 25;
28     label_h      = 20;
29     label_w      = 160;
30     slabel_w     = 80;
31     editor_h     = 120;
32     axes_w       = 3*margin_x+label_w+2*(slabel_w+4*margin_x+label_h);
33     editor_w     = axes_w-2*margin_x;
34     axes_h       = 4*margin_y+6*(label_h+margin_y)+ button_h;
35     defaultfont  = "arial"; // Default Font
36     datatipGUICurve= curve_handle
37     ud=datatipGetStruct(datatipGUICurve)
38     if typeof(ud)<>"datatips" then
39         //no datatips structure yet, initialize it
40         ud=datatipGetStruct(curve)
41     end
42     style=ud.style
43
44     datatipGUIwin=max(winsid())+1
45
46     fig_id=datatipGUIwin
47     fig = scf(fig_id)
48     fig.event_handler="datatipGUIEventHandler"
49     fig.event_handler_enable="on"
50
51     // Remove Scilab graphics menus & toolbar
52     //  drawlater (bug)
53     delmenu(fig.figure_id, gettext("&File"));
54     delmenu(fig.figure_id, gettext("&Tools"));
55     delmenu(fig.figure_id, gettext("&Edit"));
56     delmenu(fig.figure_id, gettext("&?"));
57     toolbar(fig.figure_id, "off");
58     fig.axes_size       = [axes_w axes_h];
59
60
61     fig.background      = addcolor([0.8 0.8 0.8]);
62     fig.figure_name     = _("Datatips style");
63     ax=fig.children;
64     ax.background= fig.background ;
65     gui=uicontrol( ..
66     "parent"              , fig,...
67     "style"               , "frame", ..
68     "units"               , "pixels", ..
69     "position"            , [0 0 axes_w axes_h], ..
70     "background"          , [1 1 1]*0.8, ..
71     "visible"             , "on");
72
73     yo=axes_h-margin_y-label_h;
74     xo=margin_x;
75     H=[]
76     //Datatips positionning
77     x=xo;
78     y=yo;
79     uicontrol( ...
80     "parent"              , gui, ..
81     "style"               , "text", ..
82     "string"              , _("Marker style:"), ..
83     "units"               , "pixels", ..
84     "position"            , [x y label_w label_h], ..
85     "fontname"            , defaultfont, ..
86     "fontunits"           , "points", ..
87     "fontsize"            , 12, ..
88     "fontweight"          , "bold", ..
89     "horizontalalignment" , "left", ..
90     "background"          , [1 1 1]*0.8, ..
91     "visible"             , "on");
92     x=x+label_w+margin_x;
93     uicontrol( ...
94     "parent"              , gui, ..
95     "style"               , "text", ..
96     "string"              , _("Square"), ..
97     "units"               , "pixels", ..
98     "position"            , [x y slabel_w label_h], ..
99     "HorizontalAlignment" , "right", ..
100     "fontname"            , defaultfont, ..
101     "fontunits"           , "points", ..
102     "fontsize"            , 12, ..
103     "background"          , [1 1 1]*0.8, ..
104     "visible"             , "on");
105     x=x+slabel_w+margin_x
106     r1=  uicontrol( ...
107     "parent"              , gui, ..
108     "style"               , "radiobutton", ..
109     "value"               , 1, ..
110     "units"               , "pixels", ..
111     "position"            , [x y label_h label_h], ..
112     "background"          , [1 1 1]*0.8, ..
113     "callback"            , "datatipRadioCallback(""sty"",%t)", ..
114     "visible"             , "on");
115     x=x+label_h+4*margin_x;
116     uicontrol( ...
117     "parent"              , gui, ..
118     "style"               , "text", ..
119     "string"              , _("Arrow"), ..
120     "units"               , "pixels", ..
121     "position"            , [x y slabel_w label_h], ..
122     "HorizontalAlignment" , "right", ..
123     "fontname"            , defaultfont, ..
124     "fontunits"           , "points", ..
125     "fontsize"            , 12, ..
126     "background"          , [1 1 1]*0.8, ..
127     "visible"             , "on");
128
129     x=x+slabel_w+margin_x;
130     r2=  uicontrol( ...
131     "parent"              , gui, ..
132     "style"               , "radiobutton", ..
133     "value"               , 0, ..
134     "units"               , "pixels", ..
135     "position"            , [x y label_h label_h], ..
136     "background"          , [1 1 1]*0.8, ..
137     "callback"            , "datatipRadioCallback(""sty"",%f)", ..
138     "visible"             , "on");
139     H=[H;r1 r2]
140     //Datatips Label
141     x=xo;
142     y=y-margin_y-label_h;
143     uicontrol( ...
144     "parent"              , gui, ..
145     "style"               , "text", ..
146     "string"              , _("Labeled?"), ..
147     "units"               , "pixels", ..
148     "position"            , [x y label_w label_h], ..
149     "fontname"            , defaultfont, ..
150     "fontunits"           , "points", ..
151     "fontsize"            , 12, ..
152     "fontweight"          , "bold", ..
153     "horizontalalignment" , "left", ..
154     "background"          , [1 1 1]*0.8, ..
155     "visible"             , "on");
156     x=x+label_w+margin_x;
157     uicontrol( ...
158     "parent"              , gui, ..
159     "style"               , "text", ..
160     "string"              , _("Yes"), ..
161     "units"               , "pixels", ..
162     "position"            , [x y slabel_w label_h], ..
163     "fontname"            , defaultfont, ..
164     "fontunits"           , "points", ..
165     "fontsize"            , 12, ..
166     "horizontalalignment" , "right", ..
167     "background"          , [1 1 1]*0.8, ..
168     "visible"             , "on");
169     x=x+slabel_w+margin_x
170     r1=  uicontrol( ...
171     "parent"              , gui, ..
172     "style"               , "radiobutton", ..
173     "value"               , 1, ..
174     "units"               , "pixels", ..
175     "position"            , [x y label_h label_h], ..
176     "background"          , [1 1 1]*0.8, ..
177     "callback"            , "datatipRadioCallback(""lab"",%t)", ..
178     "visible"             , "on");
179     x=x+label_h+4*margin_x;
180     uicontrol( ...
181     "parent"              , gui, ..
182     "style"               , "text", ..
183     "string"              , _("No"), ..
184     "units"               , "pixels", ..
185     "position"            , [x y slabel_w label_h], ..
186     "fontname"            , defaultfont, ..
187     "fontunits"           , "points", ..
188     "fontsize"            , 12, ..
189     "horizontalalignment" , "right", ..
190     "background"          , [1 1 1]*0.8, ..
191     "visible"             , "on");
192
193     x=x+slabel_w+margin_x;
194     r2=  uicontrol( ...
195     "parent"              , gui, ..
196     "style"               , "radiobutton", ..
197     "value"               , 0, ..
198     "units"               , "pixels", ..
199     "position"            , [x y label_h label_h], ..
200     "background"          , [1 1 1]*0.8, ..
201     "callback"            , "datatipRadioCallback(""lab"",%f)", ..
202     "visible"             , "on");
203     H=[H;r1 r2]
204
205     //Datatips box
206     x=xo;
207     y=y-margin_y-label_h;
208     uicontrol( ...
209     "parent"              , gui, ..
210     "style"               , "text", ..
211     "string"              , _("Boxed?"), ..
212     "units"               , "pixels", ..
213     "position"            , [x y label_w label_h], ..
214     "fontname"            , defaultfont, ..
215     "fontunits"           , "points", ..
216     "fontsize"            , 12, ..
217     "fontweight"          , "bold", ..
218     "horizontalalignment" , "left", ..
219     "background"          , [1 1 1]*0.8, ..
220     "visible"             , "on");
221     x=x+label_w+margin_x;
222     uicontrol( ...
223     "parent"              , gui, ..
224     "style"               , "text", ..
225     "string"              , _("Yes"), ..
226     "units"               , "pixels", ..
227     "position"            , [x y slabel_w label_h], ..
228     "fontname"            , defaultfont, ..
229     "fontunits"           , "points", ..
230     "fontsize"            , 12, ..
231     "horizontalalignment" , "right", ..
232     "background"          , [1 1 1]*0.8, ..
233     "visible"             , "on");
234     x=x+slabel_w+margin_x;
235     r1=  uicontrol( ...
236     "parent"              , gui, ..
237     "style"               , "radiobutton", ..
238     "value"               , 1, ..
239     "units"               , "pixels", ..
240     "position"            , [x y label_h label_h], ..
241     "background"          , [1 1 1]*0.8, ..
242     "callback"            , "datatipRadioCallback(""box"",%t)", ..
243     "visible"             , "on");
244     x=x+label_h+4*margin_x;
245     uicontrol( ...
246     "parent"              , gui, ..
247     "style"               , "text", ..
248     "string"              , _("No"), ..
249     "units"               , "pixels", ..
250     "position"            , [x y slabel_w label_h], ..
251     "fontname"            , defaultfont, ..
252     "fontunits"           , "points", ..
253     "fontsize"            , 12, ..
254     "horizontalalignment" , "right", ..
255     "background"          , [1 1 1]*0.8, ..
256     "visible"             , "on");
257
258     x=x+slabel_w+margin_x;
259     r2=  uicontrol( ...
260     "parent"              , gui, ..
261     "style"               , "radiobutton", ..
262     "value"               , 0, ..
263     "units"               , "pixels", ..
264     "position"            , [x y label_h label_h], ..
265     "background"          , [1 1 1]*0.8, ..
266     "callback"            , "datatipRadioCallback(""box"",%f)", ..
267     "visible"             , "on");
268     H=[H;r1 r2]
269     //marker position
270     x=xo;
271     y=y-margin_y-label_h;
272     uicontrol( ...
273     "parent"              , gui, ..
274     "style"               , "text", ..
275     "string"              , _("Positionning?"), ..
276     "units"               , "pixels", ..
277     "position"            , [x y label_w label_h], ..
278     "fontname"            , defaultfont, ..
279     "fontunits"           , "points", ..
280     "fontsize"            , 12, ..
281     "fontweight"          , "bold", ..
282     "horizontalalignment" , "left", ..
283     "background"          , [1 1 1]*0.8, ..
284     "visible"             , "on");
285     x=x+label_w+margin_x;
286     uicontrol( ...
287     "parent"              , gui, ..
288     "style"               , "text", ..
289     "string"              , _("Knots"), ..
290     "units"               , "pixels", ..
291     "position"            , [x y slabel_w label_h], ..
292     "fontname"            , defaultfont, ..
293     "fontunits"           , "points", ..
294     "fontsize"            , 12, ..
295     "horizontalalignment" , "right", ..
296     "background"          , [1 1 1]*0.8, ..
297     "visible"             , "on");
298     x=x+slabel_w+margin_x;
299     r1=  uicontrol( ...
300     "parent"              , gui, ..
301     "style"               , "radiobutton", ..
302     "value"               , 1, ..
303     "units"               , "pixels", ..
304     "position"            , [x y label_h label_h], ..
305     "background"          , [1 1 1]*0.8, ..
306     "callback"            , "datatipRadioCallback(""pos"",%t)", ..
307     "visible"             , "on");
308     x=x+label_h+4*margin_x;
309     uicontrol( ...
310     "parent"              , gui, ..
311     "style"               , "text", ..
312     "string"              , _("Interpolated"), ..
313     "units"               , "pixels", ..
314     "position"            , [x y slabel_w label_h], ..
315     "fontname"            , defaultfont, ..
316     "fontunits"           , "points", ..
317     "fontsize"            , 12, ..
318     "horizontalalignment" , "right", ..
319     "background"          , [1 1 1]*0.8, ..
320     "visible"             , "on");
321
322     x=x+slabel_w+margin_x;
323     r2=  uicontrol( ...
324     "parent"              , gui, ..
325     "style"               , "radiobutton", ..
326     "value"               , 0, ..
327     "units"               , "pixels", ..
328     "position"            , [x y label_h label_h], ..
329     "background"          , [1 1 1]*0.8, ..
330     "callback"            , "datatipRadioCallback(""pos"",%f)", ..
331     "visible"             , "on");
332     H=[H;r1 r2]
333     //Multiple datatips
334     x=xo;
335     y=y-margin_y-label_h;
336     uicontrol( ...
337     "parent"              , gui, ..
338     "style"               , "text", ..
339     "string"              , _("Allow multiple datatips?"), ..
340     "units"               , "pixels", ..
341     "position"            , [x y label_w label_h], ..
342     "fontname"            , defaultfont, ..
343     "fontunits"           , "points", ..
344     "fontsize"            , 12, ..
345     "fontweight"          , "bold", ..
346     "horizontalalignment" , "left", ..
347     "background"          , [1 1 1]*0.8, ..
348     "visible"             , "on");
349     x=x+label_w+margin_x;
350     uicontrol( ...
351     "parent"              , gui, ..
352     "style"               , "text", ..
353     "string"              , _("Yes"), ..
354     "units"               , "pixels", ..
355     "position"            , [x y slabel_w label_h], ..
356     "fontname"            , defaultfont, ..
357     "fontunits"           , "points", ..
358     "fontsize"            , 12, ..
359     "horizontalalignment" , "right", ..
360     "background"          , [1 1 1]*0.8, ..
361     "visible"             , "on");
362     x=x+slabel_w+margin_x;
363     r1=  uicontrol( ...
364     "parent"              , gui, ..
365     "style"               , "radiobutton", ..
366     "value"               , 1, ..
367     "units"               , "pixels", ..
368     "position"            , [x y label_h label_h], ..
369     "background"          , [1 1 1]*0.8, ..
370     "callback"            , "datatipRadioCallback(""mul"",%t)", ..
371     "visible"             , "on");
372     x=x+label_h+4*margin_x;
373     uicontrol( ...
374     "parent"              , gui, ..
375     "style"               , "text", ..
376     "string"              , _("No"), ..
377     "units"               , "pixels", ..
378     "position"            , [x y slabel_w label_h], ..
379     "fontname"            , defaultfont, ..
380     "fontunits"           , "points", ..
381     "fontsize"            , 12, ..
382     "horizontalalignment" , "right", ..
383     "background"          , [1 1 1]*0.8, ..
384     "visible"             , "on");
385
386     x=x+slabel_w+margin_x;
387     r2=  uicontrol( ...
388     "parent"              , gui, ..
389     "style"               , "radiobutton", ..
390     "value"               , 0, ..
391     "units"               , "pixels", ..
392     "position"            , [x y label_h label_h], ..
393     "background"          , [1 1 1]*0.8, ..
394     "callback"            , "datatipRadioCallback(""mul"",%f)", ..
395     "visible"             , "on");
396     H=[H;r1 r2]
397     //label edition function
398     x=xo;
399     y=y-2*margin_y-button_h;
400
401     E=  uicontrol( ...
402     "parent"              , gui, ..
403     "style"               , "pushbutton", ..
404     "string"              , _("Edit label generator"), ..
405     "units"               , "pixels", ..
406     "position"            , [x y button_w button_h], ..
407     "fontname"            , defaultfont, ..
408     "fontunits"           , "points", ..
409     "fontsize"            , 12, ..
410     "callback"            , "global  datatipGUICurve;datatipSetDisplay(datatipGUICurve)", ..
411     "visible"             , "on");
412
413
414     datatipGUIHandles=H
415     datatipSetGUI()
416 endfunction