~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/xsci/wf_w_file.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define FSIZE 1024
 
2
char     cur_dir[FSIZE];
 
3
char     cur_filename[FSIZE];
 
4
 
 
5
/*
 
6
 * FIG : Facility for Interactive Generation of figures
 
7
 * Copyright (c) 1991 by Brian V. Smith
 
8
 *
 
9
 * "Permission to use, copy, modify, distribute, and sell this software and its
 
10
 * documentation for any purpose is hereby granted without fee, provided that
 
11
 * the above copyright notice appear in all copies and that both the copyright
 
12
 * notice and this permission notice appear in supporting documentation. 
 
13
 * No representations are made about the suitability of this software for 
 
14
 * any purpose.  It is provided "as is" without express or implied warranty."
 
15
 */
 
16
 
 
17
#include "wf_fig.h"
 
18
#include "wf_figx.h"
 
19
#include "wf_resources.h"
 
20
 
 
21
#include "wf_mode.h" 
 
22
#include "wf_w_drawprim.h"      /* for char_height */
 
23
#include "wf_w_dir.h"
 
24
#include "wf_w_util.h"
 
25
#include "wf_w_setup.h"
 
26
 
 
27
#include <malloc.h>
 
28
 
 
29
#include "../machine.h"
 
30
#include "All-extern.h"
 
31
#include "../menusX/men_scilab.h"
 
32
 
 
33
extern Boolean  file_msg_is_popped;
 
34
extern Widget   file_msg_popup;
 
35
Boolean warnexist=True;
 
36
 
 
37
static void file_panel_dismiss  __PARAMS((void));  
 
38
static void file_panel_cancel  __PARAMS((Widget w, XButtonEvent *ev));  
 
39
 
 
40
/* don't allow newlines in text until we handle multiple line texts */
 
41
String          text_translations =
 
42
        "<Key>Return: no-op(RingBell)\n\
 
43
        Ctrl<Key>J: no-op(RingBell)\n\
 
44
        Ctrl<Key>M: no-op(RingBell)\n\
 
45
        Ctrl<Key>X: EmptyTextKey()\n\
 
46
        Ctrl<Key>U: multiply(4)\n\
 
47
        <Key>F18: PastePanelKey()\n";
 
48
 
 
49
DeclareStaticArgs(12);
 
50
 
 
51
static Widget   cfile_lab, cfile_text;
 
52
static Widget   cancel,ok, exec,load,getf,getfc,linkf;
 
53
static Widget   file_w;
 
54
static Position xposn, yposn;
 
55
static String   file_name_translations =
 
56
        "<Key>Return: exec()\n";
 
57
 
 
58
static void     file_panel_cancel();
 
59
void            do_ok(),do_exec(), do_load(),do_getf(),do_getfc(),do_linkf();
 
60
static XtActionsRec     file_name_actions[] =
 
61
{
 
62
    {"exec", (XtActionProc) do_exec},
 
63
    {"ok", (XtActionProc) do_ok},
 
64
};
 
65
static String   file_translations =
 
66
        "<Message>WM_PROTOCOLS: DismissFile()\n";
 
67
static XtActionsRec     file_actions[] =
 
68
{
 
69
    {"DismissFile", (XtActionProc) file_panel_cancel},
 
70
    {"cancel", (XtActionProc) file_panel_cancel},
 
71
    {"ok", (XtActionProc) do_ok},
 
72
    {"exec", (XtActionProc) do_exec},
 
73
    {"load", (XtActionProc) do_load},
 
74
    {"linkf", (XtActionProc) do_linkf},
 
75
    {"getf", (XtActionProc) do_getf},
 
76
    {"getfc", (XtActionProc) do_getfc}
 
77
};
 
78
 
 
79
/* Global so w_dir.c can access us */
 
80
 
 
81
Widget          file_panel,     /* so w_dir can access the scrollbars */
 
82
                file_popup,     /* the popup itself */
 
83
                file_selfile,   /* selected file widget */
 
84
                file_mask,      /* mask widget */
 
85
                file_dir,       /* current directory widget */
 
86
                file_flist,     /* file list widget */
 
87
                file_dlist,     /* dir list widget */
 
88
                labelW;         /* popup label */
 
89
 
 
90
static void
 
91
file_panel_dismiss()
 
92
{
 
93
    FirstArg(XtNstring, "\0");
 
94
    SetValues(file_selfile);    /* clear Filename string */
 
95
    XtPopdown(file_popup);
 
96
    XtSetSensitive(file_w, True);
 
97
}
 
98
 
 
99
 
 
100
#define STRW1 ";exec(\"%s/%s\");\n"
 
101
 
 
102
int
 
103
exec_file(dir,file)
 
104
    char           *file;
 
105
     char *dir;
 
106
{
 
107
    char strsend1[sizeof(STRW1)+FSIZE];
 
108
    sprintf(strsend1,STRW1,dir,file);
 
109
    write_scilab(strsend1);
 
110
    return (0);
 
111
}
 
112
 
 
113
void
 
114
do_exec(w, ev)
 
115
    Widget          w;
 
116
    XButtonEvent   *ev;
 
117
{
 
118
    char           *fval, *dval;
 
119
 
 
120
    if (file_popup) {
 
121
        FirstArg(XtNstring, &dval);
 
122
        GetValues(file_dir);
 
123
        FirstArg(XtNstring, &fval);
 
124
        GetValues(file_selfile);        
 
125
        /* check the ascii widget for a filename */
 
126
        if (emptyname(fval))
 
127
          fval = cur_filename;  
 
128
        /* "Filename" widget empty, use current filename */
 
129
 
 
130
        if (emptyname_msg(fval, "EXEC"))
 
131
            return;
 
132
 
 
133
        if (change_directory(dval) == 0) {
 
134
            if (exec_file(dval,fval) == 0) {
 
135
                FirstArg(XtNlabel, fval);
 
136
                SetValues(cfile_text);          /* set the current filename */
 
137
                if (fval != cur_filename)
 
138
                        update_cur_filename(fval);      /* and update cur_filename */
 
139
                file_panel_dismiss();
 
140
            }
 
141
        }
 
142
    } else {
 
143
        (void) exec_file("",cur_filename);
 
144
    }
 
145
}
 
146
 
 
147
 
 
148
/***********************************
 
149
 * Used with the primitive C2F(xgetfile)
 
150
 ***********************************/
 
151
 
 
152
void ok_file(dir,file)
 
153
     char           *file;
 
154
     char *dir;
 
155
{
 
156
  write_getfile(dir,file);
 
157
}
 
158
 
 
159
void ok_end()
 
160
{
 
161
  /* Accelerators to their default values */
 
162
  XtOverrideTranslations(file_selfile,
 
163
                         XtParseTranslationTable(file_name_translations));
 
164
  XtOverrideTranslations(file_flist,
 
165
                         XtParseTranslationTable(file_name_translations));
 
166
  XtSetSensitive(ok,False);
 
167
  XtSetSensitive(exec, True);
 
168
  XtSetSensitive(load, True);
 
169
  XtSetSensitive(getf, True);
 
170
  /**  XtSetSensitive(getfc, True); **/
 
171
  XtSetSensitive(linkf, True);
 
172
}
 
173
 
 
174
static String   file_name_translations1 =
 
175
        "<Key>Return: ok()\n";
 
176
 
 
177
void ok_prep(filemask,dirname,title,flag,err)
 
178
     char *filemask;
 
179
     char *dirname;
 
180
     char *title;
 
181
     int flag,*err;
 
182
{
 
183
  char newdir[PATH_MAX];
 
184
  if (file_popup) {
 
185
/*    FirstArg(XtNtitle, title);
 
186
    SetValues(file_popup);      */
 
187
      FirstArg(XtNlabel, title);
 
188
      SetValues(labelW);
 
189
  }
 
190
 
 
191
  /* Change Accelerators to ok */
 
192
  XtOverrideTranslations(file_selfile,
 
193
                         XtParseTranslationTable(file_name_translations1));
 
194
  XtOverrideTranslations(file_flist,
 
195
                         XtParseTranslationTable(file_name_translations1));
 
196
  FirstArg(XtNstring, filemask);
 
197
  SetValues(file_mask);
 
198
  /** callingRescan because of file_mask change **/
 
199
  Rescan((Widget) 0, (XEvent*) 0, (String*) 0, (Cardinal*) 0);
 
200
  if ( flag == 1 && ((int) strlen(dirname)) >= 1 )
 
201
    {
 
202
      /* We also want to change dir */
 
203
      char longdir[PATH_MAX];
 
204
      if (dirname[0]=='~')
 
205
        {
 
206
          parseuserpath(dirname,longdir);
 
207
          strcpy(newdir, longdir);
 
208
        }
 
209
      else if ( strncmp(dirname,"SCI",3) == 0) 
 
210
        {
 
211
          parsescipath(dirname,longdir);
 
212
          strcpy(newdir, longdir);
 
213
        }
 
214
      else 
 
215
        {
 
216
          strcpy(newdir,dirname);
 
217
        }
 
218
      DoChangeDir(newdir); 
 
219
    }
 
220
  XtSetSensitive(ok,True);
 
221
  XtSetSensitive(exec, False);
 
222
  XtSetSensitive(load, False);
 
223
  XtSetSensitive(getf, False);
 
224
  /** XtSetSensitive(getfc, False); **/
 
225
  XtSetSensitive(linkf, False);
 
226
}
 
227
 
 
228
/* make the full path from SCI/partialpath */
 
229
 
 
230
void parsescipath(path,longpath)
 
231
     char *path,*longpath;
 
232
{
 
233
  strcpy(longpath,getenv("SCI"));
 
234
  if (strlen(path)==3)          /* nothing after the SCI, we have the full path */
 
235
    return;
 
236
  strcat(longpath,&path[3]);    /* append the rest of the path */
 
237
  return;
 
238
}
 
239
 
 
240
void
 
241
do_ok(w, ev)
 
242
    Widget          w;
 
243
    XButtonEvent   *ev;
 
244
{
 
245
    char           *fval, *dval;
 
246
 
 
247
    if (file_popup) {
 
248
        FirstArg(XtNstring, &dval);
 
249
        GetValues(file_dir);
 
250
        FirstArg(XtNstring, &fval);
 
251
        GetValues(file_selfile);        
 
252
        /* check the ascii widget for a filename */
 
253
        if (emptyname(fval))
 
254
          fval = cur_filename;  
 
255
        /* "Filename" widget empty, use current filename */
 
256
 
 
257
        if (emptyname_msg(fval, "OK"))
 
258
            return;
 
259
 
 
260
        if (change_directory(dval) == 0) 
 
261
          {
 
262
            ok_file(dval,fval);
 
263
            /** if (ok_file(dval,fval) == 0) { **/
 
264
              FirstArg(XtNlabel, fval);
 
265
              SetValues(cfile_text);            /* set the current filename */
 
266
              if (fval != cur_filename)
 
267
                update_cur_filename(fval);      /* and update cur_filename */
 
268
              file_panel_dismiss();
 
269
            /* } */
 
270
        }
 
271
    } else {
 
272
        (void) ok_file("",cur_filename);
 
273
    }
 
274
}
 
275
 
 
276
 
 
277
#define STRW3 ";getf(\"%s/%s\",\"c\");\n"
 
278
 
 
279
int
 
280
getfc_file(dir,file)
 
281
     char  *file;
 
282
     char *dir;
 
283
{
 
284
    char strsend1[sizeof(STRW3)+FSIZE];
 
285
    sprintf(strsend1,STRW3,dir,file);
 
286
    write_scilab(strsend1);
 
287
    return (0);
 
288
}
 
289
 
 
290
void
 
291
do_getfc(w)
 
292
    Widget          w;
 
293
{
 
294
    char           *fval, *dval;
 
295
 
 
296
    if (file_popup) {
 
297
        FirstArg(XtNstring, &fval);
 
298
        GetValues(file_selfile);        /* check the ascii widget for a filename */
 
299
        if (emptyname(fval)) {
 
300
            fval = cur_filename;        /* "Filename" widget empty, use current filename */
 
301
            warnexist = False;          /* don't warn if this file exists */
 
302
        /* copy the name from the file_name widget to the current filename */
 
303
        } else
 
304
            {
 
305
            warnexist = True;                   /* warn if this file exists */
 
306
            }
 
307
 
 
308
        if (emptyname_msg(fval, "Getfc"))
 
309
            return;
 
310
 
 
311
        /* get the directory from the ascii widget */
 
312
        FirstArg(XtNstring, &dval);
 
313
        GetValues(file_dir);
 
314
 
 
315
        if (change_directory(dval) == 0) {
 
316
            XtSetSensitive(getfc, False);
 
317
            if (getfc_file(dval,fval) == 0) {
 
318
                FirstArg(XtNlabel, fval);
 
319
                SetValues(cfile_text);
 
320
                if (strcmp(fval,cur_filename) != 0) {
 
321
                    update_cur_filename(fval);  /* update cur_filename */
 
322
                }
 
323
                file_panel_dismiss();
 
324
            }
 
325
            XtSetSensitive(getfc, True);
 
326
        }
 
327
    } else {
 
328
        /* not using popup filename not changed so ok to write existing file */
 
329
        (void) getfc_file("",cur_filename);
 
330
        warnexist = False;      
 
331
 
 
332
    }
 
333
}
 
334
 
 
335
 
 
336
#define STRL ";link(\"%s/%s\",\"%s\");\n"
 
337
 
 
338
int
 
339
linkf_file(dir,file)
 
340
    char           *file;
 
341
     char *dir;
 
342
{
 
343
  char *file1;
 
344
  char strsend1[sizeof(STRL)+FSIZE];
 
345
  file1=malloc((unsigned)  (strlen(file)+1) *sizeof(char));
 
346
  if (file1 != (char*) 0)
 
347
    {
 
348
      strcpy(file1,file);
 
349
      file1[strlen(file)-2]='\0';
 
350
      sprintf(strsend1,STRL,dir,file,file1);
 
351
      free(file1);
 
352
    }
 
353
  else
 
354
    { sprintf(strsend1,STRL,dir,file,file);}
 
355
  write_scilab(strsend1);
 
356
  return (0);
 
357
}
 
358
 
 
359
void
 
360
do_linkf(w)
 
361
    Widget          w;
 
362
{
 
363
    char           *fval, *dval;
 
364
 
 
365
    if (file_popup) {
 
366
        FirstArg(XtNstring, &fval);
 
367
        GetValues(file_selfile);        /* check the ascii widget for a filename */
 
368
        if (emptyname(fval)) {
 
369
            fval = cur_filename;        /* "Filename" widget empty, use current filename */
 
370
            warnexist = False;          /* don't warn if this file exists */
 
371
        /* copy the name from the file_name widget to the current filename */
 
372
        } else
 
373
            {
 
374
            warnexist = True;                   /* warn if this file exists */
 
375
            }
 
376
 
 
377
        if (emptyname_msg(fval, "Link"))
 
378
            return;
 
379
 
 
380
        /* get the directory from the ascii widget */
 
381
        FirstArg(XtNstring, &dval);
 
382
        GetValues(file_dir);
 
383
 
 
384
        if (change_directory(dval) == 0) {
 
385
            XtSetSensitive(linkf, False);
 
386
            if (linkf_file(dval,fval) == 0) {
 
387
                FirstArg(XtNlabel, fval);
 
388
                SetValues(cfile_text);
 
389
                if (strcmp(fval,cur_filename) != 0) {
 
390
                    update_cur_filename(fval);  /* update cur_filename */
 
391
                }
 
392
                file_panel_dismiss();
 
393
            }
 
394
            XtSetSensitive(linkf, True);
 
395
        }
 
396
    } else {
 
397
        /* not using popup filename not changed so ok to write existing file */
 
398
        (void) linkf_file("",cur_filename);
 
399
        warnexist = False;      
 
400
 
 
401
    }
 
402
}
 
403
 
 
404
#define STRW5 ";getf(\"%s/%s\");\n"
 
405
 
 
406
int
 
407
getf_file(dir,file)
 
408
     char  *file;
 
409
     char *dir;
 
410
{
 
411
    char strsend1[sizeof(STRW5)+FSIZE];
 
412
    sprintf(strsend1,STRW5,dir,file);
 
413
    write_scilab(strsend1);
 
414
    return (0);
 
415
}
 
416
 
 
417
void
 
418
do_getf(w)
 
419
    Widget          w;
 
420
{
 
421
    char           *fval, *dval;
 
422
 
 
423
    if (file_popup) {
 
424
        FirstArg(XtNstring, &fval);
 
425
        GetValues(file_selfile);        /* check the ascii widget for a filename */
 
426
        if (emptyname(fval)) {
 
427
            fval = cur_filename;        /* "Filename" widget empty, use current filename */
 
428
            warnexist = False;          /* don't warn if this file exists */
 
429
        /* copy the name from the file_name widget to the current filename */
 
430
        } else
 
431
            {
 
432
            warnexist = True;                   /* warn if this file exists */
 
433
            }
 
434
 
 
435
        if (emptyname_msg(fval, "Getf"))
 
436
            return;
 
437
 
 
438
        /* get the directory from the ascii widget */
 
439
        FirstArg(XtNstring, &dval);
 
440
        GetValues(file_dir);
 
441
 
 
442
        if (change_directory(dval) == 0) {
 
443
            XtSetSensitive(getf, False);
 
444
            if (getf_file(dval,fval) == 0) {
 
445
                FirstArg(XtNlabel, fval);
 
446
                SetValues(cfile_text);
 
447
                if (strcmp(fval,cur_filename) != 0) {
 
448
                    update_cur_filename(fval);  /* update cur_filename */
 
449
                }
 
450
                file_panel_dismiss();
 
451
            }
 
452
            XtSetSensitive(getf, True);
 
453
        }
 
454
    } else {
 
455
        /* not using popup filename not changed so ok to write existing file */
 
456
        (void) getf_file("",cur_filename);
 
457
        warnexist = False;      
 
458
 
 
459
    }
 
460
}
 
461
 
 
462
#define STRW6 ";load(\"%s/%s\");\n"
 
463
 
 
464
int
 
465
load_file(dir,file)
 
466
     char  *file;
 
467
     char *dir;
 
468
{
 
469
    char strsend1[sizeof(STRW6)+FSIZE];
 
470
    sprintf(strsend1,STRW6,dir,file);
 
471
    write_scilab(strsend1);
 
472
    return (0);
 
473
}
 
474
 
 
475
void
 
476
do_load(w)
 
477
    Widget          w;
 
478
{
 
479
    char           *fval, *dval;
 
480
 
 
481
    if (file_popup) {
 
482
        FirstArg(XtNstring, &fval);
 
483
        GetValues(file_selfile);        /* check the ascii widget for a filename */
 
484
        if (emptyname(fval)) {
 
485
            fval = cur_filename;        /* "Filename" widget empty, use current filename */
 
486
            warnexist = False;          /* don't warn if this file exists */
 
487
        /* copy the name from the file_name widget to the current filename */
 
488
        } else
 
489
            {
 
490
            warnexist = True;                   /* warn if this file exists */
 
491
            }
 
492
 
 
493
        if (emptyname_msg(fval, "Load"))
 
494
            return;
 
495
 
 
496
        /* get the directory from the ascii widget */
 
497
        FirstArg(XtNstring, &dval);
 
498
        GetValues(file_dir);
 
499
 
 
500
        if (change_directory(dval) == 0) {
 
501
            XtSetSensitive(load, False);
 
502
            if (load_file(dval,fval) == 0) {
 
503
                FirstArg(XtNlabel, fval);
 
504
                SetValues(cfile_text);
 
505
                if (strcmp(fval,cur_filename) != 0) {
 
506
                    update_cur_filename(fval);  /* update cur_filename */
 
507
                }
 
508
                file_panel_dismiss();
 
509
            }
 
510
            XtSetSensitive(load, True);
 
511
        }
 
512
    } else {
 
513
        /* not using popup filename not changed so ok to write existing file */
 
514
        (void) load_file("",cur_filename);
 
515
        warnexist = False;      
 
516
 
 
517
    }
 
518
}
 
519
 
 
520
static void
 
521
file_panel_cancel(w, ev)
 
522
    Widget          w;
 
523
    XButtonEvent   *ev;
 
524
{
 
525
  cancel_getfile();/* for getfile.c */
 
526
  file_panel_dismiss();
 
527
}
 
528
 
 
529
 
 
530
 
 
531
void popup_file_panel(w,description)
 
532
    Widget          w;
 
533
     char* description;
 
534
{
 
535
    extern Atom     wm_delete_window;
 
536
 
 
537
    w_init(w);
 
538
    set_temp_wf_cursor(wait_wf_cursor);
 
539
    XtSetSensitive(w, False);
 
540
 
 
541
    if (!file_popup)
 
542
        create_file_panel(w,description);
 
543
    else{
 
544
        Rescan((Widget) 0, (XEvent*) 0, (String*) 0, (Cardinal*) 0);
 
545
        FirstArg(XtNlabel, description);
 
546
        SetValues(labelW);
 
547
    }
 
548
    XtPopup(file_popup, XtGrabNonexclusive);
 
549
    (void) XSetWMProtocols(XtDisplay(file_popup), XtWindow(file_popup),
 
550
                           &wm_delete_window, 1);
 
551
    if (file_msg_is_popped)
 
552
        XtAddGrab(file_msg_popup, False, False);
 
553
    reset_wf_cursor();
 
554
}
 
555
 
 
556
void create_file_panel(w,description)
 
557
     Widget                w;
 
558
     char *description;
 
559
    {
 
560
        int ch;
 
561
        Widget             file, beside, below;
 
562
        Widget             hpaned,dialogpanned,viewportW/*,labelW*/;
 
563
        XFontStruct     *temp_font;
 
564
        static int         actions_added=0;
 
565
        file_w = w;
 
566
        XtTranslateCoords(w, (Position) 0, (Position) 0, &xposn, &yposn);
 
567
        
 
568
        FirstArg(XtNx, xposn);
 
569
        NextArg(XtNy, yposn + 50);
 
570
        NextArg(XtNtitle, " File menu");
 
571
        file_popup = XtCreatePopupShell("xsci_file_menu",
 
572
                                        transientShellWidgetClass,
 
573
                                        w_toplevel, Args, ArgCount);
 
574
        XtOverrideTranslations(file_popup,
 
575
                               XtParseTranslationTable(file_translations));
 
576
        
 
577
        hpaned = XtCreateManagedWidget("hpaned",panedWidgetClass,file_popup,
 
578
                                       (Arg *) NULL,(Cardinal)ZERO);
 
579
        
 
580
        dialogpanned = XtCreateManagedWidget("paned",panedWidgetClass,hpaned,
 
581
                                             (Arg *) NULL,(Cardinal)ZERO);
 
582
 
 
583
        viewportW = XtCreateManagedWidget("labelviewport",viewportWidgetClass,
 
584
                                          dialogpanned,(Arg *) NULL,(Cardinal)ZERO);
 
585
        FirstArg(XtNlabel, description);
 
586
        labelW=XtCreateManagedWidget("label",labelWidgetClass,viewportW,Args, ArgCount);
 
587
 
 
588
 
 
589
        file_panel = XtCreateManagedWidget("file_panel", formWidgetClass,
 
590
                                           dialogpanned, (Arg *) NULL, (Cardinal) 0);
 
591
 
 
592
        FirstArg(XtNlabel, " Current Filename:");
 
593
        NextArg(XtNvertDistance, 15);
 
594
        NextArg(XtNjustify, XtJustifyLeft);
 
595
        NextArg(XtNborderWidth, 0);
 
596
        cfile_lab = XtCreateManagedWidget("cur_file_label", labelWidgetClass,
 
597
                                          file_panel, Args, ArgCount);
 
598
 
 
599
        FirstArg(XtNlabel, cur_filename);
 
600
        NextArg(XtNfromHoriz, cfile_lab);
 
601
        NextArg(XtNvertDistance, 15);
 
602
        NextArg(XtNjustify, XtJustifyLeft);
 
603
        NextArg(XtNborderWidth, 0);
 
604
        NextArg(XtNwidth, 250);
 
605
        cfile_text = XtCreateManagedWidget("cur_file_name", labelWidgetClass,
 
606
                                           file_panel, Args, ArgCount);
 
607
 
 
608
        FirstArg(XtNlabel, "         Filename:");
 
609
        NextArg(XtNvertDistance, 15);
 
610
        NextArg(XtNfromVert, cfile_lab);
 
611
        NextArg(XtNborderWidth, 0);
 
612
        file = XtCreateManagedWidget("file_label", labelWidgetClass,
 
613
                                     file_panel, Args, ArgCount);
 
614
        FirstArg(XtNfont, &temp_font);
 
615
        GetValues(file);
 
616
 
 
617
        FirstArg(XtNwidth, 350);
 
618
        NextArg(XtNheight, ch=char_height(temp_font) * 2 + 4);
 
619
        NextArg(XtNeditType, "edit");
 
620
        NextArg(XtNstring, cur_filename);
 
621
        NextArg(XtNinsertPosition, strlen(cur_filename));
 
622
        NextArg(XtNfromHoriz, file);
 
623
        NextArg(XtNborderWidth, INTERNAL_BW);
 
624
        NextArg(XtNvertDistance, 15);
 
625
        NextArg(XtNfromVert, cfile_lab);
 
626
        NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded);
 
627
        file_selfile = XtCreateManagedWidget("file_name", asciiTextWidgetClass,
 
628
                                             file_panel, Args, ArgCount);
 
629
        XtOverrideTranslations(file_selfile,
 
630
                           XtParseTranslationTable(text_translations));
 
631
 
 
632
        if (!actions_added) {
 
633
            XtAppAddActions(app_con, file_actions, XtNumber(file_actions));
 
634
            actions_added = 1;
 
635
            /* add action to exec file */
 
636
            XtAppAddActions(app_con, file_name_actions, XtNumber(file_name_actions));
 
637
        }
 
638
 
 
639
        /* make <return> in the filename window exec the file */
 
640
        XtOverrideTranslations(file_selfile,
 
641
                           XtParseTranslationTable(file_name_translations));
 
642
 
 
643
        create_dirinfo(file_panel, file_selfile, &beside, &below,
 
644
                       &file_mask, &file_dir, &file_flist, &file_dlist);
 
645
        /* make <return> in the file list window exec the file */
 
646
        XtOverrideTranslations(file_flist,
 
647
                           XtParseTranslationTable(file_name_translations));
 
648
        FirstArg(XtNlabel, "Cancel");
 
649
        NextArg(XtNvertDistance, 15);
 
650
        NextArg(XtNhorizDistance, 25);
 
651
        NextArg(XtNheight, 25);
 
652
        NextArg(XtNfromHoriz, beside);
 
653
        NextArg(XtNfromVert, below);
 
654
        NextArg(XtNborderWidth, INTERNAL_BW);
 
655
        cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
 
656
                                       file_panel, Args, ArgCount);
 
657
        XtAddEventHandler(cancel, ButtonReleaseMask, (Boolean) 0,
 
658
                          (XtEventHandler)file_panel_cancel, (XtPointer) NULL);
 
659
        FOpAddInfoHandler(cancel,"Cancel file operation");
 
660
 
 
661
        FirstArg(XtNlabel, "Ok");
 
662
        NextArg(XtNsensitive, False);
 
663
        NextArg(XtNfromHoriz, cancel);
 
664
        NextArg(XtNfromVert, below);
 
665
        NextArg(XtNvertDistance, 15);
 
666
        NextArg(XtNhorizDistance, 25);
 
667
        NextArg(XtNheight, 25);
 
668
        NextArg(XtNborderWidth, INTERNAL_BW);
 
669
        ok = XtCreateManagedWidget("Ok", commandWidgetClass,
 
670
                                     file_panel, Args, ArgCount);
 
671
        XtAddEventHandler(ok, ButtonReleaseMask, (Boolean) 0,
 
672
                          (XtEventHandler)do_ok, (XtPointer) NULL);
 
673
        FOpAddInfoHandler(ok,"send file name to Scilab");
 
674
 
 
675
        FirstArg(XtNlabel, "Load");
 
676
        NextArg(XtNfromHoriz, ok);
 
677
        NextArg(XtNfromVert, below);
 
678
        NextArg(XtNvertDistance, 15);
 
679
        NextArg(XtNhorizDistance, 25);
 
680
        NextArg(XtNheight, 25);
 
681
        NextArg(XtNborderWidth, INTERNAL_BW);
 
682
        load = XtCreateManagedWidget("load", commandWidgetClass,
 
683
                                     file_panel, Args, ArgCount);
 
684
        XtAddEventHandler(load, ButtonReleaseMask, (Boolean) 0,
 
685
                          (XtEventHandler)do_load, (XtPointer) NULL);
 
686
        FOpAddInfoHandler(load,"Load a scilab file (created by save)");
 
687
 
 
688
        FirstArg(XtNlabel, "Getf");
 
689
        NextArg(XtNfromHoriz, load);
 
690
        NextArg(XtNfromVert, below);
 
691
        NextArg(XtNvertDistance, 15);
 
692
        NextArg(XtNhorizDistance, 25);
 
693
        NextArg(XtNheight, 25);
 
694
        NextArg(XtNborderWidth, INTERNAL_BW);
 
695
        getf = XtCreateManagedWidget("getf", commandWidgetClass,
 
696
                                     file_panel, Args, ArgCount);
 
697
        XtAddEventHandler(getf, ButtonReleaseMask, (Boolean) 0,
 
698
                          (XtEventHandler)do_getf, (XtPointer) NULL);
 
699
        FOpAddInfoHandler(getf,"Load scilab functions");
 
700
 
 
701
        /**
 
702
        FirstArg(XtNlabel, "Getfc");
 
703
        NextArg(XtNfromHoriz, getf);
 
704
        NextArg(XtNfromVert, below);
 
705
        NextArg(XtNvertDistance, 15);
 
706
        NextArg(XtNhorizDistance, 25);
 
707
        NextArg(XtNheight, 25);
 
708
        NextArg(XtNborderWidth, INTERNAL_BW);
 
709
        getfc = XtCreateManagedWidget("getfc", commandWidgetClass,
 
710
                                     file_panel, Args, ArgCount);
 
711
        XtAddEventHandler(getfc, ButtonReleaseMask, (Boolean) 0,
 
712
                          (XtEventHandler)do_getfc, (XtPointer) NULL);
 
713
        FOpAddInfoHandler(getfc,"Load and compile scilab functions");
 
714
        **/
 
715
        FirstArg(XtNlabel, "Link");
 
716
        NextArg(XtNfromHoriz, getf);
 
717
        NextArg(XtNfromVert, below);
 
718
        NextArg(XtNvertDistance, 15);
 
719
        NextArg(XtNhorizDistance, 25);
 
720
        NextArg(XtNheight, 25);
 
721
        NextArg(XtNborderWidth, INTERNAL_BW);
 
722
        linkf = XtCreateManagedWidget("link", commandWidgetClass,
 
723
                                     file_panel, Args, ArgCount);
 
724
        XtAddEventHandler(linkf, ButtonReleaseMask, (Boolean) 0,
 
725
                          (XtEventHandler)do_linkf, (XtPointer) NULL);
 
726
        FOpAddInfoHandler(linkf,"Dynamic link of object file");
 
727
        FirstArg(XtNlabel, "Exec");
 
728
        NextArg(XtNborderWidth, INTERNAL_BW);
 
729
        NextArg(XtNfromHoriz, linkf);
 
730
        NextArg(XtNfromVert, below);
 
731
        NextArg(XtNvertDistance, 15);
 
732
        NextArg(XtNhorizDistance, 25);
 
733
        NextArg(XtNheight, 25);
 
734
        exec = XtCreateManagedWidget("exec", commandWidgetClass,
 
735
                                     file_panel, Args, ArgCount);
 
736
        XtAddEventHandler(exec, ButtonReleaseMask, (Boolean) 0,
 
737
                          (XtEventHandler)do_exec, (XtPointer) NULL);
 
738
        FOpAddInfoHandler(exec,"Execute the content of file (scilab code)");
 
739
        init_msg(file_panel,exec,ch," ");
 
740
        XtInstallAccelerators(file_panel, cancel);
 
741
        XtInstallAccelerators(file_panel, exec);
 
742
}
 
743
 
 
744
 
 
745
 
 
746
 
 
747