File: LAB_uicontrol.c

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (167 lines) | stat: -rw-r--r-- 2,698 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* Copyright INRIA */
/* UI generator main routine */
/* Bertrand Guiheneuf, INRIA 1997 */


#include "C-LAB_Interf.h"


#include <math.h>
#include <stdio.h>

#include "tksci.h"
#include "TK_uicontrol.h"



void LAB_uicontrol()


{


  Matrix **MVars;
  
  int NbParam;
  int NbChamps;
  
  int found=0;
  int i;
  
  char *tmpstr;
  int Style=0; /* Default type is pushbutton */
  char *StyleStr=NULL;


  char MyCommand[2000];
  char *StrHandle;
  int Handle;

  Matrix *Mfield;
  Matrix *Mvalue;
  
  Matrix *MOutputHandle;
  double *OutputHandle;

  int FirstField=0;
  int FigureHandle=0;
  
  NbParam = Interf.NbParamIn;


 if ( (NbParam >0) && MatrixIsScalar(Interf.Param[0]) && MatrixIsReal(Interf.Param[0]) )
    /* the first parameter is a figure handle */
    {
      FigureHandle = (int)(floor( MatrixGetScalar(Interf.Param[0]) ) );
      FirstField = 1;
    }

  /* Search for a "Style" field */  
  for (i=FirstField; ( (i<NbParam) && !(found) ); i++)
    {
      if (MatrixIsString(Interf.Param[i]))
	{
	  tmpstr=MatrixReadString(Interf.Param[i]);
	  nocase(tmpstr);
	  found = !strcmp(tmpstr,"style");
	  free(tmpstr);
	}
    }

  if (found)
    {
      if ( !(i<NbParam) )
	{
	  InterfError("uicontrol : you must specify a Style value after \"Style\"\n");
	  return;
	}
      else
	{
	  if (!MatrixIsString(Interf.Param[i]))
	    {
	      InterfError("uicontrol : you must specify a string value after \"Style\"\n");
	      return;
	    }
	  else
	    {
	      /* OK this time, It's a string after "Style" */
	      StyleStr = MatrixReadString(Interf.Param[i]);
	      nocase(StyleStr);
	      
	    }

	}

    }


if (StyleStr) 
{
  Style=GetStyle(StyleStr);
  free(StyleStr);
}
else Style=0;

if (Style==-1) 
  {
    InterfError("uicontrol : the specified style does not exist\n");
    return;
  } 



sprintf(MyCommand, "set MyTmpBertrand [CreateUIControl %d %s];", FigureHandle, UiStyleName[Style]); 

Tcl_Eval(TKinterp,MyCommand);
StrHandle = Tcl_GetVar(TKinterp, "MyTmpBertrand", 0);
Handle = (int)atoi(StrHandle);

/* Now let's set all propoerties for the uicontrol */
for (i=FirstField; i<NbParam; i++)
  {
    Mfield = Interf.Param[i];
    if (MatrixIsString(Interf.Param[i]))
      {
	if (++i==NbParam)
	  {
	    InterfError("uicontrol :The last value is missing \n");
	    return;
	  } 
	
	else Mvalue = Interf.Param[i];
      }
    else
      {
	InterfError("uicontrol : incorrect syntax.\n");
	return;
      }

    /* (*UiSet[Style])(Mfield, Mvalue); */
    TK_UiSet(Handle, Mfield, Mvalue);
  
  }


MOutputHandle = MatrixCreate(1,1,"real");
OutputHandle = (double *)MatrixGetPr(MOutputHandle);
*OutputHandle = Handle;

ReturnParam(MOutputHandle);



}