mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Refactor: Refactor baselib; merge Array_ and Bool_
This commit is contained in:
@@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.elems; import gplx.Bool_;
|
||||
package gplx.gfui.controls.elems; import gplx.objects.primitives.BoolUtl;
|
||||
import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_evt_mgr;
|
||||
@@ -324,7 +324,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
underMgr = underElem.Core();
|
||||
subElems = GfuiElemList.new_(this);
|
||||
textMgr = GfxStringData.new_(this, underElem);
|
||||
this.Focus_able_(Bool_.Cast(ctorArgs.Get_val_or(GfuiElem_.InitKey_focusAble, true)));
|
||||
this.Focus_able_(BoolUtl.Cast(ctorArgs.Get_val_or(GfuiElem_.InitKey_focusAble, true)));
|
||||
underMgr.Size_set(SizeAdp_.new_(20, 20)); // NOTE: CS inits to 20,20; JAVA inits to 0,0
|
||||
}
|
||||
public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, Keyval_hash ctorArgs) {
|
||||
@@ -335,7 +335,7 @@ public class GfuiElemBase implements GfuiElem {
|
||||
underMgr = underElem.Core();
|
||||
subElems = GfuiElemList.new_(this);
|
||||
textMgr = GfxStringData.new_(this, underElem);
|
||||
this.Focus_able_(Bool_.Cast(ctorArgs.Get_val_or(GfuiElem_.InitKey_focusAble, true)));
|
||||
this.Focus_able_(BoolUtl.Cast(ctorArgs.Get_val_or(GfuiElem_.InitKey_focusAble, true)));
|
||||
// underMgr.Size_set(SizeAdp_.new_(20, 20)); // NOTE: CS inits to 20,20; JAVA inits to 0,0
|
||||
}
|
||||
public GxwElem UnderElem_make(Keyval_hash ctorArgs) {return GxwElemFactory_.Instance.control_();}
|
||||
|
||||
@@ -14,8 +14,9 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.controls.windows; import gplx.*;
|
||||
import gplx.core.lists.*; /*ComparerAble*/
|
||||
import gplx.gfui.controls.elems.*;
|
||||
import gplx.objects.lists.CompareAbleUtl;
|
||||
import gplx.objects.lists.ComparerAble;
|
||||
public class GfuiFocusOrderer {
|
||||
public static void OrderByX(GfuiElem owner) {Order(owner, xcomparer, 0);}
|
||||
public static void OrderByY(GfuiElem owner) {Order(owner, ycomparer, 0);}
|
||||
@@ -42,16 +43,16 @@ public class GfuiFocusOrderer {
|
||||
class GfuiFocusOrderer_cls_x implements ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
GfuiElem lhs = (GfuiElem)lhsObj, rhs = (GfuiElem)rhsObj;
|
||||
if (lhs.Y() < rhs.Y()) return CompareAble_.Less;
|
||||
else if (lhs.Y() > rhs.Y()) return CompareAble_.More;
|
||||
if (lhs.Y() < rhs.Y()) return CompareAbleUtl.Less;
|
||||
else if (lhs.Y() > rhs.Y()) return CompareAbleUtl.More;
|
||||
else return Int_.Compare(lhs.X(), rhs.X());
|
||||
}
|
||||
}
|
||||
class GfuiFocusOrderer_cls_y implements ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
GfuiElem lhs = (GfuiElem)lhsObj, rhs = (GfuiElem)rhsObj;
|
||||
if (lhs.X() < rhs.X()) return CompareAble_.Less;
|
||||
else if (lhs.X() > rhs.X()) return CompareAble_.More;
|
||||
if (lhs.X() < rhs.X()) return CompareAbleUtl.Less;
|
||||
else if (lhs.X() > rhs.X()) return CompareAbleUtl.More;
|
||||
else return Int_.Compare(lhs.Y(), rhs.Y());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.imgs; import gplx.*; import gplx.gfui.*;
|
||||
package gplx.gfui.imgs; import gplx.*;
|
||||
import gplx.objects.lists.CompareAbleUtl;
|
||||
import org.junit.*;
|
||||
import gplx.core.consoles.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.core.security.algos.*;
|
||||
import gplx.gfui.imgs.*;
|
||||
public class ImageAdp_tst {
|
||||
@Before public void setup() {
|
||||
load = Tfds.RscDir.GenSubFil_nest("150_gfui", "imgs", "strawberry_java.bmp");
|
||||
@@ -36,7 +34,7 @@ public class ImageAdp_tst {
|
||||
DateAdp beforeModifiedTime = Io_mgr.Instance.QueryFil(save).ModifiedTime();
|
||||
img.SaveAsBmp(save);
|
||||
DateAdp afterModifiedTime = Io_mgr.Instance.QueryFil(save).ModifiedTime();
|
||||
Tfds.Eq_true(CompareAble_.Is(CompareAble_.More, afterModifiedTime, beforeModifiedTime));
|
||||
Tfds.Eq_true(CompareAbleUtl.Is(CompareAbleUtl.More, afterModifiedTime, beforeModifiedTime));
|
||||
|
||||
Hash_algo algo = Hash_algo_.New__md5();
|
||||
String loadHash = Hash_algo_utl.Calc_hash_as_str(algo, Io_mgr.Instance.LoadFilBry(load));
|
||||
|
||||
@@ -14,7 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.ipts;
|
||||
import gplx.Bool_;
|
||||
import gplx.objects.primitives.BoolUtl;
|
||||
import gplx.Err_;
|
||||
import gplx.Int_;
|
||||
import gplx.List_adp;
|
||||
@@ -241,10 +241,10 @@ public class IptKey_ {
|
||||
public static String To_str(int orig_val) {
|
||||
String mod_str = "", rv = "";
|
||||
int temp_val = orig_val;
|
||||
boolean mod_c = Bitmask_.Has_int(temp_val, IptKey_.Ctrl.Val()); if (mod_c) {mod_str += "c"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Ctrl.Val());}
|
||||
boolean mod_a = Bitmask_.Has_int(temp_val, IptKey_.Alt.Val()); if (mod_a) {mod_str += "a"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Alt.Val());}
|
||||
boolean mod_s = Bitmask_.Has_int(temp_val, IptKey_.Shift.Val()); if (mod_s) {mod_str += "s"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Shift.Val());}
|
||||
boolean mod_m = Bitmask_.Has_int(temp_val, IptKey_.Meta.Val()); if (mod_m) {mod_str += "m"; temp_val = Bitmask_.Flip_int(Bool_.N, temp_val, IptKey_.Meta.Val());}
|
||||
boolean mod_c = Bitmask_.Has_int(temp_val, IptKey_.Ctrl.Val()); if (mod_c) {mod_str += "c"; temp_val = Bitmask_.Flip_int(BoolUtl.N, temp_val, IptKey_.Ctrl.Val());}
|
||||
boolean mod_a = Bitmask_.Has_int(temp_val, IptKey_.Alt.Val()); if (mod_a) {mod_str += "a"; temp_val = Bitmask_.Flip_int(BoolUtl.N, temp_val, IptKey_.Alt.Val());}
|
||||
boolean mod_s = Bitmask_.Has_int(temp_val, IptKey_.Shift.Val()); if (mod_s) {mod_str += "s"; temp_val = Bitmask_.Flip_int(BoolUtl.N, temp_val, IptKey_.Shift.Val());}
|
||||
boolean mod_m = Bitmask_.Has_int(temp_val, IptKey_.Meta.Val()); if (mod_m) {mod_str += "m"; temp_val = Bitmask_.Flip_int(BoolUtl.N, temp_val, IptKey_.Meta.Val());}
|
||||
if (String_.Len_gt_0(mod_str)) {
|
||||
rv = "mod." + mod_str;
|
||||
// handle modifiers only, like "mod.cs"; else will be "mod.cs+key.#0"
|
||||
|
||||
@@ -13,30 +13,82 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.core; import gplx.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.imgs.*;
|
||||
import gplx.gfui.controls.standards.*;
|
||||
import gplx.gfui.kits.swts.*;
|
||||
package gplx.gfui.kits.core;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_invk;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.Gfo_invk_cmd;
|
||||
import gplx.Gfo_usr_dlg;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Hash_adp;
|
||||
import gplx.Hash_adp_;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.Io_url;
|
||||
import gplx.Io_url_;
|
||||
import gplx.Keyval;
|
||||
import gplx.Keyval_hash;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.String_;
|
||||
import gplx.UsrDlg_;
|
||||
import gplx.UsrMsg;
|
||||
import gplx.UsrMsgWkr;
|
||||
import gplx.UsrMsgWkr_;
|
||||
import gplx.core.brys.fmtrs.Bry_fmtr;
|
||||
import gplx.core.threads.Thread_adp_;
|
||||
import gplx.gfui.controls.customs.GfuiStatusBox;
|
||||
import gplx.gfui.controls.customs.GfuiStatusBox_;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.controls.gxws.GxwTextFld;
|
||||
import gplx.gfui.controls.standards.GfuiBtn;
|
||||
import gplx.gfui.controls.standards.GfuiBtn_;
|
||||
import gplx.gfui.controls.standards.GfuiComboBox;
|
||||
import gplx.gfui.controls.standards.GfuiLbl;
|
||||
import gplx.gfui.controls.standards.GfuiLbl_;
|
||||
import gplx.gfui.controls.standards.GfuiTextBox;
|
||||
import gplx.gfui.controls.standards.GfuiTextBox_;
|
||||
import gplx.gfui.controls.standards.Gfui_grp;
|
||||
import gplx.gfui.controls.standards.Gfui_html;
|
||||
import gplx.gfui.controls.standards.Gfui_tab_mgr;
|
||||
import gplx.gfui.controls.windows.GfoConsoleWin;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.controls.windows.GfuiWin_;
|
||||
import gplx.gfui.draws.ColorAdp;
|
||||
import gplx.gfui.draws.ColorAdp_;
|
||||
import gplx.gfui.imgs.ImageAdp;
|
||||
import gplx.gfui.imgs.ImageAdp_;
|
||||
import gplx.gfui.kits.swts.Swt_btn_no_border;
|
||||
import gplx.gfui.kits.swts.Swt_clipboard;
|
||||
import gplx.gfui.kits.swts.Swt_combo_ctrl;
|
||||
import gplx.gfui.kits.swts.Swt_control_;
|
||||
import gplx.gfui.kits.swts.Swt_dlg_dir;
|
||||
import gplx.gfui.kits.swts.Swt_dlg_file;
|
||||
import gplx.gfui.kits.swts.Swt_dlg_msg;
|
||||
import gplx.gfui.kits.swts.Swt_grp;
|
||||
import gplx.gfui.kits.swts.Swt_html;
|
||||
import gplx.gfui.kits.swts.Swt_img;
|
||||
import gplx.gfui.kits.swts.Swt_lbl;
|
||||
import gplx.gfui.kits.swts.Swt_lnr__menu_detect;
|
||||
import gplx.gfui.kits.swts.Swt_popup_grp;
|
||||
import gplx.gfui.kits.swts.Swt_tab_mgr;
|
||||
import gplx.gfui.kits.swts.Swt_text;
|
||||
import gplx.gfui.kits.swts.Swt_text_w_border;
|
||||
import gplx.gfui.kits.swts.Swt_win;
|
||||
import gplx.objects.primitives.BoolUtl;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Cursor;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Cursor;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.gfui.controls.customs.GfuiStatusBox;
|
||||
import gplx.gfui.controls.customs.GfuiStatusBox_;
|
||||
import gplx.gfui.controls.elems.GfuiElem;
|
||||
import gplx.gfui.controls.gxws.GxwTextFld;
|
||||
import gplx.gfui.controls.windows.GfoConsoleWin;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.controls.windows.GfuiWin_;
|
||||
import gplx.gfui.draws.*;
|
||||
public class Swt_kit implements Gfui_kit {
|
||||
private final Keyval_hash ctor_args = new Keyval_hash(); private final Keyval_hash ctor_args_null = new Keyval_hash();
|
||||
private final Hash_adp kit_args = Hash_adp_.New(); private Swt_msg_wkr_stop msg_wkr_stop;
|
||||
@@ -125,8 +177,8 @@ public class Swt_kit implements Gfui_kit {
|
||||
Swt_dlg_msg dlg = (Swt_dlg_msg)New_dlg_msg(ask_fmtr.Bld_str_many(ask_bfr, fmt, args)).Init_btns_(Gfui_dlg_msg_.Btn_ok).Init_ico_(Gfui_dlg_msg_.Ico_information);
|
||||
display.syncExec(dlg);
|
||||
}
|
||||
public GfuiInvkCmd New_cmd_sync (Gfo_invk invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, Bool_.N);}
|
||||
public GfuiInvkCmd New_cmd_async(Gfo_invk invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, Bool_.Y);}
|
||||
public GfuiInvkCmd New_cmd_sync (Gfo_invk invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, BoolUtl.N);}
|
||||
public GfuiInvkCmd New_cmd_async(Gfo_invk invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, BoolUtl.Y);}
|
||||
public GfuiWin New_win_utl(String key, GfuiWin owner, Keyval... args) {
|
||||
return GfuiWin_.kit_(this, key, new Swt_win(shell), ctor_args_null);
|
||||
}
|
||||
@@ -177,7 +229,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.Get_val_or(GfuiTextBox.CFG_border_on_, true));
|
||||
boolean border_on = BoolUtl.Cast(ctor_args.Get_val_or(GfuiTextBox.CFG_border_on_, true));
|
||||
GxwTextFld under = new Swt_text_w_border(this, 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);
|
||||
@@ -285,7 +337,7 @@ class Swt_shell_close_lnr implements Listener, Gfo_invk {
|
||||
@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().Exec()); // call bgn term
|
||||
boolean rslt = BoolUtl.Cast(kit.Kit_term_cbk().Exec()); // 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;
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.String_;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts;
|
||||
import gplx.objects.strings.AsciiByte;
|
||||
import org.eclipse.swt.*;
|
||||
import org.eclipse.swt.browser.*;
|
||||
import org.eclipse.swt.custom.*;
|
||||
@@ -231,11 +229,11 @@ public class Swt_app_main {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent arg0) {
|
||||
System.out.println(combo.getText());
|
||||
if (arg0.keyCode == Byte_ascii.Ltr_a) {
|
||||
if (arg0.keyCode == AsciiByte.Ltr_a) {
|
||||
combo.setItem(0, "a");
|
||||
combo.setListVisible(true);
|
||||
}
|
||||
else if (arg0.keyCode == Byte_ascii.Ltr_b) {
|
||||
else if (arg0.keyCode == AsciiByte.Ltr_b) {
|
||||
combo.setItem(0, "b");
|
||||
combo.setListVisible(true);
|
||||
}
|
||||
|
||||
@@ -1,38 +1,36 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
|
||||
import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts;
|
||||
import gplx.Gfo_evt_mgr;
|
||||
import gplx.Gfo_evt_mgr_;
|
||||
import gplx.Gfo_evt_mgr_owner;
|
||||
import gplx.Keyval_hash;
|
||||
import gplx.String_;
|
||||
import gplx.core.envs.Op_sys;
|
||||
import gplx.core.envs.Op_sys_;
|
||||
import gplx.core.threads.Thread_adp_;
|
||||
import gplx.gfui.controls.gxws.GxwComboBox;
|
||||
import gplx.gfui.controls.gxws.GxwElem;
|
||||
import gplx.gfui.draws.ColorAdp;
|
||||
import gplx.gfui.controls.standards.GfuiComboBox;
|
||||
import gplx.gfui.draws.ColorAdp;
|
||||
import gplx.gfui.kits.core.Swt_kit;
|
||||
|
||||
import gplx.objects.primitives.BoolUtl;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
@@ -122,7 +120,7 @@ class Swt_combo_list {
|
||||
public String[] Items_str_ary() {return items_str_ary;} private String[] items_str_ary = String_.Ary_empty;
|
||||
public void Items_(String[] new_ary) {
|
||||
int new_len = new_ary.length;
|
||||
if (new_len == 0) Visible_(Bool_.N); // if new_ary is empty, then hide list box; else, brief flicker as items are removed
|
||||
if (new_len == 0) Visible_(BoolUtl.N); // if new_ary is empty, then hide list box; else, brief flicker as items are removed
|
||||
|
||||
// remove all cur-items that are no longer needed b/c new_ary is smaller
|
||||
int cur_len = list_len;
|
||||
@@ -159,7 +157,7 @@ class Swt_combo_list {
|
||||
public void Sel_idx_nudge(boolean fwd) {Sel_idx_adj(fwd, 1);}
|
||||
public void Sel_idx_jump(boolean fwd) {Sel_idx_adj(fwd, Jump_len);}
|
||||
private void Sel_idx_adj(boolean fwd, int adj) {
|
||||
if (!Visible()) Visible_(Bool_.Y); // these are called by cursor keys; always make visible
|
||||
if (!Visible()) Visible_(BoolUtl.Y); // these are called by cursor keys; always make visible
|
||||
int cur_idx = table.getSelectionIndex();
|
||||
int new_idx = cur_idx;
|
||||
int idx_n = list_len - 1;
|
||||
@@ -233,7 +231,7 @@ class Swt_combo_text__key_down implements Listener { // for list-box, highligh
|
||||
if (event.stateMask == SWT.ALT) {
|
||||
list.Visible_(true);
|
||||
} else {
|
||||
list.Sel_idx_nudge(Bool_.Y);
|
||||
list.Sel_idx_nudge(BoolUtl.Y);
|
||||
}
|
||||
event.doit = false;
|
||||
break;
|
||||
@@ -241,27 +239,27 @@ class Swt_combo_text__key_down implements Listener { // for list-box, highligh
|
||||
if (event.stateMask == SWT.ALT) {
|
||||
list.Visible_(false);
|
||||
} else {
|
||||
list.Sel_idx_nudge(Bool_.N);
|
||||
list.Sel_idx_nudge(BoolUtl.N);
|
||||
}
|
||||
event.doit = false;
|
||||
break;
|
||||
case SWT.PAGE_DOWN:
|
||||
if (no_modifier) {
|
||||
list.Sel_idx_jump(Bool_.Y);
|
||||
list.Sel_idx_jump(BoolUtl.Y);
|
||||
event.doit = false;
|
||||
}
|
||||
else if (ctrl_modifier || alt_modifier) {
|
||||
list.Visible_(Bool_.N);
|
||||
list.Visible_(BoolUtl.N);
|
||||
event.doit = false;
|
||||
}
|
||||
break;
|
||||
case SWT.PAGE_UP:
|
||||
if (no_modifier) {
|
||||
list.Sel_idx_jump(Bool_.N);
|
||||
list.Sel_idx_jump(BoolUtl.N);
|
||||
event.doit = false;
|
||||
}
|
||||
else if (ctrl_modifier || alt_modifier) {
|
||||
list.Visible_(Bool_.N);
|
||||
list.Visible_(BoolUtl.N);
|
||||
event.doit = false;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,43 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
|
||||
import gplx.Byte_ascii;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
import gplx.Enm_;
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts;
|
||||
import gplx.Gfo_evt_mgr_;
|
||||
import gplx.Gfo_invk_;
|
||||
import gplx.GfoMsg_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.String_;
|
||||
import gplx.Tfds;
|
||||
import gplx.core.bits.Bitmask_;
|
||||
import gplx.core.envs.Op_sys;
|
||||
import gplx.core.envs.Op_sys_;
|
||||
import gplx.gfui.controls.gxws.GxwElem;
|
||||
import gplx.gfui.controls.standards.Gfui_html;
|
||||
import gplx.gfui.controls.windows.GfuiWin;
|
||||
import gplx.gfui.ipts.*;
|
||||
|
||||
import gplx.gfui.ipts.IptEvtDataKey;
|
||||
import gplx.gfui.ipts.IptEvtDataMouse;
|
||||
import gplx.gfui.ipts.IptKey_;
|
||||
import gplx.gfui.ipts.IptMouseBtn;
|
||||
import gplx.gfui.ipts.IptMouseBtn_;
|
||||
import gplx.gfui.ipts.IptMouseWheel_;
|
||||
import gplx.objects.primitives.BoolUtl;
|
||||
import gplx.objects.strings.AsciiByte;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.KeyListener;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
@@ -67,14 +62,14 @@ class Swt_lnr_traverse implements Listener {
|
||||
class Swt_lnr_key implements KeyListener {
|
||||
public Swt_lnr_key(GxwElem elem) {this.elem = elem;} private GxwElem elem;
|
||||
@Override public void keyPressed(KeyEvent ev) {
|
||||
IptEvtDataKey ipt_data = To_gfui(ev, Bool_.Y);
|
||||
IptEvtDataKey ipt_data = To_gfui(ev, BoolUtl.Y);
|
||||
|
||||
// cancel if handled; note order MUST be "delegate || ipt_data.Handled", not vice-versa
|
||||
if (!elem.Host().KeyDownCbk(ipt_data) || ipt_data.Handled())
|
||||
ev.doit = false;
|
||||
}
|
||||
@Override public void keyReleased(KeyEvent ev) {
|
||||
IptEvtDataKey ipt_data = To_gfui(ev, Bool_.N);
|
||||
IptEvtDataKey ipt_data = To_gfui(ev, BoolUtl.N);
|
||||
|
||||
// cancel if handled; note order MUST be "delegate || ipt_data.Handled", not vice-versa
|
||||
if (!elem.Host().KeyUpCbk(ipt_data) || ipt_data.Handled())
|
||||
@@ -85,11 +80,11 @@ class Swt_lnr_key implements KeyListener {
|
||||
int val = ev.keyCode;
|
||||
switch (val) {
|
||||
// letters; lowercase keys are transmitted as ascii value, instead of key value; EX: "a": SWT=97; SWING=65
|
||||
case Byte_ascii.Ltr_a: case Byte_ascii.Ltr_b: case Byte_ascii.Ltr_c: case Byte_ascii.Ltr_d: case Byte_ascii.Ltr_e:
|
||||
case Byte_ascii.Ltr_f: case Byte_ascii.Ltr_g: case Byte_ascii.Ltr_h: case Byte_ascii.Ltr_i: case Byte_ascii.Ltr_j:
|
||||
case Byte_ascii.Ltr_k: case Byte_ascii.Ltr_l: case Byte_ascii.Ltr_m: case Byte_ascii.Ltr_n: case Byte_ascii.Ltr_o:
|
||||
case Byte_ascii.Ltr_p: case Byte_ascii.Ltr_q: case Byte_ascii.Ltr_r: case Byte_ascii.Ltr_s: case Byte_ascii.Ltr_t:
|
||||
case Byte_ascii.Ltr_u: case Byte_ascii.Ltr_v: case Byte_ascii.Ltr_w: case Byte_ascii.Ltr_x: case Byte_ascii.Ltr_y: case Byte_ascii.Ltr_z:
|
||||
case AsciiByte.Ltr_a: case AsciiByte.Ltr_b: case AsciiByte.Ltr_c: case AsciiByte.Ltr_d: case AsciiByte.Ltr_e:
|
||||
case AsciiByte.Ltr_f: case AsciiByte.Ltr_g: case AsciiByte.Ltr_h: case AsciiByte.Ltr_i: case AsciiByte.Ltr_j:
|
||||
case AsciiByte.Ltr_k: case AsciiByte.Ltr_l: case AsciiByte.Ltr_m: case AsciiByte.Ltr_n: case AsciiByte.Ltr_o:
|
||||
case AsciiByte.Ltr_p: case AsciiByte.Ltr_q: case AsciiByte.Ltr_r: case AsciiByte.Ltr_s: case AsciiByte.Ltr_t:
|
||||
case AsciiByte.Ltr_u: case AsciiByte.Ltr_v: case AsciiByte.Ltr_w: case AsciiByte.Ltr_x: case AsciiByte.Ltr_y: case AsciiByte.Ltr_z:
|
||||
val -= 32;
|
||||
break;
|
||||
|
||||
@@ -148,7 +143,7 @@ class Swt_lnr_key implements KeyListener {
|
||||
case SWT.F12: val = IptKey_.F12.Val(); break;
|
||||
|
||||
// SWT=13; SWING=10; note that Cr maps to "enter key"
|
||||
case Byte_ascii.Cr: val = IptKey_.Enter.Val(); break;
|
||||
case AsciiByte.Cr: val = IptKey_.Enter.Val(); break;
|
||||
|
||||
case SWT.INSERT: val = IptKey_.Insert.Val(); break;
|
||||
case 127: val = IptKey_.Delete.Val(); break;
|
||||
|
||||
@@ -15,10 +15,10 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts;
|
||||
|
||||
import gplx.Bool_;
|
||||
import gplx.objects.primitives.BoolUtl;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.objects.strings.AsciiByte;
|
||||
import gplx.Err_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_evt_itm;
|
||||
@@ -118,7 +118,7 @@ public class Swt_html implements Gxw_html, Swt_control, FocusListener, Gfo_evt_m
|
||||
public void Html_js_cbks_add(String func_name, Gfo_invk invk) {new Swt_html_func(browser, func_name, invk);}
|
||||
public String Html_js_eval_script(String script) {return Eval_script_as_str(script);}
|
||||
public Object Html_js_eval_script_as_obj(String script) {return Eval_script(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 BoolUtl.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));}
|
||||
public String Html_js_send_json(String name, String data) {
|
||||
String script = String_.Format("return {0}('{1}');", name, String_.Replace(data, "\n", "") );
|
||||
@@ -126,26 +126,26 @@ public class Swt_html implements Gxw_html, Swt_control, FocusListener, Gfo_evt_m
|
||||
}
|
||||
private Object Html_js_eval_proc_as_obj(String proc, Object... args) {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
bfr.Add_str_a7("return ").Add_str_u8(proc).Add_byte(Byte_ascii.Paren_bgn);
|
||||
bfr.Add_str_a7("return ").Add_str_u8(proc).Add_byte(AsciiByte.ParenBgn);
|
||||
int args_len = args.length;
|
||||
for (int i = 0; i < args_len; ++i) {
|
||||
Object arg = args[i];
|
||||
if (i != 0) bfr.Add_byte(Byte_ascii.Comma);
|
||||
if (i != 0) bfr.Add_byte(AsciiByte.Comma);
|
||||
boolean quote_val = true;
|
||||
if ( Type_.Eq_by_obj(arg, Bool_.Cls_ref_type)
|
||||
if ( Type_.Eq_by_obj(arg, BoolUtl.ClsRefType)
|
||||
|| Type_.Eq_by_obj(arg, Int_.Cls_ref_type)
|
||||
|| Type_.Eq_by_obj(arg, Long_.Cls_ref_type)
|
||||
) {
|
||||
quote_val = false;
|
||||
}
|
||||
if (quote_val) bfr.Add_byte(Byte_ascii.Apos);
|
||||
if (quote_val) bfr.Add_byte(AsciiByte.Apos);
|
||||
if (quote_val)
|
||||
bfr.Add_str_u8(Escape_quote(Object_.Xto_str_strict_or_null_mark(arg)));
|
||||
else
|
||||
bfr.Add_obj_strict(arg);
|
||||
if (quote_val) bfr.Add_byte(Byte_ascii.Apos);
|
||||
if (quote_val) bfr.Add_byte(AsciiByte.Apos);
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Paren_end).Add_byte(Byte_ascii.Semic);
|
||||
bfr.Add_byte(AsciiByte.ParenEnd).Add_byte(AsciiByte.Semic);
|
||||
return Eval_script(bfr.To_str_and_clear());
|
||||
}
|
||||
public static String Escape_quote(String v) {
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfui.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import gplx.Bool_;
|
||||
import gplx.objects.primitives.BoolUtl;
|
||||
import gplx.Gfo_invk_cmd;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.GfsCtx;
|
||||
@@ -54,8 +54,8 @@ public class Swt_win implements GxwWin, Swt_control {
|
||||
@Override public Control Under_control() {return shell;}
|
||||
@Override public Composite Under_composite() {return shell;}
|
||||
@Override public Control Under_menu_control() {return shell;}
|
||||
public Swt_win(Shell owner) {ctor(Bool_.Y, new Shell(owner, SWT.RESIZE | SWT.DIALOG_TRIM), owner.getDisplay());}
|
||||
public Swt_win(Display display) {ctor(Bool_.N, new Shell(display), display); }
|
||||
public Swt_win(Shell owner) {ctor(BoolUtl.Y, new Shell(owner, SWT.RESIZE | SWT.DIALOG_TRIM), owner.getDisplay());}
|
||||
public Swt_win(Display display) {ctor(BoolUtl.N, new Shell(display), display); }
|
||||
public void ShowWin() {shell.setVisible(true);}
|
||||
public void HideWin() {shell.setVisible(false);}
|
||||
public boolean Maximized() {return shell.getMaximized();} public void Maximized_(boolean v) {shell.setMaximized(v);}
|
||||
|
||||
Reference in New Issue
Block a user