*
* The MIT License (MIT)
*
- * Copyright (C) 2017 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*/
public class TScrollableWidget extends TWidget implements Scrollable {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* The horizontal scrollbar.
*/
*/
protected TVScroller vScroller = null;
- /**
- * Place the scrollbars on the edge of this widget, and adjust bigChange
- * to match the new size. This is called by onResize().
- */
- protected void placeScrollbars() {
- if (hScroller != null) {
- hScroller.setY(getHeight() - 1);
- hScroller.setWidth(getWidth() - 1);
- hScroller.setBigChange(getWidth() - 1);
- }
- if (vScroller != null) {
- vScroller.setX(getWidth() - 1);
- vScroller.setHeight(getHeight() - 1);
- vScroller.setBigChange(getHeight() - 1);
- }
- }
-
- /**
- * Recompute whatever data is displayed by this widget.
- */
- public void reflowData() {
- // Default: nothing to do
- }
-
- /**
- * Handle window/screen resize events.
- *
- * @param event resize event
- */
- @Override
- public void onResize(final TResizeEvent event) {
- if (event.getType() == TResizeEvent.Type.WIDGET) {
- setWidth(event.getWidth());
- setHeight(event.getHeight());
-
- reflowData();
- placeScrollbars();
- return;
- } else {
- super.onResize(event);
- }
- }
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Protected constructor.
super(parent, enabled, x, y, width, height);
}
+ // ------------------------------------------------------------------------
+ // TWidget ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Handle window/screen resize events.
+ *
+ * @param event resize event
+ */
+ @Override
+ public void onResize(final TResizeEvent event) {
+ if (event.getType() == TResizeEvent.Type.WIDGET) {
+ setWidth(event.getWidth());
+ setHeight(event.getHeight());
+
+ reflowData();
+ placeScrollbars();
+ return;
+ } else {
+ super.onResize(event);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // TScrollableWidget ------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Place the scrollbars on the edge of this widget, and adjust bigChange
+ * to match the new size. This is called by onResize().
+ */
+ protected void placeScrollbars() {
+ if (hScroller != null) {
+ hScroller.setY(getHeight() - 1);
+ hScroller.setWidth(getWidth() - 1);
+ hScroller.setBigChange(getWidth() - 1);
+ }
+ if (vScroller != null) {
+ vScroller.setX(getWidth() - 1);
+ vScroller.setHeight(getHeight() - 1);
+ vScroller.setBigChange(getHeight() - 1);
+ }
+ }
+
+ /**
+ * Recompute whatever data is displayed by this widget.
+ */
+ public void reflowData() {
+ // Default: nothing to do
+ }
+
/**
* Get the horizontal scrollbar, or null if this Viewport does not
* support horizontal scrolling.