1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-07-12 21:10:02 -04:00
commit 794b5a232f
3099 changed files with 238212 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiBtn extends GfuiElemBase {
@Override public boolean Click_able() {return true;}
@Override public void Click() {GfuiBtn.DoThis(this, clickMsg, clickInvkCmd);}
@gplx.Internal protected GfuiBtn Click_msg_(GfoMsg v) {clickMsg = v; return this;} GfoMsg clickMsg;
@gplx.Internal protected GfuiBtn Click_invk(GfoInvkAbleCmd v) {clickInvkCmd = v; return this;} GfoInvkAbleCmd clickInvkCmd;
@Override public boolean PaintCbk(PaintArgs args) {
super.PaintCbk(args);
if (this.Focus_has()) focusBorder.DrawData(args.Graphics());
this.TextMgr().DrawData(args.Graphics());
return true;
} GfuiBorderMgr focusBorder;
@Override public boolean SizeChangedCbk() {super.SizeChangedCbk(); GfuiBtn_.FocusBorderRect_set(focusBorder, this); this.Redraw(); return true;}
@Override public boolean FocusGotCbk() {super.FocusGotCbk(); this.Redraw(); return true;} // Redraw for focusBorder
@Override public boolean FocusLostCbk() {super.FocusLostCbk(); this.Redraw(); return true;} // Redraw for focusBorder
public ImageAdp Btn_img() {
Object o = GfoInvkAble_.InvkCmd(UnderElem(), Invk_btn_img);
return o == UnderElem() ? null : (ImageAdp)o; // NOTE: lgc guard
} public GfuiBtn Btn_img_(ImageAdp v) {GfoInvkAble_.InvkCmd_val(UnderElem(), Invk_btn_img_, v); return this;}
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.control_();}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
focusBorder = GfuiBorderMgr.new_().All_(PenAdp_.new_(ColorAdp_.Gray, 1));
super.ctor_GfuiBox_base(ctorArgs);
this.TextMgr().AlignH_(GfuiAlign_.Mid);
this.Border().All_(PenAdp_.black_()); this.Border().Bounds_sync(RectAdp_.size_(this.Size().Op_subtract(1)));
GfuiBtn_.FocusBorderRect_set(focusBorder, this);
Inject_(GfuiBtnClickBnd._);
Inject_(GfuiFocusXferBnd._);
this.CustomDraw_set(true);
}
@Override public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, KeyValHash ctorArgs) {
this.kit = kit;
super.ctor_kit_GfuiElemBase(kit, key, underElem, ctorArgs);
focusBorder = GfuiBorderMgr.new_().All_(PenAdp_.new_(ColorAdp_.Gray, 1));
Inject_(GfuiBtnClickBnd._);
Inject_(GfuiFocusXferBnd._);
} Gfui_kit kit;
@gplx.Internal protected static void DoThis(GfuiElem click, GfoMsg clickMsg, GfoInvkAbleCmd clickInvkCmd) {
try {
if (clickInvkCmd != null) {
GfsCtx ctx = GfsCtx.new_().MsgSrc_(click);
clickInvkCmd.InvkAble().Invk(ctx, 0, clickInvkCmd.Cmd(), GfoMsg_.Null);
}
else if (clickMsg != null && clickMsg != GfoMsg_.Null) {
GfsCtx ctx = GfsCtx.new_().MsgSrc_(click);
if (String_.Eq(clickMsg.Key(), "."))
GfsCore._.ExecOne_to(ctx, click, clickMsg.Subs_getAt(0));
else
GfsCore._.ExecOne(ctx, clickMsg);
}
} catch (Exception e) {GfuiEnv_.ShowMsg(Err_.Message_gplx(e));}
}
public static final String Invk_btn_img = "btn_img", Invk_btn_img_ = "btn_img_";
public static final String CFG_border_on_ = "border_on_";
}

View File

@@ -0,0 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
class GfuiBtnClickBnd implements InjectAble, GfoInvkAble {
public void Inject(Object owner) {
GfuiElem elem = GfuiElem_.cast_(owner);
IptBnd_.cmd_(IptCfg_.Null, elem, GfuiElemKeys.ActionExec_cmd, IptKey_.Enter, IptKey_.Space);
IptBnd_.cmd_(IptCfg_.Null, elem, GfuiElemKeys.Focus_cmd, IptMouseBtn_.Left);
IptBnd_.ipt_to_(IptCfg_.Null, elem, this, ExecMouseUp_cmd, IptEventType_.MouseUp, IptMouseBtn_.Left);
}
void ExecMouseUp(IptEventData iptData) {
GfuiElem elem = GfuiElem_.cast_(iptData.Sender());
int x = iptData.MousePos().X(), y = iptData.MousePos().Y();
SizeAdp buttonSize = elem.Size();
if ( x >= 0 && x <= buttonSize.Width()
&& y >= 0 && y <= buttonSize.Height())
elem.Click();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, ExecMouseUp_cmd)) ExecMouseUp(IptEventData.ctx_(ctx, m));
else return GfoInvkAble_.Rv_unhandled;
return this;
} static final String ExecMouseUp_cmd = "ExecMouseUp";
public static final GfuiBtnClickBnd _ = new GfuiBtnClickBnd(); GfuiBtnClickBnd() {}
}

View File

@@ -0,0 +1,47 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiBtn_ {
public static GfuiBtn as_(Object obj) {return obj instanceof GfuiBtn ? (GfuiBtn)obj : null;}
public static GfuiBtn cast_(Object obj) {try {return (GfuiBtn)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfuiBtn.class, obj);}}
public static GfuiBtn msg_(String key, GfuiElem owner, GfoMsg msg) {
GfuiBtn rv = new_(key); rv.Owner_(owner);
rv.Click_msg_(msg);
return rv;
}
public static GfuiBtn invk_(String key, GfuiElem owner, GfoInvkAble invk, String m) {
GfuiBtn rv = new_(key); rv.Owner_(owner);
rv.Click_invk(GfoInvkAbleCmd.new_(invk, m));
return rv;
}
public static GfuiBtn kit_(Gfui_kit kit, String key, GxwElem elm, KeyValHash ctorArgs) {
GfuiBtn rv = new GfuiBtn();
rv.ctor_kit_GfuiElemBase(kit, key, elm, ctorArgs);
return rv;
}
@gplx.Internal protected static GfuiBtn new_(String key) {
GfuiBtn rv = new GfuiBtn();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_true_());
rv.Key_of_GfuiElem_(key);
return rv;
}
@gplx.Internal protected static void FocusBorderRect_set(GfuiBorderMgr borderMgr, GfuiElem elem) {
borderMgr.Bounds_sync(RectAdp_.new_(3, 3, elem.Width() - 6, elem.Height() - 6));
}
}

View File

@@ -0,0 +1,61 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiChkBox extends GfuiElemBase {
public boolean Val() {return val;} private boolean val;
public void Val_set(boolean val) {
this.val = val;
GfoEvMgr_.PubVal(this, "Check_end", val);
GfuiBtn.DoThis(this, clickMsg, clickInvkCmd);
}
public void Val_sync(boolean val) {
this.val = val;//(boolean)v; // NOTE: do not resend message
this.Redraw();
}
@gplx.Internal protected void Click_msg_(GfoMsg v) {clickMsg = v;} GfoMsg clickMsg;
@gplx.Internal protected GfuiChkBox Click_invk(GfoInvkAbleCmd v) {clickInvkCmd = v; return this;} GfoInvkAbleCmd clickInvkCmd;
public GfuiBorderMgr FocusBorder() {return focusBorder;} GfuiBorderMgr focusBorder = GfuiBorderMgr.new_();
@Override public boolean Click_able() {return true;}
@Override public void Click() {
Val_set(!val);
this.Redraw();
}
public GfuiAlign AlignH() {return alignH;} public void AlignH_set(GfuiAlign v) {alignH = v;} GfuiAlign alignH = GfuiAlign_.Mid;
public GfuiAlign AlignV() {return alignV;} public void AlignV_set(GfuiAlign v) {alignV = v;} GfuiAlign alignV = GfuiAlign_.Mid;
public PointAdp ChkAlignCustom() {return chkAlignCustom;} public void ChkAlignCustom_set(PointAdp val) {chkAlignCustom = val;} PointAdp chkAlignCustom = PointAdp_.Zero;
@gplx.Internal protected PenAdp ChkPen() {return chkPen;} PenAdp chkPen = PenAdp_.new_(ColorAdp_.Black);
@Override public boolean PaintCbk(PaintArgs args) {
super.PaintCbk(args);
GfuiChkBox_.DrawCheckBox(this, args.Graphics());
return true;
}
@Override public boolean SizeChangedCbk() {
boolean rv = super.SizeChangedCbk();
this.Redraw();
return rv;
}
@Override public boolean FocusGotCbk() {super.FocusGotCbk(); this.Redraw(); return true;} // Redraw for focusBorder
@Override public boolean FocusLostCbk() {super.FocusLostCbk(); this.Redraw(); return true;} // Redraw for focusBorder
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.lbl_();}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
focusBorder.All_(PenAdp_.new_(ColorAdp_.Gray, 1));
Inject_(GfuiFocusXferBnd._).Inject_(GfuiBtnClickBnd._);
this.CustomDraw_set(true);
}
}

View File

@@ -0,0 +1,73 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiChkBox_ {
public static GfuiChkBox as_(Object obj) {return obj instanceof GfuiChkBox ? (GfuiChkBox)obj : null;}
public static GfuiChkBox cast_(Object obj) {try {return (GfuiChkBox)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfuiChkBox.class, obj);}}
@gplx.Internal protected static GfuiChkBox new_() {
GfuiChkBox rv = new GfuiChkBox();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_true_());
return rv;
}
public static GfuiChkBox msg_(String key, GfuiElem owner, String text, GfoMsg msg) {
GfuiChkBox rv = new_(); rv.Owner_(owner, key).Text_any_(text);
rv.Click_msg_(msg);
return rv;
}
public static GfuiChkBox invk_(String key, GfuiElem owner, String text, GfoInvkAble invk, String m) {
GfuiChkBox rv = new_(); rv.Owner_(owner, key).Text_any_(text);
rv.Click_invk(GfoInvkAbleCmd.new_(invk, m));
return rv;
}
public static GfuiChkBox noop_(String key, GfuiElem owner, String text) {
GfuiChkBox rv = new_(); rv.Owner_(owner, key); rv.Text_any_(text);
return rv;
}
public static RectAdp CboxRect(GfuiChkBox box) {
SizeAdp size = SizeAdp_.new_(12, 12);
PointAdp pos = GfuiAlign_.CalcInsideOf(box.AlignH(), box.AlignV(), size, box.Size(), box.ChkAlignCustom());
return RectAdp_.vector_(pos.Op_add(0, 0), size);
}
public static void DrawCheckBox(GfuiChkBox box, GfxAdp gfx) {
RectAdp cboxRect = CboxRect(box);
box.TextMgr().AlignH_(box.AlignH()).AlignV_(box.AlignV());
RectAdpF textRect = box.TextMgr().TextRect_calc(gfx);
int w = cboxRect.Width() + 4 + (int)textRect.Width();
int h = (int)textRect.Height(); // assume textRect.Height is >= cboxRect.Height
SizeAdp size = SizeAdp_.new_(w, h);
PointAdp pos = GfuiAlign_.CalcInsideOf(box.AlignH(), box.AlignV(), size, box.Size(), PointAdp_.Zero);
cboxRect = RectAdp_.vector_(pos.Op_add(0, 1), cboxRect.Size());
textRect = RectAdpF.new_(pos.X() + cboxRect.Width() + 4, textRect.Y(), textRect.Width(), textRect.Height());
box.TextMgr().TextRect_set(textRect);
box.TextMgr().DrawData(gfx);
gfx.DrawRect(box.ChkPen(), cboxRect.X(), cboxRect.Y(), cboxRect.Width(), cboxRect.Height());
if (box.Val()) {
gfx.DrawLine(box.ChkPen(), cboxRect.CornerTL().Op_add(3), cboxRect.CornerBR().Op_add(-3));
gfx.DrawLine(box.ChkPen(), cboxRect.CornerBL().Op_add(3, -3), cboxRect.CornerTR().Op_add(-3, 3));
}
if (box.Focus_has()) {
// -1 so border does not start right on top of text; RoundUp to give a little more space to edges
// +2 so that focusRect does not overlap mnemonic (in C#)
box.FocusBorder().Bounds_sync(RectAdp_.new_((int)textRect.X() - 1, (int)cboxRect.Y(), Float_.RoundUp(textRect.Width()), Float_.RoundUp(cboxRect.Height())));
box.FocusBorder().DrawData(gfx);
}
}
}

View File

@@ -0,0 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiComboBox extends GfuiElemBase {
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.comboBox_();} GxwComboBox comboBox;
public Object SelectedItm() {return comboBox.SelectedItm();} public void SelectedItm_set(Object v) {comboBox.SelectedItm_set(v);}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
this.comboBox = (GxwComboBox)this.UnderElem();
}
public void DataSource_set(Object... ary) {
comboBox.DataSource_set(ary);
}
public static GfuiComboBox new_() {
GfuiComboBox rv = new GfuiComboBox();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_true_());
return rv;
}
}

View File

@@ -0,0 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiLbl extends GfuiElemBase { // standard label does not support tooltips
@Override public void Click() {
int focusOrder = this.OwnerElem().SubElems().IndexOfA(this);
GfuiElem focusNext = this.OwnerElem().SubElems().Get_at(focusOrder + 1); // FIXME: incorporate into new FocusOrder
focusNext.Focus();
}
@Override public boolean PaintCbk(PaintArgs args) {
super.PaintCbk(args);
this.TextMgr().DrawData(args.Graphics());
return true;
}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
this.CustomDraw_set(true);
}
@Override public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, KeyValHash ctorArgs) {
super.ctor_kit_GfuiElemBase(kit, key, underElem, ctorArgs);
this.CustomDraw_set(true);
}
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.lbl_();}
}

View File

@@ -0,0 +1,51 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiLbl_ {
public static GfuiLbl sub_(String key, GfuiElem owner) {
GfuiLbl rv = new_();
rv.Owner_(owner, key); // must be after ctor, else "Error creating window handle"
rv.TextMgr().AlignH_(GfuiAlign_.Mid);
return rv;
}
public static GfuiLbl kit_(Gfui_kit kit, String key, GxwElem elm, KeyValHash ctorArgs) {
GfuiLbl rv = new GfuiLbl();
rv.ctor_kit_GfuiElemBase(kit, key, elm, ctorArgs);
return rv;
}
public static GfuiLbl prefix_(String key, GfuiElem owner, String text) {
GfuiLbl rv = sub_(key, owner);
rv.Text_(text);
rv.TextMgr().AlignH_(GfuiAlign_.Left);
return rv;
}
public static GfuiLbl menu_(String key, GfuiElem owner, String text, String tipText) {
GfuiLbl rv = sub_(key, owner);
rv.Text_(text);
rv.TextMgr().AlignH_(GfuiAlign_.Mid);
rv.TipText_(tipText);
rv.Border().All_(PenAdp_.black_());
return rv;
}
public static final String Text_Null = null;
@gplx.Internal protected static GfuiLbl new_() {
GfuiLbl rv = new GfuiLbl();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_false_());
return rv;
}
}

View File

@@ -0,0 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import gplx.lists.*; /*EnumerAble*/
public class GfuiListBox extends GfuiElemBase {
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.listBox_();}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
this.listBox = (GxwListBox)UnderElem();
}
public void Items_Add(Object o) {listBox.Items_Add(o);}
public void Items_Clear() {listBox.Items_Clear();}
public Object Items_SelObj() {return listBox.Items_SelObj();}
public void BindData(EnumerAble enumerable) {
for (Object item : enumerable)
this.listBox.Items_Add(item.toString());
}
public int Items_Count() {return listBox.Items_Count();}
public int Items_SelIdx() {return listBox.Items_SelIdx();} public void Items_SelIdx_set(int v) {listBox.Items_SelIdx_set(v);}
GxwListBox listBox;
public static GfuiListBox new_() {
GfuiListBox rv = new GfuiListBox();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_true_());
return rv;
}
}

View File

@@ -0,0 +1,67 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiTextBox extends GfuiElemBase {
public static final String SelectionStartChanged_evt = "SelectionStartChanged";
public boolean Border_on() {return textBox.Border_on();} public void Border_on_(boolean v) {BorderOn_set(v);}
public int SelBgn() {return textBox.SelBgn();} public void SelBgn_set(int v) {textBox.SelBgn_set(v); GfoEvMgr_.Pub(this, SelectionStartChanged_evt);}
public int SelLen() {return textBox.SelLen();} public void SelLen_set(int v) {textBox.SelLen_set(v);}
public String SelText() {
return String_.MidByLen(this.TextMgr().Val(), this.SelBgn(), this.SelLen());
}
public void Focus_select_all() {
this.Focus();
this.SelBgn_set(0);
int len = String_.Len(this.Text());
this.SelLen_set(len);
}
public boolean OverrideTabKey() {return textBox.OverrideTabKey();} public void OverrideTabKey_(boolean val) {textBox.OverrideTabKey_(val);}
public void Margins_set(int left, int top, int right, int bot) {textBox.Margins_set(left, top, right, bot);}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_Margins_)) {
int u = m.ReadInt("u");
int l = m.ReadInt("l");
int d = m.ReadInt("d");
int r = m.ReadInt("r");
if (ctx.Deny()) return this;
Margins_set(l, u, r, d);
return this;
}
else return super.Invk (ctx, ikey, k, m);
} static final String Invk_Margins_ = "Margins_";
void BorderOn_set(boolean val) {
textBox.Border_on_(val);
if (val == false)
this.Height_(13); // WORKAROUND (WinForms): if border is off, height automatically becomes 13 and immutable for singleLine fields; affects statusBox in opal.imgs which will show with small gap over bottom of screen
}
@gplx.Internal @Override protected void Click_key_set_(String v) {}// TextBox's shouldn't have clickKeys; among other things, .Text is used to set ClickKey, which for textBox may be very large
@gplx.Internal protected void SetTextBox(GxwTextFld textBox) {this.textBox = textBox;}
@gplx.Internal protected void CreateControlIfNeeded() {textBox.CreateControlIfNeeded();}
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.text_fld_();}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
textBox = (GxwTextFld)this.UnderElem();
} GxwTextFld textBox;
@Override public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, KeyValHash ctorArgs) {
super.ctor_kit_GfuiElemBase(kit, key, underElem, ctorArgs);
textBox = (GxwTextFld)underElem;
}
public static final String CFG_border_on_ = "border_on_";
}

View File

@@ -0,0 +1,46 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiTextBox_ {
public static GfuiTextBox as_(Object obj) {return obj instanceof GfuiTextBox ? (GfuiTextBox)obj : null;}
public static GfuiTextBox cast_(Object obj) {try {return (GfuiTextBox)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfuiTextBox.class, obj);}}
public static final String NewLine = "\n";
public static final String Ctor_Memo = "TextBox_Memo";
public static GfuiTextBox new_() {
GfuiTextBox rv = new GfuiTextBox();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_true_());
return rv;
}
public static GfuiTextBox fld_(String key, GfuiElem owner) {
GfuiTextBox rv = new_();
rv.Owner_(owner, key);
return rv;
}
public static GfuiTextMemo multi_(String key, GfuiElem owner) {
GfuiTextMemo rv = new GfuiTextMemo();
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_true_());
rv.Key_of_GfuiElem_(key).Owner_(owner);
return rv;
}
public static GfuiTextBox kit_(Gfui_kit kit, String key, GxwTextFld wk_textBox, KeyValHash ctorArgs) {
GfuiTextBox rv = new GfuiTextBox();
rv.ctor_kit_GfuiElemBase(kit, key, wk_textBox, ctorArgs);
return rv;
}
}

View File

@@ -0,0 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class GfuiTextMemo extends GfuiTextBox { public int LinesPerScreen() {return textBox.LinesPerScreen();}
public int LinesTotal() {return textBox.LinesTotal();}
public int ScreenCount() {return Int_.DivAndRoundUp(this.LinesTotal(), this.LinesPerScreen());}
public int CharIndexOfFirst() {return textBox.CharIndexOfFirst();}
public int CharIndexOf(int lineIndex) {return textBox.CharIndexOf(lineIndex);}
public int CharIndexAtLine(int lineIndex) {return textBox.CharIndexOf(lineIndex);}
public int LineIndexOfFirst() {return textBox.LineIndexOfFirst();}
public int LineIndexOf(int charIndex) {return textBox.LineIndexOf(charIndex);}
public PointAdp PosOf(int charIndex) {return textBox.PosOf(charIndex);}
public void ScrollLineUp() {textBox.ScrollLineUp();}
public void ScrollLineDown() {textBox.ScrollLineDown();}
public void ScrollScreenUp() {textBox.ScrollScreenUp();}
public void ScrollScreenDown() {textBox.ScrollScreenDown();}
public void SelectionStart_toFirstChar() {textBox.SelectionStart_toFirstChar(); GfoEvMgr_.Pub(this, SelectionStartChanged_evt);}
public void ScrollTillSelectionStartIsFirstLine() {textBox.ScrollTillSelectionStartIsFirstLine();}
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.text_memo_();}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
textBox = (GxwTextMemo)UnderElem();
this.SetTextBox(textBox);
} GxwTextMemo textBox;
}

View File

@@ -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; import gplx.*;
public class Gfui_html extends GfuiElemBase {
public void Under_html_(Gxw_html v) {under = v;} private Gxw_html under;
public void Html_doc_html_load_by_mem(String html) {under.Html_doc_html_load_by_mem(html);}
public void Html_doc_html_load_by_url(String path, String html) {under.Html_doc_html_load_by_url(path, html);}
public byte Html_doc_html_load_tid() {return under.Html_doc_html_load_tid();}
public void Html_doc_html_load_tid_(byte v) {under.Html_doc_html_load_tid_(v);}
public void Html_js_enabled_(boolean v) {under.Html_js_enabled_(v);}
@gplx.Virtual public String Html_js_eval_proc_as_str(String name, Object... args) {return under.Html_js_eval_proc_as_str(name, args);}
@gplx.Virtual public boolean Html_js_eval_proc_as_bool(String name, Object... args) {return under.Html_js_eval_proc_as_bool(name, args);}
public String Html_js_eval_script(String script) {return under.Html_js_eval_script(script);}
public void Html_js_cbks_add(String js_func_name, GfoInvkAble invk) {under.Html_js_cbks_add(js_func_name, invk);}
public void Html_invk_src_(GfoEvObj v) {under.Html_invk_src_(v);}
public void Html_dispose() {under.Html_dispose();}
@Override public GfuiElem Text_(String v) {
this.Html_doc_html_load_by_mem(v);
return this;
}
public static Gfui_html kit_(Gfui_kit kit, String key, Gxw_html under, KeyValHash ctorArgs) {
Gfui_html rv = new Gfui_html();
rv.ctor_kit_GfuiElemBase(kit, key, (GxwElem)under, ctorArgs);
rv.under = under;
return rv;
}
public static Gfui_html mem_(String key, Gxw_html under) {
Gfui_html rv = new Gfui_html();
rv.Key_of_GfuiElem_(key);
rv.under = under;
return rv;
}
public static Object Js_args_exec(GfoInvkAble invk, Object[] args) {
GfoMsg m = Js_args_to_msg(args);
return GfoInvkAble_.InvkCmd_msg(invk, m.Key(), m);
}
public static GfoMsg Js_args_to_msg(Object[] args) {
String proc = (String)args[0];
GfoMsg rv = GfoMsg_.new_parse_(proc);
for (int i = 1; i < args.length; i++)
rv.Add(Int_.Xto_str(i), args[i]); // NOTE: args[i] can be either String or String[]
return rv;
}
public static final String Atr_href = "href", Atr_title = "title", Atr_value = "value", Atr_innerHTML = "innerHTML", Atr_src = "src";
public static final String Elem_id_body = "body";
public static final String Evt_location_changed = "location_changed", Evt_location_changing = "location_changing", Evt_link_hover = "link_hover", Evt_win_resized = "win_resized";
}

View File

@@ -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; import gplx.*;
public class Gfui_tab_itm extends GfuiElemBase {
private Gxw_tab_itm under;
public String Tab_name() {return under.Tab_name();} public void Tab_name_(String v) {under.Tab_name_(v);}
public String Tab_tip_text() {return under.Tab_tip_text();} public void Tab_tip_text_(String v) {under.Tab_tip_text_(v);}
public void Subs_add(GfuiElem elem) {under.Subs_add(elem);}
public static Gfui_tab_itm kit_(Gfui_kit kit, String key, Gxw_tab_itm under, KeyValHash ctor_args) {
Gfui_tab_itm rv = new Gfui_tab_itm();
// rv.ctor_kit_GfuiElemBase(kit, key, (GxwElem)under, ctor_args); // causes swt_tab_itm to break, since it's not a real Swt Control
rv.under = under;
return rv;
}
}

View File

@@ -0,0 +1,38 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class Gfui_tab_itm_data {
public Gfui_tab_itm_data(String key, int idx) {this.key = key; this.idx = idx;}
public String Key() {return key;} private String key;
public int Idx() {return idx;} public Gfui_tab_itm_data Idx_(int v) {idx = v; return this;} private int idx;
public String Name() {return name;} public void Name_(String v) {name = v;} private String name;
public String Tip_text() {return tip_text;} public Gfui_tab_itm_data Tip_text_(String v) {tip_text = v; return this;} private String tip_text;
public boolean Pinned() {return pinned;} public Gfui_tab_itm_data Pinned_(boolean v) {pinned = v; return this;} private boolean pinned;
public void Switch(Gfui_tab_itm_data comp) { // NOTE: key is invariant; idx should not be switched, as tab_idx remains the same; only contents have been switched
String tmp_str = name;
this.name = comp.name; comp.name = tmp_str;
tmp_str = tip_text;
this.tip_text = comp.tip_text; comp.tip_text = tmp_str;
}
public static int Get_idx_after_closing(int cur, int len) {
if (len < 1) return Idx_null; // 1 or 0 tabs; return -1
else if (cur == len - 1) return len - 2; // last tab; select_bwd
else return cur + 1; // else, select_fwd
}
public static final int Idx_null = -1;
}

View File

@@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
public class Gfui_tab_itm_data_tst {
@Before public void init() {} private Gfui_tab_itm_data_fxt fxt = new Gfui_tab_itm_data_fxt();
@Test public void Get_idx_after_closing() {
fxt.Test_Get_idx_after_closing(0, 1, -1);
fxt.Test_Get_idx_after_closing(4, 5, 3);
fxt.Test_Get_idx_after_closing(3, 5, 4);
}
}
class Gfui_tab_itm_data_fxt {
public void Test_Get_idx_after_closing(int cur, int len, int expd) {
Tfds.Eq(expd, Gfui_tab_itm_data.Get_idx_after_closing(cur, len));
}
}

View File

@@ -0,0 +1,46 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.gfui; import gplx.*;
public class Gfui_tab_mgr extends GfuiElemBase {
public void Under_tab_mgr_(Gxw_tab_mgr v) {under = v;} private Gxw_tab_mgr under;
public ColorAdp Btns_selected_color() {return under.Btns_selected_color();} public void Btns_selected_color_(ColorAdp v) {under.Btns_selected_color_(v);}
public ColorAdp Btns_unselected_color() {return under.Btns_unselected_color();} public void Btns_unselected_color_(ColorAdp v) {under.Btns_unselected_color_(v);}
public Gfui_tab_itm Tabs_add(Gfui_tab_itm_data tab_data) {
Gxw_tab_itm tab_itm = under.Tabs_add(tab_data);
return Gfui_tab_itm.kit_(this.Kit(), tab_data.Key(), tab_itm, KeyValHash.Empty);
}
public int Btns_height() {return under.Btns_height();} public void Btns_height_(int v) {under.Btns_height_(v);}
public boolean Btns_place_on_top() {return under.Btns_place_on_top();} public void Btns_place_on_top_(boolean v) {under.Btns_place_on_top_(v);}
public boolean Btns_curved() {return under.Btns_curved();} public void Btns_curved_(boolean v) {under.Btns_curved_(v);}
public boolean Btns_close_visible_() {return under.Btns_close_visible();} public void Btns_close_visible_(boolean v) {under.Btns_close_visible_(v);}
public boolean Btns_unselected_close_visible() {return under.Btns_unselected_close_visible();} public void Btns_unselected_close_visible_(boolean v) {under.Btns_unselected_close_visible_(v);}
public void Tabs_select_by_idx(int idx) {under.Tabs_select_by_idx(idx);}
public void Tabs_close_by_idx(int idx) {under.Tabs_close_by_idx(idx);}
public void Tabs_switch(int src, int trg) {under.Tabs_switch(src, trg);}
public static Gfui_tab_mgr kit_(Gfui_kit kit, String key, Gxw_tab_mgr under, KeyValHash ctor_args) {
Gfui_tab_mgr rv = new Gfui_tab_mgr();
rv.ctor_kit_GfuiElemBase(kit, key, (GxwElem)under, ctor_args);
rv.under = under;
return rv;
}
public static final String
Evt_tab_selected = "tab_selected"
, Evt_tab_closed = "tab_closed"
, Evt_tab_switched = "tab_switched"
;
}