mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Convert 'GUI - Window'
This commit is contained in:
@@ -28,7 +28,6 @@ public class Xoa_gui_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
this.app = app;
|
||||
this.browser_win = new Xog_win_itm(app, this);
|
||||
bnd_mgr = new Xog_bnd_mgr(browser_win);
|
||||
win_cfg = new Xocfg_win(app);
|
||||
html_mgr = new Xog_html_mgr(app);
|
||||
menu_mgr = new Xog_menu_mgr(this);
|
||||
search_cfg = new Srch_search_cfg(app);
|
||||
@@ -40,7 +39,7 @@ public class Xoa_gui_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
public Xog_bnd_mgr Bnd_mgr() {return bnd_mgr;} private Xog_bnd_mgr bnd_mgr;
|
||||
public Gfui_kit Kit() {return kit;} private Gfui_kit kit = Gfui_kit_.Mem();
|
||||
public Xog_cmd_mgr Cmd_mgr() {return cmd_mgr;} private Xog_cmd_mgr cmd_mgr = new Xog_cmd_mgr();
|
||||
public Xocfg_win Win_cfg() {return win_cfg;} private Xocfg_win win_cfg;
|
||||
public Xocfg_win Win_cfg() {return win_cfg;} private Xocfg_win win_cfg = new Xocfg_win();
|
||||
public Xog_layout Layout() {return layout;} private Xog_layout layout = new Xog_layout();
|
||||
public Xog_html_mgr Html_mgr() {return html_mgr;} private Xog_html_mgr html_mgr;
|
||||
public Srch_search_cfg Search_cfg() {return search_cfg;} private Srch_search_cfg search_cfg;
|
||||
@@ -66,6 +65,7 @@ public class Xoa_gui_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
, Gfo_log_.New_url(app.Fsys_mgr().Root_dir().GenSubDir_nest("user", "anonymous", "app", "tmp", "xolog"))
|
||||
, new gplx.core.logs.Gfo_log_itm_wtr__csv()));
|
||||
}
|
||||
win_cfg.Init_by_app(app);
|
||||
}
|
||||
public void Kit_(Gfui_kit kit) {
|
||||
this.kit = kit;
|
||||
|
||||
@@ -19,7 +19,18 @@ package gplx.xowa.guis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.gfui.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.standards.*;
|
||||
import gplx.xowa.users.*; import gplx.xowa.guis.views.*;
|
||||
public class Xog_resizer {
|
||||
public class Xog_resizer implements Gfo_invk {
|
||||
private Xog_win_itm win_itm;
|
||||
private String browser__adj_type = "none";
|
||||
private RectAdp browser__adj_rect = RectAdp_.Zero;
|
||||
public void Init_by_app(Xoa_app app, Xog_win_itm win_itm) {
|
||||
this.win_itm = win_itm;
|
||||
if (Op_sys.Cur().Tid_is_osx()) {
|
||||
browser__adj_type = "relative";
|
||||
browser__adj_rect = RectAdp_.new_(0, 0, 5, 30);
|
||||
}
|
||||
app.Cfg().Bind_many_app(this, Cfg__browser__adj_type, Cfg__browser__adj_rect);
|
||||
}
|
||||
public void Exec_win_resize(Xoae_app app, int main_w, int main_h) {
|
||||
Xog_layout layout = app.Gui_mgr().Layout();
|
||||
Xog_win_itm main_win = app.Gui_mgr().Browser_win();
|
||||
@@ -52,12 +63,13 @@ public class Xog_resizer {
|
||||
Exec_win_resize_elem(layout.Search_box() , search_box , new Rect_ref(0, 0, 190 , txt_dim ), url_exec_btn, Xog_resizer.Layout_right_top);
|
||||
Exec_win_resize_elem(layout.Search_exec_btn() , search_exec_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), search_box, Xog_resizer.Layout_right_top);
|
||||
Exec_win_resize_elem(layout.Html_box() , tab_mgr , new Rect_ref(0, 0, main_w , main_h + -(bar_dim * 2) - menu_bar_adj), go_bwd_btn, Xog_resizer.Layout_below_left); // -40:btn_dim(url bar) + btn_dim (find box)
|
||||
Xoc_layout_mgr layout_mgr = app.Usere().Cfg_mgr().Layout_mgr();
|
||||
switch (layout_mgr.Html_box_adj_type()) {
|
||||
case Xoc_layout_mgr.Html_box_adj_type_none_byte: break;
|
||||
case Xoc_layout_mgr.Html_box_adj_type_abs_byte: tab_mgr.Rect_set(layout_mgr.Html_box_adj_rect()); break;
|
||||
case Xoc_layout_mgr.Html_box_adj_type_rel_byte: tab_mgr.Rect_set(tab_mgr.Rect().Op_add(layout_mgr.Html_box_adj_rect())); break;
|
||||
if (String_.Eq(browser__adj_type, "none")) {}
|
||||
else if (String_.Eq(browser__adj_type, "absolute")) {
|
||||
if ( browser__adj_rect.Width() >= 320 // prevent unshowable window
|
||||
&& browser__adj_rect.Width() >= 320)
|
||||
tab_mgr.Rect_set(browser__adj_rect);
|
||||
}
|
||||
else if (String_.Eq(browser__adj_type, "relative")) tab_mgr.Rect_set(tab_mgr.Rect().Op_add(browser__adj_rect));
|
||||
Exec_win_resize_elem(layout.Find_close_btn() , find_close_btn , new Rect_ref(0, 0, btn_dim , btn_dim ), tab_mgr, Xog_resizer.Layout_below_left);
|
||||
Exec_win_resize_elem(layout.Find_box() , find_box , new Rect_ref(0, 0, 102 , txt_dim ), find_close_btn, Xog_resizer.Layout_right_top);
|
||||
find_box.Y_(tab_mgr.Y_max());
|
||||
@@ -74,6 +86,14 @@ public class Xog_resizer {
|
||||
GfuiElem_.Y_adj(btn_dif, find_fwd_btn, find_bwd_btn);
|
||||
}
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Cfg__browser__adj_type)) {browser__adj_type = m.ReadStr("v"); win_itm.Refresh_win_size();}
|
||||
else if (ctx.Match(k, Cfg__browser__adj_rect)) {browser__adj_rect = gplx.gfui.RectAdp_.parse_ws_(m.ReadStr("v")); win_itm.Refresh_win_size();}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Cfg__browser__adj_type = "xowa.gui.window.browser.adj_type", Cfg__browser__adj_rect = "xowa.gui.window.browser.adj_rect";
|
||||
|
||||
private static RectAdp Prv_elem_rect_initial = RectAdp_.Zero, Prv_elem_rect_win_7 = RectAdp_.new_(0, -1, 0, 0);
|
||||
private static void Exec_win_resize_elem(Xog_layout_box box, GfuiElem cur_elem, Rect_ref cur_elem_rect, GfuiElem prv_elem, byte layout) {Exec_win_resize_elem(box, cur_elem, cur_elem_rect, prv_elem.Rect(), layout);}
|
||||
private static void Exec_win_resize_elem(Xog_layout_box box, GfuiElem cur_elem, Rect_ref cur_elem_rect, RectAdp prv_elem_rect, byte layout) {
|
||||
|
||||
@@ -18,24 +18,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.guis.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.gfui.*; import gplx.gfui.draws.*;
|
||||
public class Xol_font_info implements Gfo_invk, Gfo_evt_mgr_owner {
|
||||
public Xol_font_info(String name, float size, FontStyleAdp style) {this.name = name; this.size = size; this.style = style;}
|
||||
public Gfo_evt_mgr Evt_mgr() {if (evt_mgr == null) evt_mgr = new Gfo_evt_mgr(this); return evt_mgr;} Gfo_evt_mgr evt_mgr;
|
||||
public String Name() {return name;} public Xol_font_info Name_(String v) {name = v; Font_changed_pub(); return this;} private String name;
|
||||
public float Size() {return size;} public Xol_font_info Size_(float v) {size = v; Font_changed_pub(); return this;} private float size;
|
||||
public FontStyleAdp Style() {return style;} public Xol_font_info Style_(FontStyleAdp v) {style = v; Font_changed_pub(); return this;} private FontStyleAdp style;
|
||||
public Xol_font_info CloneNew() {return new Xol_font_info(name, size, style);}
|
||||
public FontAdp XtoFontAdp() {return FontAdp.new_(name, size, style);}
|
||||
private FontStyleAdp style;
|
||||
public Xol_font_info(String name, float size, FontStyleAdp style) {
|
||||
this.name = name; this.size = size; this.style = style;
|
||||
}
|
||||
public Gfo_evt_mgr Evt_mgr() {if (evt_mgr == null) evt_mgr = new Gfo_evt_mgr(this); return evt_mgr;} private Gfo_evt_mgr evt_mgr;
|
||||
public String Name() {return name;} public Xol_font_info Name_(String v) {name = v; Font_changed_pub(); return this;} private String name;
|
||||
public float Size() {return size;} public Xol_font_info Size_(float v) {size = v; Font_changed_pub(); return this;} private float size;
|
||||
public FontAdp To_font() {return FontAdp.new_(name, size, style);}
|
||||
public boolean Eq(FontAdp font) {return String_.Eq(name, font.Name()) && size == font.Size() && style.Val() == font.Style().Val();}
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
app.Cfg().Bind_many_app(this, Cfg__font_name, Cfg__font_size);
|
||||
}
|
||||
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_name)) return name;
|
||||
else if (ctx.Match(k, Invk_name_)) Name_(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_size)) return size;
|
||||
else if (ctx.Match(k, Invk_size_)) Size_(m.ReadFloat("v"));
|
||||
else if (ctx.Match(k, Invk_style_)) Style_(FontStyleAdp_.parse(m.ReadStr("v")));
|
||||
if (ctx.Match(k, Cfg__font_name)) Name_(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Cfg__font_size)) Size_(m.ReadFloat("v"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_name = "name", Invk_name_ = "name_", Invk_size = "size", Invk_size_ = "size_", Invk_style_ = "style_";
|
||||
public static final String Font_changed = "font_changed";
|
||||
private void Font_changed_pub() {Gfo_evt_mgr_.Pub_obj(this, Font_changed, "font", this);}
|
||||
|
||||
private static final String Cfg__font_name = "xowa.gui.window.font.name";
|
||||
public static final String Cfg__font_size = "xowa.gui.window.font.size";
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
public Gfui_html Active_html_box() {return tab_mgr.Active_tab().Html_itm().Html_box();}
|
||||
public Xog_resizer Resizer() {return resizer;} private Xog_resizer resizer = new Xog_resizer();
|
||||
public Gfo_usr_dlg Usr_dlg() {return app.Usr_dlg();}
|
||||
public Xog_win_itm_cfg Cfg() {return cfg;} private final Xog_win_itm_cfg cfg = new Xog_win_itm_cfg();
|
||||
public void Refresh_win_size() {
|
||||
if (win_box != null) // NOTE: will be null when html box adjustment pref is set and application is starting
|
||||
resizer.Exec_win_resize(app, win_box.Width(), win_box.Height());
|
||||
@@ -93,7 +94,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
else if (ctx.Match(k, Invk_exit)) App__exit();
|
||||
else if (ctx.Match(k, Gfui_html.Evt_link_hover)) {
|
||||
if (this.Active_tab() != null) // NOTE: this.Active_tab() should not be null, but is null when running on raspberry pi; DATE:2016-09-23
|
||||
Xog_win_itm__prog_href_mgr.Hover(app, this.Active_tab().Wiki(), this.Active_page(), Xoh_href_gui_utl.Standardize_xowa_link(m.ReadStr("v")));
|
||||
Xog_win_itm__prog_href_mgr.Hover(app, cfg.Status__show_short_url(), this.Active_tab().Wiki(), this.Active_page(), Xoh_href_gui_utl.Standardize_xowa_link(m.ReadStr("v")));
|
||||
}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
@@ -289,7 +290,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
win_box = kit.New_win_app("win");
|
||||
sync_cmd = win_box.Kit().New_cmd_sync(this);
|
||||
Io_url img_dir = app.Fsys_mgr().Bin_xowa_file_dir().GenSubDir_nest("app.window");
|
||||
FontAdp ui_font = app.Gui_mgr().Win_cfg().Font().XtoFontAdp();
|
||||
FontAdp ui_font = app.Gui_mgr().Win_cfg().Font().To_font();
|
||||
go_bwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "go_bwd_btn", "go_bwd.png" );
|
||||
go_fwd_btn = Xog_win_itm_.new_btn(app, kit, win_box, img_dir, "go_fwd_btn", "go_fwd.png" );
|
||||
url_box = Xog_win_itm_.new_cbo(app, kit, win_box, ui_font, "url_box" , true);
|
||||
@@ -315,6 +316,8 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
if ( !Env_.Mode_testing()
|
||||
&& app.Mode().Tid_is_gui()) // only run for gui; do not run for tcp/http server; DATE:2014-05-03
|
||||
app.Usr_dlg().Gui_wkr_(new Gfo_usr_dlg__gui__swt(app, kit, prog_box, info_box, info_box));
|
||||
cfg.Init_by_app(app);
|
||||
resizer.Init_by_app(app, this);
|
||||
}
|
||||
public static String Remove_redirect_if_exists(String text) {
|
||||
// remove redirect target; EX: "A -> B" -> "A"
|
||||
|
||||
@@ -53,7 +53,7 @@ public class Xog_win_itm_ {
|
||||
public static void Font_update(Xog_win_itm win, Xol_font_info itm_font) {
|
||||
FontAdp gui_font = win.Url_box().TextMgr().Font();
|
||||
if (!itm_font.Eq(gui_font)) {
|
||||
FontAdp new_font = itm_font.XtoFontAdp();
|
||||
FontAdp new_font = itm_font.To_font();
|
||||
win.Url_box().TextMgr().Font_(new_font);
|
||||
win.Find_box().TextMgr().Font_(new_font);
|
||||
win.Prog_box().TextMgr().Font_(new_font);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xog_win_itm__prog_href_mgr {
|
||||
if (!String_.Eq(href, win.Prog_box().Text()))
|
||||
win.Usr_dlg().Prog_direct(href);
|
||||
}
|
||||
public static void Hover(Xoae_app app, Xowe_wiki wiki, Xoae_page page, String href) {
|
||||
public static void Hover(Xoae_app app, boolean show_status_url, Xowe_wiki wiki, Xoae_page page, String href) {
|
||||
Gfo_usr_dlg usr_dlg = app.Usr_dlg();
|
||||
if ( String_.Len_eq_0(href) // href is null / empty; occurs when hovering over empty space
|
||||
|| String_.Eq(href, "file:///")) {
|
||||
@@ -33,7 +33,6 @@ public class Xog_win_itm__prog_href_mgr {
|
||||
}
|
||||
Xoa_url url = Xoa_url.blank();
|
||||
app.Html__href_parser().Parse_as_url(url, Bry_.new_u8(href), wiki, page.Ttl().Page_txt());
|
||||
// Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(href));
|
||||
usr_dlg.Prog_direct(String_.new_u8(url.To_bry(!app.Api_root().Gui().Browser().Prog().Show_short_url(), Bool_.Y)));
|
||||
usr_dlg.Prog_direct(String_.new_u8(url.To_bry(!show_status_url, Bool_.Y)));
|
||||
}
|
||||
}
|
||||
|
||||
30
400_xowa/src/gplx/xowa/guis/views/Xog_win_itm_cfg.java
Normal file
30
400_xowa/src/gplx/xowa/guis/views/Xog_win_itm_cfg.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
public class Xog_win_itm_cfg implements Gfo_invk {
|
||||
public boolean Status__show_short_url() {return status__show_short_url;} private boolean status__show_short_url = true;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
app.Cfg().Bind_many_app(this, Cfg__status__show_short_url);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Cfg__status__show_short_url)) status__show_short_url = m.ReadYn("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Cfg__status__show_short_url = "xowa.gui.window.status.show_short_url";
|
||||
}
|
||||
Reference in New Issue
Block a user