mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.5.1.1
This commit is contained in:
@@ -57,18 +57,19 @@ class Swt_btn implements GxwElem, Swt_control {
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return null;}
|
||||
}
|
||||
class Swt_btn_no_border implements GxwElem, Swt_control {
|
||||
private ImageAdp btn_img; private Composite box_grp; private Label box_btn;
|
||||
public Swt_btn_no_border(Swt_control owner_control, KeyValHash ctorArgs) {
|
||||
Composite owner = owner_control.Under_composite();
|
||||
Make_btn_no_border(owner.getDisplay(), owner.getShell(), owner);
|
||||
core = new Swt_core_cmds(box_btn);
|
||||
this.core = new Swt_core_cmds(box_btn);
|
||||
box_btn.addKeyListener(new Swt_lnr_key(this));
|
||||
box_btn.addMouseListener(new Swt_lnr_mouse(this));
|
||||
}
|
||||
@Override public Control Under_control() {return box_btn;}
|
||||
@Override public Control Under_menu_control() {return box_btn;}
|
||||
@Override public String TextVal() {return box_btn.getText();} @Override public void TextVal_set(String v) {box_btn.setText(v);}
|
||||
@Override public GxwCore_base Core() {return core;} Swt_core_cmds core;
|
||||
@Override public GxwCbkHost Host() {return host;} @Override public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host;
|
||||
@Override public GxwCore_base Core() {return core;} private final Swt_core_cmds core;
|
||||
@Override public GxwCbkHost Host() {return host;} @Override public void Host_set(GxwCbkHost host) {this.host = host;} private GxwCbkHost host;
|
||||
@Override public Composite Under_composite() {return null;}
|
||||
@Override public void EnableDoubleBuffering() {}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
@@ -82,9 +83,6 @@ class Swt_btn_no_border implements GxwElem, Swt_control {
|
||||
int dif = 6;
|
||||
box_btn.setImage((Image)v.Resize(size.Width() - dif, size.Height() - dif).Under());
|
||||
}
|
||||
ImageAdp btn_img;
|
||||
Composite box_grp;
|
||||
Label box_btn;
|
||||
void Make_btn_no_border(Display display, Shell shell, Control owner) {
|
||||
box_grp = new Composite(shell, SWT.FLAT);
|
||||
box_btn = new Label(shell, SWT.FLAT);
|
||||
|
||||
@@ -26,10 +26,11 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
class Swt_core_cmds extends GxwCore_base {
|
||||
Control control; private boolean compositeAble = false;
|
||||
public Swt_core_cmds(Control control) {
|
||||
compositeAble = control instanceof Composite;
|
||||
this.compositeAble = control instanceof Composite;
|
||||
this.control = control;
|
||||
} Control control; boolean compositeAble = false;
|
||||
}
|
||||
@Override public int Width() {return control.getSize().x;} @Override public void Width_set(int v) {if (Cfg_resize_disabled) return; control.setSize(v, this.Height());}
|
||||
@Override public int Height() {return control.getSize().y;} @Override public void Height_set(int v) {if (Cfg_resize_disabled) return; control.setSize(this.Width(), v);}
|
||||
@Override public int X() {return control.getLocation().x;} @Override public void X_set(int v) {control.setLocation(v, this.Y());}
|
||||
|
||||
@@ -25,6 +25,8 @@ import gplx.GfoMsg_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.String_;
|
||||
import gplx.Tfds;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.KeyListener;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
@@ -50,17 +52,24 @@ class Swt_lnr_resize implements Listener {
|
||||
}
|
||||
public Swt_lnr_resize(Swt_win win) {this.win = win;} Swt_win win;
|
||||
}
|
||||
class Swt_lnr_traverse implements Listener {
|
||||
@Override public void handleEvent(Event e) {
|
||||
if (e.detail == SWT.TRAVERSE_ESCAPE)
|
||||
e.doit = false;
|
||||
}
|
||||
}
|
||||
class Swt_lnr_key implements KeyListener {
|
||||
public Swt_lnr_key(GxwElem elem) {this.elem = elem;} GxwElem elem;
|
||||
// static int counter = 0;
|
||||
@Override public void keyPressed(KeyEvent ev) {
|
||||
IptEvtDataKey data = XtoKeyData(ev);
|
||||
if (!elem.Host().KeyDownCbk(data)) {
|
||||
IptEvtDataKey ipt_data = XtoKeyData(ev);
|
||||
if (!elem.Host().KeyDownCbk(ipt_data) || ipt_data.Handled())
|
||||
ev.doit = false;
|
||||
}
|
||||
}
|
||||
@Override public void keyReleased(KeyEvent ev) {
|
||||
if (!elem.Host().KeyUpCbk(XtoKeyData(ev))) ev.doit = false;
|
||||
IptEvtDataKey ipt_data = XtoKeyData(ev);
|
||||
if (!elem.Host().KeyUpCbk(ipt_data) || ipt_data.Handled())
|
||||
ev.doit = false;
|
||||
}
|
||||
IptEvtDataKey XtoKeyData(KeyEvent ev) {
|
||||
int val = ev.keyCode;
|
||||
|
||||
@@ -17,9 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.threads.Thread_adp_;
|
||||
|
||||
import java.security.acl.Owner;
|
||||
import gplx.*;
|
||||
import gplx.threads.ThreadAdp_;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.browser.*;
|
||||
import org.eclipse.swt.events.*;
|
||||
@@ -28,7 +29,6 @@ import org.eclipse.swt.widgets.*;
|
||||
import java.security.acl.Owner;
|
||||
|
||||
import gplx.*;
|
||||
import gplx.threads.ThreadAdp_;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.browser.*;
|
||||
import org.eclipse.swt.events.*;
|
||||
@@ -99,7 +99,7 @@ class Swt_html implements Gxw_html, Swt_control, FocusListener {
|
||||
while (count < 5) {
|
||||
boolean rv = Eval_script_as_bool(kit.Html_cfg().Elem_img_update(elem_id, elem_src, elem_width, elem_height));
|
||||
if (rv) return rv;
|
||||
ThreadAdp_.Sleep(100);
|
||||
Thread_adp_.Sleep(100);
|
||||
count++;
|
||||
}
|
||||
return false;
|
||||
|
||||
44
150_gfui/xtn/gplx/gfui/Swt_lbl.java
Normal file
44
150_gfui/xtn/gplx/gfui/Swt_lbl.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
class Swt_lbl implements GxwElem, Swt_control {
|
||||
private Label lbl;
|
||||
public Swt_lbl(Swt_control owner, KeyValHash ctorArgs) {
|
||||
lbl = new Label(owner.Under_composite(), SWT.CENTER);
|
||||
core = new Swt_core_cmds(lbl);
|
||||
lbl.addKeyListener(new Swt_lnr_key(this));
|
||||
lbl.addMouseListener(new Swt_lnr_mouse(this));
|
||||
}
|
||||
@Override public Control Under_control() {return lbl;}
|
||||
@Override public Control Under_menu_control() {return lbl;}
|
||||
@Override public String TextVal() {return lbl.getText();} @Override public void TextVal_set(String v) {
|
||||
lbl.setText(v);
|
||||
}
|
||||
@Override public GxwCore_base Core() {return core;} GxwCore_base core;
|
||||
@Override public GxwCbkHost Host() {return host;} @Override public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host;
|
||||
@Override public Composite Under_composite() {return null;}
|
||||
@Override public void EnableDoubleBuffering() {}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return null;}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui;
|
||||
import gplx.*;
|
||||
import gplx.threads.ThreadAdp_;
|
||||
import gplx.core.threads.Thread_adp_;
|
||||
|
||||
import org.eclipse.swt.*;
|
||||
import org.eclipse.swt.custom.*;
|
||||
|
||||
@@ -20,6 +20,7 @@ package gplx.gfui;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import gplx.Bool_;
|
||||
import gplx.GfoInvkAbleCmd;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.GfsCtx;
|
||||
@@ -32,24 +33,26 @@ import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
class Swt_win implements GxwWin, Swt_control {
|
||||
private Swt_lnr_resize resize_lnr; private Swt_lnr_show show_lnr; // use ptr to dispose later
|
||||
void ctor(boolean window_is_dialog, Shell shell, Display display) {
|
||||
this.shell = shell;
|
||||
this.display = display;
|
||||
this.ctrl_mgr = new Swt_core_cmds(shell);
|
||||
this.show_lnr = new Swt_lnr_show(this);
|
||||
this.resize_lnr = new Swt_lnr_resize(this);
|
||||
shell.addListener(SWT.Show, show_lnr);
|
||||
shell.addListener(SWT.Resize, resize_lnr);
|
||||
if (window_is_dialog) {
|
||||
shell.addListener(SWT.Traverse, new Swt_lnr_traverse());
|
||||
}
|
||||
}
|
||||
public Display UnderDisplay() {return display;} private Display display;
|
||||
public Shell UnderShell() {return shell;} private Shell shell;
|
||||
@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(new Shell(owner, SWT.RESIZE | SWT.DIALOG_TRIM), owner.getDisplay());}
|
||||
public Swt_win(Display display) {ctor(new Shell(display), display); }
|
||||
Swt_lnr_show showLnr; // use ptr to dispose later
|
||||
void ctor(Shell shell, Display display) {
|
||||
this.shell = shell;
|
||||
this.display = display;
|
||||
ctrlMgr = new Swt_core_cmds(shell);
|
||||
showLnr = new Swt_lnr_show(this);
|
||||
resizeLnr = new Swt_lnr_resize(this);
|
||||
shell.addListener(SWT.Show, showLnr);
|
||||
shell.addListener(SWT.Resize, resizeLnr);
|
||||
}
|
||||
Swt_lnr_resize resizeLnr;
|
||||
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 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);}
|
||||
@@ -70,15 +73,12 @@ class Swt_win implements GxwWin, Swt_control {
|
||||
} catch (FileNotFoundException e1) {e1.printStackTrace();}
|
||||
shell.setImage(image);
|
||||
}
|
||||
public void OpenedCmd_set(GfoInvkAbleCmd v) {whenLoadedCmd = v;} GfoInvkAbleCmd whenLoadedCmd = GfoInvkAbleCmd.Null;
|
||||
public void Opened() {whenLoadedCmd.Invk();}
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {
|
||||
return shell.getText();}
|
||||
public void TextVal_set(String v) {
|
||||
shell.setText(v);
|
||||
}
|
||||
public void OpenedCmd_set(GfoInvkAbleCmd v) {when_loaded_cmd = v;} private GfoInvkAbleCmd when_loaded_cmd = GfoInvkAbleCmd.Null;
|
||||
public void Opened() {when_loaded_cmd.Invk();}
|
||||
public GxwCore_base Core() {return ctrl_mgr;} private GxwCore_base ctrl_mgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} private GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {return shell.getText();}
|
||||
public void TextVal_set(String v) {shell.setText(v);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
@@ -89,7 +89,7 @@ class Swt_win implements GxwWin, Swt_control {
|
||||
//public void windowDeactivated(WindowEvent e) {}
|
||||
//public void windowDeiconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
//public void windowIconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
//public void windowOpened(WindowEvent e) {whenLoadedCmd.Invk();}
|
||||
//public void windowOpened(WindowEvent e) {when_loaded_cmd.Invk();}
|
||||
//@Override public void processKeyEvent(KeyEvent e) {if (GxwCbkHost_.ExecKeyEvent(host, e)) super.processKeyEvent(e);}
|
||||
//@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
//@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@@ -102,7 +102,7 @@ class Swt_win implements GxwWin, Swt_control {
|
||||
public void TaskbarVisible_set(boolean val) {} public void TaskbarParkingWindowFix(GxwElem form) {}
|
||||
void ctor_GxwForm() {
|
||||
// this.setLayout(null); // use gfui layout
|
||||
// this.ctrlMgr.BackColor_set(ColorAdp_.White); // default form backColor to white
|
||||
// this.ctrl_mgr.BackColor_set(ColorAdp_.White); // default form backColor to white
|
||||
// this.setUndecorated(true); // remove icon, titleBar, minimize, maximize, close, border
|
||||
// this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // JAVA: cannot cancel alt+f4; set Close to noop, and manually control closing by calling this.CloseForm
|
||||
// enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
||||
|
||||
Reference in New Issue
Block a user