187 |
187 |
** and converted to integer. See #5345.
|
188 |
188 |
** VVT 20211118 Fixed: incorrect coordinate conversion when setting size atributes. See #5034-1422.
|
189 |
189 |
** ME 20220209 Replace getAttr for "realized" with isRealized method.
|
|
190 |
** ME 20220526 Extend validation for ROW/COLUMN attributes against parent.
|
190 |
191 |
*/
|
191 |
192 |
/*
|
192 |
193 |
** This program is free software: you can redistribute it and/or modify
|
... | ... | |
2796 |
2797 |
protected boolean validColumnOrRow(boolean isUnknown, double value, boolean row)
|
2797 |
2798 |
{
|
2798 |
2799 |
boolean isChui = LogicalTerminal.isChui();
|
2799 |
|
|
2800 |
|
if (isChui)
|
2801 |
|
{
|
2802 |
|
value = Coordinate.scale(value, 0);
|
2803 |
|
|
2804 |
|
if (isUnknown || value < Coordinate.MIN_CHUI_CH)
|
2805 |
|
{
|
2806 |
|
String msg = String.format(
|
2807 |
|
"**Attribute %s must be greater than or equal to 1 on %s widget",
|
2808 |
|
row ? "ROW" : "COL",
|
2809 |
|
type());
|
2810 |
|
ErrorManager.displayWarning(4081, msg, false);
|
2811 |
|
return false;
|
2812 |
|
}
|
2813 |
|
|
2814 |
|
if (value > Coordinate.MAX_CHUI_CH)
|
2815 |
|
{
|
2816 |
|
String msg = String.format("Invalid character unit value %d changed to %d",
|
2817 |
|
Math.abs((int) value), Coordinate.MAX_CHUI_CH);
|
2818 |
|
ErrorManager.recordOrShowError(13734, msg, false, true, false);
|
2819 |
|
return false;
|
2820 |
|
}
|
2821 |
|
|
2822 |
|
value = Coordinate.adjustMinMaxChuiChar(value);
|
2823 |
|
}
|
2824 |
|
else
|
2825 |
|
{
|
2826 |
|
value = Coordinate.scale(value);
|
2827 |
|
|
2828 |
|
if (isUnknown || (value > -1 && value < 1))
|
2829 |
|
{
|
2830 |
|
String msg = String.format(
|
2831 |
|
"**Attribute %s must be greater than or equal to 1 on %s widget",
|
2832 |
|
row ? "ROW" : "COL",
|
2833 |
|
type());
|
2834 |
|
ErrorManager.displayWarning(4081, msg, false);
|
2835 |
|
return false;
|
2836 |
|
}
|
2837 |
|
|
2838 |
|
if (value < Coordinate.MIN_GUI_CH || value > Coordinate.MAX_GUI_CH)
|
2839 |
|
{
|
2840 |
|
double origValue = value;
|
2841 |
|
value = Coordinate.adjustMinMaxGuiChar(value);
|
2842 |
|
String msg;
|
2843 |
|
if (origValue == (long) origValue)
|
2844 |
|
{
|
2845 |
|
msg = String.format("Invalid character unit value %d changed to %d",
|
2846 |
|
Math.abs((long) origValue), Math.abs((long) value));
|
2847 |
|
}
|
2848 |
|
else
|
2849 |
|
{
|
2850 |
|
msg = String.format("Invalid character unit value %s changed to %s",
|
2851 |
|
Math.abs(origValue), Math.abs(value));
|
2852 |
|
}
|
2853 |
|
ErrorManager.recordOrShowError(13734, msg, false, true, false);
|
2854 |
|
return false;
|
2855 |
|
}
|
2856 |
|
}
|
2857 |
|
// TODO: widget can not go outside of the frame's size (when realized)!
|
|
2800 |
value = isChui ? Coordinate.scale(value, 0) : Coordinate.scale(value);
|
|
2801 |
|
|
2802 |
if (isUnknown || value < 1)
|
|
2803 |
{
|
|
2804 |
String msg = String.format("**Attribute %s must be greater than or equal to 1 on %s %s",
|
|
2805 |
row ? "ROW" : "COL", type(), widgetName());
|
|
2806 |
ErrorManager.recordOrShowWarning(4081, msg, false, false, true, true);
|
|
2807 |
return false;
|
|
2808 |
}
|
|
2809 |
|
|
2810 |
double adjusted = isChui ? Coordinate.adjustMinMaxChuiChar(value) : Coordinate.adjustMinMaxGuiChar(value);
|
|
2811 |
|
|
2812 |
if (value > adjusted)
|
|
2813 |
{
|
|
2814 |
String msg = String.format("Invalid character unit value %d changed to %d",
|
|
2815 |
Math.abs((long) value), Math.abs((long) adjusted));
|
|
2816 |
ErrorManager.recordOrShowWarning(13734, msg, false, false, true, true);
|
|
2817 |
return true;
|
|
2818 |
}
|
|
2819 |
|
|
2820 |
// check if it fits in parent, only if parent was realized
|
|
2821 |
PaneEntity parent = getParent(PaneEntity.class);
|
|
2822 |
if (parent != null && parent._isRealized())
|
|
2823 |
{
|
|
2824 |
double parentSize = row ? parent.getVirtHeight().doubleValue()
|
|
2825 |
: parent.getVirtWidth().doubleValue();
|
|
2826 |
double size = row ? getVirtHeight().doubleValue() : getVirtWidth().doubleValue();
|
|
2827 |
|
|
2828 |
if (value - 1 > parentSize - size)
|
|
2829 |
{
|
|
2830 |
ErrorManager.recordOrShowWarning(4054,
|
|
2831 |
String.format("Unable to set %s. %s %s does not fit in %s widget",
|
|
2832 |
row ? "ROW" : "COLUMN", type(), widgetName(), parent.type()),
|
|
2833 |
false, false, true, true);
|
|
2834 |
return false;
|
|
2835 |
}
|
|
2836 |
}
|
2858 |
2837 |
|
2859 |
2838 |
return true;
|
2860 |
2839 |
}
|