2
#include "men_scilab.h"
4
#define MAXLISTLINE 30 /* Maximum number of line in a List widget Viewport */
5
#define MAXLISTCOLS 120 /* Maximum number of columns in a List widget Viewport */
6
#define MAXLABLINE 10 /* Maximum number of line in a List widget Viewport */
7
#define MAXLABCOLS 120 /* Maximum number of columns in a List widget Viewport */
8
#define MAXASCLINE 30 /* Maximum number of line in anascii widget */
9
#define MAXASCCOLS 120 /* Maximum number of columns in an ascii widget Viewport */
10
#define ScrThickness 10 /* ScrollbarThickness maximizer */
12
#define char_height(font) ((font)->max_bounds.ascent+(font)->max_bounds.descent)
13
#define char_width(font) ((font)->max_bounds.width)
16
extern int set_cmap __PARAMS((Window w));
17
extern void DisplayInit __PARAMS((char *string,Display **dpy,Widget *toplevel));
19
extern XtAppContext app_con;
20
/** int ok_Flag_sci = 0; **/
23
static Cardinal iargs = 0;
27
/*****************************************************************
28
* generic function used for all the Scilab transient `menus'
29
*****************************************************************/
31
/********************************************************
32
*a special loop when inside transient menu shells
33
* we want to exit the loop when ok_Flag_sci != 0
34
*******************************************************/
36
void XtMyLoop(w,dpy,flag,ok_Flag)
45
/* XtPopup(w,XtGrabExclusive);*/
46
XtPopup(w,XtGrabNone);
50
/** used in men_choice to get the scilab graphic colormap */
51
set_cmap(XtWindow(w));
52
/** if scilab graphic window has a private colormap we must redraw
53
the xchoice widget **/
55
/* On ignore les delete envoyes par le Window Manager */
56
wmDeleteWindow = XInternAtom(XtDisplay(w),"WM_DELETE_WINDOW", False);
57
XSetWMProtocols(XtDisplay(w),XtWindow(w), &wmDeleteWindow, 1);
59
XtAppNextEvent(app_con,&event);
60
XtDispatchEvent(&event);
61
if ( *ok_Flag != 0) break;
68
/********************************************************
69
* creates a transient shell+a form Widget
70
* #define SHELL_TYPE wmShellWidgetClass
71
********************************************************/
73
#define SHELL_TYPE transientShellWidgetClass
76
ShellFormCreate(shellname,shell,form,dpyh)
81
static Widget toplevel,hpaned;
82
DisplayInit("",dpyh,&toplevel);
84
*shell = XtCreatePopupShell(shellname,SHELL_TYPE,toplevel,
85
(Arg *) NULL,(Cardinal)ZERO);
86
hpaned = XtCreateManagedWidget("hpaned",panedWidgetClass,*shell,
87
(Arg *) NULL,(Cardinal)ZERO);
89
*form = XtCreateManagedWidget("paned",panedWidgetClass,hpaned,
90
(Arg *) NULL,(Cardinal)ZERO);
94
/********************************************************
95
* just add a button and it's callback
96
********************************************************/
98
int ButtonCreate(parentW,button,callback,data,label,name)
99
Widget parentW,*button;
101
XtCallbackProc callback;
105
XtSetArg(args[iargs], XtNlabel,label); iargs++;
106
*button=XtCreateManagedWidget(name,commandWidgetClass,parentW,args,iargs);
107
XtAddCallback(*button, XtNcallback,callback ,(XtPointer) data);
111
/********************************************************
112
* This function creates a labelwidget inside a vieportwidget
113
* and resizes the labelwidget not to exceed max values
114
* [ the viewport will have the scrollbars ]
115
* the function return the two widgets and the width and height
116
* Reste un point obscur doit on fixer le with/height du viewport ou du label ?
117
* parentW is the widget inside which the viewport/label is inserted
118
********************************************************/
121
int ViewpLabelCreate(parentW,labelW,viewportW,description)
123
Widget *labelW,*viewportW;
127
*viewportW = XtCreateManagedWidget("labelviewport",viewportWidgetClass,parentW,args,iargs);
129
XtSetArg(args[iargs], XtNlabel, description); iargs++;
130
*labelW=XtCreateManagedWidget("label",labelWidgetClass,*viewportW,args, iargs);
135
/********************************************************
136
* This function creates a listwidget inside a vieportwidget
137
* and resizes the listwidget not to exceed max values
138
* [ the viewport will have the scrollbars ]
139
* the function return the two widgets and the width and height
140
* Reste un point obscur doit on fixer le with/height du viewport ou du list ?
141
* parentW is the widget inside which the viewport/list is inserted
142
********************************************************/
145
int ViewpListCreate(parentW,listW,viewportW,strings,nstr)
147
Widget *listW,*viewportW;
152
/* create chooseviewport and chooselist widgets */
153
*viewportW = XtCreateManagedWidget("listviewport",viewportWidgetClass,
156
XtSetArg(args[iargs], XtNlist, strings); iargs++;
157
*listW=XtCreateManagedWidget("list",listWidgetClass,*viewportW,
162
/********************************************************
164
* Computes the label Widget size of a label widget
165
* filled with a string of nchar per lines and nlines
166
********************************************************/
168
int LabelSize(label,nchar,nlines,width,height)
171
Dimension *width,*height;
173
Dimension la_iheight=10 , la_iwidth=10;
174
XFontStruct *temp_font = (XFontStruct *) NULL;
176
XtSetArg(args[iargs],XtNfont, &temp_font); iargs++;
177
XtSetArg(args[iargs],XtNinternalHeight, &la_iheight); iargs++;
178
XtSetArg(args[iargs],XtNinternalWidth, &la_iwidth); iargs++;
179
XtGetValues(label, args, iargs);
180
*height = nlines*(char_height(temp_font) + 0)+ (int) 2*la_iheight + ScrThickness ;
181
*width = nchar*Max(char_width(temp_font),1) + (int) 2*la_iwidth + ScrThickness;
185
/********************************************************
186
*Computes the ascii Widget size of an ascii widget
187
* filled with a string of nchar per lines and nlines
188
* with restriction on lines and cols
189
********************************************************/
191
int AsciiSize(ascii,nchar,nlines,width,height)
194
Dimension *width,*height;
196
Dimension rmarg,lmarg,topmarg,botmarg;
197
XFontStruct *temp_font = (XFontStruct *) NULL;
199
XtSetArg(args[iargs],XtNfont, &temp_font); iargs++;
200
XtSetArg(args[iargs],XtNrightMargin, &rmarg); iargs++;
201
XtSetArg(args[iargs],XtNleftMargin, &lmarg); iargs++;
202
XtSetArg(args[iargs],XtNtopMargin, &topmarg); iargs++;
203
XtSetArg(args[iargs],XtNbottomMargin, &botmarg); iargs++;
204
XtGetValues(ascii, args, iargs);
205
*height=Min(nlines,MAXASCLINE)*(char_height(temp_font)+0) + topmarg+botmarg + ScrThickness;
206
*width=Min(nchar,MAXASCCOLS)*Max(char_width(temp_font),1) + rmarg+lmarg + ScrThickness;
210
/********************************************************
211
* Set a lable widget label and size : size is greater
212
* than the size needed by str
213
********************************************************/
216
int SetLabel(label,str,width,height)
219
Dimension width,height;
222
XtSetArg(args[iargs], XtNwidth ,width) ; iargs++;
223
XtSetArg(args[iargs], XtNheight ,height) ; iargs++;
224
XtSetArg(args[iargs], XtNlabel ,str) ; iargs++;
225
XtSetValues(label, args, iargs);
229
/********************************************************
230
* Set an ascii Widget strin and size
231
********************************************************/
233
int SetAscii(ascii,str,width,height)
236
Dimension width,height;
239
XtSetArg(args[iargs], XtNwidth ,width) ; iargs++;
240
XtSetArg(args[iargs], XtNheight ,height) ; iargs++;
241
XtSetArg(args[iargs], XtNstring ,str) ; iargs++;
242
XtSetValues(ascii, args, iargs);