add property layout_options in figure and uicontrol handles 40/13540/4
Antoine ELIAS [Sat, 25 Jan 2014 17:43:34 +0000 (18:43 +0100)]
Change-Id: I6b85f89dffa45ce523dc744f0e3faa0800ad1cbc

56 files changed:
scilab/modules/graphic_objects/Makefile.am
scilab/modules/graphic_objects/Makefile.in
scilab/modules/graphic_objects/includes/createGraphicObject.h
scilab/modules/graphic_objects/includes/graphicObjectProperties.h
scilab/modules/graphic_objects/src/c/graphic_objects.vcxproj
scilab/modules/graphic_objects/src/c/graphic_objects.vcxproj.filters
scilab/modules/graphic_objects/src/cpp/createGraphicObject.cpp
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/CallXmlLoader.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/figure/Figure.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObjectProperties.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/uicontrol/Uicontrol.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/utils/LayoutType.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParserException.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/GOBuilder.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlLoader.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlTools.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/jni/CallXmlLoader.cpp [new file with mode: 0644]
scilab/modules/graphic_objects/src/jni/CallXmlLoader.hxx [new file with mode: 0644]
scilab/modules/graphic_objects/src/jni/graphic_objects.giws.xml
scilab/modules/graphic_objects/src/scripts/propertiesMap.properties
scilab/modules/graphics/Makefile.am
scilab/modules/graphics/Makefile.in
scilab/modules/graphics/graphics.vcxproj
scilab/modules/graphics/graphics.vcxproj.filters
scilab/modules/graphics/macros/%BorderCo_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%GridBagC_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%GridCons_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%GridCons_p.sci
scilab/modules/graphics/macros/%NoLayout_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%NoLayout_p.sci
scilab/modules/graphics/macros/%OptBorde_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%OptBorde_p.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%OptGridB_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%OptGridB_p.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%OptGrid_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%OptGrid_p.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%OptNoLay_i_h.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%OptNoLay_p.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_p.sci
scilab/modules/graphics/macros/createConstraints.sci
scilab/modules/graphics/macros/createLayoutOptions.sci [new file with mode: 0644]
scilab/modules/graphics/src/c/getHandleProperty/BarType.h
scilab/modules/graphics/src/c/getHandleProperty/GetHashTable.c
scilab/modules/graphics/src/c/getHandleProperty/SetHashTable.c
scilab/modules/graphics/src/c/getHandleProperty/getHandleProperty.h
scilab/modules/graphics/src/c/getHandleProperty/get_constraints_property.c
scilab/modules/graphics/src/c/getHandleProperty/get_layout_options_property.c [new file with mode: 0644]
scilab/modules/graphics/src/c/getHandleProperty/get_layout_property.c
scilab/modules/graphics/src/c/getHandleProperty/get_rect_property.c
scilab/modules/graphics/src/c/getHandleProperty/setHandleProperty.h
scilab/modules/graphics/src/c/getHandleProperty/set_constraints_property.c
scilab/modules/graphics/src/c/getHandleProperty/set_layout_options_property.c [new file with mode: 0644]
scilab/modules/graphics/tests/unit_tests/layout.dia.ref
scilab/modules/graphics/tests/unit_tests/layout.tst
scilab/modules/gui/sci_gateway/c/sci_uicontrol.c

index c550e5e..feeada0 100644 (file)
@@ -31,13 +31,14 @@ BUILT_SOURCES =     includes/graphicObjectsProperties.h
 
 GRAPHIC_OBJECTS_JNI_SOURCES = src/jni/CallGraphicController.cpp \
                               src/jni/GraphicObjectBuilder.cpp \
-                              src/jni/Builder.cpp                              
+                              src/jni/Builder.cpp \
+                              src/jni/CallXmlLoader.cpp                              
 
 GRAPHIC_OBJECTS_C_SOURCES = src/jni/DataLoader_wrap.c \
                                                        src/jni/ScilabNativeView_wrap.c \
                                                        src/jni/PolylineData_wrap.c \
                                                        src/jni/SurfaceData_wrap.c \
-                                                        src/jni/ObjectData_wrap.c
+                            src/jni/ObjectData_wrap.c
 
 GRAPHIC_OBJECTS_CXX_SOURCES =  src/cpp/createGraphicObject.cpp \
                                                                src/cpp/getGraphicObjectProperty.cpp \
index 973a99f..ef43140 100644 (file)
@@ -190,7 +190,8 @@ am__objects_2 = src/jni/libscigraphic_objects_la-DataLoader_wrap.lo \
 am__objects_3 =  \
        src/jni/libscigraphic_objects_la-CallGraphicController.lo \
        src/jni/libscigraphic_objects_la-GraphicObjectBuilder.lo \
-       src/jni/libscigraphic_objects_la-Builder.lo
+       src/jni/libscigraphic_objects_la-Builder.lo \
+       src/jni/libscigraphic_objects_la-CallXmlLoader.lo
 am__objects_4 =  \
        src/cpp/libscigraphic_objects_la-createGraphicObject.lo \
        src/cpp/libscigraphic_objects_la-getGraphicObjectProperty.lo \
@@ -687,13 +688,14 @@ BUILT_SOURCES = includes/graphicObjectsProperties.h $(am__append_2) \
 #src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObjectProperties.java
 GRAPHIC_OBJECTS_JNI_SOURCES = src/jni/CallGraphicController.cpp \
                               src/jni/GraphicObjectBuilder.cpp \
-                              src/jni/Builder.cpp                              
+                              src/jni/Builder.cpp \
+                              src/jni/CallXmlLoader.cpp                              
 
 GRAPHIC_OBJECTS_C_SOURCES = src/jni/DataLoader_wrap.c \
                                                        src/jni/ScilabNativeView_wrap.c \
                                                        src/jni/PolylineData_wrap.c \
                                                        src/jni/SurfaceData_wrap.c \
-                                                        src/jni/ObjectData_wrap.c
+                            src/jni/ObjectData_wrap.c
 
 GRAPHIC_OBJECTS_CXX_SOURCES = src/cpp/createGraphicObject.cpp \
                                                                src/cpp/getGraphicObjectProperty.cpp \
@@ -885,6 +887,8 @@ src/jni/libscigraphic_objects_la-GraphicObjectBuilder.lo:  \
        src/jni/$(am__dirstamp) src/jni/$(DEPDIR)/$(am__dirstamp)
 src/jni/libscigraphic_objects_la-Builder.lo: src/jni/$(am__dirstamp) \
        src/jni/$(DEPDIR)/$(am__dirstamp)
+src/jni/libscigraphic_objects_la-CallXmlLoader.lo:  \
+       src/jni/$(am__dirstamp) src/jni/$(DEPDIR)/$(am__dirstamp)
 src/cpp/$(am__dirstamp):
        @$(MKDIR_P) src/cpp
        @: > src/cpp/$(am__dirstamp)
@@ -1026,6 +1030,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-setGraphicObjectProperty.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_objects_la-Builder.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_objects_la-CallGraphicController.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_objects_la-CallXmlLoader.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_objects_la-DataLoader_wrap.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_objects_la-GraphicObjectBuilder.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_objects_la-ObjectData_wrap.Plo@am__quote@
@@ -1145,6 +1150,13 @@ src/jni/libscigraphic_objects_la-Builder.lo: src/jni/Builder.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/jni/libscigraphic_objects_la-Builder.lo `test -f 'src/jni/Builder.cpp' || echo '$(srcdir)/'`src/jni/Builder.cpp
 
+src/jni/libscigraphic_objects_la-CallXmlLoader.lo: src/jni/CallXmlLoader.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/jni/libscigraphic_objects_la-CallXmlLoader.lo -MD -MP -MF src/jni/$(DEPDIR)/libscigraphic_objects_la-CallXmlLoader.Tpo -c -o src/jni/libscigraphic_objects_la-CallXmlLoader.lo `test -f 'src/jni/CallXmlLoader.cpp' || echo '$(srcdir)/'`src/jni/CallXmlLoader.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/jni/$(DEPDIR)/libscigraphic_objects_la-CallXmlLoader.Tpo src/jni/$(DEPDIR)/libscigraphic_objects_la-CallXmlLoader.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/jni/CallXmlLoader.cpp' object='src/jni/libscigraphic_objects_la-CallXmlLoader.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/jni/libscigraphic_objects_la-CallXmlLoader.lo `test -f 'src/jni/CallXmlLoader.cpp' || echo '$(srcdir)/'`src/jni/CallXmlLoader.cpp
+
 src/cpp/libscigraphic_objects_la-createGraphicObject.lo: src/cpp/createGraphicObject.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscigraphic_objects_la-createGraphicObject.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscigraphic_objects_la-createGraphicObject.Tpo -c -o src/cpp/libscigraphic_objects_la-createGraphicObject.lo `test -f 'src/cpp/createGraphicObject.cpp' || echo '$(srcdir)/'`src/cpp/createGraphicObject.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscigraphic_objects_la-createGraphicObject.Tpo src/cpp/$(DEPDIR)/libscigraphic_objects_la-createGraphicObject.Plo
index eda5468..488a987 100644 (file)
@@ -70,4 +70,5 @@ GRAPHIC_OBJECTS_IMPEXP int createLight(int parent, int type, BOOL visible, doubl
 GRAPHIC_OBJECTS_IMPEXP void initSubWinTo3d(int subwin, char* legend, int* flag, double alpha, double theta,
         double* ebox, double* x, int xSize, double* y, int ySize, double* z, int zSize);
 
+GRAPHIC_OBJECTS_IMPEXP int xmlload(char* xmlfile);
 #endif /* !__CREATEGRAPHICOBJECT_H__ */
index 0273a9c..d466f53 100755 (executable)
 #define __GO_UI_GRIDBAG_FILL__ 345
 #define __GO_UI_GRIDBAG_ANCHOR__ 346
 #define __GO_UI_GRIDBAG_PADDING__ 347
-#define __GO_UI_GRID_GRID__ 348
-#define __GO_UI_GRID_PADDING__ 349
 #define __GO_UI_BORDER_POSITION__ 350
+#define __GO_GRID_OPT_GRID__ 351
+#define __GO_GRID_OPT_PADDING__ 352
+#define __GO_BORDER_OPT_PADDING__ 353
 
 #endif /* !__GRAPHIC_OBJECT_PROPERTIES_H__ */
index cb33659..af73a85 100644 (file)
     <ClCompile Include="..\cpp\createGraphicObject.cpp" />
     <ClCompile Include="..\cpp\Data3D.cpp" />
     <ClCompile Include="..\cpp\DataLoader.cpp" />
+    <ClCompile Include="..\jni\CallXmlLoader.cpp" />
     <ClCompile Include="..\jni\DataLoader_wrap.c" />
     <ClCompile Include="..\cpp\dataModel.cpp" />
     <ClCompile Include="..\cpp\DecompositionUtils.cpp" />
     <ClInclude Include="..\..\includes\PolylineDecomposer.hxx" />
     <ClInclude Include="..\..\includes\TriangleMeshData.hxx" />
     <ClInclude Include="..\..\includes\TriangleMeshFecDataDecomposer.hxx" />
+    <ClInclude Include="..\jni\CallXmlLoader.hxx" />
     <ClInclude Include="..\jni\GraphicObjectBuilder.hxx" />
   </ItemGroup>
   <ItemGroup>
index 1e1c1f4..9b21fff 100644 (file)
     <ClCompile Include="..\jni\Builder.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\jni\CallXmlLoader.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\jni\CallGraphicController.hxx">
     <ClInclude Include="..\jni\Builder.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\jni\CallXmlLoader.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="core_import.def">
index 3793997..0f5673b 100644 (file)
@@ -17,6 +17,7 @@ extern "C"
 }
 
 #include "CallGraphicController.hxx"
+#include "CallXmlLoader.hxx"
 #include "Builder.hxx"
 #include "DataController.hxx"
 
@@ -189,3 +190,8 @@ int createLight(int parent, int type, BOOL visible, double* pos, double* dir, do
                                 diffuse, diffuse == NULL ? 0 : 3,
                                 specular, specular == NULL ? 0 : 3);
 }
+
+int xmlload(char* xmlfile)
+{
+    return CallXmlLoader::Load(getScilabJavaVM(), xmlfile);
+}
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/CallXmlLoader.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/CallXmlLoader.java
new file mode 100644 (file)
index 0000000..65037b3
--- /dev/null
@@ -0,0 +1,19 @@
+package org.scilab.modules.graphic_objects;
+
+import org.scilab.modules.graphic_objects.xmlloader.XmlLoader;
+import org.xml.sax.SAXException;
+
+public class CallXmlLoader {
+
+    public static int Load(String xmlFile) {
+        XmlLoader loader = new XmlLoader(xmlFile);
+        try {
+            return loader.parse();
+        } catch (SAXException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        return 0;
+    }
+}
index b4ca15d..4629513 100644 (file)
@@ -16,12 +16,15 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AUTORESIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES_SIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BACKGROUND__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CLOSEREQUESTFCN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_COLORMAP_SIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_COLORMAP__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DOCKABLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_EVENTHANDLER_ENABLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_EVENTHANDLER_NAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_GRID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_ID__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFOBAR_VISIBLE__;
@@ -57,7 +60,8 @@ public class Figure extends GraphicObject {
     private enum FigureProperty {
         INFOMESSAGE, COLORMAP, COLORMAPSIZE, BACKGROUND, ROTATIONTYPE,
         RESIZEFCN, CLOSEREQUESTFCN, RESIZE, TOOLBAR, TOOLBAR_VISIBLE,
-        MENUBAR, MENUBAR_VISIBLE, INFOBAR_VISIBLE, DOCKABLE, LAYOUT, LAYOUT_SET
+        MENUBAR, MENUBAR_VISIBLE, INFOBAR_VISIBLE, DOCKABLE, LAYOUT, LAYOUT_SET,
+        GRIDOPT_GRID, GRIDOPT_PADDING, BORDEROPT_PADDING
     };
 
     /** Specifies whether rotation applies to a single subwindow or to all the figure's subwindows */
@@ -393,6 +397,11 @@ public class Figure extends GraphicObject {
     /** layout */
     private LayoutType layout;
 
+    /** layout options */
+    private Integer[] gridOptGrid = new Integer[2];
+    private Integer[] gridOptPadding = new Integer[2];
+    private Integer[] borderOptPadding = new Integer[2];
+
     /** Constructor */
     public Figure() {
         super();
@@ -505,6 +514,12 @@ public class Figure extends GraphicObject {
                 return FigureProperty.LAYOUT;
             case __GO_LAYOUT_SET__ :
                 return FigureProperty.LAYOUT_SET;
+            case __GO_GRID_OPT_GRID__ :
+                return FigureProperty.GRIDOPT_GRID;
+            case __GO_GRID_OPT_PADDING__ :
+                return FigureProperty.GRIDOPT_PADDING;
+            case __GO_BORDER_OPT_PADDING__ :
+                return FigureProperty.BORDEROPT_PADDING;
             default :
                 return super.getPropertyFromName(propertyName);
         }
@@ -574,6 +589,12 @@ public class Figure extends GraphicObject {
             return getLayout();
         } else if (property == FigureProperty.LAYOUT_SET) {
             return isLayoutSettable();
+        } else if (property == FigureProperty.GRIDOPT_GRID) {
+            return getGridOptGrid();
+        } else if (property == FigureProperty.GRIDOPT_PADDING) {
+            return getGridOptPadding();
+        } else if (property == FigureProperty.BORDEROPT_PADDING) {
+            return getBorderOptPadding();
         } else {
             return super.getProperty(property);
         }
@@ -618,6 +639,12 @@ public class Figure extends GraphicObject {
                     return setDockable((Boolean) value);
                 case LAYOUT:
                     return setLayout((Integer) value);
+                case GRIDOPT_GRID:
+                    return setGridOptGrid((Integer[]) value);
+                case GRIDOPT_PADDING:
+                    return setGridOptPadding((Integer[]) value);
+                case BORDEROPT_PADDING:
+                    return setBorderOptPadding((Integer[]) value);
                 default:
                     break;
             }
@@ -748,6 +775,7 @@ public class Figure extends GraphicObject {
      * @return the axes size
      */
     public Integer[] getAxesSize() {
+        //System.out.println("getAxesSize : (" + canvas.axesSize[0] + "," + canvas.axesSize[1] + ")");
         Integer[] retAxesSize = new Integer[2];
 
         retAxesSize[0] = canvas.axesSize[0];
@@ -760,6 +788,7 @@ public class Figure extends GraphicObject {
      * @param axesSize the axes size to set
      */
     public UpdateStatus setAxesSize(Integer[] axesSize) {
+        //System.out.println("setAxesSize : (" + axesSize[0] + "," + axesSize[1] + ")");
         if (Arrays.equals(canvas.axesSize, axesSize)) {
             //must return Success to broadcast information
             return UpdateStatus.Success;
@@ -823,6 +852,7 @@ public class Figure extends GraphicObject {
      * @return the figure size
      */
     public Integer[] getSize() {
+        //System.out.println("getSize : (" + dimensions.size[0] + "," + dimensions.size[1] + ")");
         Integer[] retSize = new Integer[2];
 
         retSize[0] = dimensions.size[0];
@@ -835,6 +865,7 @@ public class Figure extends GraphicObject {
      * @param size the size to set
      */
     public UpdateStatus setSize(Integer[] size) {
+        //System.out.println("setSize : (" + size[0] + "," + size[1] + ")");
         if (Arrays.equals(dimensions.size, size)) {
             return UpdateStatus.NoChange;
         }
@@ -1291,6 +1322,67 @@ public class Figure extends GraphicObject {
         return UpdateStatus.Fail;
     }
 
+    public Integer[] getBorderOptPadding() {
+        return borderOptPadding;
+    }
+
+    public UpdateStatus setBorderOptPadding(Integer[] value) {
+        UpdateStatus status = UpdateStatus.NoChange;
+        if (borderOptPadding.length != value.length) {
+            return UpdateStatus.Fail;
+        }
+
+        for (int i = 0 ; i < value.length ; i++) {
+            if (borderOptPadding[i] != value[i]) {
+                borderOptPadding[i] = value[i];
+                status = UpdateStatus.Success;
+            }
+        }
+
+        return status;
+    }
+
+    public Integer[] getGridOptPadding() {
+        return gridOptPadding;
+    }
+
+    public UpdateStatus setGridOptPadding(Integer[] value) {
+        UpdateStatus status = UpdateStatus.NoChange;
+        if (gridOptPadding.length != value.length) {
+            return UpdateStatus.Fail;
+        }
+
+        for (int i = 0 ; i < value.length ; i++) {
+            if (gridOptPadding[i] != value[i]) {
+                gridOptPadding[i] = value[i];
+                status = UpdateStatus.Success;
+            }
+        }
+
+        return status;
+    }
+
+    public Integer[] getGridOptGrid() {
+        return gridOptGrid;
+    }
+
+    public UpdateStatus setGridOptGrid(Integer[] value) {
+        UpdateStatus status = UpdateStatus.NoChange;
+        if (gridOptGrid.length != value.length) {
+            return UpdateStatus.Fail;
+        }
+
+        for (int i = 0 ; i < value.length ; i++) {
+            if (gridOptGrid[i] != value[i]) {
+                gridOptGrid[i] = value[i];
+                status = UpdateStatus.Success;
+            }
+        }
+
+        return status;
+    }
+
+
     /**
      * @return Type as String
      */
index 6bc27e0..39a674f 100755 (executable)
@@ -368,8 +368,9 @@ public class GraphicObjectProperties {
     public static final int __GO_UI_GRIDBAG_FILL__ = 345;
     public static final int __GO_UI_GRIDBAG_ANCHOR__ = 346;
     public static final int __GO_UI_GRIDBAG_PADDING__ = 347;
-    public static final int __GO_UI_GRID_GRID__ = 348;
-    public static final int __GO_UI_GRID_PADDING__ = 349;
     public static final int __GO_UI_BORDER_POSITION__ = 350;
+    public static final int __GO_GRID_OPT_GRID__ = 351;
+    public static final int __GO_GRID_OPT_PADDING__ = 352;
+    public static final int __GO_BORDER_OPT_PADDING__ = 353;
 
 }
index 575cae1..2cd75ba 100644 (file)
@@ -36,8 +36,6 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_GRID__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_WEIGHT__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRID_GRID__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRID_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_HORIZONTALALIGNMENT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_IMAGE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LISTBOXTOP_SIZE__;
@@ -64,6 +62,9 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VALUE_SIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VALUE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VERTICALALIGNMENT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_GRID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_PADDING__;
 
 import java.util.Arrays;
 import java.util.StringTokenizer;
@@ -72,6 +73,8 @@ import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
 import org.scilab.modules.graphic_objects.graphicObject.Visitor;
 import org.scilab.modules.graphic_objects.utils.LayoutType;
 
+import sun.font.EAttribute;
+
 /**
  * @author Bruno JOFRET
  * @author Vincent COUVERT
@@ -95,6 +98,31 @@ public class Uicontrol extends GraphicObject {
                     return BorderLayoutType.EAST;
             }
         }
+
+        public static BorderLayoutType stringToEnum(String value) {
+            if (value == null || value.equals("")) {
+                return CENTER;
+            }
+
+            char[] chars = value.toCharArray();
+            if (chars[0] == 'n' || chars[0] == 'N') {
+                return NORTH;
+            }
+
+            if (chars[0] == 's' || chars[0] == 'S') {
+                return SOUTH;
+            }
+
+            if (chars[0] == 'e' || chars[0] == 'E') {
+                return EAST;
+            }
+
+            if (chars[0] == 'w' || chars[0] == 'W') {
+                return WEST;
+            }
+
+            return CENTER;
+        }
     }
 
     public enum FillType {
@@ -112,10 +140,32 @@ public class Uicontrol extends GraphicObject {
                     return FillType.BOTH;
             }
         }
+
+        public static FillType stringToEnum(String value) {
+            if (value == null || value.equals("")) {
+                return NONE;
+            }
+
+            char[] chars = value.toCharArray();
+            if (chars[0] == 'v' || chars[0] == 'V') {
+                return VERTICAL;
+            }
+
+            if (chars[0] == 'h' || chars[0] == 'H') {
+                return HORIZONTAL;
+            }
+
+            if (chars[0] == 'b' || chars[0] == 'B') {
+                return BOTH;
+            }
+
+            return NONE;
+        }
     }
 
     public enum AnchorType {
         CENTER, UPPER, LOWER, RIGHT, LEFT, UPPER_RIGHT, UPPER_LEFT, LOWER_RIGHT, LOWER_LEFT;
+        //c,e,w,n,s,ne,nw,se,sw
         public static AnchorType intToEnum(Integer value) {
             switch (value) {
                 default:
@@ -139,6 +189,51 @@ public class Uicontrol extends GraphicObject {
                     return LOWER_LEFT;
             }
         }
+
+        public static AnchorType stringToEnum(String value) {
+            if (value == null || value.equals("")) {
+                return CENTER;
+            }
+
+            char[] chars = value.toCharArray();
+            if (chars[0] == 'e' || chars[0] == 'E') {
+                return RIGHT;
+            }
+
+            if (chars[0] == 'w' || chars[0] == 'W') {
+                return LEFT;
+            }
+
+            if (chars[0] == 'n' || chars[0] == 'N') {
+                if (chars.length == 1) {
+                    return UPPER;
+                }
+
+                if (chars[1] == 'e' || chars[1] == 'E') {
+                    return UPPER_RIGHT;
+                }
+
+                if (chars[1] == 'w' || chars[1] == 'W') {
+                    return UPPER_LEFT;
+                }
+            }
+
+            if (chars[0] == 's' || chars[0] == 'S') {
+                if (chars.length == 1) {
+                    return LOWER;
+                }
+
+                if (chars[1] == 'e' || chars[1] == 'E') {
+                    return LOWER_RIGHT;
+                }
+
+                if (chars[1] == 'w' || chars[1] == 'W') {
+                    return LOWER_LEFT;
+                }
+            }
+
+            return CENTER;
+        }
     }
 
     protected static final String FLAT_RELIEF   = "flat";
@@ -196,6 +291,11 @@ public class Uicontrol extends GraphicObject {
     private Integer[] gridPadding = new Integer[] {0, 0};
     private BorderLayoutType borderPosition = BorderLayoutType.CENTER;
 
+    /** layout options */
+    private Integer[] gridOptGrid = new Integer[2];
+    private Integer[] gridOptPadding = new Integer[2];
+    private Integer[] borderOptPadding = new Integer[2];
+
     /**
      * All uicontrol properties
      */
@@ -236,9 +336,10 @@ public class Uicontrol extends GraphicObject {
         GRIDBAG_FILL,
         GRIDBAG_ANCHOR,
         GRIDBAG_PADDING,
-        GRID_GRID,
-        GRID_PADDING,
-        BORDER_POSITION
+        BORDER_POSITION,
+        GRIDOPT_GRID,
+        GRIDOPT_PADDING,
+        BORDEROPT_PADDING
     };
 
     /**
@@ -428,12 +529,14 @@ public class Uicontrol extends GraphicObject {
                 return UicontrolProperty.GRIDBAG_ANCHOR;
             case __GO_UI_GRIDBAG_PADDING__:
                 return UicontrolProperty.GRIDBAG_PADDING;
-            case __GO_UI_GRID_GRID__:
-                return UicontrolProperty.GRID_GRID;
-            case __GO_UI_GRID_PADDING__:
-                return UicontrolProperty.GRID_PADDING;
             case __GO_UI_BORDER_POSITION__:
                 return UicontrolProperty.BORDER_POSITION;
+            case __GO_GRID_OPT_GRID__:
+                return UicontrolProperty.GRIDOPT_GRID;
+            case __GO_GRID_OPT_PADDING__:
+                return UicontrolProperty.GRIDOPT_PADDING;
+            case __GO_BORDER_OPT_PADDING__:
+                return UicontrolProperty.BORDEROPT_PADDING;
             default :
                 return super.getPropertyFromName(propertyName);
         }
@@ -513,12 +616,14 @@ public class Uicontrol extends GraphicObject {
             return getGridBagAnchor();
         } else if (property == UicontrolProperty.GRIDBAG_PADDING) {
             return getGridBagPadding();
-        } else if (property == UicontrolProperty.GRID_GRID) {
-            return getGridGrid();
-        } else if (property == UicontrolProperty.GRID_PADDING) {
-            return getGridPadding();
         } else if (property == UicontrolProperty.BORDER_POSITION) {
             return getBorderPosition();
+        } else if (property == UicontrolProperty.GRIDOPT_GRID) {
+            return getGridOptGrid();
+        } else if (property == UicontrolProperty.GRIDOPT_PADDING) {
+            return getGridOptPadding();
+        } else if (property == UicontrolProperty.BORDEROPT_PADDING) {
+            return getBorderOptPadding();
         } else {
             return super.getProperty(property);
         }
@@ -595,12 +700,14 @@ public class Uicontrol extends GraphicObject {
                 return setGridBagAnchor((Integer) value);
             case GRIDBAG_PADDING:
                 return setGridBagPadding((Integer[]) value);
-            case GRID_GRID:
-                return setGridGrid((Integer[]) value);
-            case GRID_PADDING:
-                return setGridPadding((Integer[]) value);
             case BORDER_POSITION:
                 return setBorderPosition((Integer) value);
+            case GRIDOPT_GRID:
+                return setGridOptGrid((Integer[]) value);
+            case GRIDOPT_PADDING:
+                return setGridOptPadding((Integer[]) value);
+            case BORDEROPT_PADDING:
+                return setBorderOptPadding((Integer[]) value);
             default:
                 return super.setProperty(property, value);
         }
@@ -1013,46 +1120,6 @@ public class Uicontrol extends GraphicObject {
         return UpdateStatus.Success;
     }
 
-    public Integer[] getGridPadding() {
-        return gridPadding;
-    }
-
-    public UpdateStatus setGridPadding(Integer[] value) {
-        UpdateStatus status = UpdateStatus.NoChange;
-        if (gridPadding.length != value.length) {
-            return UpdateStatus.Fail;
-        }
-
-        for (int i = 0 ; i < value.length ; i++) {
-            if (gridPadding[i] != value[i]) {
-                gridPadding[i] = value[i];
-                status = UpdateStatus.Success;
-            }
-        }
-
-        return status;
-    }
-
-    public Integer[] getGridGrid() {
-        return gridGrid;
-    }
-
-    public UpdateStatus setGridGrid(Integer[] value) {
-        UpdateStatus status = UpdateStatus.NoChange;
-        if (gridGrid.length != value.length) {
-            return UpdateStatus.Fail;
-        }
-
-        for (int i = 0 ; i < value.length ; i++) {
-            if (gridGrid[i] != value[i]) {
-                gridGrid[i] = value[i];
-                status = UpdateStatus.Success;
-            }
-        }
-
-        return status;
-    }
-
     public Integer[] getGridBagPadding() {
         return gridbagPadding;
     }
@@ -1155,6 +1222,66 @@ public class Uicontrol extends GraphicObject {
         return status;
     }
 
+    public Integer[] getBorderOptPadding() {
+        return borderOptPadding;
+    }
+
+    public UpdateStatus setBorderOptPadding(Integer[] value) {
+        UpdateStatus status = UpdateStatus.NoChange;
+        if (borderOptPadding.length != value.length) {
+            return UpdateStatus.Fail;
+        }
+
+        for (int i = 0 ; i < value.length ; i++) {
+            if (borderOptPadding[i] != value[i]) {
+                borderOptPadding[i] = value[i];
+                status = UpdateStatus.Success;
+            }
+        }
+
+        return status;
+    }
+
+    public Integer[] getGridOptPadding() {
+        return gridOptPadding;
+    }
+
+    public UpdateStatus setGridOptPadding(Integer[] value) {
+        UpdateStatus status = UpdateStatus.NoChange;
+        if (gridOptPadding.length != value.length) {
+            return UpdateStatus.Fail;
+        }
+
+        for (int i = 0 ; i < value.length ; i++) {
+            if (gridOptPadding[i] != value[i]) {
+                gridOptPadding[i] = value[i];
+                status = UpdateStatus.Success;
+            }
+        }
+
+        return status;
+    }
+
+    public Integer[] getGridOptGrid() {
+        return gridOptGrid;
+    }
+
+    public UpdateStatus setGridOptGrid(Integer[] value) {
+        UpdateStatus status = UpdateStatus.NoChange;
+        if (gridOptGrid.length != value.length) {
+            return UpdateStatus.Fail;
+        }
+
+        for (int i = 0 ; i < value.length ; i++) {
+            if (gridOptGrid[i] != value[i]) {
+                gridOptGrid[i] = value[i];
+                status = UpdateStatus.Success;
+            }
+        }
+
+        return status;
+    }
+
     public void accept(Visitor visitor) {
     }
 }
index f2e05b0..0fd5586 100644 (file)
@@ -16,8 +16,8 @@ package org.scilab.modules.graphic_objects.utils;
 public enum LayoutType {
     NONE, GRIDBAG, GRID, BORDER;
 
-    public static LayoutType intToEnum(Integer intValue) {
-        switch (intValue) {
+    public static LayoutType intToEnum(Integer value) {
+        switch (value) {
             default:
             case 0:
                 return LayoutType.NONE;
@@ -29,4 +29,26 @@ public enum LayoutType {
                 return LayoutType.BORDER;
         }
     }
+
+    public static LayoutType stringToEnum(String value) {
+
+        if (value == null || value.equals("")) {
+            return NONE;
+        }
+
+        char[] chars = value.toCharArray();
+        if (chars[0] == 'g' || chars[0] == 'G') {
+            if (value.equalsIgnoreCase("grid")) {
+                return GRID;
+            } else if (value.equalsIgnoreCase("gridbag")) {
+                return GRIDBAG;
+            }
+        }
+
+        if (chars[0] == 'b' || chars[0] == 'B') {
+            return BORDER;
+        }
+
+        return NONE;
+    }
 }
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java
new file mode 100644 (file)
index 0000000..be3de80
--- /dev/null
@@ -0,0 +1,1131 @@
+/* The following code was generated by JFlex 1.4.3 on 22/11/12 18:50 */
+
+// jflex --nobak -d ../java/org.scilab.modules.gui.uiwidget/ css.jflex
+
+//CHECKSTYLE:OFF
+
+package org.scilab.modules.graphic_objects.xmlloader;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+@javax.annotation.Generated("JFlex")
+@SuppressWarnings("fallthrough")
+
+/**
+ * This class is a scanner generated by
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 22/11/12 18:50 from the specification file
+ * <tt>css.jflex</tt>
+ */
+public final class CSSParser {
+
+    /** This character denotes the end of file */
+    public static final int YYEOF = -1;
+
+    /** initial size of the lookahead buffer */
+    private static final int ZZ_BUFFERSIZE = 16384;
+
+    /** lexical states */
+    public static final int YYINITIAL = 0;
+    public static final int VALUELINE = 8;
+    public static final int LINE = 6;
+    public static final int VALUE = 4;
+    public static final int BLOCK = 2;
+
+    /**
+     * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+     * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+     *                  at the beginning of a line
+     * l is of the form l = 2*k, k a non negative integer
+     */
+    private static final int ZZ_LEXSTATE[] = {
+        0,  0,  1,  1,  2,  2,  3,  3,  4, 4
+    };
+
+    /**
+     * Translates characters to character classes
+     */
+    private static final String ZZ_CMAP_PACKED =
+        "\11\0\1\1\1\2\1\0\1\4\1\3\22\0\1\1\2\0\1\5" +
+        "\6\0\1\13\2\0\1\7\1\5\1\12\12\7\1\10\1\11\5\0" +
+        "\32\6\4\0\1\7\1\0\32\6\1\14\1\0\1\15\uff82\0";
+
+    /**
+     * Translates characters to character classes
+     */
+    private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+    /**
+     * Translates DFA states to action switch labels.
+     */
+    private static final int [] ZZ_ACTION = zzUnpackAction();
+
+    private static final String ZZ_ACTION_PACKED_0 =
+        "\2\1\1\0\1\1\1\0\1\2\1\1\1\3\1\2" +
+        "\1\4\1\1\1\5\1\6\1\7\1\10\1\2\2\11" +
+        "\1\10\1\11\1\1\1\12\1\2\1\0\1\10\1\13" +
+        "\6\0\1\1";
+
+    private static int [] zzUnpackAction() {
+        int [] result = new int[33];
+        int offset = 0;
+        offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+        return result;
+    }
+
+    private static int zzUnpackAction(String packed, int offset, int [] result) {
+        int i = 0;       /* index in packed string  */
+        int j = offset;  /* index in unpacked array */
+        int l = packed.length();
+        while (i < l) {
+            int count = packed.charAt(i++);
+            int value = packed.charAt(i++);
+            do {
+                result[j++] = value;
+            } while (--count > 0);
+        }
+        return j;
+    }
+
+
+    /* error codes */
+    private static final int ZZ_UNKNOWN_ERROR = 0;
+    private static final int ZZ_NO_MATCH = 1;
+    private static final int ZZ_PUSHBACK_2BIG = 2;
+
+    /* error messages for the codes above */
+    private static final String ZZ_ERROR_MSG[] = {
+        "Unkown internal scanner error",
+        "Error: could not match input",
+        "Error: pushback value was too large"
+    };
+
+    /** the input device */
+    private java.io.Reader zzReader;
+
+    /** the current state of the DFA */
+    private int zzState;
+
+    /** the current lexical state */
+    private int zzLexicalState = YYINITIAL;
+
+    /** this buffer contains the current text to be matched and is
+        the source of the yytext() string */
+    private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+    /** the textposition at the last accepting state */
+    private int zzMarkedPos;
+
+    /** the current text position in the buffer */
+    private int zzCurrentPos;
+
+    /** startRead marks the beginning of the yytext() string in the buffer */
+    private int zzStartRead;
+
+    /** endRead marks the last character in the buffer, that has been read
+        from input */
+    private int zzEndRead;
+
+    /** number of newlines encountered up to the start of the matched text */
+    private int yyline;
+
+    /** the number of characters up to the start of the matched text */
+    private int yychar;
+
+    /**
+     * the number of characters from the last newline up to the start of the
+     * matched text
+     */
+    private int yycolumn;
+
+    /**
+     * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+     */
+    private boolean zzAtBOL = true;
+
+    /** zzAtEOF == true <=> the scanner is at the EOF */
+    private boolean zzAtEOF;
+
+    /** denotes if the user-EOF-code has already been executed */
+    private boolean zzEOFDone;
+
+    /* user code: */
+    private String identifier;
+    private String key;
+    private String value;
+    private Map<String, Map<String, String>> map;
+    private Map<String, String> kv;
+
+    public static Map<String, Map<String, String>> parseFile(String file) throws CSSParserException {
+        try {
+            return parse(new FileReader(new File(file)));
+        } catch (IOException e) {
+            throw new CSSParserException(e.getMessage());
+        }
+    }
+
+    public static Map<String, Map<String, String>> parseBlock(String block) throws CSSParserException {
+        return parse(new StringReader(block));
+    }
+
+    private static Map<String, Map<String, String>> parse(Reader reader) throws CSSParserException {
+        try {
+            CSSParser parser = new CSSParser(reader);
+            parser.map = new HashMap<String, Map<String, String>>();
+            parser.yybegin(YYINITIAL);
+            int ret = parser.yylex();
+
+            if (ret == -1) {
+                parser.yyclose();
+                throw new CSSParserException("Invalid CSS file");
+            }
+
+            parser.yyclose();
+
+            return parser.map;
+        } catch (IOException e) {
+            throw new CSSParserException(e.getMessage());
+        }
+    }
+
+    public static Map<String, String> parseLine(String str) throws CSSParserException {
+        try {
+            CSSParser parser = new CSSParser(new StringReader(str));
+            parser.kv = new HashMap<String, String>();
+            parser.yybegin(LINE);
+            int ret = parser.yylex();
+
+            if (ret == -1) {
+                parser.yyclose();
+                throw new CSSParserException("Invalid CSS instructions");
+            }
+
+            parser.yyclose();
+
+            return parser.kv;
+        } catch (IOException e) {
+            throw new CSSParserException(e.getMessage());
+        }
+    }
+
+    private void openBlock() {
+        kv = new HashMap<String, String>();
+        map.put(identifier, kv);
+    }
+
+    private void closeBlock() {
+        kv = null;
+    }
+
+    public void pushKeyValue() {
+        kv.put(key.toLowerCase(), value);
+        key = null;
+        value = null;
+    }
+
+
+    /**
+     * Creates a new scanner
+     * There is also a java.io.InputStream version of this constructor.
+     *
+     * @param   in  the java.io.Reader to read input from.
+     */
+    public CSSParser(java.io.Reader in) {
+        this.zzReader = in;
+    }
+
+    /**
+     * Creates a new scanner.
+     * There is also java.io.Reader version of this constructor.
+     *
+     * @param   in  the java.io.Inputstream to read input from.
+     */
+    public CSSParser(java.io.InputStream in) {
+        this(new java.io.InputStreamReader(in));
+    }
+
+    /**
+     * Unpacks the compressed character translation table.
+     *
+     * @param packed   the packed character translation table
+     * @return         the unpacked character translation table
+     */
+    private static char [] zzUnpackCMap(String packed) {
+        char [] map = new char[0x10000];
+        int i = 0;  /* index in packed string  */
+        int j = 0;  /* index in unpacked array */
+        while (i < 58) {
+            int  count = packed.charAt(i++);
+            char value = packed.charAt(i++);
+            do {
+                map[j++] = value;
+            } while (--count > 0);
+        }
+        return map;
+    }
+
+
+    /**
+     * Refills the input buffer.
+     *
+     * @return      <code>false</code>, iff there was new input.
+     *
+     * @exception   java.io.IOException  if any I/O-Error occurs
+     */
+    private boolean zzRefill() throws java.io.IOException {
+
+        /* first: make room (if you can) */
+        if (zzStartRead > 0) {
+            System.arraycopy(zzBuffer, zzStartRead,
+                             zzBuffer, 0,
+                             zzEndRead - zzStartRead);
+
+            /* translate stored positions */
+            zzEndRead -= zzStartRead;
+            zzCurrentPos -= zzStartRead;
+            zzMarkedPos -= zzStartRead;
+            zzStartRead = 0;
+        }
+
+        /* is the buffer big enough? */
+        if (zzCurrentPos >= zzBuffer.length) {
+            /* if not: blow it up */
+            char newBuffer[] = new char[zzCurrentPos * 2];
+            System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+            zzBuffer = newBuffer;
+        }
+
+        /* finally: fill the buffer with new input */
+        int numRead = zzReader.read(zzBuffer, zzEndRead,
+                                    zzBuffer.length - zzEndRead);
+
+        if (numRead > 0) {
+            zzEndRead += numRead;
+            return false;
+        }
+        // unlikely but not impossible: read 0 characters, but not at end of stream
+        if (numRead == 0) {
+            int c = zzReader.read();
+            if (c == -1) {
+                return true;
+            } else {
+                zzBuffer[zzEndRead++] = (char) c;
+                return false;
+            }
+        }
+
+        // numRead < 0
+        return true;
+    }
+
+
+    /**
+     * Closes the input stream.
+     */
+    public final void yyclose() throws java.io.IOException {
+        zzAtEOF = true;            /* indicate end of file */
+        zzEndRead = zzStartRead;  /* invalidate buffer    */
+
+        if (zzReader != null) {
+            zzReader.close();
+        }
+    }
+
+
+    /**
+     * Resets the scanner to read from a new input stream.
+     * Does not close the old reader.
+     *
+     * All internal variables are reset, the old input stream
+     * <b>cannot</b> be reused (internal buffer is discarded and lost).
+     * Lexical state is set to <tt>ZZ_INITIAL</tt>.
+     *
+     * @param reader   the new input stream
+     */
+    public final void yyreset(java.io.Reader reader) {
+        zzReader = reader;
+        zzAtBOL  = true;
+        zzAtEOF  = false;
+        zzEOFDone = false;
+        zzEndRead = zzStartRead = 0;
+        zzCurrentPos = zzMarkedPos = 0;
+        yyline = yychar = yycolumn = 0;
+        zzLexicalState = YYINITIAL;
+    }
+
+
+    /**
+     * Returns the current lexical state.
+     */
+    public final int yystate() {
+        return zzLexicalState;
+    }
+
+
+    /**
+     * Enters a new lexical state
+     *
+     * @param newState the new lexical state
+     */
+    public final void yybegin(int newState) {
+        zzLexicalState = newState;
+    }
+
+
+    /**
+     * Returns the text matched by the current regular expression.
+     */
+    public final String yytext() {
+        return new String( zzBuffer, zzStartRead, zzMarkedPos - zzStartRead );
+    }
+
+
+    /**
+     * Returns the character at position <tt>pos</tt> from the
+     * matched text.
+     *
+     * It is equivalent to yytext().charAt(pos), but faster
+     *
+     * @param pos the position of the character to fetch.
+     *            A value from 0 to yylength()-1.
+     *
+     * @return the character at position pos
+     */
+    public final char yycharat(int pos) {
+        return zzBuffer[zzStartRead + pos];
+    }
+
+
+    /**
+     * Returns the length of the matched text region.
+     */
+    public final int yylength() {
+        return zzMarkedPos - zzStartRead;
+    }
+
+
+    /**
+     * Reports an error that occured while scanning.
+     *
+     * In a wellformed scanner (no or only correct usage of
+     * yypushback(int) and a match-all fallback rule) this method
+     * will only be called with things that "Can't Possibly Happen".
+     * If this method is called, something is seriously wrong
+     * (e.g. a JFlex bug producing a faulty scanner etc.).
+     *
+     * Usual syntax/scanner level error handling should be done
+     * in error fallback rules.
+     *
+     * @param   errorCode  the code of the errormessage to display
+     */
+    private void zzScanError(int errorCode) {
+        String message;
+        try {
+            message = ZZ_ERROR_MSG[errorCode];
+        } catch (ArrayIndexOutOfBoundsException e) {
+            message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+        }
+
+        throw new Error(message);
+    }
+
+
+    /**
+     * Pushes the specified amount of characters back into the input stream.
+     *
+     * They will be read again by then next call of the scanning method
+     *
+     * @param number  the number of characters to be read again.
+     *                This number must not be greater than yylength()!
+     */
+    public void yypushback(int number)  {
+        if ( number > yylength() ) {
+            zzScanError(ZZ_PUSHBACK_2BIG);
+        }
+
+        zzMarkedPos -= number;
+    }
+
+
+    /**
+     * Resumes scanning until the next regular expression is matched,
+     * the end of input is encountered or an I/O-Error occurs.
+     *
+     * @return      the next token
+     * @exception   java.io.IOException  if any I/O-Error occurs
+     */
+    public int yylex() throws java.io.IOException {
+        int zzInput;
+        int zzAction;
+
+        // cached fields:
+        int zzCurrentPosL;
+        int zzMarkedPosL;
+        int zzEndReadL = zzEndRead;
+        char [] zzBufferL = zzBuffer;
+        char [] zzCMapL = ZZ_CMAP;
+
+
+        while (true) {
+            zzMarkedPosL = zzMarkedPos;
+
+            yychar += zzMarkedPosL - zzStartRead;
+
+            zzAction = -1;
+
+            zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+            zzState = ZZ_LEXSTATE[zzLexicalState];
+
+
+            zzForAction: {
+                while (true) {
+
+                    if (zzCurrentPosL < zzEndReadL) {
+                        zzInput = zzBufferL[zzCurrentPosL++];
+                    } else if (zzAtEOF) {
+                        zzInput = YYEOF;
+                        break zzForAction;
+                    } else {
+                        // store back cached positions
+                        zzCurrentPos  = zzCurrentPosL;
+                        zzMarkedPos   = zzMarkedPosL;
+                        boolean eof = zzRefill();
+                        // get translated positions and possibly new buffer
+                        zzCurrentPosL  = zzCurrentPos;
+                        zzMarkedPosL   = zzMarkedPos;
+                        zzBufferL      = zzBuffer;
+                        zzEndReadL     = zzEndRead;
+                        if (eof) {
+                            zzInput = YYEOF;
+                            break zzForAction;
+                        } else {
+                            zzInput = zzBufferL[zzCurrentPosL++];
+                        }
+                    }
+                    zzInput = zzCMapL[zzInput];
+
+                    boolean zzIsFinal = false;
+                    boolean zzNoLookAhead = false;
+
+                    zzForNext: {
+                        switch (zzState) {
+                            case 0:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        zzState = 6;
+                                        break zzForNext;
+                                    case 5:
+                                    case 6:
+                                        zzIsFinal = true;
+                                        zzState = 7;
+                                        break zzForNext;
+                                    case 10:
+                                        zzIsFinal = true;
+                                        zzState = 8;
+                                        break zzForNext;
+                                    case 12:
+                                        zzIsFinal = true;
+                                        zzState = 9;
+                                        break zzForNext;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 5;
+                                        break zzForNext;
+                                }
+
+                            case 1:
+                                switch (zzInput) {
+                                    case 10:
+                                        zzIsFinal = true;
+                                        zzState = 8;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        zzState = 10;
+                                        break zzForNext;
+                                    case 6:
+                                    case 7:
+                                        zzIsFinal = true;
+                                        zzState = 11;
+                                        break zzForNext;
+                                    case 8:
+                                        zzIsFinal = true;
+                                        zzState = 12;
+                                        break zzForNext;
+                                    case 13:
+                                        zzIsFinal = true;
+                                        zzState = 13;
+                                        break zzForNext;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 5;
+                                        break zzForNext;
+                                }
+
+                            case 2:
+                                switch (zzInput) {
+                                    case 8:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 5;
+                                        break zzForNext;
+                                    case 1:
+                                        zzIsFinal = true;
+                                        zzState = 15;
+                                        break zzForNext;
+                                    case 2:
+                                        zzIsFinal = true;
+                                        zzState = 16;
+                                        break zzForNext;
+                                    case 3:
+                                        zzIsFinal = true;
+                                        zzState = 17;
+                                        break zzForNext;
+                                    case 4:
+                                        zzIsFinal = true;
+                                        zzState = 18;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 19;
+                                        break zzForNext;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzState = 14;
+                                        break zzForNext;
+                                }
+
+                            case 3:
+                                switch (zzInput) {
+                                    case 6:
+                                    case 7:
+                                        zzIsFinal = true;
+                                        zzState = 11;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        zzState = 20;
+                                        break zzForNext;
+                                    case 8:
+                                        zzIsFinal = true;
+                                        zzState = 21;
+                                        break zzForNext;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 5;
+                                        break zzForNext;
+                                }
+
+                            case 4:
+                                switch (zzInput) {
+                                    case 8:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 5;
+                                        break zzForNext;
+                                    case 1:
+                                    case 3:
+                                        zzIsFinal = true;
+                                        zzState = 22;
+                                        break zzForNext;
+                                    case 2:
+                                        zzState = 23;
+                                        break zzForNext;
+                                    case 4:
+                                        zzIsFinal = true;
+                                        zzState = 24;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 25;
+                                        break zzForNext;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzState = 14;
+                                        break zzForNext;
+                                }
+
+                            case 6:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    case 12:
+                                        zzIsFinal = true;
+                                        zzState = 9;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 7:
+                                switch (zzInput) {
+                                    case 6:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 8:
+                                switch (zzInput) {
+                                    case 11:
+                                        zzState = 26;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 9:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 10:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    case 13:
+                                        zzIsFinal = true;
+                                        zzState = 13;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 11:
+                                switch (zzInput) {
+                                    case 6:
+                                    case 7:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 12:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 13:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 14:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                        zzState = 27;
+                                        break zzForNext;
+                                    case 8:
+                                    case 9:
+                                        break zzForAction;
+                                    default:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                }
+
+                            case 15:
+                                switch (zzInput) {
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 19;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzState = 28;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 16:
+                                switch (zzInput) {
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 19;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzState = 28;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 17:
+                                switch (zzInput) {
+                                    case 2:
+                                        zzIsFinal = true;
+                                        zzState = 16;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 19;
+                                        break zzForNext;
+                                    case 1:
+                                    case 3:
+                                    case 4:
+                                        zzState = 28;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 18:
+                                switch (zzInput) {
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 19;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                        zzState = 29;
+                                        break zzForNext;
+                                    case 8:
+                                        break zzForAction;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzState = 14;
+                                        break zzForNext;
+                                }
+
+                            case 20:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 21:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 22:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        zzState = 23;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 25;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 23:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 25;
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 24:
+                                switch (zzInput) {
+                                    case 4:
+                                        zzIsFinal = true;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 25;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                        zzState = 30;
+                                        break zzForNext;
+                                    case 8:
+                                        break zzForAction;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzState = 14;
+                                        break zzForNext;
+                                }
+
+                            case 26:
+                                switch (zzInput) {
+                                    case 11:
+                                        zzState = 31;
+                                        break zzForNext;
+                                    default:
+                                        break zzForNext;
+                                }
+
+                            case 27:
+                                switch (zzInput) {
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                        break zzForNext;
+                                    case 8:
+                                    case 9:
+                                        break zzForAction;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzState = 14;
+                                        break zzForNext;
+                                }
+
+                            case 28:
+                                switch (zzInput) {
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 19;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                    case 4:
+                                        break zzForNext;
+                                    default:
+                                        break zzForAction;
+                                }
+
+                            case 29:
+                                switch (zzInput) {
+                                    case 4:
+                                        zzIsFinal = true;
+                                        zzState = 18;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 19;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                        break zzForNext;
+                                    case 8:
+                                        break zzForAction;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzState = 14;
+                                        break zzForNext;
+                                }
+
+                            case 30:
+                                switch (zzInput) {
+                                    case 4:
+                                        zzIsFinal = true;
+                                        zzState = 24;
+                                        break zzForNext;
+                                    case 9:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 25;
+                                        break zzForNext;
+                                    case 1:
+                                    case 2:
+                                    case 3:
+                                        break zzForNext;
+                                    case 8:
+                                        break zzForAction;
+                                    default:
+                                        zzIsFinal = true;
+                                        zzState = 14;
+                                        break zzForNext;
+                                }
+
+                            case 31:
+                                switch (zzInput) {
+                                    case 11:
+                                        break zzForNext;
+                                    case 10:
+                                        zzIsFinal = true;
+                                        zzNoLookAhead = true;
+                                        zzState = 32;
+                                        break zzForNext;
+                                    default:
+                                        zzState = 26;
+                                        break zzForNext;
+                                }
+
+                            default:
+                                // if this is ever reached, there is a serious bug in JFlex
+                                zzScanError(ZZ_UNKNOWN_ERROR);
+                                break;
+                        }
+                    }
+
+                    if ( zzIsFinal ) {
+                        zzAction = zzState;
+                        zzMarkedPosL = zzCurrentPosL;
+                        if ( zzNoLookAhead ) {
+                            break zzForAction;
+                        }
+                    }
+
+                }
+            }
+
+            // store back cached position
+            zzMarkedPos = zzMarkedPosL;
+
+            switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+                case 9 : {
+                    yybegin(BLOCK);
+                }
+                case 12:
+                    break;
+                case 4: {
+                    openBlock();
+                    yybegin(BLOCK);
+                }
+                case 13:
+                    break;
+                case 8: {
+                    value = yytext();
+                    pushKeyValue();
+                }
+                case 14:
+                    break;
+                case 10: {
+                    yybegin(VALUELINE);
+                }
+                case 15:
+                    break;
+                case 2: {
+                    return -1;
+                }
+                case 16:
+                    break;
+                case 11: {
+                    yybegin(LINE);
+                }
+                case 17:
+                    break;
+                case 6: {
+                    yybegin(VALUE);
+                }
+                case 18:
+                    break;
+                case 5: {
+                    key = yytext();
+                }
+                case 19:
+                    break;
+                case 7: {
+                    closeBlock();
+                    yybegin(YYINITIAL);
+                }
+                case 20:
+                    break;
+                case 3: {
+                    identifier = yytext();
+                }
+                case 21:
+                    break;
+                case 1: {
+                }
+                case 22:
+                    break;
+                default:
+                    if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+                        zzAtEOF = true;
+                        {
+                            return 0;
+                        }
+                    } else {
+                        zzScanError(ZZ_NO_MATCH);
+                    }
+            }
+        }
+    }
+
+
+}
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParserException.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParserException.java
new file mode 100644 (file)
index 0000000..ba29129
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.modules.graphic_objects.xmlloader;
+
+/**
+ * CSS parser exception
+ */
+public class CSSParserException extends Exception {
+
+    /**
+     * Default constructor
+     * @param msg the error message
+     */
+    public CSSParserException(String msg) {
+        super(msg);
+    }
+}
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/GOBuilder.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/GOBuilder.java
new file mode 100644 (file)
index 0000000..ee31a35
--- /dev/null
@@ -0,0 +1,260 @@
+package org.scilab.modules.graphic_objects.xmlloader;
+
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DOCKABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_GRID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFOBAR_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LAYOUT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MENUBAR_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_NAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_POSITION__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_RESIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_SIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TAG__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TOOLBAR_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BORDER_POSITION__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_GRID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_WEIGHT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_FILL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_ANCHOR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MARGINS__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_STYLE__;
+
+
+import java.util.Map;
+
+import org.scilab.modules.graphic_objects.builder.Builder;
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
+import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
+import org.scilab.modules.graphic_objects.uicontrol.Uicontrol.AnchorType;
+import org.scilab.modules.graphic_objects.uicontrol.uitext.UiText;
+import org.scilab.modules.graphic_objects.utils.LayoutType;
+import org.xml.sax.Attributes;
+
+public class GOBuilder {
+    public static Integer figureBuilder(GraphicController controller, Attributes attributes) {
+        Integer fig = Builder.createNewFigureWithAxes();
+        String item = null;
+
+        // hide toolbar
+        controller.setProperty(fig, __GO_TOOLBAR_VISIBLE__, false);
+
+        // hide menubar
+        controller.setProperty(fig, __GO_MENUBAR_VISIBLE__, false);
+
+        // hide infobar
+        controller.setProperty(fig, __GO_INFOBAR_VISIBLE__, false);
+
+        // remove dock
+        controller.setProperty(fig, __GO_DOCKABLE__, false);
+
+        // id
+        XmlTools.setPropAsString(fig, __GO_TAG__, attributes.getValue("id"));
+
+        // visible
+        XmlTools.setPropAsBoolean(fig, __GO_VISIBLE__,
+                                  attributes.getValue("visible"));
+
+        // position
+        Integer[] position = (Integer[]) controller.getProperty(fig, __GO_POSITION__);
+        // posX
+        item = attributes.getValue("posX");
+        if (item != null) {
+            position[0] = Integer.parseInt(item);
+        }
+
+        // posY
+        item = attributes.getValue("posY");
+        if (item != null) {
+            position[1] = Integer.parseInt(item);
+        }
+
+        // set position
+        controller.setProperty(fig, __GO_POSITION__, position);
+
+        Integer[] size = (Integer[]) controller.getProperty(fig, __GO_SIZE__);
+        // width
+        item = attributes.getValue("width");
+        if (item != null) {
+            size[0] = Integer.parseInt(item);
+        }
+
+        // height
+        item = attributes.getValue("height");
+        if (item != null) {
+            size[1] = Integer.parseInt(item);
+        }
+
+        // set size
+        controller.setProperty(fig, __GO_SIZE__, size);
+
+        // title
+        XmlTools.setPropAsString(fig, __GO_NAME__, attributes.getValue("title"));
+
+        // icon
+        // XmlTools.setPropAsString(fig, __GO_ICON__,
+        // attributes.getValue("icon"));
+
+        // resizable
+        XmlTools.setPropAsBoolean(fig, __GO_RESIZE__, attributes.getValue("resizable"));
+
+        // layout and layout_options
+        setLayoutProperty(controller, fig, attributes.getValue("layout"));
+
+        return fig;
+    }
+
+    public static Integer uicontrolBuilder(GraphicController controller, int type, Attributes attributes, int parent) {
+        Integer uic = controller.askObject(GraphicObject.getTypeFromName(type));
+        return uicontrolUpdater(controller, uic, attributes, parent);
+    }
+
+    public static Integer uicontrolUpdater(GraphicController controller, int uic, Attributes attributes, int parent) {
+        return uicontrolUpdater(controller, uic, attributes, parent, null);
+    }
+
+    public static Integer uicontrolUpdater(GraphicController controller, int uic, Attributes attributes, int parent, Map<String, String> fromModel) {
+        String item = null;
+
+        try {
+            Map<String, String> map = null;
+            //Common attributes
+
+            //id
+            XmlTools.setPropAsString(uic, __GO_TAG__, attributes.getValue("id"));
+
+
+            // layout and layout_options
+            item = attributes.getValue("layout");
+            if (item == null && fromModel != null) {
+                item = fromModel.get("layout");
+            }
+            setLayoutProperty(controller, uic, item);
+
+            //constraints
+
+            //get parent layout
+            LayoutType layout = LayoutType.NONE;
+            if (parent != 0) {
+                layout = LayoutType.intToEnum((Integer)controller.getProperty(parent, __GO_LAYOUT__));
+            }
+
+            if (layout != LayoutType.NONE) {
+                item = attributes.getValue("constraint");
+                if (item == null && fromModel != null) {
+                    //use value from model if property is not in "declaration"
+                    item = XmlTools.getFromMap(fromModel, "constraint");
+                }
+
+                if (item != null) {
+                    map = CSSParser.parseLine(item);
+                }
+
+                switch (layout) {
+                    case BORDER: {
+                        item = XmlTools.getFromMap(map, "position", "center");
+                        controller.setProperty(uic, __GO_UI_BORDER_POSITION__, Uicontrol.BorderLayoutType.stringToEnum(item).ordinal());
+                        break;
+                    }
+                    case GRIDBAG: {
+                        Integer[] grid = new Integer[] {0, 0, 0, 0};
+                        grid[0] = Integer.parseInt(XmlTools.getFromMap(map, "gridx", "0"));
+                        grid[1] = Integer.parseInt(XmlTools.getFromMap(map, "gridy", "0"));
+                        grid[2] = Integer.parseInt(XmlTools.getFromMap(map, "gridwidth", "0"));
+                        grid[3] = Integer.parseInt(XmlTools.getFromMap(map, "gridheight", "0"));
+
+                        Double[] weight = new Double[] {0.0, 0.0};
+                        weight[0] = Double.parseDouble(XmlTools.getFromMap(map, "weightx", "0.0"));
+                        weight[1] = Double.parseDouble(XmlTools.getFromMap(map, "weighty", "0.0"));
+
+                        Integer fill = Uicontrol.FillType.stringToEnum(XmlTools.getFromMap(map, "fill", "none")).ordinal();
+                        Integer anchor = Uicontrol.AnchorType.stringToEnum(XmlTools.getFromMap(map, "anchor", "center")).ordinal();
+
+                        Integer[] padding = new Integer[] {0, 0};
+                        padding[0] = Integer.parseInt(XmlTools.getFromMap(map, "ipadx", "0"));
+                        padding[1] = Integer.parseInt(XmlTools.getFromMap(map, "ipady", "0"));
+
+                        controller.setProperty(uic, __GO_UI_GRIDBAG_GRID__, grid);
+                        controller.setProperty(uic, __GO_UI_GRIDBAG_WEIGHT__, weight);
+                        controller.setProperty(uic, __GO_UI_GRIDBAG_FILL__, fill);
+                        controller.setProperty(uic, __GO_UI_GRIDBAG_ANCHOR__, anchor);
+                        controller.setProperty(uic, __GO_UI_GRIDBAG_PADDING__, padding);
+                        break;
+                    }
+                    default:
+                        break;
+                }
+
+                //inserts -> marging
+                String insets = XmlTools.getFromMap(map, "insets", "0,0,0,0");
+                Double[] margins = new Double[] {0.0, 0.0, 0.0, 0.0};
+                String[] insert = insets.split(",");
+                for (int i = 0; i < insert.length && i < 4; i++) {
+                    margins[i] = Double.parseDouble(insert[i]);
+                }
+
+                controller.setProperty(uic, __GO_MARGINS__, margins);
+            }
+
+
+            //specific attributes
+            Integer type = (Integer)controller.getProperty(uic, __GO_STYLE__);
+            switch (type) {
+            }
+
+        } catch (CSSParserException e) {
+            e.printStackTrace();
+        }
+
+        return uic;
+    }
+
+    private static void setLayoutProperty(GraphicController controller, Integer uid, String item) {
+        try {
+            if (item != null) {
+                Map<String, String> map = null;
+                map = CSSParser.parseLine(item);
+                item = map.get("name");
+                LayoutType layout = LayoutType.stringToEnum(item);
+                controller.setProperty(uid, __GO_LAYOUT__, layout.ordinal());
+
+                // layout_options
+                switch (layout) {
+                    case BORDER: {
+                        Integer[] pad = new Integer[] { 0, 0 };
+                        pad[0] = Integer.parseInt(XmlTools.getFromMap(map, "hgap", "0"));
+                        pad[1] = Integer.parseInt(XmlTools.getFromMap(map, "vgap", "0"));
+
+                        controller.setProperty(uid, __GO_BORDER_OPT_PADDING__, pad);
+                        break;
+                    }
+                    case GRID: {
+                        Integer[] grid = new Integer[] { 0, 0 };
+                        grid[0] = Integer.parseInt(XmlTools.getFromMap(map, "rows", "0"));
+                        grid[1] = Integer.parseInt(XmlTools.getFromMap(map, "cols", "0"));
+
+                        Integer[] pad = new Integer[] { 0, 0 };
+                        pad[0] = Integer.parseInt(XmlTools.getFromMap(map, "hgap", "0"));
+                        pad[1] = Integer.parseInt(XmlTools.getFromMap(map, "vgap", "0"));
+
+                        controller.setProperty(uid, __GO_GRID_OPT_GRID__, grid);
+                        controller.setProperty(uid, __GO_GRID_OPT_PADDING__, pad);
+                        break;
+                    }
+                    default:
+                    case GRIDBAG:
+                    case NONE:
+                        // nothing to do
+                        break;
+                }
+            }
+        } catch (CSSParserException e) {
+            e.printStackTrace();
+        }
+
+    }
+}
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlLoader.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlLoader.java
new file mode 100644 (file)
index 0000000..8f75fd0
--- /dev/null
@@ -0,0 +1,338 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - DIGITEO - Manuel JULIACHS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.modules.graphic_objects.xmlloader;
+
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FIGURE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_EDIT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_IMAGE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LISTBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_POPUPMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_PUSHBUTTON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_RADIOBUTTON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SLIDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TABGROUP__;
+//import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TAB__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TEXT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.Stack;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class XmlLoader extends DefaultHandler {
+
+    private String filename = "";
+    private Locator locator;
+    private Integer uid = 0;
+    private String namespace = null;
+    private boolean isWaitingModelName = true;
+    private String myURI = "";
+    private boolean isFirst = false;
+
+    private static HashMap<String, Integer> nameToGO = new HashMap<String, Integer>();
+    private static HashMap<String, HashMap<String, Entry<Integer, Map<String, String>>>> models = new HashMap<String, HashMap<String, Entry<Integer, Map<String, String>>>>();
+    private Stack<Integer> stackGO = new Stack<Integer>();
+
+    private GraphicController controller;
+
+    static {
+        //init map to convert control name to id
+        nameToGO.put("UIScilabWindow", __GO_FIGURE__);
+        nameToGO.put("Figure", __GO_FIGURE__);
+
+        nameToGO.put("UIPanel", __GO_UI_FRAME__);
+        nameToGO.put("UIFrame", __GO_UI_FRAME__);
+        nameToGO.put("UILayer", __GO_UI_FRAME__);
+        nameToGO.put("Panel", __GO_UI_FRAME__);
+        nameToGO.put("Frame", __GO_UI_FRAME__);
+        nameToGO.put("Layer", __GO_UI_FRAME__);
+
+        nameToGO.put("UIButton", __GO_UI_PUSHBUTTON__);
+        nameToGO.put("PushButton", __GO_UI_PUSHBUTTON__);
+        nameToGO.put("Button", __GO_UI_PUSHBUTTON__);
+
+        nameToGO.put("UILabel", __GO_UI_TEXT__);
+        nameToGO.put("Label", __GO_UI_TEXT__);
+        nameToGO.put("Text", __GO_UI_TEXT__);
+
+        nameToGO.put("UICheckbox", __GO_UI_CHECKBOX__);
+        nameToGO.put("CheckBox", __GO_UI_CHECKBOX__);
+
+        nameToGO.put("UITextfield", __GO_UI_EDIT__);
+        nameToGO.put("Textfield", __GO_UI_EDIT__);
+        nameToGO.put("EditBox", __GO_UI_EDIT__);
+        nameToGO.put("Edit", __GO_UI_EDIT__);
+
+        nameToGO.put("UISplashScreen", __GO_UI_IMAGE__);
+        nameToGO.put("Image", __GO_UI_IMAGE__);
+        nameToGO.put("Picture", __GO_UI_IMAGE__);
+
+        nameToGO.put("UIList", __GO_UI_LISTBOX__);
+        nameToGO.put("List", __GO_UI_LISTBOX__);
+        nameToGO.put("ListBox", __GO_UI_LISTBOX__);
+
+        nameToGO.put("UICombobox", __GO_UI_POPUPMENU__);
+        nameToGO.put("ComboBox", __GO_UI_POPUPMENU__);
+        nameToGO.put("PopupMenu", __GO_UI_POPUPMENU__);
+
+        nameToGO.put("UIRadio", __GO_UI_RADIOBUTTON__);
+        nameToGO.put("RadioButton", __GO_UI_RADIOBUTTON__);
+        nameToGO.put("Radio", __GO_UI_RADIOBUTTON__);
+
+        nameToGO.put("UISlider", __GO_UI_SLIDER__);
+        nameToGO.put("Slider", __GO_UI_SLIDER__);
+
+        nameToGO.put("Table", __GO_UI_TABLE__);
+
+        nameToGO.put("UILabel", __GO_UI_TEXT__);
+        nameToGO.put("Text", __GO_UI_TEXT__);
+        nameToGO.put("Label", __GO_UI_TEXT__);
+
+        nameToGO.put("UITab", __GO_UI_TABGROUP__);
+    }
+
+    public XmlLoader(String filename) {
+        controller = GraphicController.getController();
+        this.filename = filename;
+    }
+
+    public int parse() throws SAXException {
+        int ret = 0;
+        if (filename != null && filename.equals("") == false) {
+            ret = parse(filename);
+        }
+
+        Set<String> entries = models.keySet();
+        for (String key : entries) {
+            HashMap<String, Entry<Integer, Map<String, String>>> map = models.get(key);
+            Set<String> entries2 = map.keySet();
+            for (String key2 : entries2) {
+                deleteObject(map.get(key2).getKey());
+            }
+        }
+
+        return ret;
+    }
+
+    public int parse(String filename) throws SAXException {
+        this.filename = filename;
+        File f = new File(filename);
+
+        SAXParser parser;
+        try {
+            SAXParserFactory factory;
+            factory = SAXParserFactory.newInstance();
+            factory.setValidating(false);
+            factory.setNamespaceAware(true);
+            factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+            parser = factory.newSAXParser();
+        } catch (Exception e) {
+            throw new SAXException(String.format("Cannot initialize the XML parser: %s", e.getMessage()));
+        }
+
+        try {
+            parser.parse(f, this);
+        } catch (SAXException e) {
+            if (locator != null) {
+                throw new SAXException(String.format("Parse error at line %d: %s", locator.getLineNumber(), e.getMessage()));
+            } else {
+                throw new SAXException(String.format("Parse error: %s", e.getMessage()));
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return uid;
+    }
+
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        super.characters(ch, start, length);
+    }
+
+    public void endDocument() throws SAXException {
+    }
+
+    public void endElement(String uri, String localName, String qName) throws SAXException {
+
+        if (localName.equals("modele")) {
+            namespace = null;
+        }
+
+        if (stackGO.size() != 0) {
+            Integer go = stackGO.pop();
+            if (go == null) {
+            } else if (stackGO.size() > 0) {
+                Integer parent = stackGO.peek();
+                controller.setGraphicObjectRelationship(parent, go);
+                controller.setProperty(go,  __GO_VISIBLE__, true);
+            } else {
+                uid = go;
+            }
+        }
+    }
+
+    public void setDocumentLocator(Locator locator) {
+        this.locator = locator;
+    }
+
+    public void startDocument() throws SAXException {
+        isFirst = true;
+    }
+
+    public void startElement(String uri, String localName, String qName,
+                             Attributes attributes) throws SAXException {
+
+        if (localName.equals("interface")) {
+            if (isFirst) {
+                myURI =  attributes.getValue("xmlns");
+                isFirst = false;
+            }
+        } else if (localName.equals("include")) {
+            String path = attributes.getValue("path");
+            parse(path);
+        } else if (localName.equals("modele")) {
+            namespace = attributes.getValue("namespace");
+            isWaitingModelName = true;
+        } else {
+
+
+            for (int i = 0 ; i < attributes.getLength() ; i++) {
+                String val = attributes.getValue(i);
+                System.out.print(attributes.getLocalName(i) + ":");
+                if (val != null) {
+                    System.out.println(val);
+                    try {
+                        Map<String, String> map = CSSParser.parseLine(val);
+                        if (map.size() != 0) {
+                            Set<Entry<String, String>> entries = map.entrySet();
+                            for (Entry<String, String> entry : entries) {
+                                System.out.println(entry.getKey() + " -> " + entry.getValue());
+                            }
+                        }
+                    } catch (CSSParserException e) {
+                        //e.printStackTrace();
+                    }
+                } else {
+                    System.out.println("");
+                }
+            }
+
+            System.out.println("");
+
+
+
+
+
+            Integer uitype = getTypeFromName(localName);
+            Integer go = 0;
+            if (uitype != null && uitype.intValue() > 0) {
+                if (uitype == __GO_FIGURE__) {
+                    //never create a new figure, clone figure model !
+                    go = GOBuilder.figureBuilder(controller, attributes);
+                } else {
+                    int parent = 0;
+                    if (stackGO.isEmpty() == false) {
+                        parent = stackGO.peek();
+                    }
+                    go = GOBuilder.uicontrolBuilder(controller, uitype, attributes, parent);
+                }
+            } else { //namespace or bad name ...
+                if (myURI.equals(uri)) {
+                    //bad name
+                } else {
+                    HashMap<String, Entry<Integer, Map<String, String>>> m = models.get(uri);
+                    if (m == null) {
+                        //bad namespace
+                    } else {
+                        Entry<Integer, Map<String, String>> entry = m.get(localName);
+                        go = entry.getKey();
+                        //need to clone object and children
+                        Integer newgo = cloneObject(go);
+                        GOBuilder.uicontrolUpdater(controller, newgo, attributes, stackGO.peek(), entry.getValue());
+                        go = newgo;
+
+                    }
+                }
+            }
+
+            // we are in a model
+            // the first child must have field "model-name"
+            if (namespace != null) {
+                if (isWaitingModelName) {
+                    String name = attributes.getValue("modele-name");
+                    if (name == null) {
+                        //unmaned model ? :s
+                    } else {
+                        if (models.get(namespace) == null) {
+                            models.put(namespace, new HashMap<String, Entry<Integer, Map<String, String>>>());
+                        }
+
+                        //copy attributes to a Map, i do not know why a can use attributes ? Oo
+                        Map<String, String> attrib = new HashMap<String, String>();
+                        for (int i = 0 ; i < attributes.getLength() ; i++) {
+                            attrib.put(attributes.getLocalName(i), attributes.getValue(i));
+                        }
+
+                        // add root element in map model
+                        models.get(namespace).put(name, new SimpleEntry<Integer, Map<String, String>>(go, attrib));
+                        isWaitingModelName = false;
+                    }
+                }
+            }
+
+            stackGO.add(go);
+        }
+    }
+
+    Integer cloneObject(Integer root) {
+        Integer newGo = controller.cloneObject(root);
+        Integer[] children = (Integer[])controller.getProperty(root, __GO_CHILDREN__);
+        for (int i = 0 ; i < children.length ; i++) {
+            Integer newChild = cloneObject(children[i]);
+            controller.setGraphicObjectRelationship(newGo, newChild);
+        }
+
+        return newGo;
+    }
+
+    private void deleteObject(Integer root) {
+        Integer[] children = (Integer[])controller.getProperty(root, __GO_CHILDREN__);
+        for (int i = 0 ; i < children.length ; i++) {
+            deleteObject(children[i]);
+        }
+
+        controller.deleteObject(root);
+    }
+
+    private Integer getTypeFromName(String localName) {
+        return nameToGO.get(localName);
+    }
+}
diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlTools.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlTools.java
new file mode 100644 (file)
index 0000000..76fe03c
--- /dev/null
@@ -0,0 +1,164 @@
+package org.scilab.modules.graphic_objects.xmlloader;
+
+import java.awt.GridBagConstraints;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+
+public class XmlTools {
+    public static Boolean setPropAsDouble(Integer uid, Integer prop, String propString) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        GraphicController.getController().setProperty(uid, prop, Double.parseDouble(propString));
+        return true;
+    }
+
+    public static Boolean setPropAsDoubleVector(Integer uid, Integer prop, Map<String, String> map, String[] propString) {
+        if (propString == null || propString.length == 0) {
+            return false;
+        }
+
+        Double[] values = new Double[propString.length];
+        for (int i = 0 ; i < propString.length ; i++) {
+            String value = map.get(propString[i]);
+            if (value == null || value.equals("")) {
+                values[i] = 0.0;
+            } else {
+                values[i] = Double.parseDouble(value);
+            }
+        }
+
+        GraphicController.getController().setProperty(uid, prop, values);
+        return true;
+    }
+
+    public static Boolean setPropAsDoubleVector(Integer uid, Integer prop, String propString, Integer size) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        Double[] values = new Double[size];
+
+        StringTokenizer tokens = new StringTokenizer(propString, ",");
+        if (tokens.countTokens() > size) {
+            return false;
+        }
+
+        int i = 0;
+        while (tokens.hasMoreTokens()) {
+            values[i++] = Double.parseDouble(tokens.nextToken());
+        }
+
+        GraphicController.getController().setProperty(uid, prop, values);
+        return true;
+    }
+
+    public static Boolean setPropAsBoolean(Integer uid, Integer prop, String propString) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        GraphicController.getController().setProperty(uid, prop, Boolean.parseBoolean(propString));
+        return true;
+    }
+
+    public static Boolean setPropAsBooleanVector(Integer uid, Integer prop, String propString, Integer size) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        Boolean[] values = new Boolean[size];
+
+        StringTokenizer tokens = new StringTokenizer(propString, ",");
+        if (tokens.countTokens() > size) {
+            return false;
+        }
+
+        int i = 0;
+        while (tokens.hasMoreTokens()) {
+            values[i++] = Boolean.parseBoolean(tokens.nextToken());
+        }
+
+        GraphicController.getController().setProperty(uid, prop, values);
+        return true;
+    }
+
+    public static Boolean setPropAsInteger(Integer uid, Integer prop, String propString) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        GraphicController.getController().setProperty(uid, prop, Integer.parseInt(propString));
+        return true;
+    }
+
+    public static Boolean setPropAsIntegerVector(Integer uid, Integer prop, String propString, Integer size) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        Integer[] values = new Integer[size];
+
+        StringTokenizer tokens = new StringTokenizer(propString, ",");
+        if (tokens.countTokens() > size) {
+            return false;
+        }
+
+        int i = 0;
+        while (tokens.hasMoreTokens()) {
+            values[i++] = Integer.parseInt(tokens.nextToken());
+        }
+
+        GraphicController.getController().setProperty(uid, prop, values);
+        return true;
+    }
+
+    public static Boolean setPropAsString(Integer uid, Integer prop, String propString) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        GraphicController.getController().setProperty(uid, prop, propString);
+        return true;
+    }
+
+    public static Boolean setPropAsStringVector(Integer uid, Integer prop, String propString, Integer size) {
+        if (propString == null || propString.equals("")) {
+            return false;
+        }
+
+        String[] values = new String[size];
+
+        StringTokenizer tokens = new StringTokenizer(propString, ",");
+        if (tokens.countTokens() > size) {
+            return false;
+        }
+
+        int i = 0;
+        while (tokens.hasMoreTokens()) {
+            values[i++] = tokens.nextToken();
+        }
+
+        GraphicController.getController().setProperty(uid, prop, values);
+        return true;
+    }
+
+    public static String getFromMap(Map<String, String> map, String field, String defaultValue) {
+        if (map != null) {
+            String ret = map.get(field);
+            if (ret != null) {
+                return ret;
+            }
+        }
+        return defaultValue;
+    }
+
+    public static String getFromMap(Map<String, String> map, String field) {
+        return getFromMap(map, field, "");
+    }
+}
+
diff --git a/scilab/modules/graphic_objects/src/jni/CallXmlLoader.cpp b/scilab/modules/graphic_objects/src/jni/CallXmlLoader.cpp
new file mode 100644 (file)
index 0000000..9eb88fc
--- /dev/null
@@ -0,0 +1,179 @@
+#include "CallXmlLoader.hxx"
+/* Generated by GIWS (version 2.0.2) with command:
+giws --disable-return-size-array --output-dir . --throws-exception-on-error --description-file graphic_objects.giws.xml
+*/
+/*
+
+This is generated code.
+
+This software is a computer program whose purpose is to hide the complexity
+of accessing Java objects/methods from C++ code.
+
+This software is governed by the CeCILL-B license under French law and
+abiding by the rules of distribution of free software.  You can  use,
+modify and/ or redistribute the software under the terms of the CeCILL-B
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info".
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability.
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or
+data to be ensured and,  more generally, to use and operate it in the
+same conditions as regards security.
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL-B license and that you accept its terms.
+*/
+
+namespace org_scilab_modules_graphic_objects {
+
+                // Static declarations (if any)
+                
+// Returns the current env
+
+JNIEnv * CallXmlLoader::getCurrentEnv() {
+JNIEnv * curEnv = NULL;
+jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+if (res != JNI_OK) {
+throw GiwsException::JniException(getCurrentEnv());
+}
+return curEnv;
+}
+// Destructor
+
+CallXmlLoader::~CallXmlLoader() {
+JNIEnv * curEnv = NULL;
+this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+curEnv->DeleteGlobalRef(this->instance);
+curEnv->DeleteGlobalRef(this->instanceClass);
+}
+// Constructors
+CallXmlLoader::CallXmlLoader(JavaVM * jvm_) {
+jmethodID constructObject = NULL ;
+jobject localInstance ;
+jclass localClass ;
+
+const std::string construct="<init>";
+const std::string param="()V";
+jvm=jvm_;
+
+JNIEnv * curEnv = getCurrentEnv();
+
+localClass = curEnv->FindClass( this->className().c_str() ) ;
+if (localClass == NULL) {
+  throw GiwsException::JniClassNotFoundException(curEnv, this->className());
+}
+
+this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+
+/* localClass is not needed anymore */
+curEnv->DeleteLocalRef(localClass);
+
+if (this->instanceClass == NULL) {
+throw GiwsException::JniObjectCreationException(curEnv, this->className());
+}
+
+
+constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
+if(constructObject == NULL){
+throw GiwsException::JniObjectCreationException(curEnv, this->className());
+}
+
+localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
+if(localInstance == NULL){
+throw GiwsException::JniObjectCreationException(curEnv, this->className());
+}
+this->instance = curEnv->NewGlobalRef(localInstance) ;
+if(this->instance == NULL){
+throw GiwsException::JniObjectCreationException(curEnv, this->className());
+}
+/* localInstance not needed anymore */
+curEnv->DeleteLocalRef(localInstance);
+
+                /* Methods ID set to NULL */
+jintLoadjstringjava_lang_StringID=NULL;
+
+
+}
+
+CallXmlLoader::CallXmlLoader(JavaVM * jvm_, jobject JObj) {
+        jvm=jvm_;
+
+        JNIEnv * curEnv = getCurrentEnv();
+
+jclass localClass = curEnv->GetObjectClass(JObj);
+        this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
+        curEnv->DeleteLocalRef(localClass);
+
+        if (this->instanceClass == NULL) {
+throw GiwsException::JniObjectCreationException(curEnv, this->className());
+        }
+
+        this->instance = curEnv->NewGlobalRef(JObj) ;
+        if(this->instance == NULL){
+throw GiwsException::JniObjectCreationException(curEnv, this->className());
+        }
+        /* Methods ID set to NULL */
+        jintLoadjstringjava_lang_StringID=NULL;
+
+
+}
+
+// Generic methods
+
+void CallXmlLoader::synchronize() {
+if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
+throw GiwsException::JniMonitorException(getCurrentEnv(), "CallXmlLoader");
+}
+}
+
+void CallXmlLoader::endSynchronize() {
+if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
+throw GiwsException::JniMonitorException(getCurrentEnv(), "CallXmlLoader");
+}
+}
+// Method(s)
+
+int CallXmlLoader::Load (JavaVM * jvm_, char const* xmlFile){
+
+JNIEnv * curEnv = NULL;
+jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
+jclass cls = initClass(curEnv);
+if ( cls == NULL) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+
+static jmethodID jintLoadjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "Load", "(Ljava/lang/String;)I" ) ;
+if (jintLoadjstringjava_lang_StringID == NULL) {
+throw GiwsException::JniMethodNotFoundException(curEnv, "Load");
+}
+
+jstring xmlFile_ = curEnv->NewStringUTF( xmlFile );
+if (xmlFile != NULL && xmlFile_ == NULL)
+{
+throw GiwsException::JniBadAllocException(curEnv);
+}
+
+
+                        jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintLoadjstringjava_lang_StringID ,xmlFile_));
+                        curEnv->DeleteLocalRef(xmlFile_);
+if (curEnv->ExceptionCheck()) {
+throw GiwsException::JniCallMethodException(curEnv);
+}
+return res;
+
+}
+
+}
diff --git a/scilab/modules/graphic_objects/src/jni/CallXmlLoader.hxx b/scilab/modules/graphic_objects/src/jni/CallXmlLoader.hxx
new file mode 100644 (file)
index 0000000..3dc97e5
--- /dev/null
@@ -0,0 +1,178 @@
+/* Generated by GIWS (version 2.0.2) with command:
+giws --disable-return-size-array --output-dir . --throws-exception-on-error --description-file graphic_objects.giws.xml
+*/
+/*
+
+This is generated code.
+
+This software is a computer program whose purpose is to hide the complexity
+of accessing Java objects/methods from C++ code.
+
+This software is governed by the CeCILL-B license under French law and
+abiding by the rules of distribution of free software.  You can  use,
+modify and/ or redistribute the software under the terms of the CeCILL-B
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info".
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability.
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or
+data to be ensured and,  more generally, to use and operate it in the
+same conditions as regards security.
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL-B license and that you accept its terms.
+*/
+
+
+#ifndef __ORG_SCILAB_MODULES_GRAPHIC_OBJECTS_CALLXMLLOADER__
+#define __ORG_SCILAB_MODULES_GRAPHIC_OBJECTS_CALLXMLLOADER__
+#include <iostream>
+#include <string>
+#include <string.h>
+#include <stdlib.h>
+#include <jni.h>
+
+#include "GiwsException.hxx"
+
+        #if defined(_MSC_VER) /* Defined anyway with Visual */
+            #include <Windows.h>
+        #else
+            typedef signed char byte;
+        #endif
+
+
+#ifndef GIWSEXPORT
+# if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define GIWSEXPORT
+#   else
+#     define GIWSEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if __GNUC__ >= 4
+#     define GIWSEXPORT __attribute__ ((visibility ("default")))
+#   else
+#     define GIWSEXPORT
+#   endif
+# endif
+#endif
+
+namespace org_scilab_modules_graphic_objects {
+class GIWSEXPORT CallXmlLoader {
+
+private:
+JavaVM * jvm;
+
+protected:
+jmethodID jintLoadjstringjava_lang_StringID; // cache method id
+
+
+
+jobject instance;
+jclass instanceClass; // cache class
+
+                       
+// Caching (if any)
+
+
+/**
+* Get the environment matching to the current thread.
+*/
+virtual JNIEnv * getCurrentEnv();
+
+public:
+// Constructor
+/**
+* Create a wrapping of the object from a JNIEnv.
+* It will call the default constructor
+* @param JEnv_ the Java Env
+*/
+CallXmlLoader(JavaVM * jvm_);
+
+/**
+* Create a wrapping of an already existing object from a JNIEnv.
+* The object must have already been instantiated
+* @param JEnv_ the Java Env
+* @param JObj the object
+*/
+CallXmlLoader(JavaVM * jvm_, jobject JObj);
+
+
+/** 
+* This is a fake constructor to avoid the constructor
+* chaining when dealing with extended giws classes 
+*/
+#ifdef FAKEGIWSDATATYPE
+CallXmlLoader(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
+#endif
+
+// Destructor
+~CallXmlLoader();
+
+// Generic method
+// Synchronization methods
+/**
+* Enter monitor associated with the object.
+* Equivalent of creating a "synchronized(obj)" scope in Java.
+*/
+void synchronize();
+
+/**
+* Exit monitor associated with the object.
+* Equivalent of ending a "synchronized(obj)" scope.
+*/
+void endSynchronize();
+
+// Methods
+static int Load(JavaVM * jvm_, char const* xmlFile);
+
+
+                        /**
+                        * Get class name to use for static methods
+                        * @return class name to use for static methods
+                        */
+                        
+                static const std::string className()
+                {
+                return "org/scilab/modules/graphic_objects/CallXmlLoader";
+                }
+                
+
+                        /**
+                        * Get class to use for static methods
+                        * @return class to use for static methods
+                        */
+                        
+                static jclass initClass(JNIEnv * curEnv)
+                {
+                    static jclass cls = 0;
+
+                    if (cls == 0)
+                    {
+                        jclass _cls = curEnv->FindClass(className().c_str());
+                        if (_cls)
+                        {
+                            cls = static_cast<jclass>(curEnv->NewGlobalRef(_cls));
+                        }
+                    }
+
+                    return cls;
+                 }
+                
+};
+
+
+}
+#endif
index ac71dda..ebc24eb 100644 (file)
             <parameter name="isline" type="int"/>
         </method>
     </object>
+    <object name="CallXmlLoader">
+        <method name="Load" returnType="int" modifier="static">
+            <parameter name="xmlFile" type="String"/>
+        </method>
+    </object>
     <object name="CallGraphicController">
         <method name="deleteGraphicObject" returnType="void" modifier="static">
             <parameter name="id" type="int"/>
index eacbb44..0cf043a 100755 (executable)
@@ -398,3 +398,8 @@ __GO_UI_GRID_GRID__
 __GO_UI_GRID_PADDING__
 
 __GO_UI_BORDER_POSITION__
+
+
+__GO_GRID_OPT_GRID__
+__GO_GRID_OPT_PADDING__
+__GO_BORDER_OPT_PADDING__
index c110a36..711324b 100644 (file)
@@ -331,6 +331,8 @@ src/c/getHandleProperty/set_layout_property.c \
 src/c/getHandleProperty/get_constraints_property.c \
 src/c/getHandleProperty/set_constraints_property.c \
 src/c/getHandleProperty/set_rect_property.c \
+src/c/getHandleProperty/get_layout_options_property.c \
+src/c/getHandleProperty/set_layout_options_property.c \
 src/c/DefaultCommandArg.c \
 src/c/Axes.c \
 src/c/sciMatrix.c \
index fccf85c..889503e 100644 (file)
@@ -478,6 +478,8 @@ am__objects_1 = src/c/libscigraphics_algo_la-GetCommandArg.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_constraints_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-set_constraints_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-set_rect_property.lo \
+       src/c/getHandleProperty/libscigraphics_algo_la-get_layout_options_property.lo \
+       src/c/getHandleProperty/libscigraphics_algo_la-set_layout_options_property.lo \
        src/c/libscigraphics_algo_la-DefaultCommandArg.lo \
        src/c/libscigraphics_algo_la-Axes.lo \
        src/c/libscigraphics_algo_la-sciMatrix.lo \
@@ -1258,6 +1260,8 @@ src/c/getHandleProperty/set_layout_property.c \
 src/c/getHandleProperty/get_constraints_property.c \
 src/c/getHandleProperty/set_constraints_property.c \
 src/c/getHandleProperty/set_rect_property.c \
+src/c/getHandleProperty/get_layout_options_property.c \
+src/c/getHandleProperty/set_layout_options_property.c \
 src/c/DefaultCommandArg.c \
 src/c/Axes.c \
 src/c/sciMatrix.c \
@@ -2535,6 +2539,12 @@ src/c/getHandleProperty/libscigraphics_algo_la-set_constraints_property.lo:  \
 src/c/getHandleProperty/libscigraphics_algo_la-set_rect_property.lo:  \
        src/c/getHandleProperty/$(am__dirstamp) \
        src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
+src/c/getHandleProperty/libscigraphics_algo_la-get_layout_options_property.lo:  \
+       src/c/getHandleProperty/$(am__dirstamp) \
+       src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
+src/c/getHandleProperty/libscigraphics_algo_la-set_layout_options_property.lo:  \
+       src/c/getHandleProperty/$(am__dirstamp) \
+       src/c/getHandleProperty/$(DEPDIR)/$(am__dirstamp)
 src/c/libscigraphics_algo_la-DefaultCommandArg.lo:  \
        src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libscigraphics_algo_la-Axes.lo: src/c/$(am__dirstamp) \
@@ -3045,6 +3055,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_labels_font_color_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_labels_font_size_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_labels_font_style_property.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_layout_options_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_layout_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_legend_location_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_light_type_property.Plo@am__quote@
@@ -3201,6 +3212,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_label_font_style_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_labels_font_color_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_labels_font_size_property.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_layout_options_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_layout_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_legend_location_property.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_light_type_property.Plo@am__quote@
@@ -5439,6 +5451,20 @@ src/c/getHandleProperty/libscigraphics_algo_la-set_rect_property.lo: src/c/getHa
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-set_rect_property.lo `test -f 'src/c/getHandleProperty/set_rect_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/set_rect_property.c
 
+src/c/getHandleProperty/libscigraphics_algo_la-get_layout_options_property.lo: src/c/getHandleProperty/get_layout_options_property.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/getHandleProperty/libscigraphics_algo_la-get_layout_options_property.lo -MD -MP -MF src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_layout_options_property.Tpo -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_layout_options_property.lo `test -f 'src/c/getHandleProperty/get_layout_options_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_layout_options_property.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_layout_options_property.Tpo src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-get_layout_options_property.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getHandleProperty/get_layout_options_property.c' object='src/c/getHandleProperty/libscigraphics_algo_la-get_layout_options_property.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-get_layout_options_property.lo `test -f 'src/c/getHandleProperty/get_layout_options_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/get_layout_options_property.c
+
+src/c/getHandleProperty/libscigraphics_algo_la-set_layout_options_property.lo: src/c/getHandleProperty/set_layout_options_property.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/getHandleProperty/libscigraphics_algo_la-set_layout_options_property.lo -MD -MP -MF src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_layout_options_property.Tpo -c -o src/c/getHandleProperty/libscigraphics_algo_la-set_layout_options_property.lo `test -f 'src/c/getHandleProperty/set_layout_options_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/set_layout_options_property.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_layout_options_property.Tpo src/c/getHandleProperty/$(DEPDIR)/libscigraphics_algo_la-set_layout_options_property.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getHandleProperty/set_layout_options_property.c' object='src/c/getHandleProperty/libscigraphics_algo_la-set_layout_options_property.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/getHandleProperty/libscigraphics_algo_la-set_layout_options_property.lo `test -f 'src/c/getHandleProperty/set_layout_options_property.c' || echo '$(srcdir)/'`src/c/getHandleProperty/set_layout_options_property.c
+
 src/c/libscigraphics_algo_la-DefaultCommandArg.lo: src/c/DefaultCommandArg.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscigraphics_algo_la-DefaultCommandArg.lo -MD -MP -MF src/c/$(DEPDIR)/libscigraphics_algo_la-DefaultCommandArg.Tpo -c -o src/c/libscigraphics_algo_la-DefaultCommandArg.lo `test -f 'src/c/DefaultCommandArg.c' || echo '$(srcdir)/'`src/c/DefaultCommandArg.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscigraphics_algo_la-DefaultCommandArg.Tpo src/c/$(DEPDIR)/libscigraphics_algo_la-DefaultCommandArg.Plo
index 2518c08..f6d4b80 100644 (file)
@@ -299,6 +299,7 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     <ClCompile Include="src\c\getHandleProperty\get_labels_font_color_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_labels_font_size_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_labels_font_style_property.c" />
+    <ClCompile Include="src\c\getHandleProperty\get_layout_options_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_layout_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_legend_location_property.c" />
     <ClCompile Include="src\c\getHandleProperty\get_light_type_property.c" />
@@ -352,6 +353,7 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     <ClCompile Include="src\c\getHandleProperty\set_grid_style_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_grid_thickness_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_infobar_property.c" />
+    <ClCompile Include="src\c\getHandleProperty\set_layout_options_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_layout_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_light_type_property.c" />
     <ClCompile Include="src\c\getHandleProperty\set_mark_offset_property.c" />
index 9af2d0d..a218933 100644 (file)
     <ClCompile Include="src\c\getHandleProperty\set_rect_property.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\c\getHandleProperty\set_layout_options_property.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\c\getHandleProperty\get_layout_options_property.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\Axes.h">
diff --git a/scilab/modules/graphics/macros/%BorderCo_i_h.sci b/scilab/modules/graphics/macros/%BorderCo_i_h.sci
new file mode 100644 (file)
index 0000000..7a270bc
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %BorderCo_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%BorderCo_i_h",1));
+    end
+endfunction
diff --git a/scilab/modules/graphics/macros/%GridBagC_i_h.sci b/scilab/modules/graphics/macros/%GridBagC_i_h.sci
new file mode 100644 (file)
index 0000000..0a2df4f
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %GridBagC_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%GridBagC_i_h",1));
+    end
+endfunction
diff --git a/scilab/modules/graphics/macros/%GridCons_i_h.sci b/scilab/modules/graphics/macros/%GridCons_i_h.sci
new file mode 100644 (file)
index 0000000..87747e1
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %GridCons_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%GridCons_i_h",1));
+    end
+endfunction
index 10394b2..7d3392c 100644 (file)
@@ -7,6 +7,5 @@
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 function %GridCons_p(t)
     printf("Grid Layout\n");
-    printf("  Grid    : %s\n", sci2exp(t.grid));
-    printf("  Padding : %s\n", sci2exp(t.padding));
+    printf("  No option\n");
 endfunction
diff --git a/scilab/modules/graphics/macros/%NoLayout_i_h.sci b/scilab/modules/graphics/macros/%NoLayout_i_h.sci
new file mode 100644 (file)
index 0000000..a8b377d
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %NoLayout_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%NoLayout_i_h",1));
+    end
+endfunction
index 6f59873..de57a16 100644 (file)
@@ -1,3 +1,11 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 function %NoLayout_p(t)
     printf("NoLayout\n");
+    printf("  No option\n");
 endfunction
diff --git a/scilab/modules/graphics/macros/%OptBorde_i_h.sci b/scilab/modules/graphics/macros/%OptBorde_i_h.sci
new file mode 100644 (file)
index 0000000..ae02b29
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %OptBorde_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptBorde_i_h",1));
+    end
+endfunction
diff --git a/scilab/modules/graphics/macros/%OptBorde_p.sci b/scilab/modules/graphics/macros/%OptBorde_p.sci
new file mode 100644 (file)
index 0000000..2937fbd
--- /dev/null
@@ -0,0 +1,11 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function %OptBorde_p(t)
+    printf("Border Layout Options\n");
+    printf("  Padding : %s\n", sci2exp(t.padding));
+endfunction
diff --git a/scilab/modules/graphics/macros/%OptGridB_i_h.sci b/scilab/modules/graphics/macros/%OptGridB_i_h.sci
new file mode 100644 (file)
index 0000000..86c1c67
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %OptGridB_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptGridB_i_h",1));
+    end
+endfunction
diff --git a/scilab/modules/graphics/macros/%OptGridB_p.sci b/scilab/modules/graphics/macros/%OptGridB_p.sci
new file mode 100644 (file)
index 0000000..463d0fe
--- /dev/null
@@ -0,0 +1,11 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function %OptGridB_p(t)
+    printf("Gridbag Layout Options\n");
+    printf("  No option\n");
+endfunction
diff --git a/scilab/modules/graphics/macros/%OptGrid_i_h.sci b/scilab/modules/graphics/macros/%OptGrid_i_h.sci
new file mode 100644 (file)
index 0000000..2bd04cf
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %OptGrid_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptGrid_i_h",1));
+    end
+endfunction
diff --git a/scilab/modules/graphics/macros/%OptGrid_p.sci b/scilab/modules/graphics/macros/%OptGrid_p.sci
new file mode 100644 (file)
index 0000000..17909ba
--- /dev/null
@@ -0,0 +1,12 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function %OptGrid_p(t)
+    printf("Grid Layout Options\n");
+    printf("  Grid    : %s\n", sci2exp(t.grid));
+    printf("  Padding : %s\n", sci2exp(t.padding));
+endfunction
diff --git a/scilab/modules/graphics/macros/%OptNoLay_i_h.sci b/scilab/modules/graphics/macros/%OptNoLay_i_h.sci
new file mode 100644 (file)
index 0000000..fe1772d
--- /dev/null
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function h = %OptNoLay_i_h(i,v,h)
+    if type(i)==10 then
+        set(h,i,v)
+    else
+        error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptNoLay_i_h",1));
+    end
+endfunction
diff --git a/scilab/modules/graphics/macros/%OptNoLay_p.sci b/scilab/modules/graphics/macros/%OptNoLay_p.sci
new file mode 100644 (file)
index 0000000..ca7796c
--- /dev/null
@@ -0,0 +1,11 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function %OptNoLay_p(t)
+    printf("No Layout Options\n");
+    printf("  No option\n");
+endfunction
index 67715e3..b518260 100755 (executable)
@@ -297,6 +297,11 @@ function %h_p(h)
             // =====================================================================
 
         case "Figure"
+            l = h.layout_options;
+            if type(l) == 16 then //tlist
+                l = l(1);
+                l = l(1);
+            end
             u=h.user_data
             t=[t;
             "children: "+fmtchildren(h.children)
@@ -329,6 +334,7 @@ function %h_p(h)
             "infobar_visible = "+sci2exp(h.infobar_visible)
             "dockable = "+sci2exp(h.dockable)
             "layout = "+sci2exp(h.layout)
+            "layout_options = "+sci2exp(l)
             "tag = "+sci2exp(h.tag)
             ]
 
@@ -941,6 +947,16 @@ function %h_p(h)
         case "uicontrol"
 
             u=h.user_data;
+            c = h.constraints;
+            if type(c) == 16 then //tlist
+                c = c(1);
+                c = c(1);
+            end
+            l = h.layout_options;
+            if type(l) == 16 then //tlist
+                l = l(1);
+                l = l(1);
+            end
             if h.style == "tabgroup" then
                 t=[t;
                 "Parent: "+h.parent.type
@@ -953,6 +969,7 @@ function %h_p(h)
                 "Callback = "+h.callback
                 "Callback_Type = "+sci2exp(h.callback_type,0)
                 "Layout = "+sci2exp(h.layout)
+                "Layout_options = "+sci2exp(l)
                 "Constraints = "+sci2exp(h.constraints)
                 "Margins = "+sci2exp(h.margins)
                 "Value = "+sci2exp(h.value)
@@ -973,17 +990,13 @@ function %h_p(h)
                 "Callback = "+h.callback
                 "Callback_Type = "+sci2exp(h.callback_type,0)
                 "Layout = "+sci2exp(h.layout)
+                "Layout_options = "+sci2exp(l)
                 "Constraints = "+sci2exp(h.constraints)
                 "Margins = "+sci2exp(h.margins)
                 "Userdata = "+fmtuser_data(u)
                 "Tag = "+h.tag
                 ]
             else
-                c = h.constraints;
-                if type(c) == 16 then //tlist
-                    c = c(1);
-                    c = c(1);
-                end
                 t=[t;
                 "Parent: "+h.parent.type
                 "Children: "+fmtchildren(h.children)
@@ -1012,6 +1025,7 @@ function %h_p(h)
                 "Callback = "+h.callback
                 "Callback_Type = "+sci2exp(h.callback_type,0)
                 "Layout = "+sci2exp(h.layout)
+                "Layout_options = "+sci2exp(l)
                 "Constraints = "+sci2exp(c)
                 "Margins = "+sci2exp(h.margins)
                 "Userdata = "+fmtuser_data(u)
index a84533f..12a194d 100644 (file)
@@ -18,8 +18,10 @@ function ret = createConstraints(constType, varargin)
     end
 
     ret = [];
-    if constType == "nolayout" then
+    if constType == "nolayout" | constType == "none" then
         ret = tlist(["NoLayoutConstraint"]);
+    elseif constType == "grid" then
+        ret = tlist(["GridConstraints"]);
     elseif constType == "border" then
         arg1 = "center"
         if size(varargin) <> 1 then
@@ -32,25 +34,6 @@ function ret = createConstraints(constType, varargin)
         end
 
         ret = tlist(["BorderConstraint","position"], arg1);
-    elseif constType == "grid" then
-        arg1 = [0 0];
-        arg2 = [0 0];
-        if size(varargin) <> [1, 2] then
-            error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "createConstraints", 2, 3));
-        end
-
-        arg1 = varargin(1);
-        if typeof(arg1) <> "constant" | size(arg1, "*") <> 2 then
-            error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 2));
-        end
-
-        if size(varargin) > 1 then
-            arg2 = varargin(2);
-            if typeof(arg2) <> "constant" | size(arg2, "*") <> 2 then
-                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 3));
-            end
-        end
-        ret = tlist(["GridConstraints","grid","padding"], arg1, arg2);
     elseif constType == "gridbag" then
         arg1 = [0 0 0 0];
         arg2 = [0 0];
@@ -96,5 +79,7 @@ function ret = createConstraints(constType, varargin)
         end
 
         ret = tlist(["GridBagConstraints","grid","weight","fill","anchor","padding"], arg1, arg2, arg3, arg4, arg5);
+    else
+        error(999, msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "createConstraints", 1, "none/nolayout, border, grid, gridbag"));
     end
 endfunction
diff --git a/scilab/modules/graphics/macros/createLayoutOptions.sci b/scilab/modules/graphics/macros/createLayoutOptions.sci
new file mode 100644 (file)
index 0000000..079fa51
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+//
+//
+
+function ret = createLayoutOptions(constType, varargin)
+    [lhs,rhs]=argn(0)
+
+    if rhs < 1 then
+        error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected."), "createLayoutOptions", 1));
+    end
+
+    ret = [];
+    if constType == "nolayout" | constType == "none" then
+        ret = tlist(["OptNoLayout"]);
+    elseif constType == "border" then
+        arg1 = [0 0]
+
+        //hpad, vpad
+        if size(varargin) > 0 then
+            arg1 = varargin(1);
+            if typeof(arg1) <> "constant" | size(arg1, "*") <> 2 then
+                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 2));
+            end
+        end
+
+        ret = tlist(["OptBorder","padding"], arg1);
+    elseif constType == "grid" then
+        arg1 = [0 0];
+        arg2 = [0 0];
+
+        if size(varargin) > 0 then
+            arg1 = varargin(1);
+            if typeof(arg1) <> "constant" | size(arg1, "*") <> 2 then
+                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 2));
+            end
+        end
+
+        if size(varargin) > 1 then
+            arg2 = varargin(2);
+            if typeof(arg2) <> "constant" | size(arg2, "*") <> 2 then
+                error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 3));
+            end
+        end
+        ret = tlist(["OptGrid","grid","padding"], arg1, arg2);
+    elseif constType == "gridbag" then
+        ret = tlist(["OptGridBag"]);
+    else
+        error(999, msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "createLayoutOptions", 1, "none/nolayout, border, grid, gridbag"));
+    end
+endfunction
index cefe23e..0154873 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2014 - SCilab Enterprises - antoine ELIAS
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
index ff02c18..19b51b6 100755 (executable)
@@ -239,7 +239,8 @@ static getHashTableCouple propertyGetTable[] =
     {"dockable", get_dockable_property},
     {"layout", get_layout_property},
     {"constraints", get_constraints_property},
-    {"rect", get_rect_property}
+    {"rect", get_rect_property},
+    {"layout_options", get_layout_options_property}
 };
 
 /*--------------------------------------------------------------------------*/
index 7438a87..7c20008 100755 (executable)
@@ -240,7 +240,8 @@ static setHashTableCouple propertySetTable[] =
     {"dockable", set_dockable_property},
     {"layout", set_layout_property},
     {"constraints", set_constraints_property},
-    {"rect", set_rect_property}
+    {"rect", set_rect_property},
+    {"layout_options", set_layout_options_property}
 };
 
 /*--------------------------------------------------------------------------*/
index 06dae28..21facfa 100755 (executable)
@@ -212,5 +212,6 @@ int get_dockable_property(void* _pvCtx, int iObjUID);
 int get_layout_property(void* _pvCtx, int iObjUID);
 int get_constraints_property(void* _pvCtx, int iObjUID);
 int get_rect_property(void* _pvCtx, int iObjUID);
+int get_layout_options_property(void* _pvCtx, int iObjUID);
 
 #endif /* _GET_HANDLE_PROPERTY_H_ */
index 7f8e4aa..223ccfb 100644 (file)
@@ -63,37 +63,8 @@ int get_constraints_property(void* _pvCtx, int iObjUID)
         break;
         case LAYOUT_GRID :
         {
-            char * variable_tlist[] = {"GridConstraints", "grid", "padding"};
-            returnedList * tList = createReturnedList(2, variable_tlist);
-            double pdblGrid[2];
-            double pdblPadding[2];
-            int* piGrid = NULL;
-            int* piPadding = NULL;
-
-            getGraphicObjectProperty(iObjUID, __GO_UI_GRID_GRID__, jni_int_vector, (void **)&piGrid);
-            if (pdblGrid == NULL)
-            {
-                Scierror(999, _("'%s' property does not exist for this handle.\n"), "constraints");
-                return -1;
-            }
-
-            getGraphicObjectProperty(iObjUID, __GO_UI_GRID_PADDING__, jni_int_vector, (void **)&piPadding);
-            if (pdblGrid == NULL)
-            {
-                Scierror(999, _("'%s' property does not exist for this handle.\n"), "constraints");
-                return -1;
-            }
-
-            //convert to double
-            pdblGrid[0] = (double)piGrid[0];
-            pdblGrid[1] = (double)piGrid[1];
-
-            pdblPadding[0] = (double)piPadding[0];
-            pdblPadding[1] = (double)piPadding[1];
-
-            //add to TList
-            addRowVectorToReturnedList(tList, pdblGrid, 2);
-            addRowVectorToReturnedList(tList, pdblPadding, 2);
+            char * variable_tlist[] = {"GridConstraints"};
+            returnedList * tList = createReturnedList(0, variable_tlist);
             destroyReturnedList(tList);
         }
         break;
diff --git a/scilab/modules/graphics/src/c/getHandleProperty/get_layout_options_property.c b/scilab/modules/graphics/src/c/getHandleProperty/get_layout_options_property.c
new file mode 100644 (file)
index 0000000..1190012
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+/*------------------------------------------------------------------------*/
+/* file: get_figure_name_property.c                                       */
+/* desc : function to retrieve in Scilab the figure_name field of a       */
+/*        handle                                                          */
+/*------------------------------------------------------------------------*/
+
+#include <string.h>
+#include "returnProperty.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "SetPropertyStatus.h"
+
+#include "getGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+#include "LayoutType.h"
+#include "BorderLayoutType.h"
+#include "FillType.h"
+#include "AnchorType.h"
+#include "returnPropertyList.h"
+/*------------------------------------------------------------------------*/
+int get_layout_options_property(void* _pvCtx, int iObjUID)
+{
+    int iLayout = 0;
+    int* piLayout = &iLayout;
+
+    getGraphicObjectProperty(iObjUID, __GO_LAYOUT__, jni_int, (void **)&piLayout);
+    if (piLayout == NULL)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "layout_options");
+        return -1;
+    }
+
+    switch (iLayout)
+    {
+        default:
+        case LAYOUT_NONE :
+        {
+            char * variable_tlist[] = {"OptNoLayout"};
+            returnedList * tList = createReturnedList(0, variable_tlist);
+            destroyReturnedList(tList);
+        }
+        break;
+        case LAYOUT_GRID :
+        {
+            char * variable_tlist[] = {"OptGrid", "grid", "padding"};
+            returnedList * tList = createReturnedList(2, variable_tlist);
+            double pdblGrid[2];
+            double pdblPadding[2];
+            int* piGrid = NULL;
+            int* piPadding = NULL;
+
+            getGraphicObjectProperty(iObjUID, __GO_GRID_OPT_GRID__, jni_int_vector, (void **)&piGrid);
+            if (pdblGrid == NULL)
+            {
+                Scierror(999, _("'%s' property does not exist for this handle.\n"), "layout_options");
+                return -1;
+            }
+
+            getGraphicObjectProperty(iObjUID, __GO_GRID_OPT_PADDING__, jni_int_vector, (void **)&piPadding);
+            if (pdblGrid == NULL)
+            {
+                Scierror(999, _("'%s' property does not exist for this handle.\n"), "layout_options");
+                return -1;
+            }
+
+            //convert to double
+            pdblGrid[0] = (double)piGrid[0];
+            pdblGrid[1] = (double)piGrid[1];
+
+            pdblPadding[0] = (double)piPadding[0];
+            pdblPadding[1] = (double)piPadding[1];
+
+            //add to TList
+            addRowVectorToReturnedList(tList, pdblGrid, 2);
+            addRowVectorToReturnedList(tList, pdblPadding, 2);
+            destroyReturnedList(tList);
+        }
+        break;
+        case LAYOUT_BORDER :
+        {
+            char * variable_tlist[] = {"OptBorder", "padding"};
+            returnedList * tList = createReturnedList(1, variable_tlist);
+            double pdblPadding[2];
+            int* piPadding = NULL;
+
+            getGraphicObjectProperty(iObjUID, __GO_BORDER_OPT_PADDING__, jni_int_vector, (void **)&piPadding);
+            if (piPadding == NULL)
+            {
+                Scierror(999, _("'%s' property does not exist for this handle.\n"), "layout_options");
+                return -1;
+            }
+
+            //convert to double
+            pdblPadding[0] = (double)piPadding[0];
+            pdblPadding[1] = (double)piPadding[1];
+
+            //add to TList
+            addRowVectorToReturnedList(tList, pdblPadding, 2);
+            destroyReturnedList(tList);
+        }
+        break;
+        case LAYOUT_GRIDBAG :
+        {
+            char * variable_tlist[] = {"OptGridBag"};
+            returnedList * tList = createReturnedList(0, variable_tlist);
+            destroyReturnedList(tList);
+        }
+        break;
+    }
+
+    return 0;
+}
index dd6f076..6420a0b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2014 - SCilab Enterprises - antoine ELIAS
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
index add8146..25d5608 100644 (file)
@@ -31,7 +31,6 @@ int get_rect_property(void* _pvCtx, int iObjUID)
 {
     double * rect = NULL;
     double _rect[4];
-    double x;
 
     getGraphicObjectProperty(iObjUID, __GO_DATA_MODEL_MATPLOT_BOUNDS__, jni_double_vector, (void **)&rect);
 
index a8442fe..43ce041 100755 (executable)
@@ -213,5 +213,6 @@ int set_dockable_property(void* _pvCtx, int iObj, void* _pvData, int valueType,
 int set_layout_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_constraints_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 int set_rect_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
+int set_layout_options_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol);
 
 #endif /* _SET_HANDLE_PROPERTY_H_ */
index 908a65e..dba32a4 100644 (file)
@@ -123,51 +123,7 @@ int set_constraints_property(void* _pvCtx, int iObjUID, void* _pvData, int value
         }
         else if (strcmp(pstType, "GridConstraints") == 0)
         {
-            //arg2 -> double 1x2 -> int 1*2
-            //arg3 -> double 1x2 -> int 1*2
-            int* piAddr2 = NULL;
-            int iRows2 = 0;
-            int iCols2 = 0;
-            double* pdblGrid = NULL;
-            int piGrid[2];
-
-            int* piAddr3 = NULL;
-            int iRows3 = 0;
-            int iCols3 = 0;
-            double* pdblPadding = NULL;
-            int piPadding[2];
-
-            sciErr = getListItemAddress(_pvCtx, piAddrList, 2, &piAddr2);
-            if (sciErr.iErr)
-            {
-                return SET_PROPERTY_ERROR;
-            }
-
-            sciErr = getMatrixOfDouble(_pvCtx, piAddr2, &iRows2, &iCols2, &pdblGrid);
-            if (sciErr.iErr)
-            {
-                return SET_PROPERTY_ERROR;
-            }
-
-            sciErr = getListItemAddress(_pvCtx, piAddrList, 3, &piAddr3);
-            if (sciErr.iErr)
-            {
-                return SET_PROPERTY_ERROR;
-            }
-
-            sciErr = getMatrixOfDouble(_pvCtx, piAddr3, &iRows3, &iCols3, &pdblPadding);
-            if (sciErr.iErr)
-            {
-                return SET_PROPERTY_ERROR;
-            }
-
-            piGrid[0] = (int)pdblGrid[0];
-            piGrid[1] = (int)pdblGrid[1];
-            piPadding[0] = (int)pdblPadding[0];
-            piPadding[1] = (int)pdblPadding[1];
-
-            setGraphicObjectProperty(iObjUID, __GO_UI_GRID_GRID__, piGrid, jni_int_vector, 2);
-            setGraphicObjectProperty(iObjUID, __GO_UI_GRID_PADDING__, piPadding, jni_int_vector, 2);
+            return clearConstraints(iObjUID);
         }
         else if (strcmp(pstType, "GridBagConstraints") == 0)
         {
@@ -362,27 +318,13 @@ int set_constraints_property(void* _pvCtx, int iObjUID, void* _pvData, int value
 int clearConstraints(int iObjUID)
 {
     //reset all constraints data in model
-    int pi[6] = {0, 0, 0, 0, 0, 0};
+    int pi[4] = {0, 0, 0, 0};
     double pdbl[2] = {0, 0};
     int iPos = BORDER_CENTER;
     int iFill = FILL_NONE;
     int iAnchor = ANCHOR_CENTER;
     BOOL status = FALSE;
 
-    status = setGraphicObjectProperty(iObjUID, __GO_UI_GRID_GRID__, pi, jni_int_vector, 2);
-    if (status != TRUE)
-    {
-        Scierror(999, _("'%s' property does not exist for this handle.\n"), "contraints");
-        return SET_PROPERTY_ERROR;
-    }
-
-    status = setGraphicObjectProperty(iObjUID, __GO_UI_GRID_PADDING__, pi, jni_int_vector, 2);
-    if (status != TRUE)
-    {
-        Scierror(999, _("'%s' property does not exist for this handle.\n"), "contraints");
-        return SET_PROPERTY_ERROR;
-    }
-
     status = setGraphicObjectProperty(iObjUID, __GO_UI_BORDER_POSITION__, &iPos, jni_int, 1);
     if (status != TRUE)
     {
diff --git a/scilab/modules/graphics/src/c/getHandleProperty/set_layout_options_property.c b/scilab/modules/graphics/src/c/getHandleProperty/set_layout_options_property.c
new file mode 100644 (file)
index 0000000..80d04ff
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+/*------------------------------------------------------------------------*/
+/* file: set_figure_name_property.c                                       */
+/* desc : function to modify in Scilab the figure_name field of           */
+/*        a handle                                                        */
+/*------------------------------------------------------------------------*/
+#include "api_scilab.h"
+#include "MALLOC.h"
+#include "freeArrayOfString.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "SetPropertyStatus.h"
+#include "sci_types.h"
+#include "stricmp.h"
+
+#include "setGraphicObjectProperty.h"
+#include "getGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+#include "LayoutType.h"
+#include "BorderLayoutType.h"
+#include "FillType.h"
+#include "AnchorType.h"
+/*------------------------------------------------------------------------*/
+int clearLayoutOptions(int iObjUID);
+/*------------------------------------------------------------------------*/
+int set_layout_options_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol)
+{
+
+    //[] or tlist
+    if (valueType == sci_matrix)
+    {
+        return clearLayoutOptions(iObjUID);
+    }
+    else
+    {
+        SciErr sciErr;
+        int i = 0;
+        int* piAddrList = (int*)_pvData;
+
+        int* piAddr = NULL;
+        int iRows = 0;
+        int iCols = 0;
+        char** pstField = NULL;
+        char* pstType = NULL;
+
+        sciErr = getListItemAddress(_pvCtx, piAddrList, 1, &piAddr);
+        if (sciErr.iErr)
+        {
+            return SET_PROPERTY_ERROR;
+        }
+
+        if (getAllocatedMatrixOfString(_pvCtx, piAddr, &iRows, &iCols, &pstField))
+        {
+            return SET_PROPERTY_ERROR;
+        }
+
+        pstType = pstField[0];
+        //depend of kind of tlist
+        if (strcmp(pstType, "OptNoLayout") == 0)
+        {
+            return clearLayoutOptions(iObjUID);
+        }
+        else if (strcmp(pstType, "OptBorder") == 0)
+        {
+            //arg2 -> double 1x2 -> int 1*2
+            int* piAddr2 = NULL;
+            int iRows2 = 0;
+            int iCols2 = 0;
+            double* pdblPadding = NULL;
+            int piPadding[2];
+
+            sciErr = getListItemAddress(_pvCtx, piAddrList, 2, &piAddr2);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
+            sciErr = getMatrixOfDouble(_pvCtx, piAddr2, &iRows2, &iCols2, &pdblPadding);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
+            piPadding[0] = (int)pdblPadding[0];
+            piPadding[1] = (int)pdblPadding[1];
+
+            setGraphicObjectProperty(iObjUID, __GO_BORDER_OPT_PADDING__, piPadding, jni_int_vector, 2);
+        }
+        else if (strcmp(pstType, "OptGrid") == 0)
+        {
+            //arg2 -> double 1x2 -> int 1*2
+            //arg3 -> double 1x2 -> int 1*2
+            int* piAddr2 = NULL;
+            int iRows2 = 0;
+            int iCols2 = 0;
+            double* pdblGrid = NULL;
+            int piGrid[2];
+
+            int* piAddr3 = NULL;
+            int iRows3 = 0;
+            int iCols3 = 0;
+            double* pdblPadding = NULL;
+            int piPadding[2];
+
+            sciErr = getListItemAddress(_pvCtx, piAddrList, 2, &piAddr2);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
+            sciErr = getMatrixOfDouble(_pvCtx, piAddr2, &iRows2, &iCols2, &pdblGrid);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
+            sciErr = getListItemAddress(_pvCtx, piAddrList, 3, &piAddr3);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
+            sciErr = getMatrixOfDouble(_pvCtx, piAddr3, &iRows3, &iCols3, &pdblPadding);
+            if (sciErr.iErr)
+            {
+                return SET_PROPERTY_ERROR;
+            }
+
+            piGrid[0] = (int)pdblGrid[0];
+            piGrid[1] = (int)pdblGrid[1];
+            piPadding[0] = (int)pdblPadding[0];
+            piPadding[1] = (int)pdblPadding[1];
+
+            setGraphicObjectProperty(iObjUID, __GO_GRID_OPT_GRID__, piGrid, jni_int_vector, 2);
+            setGraphicObjectProperty(iObjUID, __GO_GRID_OPT_PADDING__, piPadding, jni_int_vector, 2);
+        }
+        else if (strcmp(pstType, "OptGridBag") == 0)
+        {
+            return clearLayoutOptions(iObjUID);
+        }
+        else
+        {
+            freeAllocatedMatrixOfString(iRows, iCols, pstField);
+            return SET_PROPERTY_ERROR;
+        }
+
+        freeAllocatedMatrixOfString(iRows, iCols, pstField);
+    }
+
+    return SET_PROPERTY_SUCCEED;
+}
+
+int clearLayoutOptions(int iObjUID)
+{
+    //reset all constraints data in model
+    int pi[2] = {0, 0};
+    BOOL status = FALSE;
+
+    status = setGraphicObjectProperty(iObjUID, __GO_GRID_OPT_GRID__, pi, jni_int_vector, 2);
+    if (status != TRUE)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "layout_options");
+        return SET_PROPERTY_ERROR;
+    }
+
+    status = setGraphicObjectProperty(iObjUID, __GO_GRID_OPT_PADDING__, pi, jni_int_vector, 2);
+    if (status != TRUE)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "layout_options");
+        return SET_PROPERTY_ERROR;
+    }
+
+    status = setGraphicObjectProperty(iObjUID, __GO_BORDER_OPT_PADDING__, pi, jni_int_vector, 2);
+    if (status != TRUE)
+    {
+        Scierror(999, _("'%s' property does not exist for this handle.\n"), "layout_options");
+        return SET_PROPERTY_ERROR;
+    }
+
+    return SET_PROPERTY_SUCCEED;
+}
\ No newline at end of file
index 4417027..0634598 100644 (file)
@@ -12,6 +12,7 @@ function fig = createFigure(layout)
     fig.menubar_visible = "off";
     fig.infobar_visible = "off";
 endfunction
+//constraints
 //no border
 createFigure("none");
 c = createConstraints("nolayout");
@@ -38,10 +39,7 @@ assert_checkequal(u.constraints, c);
 delete(gcf());
 //grid layout
 createFigure("grid");
-c = createConstraints("grid", [1 2]);
-u = uicontrol("constraints", c);
-assert_checkequal(u.constraints, c);
-c = createConstraints("grid", [1 2], [10 20]);
+c = createConstraints("grid");
 u = uicontrol("constraints", c);
 assert_checkequal(u.constraints, c);
 delete(gcf());
@@ -63,3 +61,30 @@ c = createConstraints("gridbag", [1 2 3 4], [1.1 2.1], "both", "lower_left", [10
 u = uicontrol("constraints", c);
 assert_checkequal(u.constraints, c);
 delete(gcf());
+// options
+createFigure("none");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("nolayout"));
+f.layout_options = createLayoutOptions("none");
+assert_checkequal(f.layout_options, createLayoutOptions("none"));
+delete(gcf());
+createFigure("gridbag");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("gridbag"));
+f.layout_options = createLayoutOptions("gridbag");
+assert_checkequal(f.layout_options, createLayoutOptions("gridbag"));
+delete(gcf());
+createFigure("border");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("border"));
+f.layout_options = createLayoutOptions("border", [10,20]);
+assert_checkequal(f.layout_options, createLayoutOptions("border", [10,20]));
+delete(gcf());
+createFigure("grid");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("grid"));
+f.layout_options = createLayoutOptions("grid", [30,40]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [30,40]));
+f.layout_options = createLayoutOptions("grid", [10,20], [30,40]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [10,20], [30,40]));
+delete(gcf());
index ad1e4c5..5d19be3 100644 (file)
@@ -16,6 +16,8 @@ function fig = createFigure(layout)
     fig.infobar_visible = "off";
 endfunction
 
+//constraints
+
 //no border
 createFigure("none");
 
@@ -53,11 +55,7 @@ delete(gcf());
 //grid layout
 createFigure("grid");
 
-c = createConstraints("grid", [1 2]);
-u = uicontrol("constraints", c);
-assert_checkequal(u.constraints, c);
-
-c = createConstraints("grid", [1 2], [10 20]);
+c = createConstraints("grid");
 u = uicontrol("constraints", c);
 assert_checkequal(u.constraints, c);
 
@@ -87,3 +85,39 @@ u = uicontrol("constraints", c);
 assert_checkequal(u.constraints, c);
 
 delete(gcf());
+
+
+// options
+createFigure("none");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("nolayout"));
+f.layout_options = createLayoutOptions("none");
+assert_checkequal(f.layout_options, createLayoutOptions("none"));
+delete(gcf());
+
+createFigure("gridbag");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("gridbag"));
+f.layout_options = createLayoutOptions("gridbag");
+assert_checkequal(f.layout_options, createLayoutOptions("gridbag"));
+delete(gcf());
+
+createFigure("border");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("border"));
+
+f.layout_options = createLayoutOptions("border", [10,20]);
+assert_checkequal(f.layout_options, createLayoutOptions("border", [10,20]));
+delete(gcf());
+
+createFigure("grid");
+f = gcf();
+assert_checkequal(f.layout_options, createLayoutOptions("grid"));
+
+f.layout_options = createLayoutOptions("grid", [30,40]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [30,40]));
+
+f.layout_options = createLayoutOptions("grid", [10,20], [30,40]);
+assert_checkequal(f.layout_options, createLayoutOptions("grid", [10,20], [30,40]));
+delete(gcf());
+
index 5d61dc9..1f8890c 100644 (file)
@@ -34,6 +34,7 @@
 #include "BuildObjects.h"
 #include "api_scilab.h"
 #include "createGraphicObject.h"
+#include "expandPathVariable.h"
 
 /* DO NOT CHANGE ORDER !! */
 static const char* propertiesNames[] =
@@ -126,12 +127,64 @@ int sci_uicontrol(char *fname, unsigned long fname_len)
     {
         /* Create a pushbutton in figure given as parameter */
         /* Or give focus to the uicontrol given as parameter */
+        int* piAddr = NULL;
+        int iType = 0;
 
-        if ((!checkInputArgumentType(pvApiCtx, 1, sci_handles)))
+        sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+        if (sciErr.iErr)
+        {
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+            return 0;
+        }
+
+        if (isHandleType(pvApiCtx, piAddr) == FALSE && isStringType(pvApiCtx, piAddr) == FALSE)
         {
             OverLoad(1);
             return FALSE;
         }
+        else if (isStringType(pvApiCtx, piAddr))
+        {
+            char* pstXmlfile = NULL;
+            char* pstExpandedPath = NULL;
+
+            if (isScalar(pvApiCtx, piAddr) == 0)
+            {
+                Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+                return FALSE;
+            }
+
+            if (getAllocatedSingleString(pvApiCtx, piAddr, &pstXmlfile))
+            {
+                freeAllocatedSingleString(pstXmlfile);
+                Scierror(999, _("%s: No more memory.\n"), fname);
+                return FALSE;
+            }
+
+            pstExpandedPath = expandPathVariable(pstXmlfile);
+            freeAllocatedSingleString(pstXmlfile);
+            iUicontrol = xmlload(pstExpandedPath);
+            if (iUicontrol < 1)
+            {
+                Scierror(999, _("%s: can not read file %s.\n"), fname, pstExpandedPath);
+                FREE(pstExpandedPath);
+                return 0;
+            }
+            FREE(pstExpandedPath);
+            GraphicHandle = getHandle(iUicontrol);
+
+            /* Create return variable */
+            if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, GraphicHandle))
+            {
+                Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                return 1;
+            }
+
+            AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+            ReturnArguments(pvApiCtx);
+            return TRUE;
+
+
+        }
         else /* Get parent ID */
         {
             int* piAddr = NULL;
@@ -314,7 +367,7 @@ int sci_uicontrol(char *fname, unsigned long fname_len)
                 if (iParentType != __GO_FIGURE__)
                 {
                     getGraphicObjectProperty(iParentUID, __GO_STYLE__, jni_int, (void **)&piParentStyle);
-                    if (iParentType != __GO_UICONTROL__ || iParentStyle != __GO_UI_FRAME__)
+                    if (iParentType != __GO_UICONTROL__ || (iParentStyle != __GO_UI_FRAME__ && iParentStyle != __GO_UI_TAB__))
                     {
                         Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure",
                                  "Frame uicontrol");