convert figure macro to gateway
[scilab.git] / scilab / modules / gui / sci_gateway / c / gw_gui.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2006 - INRIA - Allan CORNET
4  * Copyright (C) 2008 - INRIA - Vincent COUVERT
5  *
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at
10  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11  *
12  */
13
14 #include <string.h>
15 #include "gw_gui.h"
16 #include "api_scilab.h"
17 #include "MALLOC.h"
18 #include "scilabmode.h"
19 #include "callFunctionFromGateway.h"
20 #include "localization.h"
21 #include "Scierror.h"
22 #include "loadOnUseClassPath.h"
23 /*--------------------------------------------------------------------------*/
24 static BOOL loadedDep = FALSE;
25 /*--------------------------------------------------------------------------*/
26 static gw_generic_table Tab[] =
27 {
28     {sci_x_dialog, "x_dialog"},
29     {sci_x_choose, "x_choose"},
30     {sci_x_mdialog, "x_mdialog"},
31     {sci_x_choice, "xchoicesi"},
32     {sci_delmenu, "delmenu"},
33     {sci_setmenu, "setmenu"},
34     {sci_unsetmenu, "unsetmenu"},
35     {sci_raise_window, "raise_window"},
36     {sci_getlookandfeel, "getlookandfeel"},
37     {sci_getinstalledlookandfeels, "getinstalledlookandfeels"},
38     {sci_setlookandfeel, "setlookandfeel"},
39     {sci_ClipBoard, "ClipBoard"},
40     {sci_toolbar, "toolbar"},
41     {sci_uigetdir, "uigetdir"},
42     {sci_uicontrol, "uicontrol"},
43     {sci_uimenu, "uimenu"},
44     {sci_mpopup, "uipopup"},
45     {sci_x_choose_modeless, "x_choose_modeless"},
46     {sci_uicontextmenu, "uicontextmenu"},
47     {sci_uiwait, "uiwait"},
48     {sci_messagebox, "messagebox"},
49     {sci_waitbar, "waitbar"},
50     {sci_progressionbar, "progressionbar"},
51     {sci_helpbrowser, "helpbrowser"},
52     {sci_uigetfont, "uigetfont"},
53     {sci_uigetcolor, "uigetcolor"},
54     {sci_getcallbackobject, "getcallbackobject"},
55     {sci_printfigure, "printfigure"},
56     {sci_exportUI, "exportUI"},
57     {sci_printsetupbox, "printsetupbox"},
58     {sci_toprint, "toprint"},
59     {sci_uigetfile, "uigetfile"},
60     {sci_usecanvas, "usecanvas"},
61     {sci_displaytree, "uiDisplayTree"},
62     {sci_uiputfile, "uiputfile"},
63     {sci_about, "about"},
64     {sci_useeditor, "useeditor"},
65     {sci_fire_closing_finished, "fire_closing_finished"},
66     {sci_openged, "openged"},
67     {sci_datatipcreate, "datatipCreate"},
68     {sci_datatipremove, "datatipRemove"},
69     {sci_plotbrowser, "plotbrowser"},
70     {sci_datatip_manager_mode, "datatipManagerMode"},
71     {sci_datatip_toggle, "datatipToggle"},
72     {sci_datatipmove, "datatipMove"},
73     {sci_datatip_set_style, "datatipSetStyle"},
74     {sci_datatip_set_display, "datatipSetDisplay"},
75     {sci_datatip_set_interp, "datatipSetInterp"},
76     {sci_datatip_set_orient, "datatipSetOrientation"},
77     {sci_figure, "figure"}
78 };
79 /*--------------------------------------------------------------------------*/
80 int gw_gui(void)
81 {
82     Rhs = Max(0, Rhs);
83
84     if ( getScilabMode() == SCILAB_NWNI)
85     {
86         Scierror(999, _("Scilab '%s' module disabled in -nogui or -nwni mode.\n"), "GUI");
87         return 0;
88     }
89
90     /**
91      * We have to load the 'graphic' jars for
92      * - uicontrol
93      * - uimenu
94      * because these functions need to create a figure to put the created object inside.
95      *
96      * **** TODO create Scilab figures without a canvas inside and remove this crappy test. ****
97      *
98      */
99     if (!loadedDep && (strcmp(Tab[Fin - 1].name, "uicontrol") == 0
100                        || strcmp(Tab[Fin - 1].name, "uimenu") == 0
101                        || strcmp(Tab[Fin - 1].name, "usecanvas") == 0
102                        || strcmp(Tab[Fin - 1].name, "figure") == 0))
103     {
104         loadOnUseClassPath("graphics");
105         loadedDep = TRUE;
106     }
107
108
109     if (pvApiCtx == NULL)
110     {
111         pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
112     }
113
114     pvApiCtx->pstName = (char*)Tab[Fin - 1].name;
115     callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
116
117     return 0;
118 }
119 /*--------------------------------------------------------------------------*/