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,253 @@
/*
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.gfml.*;
public class GfoConsoleWin implements GfoInvkAble, UsrMsgWkr {
GfuiWin win; GfoConsoleWinCmds cmds; GfuiTextBox statusBox, resultBox; GfuiTextBoxLogger logger;
public boolean Enabled() {return enabled;} public GfoConsoleWin Enabled_(boolean v) {enabled = v; return this;} private boolean enabled = true;
public GfuiWin Win() {return win;}
void Init() {
win = GfuiWin_.tool_("gfoConsoleWin");
win.Size_(700, 600);
PointAdp point = PointAdp_.new_(ScreenAdp_.Primary.Width() - win.Width(), ScreenAdp_.Primary.Height() - win.Height());
win.Pos_(point).Focus_default_("consoleBox"); win.QuitMode_(GfuiQuitMode.Suspend);
GfuiTextBox_.fld_("consoleFilBox", win);
GfuiTextBox consoleBox = GfuiTextBox_.multi_("consoleBox", win);
consoleBox.TextMgr().Font_(FontAdp.new_("Courier New", 8, FontStyleAdp_.Plain));
consoleBox.OverrideTabKey_(false);
resultBox = GfuiTextBox_.multi_("resultBox", win);
resultBox .OverrideTabKey_(false);
resultBox.TextMgr().Font_(FontAdp.new_("Courier New", 8, FontStyleAdp_.Plain));
statusBox = GfuiTextBox_.multi_("statusBox", win);
statusBox.OverrideTabKey_(false);
statusBox.TextMgr().Font_(FontAdp.new_("Courier New", 8, FontStyleAdp_.Plain));
win.Inject_(GfuiStatusBarBnd.new_());
cmds = new GfoConsoleWinCmds(this);
cmds.Owner_set(win); cmds.Init();
IptBnd_.cmd_to_(IptCfg_.Null, win, cmds, GfoConsoleWinCmds.Invk_Hide, IptKey_.Escape);
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Exec, IptKey_.add_(IptKey_.Ctrl, IptKey_.E));
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Save, IptKey_.add_(IptKey_.Ctrl, IptKey_.S));
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Load, IptKey_.add_(IptKey_.Ctrl, IptKey_.L));
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Help, IptKey_.add_(IptKey_.Ctrl, IptKey_.D));
IptBnd_.cmd_to_(IptCfg_.Null, consoleBox, cmds, GfoConsoleWinCmds.Invk_Clear, IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.C));
logger = new GfuiTextBoxLogger(this).Init(statusBox);
// gplx.ios.GfioApp.InitGfs();
UsrDlg_._.Reg(UsrMsgWkr_.Type_Note, this);
win.Lyt_activate();
win.Lyt().Bands_add(GftBand.fillWidth_());
win.Lyt().Bands_add(GftBand.fillWidth_().Len1_pct_(50));
win.Lyt().Bands_add(GftBand.fillWidth_().Len1_abs_(20));
win.Lyt().Bands_add(GftBand.fillWidth_().Len1_pct_(50));
win.Lyt().Bands_add(GftBand.fillWidth_());
}
void Show() {
if (win == null) this.Init();
win.Pin_(false);
win.Visible_set(true);
win.Zorder_front_and_focus();
}
public void ExecUsrMsg(int type, UsrMsg umsg) {
if (win == null) this.Init();
String s = umsg.XtoStr();
if (type == UsrMsgWkr_.Type_Warn) {
if (!win.Pin()) win.Pin_();
s = "!!warn!! " + umsg.XtoStr();
if (logger == null) return;
logger.Write(s);
}
else {
statusBox.Text_(statusBox.Text() + s);
statusBox.SelBgn_set(String_.Len(statusBox.Text()) - 1);
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_Show)) Show();
else return GfoInvkAble_.Rv_unhandled;
return this;
} public static final String Invk_Show = "Show"
;
public static final GfoConsoleWin _ = new GfoConsoleWin(); GfoConsoleWin() {}
}
class GfoConsoleWinCmds implements GfoInvkAble {
GfuiWin win; GfuiTextBox consoleFilBox, consoleBox, statusBox, resultBox;
public void Owner_set(GfuiElem elem) {win = (GfuiWin)elem;}
public void Init() {
consoleFilBox = (GfuiTextBox)win.SubElems().Get_by("consoleFilBox");
consoleBox = (GfuiTextBox)win.SubElems().Get_by("consoleBox");
resultBox = (GfuiTextBox)win.SubElems().Get_by("resultBox");
statusBox = (GfuiTextBox)win.SubElems().Get_by("statusBox");
GfsCore._.AddObj(this, "gfoConsoleWin");
GfsCore._.ExecRegy("gplx.gfui.GfoConsoleWin.ini");
}
public void Results_add(String s) {
if (!String_.Has_at_end(s, GfuiTextBox_.NewLine))
s += GfuiTextBox_.NewLine;
statusBox.Text_(statusBox.Text() + s);
statusBox.SelBgn_set(String_.Len(statusBox.Text()) - 1);
}
void Hide() {win.Hide();}
void Exec(GfoMsg msg) {
String cmdText = consoleBox.SelLen() == 0 ? consoleBox.Text() : consoleBox.SelText();
String cmd = FixNewLines(cmdText);
GfoMsg runMsg = GfoMsg_.Null;
try {runMsg = GfsCore._.MsgParser().ParseToMsg(cmd);} catch (Exception e) {statusBox.Text_("invalid gfml " + Err_.Message_gplx(e)); return;}
GfsCtx ctx = GfsCtx.new_();
Object rv = GfsCore._.ExecMany(ctx, runMsg);
resultBox.Text_(Object_.Xto_str_strict_or_empty(rv));
}
void Help() {
statusBox.Text_("");
if (consoleBox.SelLen() == 0) return;
String cmdText = "help:'" + consoleBox.SelText() + "';";
String cmd = FixNewLines(cmdText);
GfoMsg runMsg = GfoMsg_.Null;
try {runMsg = GfmlDataNde.XtoMsgNoRoot(cmd);} catch (Exception e) {statusBox.Text_("invalid gfml " + Err_.Message_gplx(e)); return;}
GfsCtx ctx = GfsCtx.new_();
try {
Object rv = GfsCore._.ExecOne(ctx, runMsg);
if (rv != GfoInvkAble_.Rv_handled && rv != GfoInvkAble_.Rv_unhandled) {
UsrDlg_._.Note(Object_.Xto_str_strict_or_empty(rv));
}
// Results_add(FixNewLines(ctx.Results_XtoStr()));
} catch (Exception e) {statusBox.Text_("help failed " + Err_.Message_gplx(e)); return;}
}
void Save() {
String consoleFilStr = consoleFilBox.Text();
Io_url url = Io_url_.Empty;
if (String_.Len_eq_0(consoleFilStr)) {
url = GfuiIoDialogUtl.SelectFile();
consoleFilBox.Text_(url.Raw());
return;
}
else
url = Io_url_.new_any_(consoleFilStr);
Io_mgr.I.SaveFilStr(url, consoleBox.Text());
}
void Load() {
String consoleFilStr = consoleFilBox.Text();
Io_url dir = Io_url_.Empty;
if (String_.Len_eq_0(consoleFilStr))
dir = Io_url_.Empty;
else {
dir = Io_url_.new_any_(consoleFilStr);
dir = dir.OwnerDir();
}
Io_url url = GfuiIoDialogUtl.SelectFile(dir); if (url == Io_url_.Empty) return;
consoleBox.Text_(Io_mgr.I.LoadFilStr(url));
}
String FixNewLines(String cmd) {
cmd = String_.Replace(cmd, "\n", "\r\n");
cmd = String_.Replace(cmd, "\r\r", "\r");
return cmd;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_Exec)) Exec(m);
else if (ctx.Match(k, Invk_Hide)) Hide();
else if (ctx.Match(k, Invk_Save)) Save();
else if (ctx.Match(k, Invk_Load)) Load();
else if (ctx.Match(k, Invk_Help)) Help();
else if (ctx.Match(k, Invk_Clear)) statusBox.Text_("");
else if (ctx.Match(k, "consoleBox")) return consoleBox;
else if (ctx.Match(k, Invk_X_)) {
int v = m.ReadInt("v");
if (ctx.Deny()) return this;
win.X_(v);
}
else if (ctx.Match(k, Invk_Y_)) {
int v = m.ReadInt("v");
if (ctx.Deny()) return this;
win.Y_(v);
}
else if (ctx.Match(k, Invk_Width_)) {
int v = m.ReadInt("v");
if (ctx.Deny()) return this;
win.Width_(v);
}
else if (ctx.Match(k, Invk_Height_)) {
int v = m.ReadInt("v");
if (ctx.Deny()) return this;
win.Height_(v);
}
else if (ctx.Match(k, Invk_Enabled_)) {
boolean v = m.ReadBool("v");
if (ctx.Deny()) return this;
owner.Enabled_(v);
}
else if (ctx.Match(k, Invk_SaveUrl_)) {
Io_url v = m.ReadIoUrl("v");
if (ctx.Deny()) return this;
consoleFilBox.Text_(v.Xto_api());
consoleBox.Text_(Io_mgr.I.LoadFilStr(v));
}
else return win.Invk(ctx, ikey, k, m);
return this;
} public static final String Invk_Exec = "Exec", Invk_Hide = "Hide", Invk_Save = "Save", Invk_Load = "Load", Invk_Help = "Help", Invk_Clear = "Clear"
, Invk_X_ = "X_", Invk_Y_ = "Y_", Invk_Width_ = "Width_", Invk_Height_ = "Height_", Invk_Enabled_ = "Enabled_", Invk_SaveUrl_ = "SaveUrl_"
;
GfoConsoleWin owner;
public GfoConsoleWinCmds(GfoConsoleWin owner) {this.owner = owner;}
}
class GfuiTextBoxLogger implements GfoInvkAble {
public GfuiTextBoxLogger Init(GfuiTextBox tbox) {
this.tbox = tbox;
win = tbox.OwnerWin();
timer = TimerAdp.new_(this, Tmr_cmd, 500, false);
return this;
}
public void Write(String s) {
if (!owner.Enabled()) return;
if (!win.Visible()) win.Visible_set(true);
textToShow += tbox.Text() + String_.as_(s)+ String_.CrLf;
long curTick = Env_.TickCount();
// if (curTick - lastTick > 500) {
WriteText(textToShow);
textToShow = "";
timer.Enabled_off();
// }
// else
// timer.Enabled_on();
lastTick = curTick;
}
void WriteText(String text) {
if (!win.Visible()) return; // StatusForm not visible; return; otherwise .CreateControl will be called
tbox.CreateControlIfNeeded(); // otherwise will occasionally throw: Cannot call Invoke or InvokeAsync on a control until the window handle has been created
tbox.Invoke(GfoInvkAbleCmd.arg_(this, Invk_WriteText_cmd, text));
}
void Invk_WriteText(String text) {
tbox.Text_(text);
tbox.SelBgn_set(String_.Len(text) - 1);
if (!tbox.Focus_has()) tbox.Focus();
}
void WhenTick() {
WriteText(textToShow);
textToShow = "";
timer.Enabled_off();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Tmr_cmd)) WhenTick();
else if (ctx.Match(k, Invk_WriteText_cmd)) Invk_WriteText(m.ReadStr("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
String Invk_WriteText_cmd = "Invk_WriteText", Tmr_cmd = "Tmr";
GfoConsoleWin owner;
public GfuiTextBoxLogger(GfoConsoleWin owner) {this.owner = owner;}
GfuiTextBox tbox; GfuiWin win;
TimerAdp timer; long lastTick; String textToShow = "";
}

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 GfuiBnd_win_host {
public GfuiWin HosterWin() {return hosterWin;} GfuiWin hosterWin;
public GfuiElem HosteeBox() {return hosteeBox;} GfuiElem hosteeBox;
public GfuiWin OwnerWin() {return ownerWin;} GfuiWin ownerWin;
public static GfuiBnd_win_host new_(GfuiElem elemToHost, GfuiWin ownerForm) {
GfuiBnd_win_host rv = new GfuiBnd_win_host();
rv.ctor_(elemToHost, ownerForm);
return rv;
}
void ctor_(GfuiElem elemToHost, GfuiWin ownerForm) {
this.hosteeBox = elemToHost;
this.ownerWin = ownerForm;
this.hosterWin = GfuiWin_.toaster_("hosterWin_" + elemToHost.Key_of_GfuiElem(), ownerForm);
hosterWin.IptBnds().EventsToFwd_set(IptEventType_.None);
hosterWin.Size_(hosteeBox.Size());
hosteeBox.Owner_(hosterWin);
hosterWin.TaskbarVisible_(false);
hosterWin.TaskbarParkingWindowFix(ownerForm); // else ContextMenu shows up as WindowsFormsParkingWindow
}
}

View File

@@ -0,0 +1,52 @@
/*
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 GfuiCmdForm implements GfoInvkAble, InjectAble {
public void Inject(Object ownerObj) {
GfuiElem owner = (GfuiElem)ownerObj;
GfuiCmdForm.host_(key, cmdElem, owner);
}
public static GfuiCmdForm new_(String key, GfuiElem cmdElem) {
GfuiCmdForm rv = new GfuiCmdForm();
rv.key = key;
rv.cmdElem = cmdElem;
return rv;
} String key; GfuiElem cmdElem;
public static GfuiWin host_(String key, GfuiElem cmdElem, GfuiElem hostElem) {
GfuiWin rv = GfuiWin_.sub_(key, hostElem.OwnerWin()); rv.Size_(cmdElem.Size());
cmdElem.Owner_(rv);
GfuiCmdForm cmd = new GfuiCmdForm(); cmd.cmdForm = rv;
IptBnd_.cmd_to_(IptCfg_.Null, rv, cmd, HideMe_cmd, IptKey_.Escape);
IptBnd_.cmd_to_(IptCfg_.Null, hostElem, cmd, DoStuff, IptKey_.add_(IptKey_.Ctrl, IptKey_.Space), IptMouseBtn_.Right);
return rv;
}
GfuiWin cmdForm;
static final String DoStuff = "doStuff", HideMe_cmd = "HideMe";
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, DoStuff)) ActivateMe((GfuiElem)ctx.MsgSrc());
else if (ctx.Match(k, HideMe_cmd)) ((GfuiWin)ctx.MsgSrc()).Hide();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
void ActivateMe(GfuiElem elem) {
cmdForm.Pos_(elem.Pos().Op_add(elem.OwnerWin().Pos()));
cmdForm.Show();
}
}

View File

@@ -0,0 +1,58 @@
/*
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.*; /*ComparerAble*/
class GfuiFocusOrderer {
public static void OrderByX(GfuiElem owner) {Order(owner, xcomparer, 0);}
public static void OrderByY(GfuiElem owner) {Order(owner, ycomparer, 0);}
static int Order(GfuiElem owner, ComparerAble comparer, int order) {
List_adp list = List_adp_.new_();
for (int i = 0; i < owner.SubElems().Count(); i++) {
GfuiElem sub = (GfuiElem)owner.SubElems().Get_at(i);
if (sub.Focus_idx() != NullVal) continue;
list.Add(sub);
}
list.Sort_by(comparer);
for (Object subObj : list) {
GfuiElem sub = (GfuiElem)subObj;
sub.Focus_idx_(order++);
if (owner.SubElems().Count() > 0) // subs available; recurse;
order = Order(sub, comparer, order);
}
return order;
}
static GfuiFocusOrderer_cls_x xcomparer = new GfuiFocusOrderer_cls_x(); static GfuiFocusOrderer_cls_y ycomparer = new GfuiFocusOrderer_cls_y();
public static final int NullVal = -1;
}
class GfuiFocusOrderer_cls_x implements ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
GfuiElem lhs = (GfuiElem)lhsObj, rhs = (GfuiElem)rhsObj;
if (lhs.Y() < rhs.Y()) return CompareAble_.Less;
else if (lhs.Y() > rhs.Y()) return CompareAble_.More;
else return Int_.Compare(lhs.X(), rhs.X());
}
}
class GfuiFocusOrderer_cls_y implements ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
GfuiElem lhs = (GfuiElem)lhsObj, rhs = (GfuiElem)rhsObj;
if (lhs.X() < rhs.X()) return CompareAble_.Less;
else if (lhs.X() > rhs.X()) return CompareAble_.More;
else return Int_.Compare(lhs.Y(), rhs.Y());
}
}

View File

@@ -0,0 +1,52 @@
/*
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 GfuiFocusXferBnd implements InjectAble, GfoInvkAble {
public void Inject(Object owner) {
GfuiElem elem = GfuiElem_.cast_(owner);
IptBnd_.cmd_to_(IptCfg_.Null, elem, this, Invk_FocusNext, IptKey_.Down);
IptBnd_.cmd_to_(IptCfg_.Null, elem, this, Invk_FocusPrev, IptKey_.Up);
}
@gplx.Internal protected void Focus(GfuiElem cur, boolean fwd) {
List_adp allElemsInOwnerWin = List_adp_.new_(); AddSubs(cur.OwnerWin(), allElemsInOwnerWin);
int curIdx = allElemsInOwnerWin.Idx_of(cur);
GfuiElem target = cur;
while (true) { // find next visible elem
int cycle = TabBox_.Cycle(fwd, curIdx, allElemsInOwnerWin.Count());
target = GfuiElem_.cast_(allElemsInOwnerWin.Get_at(cycle));
if (target.Visible()) break;
if (cycle == curIdx) break; // either (a) one elem in allElemsInOwnerWin or (b) n elems, and cycled back to start; break, else infinite loop
curIdx = cycle;
}
target.Focus();
}
void AddSubs(GfuiElem owner, List_adp allElemsInOwnerWin) {
for (int i = 0; i < owner.SubElems().Count(); i++) {
GfuiElemBase sub = (GfuiElemBase)owner.SubElems().Get_at(i);
if (sub.Click_able()) allElemsInOwnerWin.Add(sub);
AddSubs(sub, allElemsInOwnerWin);
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_FocusNext)) Focus(GfuiElem_.cast_(ctx.MsgSrc()), true);
else if (ctx.Match(k, Invk_FocusPrev)) Focus(GfuiElem_.cast_(ctx.MsgSrc()), false);
else return GfoInvkAble_.Rv_unhandled;
return this;
} public static final String Invk_FocusNext = "FocusNext", Invk_FocusPrev = "FocusPrev";
public static final GfuiFocusXferBnd _ = new GfuiFocusXferBnd(); GfuiFocusXferBnd() {}
}

View File

@@ -0,0 +1,75 @@
/*
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 GfuiForm_menu implements GfoInvkAble {
public GfuiWin Form() {return form;} GfuiWin form;
void Visible_toggle(GfoMsg msg) {
GfuiElem ownerForm = owner.OwnerWin();
sub.OwnerWin().Zorder_front();
form.Visible_set(!form.Visible());
if (form.Visible()) {
PointAdp pos = ownerForm.Pos(); // NOTE: add ownerForm to handle different screens (ex: outerElem.OwnerWin.X = 1600 with dual screens))
pos = pos.Op_add(owner.Rect().Pos());
RectAdp rect = RectAdp_.vector_(pos, owner.Rect().Size());
form.Pos_(GfuiMenuFormUtl.CalcShowPos(rect, form.Size()));
form.Focus(); // force refocus; last choice is lost, but otherwise focus remains on owner box
}
}
void Visible_hide(GfoMsg msg) {
form.Visible_set(false);
}
GfuiElem sub; GfuiElem owner;
void ctor_GfuiForm_menu(GfuiElem owner_, GfuiElem sub_, SizeAdp size) {
owner = owner_; sub = sub_;
sub.Size_(size);
form = GfuiWin_.sub_("test", owner.OwnerWin());
form.IptBnds().EventsToFwd_set(IptEventType_.None);
form.TaskbarVisible_(false);
form.Size_(sub.Size());
sub.Owner_(form);
// form.CmdsA().Del(GfuiWin.Invk_Minimize);
// form.CmdsA().Del(GfuiStatusBoxBnd.Invk_ShowTime);
IptBnd_.cmd_to_(IptCfg_.Null, form, this, Visible_hide_cmd, IptKey_.Escape);
IptBnd_.cmd_to_(IptCfg_.Null, owner, this, Visible_toggle_cmd, IptKey_.add_(IptKey_.Ctrl, IptKey_.Space), IptMouseBtn_.Right);
form.TaskbarParkingWindowFix(owner.OwnerWin()); // else ContextMenu shows up as WindowsFormsParkingWindow
form.QuitMode_(GfuiQuitMode.Suspend);
}
public static final String Msg_menu_Visible_toggle = "menu.visible_toggle";
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Visible_hide_cmd)) Visible_hide(m);
else if (ctx.Match(k, Visible_toggle_cmd)) Visible_toggle(m);
else return GfoInvkAble_.Rv_unhandled;
return this;
} public static final String Visible_hide_cmd = "Visible_hide", Visible_toggle_cmd = "Visible_toggle";
public static GfuiWin new_(GfuiElem owner, GfuiElem sub, SizeAdp size) {
GfuiForm_menu rv = new GfuiForm_menu();
rv.ctor_GfuiForm_menu(owner, sub, size);
return rv.Form();
}
public static GfuiWin container3_(GfuiWin mainForm) {
GfuiWin form = GfuiWin_.sub_("test", mainForm);
form.TaskbarVisible_(false);
form.TaskbarParkingWindowFix(mainForm); // else ContextMenu shows up as WindowsFormsParkingWindow
form.QuitMode_(GfuiQuitMode.Suspend);
return form;
}
}

View File

@@ -0,0 +1,272 @@
/*
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 java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.border.EmptyBorder;
public class GfuiMenuBar implements GfoInvkAble {
public Object Under() {return winMenu;}
public boolean Visible() {return visible;} private boolean visible;
public void Visible_set(boolean v) {
this.visible = v;
MenuBar_visible_set(v);
boolean menuBandExists = win.Lyt().Bands_has(menuBand.Key());
if ( visible && !menuBandExists)
win.Lyt().Bands_add(menuBand);
else if (!visible && menuBandExists)
win.Lyt().Bands_del(menuBand.Key());
GftGrid.LytExecRecur(win);
} GftBand menuBand = GftBand.fillWidth_().Key_("GfuiMenuBar");
public void Load_cfg(String cfgKey) {
try {
root.ForeColor_(ColorAdp_.Black).BackColor_(ColorAdp_.White);
root.ExecProps();
curOwnerItm = root;
GfsCore._.AddObj(this, "GfuiMenuBar_");
GfsCore._.ExecRegy("gplx.gfui.GfuiMenuBar.ini");
}
catch (Exception e) {GfuiEnv_.ShowMsg(Err_.Message_gplx(e));}
}
String separatorText, mnemonicPrefix; int separatorIdx = 0;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_visible_toggle)) this.Visible_set(!visible);
else if (ctx.Match(k, Invk_SeparatorText_)) separatorText = GfoMsgUtl.SetStr(ctx, m, separatorText);
else if (ctx.Match(k, Invk_MnemonicPrefix_)) mnemonicPrefix = GfoMsgUtl.SetStr(ctx, m, mnemonicPrefix);
else if (ctx.Match(k, Invk_Visible_)) {
boolean v = m.ReadBoolOr("v", true);
if (ctx.Deny()) return this;
Visible_set(v);
}
else if (ctx.Match(k, Invk_RegTop)) {
String s = m.ReadStrOr("v", null);
if (ctx.Deny()) return this;
GfuiMenuBarItm itm = GfuiMenuBarItm.sub_(root);
itm.Type_(GfuiMenuBarItmType.Top);
itm.Text_(s);
itm.Ipt_(Read_prop_ipt(IptKey_.None, itm));
itms.Add(s, itm);
itm.ExecProps();
curOwnerItm = itm;
}
else if (ctx.Match(k, Invk_RegSpr)) {
String text = m.ReadStr("text");
if (ctx.Deny()) return this;
GfuiMenuBarItm itm = GfuiMenuBarItm.sub_(curOwnerItm);
itm.Type_(GfuiMenuBarItmType.Spr);
itm.Text_(text);
itm.Key_(curOwnerItm.Key() + "." + text + Int_.Xto_str(separatorIdx++));
itm.ExecProps();
}
else if (ctx.Match(k, Invk_RegCmd)) {
String text = m.ReadStr("text");
String cmd = m.ReadStrOr("cmd", null);
String tipText = m.ReadStrOr("tipText", null);
if (ctx.Deny()) return this;
GfuiMenuBarItm itm = GfuiMenuBarItm.sub_(curOwnerItm);
itm.Type_(GfuiMenuBarItmType.Cmd);
itm.Text_(text);
itm.Cmd_(cmd);
itm.TipText_(tipText);
itm.Ipt_(Read_prop_ipt(IptKey_.None, itm));
itm.Key_(curOwnerItm.Key() + "." + text);
itm.ExecProps();
}
else return GfoInvkAble_.Rv_unhandled;
return this;
} public static final String Invk_visible_toggle = "MenuBar_toggle"
, Invk_Visible_ = "Visible_", Invk_SeparatorText_ = "SeparatorText_", Invk_MnemonicPrefix_ = "MnemonicPrefix_"
, Invk_RegTop = "RegTop", Invk_RegCmd = "RegCmd", Invk_RegSpr = "RegSpr"
;
GfuiMenuBarItm curOwnerItm = null;
IptKey Read_prop_ipt(IptKey ipt, GfuiMenuBarItm itm) {
if (mnemonicPrefix == null) return ipt;
String text = itm.Text();
int pos = String_.FindFwd(text, mnemonicPrefix);
if (pos == String_.Find_none || pos == String_.Len(text) - 1) return ipt; // mnemonic not found
String keyChar = String_.MidByLen(text, pos + 1, 1);
if (!Char_.IsLetterEnglish(String_.CharAt(keyChar, 0))) return ipt; // keyChar is not a character; EX: 'A & B' (keyChar = space)
String keyCharRaw = "key." + String_.Lower(keyChar);
ipt = IptKey_.parse_(keyCharRaw);
text = String_.MidByLen(text, 0, pos) + String_.Mid(text, pos + 1); // remove mnemPrefix; ex: &File -> File && key.f
itm.Text_(text);
return ipt;
}
void MenuBar_visible_set(boolean v) {winMenu.setVisible(v);}
void InitMenuBar(GxwWin win) {
ownerForm = (JFrame)win;
ownerForm.setJMenuBar(winMenu);
winMenu.setBorder(GxwBorderFactory.Empty);
}
JMenuBar winMenu = new JMenuBar();
JFrame ownerForm;
GfuiMenuBarItm root;
void Init(GfuiWin win) {
InitMenuBar((GxwWin)win.UnderElem());
root = GfuiMenuBarItm.root_(winMenu);
itms.Add(root.Key(), root);
this.win = win;
IptBnd_.cmd_to_(GfuiEnv_.IptBndMgr_win, win, this, Invk_visible_toggle, IptKey_.add_(IptKey_.Ctrl, IptKey_.Shift, IptKey_.F12));
win.SubItms_add(SubItms_key, this);
}
Hash_adp itms = Hash_adp_.new_(); GfuiWin win;
public static final String SubItms_key = "menuBar";
public static GfuiMenuBar new_(GfuiWin win) {
GfuiMenuBar rv = new GfuiMenuBar();
rv.Init(win);
return rv;
} GfuiMenuBar() {}
}
class GfuiMenuBarItm {
public String Key() {return key;} public GfuiMenuBarItm Key_(String val) {key = val; return this;} private String key = "";
public String Text() {return text;} public GfuiMenuBarItm Text_(String val) {text = val; return this;} private String text = "";
public String Cmd() {return cmd;} public GfuiMenuBarItm Cmd_(String val) {cmd = val; return this;} private String cmd = "";
public GfuiMenuBarItmType Type() {return type;} public GfuiMenuBarItm Type_(GfuiMenuBarItmType val) {type = val; return this;} GfuiMenuBarItmType type;
public IptKey Ipt() {return ipt;} public GfuiMenuBarItm Ipt_(IptKey val) {ipt = val; return this;} IptKey ipt;
public String TipText() {return tipText;} public GfuiMenuBarItm TipText_(String val) {tipText = val; return this;} private String tipText = "";
public ColorAdp ForeColor() {return foreColor;} public GfuiMenuBarItm ForeColor_(ColorAdp val) {foreColor = val; return this;} ColorAdp foreColor;
public ColorAdp BackColor() {return backColor;} public GfuiMenuBarItm BackColor_(ColorAdp val) {backColor = val; return this;} ColorAdp backColor;
public String FontFamily() {return fontFamily;} public GfuiMenuBarItm FontFamily_(String val) {fontFamily = val; return this;} private String fontFamily = "";
public float FontSize() {return fontSize;} public GfuiMenuBarItm FontSize_(float val) {fontSize = val; return this;} float fontSize = -1;
public FontStyleAdp FontStyle() {return fontStyle;} public GfuiMenuBarItm FontStyle_(FontStyleAdp val) {fontStyle = val; return this;} FontStyleAdp fontStyle;
public GfuiMenuBarItm OwnerItm() {return ownerItm;} public GfuiMenuBarItm OwnerItm_(GfuiMenuBarItm val) {ownerItm = val; return this;} GfuiMenuBarItm ownerItm;
public Object Under() {return under;}
void ExecProps() {
if (type == GfuiMenuBarItmType.Root) Exec_root();
else if (type == GfuiMenuBarItmType.Cmd) Exec_cmd();
else if (type == GfuiMenuBarItmType.Spr) Exec_spr();
else Exec_mnu();
}
void Exec_root() {
SetProps((JMenuBar)under);
}
void Exec_mnu() {
JMenu itm = new JMenu(text);
if (ownerItm.type == GfuiMenuBarItmType.Root)
((JMenuBar)ownerItm.Under()).add(itm);
else {
((JMenu)ownerItm.Under()).add(itm);
}
SetMnemonic(itm);
SetProps(itm);
under = itm;
}
void Exec_cmd() {
JMenuItem itm = new JMenuItem(text);
JMenu ownerMenu = ((JMenu)ownerItm.Under());
ownerMenu.add(itm);
itmCmd = GfuiMenuBarItmCmd.new_(this);
itm.addActionListener(itmCmd);
SetMnemonic(itm);
SetProps(itm);
under = itm;
}
void Exec_spr() {
JMenu ownerMenu = ((JMenu)ownerItm.Under());
JSeparator itm = new JSeparator();
ownerMenu.add(itm);
SetProps(itm);
under = itm;
}
void SetMnemonic(AbstractButton itm) {
char mnem = GetMnemonic(text, ipt);
if (mnem != '\0') itm.setMnemonic(mnem);
}
void SetProps(JComponent itm) {
if (backColor != null) itm.setBackground(ColorAdpCache._.GetNativeColor(backColor));
if (foreColor != null) itm.setForeground(ColorAdpCache._.GetNativeColor(foreColor));
itm.setFont(MakeFont(itm.getFont()));
if (String_.Len(tipText) > 0) itm.setToolTipText(tipText);
}
Font MakeFont(Font cur) {
if (fontFamily == null && fontStyle == null && fontSize == -1) return cur;
String family = fontFamily == null ? cur.getFamily() : fontFamily;
int style = fontStyle == null ? cur.getStyle() : fontStyle.Val();
int size = fontSize == -1 ? cur.getSize() : (int)fontSize;
return new Font(family, style, (int)size);
}
GfuiMenuBarItm Under_(Object o) {under = o; return this;}
char GetMnemonic(String text, IptKey ipt) {
if (ipt.Val() == IptKey_.None.Val()) return '\0';
String iptStr = ipt.XtoUiStr(); if (String_.Len(iptStr) > 1) return '\0';
return String_.CharAt(iptStr, 0);
}
GfuiMenuBarItmCmd itmCmd;
Object under;
public static GfoMsg CmdMsg(GfuiMenuBarItm itm) {
if (itm.cmd == null) throw Exc_.new_null("cmd was null for menu").Args_add("key", itm.key, "text", itm.text);
return gplx.gfml.GfmlDataNde.XtoMsgNoRoot(itm.cmd);
}
public static GfuiMenuBarItm new_() {return new GfuiMenuBarItm();}
public static GfuiMenuBarItm sub_(GfuiMenuBarItm owner) {
GfuiMenuBarItm rv = new_();
rv.ownerItm = owner;
rv.foreColor = owner.foreColor;
rv.backColor = owner.backColor;
rv.fontFamily = owner.fontFamily;
rv.fontSize = owner.fontSize;
rv.fontStyle = owner.fontStyle;
return rv;
}
public static GfuiMenuBarItm root_(Object underMenuBar) {
GfuiMenuBarItm rv = new GfuiMenuBarItm().Type_(GfuiMenuBarItmType.Root).Key_("root").Under_(underMenuBar);
return rv;
} GfuiMenuBarItm() {}
}
class GfuiMenuBarItmType {
public int Val() {return val;} int val;
public String Name() {return name;} private String name;
GfuiMenuBarItmType(int v, String n) {val = v; name = n; regy.Add(n, this);}
public static GfuiMenuBarItmType parse_(String raw) {
try {return (GfuiMenuBarItmType)regy.Get_by(raw);}
catch (Exception e) {Exc_.Noop(e); throw Exc_.new_parse("GfuiMenuBarItmType", raw);}
}
static Hash_adp regy = Hash_adp_.new_();
public static final GfuiMenuBarItmType Root = new GfuiMenuBarItmType(1, "root");
public static final GfuiMenuBarItmType Top = new GfuiMenuBarItmType(2, "top");
public static final GfuiMenuBarItmType Mnu = new GfuiMenuBarItmType(3, "mnu");
public static final GfuiMenuBarItmType Cmd = new GfuiMenuBarItmType(4, "cmd");
public static final GfuiMenuBarItmType Spr = new GfuiMenuBarItmType(5, "spr");
}
class GxwBorderFactory {
public static final javax.swing.border.Border Empty = new EmptyBorder(0, 0, 1, 0);
}
class GfuiMenuBarItmCmd implements ActionListener {
public void actionPerformed(ActionEvent ev) {
try {
GfsCore._.ExecOne(GfsCtx._, GfuiMenuBarItm.CmdMsg(itm));
}
catch (Exception e) {
GfuiEnv_.ShowMsg(Err_.Message_gplx(e));
}
}
public static GfuiMenuBarItmCmd new_(GfuiMenuBarItm itm) {
GfuiMenuBarItmCmd cmd = new GfuiMenuBarItmCmd();
cmd.itm = itm;
return cmd;
} GfuiMenuBarItm itm;
}

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 GfuiMenuFormUtl {
public static PointAdp CalcShowPos(RectAdp ownerRect, SizeAdp elemSize) {
//#if plat_wce
// int x = ownerRect.X() + ownerRect.Width() - elemSize.Width();
// int y = ownerRect.Y() + ownerRect.Height() - elemSize.Height();
//#else
int x = CursorAdp.Pos().X();
int y = CursorAdp.Pos().Y();
// check if entire elem fits inside owner at x,y; if not, align to ownerEdge
int ownerMinX = ownerRect.X();
int ownerMinY = ownerRect.Y();
int ownerMaxX = ownerRect.X() + ownerRect.Width();
int ownerMaxY = ownerRect.Y() + ownerRect.Height();
if (x < ownerMinX) x = ownerMinX;
if (y < ownerMinY) y = ownerMinY;
if (x + elemSize.Width() > ownerMaxX) x = ownerMaxX - elemSize.Width();
if (y + elemSize.Height() > ownerMaxY) y = ownerMaxY - elemSize.Height();
//#endif
return PointAdp_.new_(x, y);
}
}

View File

@@ -0,0 +1,36 @@
/*
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 GfuiQuitMode {
public int Val() {return val;} int val;
GfuiQuitMode(int val) {this.val = val;}
public static final GfuiQuitMode ExitApp = new GfuiQuitMode(1);
public static final GfuiQuitMode Destroy = new GfuiQuitMode(2);
public static final GfuiQuitMode Suspend = new GfuiQuitMode(3);
public static final String
Destroy_cmd = "destroy"
, Suspend_cmd = "suspend"
, SuspendApp_cmd = "suspendApp" // TODO: merge with suspend; needs Msg Addressing (*.suspend vs app.suspend)
;
public static void Exec(GfoInvkAble invk, GfuiQuitMode stopMode) {
int val = stopMode.Val();
if (val == GfuiQuitMode.Destroy.Val()) GfoInvkAble_.InvkCmd(invk, GfuiQuitMode.Destroy_cmd);
else if (val == GfuiQuitMode.Suspend.Val()) GfoInvkAble_.InvkCmd(invk, GfuiQuitMode.Suspend_cmd);
else if (val == GfuiQuitMode.ExitApp.Val()) GfuiEnv_.Exit();
}
}

View 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.*;
import javax.swing.JComponent;
import javax.swing.ToolTipManager;
class GfuiTipTextMgr implements GfuiWinOpenAble {
public void Open_exec(GfuiWin form, GfuiElemBase owner, GfuiElemBase sub) {
if (!(sub.underElem instanceof JComponent)) return;
if (String_.Eq(sub.TipText(), "")) return; // don't register components without tooltips; will leave blue dots (blue tool tip windows with 1x1 size)
JComponent jcomp = (JComponent)sub.underElem;
ToolTipManager.sharedInstance().registerComponent(jcomp);
ToolTipManager.sharedInstance().setInitialDelay(0);
ToolTipManager.sharedInstance().setDismissDelay(1000);
ToolTipManager.sharedInstance().setReshowDelay(0);
jcomp.setToolTipText(sub.TipText());
}
public static final GfuiTipTextMgr _ = new GfuiTipTextMgr();
}

View File

@@ -0,0 +1,123 @@
/*
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 java.awt.Window;
public class GfuiWin extends GfuiElemBase {
private GxwWin win; private List_adp loadList = List_adp_.new_();
public void Show() {win.ShowWin();}
public void Hide() {win.HideWin();}
public void Close() {win.CloseWin();}
public IconAdp Icon() {return win.IconWin();} public GfuiWin Icon_(IconAdp icon) {win.IconWin_set(icon); return this;}
public boolean Pin() {return win.Pin();} public GfuiWin Pin_(boolean v) {win.Pin_set(v); return this;}
public GfuiWin Pin_() {return Pin_(true);} public void Pin_toggle() {Pin_(!Pin());}
@gplx.Virtual public void Quit() {GfuiQuitMode.Exec(this, quitMode);}
public boolean Maximized() {return win.Maximized();} public void Maximized_(boolean v) {win.Maximized_(v);}
public boolean Minimized() {return win.Minimized();} public void Minimized_(boolean v) {win.Minimized_(v);}
public GfuiQuitMode QuitMode() {return quitMode;} public GfuiWin QuitMode_(GfuiQuitMode val) {quitMode = val; return this;} private GfuiQuitMode quitMode = GfuiQuitMode.ExitApp; // easier to debug
@Override public boolean Opened_done() {return opened;} private boolean opened;
@Override public GfuiWin OwnerWin() {return this;} // TODO: null
@gplx.Internal protected GfuiWinKeyCmdMgr KeyCmdMgr() {return keyCmdMgr;} private GfuiWinKeyCmdMgr keyCmdMgr = GfuiWinKeyCmdMgr.new_();
@gplx.Internal protected GfuiWinFocusMgr FocusMgr() {return focusMgr;} private GfuiWinFocusMgr focusMgr;
@gplx.New public GfuiWin Size_(SizeAdp size) {
super.Size_(size);
if (!opened && (size.Width() < 112 || size.Height() < 27)) // WORKAROUND/WINFORMS: Form.Size must be > 112,27 if Form is not Visible
smallOpenSize = size;
return this;
} private SizeAdp smallOpenSize = SizeAdp_.Null;
@Override public void ctor_kit_GfuiElemBase(Gfui_kit kit, String key, GxwElem underElem, KeyValHash ctorArgs) {
super.ctor_kit_GfuiElemBase(kit, key, underElem, ctorArgs);
win = (GxwWin)underElem;
win.OpenedCmd_set(GfoInvkAbleCmd.new_(this, Evt_Opened));
GfoEvMgr_.Sub(this, GfuiElemKeys.IptRcvd_evt, keyCmdMgr, GfuiWinKeyCmdMgr.CheckForHotKey_cmd);
IptBnd_.cmd_(IptCfg_.Null, this, StopAppByAltF4_evt, IptKey_.Alt.Add(IptKey_.F4));
// IptBnd_.cmd_to_(IptCfg_.Null, this, GfoConsoleWin._, GfoConsoleWin.Invk_Show, IptKey_.Ctrl.Add(IptKey_.Alt).Add(IptKey_.E));
IptBnd_.cmd_(IptCfg_.Null, this, Invk_ShowFocusOwner, IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.F12));
loadList.Add(keyCmdMgr); loadList.Add(GfuiTipTextMgr._);
focusMgr = GfuiWinFocusMgr.new_(this);
}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
win = (GxwWin)this.UnderElem();
win.OpenedCmd_set(GfoInvkAbleCmd.new_(this, Evt_Opened));
GfoEvMgr_.Sub(this, GfuiElemKeys.IptRcvd_evt, keyCmdMgr, GfuiWinKeyCmdMgr.CheckForHotKey_cmd);
IptBnd_.cmd_(IptCfg_.Null, this, StopAppByAltF4_evt, IptKey_.Alt.Add(IptKey_.F4));
IptBnd_.cmd_to_(IptCfg_.Null, this, GfoConsoleWin._, GfoConsoleWin.Invk_Show, IptKey_.Ctrl.Add(IptKey_.Alt).Add(IptKey_.E));
IptBnd_.cmd_(IptCfg_.Null, this, Invk_ShowFocusOwner, IptKey_.add_(IptKey_.Ctrl, IptKey_.Alt, IptKey_.F12));
loadList.Add(keyCmdMgr); loadList.Add(GfuiTipTextMgr._);
focusMgr = GfuiWinFocusMgr.new_(this);
}
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {
String type = (String)ctorArgs.FetchValOr(GfuiWin_.InitKey_winType, GfuiWin_.InitKey_winType_app);
if (String_.Eq(type, GfuiWin_.InitKey_winType_tool)) return GxwElemFactory_._.win_tool_(ctorArgs);
else if (String_.Eq(type, GfuiWin_.InitKey_winType_toaster)) return GxwElemFactory_._.win_toaster_(ctorArgs);
else return GxwElemFactory_._.win_app_();
}
@Override public void Opened_cbk() {
if (!smallOpenSize.Eq(SizeAdp_.Null)) super.Size_(smallOpenSize); // NOTE: call before opened = true, else Layout will happen again
opened = true;
GftGrid.LytExecRecur(this);
GfuiWinUtl.Open_exec(this, loadList, this);
GfuiFocusOrderer.OrderByX(this);
focusMgr.Init(this);
if (this.Kit().Tid() == Gfui_kit_.Swing_tid)
((Window)win).setFocusTraversalPolicy(new FocusTraversalPolicy_cls_base(focusMgr));
this.Focus();
super.Opened_cbk();
GfoEvMgr_.Pub(this, Evt_Opened);
}
@Override public boolean VisibleChangedCbk() {
boolean rv = super.VisibleChangedCbk();
GfoEvMgr_.PubVal(this, Evt_VisibleChanged, this.Visible());
return rv;
}
@Override public boolean DisposeCbk() {
GfuiWinUtl.SubElems_dispose(this);
return super.DisposeCbk();
}
public GfuiWin TaskbarVisible_(boolean val) {win.TaskbarVisible_set(val); return this;}
public void TaskbarParkingWindowFix(GfuiWin owner) {
if (Env_.Mode_testing()) return; // FIXME: owner.UnderElem will throw exception in MediaPlaylistMgr_tst; see note there
if (owner == null) return;
win.TaskbarParkingWindowFix(owner.UnderElem());
}
void StopAppByAltF4(IptEventData ipt) {
ipt.Handled_on(); // WORKAROUND/WINFORMS: must set Handled to true, or else WinForms.Form.Close() will be called
// GfoFwd_.Send_event(this, GfuiWin.Invk_Quit); // NOTE: no longer relying on Invk_Quit; // NOTE: must call send in order to execute other commands added to Cmds() (ex: DVD AppForm)
}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_Quit)) {Quit(); GfoEvMgr_.Pub(this, Evt_Quited);}
else if (ctx.Match(k, Invk_Zorder_front)) Zorder_front();
else if (ctx.Match(k, Invk_Minimize)) {win.Minimized_(true); return this;}
else if (ctx.Match(k, Invk_Pin_toggle)) Pin_toggle();
else if (ctx.Match(k, Invk_Show)) Show();
else if (ctx.Match(k, Evt_Opened)) Opened_cbk();
else if (ctx.Match(k, StopAppByAltF4_evt)) StopAppByAltF4(IptEventData.ctx_(ctx, m));
else if (ctx.Match(k, Invk_ShowFocusOwner)) GfuiEnv_.ShowMsg(GfuiFocusMgr._.FocusedElem().Key_of_GfuiElem());
else if (ctx.Match(k, GfuiStatusBoxBnd.Invk_ShowTime)) {UsrDlg_._.Note(UsrMsg.new_(DateAdp_.Now().toString())); return this;}
else if (ctx.MatchIn(k, Invk_Close, GfuiQuitMode.Destroy_cmd)) Close();
else if (ctx.MatchIn(k, Invk_Hide, GfuiQuitMode.Suspend_cmd)) Hide();
else {
Object rv = this.InvkMgr().Invk(ctx, ikey, k, m, this);
return (rv == GfoInvkCmdMgr.Unhandled) ? super.Invk(ctx, ikey, k, m) : rv;
}
return this;
} public static final String Invk_Show = "Show", Invk_Hide = "Hide", Invk_Close = "Close", Invk_Quit = "Quit", Invk_Minimize = "Minimize"
, Invk_Pin_toggle = "Pin_toggle", Invk_Zorder_front = "Zorder_front", Invk_ShowFocusOwner = "ShowFocusOwner"
, Evt_VisibleChanged = "VisibleChanged", Evt_Opened = "Opened_evt", Evt_Quited = "Quited_evt"
, StopAppByAltF4_evt = "StopAppByAltF4_evt";
}

View File

@@ -0,0 +1,136 @@
/*
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 java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
public class GfuiWinFocusMgr {
public List_adp SubElems() {return subElems;} List_adp subElems = List_adp_.new_();
public void InitForm() {this.Init(win);}
public void Init(GfuiWin win) {
subElems.Clear();
InitRecursive(win, 0);
}
int InitRecursive(GfuiElem owner, int focusIdx) {
for (int i = 0; i < owner.SubElems().Count(); i++) {
GfuiElem sub = (GfuiElem)owner.SubElems().Get_at(i);
if (sub.Focus_able()) {
sub.Focus_idx_(focusIdx++);
subElems.Add(sub);
}
focusIdx = InitRecursive(sub, focusIdx);
}
return focusIdx;
}
public GfuiElem Focus(boolean fwd, int cur) {
int nxt = fwd
? cur == subElems.Idx_last() ? 0 : ++cur
: cur == 0 ? subElems.Idx_last() : --cur;
GfuiElem elm = (GfuiElem)subElems.Get_at(nxt);
elm.Focus();
return elm;
}
GfuiWin win;
public static GfuiWinFocusMgr new_(GfuiWin win) {
GfuiWinFocusMgr rv = new GfuiWinFocusMgr();
rv.win = win;
return rv;
} GfuiWinFocusMgr() {}
}
class FocusTraversalPolicy_cls_base extends FocusTraversalPolicy {
List_adp elems; GfuiWinFocusMgr formFocusMgr;
public FocusTraversalPolicy_cls_base(GfuiWinFocusMgr formFocusMgr) {
this.elems = formFocusMgr.subElems;
this.formFocusMgr = formFocusMgr;
}
boolean elems_empty() {return elems.Count() == 0;}
public Component getComponentAfter(Container focusCycleRoot, Component c) {
formFocusMgr.InitForm();
if (elems_empty()) return c;
GxwElem gxw = GxwElemOf(c);
int orig = gxw.Core().Focus_index();
int idx = orig;
while (true) {
idx++;
if (idx == elems.Count())
idx = 0;
GfuiElem elem = null;
try {elem = (GfuiElem)elems.Get_at(idx);}
catch (Exception e) {
System.out.println(idx);
Exc_.Noop(e);
}
if (elem == null) return c; // FIXME: why is elem null?; REP: add new tab through history and then close out
if (elem.Focus_able() && elem.Visible()) {
if (elem.UnderElem() instanceof GxwTextMemo_lang) {
GxwTextMemo_lang xx = (GxwTextMemo_lang)elem.UnderElem();
return xx.Inner();
}
else
return (Component)elem.UnderElem();
}
if (idx == orig)
return c;
}
}
public Component getComponentBefore(Container focusCycleRoot, Component c) {
formFocusMgr.InitForm();
if (elems_empty()) return c;
GxwElem gxw = GxwElemOf(c);
int orig = gxw.Core().Focus_index();
int idx = orig;
while (true) {
idx--;
if (idx == -1)
idx = elems.Count() - List_adp_.Base1;
GfuiElem elem = null;
try {
elem = (GfuiElem)elems.Get_at(idx);
// System.out.println(elem.Key_of_GfuiElem() + " " + elem.Focus_able() + " " + elem.Visible());
if (elem.getClass().getName().equals("gplx.gfds.gbu.GbuGrid") && elem.Key_of_GfuiElem().equals("grid0")) {
System.out.println(elem.Key_of_GfuiElem() + " " + elem.Focus_able() + " " + elem.Visible());
System.out.println(elem);
}
}
catch (Exception e) {
System.out.println(idx);
Exc_.Noop(e);
}
if (elem == null) return c; // FIXME: why is elem null?; REP: add new tab through history and then close out
if (elem.Focus_able() && elem.Visible()) {
if (elem.UnderElem() instanceof GxwTextMemo_lang) {
GxwTextMemo_lang xx = (GxwTextMemo_lang)elem.UnderElem();
return xx.Inner();
}
else
return (Component)elem.UnderElem();
}
if (idx == orig)
return c;
}
}
public Component getDefaultComponent(Container focusCycleRoot) {return getFirstComponent(focusCycleRoot);}
public Component getFirstComponent(Container focusCycleRoot) {return elems_empty() ? focusCycleRoot : (Component)FetchAt(0).UnderElem();}
public Component getLastComponent(Container focusCycleRoot) {return elems_empty() ? focusCycleRoot : (Component)FetchAt(elems.Count() - 1).UnderElem();}
GfuiElem FetchAt(int idx) {return (GfuiElem)elems.Get_at(idx);}
GxwElem GxwElemOf(Component c) {
if (GxwElem.class.isAssignableFrom(c.getClass())) return (GxwElem)c;
return (GxwElem)c.getParent(); // HACK: occurs for JComboBox when editable is true; focus is on MetalComboBox, with parent of JComboBox
}
}
//#}

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.*;
import gplx.lists.*; /*Hash_adp_list*/
class GfuiWinKeyCmdMgr implements GfuiWinOpenAble, GfoInvkAble, GfoEvObj {
private Hash_adp_list listHash = Hash_adp_list.new_();
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} private GfoEvMgr evMgr;
public void Open_exec(GfuiWin form, GfuiElemBase owner, GfuiElemBase sub) {
int keyVal = sub.Click_key().Val(); if (sub.Click_key().Eq(IptKey_.None)) return;
listHash.AddInList(keyVal, sub);
listHash.AddInList(keyVal ^ IptKey_.Alt.Val(), sub);
}
public boolean CheckForHotKey(IptEventData iptData) {
if (iptData.EventType() != IptEventType_.KeyDown) return false; // NOTE: MouseClick sometimes will send key
int keyVal = iptData.Key().Val();
GfuiElem sender = GfuiElem_.as_(iptData.Sender());
if (GfuiTextBox_.as_(sender) != null // is sender textBox?
&& !Enm_.HasInt(keyVal, IptKey_.Alt.Val()) // does key not have alt
) return false; // ignore keys from textbox if they do not have alt
List_adp elemList = (List_adp)listHash.Get_by(keyVal); if (elemList == null) return false;
for (int i = 0; i < elemList.Count(); i++) {
GfuiElem elem = (GfuiElem)elemList.Get_at(i);
if (elem.Visible())
elem.Click();
}
return true;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
ctx.Match(k, k);
CheckForHotKey(IptEventData.ctx_(ctx, m));
//boolean handled = CheckForHotKey(IptEventData.cast_(msg.Val())); msg.Fwd_set(!handled); // TOMBSTONE: somehow cause alt-F4 to continue processing and dispose form
return this;
} @gplx.Internal protected static final String CheckForHotKey_cmd = "CheckForHotKey_cmd";
public static GfuiWinKeyCmdMgr new_() {return new GfuiWinKeyCmdMgr();} GfuiWinKeyCmdMgr() {}
public static int ExtractPosFromText(String raw) {
int pos = String_.FindFwd(raw, "&");
if (pos == String_.Find_none || pos == String_.Len(raw) - 1) return String_.Find_none; // & notFound or last char; return;
char nextChar = String_.CharAt(raw, pos + 1);
return Char_.IsLetterEnglish(nextChar) ? pos : String_.Find_none; // NOTE: .IsLetter checks against space; EX: "me & you" shouldn't bring back space
}
public static IptKey ExtractKeyFromText(String raw) {
int pos = ExtractPosFromText(raw); if (pos == String_.Find_none) return IptKey_.None;
return IptKey_.parse_("key." + String_.Lower(Char_.XtoStr(String_.CharAt(raw, pos + 1)))); // pos=& pos; + 1 to get next letter
}
}

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 GfuiWin_ {
public static final String
InitKey_winType = "winType"
, InitKey_winType_toaster = "toaster"
, InitKey_winType_app = "app"
, InitKey_winType_tool = "tool"
;
public static GfuiWin as_(Object obj) {return obj instanceof GfuiWin ? (GfuiWin)obj : null;}
public static GfuiWin cast_(Object obj) {try {return (GfuiWin)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfuiWin.class, obj);}}
public static GfuiWin app_(String key) {return bld_(key, InitKey_winType_app, KeyValHash.new_());}
public static GfuiWin tool_(String key) {return bld_(key, InitKey_winType_tool, KeyValHash.new_()).TaskbarVisible_(false);}
public static GfuiWin sub_(String key, GfuiWin ownerWin) {
KeyValHash ctorArgs = KeyValHash.new_();
if (ownerWin != null) ctorArgs.Add(GfuiElem_.InitKey_ownerWin, ownerWin); // WORKAROUND/JAVA: null ownerWin will fail when adding to hash
return bld_(key, InitKey_winType_tool, ctorArgs);
}
public static GfuiWin toaster_(String key, GfuiWin ownerWin) {return bld_(key, InitKey_winType_toaster, KeyValHash.new_().Add(GfuiElem_.InitKey_ownerWin, ownerWin));}
static GfuiWin bld_(String key, String winType, KeyValHash ctorArgs) {
GfuiWin rv = new GfuiWin();
rv.Key_of_GfuiElem_(key);
ctorArgs.Add(InitKey_winType, winType)
.Add(GfuiElem_.InitKey_focusAble, false);
rv.ctor_GfuiBox_base(ctorArgs);
return rv;
}
public static GfuiWin kit_(Gfui_kit kit, String key, GxwWin under, KeyValHash ctorArgs) {
GfuiWin rv = new GfuiWin();
rv.ctor_kit_GfuiElemBase(kit, key, under, ctorArgs);
return rv;
}
}
class GfuiWinUtl {
@gplx.Internal protected static void Open_exec(GfuiWin win, List_adp loadList, GfuiElemBase owner) {
for (int i = 0; i < owner.SubElems().Count(); i++) {
GfuiElemBase sub = (GfuiElemBase)owner.SubElems().Get_at(i);
sub.OwnerWin_(win);
for (Object itmObj : loadList) {
GfuiWinOpenAble itm = (GfuiWinOpenAble)itmObj;
itm.Open_exec(win, owner, sub);
}
Open_exec(win, loadList, sub);
}
}
@gplx.Internal protected static void SubElems_dispose(GfuiElem owner) {
for (int i = 0; i < owner.SubElems().Count(); i++) {
GfuiElem sub = (GfuiElem)owner.SubElems().Get_at(i);
sub.Dispose();
SubElems_dispose(sub);
}
}
}
interface GfuiWinOpenAble {
void Open_exec(GfuiWin win, GfuiElemBase owner, GfuiElemBase sub);
}

View File

@@ -0,0 +1,180 @@
/*
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 GfuiWin_toaster extends GfuiWin { public void ShowPopup(GfuiWin owner, String text, int interval) {
this.TaskbarParkingWindowFix(owner);
ShowPopup(text, interval);
}
void ShowPopup(String text, int interval) {
if (Env_.Mode_testing()) return;
messageLabel.Text_(text);
messageLabel.SelBgn_set(0);
InitVariables(500, interval * 1000, 500);
BeginPoppingUp();
}
void InitVariables(int growingArg, int fullyGrownArg, int timeForHidingArg) {
popupState = PopupState.FullyShrunk;
fullyGrownTimerInterval = fullyGrownArg;
int timerEvents = 0;
if (growingArg > 10) {
timerEvents = Math_.Min((growingArg / 10), fullyGrown.Height());
growingTimerInterval = growingArg / timerEvents;
growingIncrement = fullyGrown.Height() / timerEvents;
}
else {
growingTimerInterval = 10;
growingIncrement = fullyGrown.Height();
}
if( timeForHidingArg > 10) {
timerEvents = Math_.Min((timeForHidingArg / 10), fullyGrown.Height());
shrinkingTimerInterval = timeForHidingArg / timerEvents;
shrinkingIncrement = fullyGrown.Height() / timerEvents;
}
else {
shrinkingTimerInterval = 10;
shrinkingIncrement = fullyGrown.Height();
}
}
void BeginPoppingUp() {
RectAdp screenRect = ScreenAdp_.Primary.Rect();//WorkingArea
int screenX_max = screenRect.X() + screenRect.Width();
int val = popupState.Val();
if (val == PopupState.FullyShrunk.Val()) {
this.Size_(SizeAdp_.new_(this.Width(), 0));
this.Pos_(screenX_max / 2 - this.Width()/2, PopupAnchorTop); //screenRect.Bottom - 1
// gplx.gfui.npis.FormNpi.BringToFrontDoNotFocus(gplx.gfui.npis.ControlNpi.Hwnd(this.UnderElem()));
if (!this.Visible()) {
// GfuiElem last = GfuiFocusMgr._.FocusedElem();
this.Visible_on_();
// GfuiFocusMgr._.FocusedElem_set(last);
}
timer.Interval_(growingTimerInterval);
popupState = PopupState.Growing;
}
else if (val == PopupState.Growing.Val()) {
this.Redraw();
}
else if (val == PopupState.FullyGrown.Val()) {
timer.Interval_(fullyGrownTimerInterval);
this.Redraw();
}
else if (val == PopupState.Shrinking.Val()) {
this.Size_(SizeAdp_.new_(this.Width(), 0));
this.Pos_(screenX_max / 2 - this.Width()/2, PopupAnchorTop); //screenRect.Bottom - 1
timer.Interval_(fullyGrownTimerInterval);
popupState = PopupState.FullyGrown;
}
timer.Enabled_on();
}
// public override boolean FocusGotCbk() {
// GfuiElem last = GfuiFocusMgr._.FocusedElemPrev();
// GfuiFocusMgr._.FocusedElem_set(last);
// last.Focus();
// return false;
// }
void WhenTick() {
int fullHeight = fullyGrown.Height();
int val = popupState.Val();
if (val == PopupState.Growing.Val()) {
if (this.Height() < fullHeight)
ChangeBounds(true, growingIncrement);
else {
this.Height_(fullHeight);
timer.Interval_(fullyGrownTimerInterval);
popupState = PopupState.FullyGrown;
}
}
else if (val == PopupState.FullyGrown.Val()) {
timer.Interval_(shrinkingTimerInterval);
// if ((bKeepVisibleOnMouseOver && !bIsMouseOverPopup ) || (!bKeepVisibleOnMouseOver)) {
popupState = PopupState.Shrinking;
}
else if (val == PopupState.Shrinking.Val()) {
// if (bReShowOnMouseOver && bIsMouseOverPopup) {popupState = PopupState.Growing; break;}
if (this.Height() > 2) // NOTE.Val()) { does not shrink less than 2 //this.Top > screenRect.Bottom
ChangeBounds(false, shrinkingIncrement);
else {
// this.Pos_(-500, -500); // WORKAROUND:JAVA: cannot do this.Hide() b/c it will focus ownerForm; EX: typing in textApp when musicApp moves forward
this.Visible_off_();
popupState = PopupState.FullyShrunk;
timer.Enabled_off();
}
}
}
static final int PopupAnchorTop = -1; // HACK: wxp1 showed obvious flickering with top edge
void ChangeBounds(boolean isGrowing, int increment) {
increment = isGrowing ? increment : -increment;
this.Pos_(this.X(), PopupAnchorTop); //this.Top - increment
this.Size_(SizeAdp_.new_(this.Width(), this.Height() + increment));
}
@Override public GxwElem UnderElem_make(KeyValHash ctorArgs) {return GxwElemFactory_._.win_toaster_(ctorArgs);}
@Override public void ctor_GfuiBox_base(KeyValHash ctorArgs) {
super.ctor_GfuiBox_base(ctorArgs);
this.fullyGrown = SizeAdp_.new_(600, 96);
this.Pos_(-100, -100); this.Size_(fullyGrown); super.Show(); super.Hide();// was 20,20; set to fullyGrown b/c of java
messageLabel = GfuiTextBox_.multi_("messageLabel", this);
messageLabel.Size_(fullyGrown.Width(), fullyGrown.Height()).ForeColor_(ColorAdp_.Green);
messageLabel.TextMgr().Font_(FontAdp.new_("Arial", 8, FontStyleAdp_.Bold));
messageLabel.Border_on_(true);
messageLabel.Focus_able_(false);
// this.Focus_able_(false);
// this.UnderElem().Core().Focus_able_force_(false);
timer = TimerAdp.new_(this, Tmr_cmd, 3000, false);
GxwWin formRef = (GxwWin)this.UnderElem();
if (formRef != null) { // FIXME: nullCheck, needed for MediaPlaylistMgr_tst
formRef.Pin_set(true);
formRef.TaskbarVisible_set(false);
}
}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Tmr_cmd)) WhenTick();
else super.Invk(ctx, ikey, k, m);
return this;
} public static final String Tmr_cmd = "Tmr";
GfuiTextMemo messageLabel;
TimerAdp timer;
SizeAdp fullyGrown = SizeAdp_.Zero;
int growingIncrement, shrinkingIncrement;
int growingTimerInterval, shrinkingTimerInterval, fullyGrownTimerInterval;
PopupState popupState = PopupState.FullyShrunk;
public static GfuiWin_toaster new_(GfuiWin owner) {
GfuiWin_toaster rv = new GfuiWin_toaster();
// rv.Icon_(IconAdp.cfg_("popup"));
rv.ctor_GfuiBox_base
(KeyValHash.new_()
.Add(GfuiElem_.InitKey_focusAble, false)
.Add(GfuiElem_.InitKey_ownerWin, owner)
.Add(GfuiWin_.InitKey_winType, GfuiWin_.InitKey_winType_toaster)
);
return rv;
}
}
class PopupState {
public int Val() {return val;} int val;
public PopupState(int v) {this.val = v;}
public static final PopupState
FullyShrunk = new PopupState(1)
, Growing = new PopupState(2)
, FullyGrown = new PopupState(3)
, Shrinking = new PopupState(4)
;
}

View File

@@ -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; import gplx.*;
class GxwWinNpi {
}