Gui: Change UI to use SWT Grid Layout instead of manual XOWA layout

pull/620/head
gnosygnu 7 years ago
parent dd6b3cabed
commit 70cfdf0c44

Binary file not shown.

@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui.controls.elems; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
import gplx.gfui.draws.*; import gplx.gfui.gfxs.*; import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.imgs.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.*; import gplx.gfui.controls.windows.*;
import gplx.gfui.layouts.swts.*;
import gplx.core.interfaces.*;
public interface GfuiElem extends Gfo_invk, GxwCbkHost, IptBndsOwner, GftItem, Gfo_evt_itm {
//% Layout
@ -32,6 +33,8 @@ public interface GfuiElem extends Gfo_invk, GxwCbkHost, IptBndsOwner, GftItem, G
void Zorder_front(); void Zorder_back();
PointAdp Pos();
SizeAdp Size();
Swt_layout_mgr Layout_mgr(); void Layout_mgr_(Swt_layout_mgr v);
Swt_layout_data Layout_data(); void Layout_data_(Swt_layout_data v);
//% Visual
boolean Visible(); void Visible_set(boolean v); GfuiElem Visible_on_(); GfuiElem Visible_off_();

@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui.controls.elems; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
import gplx.gfui.draws.*; import gplx.gfui.gfxs.*; import gplx.gfui.ipts.*; import gplx.gfui.layouts.*; import gplx.gfui.imgs.*; import gplx.gfui.kits.core.*;
import gplx.gfui.layouts.swts.*;
import gplx.gfui.controls.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.standards.*; import gplx.gfui.controls.windows.*;
import gplx.core.strings.*; import gplx.core.interfaces.*;
public class GfuiElemBase implements GfuiElem {
@ -61,6 +62,11 @@ public class GfuiElemBase implements GfuiElem {
this.Visible_set(true);
this.Focus();
}
public Swt_layout_mgr Layout_mgr() {return underElem.Core().Layout_mgr();}
public void Layout_mgr_(Swt_layout_mgr v) {underElem.Core().Layout_mgr_(v);}
public Swt_layout_data Layout_data() {return underElem.Core().Layout_data();}
public void Layout_data_(Swt_layout_data v) {underElem.Core().Layout_data_(v);}
//% Visual
@gplx.Virtual public boolean Visible() {return underMgr.Visible();} @gplx.Virtual public void Visible_set(boolean v) {underMgr.Visible_set(v);}
public GfuiElem Visible_on_() {this.Visible_set(true); return this;} public GfuiElem Visible_off_() {this.Visible_set(false); return this;}

@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui.controls.gxws; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
import gplx.gfui.draws.*;
import gplx.gfui.layouts.swts.*;
public abstract class GxwCore_base {
public abstract void Controls_add(GxwElem sub);
public abstract void Controls_del(GxwElem sub);
@ -32,6 +33,10 @@ public abstract class GxwCore_base {
public abstract ColorAdp ForeColor(); public abstract void ForeColor_set(ColorAdp v);
public abstract FontAdp TextFont(); public abstract void TextFont_set(FontAdp v);
public abstract String TipText(); public abstract void TipText_set(String v);
public abstract Swt_layout_mgr Layout_mgr();
public abstract void Layout_mgr_(Swt_layout_mgr v);
public abstract Swt_layout_data Layout_data();
public abstract void Layout_data_(Swt_layout_data v);
public abstract int Focus_index(); public abstract void Focus_index_set(int v);
public abstract boolean Focus_able(); public abstract void Focus_able_(boolean v);

@ -28,6 +28,7 @@ import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics2D;
import gplx.gfui.draws.*; import gplx.gfui.controls.gxws.*;
import gplx.gfui.layouts.swts.*;
public class GxwCore_lang extends GxwCore_base {
@Override public int Width() {return control.getWidth();} @Override public void Width_set(int v) {control.setSize(v, control.getHeight());}
@Override public int Height() {return control.getHeight();} @Override public void Height_set(int v) {control.setSize(control.getWidth(), v);}
@ -78,6 +79,11 @@ public class GxwCore_lang extends GxwCore_base {
prvFont = v;
}
@Override public String TipText() {return tipText;} @Override public void TipText_set(String v) {tipText = v;} String tipText;
@Override public Swt_layout_mgr Layout_mgr() {return null;}
@Override public void Layout_mgr_(Swt_layout_mgr v) {}
@Override public Swt_layout_data Layout_data() {return null;}
@Override public void Layout_data_(Swt_layout_data v) {}
@Override public void Controls_add(GxwElem sub) {
try {
JComponent component = (JComponent)sub;

@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui.controls.gxws; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
import gplx.gfui.draws.*; import gplx.gfui.ipts.*;
import gplx.gfui.layouts.swts.*;
public class GxwCore_mock extends GxwCore_base {
@Override public int Width() {return size.Width();} @Override public void Width_set(int v) {size = SizeAdp_.new_(v, size.Height());}
@Override public int Height() {return size.Height();} @Override public void Height_set(int v) {size = SizeAdp_.new_(size.Width(), v);}
@ -30,6 +31,10 @@ public class GxwCore_mock extends GxwCore_base {
@Override public ColorAdp ForeColor() {return textColor;} @Override public void ForeColor_set(ColorAdp v) {textColor = v;} ColorAdp textColor = ColorAdp_.Null;
@Override public FontAdp TextFont() {return font;} @Override public void TextFont_set(FontAdp v) {font = v;} FontAdp font;
@Override public String TipText() {return tipText;} @Override public void TipText_set(String v) {tipText = v;} private String tipText;
@Override public Swt_layout_mgr Layout_mgr() {return null;}
@Override public void Layout_mgr_(Swt_layout_mgr v) {}
@Override public Swt_layout_data Layout_data() {return null;}
@Override public void Layout_data_(Swt_layout_data v) {}
@Override public void Controls_add(GxwElem sub) {list.Add(sub);}
@Override public void Controls_del(GxwElem sub) {list.Del(sub);}

@ -47,6 +47,7 @@ import gplx.gfui.SizeAdp;
import gplx.gfui.controls.elems.GfuiElem;
import gplx.gfui.draws.*;
import gplx.gfui.ipts.*; import gplx.gfui.controls.windows.*;
import gplx.gfui.layouts.swts.*;
public class GxwTextMemo_lang extends JScrollPane implements GxwTextMemo {
public JTextArea Inner() {return txt_box;} GxwTextBox_lang txt_box;
public GxwCore_base Core() {return core;} GxwCore_base core;
@ -322,6 +323,11 @@ class GxwCore_host extends GxwCore_base {
@Override public ColorAdp ForeColor(){return outer.ForeColor();} @Override public void ForeColor_set(ColorAdp v){outer.ForeColor_set(v); inner.ForeColor_set(v);}
@Override public FontAdp TextFont(){return outer.TextFont();} @Override public void TextFont_set(FontAdp v){outer.TextFont_set(v); inner.TextFont_set(v);}
@Override public String TipText() {return tipText;} @Override public void TipText_set(String v) {tipText = v;} String tipText;
@Override public Swt_layout_mgr Layout_mgr() {return null;}
@Override public void Layout_mgr_(Swt_layout_mgr v) {}
@Override public Swt_layout_data Layout_data() {return null;}
@Override public void Layout_data_(Swt_layout_data v) {}
public Object Reapply() {
TextFont_set(outer.TextFont()); return this;} // HACK:

@ -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.controls.gxws; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
import gplx.gfui.draws.*; import gplx.gfui.controls.standards.*;
public interface Gxw_grp extends GxwElem {
}

@ -0,0 +1,26 @@
/*
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.controls.standards; import gplx.*; import gplx.gfui.*; import gplx.gfui.controls.*;
import gplx.gfui.draws.*; import gplx.gfui.kits.core.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.elems.*;
public class Gfui_grp extends GfuiElemBase {
public static Gfui_grp kit_(Gfui_kit kit, String key, GxwElem under, Keyval_hash ctor_args) {
Gfui_grp rv = new Gfui_grp();
rv.ctor_kit_GfuiElemBase(kit, key, under, ctor_args);
return rv;
}
}

@ -37,6 +37,7 @@ public interface Gfui_kit extends Gfo_invk {
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);
Gfui_grp New_grp(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);
GfuiComboBox New_combo(String key, GfuiElem owner, Keyval... args);

@ -58,6 +58,11 @@ public abstract class Gfui_kit_base implements Gfui_kit {
owner.SubElems().Add(rv);
return rv;
}
public Gfui_grp New_grp(String key, GfuiElem owner, Keyval... args) {
Gfui_grp rv = Gfui_grp.kit_(this, key, this.New_grp_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);
@ -87,6 +92,7 @@ public abstract class Gfui_kit_base implements Gfui_kit {
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_grp_impl();
protected abstract GxwElem New_btn_impl();
protected abstract GxwElem New_combo_impl();
@gplx.Virtual public Gfui_dlg_file New_dlg_file(byte type, String msg) {return Gfui_dlg_file_.Noop;}

@ -33,6 +33,7 @@ public class Mem_kit extends Gfui_kit_base {
@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_grp_impl() {return factory.control_();}
@Override protected GxwElem New_btn_impl() {return factory.control_();}
@Override protected GxwElem New_combo_impl() {return factory.comboBox_();}
@Override public ImageAdp New_img_load(Io_url url) {return ImageAdp_null.Instance;}

@ -30,6 +30,7 @@ public class Swing_kit extends Gfui_kit_base {
@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_grp_impl() {return factory.control_();}
@Override protected GxwElem New_btn_impl() {return factory.control_();}
@Override protected GxwElem New_combo_impl() {return factory.control_();}
public static final Swing_kit Instance = new Swing_kit(); Swing_kit() {}

@ -44,8 +44,6 @@ 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.*;
import gplx.gfui.controls.customs.GfuiStatusBox;
@ -200,12 +198,20 @@ public class Swt_kit implements Gfui_kit {
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));
GxwTextFld under = new Swt_text_w_border(Swt_control_.cast_or_fail(owner), New_color(border_on ? ColorAdp_.LightGray : ColorAdp_.White), ctor_args);
GxwTextFld under = new Swt_text_w_border(Swt_control_.cast_or_fail(owner), New_color(border_on ? ColorAdp_.LightGray : ColorAdp_.White), ctor_args, Swt_text_w_border.Margin_t__text);
GfuiTextBox rv = GfuiTextBox_.kit_(this, key, under, ctor_args);
rv.Owner_(owner);
ctor_args.Clear();
return rv;
}
public Gfui_grp New_grp(String key, GfuiElem owner, Keyval... args) {
ctor_args.Clear();
Swt_grp rv_swt = new Swt_grp(this, Swt_control_.cast_or_fail(owner), ctor_args);
Gfui_grp rv = Gfui_grp.kit_(this, key, rv_swt, ctor_args);
rv.Owner_(owner);
rv_swt.Evt_mgr_(rv.Evt_mgr());
return rv;
}
public GfuiComboBox New_combo(String key, GfuiElem owner, Keyval... args) {
Swt_combo_ctrl rv_swt = new Swt_combo_ctrl(Swt_control_.cast_or_fail(owner), this.New_color(ColorAdp_.LightGray), ctor_args);
GfuiComboBox rv = GfuiComboBox.kit_(this, key, rv_swt, ctor_args);
@ -278,18 +284,6 @@ public class Swt_kit implements Gfui_kit {
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, Gfo_invk {
private final Swt_kit kit; private final Gfo_usr_dlg usr_dlg;

@ -47,7 +47,7 @@ public class Swt_btn implements GxwElem, Swt_control {
private Button btn;
public Swt_btn(Swt_control owner, Keyval_hash ctorArgs) {
btn = new Button(owner.Under_composite(), SWT.FLAT | SWT.PUSH);
core = new Swt_core_cmds(btn);
core = new Swt_core__basic(btn);
btn.addKeyListener(new Swt_lnr_key(this));
btn.addMouseListener(new Swt_lnr_mouse(this));
}

@ -29,10 +29,13 @@ import gplx.gfui.imgs.ImageAdp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
public class Swt_btn_no_border implements GxwElem, Swt_control {
@ -40,17 +43,17 @@ public class Swt_btn_no_border implements GxwElem, Swt_control {
public Swt_btn_no_border(Swt_control owner_control, Keyval_hash ctorArgs) {
Composite owner = owner_control.Under_composite();
Make_btn_no_border(owner.getDisplay(), owner.getShell(), owner);
this.core = new Swt_core_cmds(box_btn);
this.core = new Swt_core__basic(box_btn);
box_btn.addKeyListener(new Swt_lnr_key(this));
box_btn.addMouseListener(new Swt_lnr_mouse(this));
box_btn.setCursor((Cursor)ctorArgs.Get_val_or_null("cursor"));
}
@Override public Control Under_control() {return box_btn;}
@Override public Control Under_menu_control() {return box_btn;}
@Override public Control Under_control() {return box_grp;}
@Override public Composite Under_composite() {return box_grp;}
@Override public Control Under_menu_control() {return box_grp;}
@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;} private final Swt_core_cmds core;
@Override public GxwCore_base Core() {return core;} private final Swt_core__basic 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) {
if (ctx.Match(k, GfuiBtn.Invk_btn_img)) return btn_img;
@ -60,14 +63,16 @@ public class Swt_btn_no_border implements GxwElem, Swt_control {
private void Btn_img_(ImageAdp v) {
if (box_btn == null || v == null) return;
SizeAdp size = core.Size();
int dif = 6;
int dif = 0;
box_btn.setImage((Image)v.Resize(size.Width() - dif, size.Height() - dif).Under());
}
private 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);
box_btn.setSize(25, 25);
box_btn.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
private void Make_btn_no_border(Display display, Shell shell, Composite owner) {
box_grp = new Composite(owner, SWT.FLAT);
box_btn = new Label(box_grp, SWT.FLAT);
box_grp.setSize(16, 16);
box_btn.setSize(16, 16);
box_grp.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
box_btn.setBackground(display.getSystemColor(SWT.COLOR_RED));
box_btn.addFocusListener(new Swt_clabel_lnr_focus(box_grp));
}
}

@ -44,7 +44,7 @@ class Swt_combo implements GxwElem, GxwComboBox, Swt_control, Gfo_evt_mgr_owner
private final Combo combo;
public Swt_combo(Swt_control owner, Keyval_hash ctorArgs) {
combo = new Combo(owner.Under_composite(), SWT.DROP_DOWN);
core = new Swt_core_cmds(combo);
core = new Swt_core__basic(combo);
combo.addKeyListener(new Swt_lnr_key(this));
combo.addMouseListener(new Swt_lnr_mouse(this));
combo.addSelectionListener(new Swt_combo__selection_listener(this));

@ -46,7 +46,7 @@ public class Swt_combo_ctrl extends Swt_text_w_border implements GxwElem, GxwCom
private final Text swt_text;
private final Swt_combo_list list;
public Swt_combo_ctrl(Swt_control owner, Color color, Keyval_hash ctorArgs) {
super(owner, color, new Keyval_hash());
super(owner, color, new Keyval_hash(), Swt_text_w_border.Margin_t__combo);
Display display = owner.Under_control().getDisplay();
Shell shell = owner.Under_control().getShell();
this.swt_text = super.Under_text();

@ -34,10 +34,10 @@ public class Swt_control_ {
public static void Pos_set(Control c, int x, int y) {c.setLocation(x, y);}
public static void Size_set(Control c, SizeAdp v) {c.setSize(v.Width(), v.Height());}
public static void Size_set(Control c, int w, int h) {c.setSize(w, h);}
public static void Rect_set(Control c, RectAdp v) {c.setBounds(Xto_rectangle(v));}
public static void Rect_set(Control c, int x, int y, int w, int h) {c.setBounds(Xto_rectangle(x, y, w, h));}
public static void Rect_add(Control c, RectAdp v, int x, int y, int w, int h) {c.setBounds(Xto_rectangle(v.X() + x, v.Y() + y, v.Width() + w, v.Height()+ h));}
public static Rectangle Xto_rectangle(int x, int y, int w, int h) {return new Rectangle(x, y, w, h);}
public static Rectangle Xto_rectangle(RectAdp v) {return new Rectangle(v.X(), v.Y(), v.Width(), v.Height());}
public static void Rect_set(Control c, RectAdp v) {c.setBounds(To_rectangle(v));}
public static void Rect_set(Control c, int x, int y, int w, int h) {c.setBounds(To_rectangle(x, y, w, h));}
public static void Rect_add(Control c, RectAdp v, int x, int y, int w, int h) {c.setBounds(To_rectangle(v.X() + x, v.Y() + y, v.Width() + w, v.Height()+ h));}
private static Rectangle To_rectangle(int x, int y, int w, int h) {return new Rectangle(x, y, w, h);}
private static Rectangle To_rectangle(RectAdp v) {return new Rectangle(v.X(), v.Y(), v.Width(), v.Height());}
public static Swt_control cast_or_fail(GfuiElem elem) {return (Swt_control)elem.UnderElem();}
}

@ -0,0 +1,151 @@
/*
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.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import gplx.gfui.controls.gxws.GxwCore_base;
import gplx.gfui.controls.gxws.GxwElem;
import gplx.gfui.draws.*;
import gplx.gfui.kits.*;
import gplx.gfui.layouts.swts.*;
abstract class Swt_core__base extends GxwCore_base {
private boolean focus_able;
private int focus_index;
protected Swt_layout_mgr layout_mgr;
protected Swt_layout_data layout_data;
private Control sizeable, viewable;
private FontAdp text_font;
public Swt_core__base(Control sizeable, Control viewable) {
this.sizeable = sizeable;
this.viewable = viewable;
}
@Override public int X() {return sizeable.getLocation().x;}
@Override public void X_set(int v) {Swt_control_.X_set(sizeable, v);}
@Override public int Y() {return sizeable.getLocation().y;}
@Override public void Y_set(int v) {Swt_control_.Y_set(sizeable, v);}
@Override public int Width() {return sizeable.getSize().x;}
@Override public void Width_set(int v) {Swt_control_.W_set(sizeable, v);}
@Override public int Height() {return sizeable.getSize().y;}
@Override public void Height_set(int v) {Swt_control_.H_set(sizeable, v);}
@Override public SizeAdp Size() {return SizeAdp_.new_(this.Width(), this.Height());}
@Override public void Size_set(SizeAdp v) {Swt_control_.Size_set(sizeable, v);}
@Override public PointAdp Pos() {return PointAdp_.new_(this.X(), this.Y());}
@Override public void Pos_set(PointAdp v) {Swt_control_.Pos_set(sizeable, v);}
@Override public RectAdp Rect() {return RectAdp_.new_(this.X(), this.Y(), this.Width(), this.Height());}
@Override public void Rect_set(RectAdp v) {Swt_control_.Rect_set(sizeable, v);}
@Override public boolean Visible() {return sizeable.isVisible();}
@Override public void Visible_set(boolean v) {sizeable.setVisible(v);}
@Override public Swt_layout_mgr Layout_mgr() {return layout_mgr;}
@Override public Swt_layout_data Layout_data() {return layout_data;}
@Override public void Layout_mgr_(Swt_layout_mgr v) {
Swt_core__base.Layout_mgr_set(sizeable, v);
this.layout_mgr = v;
}
@Override public void Layout_data_(Swt_layout_data v) {
Swt_core__base.Layout_data_set(sizeable, v);
this.layout_data = v;
}
@Override public void Controls_add(GxwElem sub) {
if (!(sizeable instanceof Composite)) throw Err_.new_wo_type("cannot add sub to control");
Composite owner_as_composite = (Composite)sizeable;
Control sub_as_swt = ((Swt_control)sub).Under_control();
sub_as_swt.setParent(owner_as_composite);
}
@Override public void Controls_del(GxwElem sub) {
if (!(sizeable instanceof Composite)) throw Err_.new_wo_type("cannot remove sub from control");
Control sub_as_swt = ((Swt_control)sub).Under_control();
sub_as_swt.dispose(); // SWT: no way to officially remove sub from control; can only dispose
}
@Override public ColorAdp BackColor() {return To_color_gfui(viewable.getBackground());}
@Override public void BackColor_set(ColorAdp v) {viewable.setBackground(To_color_swt(viewable, v));}
@Override public ColorAdp ForeColor() {return To_color_gfui(viewable.getForeground());}
@Override public void ForeColor_set(ColorAdp v) {viewable.setForeground(To_color_swt(viewable, v));}
@Override public String TipText() {return viewable.getToolTipText();}
@Override public void TipText_set(String v) {viewable.setToolTipText(v);}
@Override public FontAdp TextFont() {
if (text_font == null)
text_font = Swt_core__base.Control_font_get(viewable.getFont(), this);
return text_font;
}
@Override public void TextFont_set(FontAdp v) {
Swt_core__base.Control_font_set(v, this, viewable);
this.text_font = v;
}
@Override public void Select_exec() {viewable.setFocus();}
@Override public boolean Focus_has() {return viewable.isFocusControl();}
@Override public void Focus() {
if (Focus_able())
viewable.forceFocus();
}
@Override public boolean Focus_able() {return focus_able;}
@Override public void Focus_able_(boolean v) {focus_able = v;}
@Override public int Focus_index() {return focus_index;}
@Override public void Focus_index_set(int v) {focus_index = v;}
@Override public void Zorder_front() {} // TODO.FUTURE: Canvas c; c.moveAbove(arg0);
@Override public void Zorder_back() {} // TODO.FUTURE: Canvas c; c.moveBelow(arg0);
private static ColorAdp To_color_gfui(Color v) {return ColorAdp_.new_(0, v.getRed(), v.getGreen(), v.getBlue());}
protected static Color To_color_swt(Control control, ColorAdp v) {return new Color(control.getDisplay(), v.Red(), v.Green(), v.Blue());}
private 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;
}
private 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);
}
private static void Layout_mgr_set(Control control, Swt_layout_mgr v) {
Swt_layout_mgr__grid gfui_layout = (Swt_layout_mgr__grid)v;
GridLayout swt_layout = new GridLayout();
swt_layout.numColumns = gfui_layout.Cols();
swt_layout.marginHeight = gfui_layout.Margin_h();
swt_layout.marginWidth = gfui_layout.Margin_w();
swt_layout.verticalSpacing = gfui_layout.Spacing_h();
Composite control_as_composite = (Composite)control;
control_as_composite.setLayout(swt_layout);
}
private static void Layout_data_set(Control control, Swt_layout_data v) {
Swt_layout_data__grid gfui_data = (Swt_layout_data__grid)v;
GridData swt_data = new GridData();
if (gfui_data.Align_w_fill()) swt_data.horizontalAlignment = GridData.FILL;
if (gfui_data.Align_h_fill()) swt_data.verticalAlignment = GridData.FILL;
if (gfui_data.Grab_excess_w()) swt_data.grabExcessHorizontalSpace = gfui_data.Grab_excess_w();
if (gfui_data.Grab_excess_h()) swt_data.grabExcessVerticalSpace = gfui_data.Grab_excess_h();
if (gfui_data.Hint_w() > 0) {
swt_data.widthHint = gfui_data.Hint_w();
swt_data.horizontalAlignment = GridData.CENTER;
}
if (gfui_data.Hint_h() > 0) {
swt_data.heightHint = gfui_data.Hint_h();
swt_data.verticalAlignment = GridData.CENTER;
}
if (gfui_data.Min_w() > 0) swt_data.minimumWidth = gfui_data.Min_w();
control.setLayoutData(swt_data);
}
}

@ -0,0 +1,30 @@
/*
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.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
import org.eclipse.swt.widgets.*;
import gplx.gfui.controls.gxws.*;
class Swt_core__basic extends Swt_core__base {
protected final Control control;
public Swt_core__basic(Control control) {
super(control, control);
this.control = control;
}
@Override public void Invalidate() {control.redraw(); control.update();}
@Override public void Dispose() {control.dispose();}
}

@ -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.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
import org.eclipse.swt.widgets.*;
import gplx.gfui.controls.gxws.*;
class Swt_core__dual extends Swt_core__base {
private final Control outer, inner;
private final int inner_adj_w, inner_adj_h;
public Swt_core__dual(Composite outer, Control inner, int inner_adj_w, int inner_adj_h) {
super(outer, inner);
this.outer = outer; this.inner = inner;
this.inner_adj_w = inner_adj_w; this.inner_adj_h = inner_adj_h;
}
@Override public void Width_set(int v) {super.Width_set(v); Swt_control_.W_set(outer, v + inner_adj_w);}
@Override public void Height_set(int v) {super.Height_set(v); Swt_control_.H_set(outer, v + inner_adj_h);}
@Override public void Size_set(SizeAdp v) {super.Size_set(v); Swt_control_.Size_set(inner, v.Width() + inner_adj_w, v.Height() + inner_adj_h);}
@Override public void Rect_set(RectAdp v) {super.Rect_set(v); Swt_control_.Size_set(inner, v.Width() + inner_adj_w, v.Height() + inner_adj_h);}
@Override public void Invalidate() {outer.update(); inner.update();}
@Override public void Dispose() {outer.dispose(); inner.dispose();}
}

@ -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.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import gplx.gfui.controls.gxws.*;
import gplx.gfui.draws.*;
import gplx.gfui.kits.*;
import gplx.gfui.kits.core.Swt_kit;
import gplx.gfui.layouts.swts.*;
class Swt_core__frames extends Swt_core__base {
private final Composite outer;
private final Control inner;
private final Swt_frame_itm[] frames;
private final int frames_len;
public Swt_core__frames(final Swt_text_w_border text_w_border, final Composite outer, final Swt_frame_itm[] frames) {
super(outer, frames[frames.length - 1].Item());
this.frames = frames;
this.frames_len = frames.length;
this.outer = outer;
this.inner = frames[frames_len - 1].Item();
// listener needed for layout changes to propagate to Gxw size methods
outer.addListener (SWT.Resize, new Listener() {
public void handleEvent (Event e) {
Rectangle outer_rect = outer.getBounds();
Frames_w_set(outer_rect.width);
Frames_h_set(outer_rect.height);
// vertically center
int text_size = frames[1].Item().getSize().y;
text_w_border.margins_t = (outer_rect.height - text_size) / 2;
}
});
}
@Override public void Width_set(int v) {super.Width_set(v); Frames_w_set(v);}
@Override public void Height_set(int v) {super.Height_set(v); Frames_h_set(v);}
@Override public void Size_set(SizeAdp v) {super.Size_set(v); Frames_size_set(v);}
@Override public void Rect_set(RectAdp v) {super.Rect_set(v); Frames_size_set(v.Size());}
@Override public void BackColor_set(ColorAdp v) {
Color color = Swt_core__base.To_color_swt(outer, v);
for (int i = 0; i < frames_len; i++)
frames[i].Item().setBackground(color);
}
@Override public void Controls_add(GxwElem sub) {throw Err_.new_unimplemented();}
@Override public void Controls_del(GxwElem sub) {}
@Override public void Invalidate() {
inner.redraw();
inner.update();
}
@Override public void Dispose() {outer.dispose(); inner.dispose();}
private void Frames_w_set(int v) {
for (int i = 0; i < frames_len; i++)
frames[i].Rect_set(v, this.Height());
}
private void Frames_h_set(int v) {
for (int i = 0; i < frames_len; i++)
frames[i].Rect_set(this.Width(), v);
}
private void Frames_size_set(SizeAdp v) {
for (int i = 0; i < frames_len; i++)
frames[i].Rect_set(v.Width(), v.Height());
}
}
interface Swt_frame_itm {
Control Item();
void Rect_set(int w, int h);
}
class Swt_frame_itm__manual implements Swt_frame_itm {
private final Control control; private final int x, y, w, h;
public Swt_frame_itm__manual(Control control, int x, int y, int w, int h) {
this.control = control; this.x = x; this.y = y; this.w = w; this.h = h;
}
public Control Item() {return control;}
public void Rect_set(int new_w, int new_h) {
Swt_control_.Rect_set(control, x, y, new_w + w, new_h + h);
}
}
class Swt_frame_itm__center_v implements Swt_frame_itm {
private final Control control; private final Swt_text_w_border margin_owner;
public Swt_frame_itm__center_v(Control control, Swt_text_w_border margin_owner) {
this.control = control;
this.margin_owner = margin_owner;
}
public Control Item() {return control;}
public void Rect_set(int new_w, int new_h) {
int margin_t = margin_owner.margins_t;
int margin_b = margin_owner.margins_b;
Swt_control_.Rect_set(control, 0, margin_t, new_w, new_h - (margin_t + margin_b));
}
}

@ -1,255 +0,0 @@
/*
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.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
import gplx.gfui.PointAdp;
import gplx.gfui.PointAdp_;
import gplx.gfui.RectAdp;
import gplx.gfui.RectAdp_;
import gplx.gfui.SizeAdp;
import gplx.gfui.SizeAdp_;
import gplx.gfui.controls.gxws.GxwCore_base;
import gplx.gfui.controls.gxws.GxwElem;
import gplx.gfui.draws.*;
import gplx.gfui.kits.core.Swt_kit;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
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) {
this.compositeAble = control instanceof Composite;
this.control = control;
}
@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());}
@Override public int Y() {return control.getLocation().y;} @Override public void Y_set(int v) {control.setLocation(this.X(), v);}
@Override public SizeAdp Size() {return SizeAdp_.new_(this.Width(), this.Height());} @Override public void Size_set(SizeAdp v) {if (Cfg_resize_disabled) return; control.setSize(v.Width(), v.Height());}
@Override public PointAdp Pos() {return PointAdp_.new_(this.X(), this.Y());} @Override public void Pos_set(PointAdp v) {control.setLocation(v.X(), v.Y());}
@Override public RectAdp Rect() {return RectAdp_.new_(this.X(), this.Y(), this.Width(), this.Height());}
@Override public void Rect_set(RectAdp v) {
if (Cfg_resize_disabled)
control.setLocation(v.X(), v.Y());
else
control.setBounds(v.X(), v.Y(), v.Width(), v.Height());
}
@Override public boolean Visible() {return control.isVisible();}
@Override public void Visible_set(boolean v) {control.setVisible(v);}
@Override public ColorAdp BackColor() {return XtoColorAdp(control.getBackground());} @Override public void BackColor_set(ColorAdp v) {control.setBackground(XtoColor(v));}
@Override public ColorAdp ForeColor() {return XtoColorAdp(control.getForeground());} @Override public void ForeColor_set(ColorAdp v) {control.setForeground(XtoColor(v));}
public boolean Cfg_resize_disabled = false;
ColorAdp XtoColorAdp(Color v) {return ColorAdp_.new_(0, v.getRed(), v.getGreen(), v.getBlue());}
Color XtoColor(ColorAdp v) {return new Color(control.getDisplay(), v.Red(), v.Green(), v.Blue());}
@Override public FontAdp TextFont() {
if (prv_font != null) return prv_font;
prv_font = Swt_kit.Control_font_get(control.getFont(), this);
return prv_font;
} FontAdp prv_font;
@Override public void TextFont_set(FontAdp v) {
Swt_kit.Control_font_set(v, this, control);
prv_font = v;
}
@Override public String TipText() {return control.getToolTipText();} @Override public void TipText_set(String v) {control.setToolTipText(v);}
@Override public void Controls_add(GxwElem sub) {
if (!compositeAble) throw Err_.new_wo_type("cannot add sub to control");
Composite owner_as_composite = (Composite)control;
Swt_control sub_as_WxSwt = (Swt_control)sub;
Control sub_as_swt = sub_as_WxSwt.Under_control();
sub_as_swt.setParent(owner_as_composite);
}
@Override public void Controls_del(GxwElem sub) {
if (!compositeAble) throw Err_.new_wo_type("cannot add sub to control");
Swt_control sub_as_WxSwt = (Swt_control)sub;
Control sub_as_swt = sub_as_WxSwt.Under_control();
sub_as_swt.dispose(); // SWT_NOTE: no way to officially remove sub from control; can only dispose
}
@Override public boolean Focus_has() {return control.isFocusControl();}
@Override public boolean Focus_able() {return focus_able;} boolean focus_able;
@Override public void Focus_able_(boolean v) {focus_able = v;}
@Override public int Focus_index() {return focusIndex;} @Override public void Focus_index_set(int v) {focusIndex = v;} int focusIndex;
@Override public void Focus() {
if (Focus_able())
control.forceFocus();
}
@Override public void Select_exec() {
control.setFocus();
}
@Override public void Zorder_front() {
// Canvas c; c.moveAbove(arg0);
}
@Override public void Zorder_back() {
// Canvas c; c.moveBelow(arg0);
}
@Override public void Invalidate() {control.redraw(); control.update();}
@Override public void Dispose() {control.dispose();}
}
class Swt_core_cmds_dual extends GxwCore_base {
public Swt_core_cmds_dual(Composite outer, Control inner, int inner_adj_x, int inner_adj_y, int inner_adj_w, int inner_adj_h) {
this.outer = outer; this.inner = inner;
outer_is_composite = outer instanceof Composite;
this.inner_adj_x = inner_adj_x; this.inner_adj_y = inner_adj_y; this.inner_adj_w = inner_adj_w; this.inner_adj_h = inner_adj_h;
} Control outer, inner; boolean outer_is_composite = false; int inner_adj_x, inner_adj_y, inner_adj_w, inner_adj_h;
@Override public int X() {return outer.getLocation().x;} @Override public void X_set(int v) {Swt_control_.X_set(outer, v);}
@Override public int Y() {return outer.getLocation().y;} @Override public void Y_set(int v) {Swt_control_.Y_set(outer, v);}
@Override public int Width() {return outer.getSize().x;} @Override public void Width_set(int v) {Swt_control_.W_set(outer, v); Swt_control_.W_set(outer, v + inner_adj_w);}
@Override public int Height() {return outer.getSize().y;} @Override public void Height_set(int v) {Swt_control_.H_set(outer, v); Swt_control_.H_set(outer, v + inner_adj_h);}
@Override public SizeAdp Size() {return SizeAdp_.new_(this.Width(), this.Height());} @Override public void Size_set(SizeAdp v) {Swt_control_.Size_set(outer, v); Swt_control_.Size_set(inner, v.Width() + inner_adj_w, v.Height() + inner_adj_h);}
@Override public PointAdp Pos() {return PointAdp_.new_(this.X(), this.Y());} @Override public void Pos_set(PointAdp v) {Swt_control_.Pos_set(outer, v);}
@Override public RectAdp Rect() {return RectAdp_.new_(this.X(), this.Y(), this.Width(), this.Height());} @Override public void Rect_set(RectAdp v) {Swt_control_.Rect_set(outer, v); Swt_control_.Size_set(inner, v.Width() + inner_adj_w, v.Height() + inner_adj_h);}
@Override public boolean Visible() {return outer.isVisible();}
@Override public void Visible_set(boolean v) {outer.setVisible(v);}
@Override public ColorAdp BackColor() {return XtoColorAdp(inner.getBackground());} @Override public void BackColor_set(ColorAdp v) {inner.setBackground(XtoColor(v));}
@Override public ColorAdp ForeColor() {return XtoColorAdp(inner.getForeground());} @Override public void ForeColor_set(ColorAdp v) {inner.setForeground(XtoColor(v));}
ColorAdp XtoColorAdp(Color v) {return ColorAdp_.new_(0, v.getRed(), v.getGreen(), v.getBlue());}
Color XtoColor(ColorAdp v) {return new Color(outer.getDisplay(), v.Red(), v.Green(), v.Blue());}
@Override public FontAdp TextFont() {
if (prv_font != null) return prv_font;
prv_font = Swt_kit.Control_font_get(inner.getFont(), this);
return prv_font;
} FontAdp prv_font;
@Override public void TextFont_set(FontAdp v) {
Swt_kit.Control_font_set(v, this, inner);
prv_font = v;
}
@Override public String TipText() {return inner.getToolTipText();} @Override public void TipText_set(String v) {inner.setToolTipText(v);}
@Override public void Controls_add(GxwElem sub) {
if (!outer_is_composite) throw Err_.new_wo_type("cannot add sub to outer");
Composite owner_as_composite = (Composite)outer;
Swt_control sub_as_WxSwt = (Swt_control)sub;
Control sub_as_swt = sub_as_WxSwt.Under_control();
sub_as_swt.setParent(owner_as_composite);
}
@Override public void Controls_del(GxwElem sub) {
if (!outer_is_composite) throw Err_.new_wo_type("cannot add sub to outer");
Swt_control sub_as_WxSwt = (Swt_control)sub;
Control sub_as_swt = sub_as_WxSwt.Under_control();
sub_as_swt.dispose(); // SWT_NOTE: no way to officially remove sub from outer; can only dispose
}
@Override public boolean Focus_has() {return inner.isFocusControl();}
@Override public boolean Focus_able() {return focus_able;} boolean focus_able;
@Override public void Focus_able_(boolean v) {focus_able = v;}
@Override public int Focus_index() {return focusIndex;} @Override public void Focus_index_set(int v) {focusIndex = v;} int focusIndex;
@Override public void Focus() {
if (Focus_able())
inner.forceFocus();
}
@Override public void Select_exec() {
inner.setFocus();
}
@Override public void Zorder_front() {}
@Override public void Zorder_back() {}
@Override public void Invalidate() {outer.update(); inner.update();}
@Override public void Dispose() {outer.dispose(); inner.dispose();}
}
interface Swt_core_cmds_frames_itm {
Control Itm();
void Rect_set(int w, int h);
}
class Swt_core_cmds_frames_itm_manual implements Swt_core_cmds_frames_itm {
public Swt_core_cmds_frames_itm_manual(Control control, int x, int y, int w, int h) {
this.control = control; this.x = x; this.y = y; this.w = w; this.h = h;
} Control control; int x, y, w, h;
public Control Itm() {return control;}
public void Rect_set(int new_w, int new_h) {
Swt_control_.Rect_set(control, x, y, new_w + w, new_h + h);
}
}
class Swt_core_cmds_frames_itm_center_v implements Swt_core_cmds_frames_itm {
public Swt_core_cmds_frames_itm_center_v(Control control, Swt_text_w_border margin_owner) {this.control = control; this.margin_owner = margin_owner;} Control control; Swt_text_w_border margin_owner;
public Control Itm() {return control;}
public void Rect_set(int new_w, int new_h) {
int margin_t = margin_owner.margins_t;
int margin_b = margin_owner.margins_b;
Swt_control_.Rect_set(control, 0, margin_t, new_w, new_h - (margin_t + margin_b));
}
}
class Swt_core_cmds_frames extends GxwCore_base {
public Swt_core_cmds_frames(Composite outer, Swt_core_cmds_frames_itm[] frames) {
this.outer = outer; this.frames = frames;
frames_len = frames.length;
this.inner = frames[frames_len - 1].Itm();
} Composite outer; Control inner; Swt_core_cmds_frames_itm[] frames; int frames_len;
void Frames_w_set(int v) {
for (int i = 0; i < frames_len; i++)
frames[i].Rect_set(v, this.Height());
}
void Frames_h_set(int v) {
for (int i = 0; i < frames_len; i++)
frames[i].Rect_set(this.Width(), v);
}
void Frames_size_set(SizeAdp v) {
for (int i = 0; i < frames_len; i++)
frames[i].Rect_set(v.Width(), v.Height());
}
@Override public int X() {return outer.getLocation().x;} @Override public void X_set(int v) {Swt_control_.X_set(outer, v);}
@Override public int Y() {return outer.getLocation().y;} @Override public void Y_set(int v) {Swt_control_.Y_set(outer, v);}
@Override public int Width() {return outer.getSize().x;} @Override public void Width_set(int v) {Swt_control_.W_set(outer, v); Frames_w_set(v);}
@Override public int Height() {return outer.getSize().y;} @Override public void Height_set(int v) {Swt_control_.H_set(outer, v); Frames_h_set(v);}
@Override public SizeAdp Size() {return SizeAdp_.new_(this.Width(), this.Height());} @Override public void Size_set(SizeAdp v) {Swt_control_.Size_set(outer, v); Frames_size_set(v);}
@Override public PointAdp Pos() {return PointAdp_.new_(this.X(), this.Y());} @Override public void Pos_set(PointAdp v) {Swt_control_.Pos_set(outer, v);}
@Override public RectAdp Rect() {return RectAdp_.new_(this.X(), this.Y(), this.Width(), this.Height());} @Override public void Rect_set(RectAdp v) {Swt_control_.Rect_set(outer, v); Frames_size_set(v.Size());}
@Override public boolean Visible() {return outer.isVisible();}
@Override public void Visible_set(boolean v) {outer.setVisible(v);}
@Override public ColorAdp BackColor() {return XtoColorAdp(inner.getBackground());}
@Override public void BackColor_set(ColorAdp v) {
Color color = XtoColor(v);
// outer.setBackground(color);
for (int i = 0; i < frames_len; i++)
frames[i].Itm().setBackground(color);
}
@Override public ColorAdp ForeColor() {return XtoColorAdp(inner.getForeground());} @Override public void ForeColor_set(ColorAdp v) {inner.setForeground(XtoColor(v));}
ColorAdp XtoColorAdp(Color v) {return ColorAdp_.new_(0, v.getRed(), v.getGreen(), v.getBlue());}
Color XtoColor(ColorAdp v) {return new Color(outer.getDisplay(), v.Red(), v.Green(), v.Blue());}
@Override public FontAdp TextFont() {
if (prv_font != null) return prv_font;
prv_font = Swt_kit.Control_font_get(inner.getFont(), this);
return prv_font;
} FontAdp prv_font;
@Override public void TextFont_set(FontAdp v) {
Swt_kit.Control_font_set(v, this, inner);
prv_font = v;
}
@Override public String TipText() {return inner.getToolTipText();} @Override public void TipText_set(String v) {inner.setToolTipText(v);}
@Override public void Controls_add(GxwElem sub) {throw Err_.new_unimplemented();}
@Override public void Controls_del(GxwElem sub) {}
@Override public boolean Focus_has() {return inner.isFocusControl();}
@Override public boolean Focus_able() {return focus_able;} boolean focus_able;
@Override public void Focus_able_(boolean v) {focus_able = v;}
@Override public int Focus_index() {return focusIndex;} @Override public void Focus_index_set(int v) {focusIndex = v;} int focusIndex;
@Override public void Focus() {
if (Focus_able())
inner.forceFocus();
}
@Override public void Select_exec() {
inner.setFocus();
}
@Override public void Zorder_front() {}
@Override public void Zorder_back() {}
@Override public void Invalidate() {
inner.redraw();
inner.update();
}
@Override public void Dispose() {outer.dispose(); inner.dispose();}
}

@ -0,0 +1,62 @@
/*
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.kits.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.kits.*;
import gplx.*;
import gplx.core.threads.Thread_adp_;
import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import gplx.gfui.controls.gxws.GxwCbkHost;
import gplx.gfui.controls.gxws.GxwCore_base;
import gplx.gfui.controls.gxws.Gxw_grp;
import gplx.gfui.draws.*;
import gplx.gfui.kits.core.GfuiInvkCmd;
import gplx.gfui.kits.core.Swt_kit;
public class Swt_grp implements Gxw_grp, Swt_control, FocusListener, Gfo_evt_mgr_owner {
// private GfuiInvkCmd cmd_sync;
private Composite composite;
public Swt_grp(Swt_kit kit, Swt_control owner, Keyval_hash ctorArgs) {
this.kit = kit;
composite = new Composite(owner.Under_composite(), SWT.NONE);
core = new Swt_core__basic(composite);
composite.addKeyListener(new Swt_lnr_key(this));
composite.addMouseListener(new Swt_lnr_mouse(this));
}
public Swt_kit Kit() {return kit;} private Swt_kit kit;
@Override public Control Under_control() {return composite;}
@Override public Composite Under_composite() {return composite;}
@Override public Control Under_menu_control() {return composite;}
public Gfo_evt_mgr Evt_mgr() {return ev_mgr;} private Gfo_evt_mgr ev_mgr;
public void Evt_mgr_(Gfo_evt_mgr v) {ev_mgr = 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 String TextVal() {return "not implemented";}
@Override public void TextVal_set(String v) {}
@Override public void EnableDoubleBuffering() {}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
return Gfo_invk_.Rv_unhandled;
}
@Override public void focusGained(FocusEvent arg0) {}
@Override public void focusLost(FocusEvent arg0) {}
}

@ -159,7 +159,7 @@ public class Swt_html implements Gxw_html, Swt_control, FocusListener, Gfo_evt_m
, Browser_tid_webkit = SWT.WEBKIT
;
}
class Swt_core_cmds_html extends Swt_core_cmds {
class Swt_core_cmds_html extends Swt_core__basic {
public Swt_core_cmds_html(Swt_html html_box, Control control) {super(control);}
@Override public void Focus() {
if (Focus_able())

@ -30,7 +30,7 @@ public class Swt_lbl implements GxwElem, Swt_control {
private Label lbl;
public Swt_lbl(Swt_control owner, Keyval_hash ctorArgs) {
lbl = new Label(owner.Under_composite(), SWT.CENTER);
core = new Swt_core_cmds(lbl);
core = new Swt_core__basic(lbl);
lbl.addKeyListener(new Swt_lnr_key(this));
lbl.addMouseListener(new Swt_lnr_mouse(this));
}

@ -51,7 +51,7 @@ public class Swt_tab_mgr implements Gxw_tab_mgr, Swt_control, FocusListener, Gfo
new Swt_tab_mgr_lnr_drag_drop(this, tab_folder);
tab_folder.addCTabFolder2Listener(new Swt_tab_mgr_lnr_close(this));
core = new Swt_core_cmds(tab_folder);
core = new Swt_core__basic(tab_folder);
// cmd_async = kit.New_cmd_async(this);
cmd_sync = kit.New_cmd_sync(this);
}

@ -44,7 +44,7 @@ public class Swt_text implements GxwTextFld, Swt_control {
: SWT.NONE
;
text_box = new Text(owner_control.Under_composite(), text_box_args);
core = new Swt_core_cmds(text_box);
core = new Swt_core__basic(text_box);
text_box.addKeyListener(new Swt_lnr_key(this));
text_box.addMouseListener(new Swt_lnr_mouse(this));
}

@ -39,14 +39,15 @@ public class Swt_text_w_border implements GxwTextFld, Swt_control {
private Composite text_host;
private Composite text_margin;
private Text text_elem;
public Swt_text_w_border(Swt_control owner_control, Color color, Keyval_hash ctorArgs) {
public Swt_text_w_border(Swt_control owner_control, Color color, Keyval_hash ctorArgs, int margin_t) {
Composite owner = owner_control.Under_composite();
int text_elem_style = ctorArgs.Has(GfuiTextBox_.Ctor_Memo) ? SWT.MULTI | SWT.WRAP | SWT.V_SCROLL : SWT.FLAT;
New_box_text_w_border(owner.getDisplay(), owner.getShell(), text_elem_style, color);
core = new Swt_core_cmds_frames(text_host, new Swt_core_cmds_frames_itm[]
{ new Swt_core_cmds_frames_itm_manual(text_margin, 1, 1, -2, -2)
, new Swt_core_cmds_frames_itm_center_v(text_elem, this)
});
New_box_text_w_border(owner.getDisplay(), owner, text_elem_style, color);
core = new Swt_core__frames(this, text_host, new Swt_frame_itm[]
{ new Swt_frame_itm__manual(text_margin, 1, 1, -2, -2)
, new Swt_frame_itm__center_v(text_elem, this)
});
this.margins_t = margin_t;
text_elem.addKeyListener(new Swt_lnr_key(this));
text_elem.addMouseListener(new Swt_lnr_mouse(this));
}
@ -57,7 +58,7 @@ public class Swt_text_w_border implements GxwTextFld, Swt_control {
@Override public int SelBgn() {return text_elem.getCaretPosition();} @Override public void SelBgn_set(int v) {text_elem.setSelection(v);}
@Override public int SelLen() {return text_elem.getSelectionCount();} @Override public void SelLen_set(int v) {text_elem.setSelection(this.SelBgn(), this.SelBgn() + v);}
@Override public String TextVal() {return text_elem.getText();} @Override public void TextVal_set(String v) {text_elem.setText(v);}
@Override public GxwCore_base Core() {return core;} Swt_core_cmds_frames core;
@Override public GxwCore_base Core() {return core;} Swt_core__frames core;
@Override public GxwCbkHost Host() {return host;} @Override public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host;
@Override public void EnableDoubleBuffering() {}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
@ -65,7 +66,7 @@ public class Swt_text_w_border implements GxwTextFld, Swt_control {
}
public int Margins_l() {return margins_l;} int margins_l;
public int Margins_r() {return margins_r;} int margins_r;
public int Margins_t() {return margins_t;} int margins_t;
public int Margins_t() {return margins_t;} int margins_t;
public int Margins_b() {return margins_b;} int margins_b;
public void Margins_set(int left, int top, int right, int bot) {
this.margins_l = left; this.margins_t = top; this.margins_r = right; this.margins_b = bot;
@ -73,18 +74,17 @@ public class Swt_text_w_border implements GxwTextFld, Swt_control {
@Override public boolean Border_on() {return false;} @Override public void Border_on_(boolean v) {} // SWT_TODO:borderWidth doesn't seem mutable
@Override public void CreateControlIfNeeded() {}
@Override public boolean OverrideTabKey() {return false;} @Override public void OverrideTabKey_(boolean v) {}
void New_box_text_w_border(Display display, Shell shell, int style, Color color) {
text_host = new Composite(shell, SWT.FLAT);
private void New_box_text_w_border(Display display, Composite owner, int style, Color color) {
text_host = new Composite(owner, SWT.FLAT);
text_margin = new Composite(text_host, SWT.FLAT);
text_elem = new Text(text_margin, style);
text_elem .addTraverseListener(Swt_lnr_traverse_ignore_ctrl.Instance); // do not allow ctrl+tab to change focus when pressed in text box; allows ctrl+tab to be used by other bindings; DATE:2014-04-30
text_host.setSize(20, 20);
text_host.setBackground(color);
text_margin.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
text_margin.setSize(20, 20);
text_elem.setSize(20 - 2, 20 - 2);
text_elem.setLocation(1, 1);
text_margin.setSize(25, 25);
}
public static final int Margin_t__text = 4, Margin_t__combo = 6; // magic constants
}
class Swt_lnr_traverse_ignore_ctrl implements TraverseListener {
public void keyTraversed(TraverseEvent e) {

@ -42,7 +42,7 @@ public class Swt_win implements GxwWin, Swt_control {
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.ctrl_mgr = new Swt_core__basic(shell);
this.show_lnr = new Swt_lnr_show(this);
this.resize_lnr = new Swt_lnr_resize(this);
shell.addListener(SWT.Show, show_lnr);

@ -0,0 +1,20 @@
/*
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.layouts.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.layouts.*;
public interface Swt_layout_data {
}

@ -0,0 +1,28 @@
/*
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.layouts.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.layouts.*;
public class Swt_layout_data__grid implements Swt_layout_data {
public boolean Grab_excess_h() {return grab_excess_h;} public Swt_layout_data__grid Grab_excess_h_(boolean v) {grab_excess_h = v; return this;} private boolean grab_excess_h;
public boolean Align_h_fill() {return align_h_fill;} public Swt_layout_data__grid Align_h_fill_(boolean v) {align_h_fill = v; return this;} private boolean align_h_fill;
public boolean Grab_excess_w() {return grab_excess_w;} public Swt_layout_data__grid Grab_excess_w_(boolean v) {grab_excess_w = v; return this;} private boolean grab_excess_w;
public boolean Align_w_fill() {return align_w_fill;} public Swt_layout_data__grid Align_w_fill_(boolean v) {align_w_fill = v; return this;} private boolean align_w_fill;
public int Min_w() {return min_w;} public Swt_layout_data__grid Min_w_(int v) {min_w = v; return this;} private int min_w = -1;
public int Min_h() {return min_h;} public Swt_layout_data__grid Min_h_(int v) {min_h = v; return this;} private int min_h = -1;
public int Hint_w() {return hint_w;} public Swt_layout_data__grid Hint_w_(int v) {hint_w = v; return this;} private int hint_w = -1;
public int Hint_h() {return hint_h;} public Swt_layout_data__grid Hint_h_(int v) {hint_h = v; return this;} private int hint_h = -1;
}

@ -0,0 +1,20 @@
/*
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.layouts.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.layouts.*;
public interface Swt_layout_mgr {
}

@ -0,0 +1,26 @@
/*
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.layouts.swts; import gplx.*; import gplx.gfui.*; import gplx.gfui.layouts.*;
import gplx.gfui.controls.elems.*;
public class Swt_layout_mgr__grid implements Swt_layout_mgr {
public int Cols() {return cols;} public Swt_layout_mgr__grid Cols_(int v) {cols = v; return this;} private int cols = -1;
public int Margin_w() {return margin_w;} public Swt_layout_mgr__grid Margin_w_(int v) {margin_w = v; return this;} private int margin_w = -1;
public int Margin_h() {return margin_h;} public Swt_layout_mgr__grid Margin_h_(int v) {margin_h = v; return this;} private int margin_h = -1;
public int Spacing_w() {return spacing_w;} public Swt_layout_mgr__grid Spacing_w_(int v) {spacing_w = v; return this;} private int spacing_w = -1;
public int Spacing_h() {return spacing_h;} public Swt_layout_mgr__grid Spacing_h_(int v) {spacing_h = v; return this;} private int spacing_h = -1;
}

@ -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.xowa.addons.wikis.directorys.specials.items.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.directorys.*; import gplx.xowa.addons.wikis.directorys.specials.*; import gplx.xowa.addons.wikis.directorys.specials.items.*;
import gplx.dbs.*;
import gplx.dbs.*; import gplx.dbs.cfgs.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.addons.wikis.ctgs.dbs.*;
public class Xow_wiki_factory {
public static Xowe_wiki Load_personal(Xoae_app app, byte[] domain, Io_url dir_url) {
@ -56,6 +56,7 @@ public class Xow_wiki_factory {
}
Db_conn core_db_conn = Db_conn_bldr.Instance.Get_or_fail(core_db_url);
// > v4.2.0
// cat_link: if cat_link.cl_sortkey_prefix doesn't exist, then cat_link is old format; drop it and add the new one
try {
if (!core_db_conn.Meta_fld_exists(Xodb_cat_link_tbl.TBL_NAME, Xodb_cat_link_tbl.FLD__cl_sortkey_prefix)) {
@ -76,5 +77,9 @@ public class Xow_wiki_factory {
} catch (Exception e) {
Gfo_usr_dlg_.Instance.Warn_many("", "", "xo.personal:page.page_cat_db_id upgrade failed; err=~{0}", Err_.Message_gplx_log(e));
}
// cfg: add some settings
// Db_cfg_tbl cfg_tbl = Xowd_cfg_tbl_.Get_or_fail(core_db_conn);
// Db_cfg_hash cfg_hash = cfg_tbl.Select_as_hash("xowa.wiki.settings");
}
}

@ -1,143 +0,0 @@
/*
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.xowa.guis; import gplx.*; import gplx.xowa.*;
import gplx.core.envs.*;
import gplx.gfui.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.standards.*;
import gplx.xowa.users.*; import gplx.xowa.guis.views.*;
public class Xog_resizer implements Gfo_invk {
private Xog_win_itm win_itm;
private String browser__adj_type = "none";
private RectAdp browser__adj_rect = RectAdp_.Zero;
public void Init_by_app(Xoa_app app, Xog_win_itm win_itm) {
this.win_itm = win_itm;
if (Op_sys.Cur().Tid_is_osx()) {
browser__adj_type = "relative";
browser__adj_rect = RectAdp_.new_(0, 0, 5, 30);
}
app.Cfg().Bind_many_app(this, Cfg__browser__adj_type, Cfg__browser__adj_rect);
}
public void Exec_win_resize(Xoae_app app, int main_w, int main_h) {
Xog_layout layout = app.Gui_mgr().Layout();
Xog_win_itm main_win = app.Gui_mgr().Browser_win();
GfuiBtn go_bwd_btn = main_win.Go_bwd_btn(), go_fwd_btn = main_win.Go_fwd_btn(), url_exec_btn = main_win.Url_exec_btn(), search_exec_btn = main_win.Search_exec_btn(), find_fwd_btn = main_win.Find_fwd_btn(), find_bwd_btn = main_win.Find_bwd_btn(), find_close_btn = main_win.Find_close_btn();
GfuiComboBox url_box = main_win.Url_box();
GfuiTextBox search_box = main_win.Search_box(), find_box = main_win.Find_box(), prog_box = main_win.Prog_box(), note_box = main_win.Info_box();
Gfui_tab_mgr tab_mgr = main_win.Tab_mgr().Tab_mgr();
int txt_dim = layout.Box_height_calc(app.Gui_mgr().Kit(), url_box);
int btn_dim = 25; // txt_dim + 1;
if (txt_dim < 25) {
txt_margin_v = (25 - txt_dim) / 2;
txt_dim = 25;
}
else
txt_margin_v = 0;
int txt_dif = 0, btn_dif = 0;
int bar_dim = btn_dim > txt_dim ? btn_dim : txt_dim;
if (txt_dim < 25) {txt_dif = (25 - txt_dim) / 2;}
else {btn_dif = (txt_dim - 25) / 2;}
boolean menu_bar_enabled = app.Gui_mgr().Menu_mgr().Window().Get_or_new("main_win").Enabled();
int menu_bar_adj = menu_bar_enabled ? 20 : 2; // 2, else linux progress bar abuts bottom of screen
RectAdp prv_elem_rect = (Op_sys.Cur().Tid_is_wnt() && Op_sys.Cur().Sub_tid() == Op_sys.Sub_tid_win_7) && menu_bar_enabled
? Prv_elem_rect_win_7 // NOTE: if windows 7 and menu bar enabled, shift everything up by 1 pixel; else ugly gap at top border of url box; only affects win 7; DATE:2013-08-31
: Prv_elem_rect_initial
;
Exec_win_resize_elem(layout.Go_bwd_btn() , go_bwd_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), prv_elem_rect, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Go_fwd_btn() , go_fwd_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), go_bwd_btn, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Url_box() , url_box , new Rect_ref(0, 0, main_w - (btn_dim * 5) - 200 , txt_dim ), go_fwd_btn, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Url_exec_btn() , url_exec_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), url_box, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Search_box() , search_box , new Rect_ref(0, 0, 190 , txt_dim ), url_exec_btn, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Search_exec_btn() , search_exec_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), search_box, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Html_box() , tab_mgr , new Rect_ref(0, 0, main_w , main_h + -(bar_dim * 2) - menu_bar_adj), go_bwd_btn, Xog_resizer.Layout_below_left); // -40:btn_dim(url bar) + btn_dim (find box)
if (String_.Eq(browser__adj_type, "none")) {}
else if (String_.Eq(browser__adj_type, "absolute")) {
if ( browser__adj_rect.Width() >= 320 // prevent unshowable window
&& browser__adj_rect.Width() >= 320)
tab_mgr.Rect_set(browser__adj_rect);
}
else if (String_.Eq(browser__adj_type, "relative")) tab_mgr.Rect_set(tab_mgr.Rect().Op_add(browser__adj_rect));
Exec_win_resize_elem(layout.Find_close_btn() , find_close_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), tab_mgr, Xog_resizer.Layout_below_left);
Exec_win_resize_elem(layout.Find_box() , find_box , new Rect_ref(0, 0, 102 , txt_dim ), find_close_btn, Xog_resizer.Layout_right_top);
find_box.Y_(tab_mgr.Y_max());
Exec_win_resize_elem(layout.Find_fwd_btn() , find_fwd_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), find_box, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Find_bwd_btn() , find_bwd_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), find_fwd_btn, Xog_resizer.Layout_right_top);
Exec_win_resize_elem(layout.Prog_box() , prog_box , new Rect_ref(0, 0, (main_w - 102 - 200 - (bar_dim * 3)), txt_dim ), find_bwd_btn, Xog_resizer.Layout_right_top); // -200=200(find_box) - 200 (note_box)
Exec_win_resize_elem(layout.Note_box() , note_box , new Rect_ref(0, 0, 200 , txt_dim ), prog_box, Xog_resizer.Layout_right_top); // -200=200(find_box)
if (txt_dif > 0) {
GfuiElem_.Y_adj(txt_dif, url_box, search_box);
GfuiElem_.Y_adj(txt_dif, find_box, prog_box, note_box);
}
if (btn_dif > 0) {
GfuiElem_.Y_adj(btn_dif, go_bwd_btn, go_fwd_btn, url_exec_btn, find_close_btn, search_exec_btn);
GfuiElem_.Y_adj(btn_dif, find_fwd_btn, find_bwd_btn);
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Cfg__browser__adj_type)) {browser__adj_type = m.ReadStr("v"); win_itm.Refresh_win_size();}
else if (ctx.Match(k, Cfg__browser__adj_rect)) {browser__adj_rect = gplx.gfui.RectAdp_.parse_ws_(m.ReadStr("v")); win_itm.Refresh_win_size();}
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Cfg__browser__adj_type = "xowa.gui.html_box.adj_type", Cfg__browser__adj_rect = "xowa.gui.html_box.adj_rect";
private static RectAdp Prv_elem_rect_initial = RectAdp_.Zero, Prv_elem_rect_win_7 = RectAdp_.new_(0, -1, 0, 0);
private static void Exec_win_resize_elem(Xog_layout_box box, GfuiElem cur_elem, Rect_ref cur_elem_rect, GfuiElem prv_elem, byte layout) {Exec_win_resize_elem(box, cur_elem, cur_elem_rect, prv_elem.Rect(), layout);}
private static void Exec_win_resize_elem(Xog_layout_box box, GfuiElem cur_elem, Rect_ref cur_elem_rect, RectAdp prv_elem_rect, byte layout) {
if (Type_adp_.Eq_typeSafe(cur_elem, GfuiTextBox.class)) {
try {
GfuiTextBox cur_box = (GfuiTextBox)cur_elem;
cur_box.Margins_set(0, txt_margin_v, 0, txt_margin_v);
} catch (Exception e) {Err_.Noop(e);}
}
else if (Type_adp_.Eq_typeSafe(cur_elem, GfuiComboBox.class)) {
try {
GfuiComboBox cur_box = (GfuiComboBox)cur_elem;
cur_box.Margins_set(0, txt_margin_v, 0, txt_margin_v);
} catch (Exception e) {Err_.Noop(e);}
}
if (box.Mode() == Xog_layout_box.Mode_abs) // absolute mode; set dimensions manually
cur_elem_rect.X_(box.X_abs()).Y_(box.Y_abs()).W_(box.W_abs()).H_(box.H_abs());
else {
box.Adj_size(cur_elem_rect);
Set_pos_by_prv(layout, cur_elem_rect, Rect_ref.rectAdp_(prv_elem_rect));
box.Adj_pos(cur_elem_rect);
}
cur_elem.Rect_set(cur_elem_rect.XtoRectAdp());
if (Type_adp_.Eq_typeSafe(cur_elem, GfuiBtn.class)) {
GfuiBtn cur_btn = (GfuiBtn)cur_elem;
cur_btn.Btn_img_(cur_btn.Btn_img());
}
}
private static void Set_pos_by_prv(byte layout, Rect_ref cur_elem_rect, Rect_ref prv_elem_rect) {
switch (layout) {
case Xog_resizer.Layout_right_top:
cur_elem_rect.X_(prv_elem_rect.X_max());
cur_elem_rect.Y_(prv_elem_rect.Y());
break;
case Xog_resizer.Layout_right_bot:
cur_elem_rect.X_(prv_elem_rect.X_max());
cur_elem_rect.Y_(prv_elem_rect.Y_max() - cur_elem_rect.H()); // cur_elem.Height
break;
case Xog_resizer.Layout_below_left:
cur_elem_rect.X_(prv_elem_rect.X());
cur_elem_rect.Y_(prv_elem_rect.Y_max());
break;
}
}
public static final byte Layout_init = 0, Layout_right_top = 1, Layout_right_bot = 2, Layout_below_left = 3;
private static int txt_margin_v = 0;
}

@ -39,8 +39,6 @@ public class Xog_mnu_grp extends Xog_mnu_base {
this.Source_exec(app.Gfs_mgr());
else
this.Clear();
if (!mnu_is_popup && app.Gui_mgr().Browser_win().Win_box() != null)
Gfo_invk_.Invk_by_key(app.Gui_mgr().Browser_win(), Gfui_html.Evt_win_resized);
}
public String Source() {return source;} private String source = ""; // NOTE: default to "" not null, else init will try to run "clear;\nnullbuild;"
public void Source_(String v) {this.source = v; this.Source_exec(app.Gfs_mgr());}

@ -19,6 +19,7 @@ package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xow
import gplx.core.threads.*; import gplx.core.envs.*;
import gplx.gfui.*; import gplx.gfui.draws.*; import gplx.gfui.kits.core.*; import gplx.gfui.controls.windows.*; import gplx.gfui.controls.standards.*;
import gplx.xowa.guis.*; import gplx.xowa.guis.history.*; import gplx.xowa.guis.langs.*; import gplx.xowa.guis.urls.*; import gplx.xowa.guis.views.*;
import gplx.gfui.layouts.swts.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
import gplx.xowa.wikis.pages.*; import gplx.xowa.apps.urls.*; import gplx.xowa.files.*;
import gplx.xowa.htmls.hrefs.*;
@ -53,19 +54,13 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
public Xowe_wiki Active_wiki() {return tab_mgr.Active_tab().Wiki();}
public Xog_html_itm Active_html_itm() {return tab_mgr.Active_tab().Html_itm();}
public Gfui_html Active_html_box() {return tab_mgr.Active_tab().Html_itm().Html_box();}
public Xog_resizer Resizer() {return resizer;} private Xog_resizer resizer = new Xog_resizer();
public Gfo_usr_dlg Usr_dlg() {return app.Usr_dlg();}
public Xog_win_itm_cfg Cfg() {return cfg;} private final Xog_win_itm_cfg cfg = new Xog_win_itm_cfg();
public void Refresh_win_size() {
if (win_box != null) // NOTE: will be null when html box adjustment pref is set and application is starting
resizer.Exec_win_resize(app, win_box.Width(), win_box.Height());
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_link_click)) Win__link_click();
else if (ctx.Match(k, Invk_link_print)) Xog_win_itm__prog_href_mgr.Print(this);
else if (ctx.Match(k, Gfui_html.Evt_location_changed)) Win__link_clicked(m.ReadStr("v"));
else if (ctx.Match(k, Gfui_html.Evt_location_changing)) Page__navigate_by_href(tab_mgr.Active_tab(), Xoh_href_gui_utl.Standardize_xowa_link(m.ReadStr("v")));
else if (ctx.Match(k, Gfui_html.Evt_win_resized)) Refresh_win_size();
else if (ctx.Match(k, Invk_page_refresh)) Page__refresh();
else if (ctx.Match(k, Invk_page_async_exec)) Xog_async_wkr.Async(((Xog_tab_itm)m.ReadObj("v")));
else if (ctx.Match(k, Invk_page_view_read)) Page__mode_(Xopg_page_.Tid_read);
@ -298,23 +293,40 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
sync_cmd = win_box.Kit().New_cmd_sync(this);
Io_url img_dir = app.Fsys_mgr().Bin_xowa_file_dir().GenSubDir_nest("app.window");
FontAdp ui_font = app.Gui_mgr().Win_cfg().Font().To_font();
go_bwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "go_bwd_btn", "go_bwd.png" );
go_fwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "go_fwd_btn", "go_fwd.png" );
url_box = Xog_win_itm_.new_cbo(app, kit, win_box, ui_font, "url_box" , true);
url_exec_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "url_exec_btn", "url_exec.png" );
search_box = Xog_win_itm_.new_txt(app, kit, win_box, ui_font, "search_box" , true);
search_exec_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "search_exec_btn", "search_exec.png" );
find_close_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "find_close_btn", "find_close.png" );
find_box = Xog_win_itm_.new_txt(app, kit, win_box, ui_font, "find_box" , true);
find_fwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "find_fwd_btn", "find_fwd.png" );
find_bwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "find_bwd_btn", "find_bwd.png" );
prog_box = Xog_win_itm_.new_txt(app, kit, win_box, ui_font, "prog_box" , false);
info_box = Xog_win_itm_.new_txt(app, kit, win_box, ui_font, "note_box" , false);
win_box.Layout_mgr_(new Swt_layout_mgr__grid().Cols_(1).Margin_w_(0).Margin_h_(0).Spacing_h_(0));
Gfui_grp toolbar_grp = kit.New_grp("toolbar_grp", win_box);
toolbar_grp.BackColor_(ColorAdp_.White);
toolbar_grp.Layout_data_(new Swt_layout_data__grid().Grab_excess_w_(true).Align_w_fill_(true));
toolbar_grp.Layout_mgr_(new Swt_layout_mgr__grid().Cols_(6).Margin_w_(0).Margin_h_(0).Spacing_h_(0));
go_bwd_btn = Xog_win_itm_.new_btn(app, kit, toolbar_grp, img_dir, "go_bwd_btn", "go_bwd.png" );
go_fwd_btn = Xog_win_itm_.new_btn(app, kit, toolbar_grp, img_dir, "go_fwd_btn", "go_fwd.png" );
url_box = Xog_win_itm_.new_cbo(app, kit, toolbar_grp, ui_font, "url_box" , true);
url_exec_btn = Xog_win_itm_.new_btn(app, kit, toolbar_grp, img_dir, "url_exec_btn", "url_exec.png" );
search_box = Xog_win_itm_.new_txt(app, kit, toolbar_grp, ui_font, "search_box" , true);
search_exec_btn = Xog_win_itm_.new_btn(app, kit, toolbar_grp, img_dir, "search_exec_btn", "search_exec.png" );
url_box.Layout_data_(new Swt_layout_data__grid().Grab_excess_w_(true).Align_w_fill_(true).Min_w_(100));
search_box.Layout_data_(new Swt_layout_data__grid().Hint_w_(110));
tab_mgr.Init_by_kit(kit);
tab_mgr.Tab_mgr().Layout_data_(new Swt_layout_data__grid().Grab_excess_h_(true).Align_h_fill_(true).Grab_excess_w_(true).Align_w_fill_(true));
Gfui_grp statusbar_grp = kit.New_grp("statusbar_grp", win_box);
statusbar_grp.BackColor_(ColorAdp_.White);
statusbar_grp.Layout_data_(new Swt_layout_data__grid().Grab_excess_w_(true).Align_w_fill_(true));
statusbar_grp.Layout_mgr_(new Swt_layout_mgr__grid().Cols_(6).Margin_w_(0).Margin_h_(0).Spacing_h_(0));
find_close_btn = Xog_win_itm_.new_btn(app, kit, statusbar_grp, img_dir, "find_close_btn", "find_close.png" );
find_box = Xog_win_itm_.new_txt(app, kit, statusbar_grp, ui_font, "find_box" , true);
find_fwd_btn = Xog_win_itm_.new_btn(app, kit, statusbar_grp, img_dir, "find_fwd_btn", "find_fwd.png" );
find_bwd_btn = Xog_win_itm_.new_btn(app, kit, statusbar_grp, img_dir, "find_bwd_btn", "find_bwd.png" );
prog_box = Xog_win_itm_.new_txt(app, kit, statusbar_grp, ui_font, "prog_box" , false);
info_box = Xog_win_itm_.new_txt(app, kit, statusbar_grp, ui_font, "note_box" , false);
find_box.Layout_data_(new Swt_layout_data__grid().Hint_w_(110));
prog_box.Layout_data_(new Swt_layout_data__grid().Grab_excess_w_(true).Align_w_fill_(true).Min_w_(100));
this.Lang_changed(app.Usere().Lang());
Gfo_evt_mgr_.Sub_same_many(this, this, Gfui_html.Evt_location_changed, Gfui_html.Evt_location_changing, Gfui_html.Evt_link_hover);
Gfo_evt_mgr_.Sub_same(win_box, Gfui_html.Evt_win_resized, this);
Gfo_evt_mgr_.Sub(app.Gui_mgr().Win_cfg().Font(), Xol_font_info.Font_changed, this, Invk_window_font_changed);
url_box__selection_changed = new Xog_url_box__selection_changed(app, url_box);
Gfo_evt_mgr_.Sub_same(url_box, GfuiComboBox.Evt__selected_changed, url_box__selection_changed);
@ -324,7 +336,6 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
&& app.Mode().Tid_is_gui()) // only run for gui; do not run for tcp/http server; DATE:2014-05-03
app.Usr_dlg().Gui_wkr_(new Gfo_usr_dlg__gui__swt(app, kit, prog_box, info_box, info_box));
cfg.Init_by_app(app);
resizer.Init_by_app(app, this);
}
public static String Remove_redirect_if_exists(String text) {
// remove redirect target; EX: "A -> B" -> "A"

@ -28,21 +28,20 @@ public class Xog_win_itm_ {
win.Tab_mgr().Tab_mgr().BackColor_(ColorAdp_.White);
Xog_startup_win_.Startup(app, win_box);
win.Resizer().Exec_win_resize(app, win_box.Width(), win_box.Height());
win_box.Icon_(IconAdp.file_or_blank(app.Fsys_mgr().Bin_xowa_dir().GenSubFil_nest("file", "app.window", "app_icon.png")));
}
public static GfuiBtn new_btn(Xoae_app app, Gfui_kit kit, GfuiWin win, Io_url img_dir, String id, String file) {
public static GfuiBtn new_btn(Xoae_app app, Gfui_kit kit, GfuiElem win, Io_url img_dir, String id, String file) {
GfuiBtn rv = kit.New_btn(id, win);
rv.Btn_img_(kit.New_img_load(img_dir.GenSubFil(file)));
return rv;
}
public static GfuiComboBox new_cbo(Xoae_app app, Gfui_kit kit, GfuiWin win, FontAdp ui_font, String id, boolean border_on) {
public static GfuiComboBox new_cbo(Xoae_app app, Gfui_kit kit, GfuiElem win, FontAdp ui_font, String id, boolean border_on) {
GfuiComboBox rv = kit.New_combo(id, win, Keyval_.new_(GfuiTextBox.CFG_border_on_, border_on));
rv.TextMgr().Font_(ui_font);
return rv;
}
public static GfuiTextBox new_txt(Xoae_app app, Gfui_kit kit, GfuiWin win, FontAdp ui_font, String id, boolean border_on) {
public static GfuiTextBox new_txt(Xoae_app app, Gfui_kit kit, GfuiElem win, FontAdp ui_font, String id, boolean border_on) {
GfuiTextBox rv = kit.New_text_box(id, win, Keyval_.new_(GfuiTextBox.CFG_border_on_, border_on));
rv.TextMgr().Font_(ui_font);
return rv;

@ -76,7 +76,6 @@ public class Xows_page_allpages implements gplx.core.brys.Bfr_arg, Gfo_invk, Xow
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
wiki.Parser_mgr().Ctx().Page().Html_data().Display_ttl_(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_sp_allpages_hdr));
url.Page_bry_(Bry_.Add(Bry_.new_a7("Special:"), ttl.Page_txt_wo_qargs())); // HACK: need to re-set Page b/c href_wtr does not eliminate qargs; DATE:2013-02-08
if (wiki.Domain_tid() == Xow_domain_tid_.Tid__home) {wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "home.invalid", "AllPages not implemented for home wiki"); return;}
if (rslt_list_ttls == null) this.Itms_per_page_(itms_per_page);
boolean found = Build_data(url, ttl); if (!found) return;
Build_html(page);

Loading…
Cancel
Save