mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.2.1
This commit is contained in:
89
150_gfui/src_500_tab/gplx/gfui/TabBnd.java
Normal file
89
150_gfui/src_500_tab/gplx/gfui/TabBnd.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
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 TabBoxEvt_nameChange {
|
||||
public static String Key = "TabBoxEvt_nameChange";
|
||||
public static void Send(TabBoxMgr mgr, TabPnlItm itm) {
|
||||
GfoEvMgr_.PubVal(mgr, Key, itm);
|
||||
}
|
||||
public static void Rcvd(TabBox tabBox, GfsCtx ctx, GfoMsg m) {
|
||||
TabPnlItm itm = (TabPnlItm)m.CastObj("v");
|
||||
GfuiBtn btn = GfuiBtn_.as_(tabBox.BtnBox().SubElems().Get_by(itm.Key()));
|
||||
if (btn != null) // HACK: check needed b/c Gfds will raise UpdateCaption event before Creating tab
|
||||
btn.Text_(itm.Name()).TipText_(itm.Name());
|
||||
}
|
||||
}
|
||||
class TabBoxEvt_tabSelectByBtn {
|
||||
public static String Key = "TabBoxEvt_tabSelectByBtn";
|
||||
public static void Rcvd(Object sender, TabBox tabBox) {
|
||||
GfuiBtn btn = (GfuiBtn)sender;
|
||||
String key = btn.Key_of_GfuiElem();
|
||||
TabBoxMgr mgr = tabBox.Mgr();
|
||||
mgr.Select(mgr.Get_by(key));
|
||||
}
|
||||
}
|
||||
class TabBnd_selectTab implements InjectAble, GfoInvkAble {
|
||||
public void Inject(Object obj) {
|
||||
tabBox = TabBox_.cast_(obj);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectNext_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Tab), IptKey_.add_(IptKey_.Ctrl, IptKey_.PageDown));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, tabBox, this, SelectPrev_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Tab, IptKey_.Shift), IptKey_.add_(IptKey_.Ctrl, IptKey_.PageUp));
|
||||
}
|
||||
void Select(GfoMsg msg, int delta) {
|
||||
TabPnlItm curTab = tabBox.Mgr().CurTab();
|
||||
int newIdx = TabBox_.Cycle(delta > 0, curTab.Idx(), tabBox.Mgr().Count());
|
||||
tabBox.Tabs_Select(newIdx);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, SelectNext_cmd)) Select(m, 1);
|
||||
else if (ctx.Match(k, SelectPrev_cmd)) Select(m, -1);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} static final String SelectNext_cmd = "SelectNext", SelectPrev_cmd = "SelectPrev";
|
||||
TabBox tabBox;
|
||||
public static TabBnd_selectTab new_() {return new TabBnd_selectTab();} TabBnd_selectTab() {}
|
||||
}
|
||||
class TabBnd_reorderTab implements InjectAble, GfoInvkAble {
|
||||
public void Inject(Object owner) {
|
||||
GfuiBtn btn = GfuiBtn_.cast_(owner);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MovePrev_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Left));
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, btn, this, MoveNext_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Right));
|
||||
}
|
||||
@gplx.Internal protected void MoveTab(GfuiBtn curBtn, int delta) {
|
||||
TabPnlItm curItm = tabBox.Mgr().Get_by(curBtn.Key_of_GfuiElem());
|
||||
int curIdx = curItm.Idx();
|
||||
int newIdx = TabBox_.Cycle(delta > 0, curIdx, tabBox.Mgr().Count());
|
||||
|
||||
tabBox.Mgr().Move_to(curIdx, newIdx);
|
||||
tabBox.Mgr().Reorder(0); // reorder all; exchanging curIdx for newIdx does not work when going from last to first (17 -> 0, but 0 -> 1)
|
||||
tabBox.PnlBox().SubElems().Move_to(curIdx, newIdx);
|
||||
TabBtnAreaMgr.Move_to(tabBox, curIdx, newIdx);
|
||||
TabBoxEvt_orderChanged.Publish(tabBox, curIdx, newIdx);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, MoveNext_cmd)) MoveTab(GfuiBtn_.cast_(ctx.MsgSrc()), 1);
|
||||
else if (ctx.Match(k, MovePrev_cmd)) MoveTab(GfuiBtn_.cast_(ctx.MsgSrc()), -1);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String MoveNext_cmd = "MoveNext", MovePrev_cmd = "MovePrev";
|
||||
public static TabBnd_reorderTab new_(TabBox tabBox) {
|
||||
TabBnd_reorderTab rv = new TabBnd_reorderTab();
|
||||
rv.tabBox = tabBox;
|
||||
return rv;
|
||||
} TabBnd_reorderTab() {}
|
||||
TabBox tabBox;
|
||||
}
|
||||
154
150_gfui/src_500_tab/gplx/gfui/TabBox.java
Normal file
154
150_gfui/src_500_tab/gplx/gfui/TabBox.java
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
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 TabBox extends GfuiElemBase {
|
||||
public int Tabs_Count() {return mgr.Count();}
|
||||
public TabPnlItm Tabs_SelectedItm() {return mgr.CurTab();}
|
||||
public GfuiElem Tabs_FetchAt(int i) {return pnlBox.SubElems().Get_by(mgr.Get_at(i).Key());}
|
||||
public GfuiElem Tabs_SelectedPnl() {return pnlBox.SubElems().Get_by(mgr.CurTab().Key());}
|
||||
public void Tabs_Select(int idx) {mgr.Select(idx);}
|
||||
public GfuiElem Tabs_Add(String key, String name) {
|
||||
TabPnlItm newTab = mgr.Add(key, name);
|
||||
TabBtnAreaMgr.Add(this, newTab);
|
||||
GfuiElem pnl = TabPnlAreaMgr.Add(this, newTab);
|
||||
mgr.Select(newTab); // always select added tab
|
||||
return pnl;
|
||||
}
|
||||
public void Tabs_DelAt(int idx) {
|
||||
TabBtnAreaMgr.Del(this, mgr.Get_at(idx));
|
||||
TabPnlAreaMgr.Del(this, mgr.Get_at(idx));
|
||||
mgr.Del_at(idx);
|
||||
}
|
||||
@gplx.Internal protected TabBoxMgr Mgr() {return mgr;} TabBoxMgr mgr = TabBoxMgr.new_();
|
||||
@gplx.Internal protected GfuiElem BtnBox() {return btnBox;} GfuiElem btnBox;
|
||||
@gplx.Internal protected GfuiElem PnlBox() {return pnlBox;} GfuiElem pnlBox;
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, TabBoxEvt_tabSelectByBtn.Key)) TabBoxEvt_tabSelectByBtn.Rcvd(ctx.MsgSrc(), this);
|
||||
else if (ctx.Match(k, TabBoxEvt_tabSelect.Key)) TabBoxEvt_tabSelect.Select(this, ctx, m);
|
||||
else if (ctx.Match(k, TabBoxEvt_nameChange.Key)) TabBoxEvt_nameChange.Rcvd(this, ctx, m);
|
||||
else return super.Invk(GfsCtx._, 0, k, m);
|
||||
return this;
|
||||
}
|
||||
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
|
||||
super.ctor_GfuiBox_base(ctorArgs);
|
||||
btnBox = TabBtnAreaMgr.new_("btnBox", this);
|
||||
pnlBox = TabPnlAreaMgr.new_("pnlBox", this);
|
||||
this.Inject_(TabBnd_selectTab.new_());
|
||||
GfoEvMgr_.SubSame(mgr, TabBoxEvt_tabSelect.Key, this);
|
||||
GfoEvMgr_.SubSame(mgr, TabBoxEvt_nameChange.Key, this);
|
||||
|
||||
this.Lyt_activate();
|
||||
this.Lyt().Bands_add(GftBand.fillWidth_());
|
||||
this.Lyt().Bands_add(GftBand.fillAll_());
|
||||
}
|
||||
}
|
||||
class TabBtnAreaMgr {
|
||||
public static GfuiElemBase new_(String key, GfuiElem owner) {
|
||||
GfuiElemBase rv = new GfuiElemBase();
|
||||
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_false_());
|
||||
rv.Owner_(owner, key);
|
||||
return rv;
|
||||
}
|
||||
public static GfuiBtn Add(TabBox tabBox, TabPnlItm itm) {
|
||||
GfuiElem btnBox = tabBox.BtnBox();
|
||||
GfuiBtn btn = GfuiBtn_.new_(itm.Key());
|
||||
btn.TipText_(itm.Name()).Text_(itm.Name()).Width_(80);
|
||||
btn.TextMgr().Font_(btn.TextMgr().Font().Size_(8));
|
||||
btn.Click_invk(GfoInvkAbleCmd.new_(tabBox, TabBoxEvt_tabSelectByBtn.Key));
|
||||
btn.Inject_(TabBnd_reorderTab.new_(tabBox));
|
||||
if (btnBox.SubElems().Count() > 0) { // place button after last
|
||||
GfuiElem lastBtn = btnBox.SubElems().Get_at(btnBox.SubElems().Count() - 1);
|
||||
btn.X_(lastBtn.X() + lastBtn.Width());
|
||||
}
|
||||
btnBox.SubElems().Add(btn);
|
||||
return btn;
|
||||
}
|
||||
public static void Del(TabBox tabBox, TabPnlItm itm) {
|
||||
GfuiElem btnBox = tabBox.BtnBox();
|
||||
int idx = itm.Idx();
|
||||
GfuiBtn btn = (GfuiBtn)btnBox.SubElems().Get_at(idx);
|
||||
btnBox.SubElems().Del_at(idx);
|
||||
for (int i = idx; i < btnBox.SubElems().Count(); i++) {
|
||||
GfuiBtn cur = (GfuiBtn)btnBox.SubElems().Get_at(i);
|
||||
cur.X_(cur.X() - btn.Width());
|
||||
}
|
||||
}
|
||||
public static void Select(TabBox tabBox, TabPnlItm curTabItm, TabPnlItm newTabItm) {
|
||||
if (curTabItm != null) {
|
||||
GfuiBtn curBtn = (GfuiBtn)tabBox.BtnBox().SubElems().Get_at(curTabItm.Idx());
|
||||
Select(curBtn, false);
|
||||
}
|
||||
GfuiBtn newBtn = (GfuiBtn)tabBox.BtnBox().SubElems().Get_at(newTabItm.Idx());
|
||||
Select(newBtn, true);
|
||||
}
|
||||
public static void Move_to(TabBox tabBox, int curIdx, int newIdx) {
|
||||
GfuiElemList btns = tabBox.BtnBox().SubElems();
|
||||
btns.Move_to(curIdx, newIdx);
|
||||
int curX = 0;
|
||||
for (int i = 0; i < btns.Count(); i++) {
|
||||
GfuiBtn cur = (GfuiBtn)btns.Get_at(i);
|
||||
cur.X_(curX);
|
||||
curX += cur.Width();
|
||||
}
|
||||
}
|
||||
static void Select(GfuiBtn btn, boolean enabled) {
|
||||
btn.TextMgr().Color_(enabled ? ColorAdp_.Black : ColorAdp_.Gray);
|
||||
btn.TextMgr().Font().Style_(enabled ? FontStyleAdp_.Bold : FontStyleAdp_.Plain);
|
||||
if (enabled)
|
||||
btn.Border().All_(PenAdp_.black_());
|
||||
else
|
||||
btn.Border().None_();
|
||||
}
|
||||
}
|
||||
class TabPnlAreaMgr {
|
||||
public static GfuiElemBase new_(String key, GfuiElem owner) {
|
||||
GfuiElemBase rv = new GfuiElemBase();
|
||||
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_false_());
|
||||
rv.Owner_(owner, key);
|
||||
rv.Lyt_activate();
|
||||
return rv;
|
||||
}
|
||||
public static GfuiElemBase Add(TabBox tabBox, TabPnlItm itm) {
|
||||
GfuiElem pnlBox = tabBox.PnlBox();
|
||||
GfuiElemBase pnl = pnl_(tabBox, pnlBox, itm.Key());
|
||||
return pnl;
|
||||
}
|
||||
public static void Del(TabBox tabBox, TabPnlItm itm) {
|
||||
tabBox.PnlBox().SubElems().Del_at(itm.Idx());
|
||||
((GfuiElemBase)tabBox.PnlBox()).Lyt().SubLyts().Del_at(itm.Idx());
|
||||
}
|
||||
public static void Select(TabBox tabBox, TabPnlItm curTabItm, TabPnlItm newTabItm) {
|
||||
if (curTabItm != null) {
|
||||
GfuiElem curTab = tabBox.PnlBox().SubElems().Get_at(curTabItm.Idx());
|
||||
curTab.Visible_set(false);
|
||||
}
|
||||
GfuiElem newTab = tabBox.PnlBox().SubElems().Get_at(newTabItm.Idx());
|
||||
newTab.Visible_set(true);
|
||||
newTab.Zorder_front();
|
||||
newTab.Focus();
|
||||
}
|
||||
@gplx.Internal protected static GfuiElemBase pnl_(TabBox tabBox, GfuiElem pnlBox, String key) {
|
||||
GfuiElemBase rv = new GfuiElemBase();
|
||||
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_false_());
|
||||
rv.Owner_(pnlBox, key);
|
||||
rv.Lyt_activate();
|
||||
rv.Lyt().Bands_add(GftBand.fillAll_());
|
||||
((GfuiElemBase)pnlBox).Lyt().SubLyts().Add(GftGrid.new_().Bands_add(GftBand.fillAll_()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
33
150_gfui/src_500_tab/gplx/gfui/TabBoxEvt_orderChanged.java
Normal file
33
150_gfui/src_500_tab/gplx/gfui/TabBoxEvt_orderChanged.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class TabBoxEvt_orderChanged {
|
||||
public int CurIdx() {return curIdx;} public TabBoxEvt_orderChanged CurIdx_(int v) {curIdx = v; return this;} int curIdx;
|
||||
public int NewIdx() {return newIdx;} public TabBoxEvt_orderChanged NewIdx_(int v) {newIdx = v; return this;} int newIdx;
|
||||
|
||||
public static final String OrderChanged_evt = "OrderChanged_evt";
|
||||
public static void Publish(TabBox tabBox, int curIdx, int newIdx) {
|
||||
GfoEvMgr_.PubVals(tabBox, OrderChanged_evt, KeyVal_.new_("curIdx", curIdx), KeyVal_.new_("newIdx", newIdx));
|
||||
}
|
||||
public static TabBoxEvt_orderChanged Handle(GfsCtx ctx, GfoMsg m) {
|
||||
TabBoxEvt_orderChanged rv = new TabBoxEvt_orderChanged();
|
||||
rv.curIdx = m.ReadInt("curIdx");
|
||||
rv.newIdx = m.ReadInt("newIdx");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
37
150_gfui/src_500_tab/gplx/gfui/TabBoxEvt_tabSelect.java
Normal file
37
150_gfui/src_500_tab/gplx/gfui/TabBoxEvt_tabSelect.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class TabBoxEvt_tabSelect {
|
||||
public static String Key = "TabBoxEvt_tabSelect";
|
||||
public static final String SelectedChanged_evt = "SelectedChanged_evt";
|
||||
public static void Send(TabBoxMgr tabBoxMgr, TabPnlItm oldTab, TabPnlItm newTab) {
|
||||
GfoEvMgr_.PubVal(tabBoxMgr, Key, new TabPnlItm[] {oldTab, newTab});
|
||||
}
|
||||
@gplx.Internal protected static void Select(TabBox tabBox, GfsCtx ctx, GfoMsg m) {
|
||||
TabPnlItm[] ary = (TabPnlItm[])m.CastObj("v");
|
||||
Select(tabBox, ary[0], ary[1]);
|
||||
}
|
||||
@gplx.Internal protected static void Select(TabBox tabBox, TabPnlItm curTabItm, TabPnlItm newTabItm) {
|
||||
TabPnlAreaMgr.Select(tabBox, curTabItm, newTabItm);
|
||||
TabBtnAreaMgr.Select(tabBox, curTabItm, newTabItm);
|
||||
GfoEvMgr_.PubVal(tabBox, SelectedChanged_evt, newTabItm.Idx());
|
||||
}
|
||||
public static int Handle(GfsCtx ctx, GfoMsg m) {
|
||||
return m.ReadInt("v");
|
||||
}
|
||||
}
|
||||
57
150_gfui/src_500_tab/gplx/gfui/TabBoxMgr.java
Normal file
57
150_gfui/src_500_tab/gplx/gfui/TabBoxMgr.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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 TabBoxMgr implements GfoEvMgrOwner {
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
public int Count() {return itms.Count();}
|
||||
public TabPnlItm Get_by(String k) {return (TabPnlItm)itms.Get_by(k);}
|
||||
public TabPnlItm Get_at(int i) {return (TabPnlItm)itms.Get_at(i);}
|
||||
public TabPnlItm CurTab() {return curTab;} TabPnlItm curTab;
|
||||
public TabPnlItm Add(String key, String name) {
|
||||
TabPnlItm itm = TabPnlItm.new_(this, key).Name_(name).Idx_(itms.Count());
|
||||
itms.Add(itm.Key(), itm);
|
||||
return itm;
|
||||
}
|
||||
public void Del_at(int i) {
|
||||
boolean isCur = i == curTab.Idx(), isLast = i == itms.Count() - 1;
|
||||
TabPnlItm itm = this.Get_at(i);
|
||||
itms.Del(itm.Key());
|
||||
this.Reorder(i);
|
||||
if (isCur) {
|
||||
curTab = null; // must null out curTab since it has been deleted from itms; TODO: should raise Deleted event to delete btn,pnl,view; wait for rewrite of view
|
||||
if (isLast) i--; // last was dropped; select prev; otherwise re-select idx (effectively, whatever tab drops into slot)
|
||||
if (i >=0)
|
||||
this.Select(i);
|
||||
}
|
||||
}
|
||||
public void Select(int i) {Select((TabPnlItm)itms.Get_at(i));}
|
||||
@gplx.Internal protected void Move_to(int src, int trg) {itms.Move_to(src, trg);}
|
||||
@gplx.Internal protected void Reorder(int bgn) {
|
||||
for (int i = bgn; i < itms.Count(); i++) {
|
||||
TabPnlItm itm = (TabPnlItm)itms.Get_at(i);
|
||||
itm.Idx_(i);
|
||||
}
|
||||
}
|
||||
@gplx.Internal protected void Select(TabPnlItm newTab) {
|
||||
TabPnlItm oldTab = curTab;
|
||||
curTab = newTab;
|
||||
TabBoxEvt_tabSelect.Send(this, oldTab, newTab);
|
||||
}
|
||||
Ordered_hash itms = Ordered_hash_.new_();
|
||||
@gplx.Internal protected static TabBoxMgr new_() {return new TabBoxMgr();} TabBoxMgr() {}
|
||||
}
|
||||
33
150_gfui/src_500_tab/gplx/gfui/TabBox_.java
Normal file
33
150_gfui/src_500_tab/gplx/gfui/TabBox_.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class TabBox_ {
|
||||
public static TabBox as_(Object obj) {return obj instanceof TabBox ? (TabBox)obj : null;}
|
||||
public static TabBox cast_(Object obj) {try {return (TabBox)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, TabBox.class, obj);}}
|
||||
public static TabBox new_() {
|
||||
TabBox rv = new TabBox();
|
||||
rv.ctor_GfuiBox_base(GfuiElem_.init_focusAble_false_());
|
||||
return rv;
|
||||
}
|
||||
public static int Cycle(boolean fwd, int val, int max) {
|
||||
if (fwd)
|
||||
return val == max - 1 ? 0 : val + 1;
|
||||
else
|
||||
return val == 0 ? max - 1 : val - 1;
|
||||
}
|
||||
}
|
||||
38
150_gfui/src_500_tab/gplx/gfui/TabPnlItm.java
Normal file
38
150_gfui/src_500_tab/gplx/gfui/TabPnlItm.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class TabPnlItm {
|
||||
public String Key() {return key;} private String key;
|
||||
public String Name() {return name;}
|
||||
public TabPnlItm Name_(String val) {
|
||||
name = val;
|
||||
TabBoxEvt_nameChange.Send(mgr, this);
|
||||
return this;
|
||||
} String name;
|
||||
public int Idx() {return idx;}
|
||||
@gplx.Internal protected TabPnlItm Idx_(int val) {
|
||||
idx = val;
|
||||
return this;
|
||||
} int idx;
|
||||
TabBoxMgr mgr;
|
||||
public static TabPnlItm new_(TabBoxMgr mgr, String key) {
|
||||
TabPnlItm rv = new TabPnlItm();
|
||||
rv.mgr = mgr; rv.key = key;
|
||||
return rv;
|
||||
} TabPnlItm() {}
|
||||
}
|
||||
Reference in New Issue
Block a user