mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.5.4.1
This commit is contained in:
@@ -23,7 +23,7 @@ class TabBoxEvt_nameChange {
|
||||
}
|
||||
public static void Rcvd(TabBox tabBox, GfsCtx ctx, GfoMsg m) {
|
||||
TabPnlItm itm = (TabPnlItm)m.CastObj("v");
|
||||
GfuiBtn btn = GfuiBtn_.as_(tabBox.BtnBox().SubElems().Fetch(itm.Key()));
|
||||
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());
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class TabBoxEvt_tabSelectByBtn {
|
||||
GfuiBtn btn = (GfuiBtn)sender;
|
||||
String key = btn.Key_of_GfuiElem();
|
||||
TabBoxMgr mgr = tabBox.Mgr();
|
||||
mgr.Select(mgr.Fetch(key));
|
||||
mgr.Select(mgr.Get_by(key));
|
||||
}
|
||||
}
|
||||
class TabBnd_selectTab implements InjectAble, GfoInvkAble {
|
||||
@@ -64,14 +64,14 @@ class TabBnd_reorderTab implements InjectAble, GfoInvkAble {
|
||||
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().Fetch(curBtn.Key_of_GfuiElem());
|
||||
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().MoveTo(curIdx, newIdx);
|
||||
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().MoveTo(curIdx, newIdx);
|
||||
TabBtnAreaMgr.MoveTo(tabBox, curIdx, newIdx);
|
||||
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) {
|
||||
|
||||
@@ -19,8 +19,8 @@ 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().Fetch(mgr.FetchAt(i).Key());}
|
||||
public GfuiElem Tabs_SelectedPnl() {return pnlBox.SubElems().Fetch(mgr.CurTab().Key());}
|
||||
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);
|
||||
@@ -30,9 +30,9 @@ public class TabBox extends GfuiElemBase {
|
||||
return pnl;
|
||||
}
|
||||
public void Tabs_DelAt(int idx) {
|
||||
TabBtnAreaMgr.Del(this, mgr.FetchAt(idx));
|
||||
TabPnlAreaMgr.Del(this, mgr.FetchAt(idx));
|
||||
mgr.DelAt(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;
|
||||
@@ -72,7 +72,7 @@ class TabBtnAreaMgr {
|
||||
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().FetchAt(btnBox.SubElems().Count() - 1);
|
||||
GfuiElem lastBtn = btnBox.SubElems().Get_at(btnBox.SubElems().Count() - 1);
|
||||
btn.X_(lastBtn.X() + lastBtn.Width());
|
||||
}
|
||||
btnBox.SubElems().Add(btn);
|
||||
@@ -81,27 +81,27 @@ class TabBtnAreaMgr {
|
||||
public static void Del(TabBox tabBox, TabPnlItm itm) {
|
||||
GfuiElem btnBox = tabBox.BtnBox();
|
||||
int idx = itm.Idx();
|
||||
GfuiBtn btn = (GfuiBtn)btnBox.SubElems().FetchAt(idx);
|
||||
btnBox.SubElems().DelAt(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().FetchAt(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().FetchAt(curTabItm.Idx());
|
||||
GfuiBtn curBtn = (GfuiBtn)tabBox.BtnBox().SubElems().Get_at(curTabItm.Idx());
|
||||
Select(curBtn, false);
|
||||
}
|
||||
GfuiBtn newBtn = (GfuiBtn)tabBox.BtnBox().SubElems().FetchAt(newTabItm.Idx());
|
||||
GfuiBtn newBtn = (GfuiBtn)tabBox.BtnBox().SubElems().Get_at(newTabItm.Idx());
|
||||
Select(newBtn, true);
|
||||
}
|
||||
public static void MoveTo(TabBox tabBox, int curIdx, int newIdx) {
|
||||
public static void Move_to(TabBox tabBox, int curIdx, int newIdx) {
|
||||
GfuiElemList btns = tabBox.BtnBox().SubElems();
|
||||
btns.MoveTo(curIdx, newIdx);
|
||||
btns.Move_to(curIdx, newIdx);
|
||||
int curX = 0;
|
||||
for (int i = 0; i < btns.Count(); i++) {
|
||||
GfuiBtn cur = (GfuiBtn)btns.FetchAt(i);
|
||||
GfuiBtn cur = (GfuiBtn)btns.Get_at(i);
|
||||
cur.X_(curX);
|
||||
curX += cur.Width();
|
||||
}
|
||||
@@ -129,15 +129,15 @@ class TabPnlAreaMgr {
|
||||
return pnl;
|
||||
}
|
||||
public static void Del(TabBox tabBox, TabPnlItm itm) {
|
||||
tabBox.PnlBox().SubElems().DelAt(itm.Idx());
|
||||
((GfuiElemBase)tabBox.PnlBox()).Lyt().SubLyts().DelAt(itm.Idx());
|
||||
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().FetchAt(curTabItm.Idx());
|
||||
GfuiElem curTab = tabBox.PnlBox().SubElems().Get_at(curTabItm.Idx());
|
||||
curTab.Visible_set(false);
|
||||
}
|
||||
GfuiElem newTab = tabBox.PnlBox().SubElems().FetchAt(newTabItm.Idx());
|
||||
GfuiElem newTab = tabBox.PnlBox().SubElems().Get_at(newTabItm.Idx());
|
||||
newTab.Visible_set(true);
|
||||
newTab.Zorder_front();
|
||||
newTab.Focus();
|
||||
|
||||
@@ -19,17 +19,17 @@ 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 Fetch(String k) {return (TabPnlItm)itms.Fetch(k);}
|
||||
public TabPnlItm FetchAt(int i) {return (TabPnlItm)itms.FetchAt(i);}
|
||||
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 DelAt(int i) {
|
||||
public void Del_at(int i) {
|
||||
boolean isCur = i == curTab.Idx(), isLast = i == itms.Count() - 1;
|
||||
TabPnlItm itm = this.FetchAt(i);
|
||||
TabPnlItm itm = this.Get_at(i);
|
||||
itms.Del(itm.Key());
|
||||
this.Reorder(i);
|
||||
if (isCur) {
|
||||
@@ -39,11 +39,11 @@ public class TabBoxMgr implements GfoEvMgrOwner {
|
||||
this.Select(i);
|
||||
}
|
||||
}
|
||||
public void Select(int i) {Select((TabPnlItm)itms.FetchAt(i));}
|
||||
@gplx.Internal protected void MoveTo(int src, int trg) {itms.MoveTo(src, trg);}
|
||||
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.FetchAt(i);
|
||||
TabPnlItm itm = (TabPnlItm)itms.Get_at(i);
|
||||
itm.Idx_(i);
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,6 @@ public class TabBoxMgr implements GfoEvMgrOwner {
|
||||
curTab = newTab;
|
||||
TabBoxEvt_tabSelect.Send(this, oldTab, newTab);
|
||||
}
|
||||
OrderedHash itms = OrderedHash_.new_();
|
||||
Ordered_hash itms = Ordered_hash_.new_();
|
||||
@gplx.Internal protected static TabBoxMgr new_() {return new TabBoxMgr();} TabBoxMgr() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user