updatePosition(uiControl, uid, value);
break;
}
+ case __GO_UI_UNITS__: {
+ /* Convert value according to units */
+ Double[] p = (Double[]) GraphicController.getController().getProperty(uid, __GO_POSITION__);
+ updatePosition(uiControl, uid, p);
+ break;
+ }
case __GO_UI_RELIEF__: {
uiControl.setRelief((String) value);
break;
import org.scilab.modules.gui.utils.PositionConverter;
import org.scilab.modules.gui.utils.ScilabRelief;
import org.scilab.modules.gui.utils.Size;
+import org.scilab.modules.gui.utils.UnitsConverter;
+import org.scilab.modules.gui.utils.UnitsConverter.UicontrolUnits;
/**
* Swing implementation for Scilab frames in GUI
Double[] newPosition = new Double[4];
Double[] positions = (Double[]) GraphicController.getController().getProperty(getId(), GraphicObjectProperties.__GO_POSITION__);
- newPosition[0] = positions[0];
- newPosition[1] = positions[1];
- newPosition[2] = getSize().getWidth();
- newPosition[3] = getSize().getHeight();
- positions[2] = getSize().getWidth();
- positions[3] = getSize().getHeight();
+ if (positions == null) {
+ // Position property not yet set
+ return;
+ }
+ UicontrolUnits unitsProperty = UnitsConverter.stringToUnitsEnum((String) GraphicController.getController().getProperty(uid, GraphicObjectProperties.__GO_UI_UNITS__));
+ newPosition[0] = UnitsConverter.convertFromPixel(getPosition().getX(), unitsProperty, (SwingScilabFrame) SwingView.getFromId(uid), true);
+ newPosition[1] = UnitsConverter.convertFromPixel(getPosition().getY(), unitsProperty, (SwingScilabFrame) SwingView.getFromId(uid), true);
+ newPosition[2] = UnitsConverter.convertFromPixel(getWidth(), unitsProperty, (SwingScilabFrame) SwingView.getFromId(uid), true);
+ newPosition[3] = UnitsConverter.convertFromPixel(getHeight(), unitsProperty, (SwingScilabFrame) SwingView.getFromId(uid), true);
+ positions[2] = newPosition[2];
+ positions[3] = newPosition[3];
invalidate();
if (getParent() != null && getParent().getLayout() == null) {
GraphicController.getController().setProperty(getId(), GraphicObjectProperties.__GO_POSITION__, newPosition);
case CENTIMETERS:
return value * CM_PER_INCH / POINT_PER_INCH;
case PIXELS:
- return value * CallScilabBridge.getScreenResolution() / POINT_PER_INCH;
+ return value * CallScilabBridge.getScreenResolution() / POINT_PER_INCH + 1;
default:
return 0.0;
}
refSize = parentSize[3].intValue();
}
}
- return (int) (value * refSize * POINT_PER_INCH / CallScilabBridge.getScreenResolution());
+ return (value * refSize * POINT_PER_INCH / CallScilabBridge.getScreenResolution());
case INCHES:
- return (int) (value * POINT_PER_INCH);
+ return (value * POINT_PER_INCH);
case CENTIMETERS:
- return (int) (value * POINT_PER_INCH / CM_PER_INCH);
+ return (value * POINT_PER_INCH / CM_PER_INCH);
case PIXELS:
- return (int) (value * POINT_PER_INCH / CallScilabBridge.getScreenResolution());
+ return Math.round((value * POINT_PER_INCH / CallScilabBridge.getScreenResolution()));
default:
return 0;
}
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2008 - INRIA - Vincent COUVERT
-//
+// Copyright (C) 2008 - INRIA - Vincent COUVERT
+//
// 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
+// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
// This test check save and load functions used with uicontrols
// The following functions are tested:
save(TMPDIR + "/uicontrol.scg", h);
hsaved = h;
clear h;
+scf(1);
// Load saved handle
load(TMPDIR + "/uicontrol.scg");
// Check if properties are equal
if or(h.enable<>hsaved.enable) then bugmes();quit;end
if or(h.fontangle<>hsaved.fontangle) then bugmes();quit;end
if or(h.fontname<>hsaved.fontname) then bugmes();quit;end
-//if or(h.fontsize<>hsaved.fontsize) then bugmes();quit;end // TODO FIX ME !!
+if or(h.fontsize<>hsaved.fontsize) then bugmes();quit;end
if or(h.fontunits<>hsaved.fontunits) then bugmes();quit;end
if or(h.fontweight<>hsaved.fontweight) then bugmes();quit;end
if or(h.foregroundcolor<>hsaved.foregroundcolor) then bugmes();quit;end
if or(h.listboxtop<>hsaved.listboxtop) then bugmes();quit;end
if or(h.max<>hsaved.max) then bugmes();quit;end
if or(h.min<>hsaved.min) then bugmes();quit;end
-if abs(sum(h.position-hsaved.position)) > 4 then bugmes();quit;end // TODO FIX ME !! Can have a difference of 1 (point or pixel) when getting position
+if or(h.position<>hsaved.position) then bugmes();quit;end
if or(h.relief<>hsaved.relief) then bugmes();quit;end
if or(h.sliderstep<>hsaved.sliderstep) then bugmes();quit;end
if or(h.string<>hsaved.string) then bugmes();quit;end
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2008 - INRIA - Vincent COUVERT
-//
+// Copyright (C) 2008 - INRIA - Vincent COUVERT
+//
// 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
+// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
// This test check save and load functions used with uicontrols
hsaved = h;
clear h;
+scf(1);
// Load saved handle
load(TMPDIR + "/uicontrol.scg");
if or(h.enable<>hsaved.enable) then pause; end
if or(h.fontangle<>hsaved.fontangle) then pause; end
if or(h.fontname<>hsaved.fontname) then pause; end
-//if or(h.fontsize<>hsaved.fontsize) then pause; end // TODO FIX ME !!
+if or(h.fontsize<>hsaved.fontsize) then pause; end
if or(h.fontunits<>hsaved.fontunits) then pause; end
if or(h.fontweight<>hsaved.fontweight) then pause; end
if or(h.foregroundcolor<>hsaved.foregroundcolor) then pause; end
if or(h.listboxtop<>hsaved.listboxtop) then pause; end
if or(h.max<>hsaved.max) then pause; end
if or(h.min<>hsaved.min) then pause; end
-if abs(sum(h.position-hsaved.position)) > 4 then pause; end // TODO FIX ME !! Can have a difference of 1 (point or pixel) when getting position
+if or(h.position<>hsaved.position) then pause; end
if or(h.relief<>hsaved.relief) then pause; end
if or(h.sliderstep<>hsaved.sliderstep) then pause; end
if or(h.string<>hsaved.string) then pause; end