File: addmenu.xml

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (233 lines) | stat: -rw-r--r-- 6,912 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?xml version="1.0" encoding="UTF-8"?>
<refentry version="5.0-subset Scilab" xml:id="addmenu" xml:lang="en"
          xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg"
          xmlns:ns4="http://www.w3.org/1999/xhtml"
          xmlns:mml="http://www.w3.org/1998/Math/MathML"
          xmlns:db="http://docbook.org/ns/docbook">
  <info>
    <pubdate>$LastChangedDate$</pubdate>
  </info>

  <refnamediv>
    <refname>addmenu</refname>

    <refpurpose>interactive button or menu definition</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <title>Calling Sequence</title>

    <synopsis>addmenu(button [,submenus] [,action])
addmenu(gwin,button [,submenus] [,action])</synopsis>
  </refsynopsisdiv>

  <refsection>
    <title>Parameters</title>

    <variablelist>
      <varlistentry>
        <term>button</term>

        <listitem>
          <para>a character string. The button name. An &amp; can be placed
          before the character in the name to be used for keyboard shortcut;
          this character will be underlined on the GUI. Under MacOSX, a
          sub-menu with the same name is automatically added (no button can be
          added to the menu bar).</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>submenus</term>

        <listitem>
          <para>a vector of character string. The sub_menus items names</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>action</term>

        <listitem>
          <para>a list with 2 elements action=list(flag,proc_name)</para>

          <variablelist>
            <varlistentry>
              <term>flag</term>

              <listitem>
                <para>an integer (default value is 0)</para>
              </listitem>
            </varlistentry>

            <varlistentry>
              <term>flag==0</term>

              <listitem>
                <para>the action is defined by a scilab instruction</para>
              </listitem>
            </varlistentry>

            <varlistentry>
              <term>flag==1</term>

              <listitem>
                <para>the action is defined by a C or Fortran procedure</para>
              </listitem>
            </varlistentry>

            <varlistentry>
              <term>flag==2</term>

              <listitem>
                <para>the action is defined by a scilab function</para>
              </listitem>
            </varlistentry>

            <varlistentry>
              <term>proc_name</term>

              <listitem>
                <para>a character string which gives the name of scilab
                variable containing the instruction or the name of procedure
                to call.</para>
              </listitem>
            </varlistentry>
          </variablelist>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>gwin</term>

        <listitem>
          <para>integer. The number of graphic window where the button is
          required to be installed</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsection>

  <refsection>
    <title>Description</title>

    <para>The function allows the user to add new buttons or menus in the main
    window or graphics windows command panels.</para>

    <variablelist>
      <varlistentry>
        <term>If</term>

        <listitem>
          <para><literal>action</literal> argument is not given the action
          associated with a button must be defined by a scilab instruction
          given by the character string variable which name is</para>

          <para>+ <literal>button</literal> for a main window command</para>

          <para>+ <literal>button_gwin</literal> for a graphic window
          command</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>If</term>

        <listitem>
          <para><literal>action</literal> argument is set to 0
          <literal>proc_name</literal> should be the name of a Scilab string
          vector. Actions associated with the kth sub_menu must be defined by
          scilab instructions stored in the kth element of the character
          string variable.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>If</term>

        <listitem>
          <para><literal>action</literal> argument is set to 1
          <literal>proc_name</literal> designes a C or Fortran procedure, this
          procedure may be interfaced in Fortran subroutine default/fbutn.f or
          dynamically linked with scilab using the <literal>link</literal>
          function. The C calling sequence is: <literal>(char* button_name,
          int* gwin,int *k)</literal></para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>If</term>

        <listitem>
          <para><literal>action</literal> argument is set to 2
          <literal>proc_name</literal> designes a Scilab function. This
          function calling sequence should be:</para>

          <para>+ <literal>proc_name(k)</literal>for a main window
          command</para>

          <para>+ <literal>proc_name(k,gwin)</literal>for a graphic window
          command or a main window command</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsection>

  <refsection>
    <title>Examples</title>

    <programlisting role="example">if (getscilabmode() == "STD") then
  addmenu('foo');
  foo = 'disp(''hello'')';

  addmenu('Hello',['Franck';'Peter'])
  Hello = ['disp(''hello Franck'')';'disp(''hello Peter'')'];

  addmenu('Bye',list(0,'French_Bye'));
  French_Bye = 'disp(''Au revoir'')';
else
  mprintf('This example requires to use scilab with GUI mode.\n');
end

addmenu(0,'Hello',['Franck';'Peter']);
Hello_0 = ['disp(''hello Franck'')';'disp(''hello Peter'')'];

//C defined Callback
// creating Callback code
code=[ '#include ""machine.h""'
       '#include ""sciprint.h""'
       'void foo(char *name, int *win, int *entry)'
       '{'
       '  if (*win==-1) '
       '    sciprint(""menu %s(%i) in Scilab window selected.\n"", name, *entry+1);'
       '  else'
       '    sciprint(""menu %s(%i) in window %i selected.\n"", name, *entry+1, *win);'
       '}'];
//creating foo.c file
current_dir = pwd();
chdir(TMPDIR);
mputl(code, TMPDIR+'/foo.c');
//creating Makefile
ilib_for_link('foo','foo.c',[],'c');
exec('loader.sce');
chdir(current_dir);
//add menu
addmenu(0,'foo',['a','b','c'],list(1,'foo'));

 </programlisting>
  </refsection>

  <refsection>
    <title>See Also</title>

    <simplelist type="inline">
      <member><link linkend="setmenu">setmenu</link></member>

      <member><link linkend="unsetmenu">unsetmenu</link></member>

      <member><link linkend="delmenu">delmenu</link></member>
    </simplelist>
  </refsection>
</refentry>