mirror of https://github.com/gnosygnu/xowa
parent
dd6b3cabed
commit
70cfdf0c44
Binary file not shown.
@ -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;
|
||||
}
|
||||
}
|
@ -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) {}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
Loading…
Reference in new issue