mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.5.1.1'
This commit is contained in:
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import gplx.core.strings.*; import gplx.core.texts.*;
|
||||
import gplx.core.strings.*; import gplx.core.encoders.*;
|
||||
public class ColorAdp {
|
||||
public int Value() {return val;} int val;
|
||||
public int Alpha() {return (255 & val >> 24);}
|
||||
@@ -26,10 +26,10 @@ public class ColorAdp {
|
||||
public String XtoHexStr() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
sb.Add("#");
|
||||
sb.Add(HexDecUtl.To_str(Alpha(), 2));
|
||||
sb.Add(HexDecUtl.To_str(Red(), 2));
|
||||
sb.Add(HexDecUtl.To_str(Green(), 2));
|
||||
sb.Add(HexDecUtl.To_str(Blue(), 2));
|
||||
sb.Add(Hex_utl_.To_str(Alpha(), 2));
|
||||
sb.Add(Hex_utl_.To_str(Red(), 2));
|
||||
sb.Add(Hex_utl_.To_str(Green(), 2));
|
||||
sb.Add(Hex_utl_.To_str(Blue(), 2));
|
||||
return sb.To_str();
|
||||
}
|
||||
public boolean Eq(Object obj) {
|
||||
@@ -52,5 +52,5 @@ class ColorAdpCache {
|
||||
return (java.awt.Color)rv;
|
||||
}
|
||||
Hash_adp hash = Hash_adp_.new_();
|
||||
public static final ColorAdpCache Instance = new ColorAdpCache(); ColorAdpCache() {}
|
||||
public static final ColorAdpCache Instance = new ColorAdpCache(); ColorAdpCache() {}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import gplx.core.texts.*; import gplx.core.interfaces.*;
|
||||
import gplx.core.encoders.*; import gplx.core.interfaces.*;
|
||||
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 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 static final ColorAdp_ Parser = new ColorAdp_();
|
||||
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;
|
||||
@@ -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++] = Hex_utl_.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);}
|
||||
@@ -95,7 +95,7 @@ public class ColorAdp_ implements ParseAble {
|
||||
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 final ColorAdp
|
||||
public static final ColorAdp
|
||||
Null = new_( 0, 0, 0, 0)
|
||||
, Black = new_(255, 0, 0, 0)
|
||||
, White = new_(255, 255, 255, 255)
|
||||
|
||||
@@ -25,6 +25,7 @@ public interface Gxw_html extends GxwElem {
|
||||
boolean Html_js_eval_proc_as_bool (String name, Object... args);
|
||||
String Html_js_eval_script (String script);
|
||||
void Html_js_cbks_add (String js_func_name, GfoInvkAble invk);
|
||||
String Html_js_send_json (String name, String data);
|
||||
void Html_invk_src_(GfoEvObj v);
|
||||
void Html_dispose();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class Gfui_html extends GfuiElemBase {
|
||||
@gplx.Virtual public String Html_js_eval_proc_as_str(String name, Object... args) {return under.Html_js_eval_proc_as_str(name, args);}
|
||||
@gplx.Virtual public boolean Html_js_eval_proc_as_bool(String name, Object... args) {return under.Html_js_eval_proc_as_bool(name, args);}
|
||||
public String Html_js_eval_script(String script) {return under.Html_js_eval_script(script);}
|
||||
public String Html_js_send_json(String name, String data) {return under.Html_js_send_json(name, data);}
|
||||
public void Html_js_cbks_add(String js_func_name, GfoInvkAble invk) {under.Html_js_cbks_add(js_func_name, invk);}
|
||||
public void Html_invk_src_(GfoEvObj v) {under.Html_invk_src_(v);}
|
||||
public void Html_dispose() {under.Html_dispose();}
|
||||
|
||||
@@ -31,6 +31,7 @@ class Mem_html extends GxwTextMemo_lang implements Gxw_html { public void Html_
|
||||
public byte Html_doc_html_load_tid() {return html_doc_html_load_tid;} private byte html_doc_html_load_tid;
|
||||
public void Html_doc_html_load_tid_(byte v) {html_doc_html_load_tid = v;}
|
||||
public String Html_js_eval_script(String script) {return "";}
|
||||
public String Html_js_send_json(String name, String data) {return "";}
|
||||
String ExtractAtr(String key, String txt, int pos) {
|
||||
int key_pos = String_.FindBwd(txt, key, pos); if (key_pos == String_.Find_none) return null;
|
||||
int q0 = String_.FindFwd(txt, "\"", key_pos); if (q0 == String_.Find_none) return null;
|
||||
|
||||
@@ -318,6 +318,7 @@ class Swt_kit_mode {
|
||||
class Swt_gui_cmd implements GfuiInvkCmd, Runnable {
|
||||
private final Swt_kit kit; private final Gfo_usr_dlg usr_dlg; private final Display display; private final GfoInvkAble target; private final boolean async;
|
||||
private GfsCtx invk_ctx; private int invk_ikey; private String invk_key; private GfoMsg invk_msg;
|
||||
private Object rv_obj;
|
||||
public Swt_gui_cmd(Swt_kit kit, Gfo_usr_dlg usr_dlg, Display display, GfoInvkAble target, boolean async) {
|
||||
this.kit = kit; this.usr_dlg = usr_dlg; this.display = display; this.target = target; this.async = async;
|
||||
}
|
||||
@@ -330,11 +331,11 @@ class Swt_gui_cmd implements GfuiInvkCmd, Runnable {
|
||||
try {display.syncExec(this);}
|
||||
finally {kit.Kit_sync_cmd_del(this);}
|
||||
}
|
||||
return this;
|
||||
return rv_obj;
|
||||
}
|
||||
@Override public void run() {
|
||||
synchronized (this) {// needed for Special:Search and async; DATE:2015-04-23
|
||||
try {target.Invk(invk_ctx, invk_ikey, invk_key, invk_msg);}
|
||||
try {rv_obj = target.Invk(invk_ctx, invk_ikey, invk_key, invk_msg);}
|
||||
catch (Exception e) {
|
||||
if (kit.Kit_mode__term()) return; // NOTE: if shutting down, don't warn; warn will try to write to status.bar, which will fail b/c SWT is shutting down; failures will try to write to status.bar again, causing StackOverflow exception; DATE:2014-05-04
|
||||
usr_dlg.Warn_many("", "", "fatal error while running; key=~{0} err=~{1}", invk_key, Err_.Message_gplx_full(e));
|
||||
|
||||
@@ -39,8 +39,9 @@ public class ImageAdp_tst {
|
||||
DateAdp afterModifiedTime = Io_mgr.Instance.QueryFil(save).ModifiedTime();
|
||||
Tfds.Eq_true(CompareAble_.Is_more(afterModifiedTime, beforeModifiedTime));
|
||||
|
||||
String loadHash = HashAlgo_.Md5.CalcHash(Console_adp_.Noop, Io_mgr.Instance.OpenStreamRead(load));
|
||||
String saveHash = HashAlgo_.Md5.CalcHash(Console_adp_.Noop, Io_mgr.Instance.OpenStreamRead(save));
|
||||
Hash_algo algo = Hash_algo_.New__md5();
|
||||
String loadHash = algo.Hash_stream_as_str(Console_adp_.Noop, Io_mgr.Instance.OpenStreamRead(load));
|
||||
String saveHash = algo.Hash_stream_as_str(Console_adp_.Noop, Io_mgr.Instance.OpenStreamRead(save));
|
||||
Tfds.Eq(loadHash, saveHash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ class Swt_html implements Gxw_html, Swt_control, FocusListener {
|
||||
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 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", "") );
|
||||
return (String)Eval_script(script);
|
||||
}
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user