Set svn:eol-style to native
[scilab.git] / scilab / modules / gui / sci_gateway / cpp / sci_setlookandfeel.cpp
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2008 - DIGITEO - Allan CORNET
4  * 
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at    
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 #include "LookAndFeelManager.hxx"
14
15
16 extern "C"
17 {
18 #include "gw_gui.h"
19 #include "stack-c.h"
20 #include "getScilabJavaVM.h"
21 #include "Scierror.h"
22 #include "localization.h"
23 #include "BOOL.h"
24 #include "MALLOC.h"
25 /*--------------------------------------------------------------------------*/
26 int sci_setlookandfeel(char *fname,unsigned long fname_len)
27 {
28         CheckRhs(0,1);
29         CheckLhs(0,1);
30
31         if (Rhs == 0)
32         {
33                 org_scilab_modules_gui_utils::LookAndFeelManager *lnf = new org_scilab_modules_gui_utils::LookAndFeelManager(getScilabJavaVM());
34                 if (lnf)
35                 {
36                         int n1 = 1;
37                         int *paramoutINT=(int*)MALLOC(sizeof(int));
38
39                         *paramoutINT = (int) booltoBOOL(lnf->setSystemLookAndFeel());
40                         delete lnf;
41
42                         n1=1;
43                         CreateVarFromPtr(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1, &n1, &paramoutINT);
44                         LhsVar(1)=Rhs+1;
45
46                         C2F(putlhsvar)();
47
48                         if (paramoutINT) {FREE(paramoutINT);paramoutINT=NULL;}
49                 }
50                 else
51                 {
52                          Scierror(999,_("%s: No more memory.\n"),fname);
53                 }
54         }
55         else if ( GetType(1) == sci_strings )
56         {
57                 int m1,n1=0,l1=0;
58                 
59                 char *looknfeel = NULL;
60                 
61                 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
62                 looknfeel = cstk(l1);
63
64                 org_scilab_modules_gui_utils::LookAndFeelManager *lnf = new org_scilab_modules_gui_utils::LookAndFeelManager(getScilabJavaVM());
65                 if (lnf)
66                 {
67                         int *paramoutINT = (int*)MALLOC(sizeof(int));
68                         *paramoutINT = (int)booltoBOOL(lnf->setLookAndFeel(looknfeel));
69                         delete lnf;
70                 
71                         n1=1;
72                         CreateVarFromPtr(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1, &n1, &paramoutINT);
73                         LhsVar(1)=Rhs+1;
74
75                         C2F(putlhsvar)();
76
77                         if (paramoutINT) {FREE(paramoutINT);paramoutINT=NULL;}
78                 }
79                 else
80                 {
81                         Scierror(999,_("%s: No more memory.\n"),fname);
82                 }
83         }
84         else
85         {
86           Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
87         }
88         return 0;
89 }
90 /*--------------------------------------------------------------------------*/
91
92 }
93 /* END OF extern "C" */
94 /*--------------------------------------------------------------------------*/
95