1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-08-30 22:57:59 -04:00
parent ed911e3de5
commit 5fc4eb41ec
579 changed files with 2460 additions and 1564 deletions

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class GfuiAlign_ implements ParseAble {
public static GfuiAlign as_(Object obj) {return obj instanceof GfuiAlign ? (GfuiAlign)obj : null;}
public static GfuiAlign cast_(Object obj) {try {return (GfuiAlign)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiAlign.class, obj);}}
public static GfuiAlign cast(Object obj) {try {return (GfuiAlign)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiAlign.class, obj);}}
public static final GfuiAlign
Null = new_(0, "nil")
, Lo = new_(1, "lo")
@@ -31,14 +31,14 @@ public class GfuiAlign_ implements ParseAble {
, Right = Hi;
static GfuiAlign new_(int v, String s) {return new GfuiAlign(v, s);}
public static final GfuiAlign_ Parser = new GfuiAlign_();
public Object ParseAsObj(String raw) {return parse_(raw);}
public Object ParseAsObj(String raw) {return parse(raw);}
public static GfuiAlign val_(int v) {
if (v == Lo.Val()) return Lo;
else if (v == Mid.Val()) return Mid;
else if (v == Hi.Val()) return Hi;
else return Null;
}
public static GfuiAlign parse_(String raw) {
public static GfuiAlign parse(String raw) {
if (String_.Eq(raw, "bot")) return Bot;
else if (String_.Eq(raw, "mid")) return Mid;
else if (String_.Eq(raw, "top")) return Top;
@@ -51,7 +51,7 @@ public class GfuiAlign_ implements ParseAble {
}
public static int CalcInsideOfAxis(int posEnm, int innerSize, int outerSize) {
int rv = 0;
if (posEnm == GfuiAlign_.Null.Val()) rv = Int_.MinValue;
if (posEnm == GfuiAlign_.Null.Val()) rv = Int_.Min_value;
else if (posEnm == GfuiAlign_.Lo.Val()) rv = 0;
else if (posEnm == GfuiAlign_.Mid.Val()) rv = (outerSize - innerSize) / 2;
else if (posEnm == GfuiAlign_.Hi.Val()) rv = outerSize - innerSize;

View File

@@ -39,7 +39,7 @@ class GfuiBorderEdge_ {
else if (val == GfuiBorderEdge.All.Val()) return All_raw;
else throw Err_.new_unhandled(edge);
}
public static GfuiBorderEdge parse_(String raw) {
public static GfuiBorderEdge parse(String raw) {
if (String_.Eq(raw, Left_raw)) return GfuiBorderEdge.Left;
else if (String_.Eq(raw, Right_raw)) return GfuiBorderEdge.Right;
else if (String_.Eq(raw, Top_raw)) return GfuiBorderEdge.Top;

View File

@@ -17,16 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class PointAdp_ {
public static final PointAdp Null = new PointAdp(Int_.MinValue, Int_.MinValue);
public static final PointAdp Null = new PointAdp(Int_.Min_value, Int_.Min_value);
public static final PointAdp Zero = new PointAdp(0, 0);
public static PointAdp as_(Object obj) {return obj instanceof PointAdp ? (PointAdp)obj : null;}
public static PointAdp cast_(Object obj) {try {return (PointAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, PointAdp.class, obj);}}
public static PointAdp cast(Object obj) {try {return (PointAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, PointAdp.class, obj);}}
public static PointAdp new_(int x, int y) {return new PointAdp(x, y);}
public static PointAdp coerce_(Object o) {PointAdp rv = PointAdp_.as_(o); return (rv == null) ? parse_((String)o) : rv;}
public static PointAdp parse_(String raw) {
public static PointAdp coerce_(Object o) {PointAdp rv = PointAdp_.as_(o); return (rv == null) ? parse((String)o) : rv;}
public static PointAdp parse(String raw) {
try {
String[] ary = String_.Split(raw, ",");
return new PointAdp(Int_.parse_(ary[0]), Int_.parse_(ary[1]));
return new PointAdp(Int_.parse(ary[0]), Int_.parse(ary[1]));
} catch (Exception exc) {throw Err_.new_parse_exc(exc, PointAdp.class, raw);}
}
}

View File

@@ -24,7 +24,7 @@ public class RectAdpF { //_20101206 // supports Graphics.MeasureString
return comp.x == x && comp.y == y && comp.width == width && comp.height == height;
}
public static final RectAdpF Null = new_(Int_.MinValue, Int_.MinValue, Int_.MinValue, Int_.MinValue);
public static final RectAdpF Null = new_(Int_.Min_value, Int_.Min_value, Int_.Min_value, Int_.Min_value);
public static RectAdpF new_(float x, float y, float width, float height) {
RectAdpF rv = new RectAdpF();
rv.x = x; rv.y = y; rv.width = width; rv.height = height;

View File

@@ -23,11 +23,11 @@ public class RectAdp_ {
public static RectAdp vector_(PointAdp pos, SizeAdp size) {return new RectAdp(pos, size);}
public static RectAdp size_(int w, int h) {return new_(0, 0, w, h);}
public static RectAdp size_(SizeAdp size) {return new RectAdp(PointAdp_.Zero, size);}
public static RectAdp parse_ws_(String raw) {return parse_(String_.Replace(raw, " ", ""));}
public static RectAdp parse_(String raw) {
public static RectAdp parse_ws_(String raw) {return parse(String_.Replace(raw, " ", ""));}
public static RectAdp parse(String raw) {
try {
String[] ary = String_.Split(raw, ",");
return RectAdp_.new_(Int_.parse_(ary[0]), Int_.parse_(ary[1]), Int_.parse_(ary[2]), Int_.parse_(ary[3]));
return RectAdp_.new_(Int_.parse(ary[0]), Int_.parse(ary[1]), Int_.parse(ary[2]), Int_.parse(ary[3]));
} catch(Exception exc) {throw Err_.new_parse_exc(exc, RectAdp.class, raw);}
}
public static String Xto_str(RectAdp rect) {return String_.Format("{0},{1},{2},{3}", rect.X(), rect.Y(), rect.Width(), rect.Height());}

View File

@@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
public class SizeAdpF implements ParseAble {
public float Width() {return width;} float width;
public float Height() {return height;} float height;
public Object ParseAsObj(String raw) {return SizeAdp_.parse_(raw);}
public Object ParseAsObj(String raw) {return SizeAdp_.parse(raw);}
@Override public String toString() {return String_.Concat_any(width, ":", height);}
@gplx.Internal protected SizeAdpF(float width, float height) {this.width = width; this.height = height;}
}

View File

@@ -17,17 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class SizeAdpF_ {
public static final SizeAdpF Null = new_(Int_.MinValue, Int_.MinValue);
public static final SizeAdpF Null = new_(Int_.Min_value, Int_.Min_value);
public static final SizeAdpF Zero = new_(0, 0);
public static final SizeAdpF Parser = new SizeAdpF(0, 0);
public static SizeAdpF as_(Object obj) {return obj instanceof SizeAdpF ? (SizeAdpF)obj : null;}
public static SizeAdpF new_(float width, float height) {return new SizeAdpF(width, height);}
public static SizeAdpF coerce_(Object obj) {SizeAdpF rv = as_(obj); return rv == null ? parse_((String)obj) : rv;}
public static SizeAdpF parse_(String s) {
public static SizeAdpF coerce_(Object obj) {SizeAdpF rv = as_(obj); return rv == null ? parse((String)obj) : rv;}
public static SizeAdpF parse(String s) {
try {
String[] ary = String_.Split(s, ","); if (ary.length != 2) throw Err_.new_wo_type("SizeAdf should only have 2 numbers separated by 1 comma");
float val1 = Float_.parse_(ary[0]);
float val2 = Float_.parse_(ary[1]);
float val1 = Float_.parse(ary[0]);
float val2 = Float_.parse(ary[1]);
return new_(val1, val2);
} catch (Exception e) {throw Err_.new_parse_exc(e, SizeAdpF.class, s);}
}

View File

@@ -17,16 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class SizeAdp_ {
public static final SizeAdp Null = new SizeAdp(Int_.MinValue, Int_.MinValue);
public static final SizeAdp Null = new SizeAdp(Int_.Min_value, Int_.Min_value);
public static final SizeAdp Zero = new SizeAdp(0, 0);
public static final SizeAdp[] Ary_empty = new SizeAdp[0];
public static SizeAdp cast_(Object obj) {try {return (SizeAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, SizeAdp.class, obj);}}
public static SizeAdp cast(Object obj) {try {return (SizeAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, SizeAdp.class, obj);}}
public static SizeAdp new_(int width, int height) {return new SizeAdp(width, height);}
public static SizeAdp parse_(String raw) {return parse_or_(raw, SizeAdp_.Null);}
public static SizeAdp parse_or_(String raw, SizeAdp or) {
public static SizeAdp parse(String raw) {return parse_or(raw, SizeAdp_.Null);}
public static SizeAdp parse_or(String raw, SizeAdp or) {
String[] ary = String_.Split(raw, ","); if (ary.length != 2) return or;
int w = Int_.parse_or_(ary[0], Int_.MinValue); if (w == Int_.MinValue) return or;
int h = Int_.parse_or_(ary[1], Int_.MinValue); if (h == Int_.MinValue) return or;
int w = Int_.parse_or(ary[0], Int_.Min_value); if (w == Int_.Min_value) return or;
int h = Int_.parse_or(ary[1], Int_.Min_value); if (h == Int_.Min_value) return or;
return new SizeAdp(w, h);
}
public static SizeAdp corners_(PointAdp topLeft, PointAdp bottomRight) {

View File

@@ -19,15 +19,15 @@ package gplx.gfui; import gplx.*;
import gplx.texts.*;
public class ColorAdp_ implements ParseAble {
public static ColorAdp as_(Object obj) {return obj instanceof ColorAdp ? (ColorAdp)obj : null;}
public static ColorAdp cast_(Object obj) {try {return (ColorAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ColorAdp.class, obj);}}
public static ColorAdp cast(Object obj) {try {return (ColorAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ColorAdp.class, obj);}}
public static ColorAdp new_(int a, int r, int g, int b) {return ColorAdp.new_((int)a, (int)r, (int)g, (int)b);}
public static final ColorAdp_ Parser = new ColorAdp_();
public Object ParseAsObj(String raw) {return ColorAdp_.parse_(raw);}
public Object ParseAsObj(String raw) {return ColorAdp_.parse(raw);}
public static ColorAdp parseOr_(String raw, ColorAdp or) {
ColorAdp rv = parse_internal_(raw); if (rv == null) return or;
return rv;
}
public static ColorAdp parse_(String raw) {
public static ColorAdp parse(String raw) {
ColorAdp rv = parse_internal_(raw); if (rv == null) throw Err_.new_parse_type(ColorAdp.class, raw);
return rv;
}
@@ -63,7 +63,7 @@ public class ColorAdp_ implements ParseAble {
int rawLen = String_.Len(raw);
for (int i = 1; i < rawLen; i += 2) { // fill ARGB ary by parsing raw 2 at a time; EX: #FFFFFFFF -> 255,255,255,255; NOTE: start at 1 to ignore leading #
String hexStr = String_.MidByLen(raw, i, 2);
ary[idx++] = HexDecUtl.parse_(hexStr);
ary[idx++] = HexDecUtl.parse(hexStr);
}
return ColorAdp.new_(ary[0], ary[1], ary[2], ary[3]);
} catch (Exception exc) {throw Err_.new_parse_exc(exc, ColorAdp.class, raw);}
@@ -71,7 +71,7 @@ public class ColorAdp_ implements ParseAble {
@gplx.Internal protected static ColorAdp parse_int_(String v) {
String[] ary = String_.Split(v, ",");
switch (ary.length) {
case 1: return new_int_(Int_.parse_(ary[0]));
case 1: return new_int_(Int_.parse(ary[0]));
case 3:
case 4: return parse_int_ary_(ary);
default: throw Err_.new_wo_type("invalid array", "len", ary.length);
@@ -81,10 +81,10 @@ public class ColorAdp_ implements ParseAble {
int a;
int idx = 0;
if (ary.length == 3) {idx = 0; a = 255;}
else {idx = 1; a = Int_.parse_(ary[0]);}
int r = Int_.parse_(ary[idx++]);
int g = Int_.parse_(ary[idx++]);
int b = Int_.parse_(ary[idx++]);
else {idx = 1; a = Int_.parse(ary[0]);}
int r = Int_.parse(ary[idx++]);
int g = Int_.parse(ary[idx++]);
int b = Int_.parse(ary[idx++]);
return ColorAdp_.new_(a, r, g, b);
}
public static ColorAdp new_int_(int val) {
@@ -94,7 +94,7 @@ public class ColorAdp_ implements ParseAble {
int b = ((val) & 255);
return ColorAdp.new_(a, r, g, b);
}
public static ColorAdp read_(Object o) {String s = String_.as_(o); return s != null ? ColorAdp_.parse_(s) : ColorAdp_.cast_(o);}
public static ColorAdp read_(Object o) {String s = String_.as_(o); return s != null ? ColorAdp_.parse(s) : ColorAdp_.cast(o);}
public static final ColorAdp
Null = new_( 0, 0, 0, 0)
, Black = new_(255, 0, 0, 0)

View File

@@ -28,10 +28,10 @@ public class ColorAdp__tst {
tst_parse_int_(255, 0, 0, 0, 255);
tst_parse_int_(65535, 0, 0, 255, 255);
tst_parse_int_(16777215, 0, 255, 255, 255);
tst_parse_int_(Int_.MaxValue, 127, 255, 255, 255);
tst_parse_int_(Int_.Max_value, 127, 255, 255, 255);
tst_parse_int_(-1, 255, 255, 255, 255);
}
@Test public void parse_() {
@Test public void parse() {
tst_parse_("0,0,0,0", 0, 0, 0, 0); // parse all ints
tst_parse_("0,0,0", 255, 0, 0, 0); // a=255, parse rest
tst_parse_("255", 0, 0, 0, 255); // parse as single int
@@ -46,7 +46,7 @@ public class ColorAdp__tst {
tst_ColorAdp(color, a, r, g, b);
Tfds.Eq(color.Value(), val);
}
void tst_parse_(String s, int alpha, int red, int green, int blue) {tst_ColorAdp(ColorAdp_.parse_(s), alpha, red, green, blue);}
void tst_parse_(String s, int alpha, int red, int green, int blue) {tst_ColorAdp(ColorAdp_.parse(s), alpha, red, green, blue);}
void tst_ColorAdp(ColorAdp color, int alpha, int red, int green, int blue) {
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
tstr.Eq_str(color.Alpha(), alpha, "alpha");

View File

@@ -56,7 +56,7 @@ public class FontAdp implements GfoInvkAble {
public static final FontAdp NullPtr = null;
public static FontAdp as_(Object obj) {return obj instanceof FontAdp ? (FontAdp)obj : null;}
public static FontAdp cast_(Object obj) {try {return (FontAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, FontAdp.class, obj);}}
public static FontAdp cast(Object obj) {try {return (FontAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, FontAdp.class, obj);}}
public static FontAdp new_(String name, float size, FontStyleAdp style) {
FontAdp rv = new FontAdp();
rv.name = name; rv.size = size; rv.style = style;

View File

@@ -25,9 +25,9 @@ public class FontStyleAdp_ implements ParseAble {
, BoldItalic = new FontStyleAdp(3)
;
public static final FontStyleAdp_ Parser = new FontStyleAdp_();
public Object ParseAsObj(String raw) {return FontStyleAdp_.parse_(raw);}
public Object ParseAsObj(String raw) {return FontStyleAdp_.parse(raw);}
public static FontStyleAdp cast_(Object obj) {try {return (FontStyleAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, FontStyleAdp.class, obj);}}
public static FontStyleAdp cast(Object obj) {try {return (FontStyleAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, FontStyleAdp.class, obj);}}
public static FontStyleAdp parseOr_(String raw, FontStyleAdp or) {
FontStyleAdp rv = parse_internal_(raw); if (rv == null) return or;
return rv;
@@ -37,11 +37,11 @@ public class FontStyleAdp_ implements ParseAble {
v += italic == Bool_obj_val.True ? 2 : 0;
return lang_(v);
}
public static FontStyleAdp parse_(String raw) {
public static FontStyleAdp parse(String raw) {
FontStyleAdp rv = parse_internal_(raw); if (rv == null) throw Err_.new_unhandled(raw);
return rv;
}
public static FontStyleAdp read_(Object o) {String s = String_.as_(o); return s != null ? FontStyleAdp_.parse_(s) : FontStyleAdp_.cast_(o);}
public static FontStyleAdp read_(Object o) {String s = String_.as_(o); return s != null ? FontStyleAdp_.parse(s) : FontStyleAdp_.cast(o);}
static FontStyleAdp parse_internal_(String raw) {
if (String_.Eq(raw, "plain")) return FontStyleAdp_.Plain;
else if (String_.Eq(raw, "bold")) return FontStyleAdp_.Bold;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class PenAdp_ {
public static PenAdp as_(Object obj) {return obj instanceof PenAdp ? (PenAdp)obj : null;}
public static PenAdp cast_(Object obj) {try {return (PenAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, PenAdp.class, obj);}}
public static PenAdp cast(Object obj) {try {return (PenAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, PenAdp.class, obj);}}
public static PenAdp black_() {return new_(ColorAdp_.Black, 1);}
public static PenAdp new_(ColorAdp color) {return new_(color, 1);}
public static PenAdp new_(ColorAdp color, float width) {return new PenAdp(color, width);}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class SolidBrushAdp_ {
public static SolidBrushAdp as_(Object obj) {return obj instanceof SolidBrushAdp ? (SolidBrushAdp)obj : null;}
public static SolidBrushAdp cast_(Object obj) {try {return (SolidBrushAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, SolidBrushAdp.class, obj);}}
public static SolidBrushAdp cast(Object obj) {try {return (SolidBrushAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, SolidBrushAdp.class, obj);}}
public static final SolidBrushAdp Black = new_(ColorAdp_.Black);
public static final SolidBrushAdp White = new_(ColorAdp_.White);
public static final SolidBrushAdp Null = new_(ColorAdp_.Null);

View File

@@ -40,7 +40,7 @@ public class GfuiBorderMgr {
this.None_();
else {
Object[] ary = (Object[])o;
this.Edge_set(GfuiBorderEdge.All, PenAdp_.new_((ColorAdp)ary[1], Float_.cast_(ary[0])));
this.Edge_set(GfuiBorderEdge.All, PenAdp_.new_((ColorAdp)ary[1], Float_.cast(ary[0])));
}
}
public void Edge_set(GfuiBorderEdge edge, PenAdp pen) {

View File

@@ -93,7 +93,7 @@ public class GfxStringData {
// }
float x = GfuiAlign_.CalcInsideOfAxis(alignH.Val(), (int)width, ownerSize.Width());
float y = 0; int alignVVal = alignV.Val(); float ownerHeight = ownerSize.Height();
if (alignVVal == GfuiAlign_.Null.Val()) y = Int_.MinValue;
if (alignVVal == GfuiAlign_.Null.Val()) y = Int_.Min_value;
else if (alignVVal == GfuiAlign_.Lo.Val()) y = height - descent;
else if (alignVVal == GfuiAlign_.Mid.Val()) y = (ownerHeight - (ownerHeight - height) / 2);// - descent; // COMMENT: subtracting descent is theoretically correct, but practically results in text shifted up
else if (alignVVal == GfuiAlign_.Hi.Val()) y = ownerHeight - descent;

View File

@@ -20,7 +20,7 @@ public class PaintArgs {
public GfxAdp Graphics() {return graphics;} GfxAdp graphics;
public RectAdp ClipRect() {return clipRect;} RectAdp clipRect;
public static PaintArgs cast_(Object obj) {try {return (PaintArgs)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, PaintArgs.class, obj);}}
public static PaintArgs cast(Object obj) {try {return (PaintArgs)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, PaintArgs.class, obj);}}
public static PaintArgs new_(GfxAdp graphics, RectAdp clipRect) {
PaintArgs rv = new PaintArgs();
rv.graphics = graphics; rv.clipRect = clipRect;

View File

@@ -34,11 +34,11 @@ class IptKeyChain implements IptArg {
}
key = sb.To_str();
}
public static IptKeyChain parse_(String raw) {
public static IptKeyChain parse(String raw) {
String[] itms = String_.Split(raw, ",");
IptArg[] rv = new IptArg[itms.length];
for (int i = 0; i < rv.length; i++)
rv[i] = IptArg_.parse_(String_.Trim(itms[i]));
rv[i] = IptArg_.parse(String_.Trim(itms[i]));
return new IptKeyChain(rv);
}
}

View File

@@ -20,7 +20,7 @@ public class IptArg_ {
public static final IptArg[] Ary_empty = new IptArg[0];
public static final IptArg Null = null;
public static final String Wildcard_key = "wildcard";
public static IptArg Wildcard = new IptKey(Int_.MaxValue, Wildcard_key);
public static IptArg Wildcard = new IptKey(Int_.Max_value, Wildcard_key);
public static boolean Is_null_or_none(IptArg arg) {return arg == Null || arg == IptKey_.None;}
public static IptArg[] Ary(IptArg... v) {return v;}
public static IptArg[] parse_ary_or_empty(String v) {
@@ -35,28 +35,28 @@ public class IptArg_ {
int args_len = args.length; if (args_len == 0) return Ary_empty;
IptArg[] rv = new IptArg[args_len];
for (int i = 0; i < args_len; i++)
rv[i] = parse_(String_.Trim(args[i]));
rv[i] = parse(String_.Trim(args[i]));
return rv;
}
public static IptArg parse_chain_(String raw) {return IptKeyChain.parse_(raw);}
public static IptArg parse_chain_(String raw) {return IptKeyChain.parse(raw);}
public static IptArg parse_or_none_(String raw) {
try {
return String_.Eq(raw, String_.Empty)
? IptKey_.None
: parse_(raw);
: parse(raw);
}
catch (Exception exc) { // as an "or" proc, handle errors; note that it may accept raw values from cfg files, so invalid input is possible; DATE:2014-06-04
Err_.Noop(exc);
return IptKey_.None;
}
}
public static IptArg parse_(String raw) {
if (String_.Has(raw, ",")) return IptKeyChain.parse_(raw);
public static IptArg parse(String raw) {
if (String_.Has(raw, ",")) return IptKeyChain.parse(raw);
String bgn = String_.GetStrBefore(raw, ".");
if (String_.Eq(bgn, "wheel")) return IptMouseWheel_.parse_(raw);
else if (String_.Eq(bgn, "mouse")) return IptMouseBtn_.parse_(raw);
else if (String_.Eq(bgn, "key")) return IptKey_.parse_(raw);
else return IptMacro._.parse_(raw);
if (String_.Eq(bgn, "wheel")) return IptMouseWheel_.parse(raw);
else if (String_.Eq(bgn, "mouse")) return IptMouseBtn_.parse(raw);
else if (String_.Eq(bgn, "key")) return IptKey_.parse(raw);
else return IptMacro._.parse(raw);
}
// NOTE: the following two methods should theoretically be interface methods, but since they are only used by two procs, they will be handled with if/else
@gplx.Internal protected static IptEventType EventType_default(IptArg arg) {
@@ -98,7 +98,7 @@ class IptMacro {
Reg("mod", "as", IptKey_.add_(IptKey_.Alt, IptKey_.Shift));
Reg("mod", "cas", IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.Shift));
}
public IptArg parse_(String raw) {
public IptArg parse(String raw) {
if (regy == null) Init();
String[] plusAry = String_.Split(raw, "+");
String[] dotAry = String_.Split(plusAry[0], ".");
@@ -108,7 +108,7 @@ class IptMacro {
IptKey rv = (IptKey)list.Get_by(end);
if (rv == null) throw parse_err(raw, "arg not found").Args_add("arg", end);
for (int i = 1; i < plusAry.length; i++) {
rv = rv.Add((IptKey)IptKey_.parse_(plusAry[i]));
rv = rv.Add((IptKey)IptKey_.parse(plusAry[i]));
}
return rv;
}

View File

@@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
public class IptBnd_chkBox implements InjectAble, GfoEvObj {
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
public void Inject(Object owner) {
chkBox = GfuiChkBox_.cast_(owner);
chkBox = GfuiChkBox_.cast(owner);
GfoEvMgr_.Sub(chkBox, "Check_end", this, setCmd);
GfoEvMgr_.SubSame(fwd, setEvt, this);
}
@@ -36,7 +36,7 @@ public class IptBnd_chkBox implements InjectAble, GfoEvObj {
GfoEvObj fwd; GfoInvkAble invkAble; String setCmd, setEvt, msgArg; GfuiChkBox chkBox;
public static IptBnd_chkBox new_(GfoEvObj src, String setCmd, String setEvt, String msgArg) {
IptBnd_chkBox rv = new IptBnd_chkBox();
rv.fwd = src; rv.invkAble = GfoInvkAble_.cast_(src); rv.setCmd = setCmd; rv.setEvt = setEvt; rv.msgArg = msgArg;
rv.fwd = src; rv.invkAble = GfoInvkAble_.cast(src); rv.setCmd = setCmd; rv.setEvt = setEvt; rv.msgArg = msgArg;
return rv;
}
}

View File

@@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
public class IptBnd_txt_cmd implements InjectAble, GfoInvkAble, GfoEvObj {
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
public void Inject(Object owner) {
txtBox = GfuiTextBox_.cast_(owner);
txtBox = GfuiTextBox_.cast(owner);
txtBox.TextAlignH_center_();
IptBnd_.cmd_to_(IptCfg_.Null, txtBox, this, TxtBox_exec, IptKey_.Enter);
GfoEvMgr_.SubSame(fwd, setEvt, this);
@@ -36,7 +36,7 @@ public class IptBnd_txt_cmd implements InjectAble, GfoInvkAble, GfoEvObj {
GfuiTextBox txtBox; GfoInvkAble src; GfoEvObj fwd; String setCmd, setEvt; ClassXtn cls;
public static IptBnd_txt_cmd new_(GfoEvObj fwd, String setCmd, String setEvt, ClassXtn cls) {
IptBnd_txt_cmd rv = new IptBnd_txt_cmd();
rv.fwd = fwd; rv.src = GfoInvkAble_.cast_(fwd);
rv.fwd = fwd; rv.src = GfoInvkAble_.cast(fwd);
rv.setCmd = setCmd; rv.setEvt = setEvt; rv.cls = cls;
return rv;
}

View File

@@ -29,7 +29,7 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
return this;
} KeyVal[] list = null;
public void Inject(Object owner) {
txtBox = GfuiTextBox_.cast_(owner);
txtBox = GfuiTextBox_.cast(owner);
txtBox.TextAlignH_center_();
IptBnd_.cmd_to_(IptCfg_.Null, txtBox, this, Invk_dec, IptKey_.Down, IptMouseWheel_.Down);
IptBnd_.cmd_to_(IptCfg_.Null, txtBox, this, Invk_inc, IptKey_.Up, IptMouseWheel_.Up);
@@ -52,14 +52,14 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
WhenEvtCmd(list[newVal].Key_as_obj());
}
Object UpdateCmd() {
int idx = Int_.MinValue;
int idx = Int_.Min_value;
String find = txtBox.Text();
for (int i = 0; i < list.length; i++) { // try to find .Text in list.Vals
if (String_.Eq(find, (String)list[i].Val())) idx = i;
}
if (idx == Int_.MinValue) { // try to find .Text in list.Keys
int key = Int_.parse_or_(txtBox.Text(), Int_.MinValue); if (key == Int_.MinValue) return GfoInvkAble_.Rv_unhandled;
idx = GetByKey(key); if (idx == Int_.MinValue) return GfoInvkAble_.Rv_unhandled;
if (idx == Int_.Min_value) { // try to find .Text in list.Keys
int key = Int_.parse_or(txtBox.Text(), Int_.Min_value); if (key == Int_.Min_value) return GfoInvkAble_.Rv_unhandled;
idx = GetByKey(key); if (idx == Int_.Min_value) return GfoInvkAble_.Rv_unhandled;
}
ExecCmd(setCmd, idx);
return GfoInvkAble_.Rv_handled;
@@ -71,7 +71,7 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
WhenEvtCmd(curId);
}
void WhenEvtCmd(Object id) {
int idx = GetByKey(id); if (idx == Int_.MinValue) return;
int idx = GetByKey(id); if (idx == Int_.Min_value) return;
previewIdx = idx;
txtBox.Text_(list[idx].Val_to_str_or_empty());
}
@@ -84,7 +84,7 @@ public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
for (int i = 0; i < list.length; i++) {
if (Object_.Eq(find, list[i].Key_as_obj())) return i;
}
return Int_.MinValue;
return Int_.Min_value;
}
public static IptBnd_txt_range new_(GfoEvObj propSrc) {
IptBnd_txt_range rv = new IptBnd_txt_range();

View File

@@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
public class IptBnd_upDownRange implements InjectAble, GfoInvkAble, GfoEvObj {
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
public void Inject(Object owner) {
txtBox = GfuiTextBox_.cast_(owner);
txtBox = GfuiTextBox_.cast(owner);
txtBox.TextAlignH_center_();
if (bndCfg == null) bndCfg = IptCfg_.new_("gplx.gfui.IptBnd_upDownRange");
IptBnd_.cmd_to_(bndCfg, txtBox, this, Invk_TxtBox_dec, IptKey_.Down, IptMouseWheel_.Down);
@@ -32,7 +32,7 @@ public class IptBnd_upDownRange implements InjectAble, GfoInvkAble, GfoEvObj {
else if (ctx.Match(k, Invk_TxtBox_inc)) ExecCmd(cmd, curVal + 1);
else if (ctx.Match(k, Invk_TxtBox_exec)) {
Object valObj = IntClassXtn._.ParseOrNull(txtBox.Text()); if (valObj == null) throw Err_.new_wo_type("invalid int", "text", txtBox.Text());
ExecCmd(doIt, Int_.cast_(valObj));
ExecCmd(doIt, Int_.cast(valObj));
}
else if (ctx.Match(k, evt)) WhenEvt(ctx, m);
else return GfoInvkAble_.Rv_unhandled;
@@ -51,7 +51,7 @@ public class IptBnd_upDownRange implements InjectAble, GfoInvkAble, GfoEvObj {
public static IptBnd_upDownRange new_(GfoEvObj fwd, String cmd, String evt, String arg) {return exec_(fwd, cmd, evt, cmd, arg);}
public static IptBnd_upDownRange exec_(GfoEvObj fwd, String cmd, String evt, String doIt, String arg) {
IptBnd_upDownRange rv = new IptBnd_upDownRange();
rv.fwd = fwd; rv.src = GfoInvkAble_.cast_(fwd);
rv.fwd = fwd; rv.src = GfoInvkAble_.cast(fwd);
rv.cmd = cmd; rv.evt = evt; rv.doIt = doIt; rv.arg = arg;
return rv;
}

View File

@@ -55,7 +55,7 @@ public class IptCfg_tst {
box.tst_SendKey(IptKey_.A, 0);
}
@Test public void Chained() {
cfg.run_GetOrDflt(box, key, IptKeyChain.parse_("key.ctrl+key.a,key.b"));
cfg.run_GetOrDflt(box, key, IptKeyChain.parse("key.ctrl+key.a,key.b"));
cfg.run_Set(key, IptKey_.A);
box.tst_SendKey(IptKey_.A, 1);
}

View File

@@ -36,7 +36,7 @@ public class IptEventData {
}
public static IptEventData as_(Object obj) {return obj instanceof IptEventData ? (IptEventData)obj : null;}
public static IptEventData cast_(Object obj) {try {return (IptEventData)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEventData.class, obj);}}
public static IptEventData cast(Object obj) {try {return (IptEventData)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEventData.class, obj);}}
@gplx.Internal protected static IptEventData new_(GfuiElem sender, IptEventType eventType, IptArg eventArg, IptEvtDataKey keyData, IptEvtDataMouse mouseData) {return new_(sender, eventType, eventArg, keyData, IptEvtDataKeyHeld.Null, mouseData);}
@gplx.Internal protected static IptEventData new_(GfuiElem sender, IptEventType eventType, IptArg eventArg, IptEvtDataKey keyData, IptEvtDataKeyHeld keyPressData, IptEvtDataMouse mouseData) {
IptEventData rv = new IptEventData();
@@ -45,5 +45,5 @@ public class IptEventData {
rv.keyData = keyData; rv.keyPressData = keyPressData; rv.mouseData = mouseData;
return rv;
} IptEventData() {}
public static IptEventData ctx_(GfsCtx ctx, GfoMsg m) {return IptEventData.cast_(m.CastObj("iptData"));}
public static IptEventData ctx_(GfsCtx ctx, GfoMsg m) {return IptEventData.cast(m.CastObj("iptData"));}
}

View File

@@ -21,7 +21,7 @@ public class IptEvtDataKey {
public boolean Handled() {return handled;} public void Handled_set(boolean v) {handled = v;} private boolean handled;
public static IptEvtDataKey as_(Object obj) {return obj instanceof IptEvtDataKey ? (IptEvtDataKey)obj : null;}
public static IptEvtDataKey cast_(Object obj) {try {return (IptEvtDataKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKey.class, obj);}}
public static IptEvtDataKey cast(Object obj) {try {return (IptEvtDataKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKey.class, obj);}}
@gplx.Internal protected static final IptEvtDataKey Null = new_(IptKey_.None);
@gplx.Internal protected static IptEvtDataKey test_(IptKey keyArg) {return new_(keyArg);}
@gplx.Internal protected static IptEvtDataKey int_(int val) {

View File

@@ -21,7 +21,7 @@ public class IptEvtDataKeyHeld {
public boolean Handled() {return handled;} public void Handled_set(boolean v) {handled = v;} private boolean handled;
public static IptEvtDataKeyHeld as_(Object obj) {return obj instanceof IptEvtDataKeyHeld ? (IptEvtDataKeyHeld)obj : null;}
public static IptEvtDataKeyHeld cast_(Object obj) {try {return (IptEvtDataKeyHeld)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKeyHeld.class, obj);}}
public static IptEvtDataKeyHeld cast(Object obj) {try {return (IptEvtDataKeyHeld)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataKeyHeld.class, obj);}}
@gplx.Internal protected static final IptEvtDataKeyHeld Null = char_((char)0);
@gplx.Internal protected static IptEvtDataKeyHeld char_(char c) {
IptEvtDataKeyHeld rv = new IptEvtDataKeyHeld();

View File

@@ -22,7 +22,7 @@ public class IptEvtDataMouse {
public PointAdp Pos() {return location;} PointAdp location;
public static IptEvtDataMouse as_(Object obj) {return obj instanceof IptEvtDataMouse ? (IptEvtDataMouse)obj : null;}
public static IptEvtDataMouse cast_(Object obj) {try {return (IptEvtDataMouse)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataMouse.class, obj);}}
public static IptEvtDataMouse cast(Object obj) {try {return (IptEvtDataMouse)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptEvtDataMouse.class, obj);}}
@gplx.Internal protected static final IptEvtDataMouse Null = IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, 0, 0);
public static IptEvtDataMouse new_(IptMouseBtn button, IptMouseWheel wheel, int x, int y) {
IptEvtDataMouse rv = new IptEvtDataMouse();

View File

@@ -23,7 +23,7 @@ public class IptKey_ {
public static IptKey[] Ary(IptKey... ary) {return ary;}
public static final IptKey[] Ary_empty = new IptKey[0];
public static IptKey as_(Object obj) {return obj instanceof IptKey ? (IptKey)obj : null;}
public static IptKey cast_(Object obj) {try {return (IptKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptKey.class, obj);}}
public static IptKey cast(Object obj) {try {return (IptKey)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, IptKey.class, obj);}}
public static IptKey add_(IptKey... ary) {
if (ary.length == 0) return IptKey_.None;
int newVal = ary[0].Val();
@@ -35,10 +35,10 @@ public class IptKey_ {
IptKey rv = (IptKey)enm_mgr.Get(val);
return (rv == null) ? new_(val, "key_" + Int_.Xto_str(val)) : rv;
}
public static IptKey parse_(String raw) {return get_or_new_(enm_mgr.GetVal(raw));}
public static IptKey parse(String raw) {return get_or_new_(enm_mgr.GetVal(raw));}
public static IptKey rdr_or_(DataRdr rdr, String key, IptKey or) {
String val = rdr.ReadStrOr(key, ""); // NOTE: "" cannot be null, b/c nullRdr returns String.empty
return (String_.Eq(val, "")) ? or : parse_(val);
return (String_.Eq(val, "")) ? or : parse(val);
}
public static List_adp printableKeys2_(IptKey[] add, IptKey[] del) {
List_adp list = List_adp_.new_();

View File

@@ -25,7 +25,7 @@ public class IptKey__tst {
@Test public void To_str__numeric() {
fxt.Test_to_str(16777296, "key.#16777296");
}
@Test public void parse_() {
@Test public void parse() {
fxt.Test_parse("key.#10", 10);
}
}
@@ -34,6 +34,6 @@ class IptKey__fxt {
Tfds.Eq(expd, IptKey_.To_str(keycode));
}
public void Test_parse(String raw, int keycode) {
Tfds.Eq(keycode, IptKey_.parse_(raw).Val());
Tfds.Eq(keycode, IptKey_.parse(raw).Val());
}
}

View File

@@ -33,7 +33,7 @@ public class IptMouseBtn_ {
, X1 = new IptMouseBtn(Tid_x1 , "mouse.x1")
, X2 = new IptMouseBtn(Tid_x2 , "mouse.x2")
;
public static IptMouseBtn parse_(String raw) {
public static IptMouseBtn parse(String raw) {
if (String_.Eq(raw, None.Key())) return None;
else if (String_.Eq(raw, Left.Key())) return Left;
else if (String_.Eq(raw, Right.Key())) return Right;

View File

@@ -21,14 +21,14 @@ public class IptMouseWheel_ {
None = new IptMouseWheel("wheel.none")
, Up = new IptMouseWheel("wheel.up")
, Down = new IptMouseWheel("wheel.down");
public static IptMouseWheel parse_(String raw) {
public static IptMouseWheel parse(String raw) {
if (String_.Eq(raw, None.Key())) return None;
else if (String_.Eq(raw, Up.Key())) return Up;
else if (String_.Eq(raw, Down.Key())) return Down;
else throw Err_.new_parse_type(IptMouseWheel.class, raw);
}
@gplx.Internal protected static IptMouseWheel api_(Object obj) {
int delta = Int_.cast_(obj);
int delta = Int_.cast(obj);
if (delta > 0) return Up;
else if (delta < 0) return Down;
else return None;

View File

@@ -147,7 +147,7 @@ class GxwTextFld_cls_lang extends JTextField implements GxwTextFld {
this.SelBgn_set(0); this.SelLen_set(0); // otherwise will set cursor to end; want to see text start
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, GxwElem_lang.AlignH_cmd)) AlignH_(GfuiAlign_.cast_(m.CastObj("v")));
if (ctx.Match(k, GxwElem_lang.AlignH_cmd)) AlignH_(GfuiAlign_.cast(m.CastObj("v")));
return this;
}
public void SendKeyDown(IptKey key) {}

View File

@@ -293,7 +293,7 @@ public class GxwTextMemo_lang extends JScrollPane implements GxwTextMemo {
txt_box.setSelectionStart(0); txt_box.setSelectionEnd(0); // else selects whole text and scrolls to end of selection
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, GxwElem_lang.AlignH_cmd)) AlignH_(GfuiAlign_.cast_(m.CastObj("v")));
if (ctx.Match(k, GxwElem_lang.AlignH_cmd)) AlignH_(GfuiAlign_.cast(m.CastObj("v")));
return txt_box.Invk(ctx, ikey, k, m);
}
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
class GfuiFocusXferBnd implements InjectAble, GfoInvkAble {
public void Inject(Object owner) {
GfuiElem elem = GfuiElem_.cast_(owner);
GfuiElem elem = GfuiElem_.cast(owner);
IptBnd_.cmd_to_(IptCfg_.Null, elem, this, Invk_FocusNext, IptKey_.Down);
IptBnd_.cmd_to_(IptCfg_.Null, elem, this, Invk_FocusPrev, IptKey_.Up);
}
@@ -28,7 +28,7 @@ class GfuiFocusXferBnd implements InjectAble, GfoInvkAble {
GfuiElem target = cur;
while (true) { // find next visible elem
int cycle = TabBox_.Cycle(fwd, curIdx, allElemsInOwnerWin.Count());
target = GfuiElem_.cast_(allElemsInOwnerWin.Get_at(cycle));
target = GfuiElem_.cast(allElemsInOwnerWin.Get_at(cycle));
if (target.Visible()) break;
if (cycle == curIdx) break; // either (a) one elem in allElemsInOwnerWin or (b) n elems, and cycled back to start; break, else infinite loop
curIdx = cycle;
@@ -43,8 +43,8 @@ class GfuiFocusXferBnd implements InjectAble, GfoInvkAble {
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_FocusNext)) Focus(GfuiElem_.cast_(ctx.MsgSrc()), true);
else if (ctx.Match(k, Invk_FocusPrev)) Focus(GfuiElem_.cast_(ctx.MsgSrc()), false);
if (ctx.Match(k, Invk_FocusNext)) Focus(GfuiElem_.cast(ctx.MsgSrc()), true);
else if (ctx.Match(k, Invk_FocusPrev)) Focus(GfuiElem_.cast(ctx.MsgSrc()), false);
else return GfoInvkAble_.Rv_unhandled;
return this;
} public static final String Invk_FocusNext = "FocusNext", Invk_FocusPrev = "FocusPrev";

View File

@@ -111,7 +111,7 @@ public class GfuiMenuBar implements GfoInvkAble {
String keyChar = String_.MidByLen(text, pos + 1, 1);
if (!Char_.IsLetterEnglish(String_.CharAt(keyChar, 0))) return ipt; // keyChar is not a character; EX: 'A & B' (keyChar = space)
String keyCharRaw = "key." + String_.Lower(keyChar);
ipt = IptKey_.parse_(keyCharRaw);
ipt = IptKey_.parse(keyCharRaw);
text = String_.MidByLen(text, 0, pos) + String_.Mid(text, pos + 1); // remove mnemPrefix; ex: &File -> File && key.f
itm.Text_(text);
return ipt;
@@ -241,7 +241,7 @@ class GfuiMenuBarItmType {
public int Val() {return val;} int val;
public String Name() {return name;} private String name;
GfuiMenuBarItmType(int v, String n) {val = v; name = n; regy.Add(n, this);}
public static GfuiMenuBarItmType parse_(String raw) {
public static GfuiMenuBarItmType parse(String raw) {
try {return (GfuiMenuBarItmType)regy.Get_by(raw);}
catch (Exception e) {Err_.Noop(e); throw Err_.new_parse("GfuiMenuBarItmType", raw);}
}

View File

@@ -43,7 +43,7 @@ class GfuiWinKeyCmdMgr implements GfuiWinOpenAble, GfoInvkAble, GfoEvObj {
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
ctx.Match(k, k);
CheckForHotKey(IptEventData.ctx_(ctx, m));
//boolean handled = CheckForHotKey(IptEventData.cast_(msg.Val())); msg.Fwd_set(!handled); // TOMBSTONE: somehow cause alt-F4 to continue processing and dispose form
//boolean handled = CheckForHotKey(IptEventData.cast(msg.Val())); msg.Fwd_set(!handled); // TOMBSTONE: somehow cause alt-F4 to continue processing and dispose form
return this;
} @gplx.Internal protected static final String CheckForHotKey_cmd = "CheckForHotKey_cmd";
@@ -56,6 +56,6 @@ class GfuiWinKeyCmdMgr implements GfuiWinOpenAble, GfoInvkAble, GfoEvObj {
}
public static IptKey ExtractKeyFromText(String raw) {
int pos = ExtractPosFromText(raw); if (pos == String_.Find_none) return IptKey_.None;
return IptKey_.parse_("key." + String_.Lower(Char_.To_str(String_.CharAt(raw, pos + 1)))); // pos=& pos; + 1 to get next letter
return IptKey_.parse("key." + String_.Lower(Char_.To_str(String_.CharAt(raw, pos + 1)))); // pos=& pos; + 1 to get next letter
}
}

View File

@@ -24,7 +24,7 @@ public class GfuiWin_ {
, InitKey_winType_tool = "tool"
;
public static GfuiWin as_(Object obj) {return obj instanceof GfuiWin ? (GfuiWin)obj : null;}
public static GfuiWin cast_(Object obj) {try {return (GfuiWin)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiWin.class, obj);}}
public static GfuiWin cast(Object obj) {try {return (GfuiWin)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiWin.class, obj);}}
public static GfuiWin app_(String key) {return bld_(key, InitKey_winType_app, KeyValHash.new_());}
public static GfuiWin tool_(String key) {return bld_(key, InitKey_winType_tool, KeyValHash.new_()).TaskbarVisible_(false);}
public static GfuiWin sub_(String key, GfuiWin ownerWin) {

View File

@@ -268,7 +268,7 @@ public class GfuiElemBase implements GfuiElem {
underMgr = underElem.Core();
subElems = GfuiElemList.new_(this);
textMgr = GfxStringData.new_(this, underElem);
this.Focus_able_(Bool_.cast_(ctorArgs.FetchValOr(GfuiElem_.InitKey_focusAble, true)));
this.Focus_able_(Bool_.cast(ctorArgs.FetchValOr(GfuiElem_.InitKey_focusAble, true)));
underMgr.Size_set(SizeAdp_.new_(20, 20)); // NOTE: CS inits to 20,20; JAVA inits to 0,0
}
@gplx.Virtual public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, KeyValHash ctorArgs) {
@@ -279,7 +279,7 @@ public class GfuiElemBase implements GfuiElem {
underMgr = underElem.Core();
subElems = GfuiElemList.new_(this);
textMgr = GfxStringData.new_(this, underElem);
this.Focus_able_(Bool_.cast_(ctorArgs.FetchValOr(GfuiElem_.InitKey_focusAble, true)));
this.Focus_able_(Bool_.cast(ctorArgs.FetchValOr(GfuiElem_.InitKey_focusAble, true)));
// underMgr.Size_set(SizeAdp_.new_(20, 20)); // NOTE: CS inits to 20,20; JAVA inits to 0,0
}
@gplx.Virtual public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.control_();}

View File

@@ -18,5 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class GfuiElemBase_ {
public static GfuiElemBase as_(Object obj) {return obj instanceof GfuiElemBase ? (GfuiElemBase)obj : null;}
public static GfuiElemBase cast_(Object obj) {try {return (GfuiElemBase)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiElemBase.class, obj);}}
public static GfuiElemBase cast(Object obj) {try {return (GfuiElemBase)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiElemBase.class, obj);}}
}

View File

@@ -21,7 +21,7 @@ public class GfuiElem_ {
InitKey_focusAble = "focusAble"
, InitKey_ownerWin = "ownerForm";
public static GfuiElem as_(Object obj) {return obj instanceof GfuiElem ? (GfuiElem)obj : null;}
public static GfuiElem cast_(Object obj) {try {return (GfuiElem)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiElem.class, obj);}}
public static GfuiElem cast(Object obj) {try {return (GfuiElem)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiElem.class, obj);}}
public static GfuiElemBase sub_(String key, GfuiElem owner) {
GfuiElemBase rv = new_();
rv.Owner_(owner, key);

View File

@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
class GfuiBtnClickBnd implements InjectAble, GfoInvkAble {
public void Inject(Object owner) {
GfuiElem elem = GfuiElem_.cast_(owner);
GfuiElem elem = GfuiElem_.cast(owner);
IptBnd_.cmd_(IptCfg_.Null, elem, GfuiElemKeys.ActionExec_cmd, IptKey_.Enter, IptKey_.Space);
IptBnd_.cmd_(IptCfg_.Null, elem, GfuiElemKeys.Focus_cmd, IptMouseBtn_.Left);
IptBnd_.ipt_to_(IptCfg_.Null, elem, this, ExecMouseUp_cmd, IptEventType_.MouseUp, IptMouseBtn_.Left);
}
void ExecMouseUp(IptEventData iptData) {
GfuiElem elem = GfuiElem_.cast_(iptData.Sender());
GfuiElem elem = GfuiElem_.cast(iptData.Sender());
int x = iptData.MousePos().X(), y = iptData.MousePos().Y();
SizeAdp buttonSize = elem.Size();
if ( x >= 0 && x <= buttonSize.Width()

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class GfuiBtn_ {
public static GfuiBtn as_(Object obj) {return obj instanceof GfuiBtn ? (GfuiBtn)obj : null;}
public static GfuiBtn cast_(Object obj) {try {return (GfuiBtn)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiBtn.class, obj);}}
public static GfuiBtn cast(Object obj) {try {return (GfuiBtn)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiBtn.class, obj);}}
public static GfuiBtn msg_(String key, GfuiElem owner, GfoMsg msg) {
GfuiBtn rv = new_(key); rv.Owner_(owner);

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class GfuiChkBox_ {
public static GfuiChkBox as_(Object obj) {return obj instanceof GfuiChkBox ? (GfuiChkBox)obj : null;}
public static GfuiChkBox cast_(Object obj) {try {return (GfuiChkBox)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiChkBox.class, obj);}}
public static GfuiChkBox cast(Object obj) {try {return (GfuiChkBox)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiChkBox.class, obj);}}
@gplx.Internal protected static GfuiChkBox new_() {
GfuiChkBox rv = new GfuiChkBox();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_true_());

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class GfuiTextBox_ {
public static GfuiTextBox as_(Object obj) {return obj instanceof GfuiTextBox ? (GfuiTextBox)obj : null;}
public static GfuiTextBox cast_(Object obj) {try {return (GfuiTextBox)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiTextBox.class, obj);}}
public static GfuiTextBox cast(Object obj) {try {return (GfuiTextBox)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiTextBox.class, obj);}}
public static final String NewLine = "\n";
public static final String Ctor_Memo = "TextBox_Memo";

View File

@@ -30,7 +30,7 @@ public class DataBndr_whenEvt_execCmd implements InjectAble, GfoInvkAble, GfoEvO
return this;
} GfoInvkAble getInvk; String getCmd;
public void Inject(Object owner) {
setInvk = GfoInvkAble_.cast_(owner);
setInvk = GfoInvkAble_.cast(owner);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, whenEvt)) {

View File

@@ -55,7 +55,7 @@ public class GfuiMoveElemBnd implements IptBnd, GfoInvkAble, InjectAble {
}
void ExecKeyDown(IptEventData msg) {
PointAdp current = targetElem.Pos();
PointAdp offset = PointAdp_.cast_(hash.Get_by(msg.EventArg()));
PointAdp offset = PointAdp_.cast(hash.Get_by(msg.EventArg()));
targetElem.Pos_(current.Op_add(offset));
}
@gplx.Internal protected void Key_set(String key) {this.key = key;} private String key;

View File

@@ -39,7 +39,7 @@ class TabBoxEvt_tabSelectByBtn {
}
class TabBnd_selectTab implements InjectAble, GfoInvkAble {
public void Inject(Object obj) {
tabBox = TabBox_.cast_(obj);
tabBox = TabBox_.cast(obj);
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectNext_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Tab), IptKey_.add_(IptKey_.Ctrl, IptKey_.PageDown));
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectPrev_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Tab, IptKey_.Shift), IptKey_.add_(IptKey_.Ctrl, IptKey_.PageUp));
}
@@ -59,7 +59,7 @@ class TabBnd_selectTab implements InjectAble, GfoInvkAble {
}
class TabBnd_reorderTab implements InjectAble, GfoInvkAble {
public void Inject(Object owner) {
GfuiBtn btn = GfuiBtn_.cast_(owner);
GfuiBtn btn = GfuiBtn_.cast(owner);
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MovePrev_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Left));
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MoveNext_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Right));
}
@@ -75,8 +75,8 @@ class TabBnd_reorderTab implements InjectAble, GfoInvkAble {
TabBoxEvt_orderChanged.Publish(tabBox, curIdx, newIdx);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, MoveNext_cmd)) MoveTab(GfuiBtn_.cast_(ctx.MsgSrc()), 1);
else if (ctx.Match(k, MovePrev_cmd)) MoveTab(GfuiBtn_.cast_(ctx.MsgSrc()), -1);
if (ctx.Match(k, MoveNext_cmd)) MoveTab(GfuiBtn_.cast(ctx.MsgSrc()), 1);
else if (ctx.Match(k, MovePrev_cmd)) MoveTab(GfuiBtn_.cast(ctx.MsgSrc()), -1);
else return GfoInvkAble_.Rv_unhandled;
return this;
} public static final String MoveNext_cmd = "MoveNext", MovePrev_cmd = "MovePrev";

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
public class TabBox_ {
public static TabBox as_(Object obj) {return obj instanceof TabBox ? (TabBox)obj : null;}
public static TabBox cast_(Object obj) {try {return (TabBox)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TabBox.class, obj);}}
public static TabBox cast(Object obj) {try {return (TabBox)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TabBox.class, obj);}}
public static TabBox new_() {
TabBox rv = new TabBox();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_false_());

View File

@@ -22,11 +22,12 @@ import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
public class IconAdp {
public Icon UnderIcon() {return icon;} final Icon icon;
public Icon UnderIcon() {return icon;} private final Icon icon;
public Image XtoImage() {return ((ImageIcon)icon).getImage();}
public Io_url Url() {return url;} Io_url url = Io_url_.Empty;
public Io_url Url() {return url;} private Io_url url = Io_url_.Empty;
IconAdp(Icon icon) {this.icon = icon;}
public static IconAdp new_(Icon icon) {return new IconAdp(icon);}
public static IconAdp file_or_blank(Io_url url) {return file_(url);}
public static IconAdp file_(Io_url url) {
Icon icon = new ImageIcon(url.Xto_api());
IconAdp rv = new IconAdp(icon);

View File

@@ -31,7 +31,7 @@ import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class ImageAdp_ {
public static ImageAdp as_(Object obj) {return obj instanceof ImageAdp ? (ImageAdp)obj : null;}
public static ImageAdp cast_(Object obj) {try {return (ImageAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ImageAdp.class, obj);}}
public static ImageAdp cast(Object obj) {try {return (ImageAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ImageAdp.class, obj);}}
public static final ImageAdp Null = new_(10, 10);
public static ImageAdp new_(int width, int height) {
// BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // JAVA: must be TYPE_INT_RGB or else ImageIO.write("bmp") will fail
@@ -44,7 +44,7 @@ public class ImageAdp_ {
SizeAdp size = null;
if (String_.Eq(raw, "")) size = SizeAdp_.Zero;
else if (String_.Eq(url.Ext(), ".svg")) size = SizeOf_svg(url);
else size = SizeAdp_.parse_(raw);
else size = SizeAdp_.parse(raw);
return new ImageAdp_txt(url, size);
}
public static SizeAdp SizeOf_svg(Io_url url) {return Gfui_svg_util.QuerySize(url);}
@@ -121,6 +121,6 @@ class Gfui_svg_util {
if (px != -1) end = px;
String str = String_.Mid(xml, bgn, end);
pos_ref.Val_(end);
return Double_.parse_(str);
return Double_.parse(str);
}
}

View File

@@ -23,12 +23,12 @@ import java.awt.Toolkit;
public class ScreenAdp_ {
public static final ScreenAdp Primary = screen_(0);
public static ScreenAdp as_(Object obj) {return obj instanceof ScreenAdp ? (ScreenAdp)obj : null;}
public static ScreenAdp cast_(Object obj) {try {return (ScreenAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ScreenAdp.class, obj);}}
public static ScreenAdp parse_(String raw) { // ex: {screen{1}
public static ScreenAdp cast(Object obj) {try {return (ScreenAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ScreenAdp.class, obj);}}
public static ScreenAdp parse(String raw) { // ex: {screen{1}
try {
raw = String_.Replace(raw, "{screen{", "");
raw = String_.Replace(raw, "}", "");
return ScreenAdp_.screen_(Int_.parse_(raw));
return ScreenAdp_.screen_(Int_.parse(raw));
} catch(Exception exc) {throw Err_.new_parse_exc(exc, ScreenAdp.class, raw);}
}
public static ScreenAdp from_point_(PointAdp pos) {// NOTE: not using FromPoint b/c of plat_wce

View File

@@ -28,6 +28,6 @@ class Gfui_dlg_msg_null implements Gfui_dlg_msg {
public Gfui_dlg_msg Init_ico_(int v) {return this;}
public Gfui_dlg_msg Init_btns_(int... ary) {return this;}
public boolean Ask(int expd) {return false;}
public int Ask() {return Int_.MinValue;}
public int Ask() {return Int_.Min_value;}
public static final Gfui_dlg_msg_null _ = new Gfui_dlg_msg_null(); Gfui_dlg_msg_null() {}
}

View File

@@ -172,7 +172,7 @@ public class Swt_kit implements Gfui_kit {
int args_len = args.length;
for (int i = 0; i < args_len; i++)
ctor_args.Add(args[i]);
boolean border_on = Bool_.cast_(ctor_args.FetchValOr(GfuiTextBox.CFG_border_on_, true));
boolean border_on = Bool_.cast(ctor_args.FetchValOr(GfuiTextBox.CFG_border_on_, true));
GxwTextFld under = new Swt_text_w_border(Swt_control_.cast_or_fail(owner), New_color(border_on ? ColorAdp_.LightGray : ColorAdp_.White), ctor_args);
GfuiTextBox rv = GfuiTextBox_.kit_(this, key, under, ctor_args);
rv.Owner_(owner);
@@ -261,7 +261,7 @@ class Swt_shell_close_lnr implements Listener, GfoInvkAble {
@Override public void handleEvent(Event event) {
if (kit.Kit_mode__term()) return; // NOTE: will be term if called again from wait_for_sync_cmd
kit.Kit_mode_(Swt_kit_mode.Tid_term); // NOTE: must mark kit as shutting down, else writing to status_bar will create stack overflow; DATE:2014-05-05
boolean rslt = Bool_.cast_(kit.Kit_term_cbk().Invk()); // call bgn term
boolean rslt = Bool_.cast(kit.Kit_term_cbk().Invk()); // call bgn term
if (!rslt) {
event.doit = false; // cbk canceled term; stop close
kit.Kit_mode_(Swt_kit_mode.Tid_ready); // reset kit back to "running" mode;

View File

@@ -30,5 +30,5 @@ public abstract class GfxItm_base implements GfxItm {
pos = posVal; size = sizeVal;
}
public static GfxItm_base as_(Object obj) {return obj instanceof GfxItm_base ? (GfxItm_base)obj : null;}
public static GfxItm_base cast_(Object obj) {try {return (GfxItm_base)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfxItm_base.class, obj);}}
public static GfxItm_base cast(Object obj) {try {return (GfxItm_base)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfxItm_base.class, obj);}}
}

View File

@@ -36,5 +36,5 @@ public class GfxLineItm implements GfxItm {
return rv;
} GfxLineItm() {}
public static GfxLineItm as_(Object obj) {return obj instanceof GfxLineItm ? (GfxLineItm)obj : null;}
public static GfxLineItm cast_(Object obj) {try {return (GfxLineItm)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfxLineItm.class, obj);}}
public static GfxLineItm cast(Object obj) {try {return (GfxLineItm)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfxLineItm.class, obj);}}
}

View File

@@ -26,7 +26,7 @@ public class IptArg_parser_tst {
tst_parse_Key_("key.pageUp", IptKey_.PageUp);
tst_parse_Key_("key.ctrl", IptKey_.Ctrl);
tst_parse_Key_("key.none", IptKey_.None);
} void tst_parse_Key_(String raw, IptKey expd) {Tfds.Eq(expd.Val(), IptKey_.parse_(raw).Val());}
} void tst_parse_Key_(String raw, IptKey expd) {Tfds.Eq(expd.Val(), IptKey_.parse(raw).Val());}
@Test public void KbdCmdModifiers() {
tst_parse_Key_("key.ctrl+key.enter", IptKey_.Ctrl.Add(IptKey_.Enter));
tst_parse_Key_("key.alt+key.escape", IptKey_.Alt.Add(IptKey_.Escape));
@@ -43,11 +43,11 @@ public class IptArg_parser_tst {
tst_parse_MouseBtn_("mouse.middle", IptMouseBtn_.Middle);
tst_parse_MouseBtn_("mouse.x1", IptMouseBtn_.X1);
tst_parse_MouseBtn_("mouse.x2", IptMouseBtn_.X2);
} void tst_parse_MouseBtn_(String raw, IptMouseBtn expd) {Tfds.Eq(expd, IptMouseBtn_.parse_(raw));}
} void tst_parse_MouseBtn_(String raw, IptMouseBtn expd) {Tfds.Eq(expd, IptMouseBtn_.parse(raw));}
@Test public void MouseWheel() {
tst_parse_MouseWheel_("wheel.up", IptMouseWheel_.Up);
tst_parse_MouseWheel_("wheel.down", IptMouseWheel_.Down);
} void tst_parse_MouseWheel_(String raw, IptMouseWheel expd) {Tfds.Eq(expd, IptMouseWheel_.parse_(raw));}
} void tst_parse_MouseWheel_(String raw, IptMouseWheel expd) {Tfds.Eq(expd, IptMouseWheel_.parse(raw));}
@Test public void Mod() {
tst_parse_("mod.c", IptKey_.Ctrl);
tst_parse_("mod.cs", IptKey_.add_(IptKey_.Ctrl, IptKey_.Shift));
@@ -59,5 +59,5 @@ public class IptArg_parser_tst {
tst_parse_("mouse.left", IptMouseBtn_.Left);
tst_parse_("wheel.up", IptMouseWheel_.Up);
tst_parse_("mod.c", IptKey_.Ctrl);
} void tst_parse_(String raw, IptArg expd) {Tfds.Eq(expd, IptArg_.parse_(raw));}
} void tst_parse_(String raw, IptArg expd) {Tfds.Eq(expd, IptArg_.parse(raw));}
}

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.gfui; import gplx.*;
import org.junit.*;
public class ScreenAdp_tst {
@Test public void parse_() {
ScreenAdp actl = ScreenAdp_.parse_("{screen{0}");
@Test public void parse() {
ScreenAdp actl = ScreenAdp_.parse("{screen{0}");
Tfds.Eq(0, actl.Index());
}
@Test public void opposite_() {

View File

@@ -41,7 +41,7 @@ class Swt_html implements Gxw_html, Swt_control, FocusListener {
lnr_location = new Swt_html_lnr_location(this);
lnr_status = new Swt_html_lnr_status(this);
Object browser_tid_obj = ctorArgs.FetchValOr(Swt_kit.Cfg_Html_BrowserType, null);
this.browser_tid = browser_tid_obj == null ? Browser_tid_none : Int_.cast_(browser_tid_obj);
this.browser_tid = browser_tid_obj == null ? Browser_tid_none : Int_.cast(browser_tid_obj);
browser = new Browser(owner_control.Under_composite(), browser_tid);
core = new Swt_core_cmds_html(this, browser);
browser.addKeyListener(new Swt_lnr_key(this));
@@ -75,7 +75,7 @@ class Swt_html implements Gxw_html, Swt_control, FocusListener {
public void Html_js_enabled_(boolean v) {browser.setJavascriptEnabled(v);}
public void Html_js_cbks_add(String func_name, GfoInvkAble invk) {new Swt_html_func(browser, func_name, invk);}
public String Html_js_eval_script(String script) {return Eval_script_as_str(script);}
public boolean Html_js_eval_proc_as_bool(String proc, Object... args) {return Bool_.cast_(Html_js_eval_proc_as_obj(proc, args));}
public boolean Html_js_eval_proc_as_bool(String proc, Object... args) {return Bool_.cast(Html_js_eval_proc_as_obj(proc, args));}
public String Html_js_eval_proc_as_str(String proc, Object... args) {return Object_.Xto_str_strict_or_null(Html_js_eval_proc_as_obj(proc, args));}
private Object Html_js_eval_proc_as_obj(String proc, Object... args) {
Bry_bfr bfr = Bry_bfr.new_();