1 package be
.nikiroo
.fanfix
.reader
.tui
;
3 import jexer
.TApplication
;
4 import jexer
.THScroller
;
6 import jexer
.TScrollableWindow
;
7 import jexer
.TVScroller
;
10 public class TSimpleScrollableWindow
extends TScrollableWindow
{
11 protected TPanel mainPane
;
12 private int prevHorizontal
= -1;
13 private int prevVertical
= -1;
15 public TSimpleScrollableWindow(TApplication application
, String title
,
16 int width
, int height
) {
17 this(application
, title
, width
, height
, 0, 0, 0);
20 public TSimpleScrollableWindow(TApplication application
, String title
,
21 int width
, int height
, int flags
) {
22 this(application
, title
, width
, height
, flags
, 0, 0);
25 // 0 = none (so, no scrollbar)
26 public TSimpleScrollableWindow(TApplication application
, String title
,
27 int width
, int height
, int flags
, int realWidth
, int realHeight
) {
28 super(application
, title
, width
, height
, flags
);
30 mainPane
= new TPanel(this, 0, 0, width
, 80) {
33 for (TWidget children
: mainPane
.getChildren()) {
34 int y
= children
.getY() + children
.getHeight();
35 int x
= children
.getX() + children
.getWidth();
36 boolean visible
= (y
> getVerticalValue())
37 && (x
> getHorizontalValue());
38 children
.setVisible(visible
);
45 // for (int i = 0; i < 80; i++) {
46 // mainPane.addLabel("ligne " + i, i, i);
49 setRealWidth(realWidth
);
50 setRealHeight(realHeight
);
55 * The main pane on which you can add other widgets for this scrollable
58 * @return the main pane
60 public TPanel
getMainPane() {
64 public void setRealWidth(int realWidth
) {
66 if (hScroller
!= null) {
70 if (hScroller
== null) {
71 // size/position will be fixed by placeScrollbars()
72 hScroller
= new THScroller(this, 0, 0, 10);
74 hScroller
.setRightValue(realWidth
);
80 public void setRealHeight(int realHeight
) {
81 if (realHeight
<= 0) {
82 if (vScroller
!= null) {
86 if (vScroller
== null) {
87 // size/position will be fixed by placeScrollbars()
88 vScroller
= new TVScroller(this, 0, 0, 10);
90 vScroller
.setBottomValue(realHeight
);
97 public void reflowData() {
99 reflowData(getHorizontalValue(), getVerticalValue());
102 protected void reflowData(int totalX
, int totalY
) {
104 mainPane
.setX(-totalX
);
105 mainPane
.setY(-totalY
);
110 if (prevHorizontal
!= getHorizontalValue()
111 || prevVertical
!= getVerticalValue()) {
112 prevHorizontal
= getHorizontalValue();
113 prevVertical
= getVerticalValue();