mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.2.1
This commit is contained in:
39
150_gfui/src_700_env/gplx/gfui/GfoFactory_gfui.java
Normal file
39
150_gfui/src_700_env/gplx/gfui/GfoFactory_gfui.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class GfoFactory_gfui {
|
||||
public static void Btn_MinWin(GfuiElem owner, GfoMsg appWinMsg) {
|
||||
GfuiBtn_.msg_("minWin", owner, GfoMsg_.chain_(appWinMsg, GfuiWin.Invk_Minimize)).Text_("_").TipText_("minmize window").Width_(20);
|
||||
}
|
||||
public static void Btn_MinWin2(GfuiElem owner) {
|
||||
GfuiBtn_.msg_("minWin", owner, GfoMsg_.root_(".", GfuiElemBase.Invk_OwnerWin_cmd, GfuiWin.Invk_Minimize)).Text_("_").TipText_("minmize window").Width_(20);
|
||||
}
|
||||
public static void Btn_MoveBox(GfuiElem owner, GfuiElem target) {
|
||||
GfuiElem rv = GfuiBtn_.new_("moveBox").Owner_(owner).Text_("*").TipText_("move box").Width_(20);
|
||||
GfuiMoveElemBnd bnd = GfuiMoveElemBnd.new_();
|
||||
bnd.TargetElem_set(target);
|
||||
rv.Inject_(bnd);
|
||||
}
|
||||
public static GfuiBtn Btn_QuitWin3(GfuiElem owner) {
|
||||
return (GfuiBtn)GfuiBtn_.msg_("quitWin", owner, GfoMsg_.root_(".", GfuiElemBase.Invk_OwnerWin_cmd, GfuiWin.Invk_Quit)).Text_("X").TipText_("quit win").Width_(20);
|
||||
}
|
||||
public static void Btn_QuitWin2(GfuiElem owner, GfoMsg quitMsg) {
|
||||
GfuiBtn_.msg_("quitWin", owner, quitMsg).Text_("X").TipText_("quit win").Width_(20);
|
||||
}
|
||||
public static final GfoFactory_gfui _ = new GfoFactory_gfui(); GfoFactory_gfui() {}
|
||||
}
|
||||
24
150_gfui/src_700_env/gplx/gfui/GfsLibIni_gfui.java
Normal file
24
150_gfui/src_700_env/gplx/gfui/GfsLibIni_gfui.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class GfsLibIni_gfui implements GfsLibIni {
|
||||
public void Ini(GfsCore core) {
|
||||
core.AddCmd(IptCfgRegy._, "IptBndMgr_");
|
||||
}
|
||||
public static final GfsLibIni_gfui _ = new GfsLibIni_gfui(); GfsLibIni_gfui() {}
|
||||
}
|
||||
109
150_gfui/src_700_env/gplx/gfui/GfuiEnv_.java
Normal file
109
150_gfui/src_700_env/gplx/gfui/GfuiEnv_.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.gfml.*;
|
||||
import gplx.core.threads.*;
|
||||
import java.awt.AWTKeyStroke;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
public class GfuiEnv_ {
|
||||
static FontAdp system_font;
|
||||
public static void Exit() {if (!Env_.Mode_testing()) System.exit(0);}
|
||||
public static void Init(String[] args, String appNameAndExt, Class<?> type) {Init(args, appNameAndExt, type, true);}
|
||||
public static void Init(String[] args, String appNameAndExt, Class<?> type, boolean swingHack) {
|
||||
Env_.Init(args, appNameAndExt, type);
|
||||
if (swingHack) { // TODO: move to kit dependent functionality; WHEN: swing kit
|
||||
if (Op_sys.Cur().Tid_is_wnt()) {
|
||||
try {UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");}
|
||||
catch (ClassNotFoundException e) {e.printStackTrace();}
|
||||
catch (InstantiationException e) {e.printStackTrace();}
|
||||
catch (IllegalAccessException e) {e.printStackTrace();}
|
||||
catch (UnsupportedLookAndFeelException e) {e.printStackTrace();}
|
||||
}
|
||||
Set<AWTKeyStroke> fwdSet = new HashSet<AWTKeyStroke>(); fwdSet.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
|
||||
Set<AWTKeyStroke> bwdSet = new HashSet<AWTKeyStroke>(); bwdSet.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, java.awt.event.InputEvent.SHIFT_DOWN_MASK ));
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, fwdSet);
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdSet);
|
||||
}
|
||||
if (!Op_sys.Cur().Tid_is_drd())
|
||||
GxwElemFactory_.winForms_();
|
||||
|
||||
// reg interruptLnr
|
||||
if (swingHack) { // TODO: move to kit dependent functionality; WHEN: swing kit
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Warn, GfoConsoleWin._);
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Stop, GfuiInterruptLnr.new_());
|
||||
}
|
||||
IptBndMgr_win = IptCfg_.new_("gplx.gfui.GfuiWin");
|
||||
|
||||
// alias default dirs
|
||||
Io_mgr.I.AliasDir_sysEngine("app:\\", Env_.AppUrl().OwnerDir().Raw());
|
||||
|
||||
GfsCore._.MsgParser_(GfoMsgParser_gfml._);
|
||||
GfsCore._.AddLib(GfsLibIni_core._);
|
||||
GfsCore._.AddLib(GfsLibIni_gfui._);
|
||||
Io_url iniFile = Env_.AppUrl().GenSubFil(".gfs");
|
||||
if (Io_mgr.I.ExistsFil(iniFile))
|
||||
GfsCore._.ExecFile(iniFile);
|
||||
}
|
||||
public static void Init_swt(String[] args, Class<?> type) {
|
||||
Env_.Init_swt(args, type);
|
||||
if (!Op_sys.Cur().Tid_is_drd()) GxwElemFactory_.winForms_();
|
||||
GfsCore._.MsgParser_(GfoMsgParser_gfml._);
|
||||
}
|
||||
public static void Gfs_init() {GfsCore._.MsgParser_(GfoMsgParser_gfml._);}
|
||||
public static IptCfg IptBndMgr_win;
|
||||
public static void DoEvents() {;}
|
||||
public static void ShowMsg(String message) {javax.swing.JOptionPane.showMessageDialog(null, message, "", javax.swing.JOptionPane.INFORMATION_MESSAGE, null);}
|
||||
public static void BringToFront(ProcessAdp process) {}
|
||||
public static void DoEvents(int milliseconds) {
|
||||
Thread_adp_.Sleep(milliseconds);
|
||||
}
|
||||
public static void Run(GfuiWin form) {javax.swing.SwingUtilities.invokeLater(new GfuiFormRunner(form));}
|
||||
public static FontAdp System_font() {
|
||||
try {
|
||||
if (system_font == null) {
|
||||
Font label_font = (Font)UIManager.get("Label.font");
|
||||
system_font = FontAdp.new_(label_font.getFamily(), label_font.getSize(), FontStyleAdp_.Plain);
|
||||
}
|
||||
return system_font;
|
||||
} catch (Exception e) {return FontAdp.new_("Arial", 8, FontStyleAdp_.Plain);}
|
||||
}
|
||||
public static final String Quit_commit_evt = "quit_commit_evt", Quit_notify_evt = "quit_notify_evt";
|
||||
public static final String Err_GfuiException = "gplx.dbs.GfuiException"; // TODO: used in JAVA. move
|
||||
}
|
||||
class GfuiInterruptLnr implements UsrMsgWkr {
|
||||
public void ExecUsrMsg(int type, UsrMsg umsg) {GfuiEnv_.ShowMsg(umsg.XtoStr());}
|
||||
public static GfuiInterruptLnr new_() {return new GfuiInterruptLnr();} GfuiInterruptLnr() {}
|
||||
}
|
||||
class GfuiFormRunner implements Runnable {
|
||||
public GfuiFormRunner(GfuiWin form) {this.form = form;} GfuiWin form;
|
||||
public void run() {
|
||||
form.Show();
|
||||
}
|
||||
}
|
||||
//#}
|
||||
23
150_gfui/src_700_env/gplx/gfui/GfuiInvkCmd.java
Normal file
23
150_gfui/src_700_env/gplx/gfui/GfuiInvkCmd.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public interface GfuiInvkCmd extends GfoInvkAble, RlsAble {
|
||||
}
|
||||
class GfuiInvkCmd_ {
|
||||
public static final String Invk_sync = "Sync";
|
||||
}
|
||||
27
150_gfui/src_700_env/gplx/gfui/Gfui_clipboard.java
Normal file
27
150_gfui/src_700_env/gplx/gfui/Gfui_clipboard.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public interface Gfui_clipboard extends GfoInvkAble, RlsAble {
|
||||
void Copy(String s);
|
||||
}
|
||||
class Gfui_clipboard_null implements Gfui_clipboard {
|
||||
public void Copy(String s) {}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
public void Rls() {}
|
||||
public static final Gfui_clipboard_null Null = new Gfui_clipboard_null(); Gfui_clipboard_null() {}
|
||||
}
|
||||
21
150_gfui/src_700_env/gplx/gfui/Gfui_clipboard_.java
Normal file
21
150_gfui/src_700_env/gplx/gfui/Gfui_clipboard_.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Gfui_clipboard_ {
|
||||
public static final String Invk_copy = "copy", Invk_select_all = "select_all";
|
||||
}
|
||||
33
150_gfui/src_700_env/gplx/gfui/Gfui_dlg_file.java
Normal file
33
150_gfui/src_700_env/gplx/gfui/Gfui_dlg_file.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public interface Gfui_dlg_file {
|
||||
Gfui_dlg_file Init_msg_(String v);
|
||||
Gfui_dlg_file Init_file_(String v);
|
||||
Gfui_dlg_file Init_dir_(Io_url v);
|
||||
Gfui_dlg_file Init_exts_(String... v);
|
||||
String Ask();
|
||||
}
|
||||
class Gfui_dlg_file_null implements Gfui_dlg_file {
|
||||
public Gfui_dlg_file Init_msg_(String v) {return this;}
|
||||
public Gfui_dlg_file Init_file_(String v) {return this;}
|
||||
public Gfui_dlg_file Init_dir_(Io_url v) {return this;}
|
||||
public Gfui_dlg_file Init_exts_(String... v) {return this;}
|
||||
public String Ask() {return "";}
|
||||
public static final Gfui_dlg_file_null _ = new Gfui_dlg_file_null(); Gfui_dlg_file_null() {}
|
||||
}
|
||||
33
150_gfui/src_700_env/gplx/gfui/Gfui_dlg_msg.java
Normal file
33
150_gfui/src_700_env/gplx/gfui/Gfui_dlg_msg.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public interface Gfui_dlg_msg {
|
||||
Gfui_dlg_msg Init_msg_(String v);
|
||||
Gfui_dlg_msg Init_ico_(int v);
|
||||
Gfui_dlg_msg Init_btns_(int... ary);
|
||||
int Ask();
|
||||
boolean Ask(int expd);
|
||||
}
|
||||
class Gfui_dlg_msg_null implements Gfui_dlg_msg {
|
||||
public Gfui_dlg_msg Init_msg_(String v) {return this;}
|
||||
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 static final Gfui_dlg_msg_null _ = new Gfui_dlg_msg_null(); Gfui_dlg_msg_null() {}
|
||||
}
|
||||
22
150_gfui/src_700_env/gplx/gfui/Gfui_dlg_msg_.java
Normal file
22
150_gfui/src_700_env/gplx/gfui/Gfui_dlg_msg_.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Gfui_dlg_msg_ {
|
||||
public static final int Ico_error = 0, Ico_information = 1, Ico_question = 2, Ico_warning = 3, Ico_working = 4;
|
||||
public static final int Btn_ok = 0, Btn_cancel = 1, Btn_yes = 2, Btn_no = 3, Retry = 4, Btn_abort = 5, Btn_ignore = 6;
|
||||
}
|
||||
50
150_gfui/src_700_env/gplx/gfui/Gfui_kit.java
Normal file
50
150_gfui/src_700_env/gplx/gfui/Gfui_kit.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public interface Gfui_kit extends GfoInvkAble {
|
||||
byte Tid();
|
||||
String Key();
|
||||
void Cfg_set(String type, String key, Object val);
|
||||
boolean Kit_mode__ready();
|
||||
void Kit_init(Gfo_usr_dlg gui_wtr);
|
||||
void Kit_run();
|
||||
void Kit_term();
|
||||
void Kit_term_cbk_(GfoInvkAbleCmd cmd);
|
||||
Gfui_clipboard Clipboard();
|
||||
void Ask_ok(String grp_key, String msg_key, String fmt, Object... args);
|
||||
boolean Ask_yes_no(String grp_key, String msg_key, String fmt, Object... args);
|
||||
boolean Ask_ok_cancel(String grp_key, String msg_key, String fmt, Object... args);
|
||||
int Ask_yes_no_cancel(String grp_key, String msg_key, String fmt, Object... args);
|
||||
GfuiInvkCmd New_cmd_sync(GfoInvkAble invk);
|
||||
GfuiInvkCmd New_cmd_async(GfoInvkAble invk);
|
||||
GfuiWin New_win_app(String key, KeyVal... args);
|
||||
GfuiWin New_win_utl(String key, GfuiWin owner, KeyVal... args);
|
||||
Gfui_html New_html(String key, GfuiElem owner, KeyVal... args);
|
||||
Gfui_tab_mgr New_tab_mgr(String key, GfuiElem owner, KeyVal... args);
|
||||
GfuiTextBox New_text_box(String key, GfuiElem owner, KeyVal... args);
|
||||
GfuiBtn New_btn(String key, GfuiElem owner, KeyVal... args);
|
||||
GfuiLbl New_lbl(String key, GfuiElem owner, KeyVal... args);
|
||||
Gfui_dlg_file New_dlg_file(byte type, String msg);
|
||||
Gfui_dlg_msg New_dlg_msg(String msg);
|
||||
ImageAdp New_img_load(Io_url path);
|
||||
Object New_color(int a, int r, int g, int b);
|
||||
Gfui_mnu_grp New_mnu_popup(String key, GfuiElem owner);
|
||||
Gfui_mnu_grp New_mnu_bar(String key, GfuiWin owner);
|
||||
void Set_mnu_popup(GfuiElem owner, Gfui_mnu_grp grp);
|
||||
float Calc_font_height(GfuiElem elem, String s);
|
||||
}
|
||||
32
150_gfui/src_700_env/gplx/gfui/Gfui_kit_.java
Normal file
32
150_gfui/src_700_env/gplx/gfui/Gfui_kit_.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Gfui_kit_ {
|
||||
public static final byte Mem_tid = 0, Swing_tid = 1, Swt_tid = 2, Android_tid = 3;
|
||||
public static Gfui_kit Mem() {return mem_kit;} private static final Gfui_kit mem_kit = Mem_kit._;
|
||||
public static Gfui_kit Swt() {if (swt_kit == null) swt_kit = Swt_kit._; return swt_kit;} private static Gfui_kit swt_kit; // NOTE: late-binding else swing apps will fail (since swt jar is not deployed)
|
||||
public static Gfui_kit Swing() {if (swing_kit == null) swing_kit = Swing_kit._; return swing_kit;} private static Gfui_kit swing_kit;
|
||||
public static Gfui_kit Get_by_key(String key) {
|
||||
if (String_.Eq(key, Mem().Key())) return Mem();
|
||||
else if (String_.Eq(key, Swt().Key())) return Swt();
|
||||
else if (String_.Eq(key, Swing().Key())) return Swing();
|
||||
else throw Exc_.new_unhandled(key);
|
||||
}
|
||||
public static final String Cfg_HtmlBox = "HtmlBox";
|
||||
public static final byte File_dlg_type_open = 0, File_dlg_type_save = 1;
|
||||
}
|
||||
109
150_gfui/src_700_env/gplx/gfui/Gfui_kit_base.java
Normal file
109
150_gfui/src_700_env/gplx/gfui/Gfui_kit_base.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public abstract class Gfui_kit_base implements Gfui_kit {
|
||||
private KeyValHash ctor_args = KeyValHash.new_();
|
||||
public abstract byte Tid();
|
||||
public abstract String Key();
|
||||
public abstract GxwElemFactory_base Factory();
|
||||
public GfuiWin Main_win() {return main_win;} public Gfui_kit Main_win_(GfuiWin v) {main_win = v; return this;} private GfuiWin main_win;
|
||||
public Gfui_clipboard Clipboard() {return Gfui_clipboard_null.Null;}
|
||||
public GfoInvkAbleCmd Kit_term_cbk() {return kit_term_cbk;} public void Kit_term_cbk_(GfoInvkAbleCmd v) {kit_term_cbk = v;} private GfoInvkAbleCmd kit_term_cbk;
|
||||
public void Cfg_set(String type, String key, Object val) {}
|
||||
public boolean Kit_mode__ready() {return true;}
|
||||
public void Kit_init(Gfo_usr_dlg gui_wtr) {}
|
||||
@gplx.Virtual public void Kit_run() {}
|
||||
@gplx.Virtual public void Kit_term() {kit_term_cbk.Invk();}
|
||||
@gplx.Virtual public void Ask_ok(String grp_key, String msg_key, String fmt, Object... args) {}
|
||||
public boolean Ask_yes_no(String grp_key, String msg_key, String fmt, Object... args) {return false;}
|
||||
public int Ask_yes_no_cancel(String grp_key, String msg_key, String fmt, Object... args) {return Gfui_dlg_msg_.Btn_cancel;}
|
||||
public boolean Ask_ok_cancel(String grp_key, String msg_key, String fmt, Object... args) {return false;}
|
||||
public void Btn_img_(GfuiBtn btn, IconAdp v) {}
|
||||
public GfuiInvkCmd New_cmd_sync(GfoInvkAble invk) {return new Gfui_kit_cmd_sync(invk);}
|
||||
public GfuiInvkCmd New_cmd_async(GfoInvkAble invk) {return new Gfui_kit_cmd_async(invk);}
|
||||
public GfuiWin New_win_app(String key, KeyVal... args) {
|
||||
GfuiWin rv = GfuiWin_.kit_(this, key, this.Factory().win_app_(), ctor_args);
|
||||
main_win = rv;
|
||||
return rv;
|
||||
}
|
||||
public GfuiWin New_win_utl(String key, GfuiWin owner, KeyVal... args) {return GfuiWin_.kit_(this, key, this.Factory().win_tool_(ctor_args), ctor_args);}
|
||||
@gplx.Virtual public Gfui_html New_html(String key, GfuiElem owner, KeyVal... args) {
|
||||
Gfui_html rv = Gfui_html.kit_(this, key, this.New_html_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public Gfui_tab_mgr New_tab_mgr(String key, GfuiElem owner, KeyVal... args) {
|
||||
Gfui_tab_mgr rv = Gfui_tab_mgr.kit_(this, key, this.New_tab_mgr_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public Gfui_tab_itm New_tab_itm(String key, Gfui_tab_mgr owner, KeyVal... args) {
|
||||
Gfui_tab_itm rv = Gfui_tab_itm.kit_(this, key, this.New_tab_itm_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public GfuiTextBox New_text_box(String key, GfuiElem owner, KeyVal... args) {
|
||||
GfuiTextBox rv = GfuiTextBox_.kit_(this, key, this.Factory().text_fld_(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public GfuiBtn New_btn(String key, GfuiElem owner, KeyVal... args) {
|
||||
GfuiBtn rv = GfuiBtn_.kit_(this, key, New_btn_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public GfuiLbl New_lbl(String key, GfuiElem owner, KeyVal... args) {
|
||||
GfuiLbl rv = GfuiLbl_.kit_(this, key, New_btn_impl(), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public GfuiStatusBox New_status_box(String key, GfuiElem owner, KeyVal... args) {
|
||||
GfuiStatusBox rv = GfuiStatusBox_.kit_(this, key, this.Factory().text_memo_());
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public void Set_mnu_popup(GfuiElem owner, Gfui_mnu_grp grp) {}
|
||||
protected abstract Gxw_html New_html_impl();
|
||||
protected abstract Gxw_tab_mgr New_tab_mgr_impl();
|
||||
protected abstract Gxw_tab_itm New_tab_itm_impl();
|
||||
protected abstract GxwElem New_btn_impl();
|
||||
@gplx.Virtual public Gfui_dlg_file New_dlg_file(byte type, String msg) {return Gfui_dlg_file_null._;}
|
||||
@gplx.Virtual public Gfui_dlg_msg New_dlg_msg(String msg) {return Gfui_dlg_msg_null._;}
|
||||
@gplx.Virtual public Gfui_mnu_grp New_mnu_popup(String key, GfuiElem owner) {return Gfui_mnu_grp_null.Null;}
|
||||
@gplx.Virtual public Gfui_mnu_grp New_mnu_bar(String key, GfuiWin owner) {return Gfui_mnu_grp_null.Null;}
|
||||
public abstract ImageAdp New_img_load(Io_url url);
|
||||
public Object New_color(int a, int r, int g, int b) {return null;}
|
||||
public float Calc_font_height(GfuiElem elem, String s) {return 13;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class Gfui_kit_cmd_sync implements GfuiInvkCmd {
|
||||
public Gfui_kit_cmd_sync(GfoInvkAble target) {this.target = target;} private GfoInvkAble target;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return target.Invk(ctx, ikey, k, m);
|
||||
}
|
||||
public void Rls() {target = null;}
|
||||
}
|
||||
class Gfui_kit_cmd_async implements GfuiInvkCmd {
|
||||
public Gfui_kit_cmd_async(GfoInvkAble target) {this.target = target;} private GfoInvkAble target;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return target.Invk(ctx, ikey, k, m);
|
||||
}
|
||||
public void Rls() {target = null;}
|
||||
}
|
||||
48
150_gfui/src_700_env/gplx/gfui/Gfui_mnu_grp.java
Normal file
48
150_gfui/src_700_env/gplx/gfui/Gfui_mnu_grp.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public interface Gfui_mnu_grp extends Gfui_mnu_itm {
|
||||
String Root_key();
|
||||
void Itms_clear();
|
||||
boolean Disposed();
|
||||
Gfui_mnu_itm Itms_add_btn_cmd (String txt, ImageAdp img, GfoInvkAble invk, String invk_cmd);
|
||||
Gfui_mnu_itm Itms_add_btn_msg (String txt, ImageAdp img, GfoInvkAble invk, GfoInvkRootWkr root_wkr, GfoMsg msg);
|
||||
Gfui_mnu_itm Itms_add_chk_msg (String txt, ImageAdp img, GfoInvkAble invk, GfoInvkRootWkr root_wkr, GfoMsg msg_n, GfoMsg msg_y);
|
||||
Gfui_mnu_itm Itms_add_rdo_msg (String txt, ImageAdp img, GfoInvkAble invk, GfoInvkRootWkr root_wkr, GfoMsg msg);
|
||||
Gfui_mnu_grp Itms_add_grp (String txt, ImageAdp img);
|
||||
Gfui_mnu_itm Itms_add_separator();
|
||||
}
|
||||
class Gfui_mnu_grp_null implements Gfui_mnu_grp {
|
||||
public String Uid() {return "";}
|
||||
public int Tid() {return Gfui_mnu_itm_.Tid_grp;}
|
||||
public boolean Enabled() {return true;} public void Enabled_(boolean v) {}
|
||||
public boolean Disposed() {return false;}
|
||||
public String Text() {return null;} public void Text_(String v) {}
|
||||
public ImageAdp Img() {return null;} public void Img_(ImageAdp v) {}
|
||||
public boolean Selected() {return true;} public void Selected_(boolean v) {}
|
||||
public String Root_key() {return "null";}
|
||||
public Object Under() {return null;}
|
||||
public void Itms_clear() {}
|
||||
public Gfui_mnu_itm Itms_add_btn_cmd (String txt, ImageAdp img, GfoInvkAble invk, String invk_cmd) {return Gfui_mnu_itm_null.Null;}
|
||||
public Gfui_mnu_itm Itms_add_btn_msg (String txt, ImageAdp img, GfoInvkAble invk, GfoInvkRootWkr root_wkr, GfoMsg invk_msg) {return Gfui_mnu_itm_null.Null;}
|
||||
public Gfui_mnu_itm Itms_add_chk_msg (String txt, ImageAdp img, GfoInvkAble invk, GfoInvkRootWkr root_wkr, GfoMsg msg_n, GfoMsg msg_y) {return Gfui_mnu_itm_null.Null;}
|
||||
public Gfui_mnu_itm Itms_add_rdo_msg (String txt, ImageAdp img, GfoInvkAble invk, GfoInvkRootWkr root_wkr, GfoMsg msg) {return Gfui_mnu_itm_null.Null;}
|
||||
public Gfui_mnu_grp Itms_add_grp(String txt, ImageAdp img) {return Gfui_mnu_grp_null.Null;}
|
||||
public Gfui_mnu_itm Itms_add_separator() {return Gfui_mnu_itm_null.Null;}
|
||||
public static final Gfui_mnu_grp_null Null = new Gfui_mnu_grp_null(); Gfui_mnu_grp_null() {}
|
||||
}
|
||||
37
150_gfui/src_700_env/gplx/gfui/Gfui_mnu_itm.java
Normal file
37
150_gfui/src_700_env/gplx/gfui/Gfui_mnu_itm.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public interface Gfui_mnu_itm {
|
||||
int Tid();
|
||||
String Uid();
|
||||
boolean Enabled(); void Enabled_(boolean v);
|
||||
String Text(); void Text_(String v);
|
||||
ImageAdp Img(); void Img_(ImageAdp v);
|
||||
boolean Selected(); void Selected_(boolean v);
|
||||
Object Under();
|
||||
}
|
||||
class Gfui_mnu_itm_null implements Gfui_mnu_itm {
|
||||
public String Uid() {return "";}
|
||||
public int Tid() {return Gfui_mnu_itm_.Tid_btn;}
|
||||
public boolean Enabled() {return true;} public void Enabled_(boolean v) {}
|
||||
public String Text() {return text;} public void Text_(String v) {text = v;} private String text;
|
||||
public ImageAdp Img() {return img;} public void Img_(ImageAdp v) {img = v;} private ImageAdp img;
|
||||
public boolean Selected() {return true;} public void Selected_(boolean v) {}
|
||||
public Object Under() {return null;}
|
||||
public static final Gfui_mnu_itm_null Null = new Gfui_mnu_itm_null(); Gfui_mnu_itm_null() {}
|
||||
}
|
||||
22
150_gfui/src_700_env/gplx/gfui/Gfui_mnu_itm_.java
Normal file
22
150_gfui/src_700_env/gplx/gfui/Gfui_mnu_itm_.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Gfui_mnu_itm_ {
|
||||
public static String Gen_uid() {return "mnu_" + Int_.Xto_str(++uid_next);} private static int uid_next = 0;
|
||||
public static final int Tid_nil = 0, Tid_grp = 1, Tid_spr = 2, Tid_btn = 3, Tid_chk = 4, Tid_rdo = 5;
|
||||
}
|
||||
66
150_gfui/src_700_env/gplx/gfui/Mem_html.java
Normal file
66
150_gfui/src_700_env/gplx/gfui/Mem_html.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
class Mem_html extends GxwTextMemo_lang implements Gxw_html { public void Html_invk_src_(GfoEvObj v) {}
|
||||
public void Html_doc_html_load_by_mem(String s) {
|
||||
// this.Core().ForeColor_set(plainText ? ColorAdp_.Black : ColorAdp_.Gray);
|
||||
s = String_.Replace(s, "\r", "");
|
||||
s = String_.Replace(s, "\n", "\r\n");
|
||||
this.TextVal_set(s);
|
||||
this.SelBgn_set(0);
|
||||
html_doc_html_load_tid = Gxw_html_load_tid_.Tid_mem;
|
||||
}
|
||||
public void Html_doc_html_load_by_url(String path, String html) {
|
||||
html_doc_html_load_tid = Gxw_html_load_tid_.Tid_url;
|
||||
}
|
||||
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 "";}
|
||||
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;
|
||||
int q1 = String_.FindFwd(txt, "\"", q0 + 1); if (q1 == String_.Find_none) return null;
|
||||
if (!Int_.Between(pos, q0, q1)) return null; // current pos is not between nearest quotes
|
||||
return String_.Mid(txt, q0 + 1, q1);
|
||||
}
|
||||
public void Html_js_enabled_(boolean v) {}
|
||||
public String Html_js_eval_proc_as_str(String proc, Object... args) {return "not implemented by mem_html";}
|
||||
public boolean Html_js_eval_proc_as_bool(String proc, Object... args) {return false;}
|
||||
public void Html_js_cbks_add(String js_func_name, GfoInvkAble invk) {}
|
||||
public void Html_dispose() {}
|
||||
public Mem_html() {
|
||||
this.ctor_MsTextBoxMultiline_();
|
||||
}
|
||||
}
|
||||
class Mem_tab_mgr extends GxwElem_mock_base implements Gxw_tab_mgr { public ColorAdp Btns_selected_color() {return btns_selected_color;} public void Btns_selected_color_(ColorAdp v) {btns_selected_color = v;} private ColorAdp btns_selected_color;
|
||||
public ColorAdp Btns_unselected_color() {return btns_unselected_color;} public void Btns_unselected_color_(ColorAdp v) {btns_unselected_color = v;} private ColorAdp btns_unselected_color;
|
||||
public Gxw_tab_itm Tabs_add(Gfui_tab_itm_data tab_data) {return new Mem_tab_itm();}
|
||||
public void Tabs_select_by_idx(int i) {}
|
||||
public void Tabs_close_by_idx(int i) {}
|
||||
public void Tabs_switch(int src, int trg) {}
|
||||
public int Btns_height() {return 0;} public void Btns_height_(int v) {}
|
||||
public boolean Btns_place_on_top() {return false;} public void Btns_place_on_top_(boolean v) {}
|
||||
public boolean Btns_curved() {return false;} public void Btns_curved_(boolean v) {}
|
||||
public boolean Btns_close_visible() {return false;} public void Btns_close_visible_(boolean v) {}
|
||||
public boolean Btns_unselected_close_visible() {return false;} public void Btns_unselected_close_visible_(boolean v) {}
|
||||
}
|
||||
class Mem_tab_itm extends GxwElem_mock_base implements Gxw_tab_itm { public void Subs_add(GfuiElem sub) {}
|
||||
public Gfui_tab_itm_data Tab_data() {return tab_data;} private Gfui_tab_itm_data tab_data = new Gfui_tab_itm_data("null", -1);
|
||||
public String Tab_name() {return tab_name;} public void Tab_name_(String v) {tab_name = v;} private String tab_name;
|
||||
public String Tab_tip_text() {return tab_tip_text;} public void Tab_tip_text_(String v) {tab_tip_text = v;} private String tab_tip_text;
|
||||
}
|
||||
38
150_gfui/src_700_env/gplx/gfui/Mem_kit.java
Normal file
38
150_gfui/src_700_env/gplx/gfui/Mem_kit.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Mem_kit extends Gfui_kit_base {
|
||||
@Override public byte Tid() {return Gfui_kit_.Mem_tid;}
|
||||
@Override public String Key() {return "mem";}
|
||||
@Override public GxwElemFactory_base Factory() {return factory;} private GxwElemFactory_cls_mock factory = new GxwElemFactory_cls_mock();
|
||||
public void New_html_impl_prototype_(Gxw_html v) {html_impl_prototype = v;} private Gxw_html html_impl_prototype;
|
||||
@Override public Gfui_html New_html(String key, GfuiElem owner, KeyVal... args) {
|
||||
if (html_impl_prototype == null)
|
||||
return super.New_html(key, owner, args);
|
||||
else {
|
||||
Gfui_html rv = Gfui_html.mem_(key, html_impl_prototype);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@Override protected Gxw_html New_html_impl() {return html_impl_prototype == null ? new Mem_html(): html_impl_prototype;}
|
||||
@Override protected Gxw_tab_mgr New_tab_mgr_impl() {return new Mem_tab_mgr();}
|
||||
@Override protected Gxw_tab_itm New_tab_itm_impl() {return new Mem_tab_itm();}
|
||||
@Override protected GxwElem New_btn_impl() {return factory.control_();}
|
||||
@Override public ImageAdp New_img_load(Io_url url) {return ImageAdp_null._;}
|
||||
public static final Mem_kit _ = new Mem_kit(); Mem_kit() {}
|
||||
}
|
||||
33
150_gfui/src_700_env/gplx/gfui/Swing_kit.java
Normal file
33
150_gfui/src_700_env/gplx/gfui/Swing_kit.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Swing_kit extends Gfui_kit_base {
|
||||
private Bry_fmtr ask_fmtr = Bry_fmtr.new_(); private Bry_bfr ask_bfr = Bry_bfr.new_();
|
||||
@Override public byte Tid() {return Gfui_kit_.Swing_tid;}
|
||||
@Override public String Key() {return "swing";}
|
||||
@Override public GxwElemFactory_base Factory() {return factory;} private GxwElemFactory_cls_lang factory = new GxwElemFactory_cls_lang();
|
||||
@Override public void Ask_ok(String grp_key, String msg_key, String fmt, Object... args) {GfuiEnv_.ShowMsg(ask_fmtr.Bld_str_many(ask_bfr, fmt, args));}
|
||||
@Override public void Kit_run() {GfuiEnv_.Run(this.Main_win());}
|
||||
@Override public void Kit_term() {this.Kit_term_cbk().Invk(); GfuiEnv_.Exit();}
|
||||
@Override public ImageAdp New_img_load(Io_url url) {return ImageAdp_.file_(url);}
|
||||
@Override protected Gxw_html New_html_impl() {return new Mem_html();}
|
||||
@Override protected Gxw_tab_mgr New_tab_mgr_impl() {return new Mem_tab_mgr();}
|
||||
@Override protected Gxw_tab_itm New_tab_itm_impl() {return new Mem_tab_itm();}
|
||||
@Override protected GxwElem New_btn_impl() {return factory.control_();}
|
||||
public static final Swing_kit _ = new Swing_kit(); Swing_kit() {}
|
||||
}
|
||||
342
150_gfui/src_700_env/gplx/gfui/Swt_kit.java
Normal file
342
150_gfui/src_700_env/gplx/gfui/Swt_kit.java
Normal file
@@ -0,0 +1,342 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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 org.eclipse.swt.SWT;
|
||||
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.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
import org.eclipse.swt.browser.Browser;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.dnd.TextTransfer;
|
||||
import org.eclipse.swt.dnd.Transfer;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Cursor;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.omg.PortableServer.THREAD_POLICY_ID;
|
||||
|
||||
import gplx.core.threads.Thread_adp_;
|
||||
import gplx.core.threads.*;
|
||||
public class Swt_kit implements Gfui_kit {
|
||||
private final KeyValHash ctor_args = KeyValHash.new_(); private final KeyValHash ctor_args_null = KeyValHash.new_();
|
||||
private final Hash_adp kit_args = Hash_adp_.new_(); private Swt_msg_wkr_stop msg_wkr_stop;
|
||||
private Gfo_usr_dlg gui_wtr; private String xul_runner_path = null;
|
||||
private final Bry_fmtr ask_fmtr = Bry_fmtr.new_().Fail_when_invalid_escapes_(false); private final Bry_bfr ask_bfr = Bry_bfr.new_();
|
||||
private final Object thread_lock = new Object();
|
||||
public byte Tid() {return Gfui_kit_.Swt_tid;}
|
||||
public String Key() {return "swt";}
|
||||
public Display Swt_display() {return display;} private Display display;
|
||||
public Shell Swt_shell() {return shell;} private Shell shell;
|
||||
public Gfui_clipboard Clipboard() {return clipboard;} private Swt_clipboard clipboard;
|
||||
public int Kit_mode() {synchronized (thread_lock) {return mode;}} private int mode = Swt_kit_mode.Tid_ctor;
|
||||
public void Kit_mode_(int v) {synchronized (thread_lock) {mode = v;}}
|
||||
public boolean Kit_mode__ready() {return Kit_mode() == Swt_kit_mode.Tid_ready;}
|
||||
public boolean Kit_mode__term() {return Kit_mode() == Swt_kit_mode.Tid_term;}
|
||||
public boolean Kit_sync_cmd_exists() {synchronized (thread_lock) {return sync_cmd_list.Count() != 0;}} private final List_adp sync_cmd_list = List_adp_.new_();
|
||||
public void Kit_sync_cmd_add(Swt_gui_cmd cmd) {synchronized (thread_lock) {sync_cmd_list.Add(cmd);}}
|
||||
public void Kit_sync_cmd_del(Swt_gui_cmd cmd) {synchronized (thread_lock) {sync_cmd_list.Del(cmd);}}
|
||||
public GfoInvkAbleCmd Kit_term_cbk() {return term_cbk;} public void Kit_term_cbk_(GfoInvkAbleCmd v) {this.term_cbk = v;} private GfoInvkAbleCmd term_cbk = GfoInvkAbleCmd.Null;
|
||||
public void Kit_init(Gfo_usr_dlg gui_wtr) {
|
||||
this.gui_wtr = gui_wtr;
|
||||
this.msg_wkr_stop = new Swt_msg_wkr_stop(this, gui_wtr);
|
||||
this.display = new Display();
|
||||
this.clipboard = new Swt_clipboard(display);
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Warn, GfoConsoleWin._);
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Stop, msg_wkr_stop);
|
||||
if (xul_runner_path != null) System.setProperty("org.eclipse.swt.browser.XULRunnerPath", xul_runner_path);
|
||||
this.Kit_mode_(Swt_kit_mode.Tid_ready);
|
||||
gui_wtr.Log_many("", "", "swt.kit.init.done");
|
||||
}
|
||||
public void Kit_run() {
|
||||
shell.addListener(SWT.Close, new Swt_shell_close_lnr(this, gui_wtr));
|
||||
shell.open();
|
||||
Cursor cursor = new Cursor(display, SWT.CURSOR_ARROW);
|
||||
shell.setCursor(cursor); // set cursor to hand else cursor defaults to Hourglass until mouse is moved; DATE: 2014-01-31
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch())
|
||||
display.sleep();
|
||||
}
|
||||
gui_wtr.Log_many("", "", "swt.kit.term:bgn");
|
||||
cursor.dispose(); gui_wtr.Log_many("", "", "swt.kit.term:cursor");
|
||||
}
|
||||
public void Kit_term() {
|
||||
clipboard.Rls(); gui_wtr.Log_many("", "", "swt.kit.term:clipboard");
|
||||
shell.close();
|
||||
}
|
||||
public void Cfg_set(String type, String key, Object val) {
|
||||
// XulRunnerPath gets set immediately; do not add to widget_cfg_hash
|
||||
if (String_.Eq(type, Gfui_kit_.Cfg_HtmlBox) && String_.Eq(key, "XulRunnerPath")) {
|
||||
this.xul_runner_path = (String)val;
|
||||
return;
|
||||
}
|
||||
// add kv to widget_cfg_hash; new controls will get properties from cfg_hash
|
||||
KeyValHash widget_cfg_hash = (KeyValHash)kit_args.Get_by(type);
|
||||
if (widget_cfg_hash == null) {
|
||||
widget_cfg_hash = KeyValHash.new_();
|
||||
kit_args.Add(type, widget_cfg_hash);
|
||||
}
|
||||
widget_cfg_hash.Add_if_dupe_use_nth(key, val);
|
||||
}
|
||||
public boolean Ask_yes_no(String grp_key, String msg_key, String fmt, Object... args) {
|
||||
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_yes, Gfui_dlg_msg_.Btn_no).Init_ico_(Gfui_dlg_msg_.Ico_question);
|
||||
display.syncExec(dlg);
|
||||
return dlg.Ask_rslt == Gfui_dlg_msg_.Btn_yes;
|
||||
}
|
||||
public boolean Ask_ok_cancel(String grp_key, String msg_key, String fmt, Object... args) {
|
||||
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, Gfui_dlg_msg_.Btn_cancel).Init_ico_(Gfui_dlg_msg_.Ico_question);
|
||||
display.syncExec(dlg);
|
||||
return dlg.Ask_rslt == Gfui_dlg_msg_.Btn_ok;
|
||||
}
|
||||
public int Ask_yes_no_cancel(String grp_key, String msg_key, String fmt, Object... args) {
|
||||
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_yes, Gfui_dlg_msg_.Btn_no, Gfui_dlg_msg_.Btn_cancel).Init_ico_(Gfui_dlg_msg_.Ico_question);
|
||||
display.syncExec(dlg);
|
||||
return dlg.Ask_rslt;
|
||||
}
|
||||
public void Ask_ok(String grp_key, String msg_key, String fmt, Object... args) {
|
||||
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 (GfoInvkAble invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, Bool_.N);}
|
||||
public GfuiInvkCmd New_cmd_async(GfoInvkAble invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, Bool_.Y);}
|
||||
public GfuiWin New_win_utl(String key, GfuiWin owner, KeyVal... args) {
|
||||
return GfuiWin_.kit_(this, key, new Swt_win(shell), ctor_args_null);
|
||||
}
|
||||
public GfuiWin New_win_app(String key, KeyVal... args) {
|
||||
Swt_win win = new Swt_win(display);
|
||||
this.shell = win.UnderShell();
|
||||
shell.setLayout(null);
|
||||
return GfuiWin_.kit_(this, key, win, ctor_args_null);
|
||||
}
|
||||
public GfuiBtn New_btn(String key, GfuiElem owner, KeyVal... args) {
|
||||
GfuiBtn rv = GfuiBtn_.kit_(this, key, new Swt_btn_no_border(Swt_control_.cast_or_fail(owner), ctor_args), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public GfuiLbl New_lbl(String key, GfuiElem owner, KeyVal... args) {
|
||||
GfuiLbl rv = GfuiLbl_.kit_(this, key, new Swt_lbl(Swt_control_.cast_or_fail(owner), ctor_args), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public Gfui_html New_html(String key, GfuiElem owner, KeyVal... args) {
|
||||
ctor_args.Clear();
|
||||
// check cfg for browser type
|
||||
KeyValHash html_cfg_args = (KeyValHash)kit_args.Get_by(Gfui_kit_.Cfg_HtmlBox);
|
||||
if (html_cfg_args != null) {
|
||||
KeyVal browser_type = html_cfg_args.FetchOrNull(Cfg_Html_BrowserType);
|
||||
if (browser_type != null) ctor_args.Add(browser_type);
|
||||
}
|
||||
Swt_html swt_html = new Swt_html(this, Swt_control_.cast_or_fail(owner), ctor_args);
|
||||
Gfui_html gfui_html = Gfui_html.kit_(this, key, swt_html, ctor_args);
|
||||
swt_html.Under_control().addMenuDetectListener(new Swt_lnr__menu_detect(this, gfui_html));
|
||||
gfui_html.Owner_(owner);
|
||||
swt_html.Delete_elems_(owner, gfui_html);
|
||||
return gfui_html;
|
||||
}
|
||||
public Gfui_tab_mgr New_tab_mgr(String key, GfuiElem owner, KeyVal... args) {
|
||||
ctor_args.Clear();
|
||||
Swt_tab_mgr rv_swt = new Swt_tab_mgr(this, Swt_control_.cast_or_fail(owner), ctor_args);
|
||||
Gfui_tab_mgr rv = Gfui_tab_mgr.kit_(this, key, rv_swt, ctor_args);
|
||||
rv.Owner_(owner);
|
||||
rv_swt.EvMgr_(rv.EvMgr());
|
||||
return rv;
|
||||
}
|
||||
public GfuiTextBox New_text_box(String key, GfuiElem owner, KeyVal... args) {
|
||||
ctor_args.Clear();
|
||||
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));
|
||||
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);
|
||||
ctor_args.Clear();
|
||||
return rv;
|
||||
}
|
||||
public GfuiStatusBox New_status_box(String key, GfuiElem owner, KeyVal... args) {
|
||||
ctor_args.Clear();
|
||||
GfuiStatusBox rv = GfuiStatusBox_.kit_(this, key, new Swt_text(Swt_control_.cast_or_fail(owner), ctor_args));
|
||||
rv.Owner_(owner);
|
||||
return rv;
|
||||
}
|
||||
public Gfui_dlg_file New_dlg_file(byte type, String msg) {return new Swt_dlg_file(type, shell).Init_msg_(msg);}
|
||||
public Gfui_dlg_msg New_dlg_msg(String msg) {return new Swt_dlg_msg(shell).Init_msg_(msg);}
|
||||
public ImageAdp New_img_load(Io_url url) {
|
||||
if (url == Io_url_.Empty) return ImageAdp_.Null;
|
||||
Image img = new Image(display, url.Raw());
|
||||
Rectangle rect = img.getBounds();
|
||||
return new Swt_img(this, img, rect.width, rect.height).Url_(url);
|
||||
}
|
||||
public Color New_color(ColorAdp v) {return (Color)New_color(v.Alpha(), v.Red(), v.Green(), v.Blue());}
|
||||
public Object New_color(int a, int r, int g, int b) {return new Color(display, r, g, b);}
|
||||
public Gfui_mnu_grp New_mnu_popup(String key, GfuiElem owner) {return Swt_popup_grp.new_popup(key, owner);}
|
||||
public Gfui_mnu_grp New_mnu_bar(String key, GfuiWin owner) {return Swt_popup_grp.new_bar(key, owner);}
|
||||
public float Calc_font_height(GfuiElem elem, String s) {
|
||||
if (String_.Len_eq_0(s)) return 8;
|
||||
try {
|
||||
String old_text = elem.Text();
|
||||
elem.Text_(s);
|
||||
float rv = ((Swt_text_w_border)(elem.UnderElem())).Under_text().getFont().getFontData()[0].height;
|
||||
elem.Text_(old_text); // was shell.setText(old_text); DATE:2014-07-25
|
||||
return rv;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "error while calculating font height; err=~{0}", Err_.Message_gplx_brief(e));
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
public void Set_mnu_popup(GfuiElem owner, Gfui_mnu_grp grp) {
|
||||
Control control = Swt_control_.cast_or_fail(owner).Under_menu_control();
|
||||
Swt_popup_grp popup = (Swt_popup_grp)grp;
|
||||
control.setMenu(popup.Under_menu());
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (String_.Eq(k, Invk_Cfg_add)) {
|
||||
String type = m.ReadStrOr("type", "");
|
||||
String key = m.ReadStrOr("key", "");
|
||||
String val = m.ReadStrOr("val", "");
|
||||
if (ctx.Deny()) return this;
|
||||
if (String_.Eq(type, Gfui_kit_.Cfg_HtmlBox)) {
|
||||
if (String_.Eq(key, "XulRunnerPath"))
|
||||
xul_runner_path = val;
|
||||
else if (String_.Eq(key, Swt_kit.Cfg_Html_BrowserType))
|
||||
Cfg_set(type, Swt_kit.Cfg_Html_BrowserType, Cfg_Html_BrowserType_parse(val));
|
||||
}
|
||||
}
|
||||
else if (String_.Eq(k, Invk_ask_file)) return this.New_dlg_file(Gfui_kit_.File_dlg_type_open, m.Args_getAt(0).Val_to_str_or_empty()).Ask();
|
||||
else if (String_.Eq(k, Invk_shell_close)) shell.close();
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_Cfg_add = "Cfg_add", Invk_ask_file = "ask_file"; // private or public?
|
||||
public static final String Invk_shell_close = "shell_close"; // public
|
||||
public static final Swt_kit _ = new Swt_kit(); private Swt_kit() {} // singleton b/c of following line "In particular, some platforms which SWT supports will not allow more than one active display" (http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html)
|
||||
public static final String Cfg_Html_BrowserType = "BrowserType";
|
||||
public static int Cfg_Html_BrowserType_parse(String v) {
|
||||
if (String_.Eq(v, "mozilla")) return Swt_html.Browser_tid_mozilla;
|
||||
else if (String_.Eq(v, "webkit")) return Swt_html.Browser_tid_webkit;
|
||||
else return Swt_html.Browser_tid_none;
|
||||
}
|
||||
public static FontAdp Control_font_get(Font font, GxwCore_base owner) {
|
||||
FontData fontData = font.getFontData()[0];
|
||||
FontAdp rv = FontAdp.new_(fontData.getName(), fontData.getHeight(), FontStyleAdp_.lang_(fontData.getStyle())); // NOTE: swt style constants match swing
|
||||
rv.OwnerGxwCore_(owner);
|
||||
return rv;
|
||||
}
|
||||
public static void Control_font_set(FontAdp font, GxwCore_base owner, Control control) {
|
||||
font.OwnerGxwCore_(owner);
|
||||
FontData fontData = new FontData(font.Name(), (int)font.size, font.Style().Val());
|
||||
Font rv = new Font(control.getDisplay(), fontData);
|
||||
control.setFont(rv);
|
||||
}
|
||||
}
|
||||
class Swt_shell_close_lnr implements Listener, GfoInvkAble {
|
||||
private final Swt_kit kit; private final Gfo_usr_dlg usr_dlg;
|
||||
public Swt_shell_close_lnr(Swt_kit kit, Gfo_usr_dlg usr_dlg) {this.kit = kit; this.usr_dlg = usr_dlg;}
|
||||
@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
|
||||
if (!rslt) {
|
||||
event.doit = false; // cbk canceled term; stop close
|
||||
kit.Kit_mode_(Swt_kit_mode.Tid_ready); // reset kit back to "running" mode;
|
||||
return;
|
||||
}
|
||||
if (kit.Kit_sync_cmd_exists()) { // sync cmd is running; cannot shut down app else app just hangs; DATE:2015-04-13
|
||||
event.doit = false; // cancel shutdown
|
||||
Thread_adp_.invk_(this, Invk_wait_for_sync_cmd).Start(); // wait for sync_cmd to end in background thread; call shutdown again when it does
|
||||
}
|
||||
}
|
||||
private void Wait_for_sync_cmd() { // THREAD:non-GUI
|
||||
int loop_count = 0, loop_max = 50, loop_wait = 100; // loop for 100 ms for no more than 5 seconds
|
||||
while (loop_count < loop_max) {
|
||||
usr_dlg.Log_many("", "", "swt:waiting for sync cmd; loop=~{0}", loop_count);
|
||||
if (!kit.Kit_sync_cmd_exists()) {
|
||||
usr_dlg.Log_many("", "", "swt:sync cmd done; shutting down");
|
||||
break;
|
||||
}
|
||||
Thread_adp_.Sleep(loop_wait);
|
||||
loop_count++;
|
||||
}
|
||||
if (loop_count == loop_max)
|
||||
usr_dlg.Log_many("", "", "swt:sync_wait failed", loop_count);
|
||||
GfoInvkAble_.InvkCmd(kit.New_cmd_sync(kit), Swt_kit.Invk_shell_close); // shutdown again; note that cmd must be called on GUI thread
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_wait_for_sync_cmd)) Wait_for_sync_cmd();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_wait_for_sync_cmd = "wait_for_sync_cmd";
|
||||
}
|
||||
class Swt_kit_mode {
|
||||
public static final int
|
||||
Tid_ctor = 0
|
||||
, Tid_ready = 1
|
||||
, Tid_term = 2
|
||||
;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
this.invk_ctx = ctx; this.invk_ikey = ikey; this.invk_key = k; this.invk_msg = m;
|
||||
if (async)
|
||||
display.asyncExec(this);
|
||||
else {
|
||||
kit.Kit_sync_cmd_add(this);
|
||||
try {display.syncExec(this);}
|
||||
finally {kit.Kit_sync_cmd_del(this);}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@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);}
|
||||
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_brief(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Rls() {
|
||||
this.invk_ctx = null; this.invk_key = null; this.invk_msg = null;
|
||||
}
|
||||
}
|
||||
class Swt_msg_wkr_stop implements UsrMsgWkr {
|
||||
private final Swt_kit kit; private final Gfo_usr_dlg gui_wtr;
|
||||
public Swt_msg_wkr_stop(Swt_kit kit, Gfo_usr_dlg gui_wtr) {this.kit = kit; this.gui_wtr = gui_wtr;}
|
||||
public void ExecUsrMsg(int type, UsrMsg umsg) {
|
||||
String msg = umsg.XtoStr();
|
||||
kit.Ask_ok("xowa.gui", "stop", msg);
|
||||
gui_wtr.Log_many("", "", msg);
|
||||
}
|
||||
}
|
||||
48
150_gfui/src_700_env/gplx/gfui/TxtFindMgr.java
Normal file
48
150_gfui/src_700_env/gplx/gfui/TxtFindMgr.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class TxtFindMgr {
|
||||
public String Text() {return text;}
|
||||
public TxtFindMgr Text_(String v) {
|
||||
if (!caseSensitive) v = String_.Lower(v);
|
||||
text = v;
|
||||
return this;
|
||||
} String text;
|
||||
public boolean CaseSensitive() {return caseSensitive;} public TxtFindMgr CaseSensitive_(boolean v) {caseSensitive = v; return this;} private boolean caseSensitive = false;
|
||||
public int[] FindByUi(String findText, int selBgn, int selLen, boolean keyIsEnter) {
|
||||
int[] rv = new int[2];
|
||||
if (String_.Eq(findText, "")) return rv; // make newSel = 0 b/c all text deleted; else, find will continue from last selBgn; easy way to "reset"
|
||||
rv[0] = selBgn; rv[1] = selLen; // make newSel = curSel
|
||||
int adj = keyIsEnter ? 1 : 0; // if enter, search next, else search from cur; else will add to selLen if at match; ex: ab->c at abc will keep same selBgn, but increase selLen to 3
|
||||
int findPos = FindNext(findText, selBgn + adj);
|
||||
if (findPos == String_.Find_none) { // nothing found; set selLen to 0 and return
|
||||
rv[1] = 0;
|
||||
return rv;
|
||||
}
|
||||
rv[0] = findPos;
|
||||
rv[1] = String_.Len(findText);
|
||||
return rv;
|
||||
}
|
||||
public int FindNext(String find, int guiPos) {
|
||||
if (!caseSensitive) find = String_.Lower(find);
|
||||
int findPos = String_.FindFwd(text, find, guiPos);
|
||||
if (findPos == String_.Find_none && guiPos != 0)
|
||||
findPos = String_.FindFwd(text, find, 0);
|
||||
return findPos;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user