File: message.c

package info (click to toggle)
scilab 2.2-4
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 31,472 kB
  • ctags: 21,963
  • sloc: fortran: 110,983; ansic: 89,717; makefile: 3,016; sh: 1,892; csh: 150; cpp: 101
file content (103 lines) | stat: -rw-r--r-- 2,123 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "scilab_d.h"

#define OK 1
#define CANCEL 2

extern int ok_Flag_sci;

extern void ShellFormCreate();
static void MessageOk();
static void MessageCancel();
void ExposeMessageWindow();

/* main function called from scilab */

void C2F(xmsg)(basstrings,nstring,ptrstrings,btn,ptrbtn,nb,nrep,ierr)
int *basstrings,*nstring,*ptrstrings,*btn,*nb,*ptrbtn,*nrep,*ierr;
{
  int i;
  char *strings, **buttonname;
  *ierr=0;
  ScilabMStr2C(basstrings,nstring,ptrstrings,&strings,ierr);
  if ( *ierr == 1) return;
  ScilabMStr2CM(btn,nb,ptrbtn,&buttonname,ierr);
  if ( *ierr == 1) return;
  ExposeMessageWindow(strings,nstring,buttonname,nb);
  FREE(strings);
  for (i=0 ; i < *nb ; i++ )FREE(buttonname[i]);
  FREE( buttonname);
  *nrep=ok_Flag_sci;
}

/*test function */

TestMessage()
{
  static String description = "Message \ntest";
  static String buttonname[] = {
        "Label1",
	"Label2",
	NULL
    };
  static nstrings=1; /* unused */
  static nbut=2;
  ExposeMessageWindow(description,&nstrings,buttonname,&nbut);
}



static 
void MessageOk(w,shell,callData)
     Widget w;
     caddr_t shell;
     caddr_t callData;
{
  ok_Flag_sci = OK;
}

static 
void MessageCancel(w,shell,callData)
     Widget w;
     caddr_t shell;
     caddr_t callData;
{
  ok_Flag_sci = CANCEL;
}

void ExposeMessageWindow(string,nstring,buttonname,nbutton)
     char *string;
     int *nstring;
     int *nbutton;
     char **buttonname;
{
  Arg args[10];
  Cardinal iargs = 0;
  Widget shell,dialog,mpanned,mviewport,okbutton,cancelbutton,cform;
  static Display *dpy = (Display *) NULL;

  ShellFormCreate("messageShell",&shell,&mpanned,&dpy);

  /* Create a Viewport+Label and resize it */
  ViewpLabelCreate(mpanned,&dialog,&mviewport,string);
  /* The buttons */

  iargs=0;
  cform = XtCreateManagedWidget("cform",formWidgetClass,mpanned,args,iargs);

  ButtonCreate(cform,&okbutton,(XtCallbackProc)MessageOk,(XtPointer) NULL,buttonname[0],"ok");
  if ( *nbutton == 2) 
    {
      ButtonCreate(cform,&cancelbutton,(XtCallbackProc)MessageCancel,(XtPointer) NULL,buttonname[1],"cancel");
    }
  XtMyLoop(shell,dpy);
}