File: jpc_xwidgets.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (106 lines) | stat: -rw-r--r-- 2,583 bytes parent folder | download | duplicates (2)
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
104
105
106
/* Copyright (C) 1998 Chancelier Jean-Philippe */
#include <stdio.h>
#include <math.h>
#include "../graphics/Math.h"

#include <X11/Xatom.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>

#include <X11/Xaw3d/AsciiText.h>
#include <X11/Xaw3d/Box.h>
#include <X11/Xaw3d/Command.h>
#include <X11/Xaw3d/Dialog.h>
#include <X11/Xaw3d/Form.h>
#include <X11/Xaw3d/Label.h>
#include <X11/Xaw3d/List.h>
#include <X11/Xaw3d/MenuButton.h>
#include <X11/Xaw3d/SimpleMenu.h>
#include <X11/Xaw3d/SmeBSB.h>
#include <X11/Xaw3d/SmeLine.h>
#include <X11/Xaw3d/Paned.h>
#include <X11/Xaw3d/Toggle.h>
#include <X11/Xaw3d/Viewport.h>
#include <X11/Xaw3d/Cardinals.h>

typedef  struct  {
  char *name;
  void  (*fonc)();} TestOpTab ;

extern TestOpTab GraphicTestTab[];

extern XtAppContext app_con;

/*	Function Name: MenuSelect
 *	Description: called whenever a menu item is selected.
 *	Arguments: w - the menu item that was selected.
 *                 junk, garbage - *** unused ***.
 *	Returns: 
 */

#define streq(a, b)        ( strcmp((a), (b)) == 0 )

/* ARGSUSED */
static void
MenuSelect(w, junk, garbage)
     Widget w;
     XtPointer junk;
     XtPointer garbage;
{
  static int firstentry=0;
  integer i;
  if (firstentry==0) 
    {
      integer verbose=0,ww,narg;
      C2F(SetDriver)("Rec",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
      C2F(dr)("xget","window",&verbose,&ww,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
      C2F(dr)("xset","window",&ww,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
      firstentry++;
    }
  else 
    {
      integer num=0;
      C2F(dr)("xclear","v",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
      C2F(dr)("xstart","v",&num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
    }
  i=0;
  while ( GraphicTestTab[i].name != (char *) NULL)
     {
       if (streq(XtName(w), GraphicTestTab[i].name)) 
	 {
	   (*(GraphicTestTab[i].fonc))();
	 }
       i++;
     }
}



/*
 * AddNewMenu 
 */

void AddNewMenu(parent, drawbox)
     Widget parent;
     Widget drawbox;
{
  Widget button,menu,entry;
  static Arg args[1] ;
  Cardinal n=0;
  int i=0;
  XtSetArg(args[n], XtNfromHoriz,drawbox ); n++;
  button = XtCreateManagedWidget("menuButton", menuButtonWidgetClass, parent,
				 args,n);
  n=0;
  menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, button,args,n);
  while ( GraphicTestTab[i].name != (char *) NULL)
     {
       entry= XtCreateManagedWidget(GraphicTestTab[i].name, smeBSBObjectClass, menu,
				    args, ZERO);
       XtAddCallback(entry,XtNcallback,MenuSelect,(XtPointer) NULL);
       i++;
     }
}