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:
90
150_gfui/src_210_lyt/gplx/gfui/GftBand.java
Normal file
90
150_gfui/src_210_lyt/gplx/gfui/GftBand.java
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
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 GftBand {
|
||||
public String Key() {return key;} public GftBand Key_(String v) {key = v; return this;} private String key;
|
||||
public int Idx() {return idx;} public GftBand Idx_(int v) {idx = v; return this;} int idx;
|
||||
public GftSizeCalc Len1() {return len1;} public GftBand Len1_(GftSizeCalc v) {len1 = v; return this;} GftSizeCalc len1 = new GftSizeCalc_abs(20);
|
||||
public GftBand Len1_pct_(float val) {return Len1_(new GftSizeCalc_pct(val));}
|
||||
public GftBand Len1_abs_(int v) {return Len1_(new GftSizeCalc_abs(v));}
|
||||
public GftCell Cell_dfl() {return cell_dfl;} GftCell cell_dfl = new GftCell();
|
||||
public List_adp Cells() {return cells;} List_adp cells = List_adp_.new_();
|
||||
public GftBand Cells_var_(int count) {
|
||||
for (int i = 0; i < count; i++)
|
||||
cells.Add(new GftCell().Len0_(new GftSizeCalc_var(count)));
|
||||
return this;
|
||||
}
|
||||
public GftBand Cell_abs_(int val) {cells.Add(new GftCell().Len0_(new GftSizeCalc_abs(val))); return this;}
|
||||
public GftBand Cell_pct_(float val) {cells.Add(new GftCell().Len0_(new GftSizeCalc_pct(val))); return this;}
|
||||
public GftBand Cells_num_(int num) {
|
||||
cells.Clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
cells.Add(new GftCell().Len0_(new GftSizeCalc_num(num)));
|
||||
return this;
|
||||
}
|
||||
public List_adp Items() {return items;} List_adp items = List_adp_.new_();
|
||||
public void Items_add(GftItem item) {items.Add(item);}
|
||||
public void Calc(GftItem owner, int y, int h) {
|
||||
int x = 0;
|
||||
y = grid.Bands_dir().GetValByDir(y - h, y);
|
||||
int availX = owner.Gft_w();
|
||||
for (int i = 0; i < cells.Count(); i++) {
|
||||
GftCell cell = (GftCell)cells.Get_at(i);
|
||||
if (cell.Len0().Key() == GftSizeCalc_abs.KEY) {
|
||||
GftSizeCalc_abs calc = (GftSizeCalc_abs)cell.Len0();
|
||||
availX -= calc.Val();
|
||||
}
|
||||
else if (cell.Len0().Key() == GftSizeCalc_var.KEY) {
|
||||
if (i >= items.Count()) continue;
|
||||
GftItem item = (GftItem)items.Get_at(i);
|
||||
GfuiElem elem = GfuiElem_.as_(item);
|
||||
availX -= elem == null ? item.Gft_w() : elem.Width();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < items.Count(); i++) {
|
||||
GftItem item = (GftItem)items.Get_at(i);
|
||||
GftCell cell = i >= cells.Count() ? cell_dfl : (GftCell)cells.Get_at(i);
|
||||
int w = cell.Len0().Calc(grid, this, owner, item, availX);
|
||||
item.Gft_rect_(RectAdp_.new_(x, y, w, h));
|
||||
// Tfds.Write(item.Key_of_GfuiElem(), w, h, x, y);
|
||||
x += w;
|
||||
}
|
||||
this.items.Clear();
|
||||
}
|
||||
public GftBand Clone(GftGrid grid, int idx) {
|
||||
GftBand rv = new GftBand();
|
||||
rv.grid = grid;
|
||||
rv.key = key; rv.idx = idx; rv.cell_dfl = cell_dfl.Clone(); rv.len1 = this.len1.Clone();
|
||||
for (int i = 0; i < cells.Count(); i++) {
|
||||
GftCell cell = (GftCell)cells.Get_at(i);
|
||||
rv.cells.Add(cell.Clone());
|
||||
}
|
||||
return rv;
|
||||
} GftGrid grid;
|
||||
public static GftBand new_() {return new GftBand();} GftBand() {}
|
||||
public static GftBand fillWidth_() {
|
||||
GftBand rv = new GftBand();
|
||||
rv.Cells_num_(1);
|
||||
return rv;
|
||||
}
|
||||
public static GftBand fillAll_() {
|
||||
GftBand rv = new GftBand();
|
||||
rv.Cells_num_(1).Len1_pct_(100);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
112
150_gfui/src_210_lyt/gplx/gfui/GftBand_tst.java
Normal file
112
150_gfui/src_210_lyt/gplx/gfui/GftBand_tst.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class GftBand_tst {
|
||||
@Before public void setup() {
|
||||
fx.Clear().ini_OwnerSize(200, 400);
|
||||
} GftGrid_fx fx = new GftGrid_fx();
|
||||
@Test public void Bands_1() {
|
||||
fx .ini_AddItms(2)
|
||||
.ini_Set(0, GftBand.new_().Cells_num_(2))
|
||||
.run()
|
||||
.tst_Filter(0, 1).tst_X(0, 100).tst_W_all(100).tst_H_all(20).tst_Y_all(0);
|
||||
}
|
||||
@Test public void Bands_1_half() { // only add 1 to 2 cell-band
|
||||
fx .ini_AddItms(1)
|
||||
.ini_Set(0, GftBand.new_().Cells_num_(2))
|
||||
.run()
|
||||
.tst_Filter(0).tst_X(0).tst_W(100).tst_H(20).tst_Y(0);
|
||||
}
|
||||
@Test public void Bands_2() { // put cells 2, 3 on band 1
|
||||
fx .ini_AddItms(4)
|
||||
.ini_Set(0, GftBand.new_().Cells_num_(2))
|
||||
.ini_Set(1, GftBand.new_().Cells_num_(2))
|
||||
.run()
|
||||
.tst_Filter(0, 1).tst_X(0, 100).tst_W_all(100).tst_H_all(20).tst_Y_all(0)
|
||||
.tst_Filter(2, 3).tst_X(0, 100).tst_W_all(100).tst_H_all(20).tst_Y_all(20); // put on 2nd row
|
||||
}
|
||||
@Test public void Pct_one() {
|
||||
fx .ini_AddItms(1)
|
||||
.ini_Set(0, GftBand.new_().Cell_pct_(50))
|
||||
.run()
|
||||
.tst_Filter(0).tst_X(0).tst_W(100).tst_H_all(20).tst_Y_all(0);
|
||||
}
|
||||
@Test public void Pct_many() {
|
||||
fx .ini_AddItms(3)
|
||||
.ini_Set(0, GftBand.new_().Cell_pct_(20).Cell_pct_(70).Cell_pct_(10))
|
||||
.run()
|
||||
.tst_Filter(0, 2).tst_W(40, 140, 20).tst_X(0, 40, 180).tst_H_all(20).tst_Y_all(0);
|
||||
}
|
||||
@Test public void Mix_pctAtEnd() {
|
||||
fx .ini_AddItms(2)
|
||||
.ini_Set(0, GftBand.new_().Cell_abs_(60).Cell_pct_(100))
|
||||
.run()
|
||||
.tst_Filter(0, 1).tst_X(0, 60).tst_W(60, 140).tst_H_all(20).tst_Y_all(0);
|
||||
}
|
||||
@Test public void Mix_pctAtBgn() {
|
||||
fx .ini_AddItms(2)
|
||||
.ini_Set(0, GftBand.new_().Cell_pct_(100).Cell_abs_(60))
|
||||
.run()
|
||||
.tst_Filter(0, 1).tst_X(0, 140).tst_W(140, 60).tst_H_all(20).tst_Y_all(0);
|
||||
}
|
||||
@Test public void Mix_pctAtMid() {
|
||||
fx .ini_AddItms(3)
|
||||
.ini_Set(0, GftBand.new_().Cell_abs_(60).Cell_pct_(100).Cell_abs_(40))
|
||||
.run()
|
||||
.tst_Filter(0, 2).tst_X(0, 60, 160).tst_W(60, 100, 40).tst_H_all(20).tst_Y_all(0);
|
||||
}
|
||||
@Test public void Height_pct() {
|
||||
fx .ini_AddItms(1)
|
||||
.ini_Set(0, GftBand.new_().Cell_pct_(100).Len1_pct_(100))
|
||||
.run()
|
||||
.tst_Filter(0).tst_X(0).tst_W(200).tst_H_all(400).tst_Y_all(0);
|
||||
}
|
||||
@Test public void Height_mix() {
|
||||
fx .ini_AddItms(3)
|
||||
.ini_Set(0, GftBand.new_().Cells_num_(1).Len1_abs_( 60))
|
||||
.ini_Set(1, GftBand.new_().Cells_num_(1).Len1_pct_(100))
|
||||
.ini_Set(2, GftBand.new_().Cells_num_(1).Len1_abs_( 20))
|
||||
.run()
|
||||
.tst_Filter(0).tst_H( 60).tst_Y_all( 0).tst_X(0).tst_W(200)
|
||||
.tst_Filter(1).tst_H(320).tst_Y_all( 60).tst_X(0).tst_W(200)
|
||||
.tst_Filter(2).tst_H( 20).tst_Y_all(380).tst_X(0).tst_W(200);
|
||||
}
|
||||
@Test public void RevDir() {
|
||||
fx .ini_AddItms(2).ini_BandDir(DirInt.Bwd)
|
||||
.ini_Set(0, 1, GftBand.new_().Cells_num_(1).Len1_abs_(20))
|
||||
.run()
|
||||
.tst_Filter(0).tst_W(200).tst_H(20).tst_X(0).tst_Y(380)
|
||||
.tst_Filter(1).tst_W(200).tst_H(20).tst_X(0).tst_Y(360);
|
||||
}
|
||||
@Test public void SubLyts() {
|
||||
fx .ini_AddItms(2).ini_AddLyts(2)
|
||||
.ini_Lyt(0).ini_Set(0, GftBand.new_().Cells_num_(1).Len1_pct_(100))
|
||||
.ini_Lyt(1).ini_Set(0, GftBand.new_().Cells_num_(1).Len1_abs_( 20)).ini_BandDir(DirInt.Bwd)
|
||||
.run()
|
||||
.tst_Filter(0).tst_W(200).tst_H(400).tst_X(0).tst_Y( 0)
|
||||
.tst_Filter(1).tst_W(200).tst_H( 20).tst_X(0).tst_Y(380);
|
||||
}
|
||||
@Test public void Var() {
|
||||
fx .ini_AddItms(2)
|
||||
.ini_ItmWidth(0, 30).ini_ItmWidth(1, 40)
|
||||
.ini_Set(0, GftBand.new_().Cells_var_(2))
|
||||
.run()
|
||||
.tst_Filter(0, 1).tst_X(0, 30).tst_W(30, 40).tst_H_all(20).tst_Y_all(0);
|
||||
}
|
||||
}
|
||||
26
150_gfui/src_210_lyt/gplx/gfui/GftCell.java
Normal file
26
150_gfui/src_210_lyt/gplx/gfui/GftCell.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
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 GftCell {
|
||||
public GftSizeCalc Len0() {return len0;} public GftCell Len0_(GftSizeCalc c) {len0 = c; return this;} GftSizeCalc len0 = new GftSizeCalc_num(1);
|
||||
public GftCell Clone() {
|
||||
GftCell rv = new GftCell();
|
||||
rv.len0 = len0.Clone();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
138
150_gfui/src_210_lyt/gplx/gfui/GftGrid.java
Normal file
138
150_gfui/src_210_lyt/gplx/gfui/GftGrid.java
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
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 GftGrid {
|
||||
public String Key() {return key;} public GftGrid Key_(String v) {key = v; return this;} private String key;
|
||||
public List_adp Bands() {return bands;} List_adp bands = List_adp_.new_();
|
||||
public List_adp SubLyts() {return subLyts;} List_adp subLyts = List_adp_.new_();
|
||||
public void Clear() {bands.Clear(); subLyts.Clear(); bandDir = DirInt.Fwd;}
|
||||
public DirInt Bands_dir() {return bandDir;} public GftGrid Bands_dir_(DirInt v) {bandDir = v; return this;} DirInt bandDir = DirInt.Fwd;
|
||||
public GftGrid SubLyts_get(String key) {
|
||||
for (int i = 0; i < subLyts.Count(); i++) {
|
||||
GftGrid grid = (GftGrid)subLyts.Get_at(i);
|
||||
if (String_.Eq(key, grid.Key())) return grid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public GftBand Bands_get(String key) {
|
||||
for (int i = 0; i < bands.Count(); i++) {
|
||||
GftBand band = (GftBand)bands.Get_at(i);
|
||||
if (String_.Eq(key, band.Key())) return band;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public GftGrid Bands_add(GftBand band) {
|
||||
bands.Add(band.Clone(this, bands.Count()));
|
||||
return this;
|
||||
}
|
||||
public GftGrid Bands_add(int count, GftBand band) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
GftBand copy = band.Clone(this, bands.Count() + i);
|
||||
bands.Add(copy);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@gplx.Internal protected void Bands_delAt(int i) {bands.Del_at(i);}
|
||||
@gplx.Internal protected boolean Bands_has(String key) {return Bands_indexOf(key) != List_adp_.NotFound;}
|
||||
@gplx.Internal protected void Bands_del(String key) {
|
||||
int idx = Bands_indexOf(key);
|
||||
if (idx != List_adp_.NotFound) bands.Del_at(idx);
|
||||
}
|
||||
int Bands_indexOf(String key) {
|
||||
int curIdx = List_adp_.NotFound;
|
||||
for (int i = 0; i < bands.Count(); i++) {
|
||||
GftBand band = (GftBand)bands.Get_at(i);
|
||||
if (String_.Eq(key, band.Key())) {
|
||||
curIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return curIdx;
|
||||
}
|
||||
public GftGrid Bands_set(int idx, GftBand orig) {return Bands_set(idx, idx, orig);}
|
||||
public GftGrid Bands_set(int bgn, int end, GftBand orig) {
|
||||
int len = end - bgn + 1;
|
||||
for (int i = 0; i < len; i++) {
|
||||
GftBand copy = orig.Clone(this, bgn + i);
|
||||
bands.Add(copy);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public void Exec(GftItem owner, GftItem... ary) {
|
||||
ExecLyts(owner, ary);
|
||||
ExecBands(owner, ary);
|
||||
}
|
||||
void ExecLyts(GftItem owner, GftItem[] ary) {
|
||||
int idx = 0;
|
||||
for (int i = 0; i < subLyts.Count(); i++) {
|
||||
GftGrid subGrid = (GftGrid)subLyts.Get_at(i);
|
||||
GftItem[] subAry = new GftItem[subGrid.Bands_cellCount()];
|
||||
for (int j = 0; j < subAry.length; j++) {
|
||||
subAry[j] = ary[idx++];
|
||||
}
|
||||
subGrid.Exec(owner, subAry);
|
||||
}
|
||||
}
|
||||
void ExecBands(GftItem owner, GftItem[] ary) {
|
||||
if (bands.Count() == 0) return;
|
||||
int availY = owner.Gft_h();
|
||||
GftBand band = null;
|
||||
int bgn = bandDir.GetValByDir(bands.Idx_last(), 0);
|
||||
int end = bandDir.GetValByDir(-1, bands.Count());
|
||||
for (int i = bgn; i != end; i += bandDir.Val()) {
|
||||
band = (GftBand)bands.Get_at(i);
|
||||
if (band.Len1().Key() == GftSizeCalc_abs.KEY) {
|
||||
GftSizeCalc_abs calc = (GftSizeCalc_abs)band.Len1();
|
||||
availY -= calc.Val();
|
||||
}
|
||||
}
|
||||
int bandIdx = 0;
|
||||
band = (GftBand)bands.Get_at(bandIdx);
|
||||
band.Items().Clear();
|
||||
int y = bandDir.GetValByDir(owner.Gft_h(), 0);
|
||||
for (int itmIdx = 0; itmIdx < ary.length; itmIdx++) {
|
||||
GftItem itm = ary[itmIdx];
|
||||
if (band.Items().Count() >= band.Cells().Count()) {
|
||||
int h = band.Len1().Calc(this, band, owner, itm, availY);
|
||||
band.Calc(owner, y, h);
|
||||
y += h * bandDir.Val();
|
||||
if (bandIdx + 1 >= bands.Count()) throw Exc_.new_("error retrieving band", "owner", owner.Key_of_GfuiElem(), "item", itm.Key_of_GfuiElem(), "bandIdx", bandIdx + 1, "count", bands.Count());
|
||||
band = (GftBand)bands.Get_at(++bandIdx);
|
||||
band.Items().Clear();
|
||||
}
|
||||
band.Items_add(itm);
|
||||
}
|
||||
band.Calc(owner, y, band.Len1().Calc(this, band, owner, null, availY));
|
||||
}
|
||||
int Bands_cellCount() {
|
||||
int rv = 0;
|
||||
for (int i = 0; i < bands.Count(); i++) {
|
||||
GftBand band = (GftBand)bands.Get_at(i);
|
||||
rv += band.Cells().Count();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static GftGrid new_() {return new GftGrid();} GftGrid() {}
|
||||
public static void LytExecRecur(GfuiElemBase owner) {
|
||||
if (owner.Lyt() != null) owner.Lyt_exec();
|
||||
for (int i = 0; i < owner.SubElems().Count(); i++) {
|
||||
GfuiElemBase sub = (GfuiElemBase)owner.SubElems().Get_at(i);
|
||||
LytExecRecur(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
93
150_gfui/src_210_lyt/gplx/gfui/GftGrid_fx.java
Normal file
93
150_gfui/src_210_lyt/gplx/gfui/GftGrid_fx.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
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 GftGrid_fx {
|
||||
public GftItem Owner() {return owner;} GftItem owner;
|
||||
public GftGrid_fx Clear() {
|
||||
itms.Clear();
|
||||
grid.Clear();
|
||||
curGrid = grid;
|
||||
owner = new GftItem_mok();//.Key_("owner");
|
||||
return this;
|
||||
}
|
||||
public GftGrid_fx ini_AddItms(int num) {
|
||||
for (int i = 0; i < num; i++)
|
||||
itms.Add(new GftItem_mok());//.Key_("key" + Int_.Xto_str(i)));
|
||||
return this;
|
||||
}
|
||||
public GftGrid_fx ini_ItmWidth(int i, int width) {
|
||||
GftItem itm = (GftItem)itms.Get_at(i);
|
||||
itm.Gft_w_(width);
|
||||
return this;
|
||||
}
|
||||
public GftGrid_fx ini_AddLyts(int num) {
|
||||
for (int i = 0; i < num; i++) {
|
||||
GftGrid newGrid = GftGrid.new_();
|
||||
grid.SubLyts().Add(newGrid);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public GftGrid_fx ini_Lyt(int num) {
|
||||
curGrid = (GftGrid)grid.SubLyts().Get_at(num);
|
||||
return this;
|
||||
}
|
||||
public GftGrid_fx ini_BandDir(DirInt dir) {curGrid.Bands_dir_(dir); return this;}
|
||||
public GftGrid_fx ini_OwnerSize(int w, int h) {owner.Gft_w_(w); owner.Gft_h_(h); return this;}
|
||||
public GftGrid_fx ini_Set(int idx, GftBand orig) {return ini_Set(idx, idx, orig);}
|
||||
public GftGrid_fx ini_Set(int bgn, int end, GftBand orig) {curGrid.Bands_set(bgn, end, orig); return this;}
|
||||
public GftGrid_fx run() {
|
||||
GftItem[] ary = (GftItem[])itms.To_ary(GftItem.class);
|
||||
grid.Exec(owner, ary);
|
||||
return this;
|
||||
}
|
||||
public GftGrid_fx tst_Filter(int idx) {return tst_Filter(idx, idx);}
|
||||
public GftGrid_fx tst_Filter(int bgn, int end) {this.bgn = bgn; this.end = end; return this;} int bgn, end;
|
||||
public GftGrid_fx tst_W(int... expd) {return tst_ary("w", expd);}
|
||||
public GftGrid_fx tst_H(int... expd) {return tst_ary("h", expd);}
|
||||
public GftGrid_fx tst_X(int... expd) {return tst_ary("x", expd);}
|
||||
public GftGrid_fx tst_Y(int... expd) {return tst_ary("y", expd);}
|
||||
public GftGrid_fx tst_W_all(int expd) {return tst_all("w", expd);}
|
||||
public GftGrid_fx tst_H_all(int expd) {return tst_all("h", expd);}
|
||||
public GftGrid_fx tst_X_all(int expd) {return tst_all("x", expd);}
|
||||
public GftGrid_fx tst_Y_all(int expd) {return tst_all("y", expd);}
|
||||
GftGrid_fx tst_all(String name, int expdVal) {return tst_ary(name, rng_(expdVal, end - bgn + 1));}
|
||||
GftGrid_fx tst_ary(String name, int[] expd) {
|
||||
int len = end - bgn + 1;
|
||||
int[] actl = new int[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
GftItem itm = (GftItem)itms.Get_at(i + bgn);
|
||||
actl[i] = GetVal(itm, name);
|
||||
}
|
||||
Tfds.Eq_ary(expd, actl, name);
|
||||
return this;
|
||||
}
|
||||
int GetVal(GftItem item, String name) {
|
||||
if (String_.Eq(name, "x")) return item.Gft_x();
|
||||
else if (String_.Eq(name, "y")) return item.Gft_y();
|
||||
else if (String_.Eq(name, "w")) return item.Gft_w();
|
||||
else if (String_.Eq(name, "h")) return item.Gft_h();
|
||||
else throw Exc_.new_unhandled(name);
|
||||
}
|
||||
static int[] rng_(int expdVal, int len) {
|
||||
int[] rv = new int[len];
|
||||
for (int i = 0; i < len; i++) rv[i] = expdVal;
|
||||
return rv;
|
||||
}
|
||||
GftGrid grid = GftGrid.new_(), curGrid;
|
||||
List_adp itms = List_adp_.new_();
|
||||
}
|
||||
34
150_gfui/src_210_lyt/gplx/gfui/GftItem.java
Normal file
34
150_gfui/src_210_lyt/gplx/gfui/GftItem.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GftItem {
|
||||
String Key_of_GfuiElem();
|
||||
int Gft_h(); GftItem Gft_h_(int v);
|
||||
int Gft_w(); GftItem Gft_w_(int v);
|
||||
int Gft_x(); GftItem Gft_x_(int v);
|
||||
int Gft_y(); GftItem Gft_y_(int v);
|
||||
GftItem Gft_rect_(RectAdp rect);
|
||||
}
|
||||
class GftItem_mok implements GftItem {
|
||||
public String Key_of_GfuiElem() {return "null";}
|
||||
public int Gft_h() {return gft_h;} public GftItem Gft_h_(int v) {gft_h = v; return this;} int gft_h;
|
||||
public int Gft_w() {return gft_w;} public GftItem Gft_w_(int v) {gft_w = v; return this;} int gft_w;
|
||||
public int Gft_x() {return gft_x;} public GftItem Gft_x_(int v) {gft_x = v; return this;} int gft_x;
|
||||
public int Gft_y() {return gft_y;} public GftItem Gft_y_(int v) {gft_y = v; return this;} int gft_y;
|
||||
public GftItem Gft_rect_(RectAdp rect) {gft_x = rect.X(); gft_y = rect.Y(); gft_w = rect.Width(); gft_h = rect.Height(); return this;}
|
||||
}
|
||||
60
150_gfui/src_210_lyt/gplx/gfui/GftSizeCalc.java
Normal file
60
150_gfui/src_210_lyt/gplx/gfui/GftSizeCalc.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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 interface GftSizeCalc {
|
||||
int Key();
|
||||
int Calc(GftGrid grid, GftBand band, GftItem owner, GftItem item, int ownerWidth);
|
||||
GftSizeCalc Clone();
|
||||
}
|
||||
class GftSizeCalc_pct implements GftSizeCalc {
|
||||
public int Key() {return KEY;} public static final int KEY = 1;
|
||||
public float Val() {return pct;} float pct;
|
||||
public int Calc(GftGrid grid, GftBand band, GftItem owner, GftItem item, int ownerWidth) {
|
||||
return Int_.Mult(ownerWidth, pct / 100);
|
||||
}
|
||||
public GftSizeCalc Clone() {return new GftSizeCalc_pct(pct);}
|
||||
public GftSizeCalc_pct(float v) {pct = v;}
|
||||
}
|
||||
class GftSizeCalc_abs implements GftSizeCalc {
|
||||
public int Key() {return KEY;} public static final int KEY = 2;
|
||||
public int Val() {return abs;} int abs;
|
||||
public int Calc(GftGrid grid, GftBand band, GftItem owner, GftItem item, int ownerWidth) {
|
||||
return abs;
|
||||
}
|
||||
public GftSizeCalc Clone() {return new GftSizeCalc_abs(abs);}
|
||||
public GftSizeCalc_abs(int v) {abs = v;}
|
||||
}
|
||||
class GftSizeCalc_num implements GftSizeCalc {
|
||||
public int Key() {return KEY;} public static final int KEY = 3;
|
||||
public int Val() {return num;} int num;
|
||||
public int Calc(GftGrid grid, GftBand band, GftItem owner, GftItem item, int ownerWidth) {
|
||||
return owner.Gft_w() / num;
|
||||
}
|
||||
public GftSizeCalc Clone() {return new GftSizeCalc_num(num);}
|
||||
public GftSizeCalc_num(int num) {this.num = num;}
|
||||
}
|
||||
class GftSizeCalc_var implements GftSizeCalc {
|
||||
public int Key() {return KEY;} public static final int KEY = 4;
|
||||
public int Val() {return num;} int num;
|
||||
public int Calc(GftGrid grid, GftBand band, GftItem owner, GftItem item, int ownerWidth) {
|
||||
GfuiElem elem = GfuiElem_.as_(item);
|
||||
return elem == null ? item.Gft_w() : elem.Width();
|
||||
}
|
||||
public GftSizeCalc Clone() {return new GftSizeCalc_var(num);}
|
||||
public GftSizeCalc_var(int num) {this.num = num;}
|
||||
}
|
||||
Reference in New Issue
Block a user