ewe.ui
Class Canvas

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.Container
              extended byewe.ui.Canvas
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, ImageRefresher, IScroll, ScrollClient, TimerProc, UIConstants
Direct Known Subclasses:
ImageControl, Mosaic, PageDisplay, Panel, ScrollableHolder, TransparentPicker

public class Canvas
extends Container
implements ScrollClient

A Canvas is a general Control that is the best control to extend if you are designing a control that may be used as Container or that may need to be scrolled.


Field Summary
protected  boolean isFullScrollClient
          Overriding classes must set this true if the new class fully implements the ScrollClient interface (which Canvas does not).
 Point origin
          This is the origin for the Canvas.
 int scrollPercent
           
 Rect virtualSize
           
 
Fields inherited from class ewe.ui.Container
closedFocus, cycleFocus, dontAutoScroll, dontFocusOnChildren
 
Fields inherited from class ewe.ui.Control
_debug, backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, DoPaintMethod, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, foreGround, haveNativePaint, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, MyClass, name, next, np, parent, penStatus, popupSound, popupSoundClip, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, standardBorder, standardEdge, startDragResolution, tags, tail, text, toolTip, width, x, y
 
Fields inherited from class ewe.ui.ControlBase
clipItems, clipObject, clipOwner, curPoint, currentPenEvent, debugControl, debugFlag, DidHoldDown, doubleBuffer, doubleClickTime, firstPress, globalDrawFlat, globalEditable, globalEnabled, globalPalmStyle, globalSmallControls, GotPenDown, PenIsOn, pressPoint, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed, useNativeTextInput
 
Fields inherited from interface ewe.ui.IScroll
Higher, Horizontal, Lower, OPTION_INDICATOR_ONLY, PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTo, Vertical
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Fields inherited from interface ewe.fx.ImageRefresher
KEEP_VISIBLE
 
Constructor Summary
Canvas()
           
 
Method Summary
 boolean canGo(int orientation, int direction, int position)
           
 boolean canScreenScroll()
          This should return true if pixel scrolling of the on-screen data is allowed.
 void checkScrolls()
           
 void doBorder(Graphics g)
           
 void doScroll(int which, int action, int value)
           
 void fixOrigin()
           
 int getActual(int which)
           
 Image getBuffer()
           
 int getCurrent(int which)
           
 Dimension getDisplayedSize(Dimension dest)
           
 Dimension getMySize(Dimension dest)
           
protected  int getPercent(int size, int percent, int minimum)
           
 ScrollablePanel getScrollablePanel()
          Return a ScrollablePanel (usually a ScrollBarPanel) which contains this Control.
 ScrollClient getScrollClient()
          Return a fully implemented ScrollClient for this Control.
 int getVisible(int which, int forSize)
           
 Rect getVisibleArea(Rect dest)
           
 boolean needScrollBar(int which, int forSize)
           
 void onScroll(int movedX, int movedY)
           
 void onSetOrigin()
           
 void reduceClip(Graphics g, Rect r)
           
 boolean scroll(int dx, int dy)
          Scroll the panel - this does not update the ScrollBars.
 boolean scroll(int dx, int dy, Point moved)
          Scroll the panel and save in moved, the amount of distance moved in x and y.
 boolean scrollToVisible(int x, int y, int width, int height)
           
 boolean setOrigin(int nx, int ny, Point moved)
           
 void updateScrollServer(int which)
           
 
Methods inherited from class ewe.ui.Container
_paintChildren, add, addDirectly, containerHasFocus, dismantle, dismantle, doHotKey, findChild, focusFirst, focusFirst, focusOnContainer, focusOnData, getChildren, getChildrenBackwards, getFirstFocus, getNextKeyFocus, gotFocus, lostFocus, remove, removeAll, repaintDataNow, takeFocus, takePromptControl
 
Methods inherited from class ewe.ui.Control
acceptsData, activate, addListener, addTimer, amOnTopFrame, calculateSizes, calculateTextSize, cancelCut, cancelHoldDown, canEdit, chainDataChange, change, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkPenTransparent, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createGraphics, dataAccepted, dataBeingRemoved, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, dataTransferCancelled, deactivate, defaultTo, doAction, doActionKey, doBackground, doMenu, dontAcceptDrop, doPaint, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doPaintData, doShowMenu, dragged, exitEntry, fillBackground, formClosing, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getBackground, getClipboardMenu, getClipObject, getControlBuffer, getControlBuffer, getDataRect, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFont, getFontMetrics, getFontMetrics, getForeground, getFrame, getFrameOrContainer, getGraphics, getImage, getLastSelected, getLocation, getMaximumSize, getMenu, getMinimumSize, getModifiers, getNext, getParent, getPasswordCharacter, getPosInFrame, getPosInParent, getPreferredSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getSubControls, getTag, getText, getToolTip, getWindow, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, make, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onControlEvent, onEvent, onKeyEvent, onLabelPenEvent, onPaint, onPenEvent, paintBackground, paintChildren, penClicked, penDoubleClicked, penHeld, penPressed, penReleased, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, postEvent, recalculatePreferredSize, redisplay, refresh, removeListener, removeTimer, repaint, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetRect, resizeTo, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, setText, setTextSize, setToolTip, show, shown, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, startDragging, stopDragging, takeData, takeFromClipboard, testDim, ticked, toClipboard, toField, toField, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryNext, tryStartMenu, updateData, willAcceptDrop, willShowFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 
Methods inherited from interface ewe.ui.ScrollClient
getServer, setServer
 

Field Detail

virtualSize

public Rect virtualSize

origin

public Point origin
This is the origin for the Canvas. If it is null then it should be considered to be (0,0)


scrollPercent

public int scrollPercent

isFullScrollClient

protected boolean isFullScrollClient
Overriding classes must set this true if the new class fully implements the ScrollClient interface (which Canvas does not).

Constructor Detail

Canvas

public Canvas()
Method Detail

getDisplayedSize

public Dimension getDisplayedSize(Dimension dest)

getMySize

public Dimension getMySize(Dimension dest)

getBuffer

public Image getBuffer()

reduceClip

public void reduceClip(Graphics g,
                       Rect r)

getVisibleArea

public Rect getVisibleArea(Rect dest)

fixOrigin

public void fixOrigin()

onScroll

public void onScroll(int movedX,
                     int movedY)

onSetOrigin

public void onSetOrigin()

setOrigin

public boolean setOrigin(int nx,
                         int ny,
                         Point moved)

getVisible

public int getVisible(int which,
                      int forSize)
Specified by:
getVisible in interface ScrollClient

getActual

public int getActual(int which)
Specified by:
getActual in interface ScrollClient

getCurrent

public int getCurrent(int which)
Specified by:
getCurrent in interface ScrollClient

needScrollBar

public boolean needScrollBar(int which,
                             int forSize)
Specified by:
needScrollBar in interface ScrollClient

canGo

public boolean canGo(int orientation,
                     int direction,
                     int position)
Specified by:
canGo in interface ScrollClient

checkScrolls

public void checkScrolls()

updateScrollServer

public void updateScrollServer(int which)

scroll

public boolean scroll(int dx,
                      int dy,
                      Point moved)
Scroll the panel and save in moved, the amount of distance moved in x and y. Scroll the panel - this does not update the ScrollBars. To do so you should call checkScrolls().

Parameters:
dx - The x distance to move.
dy - The y distance to move.
moved - The actual x and y distance moved. This may be different to dx and dy since the the Canvas may limit the location the origin can actually be.
Returns:
true if a scroll was done, false if not.

canScreenScroll

public boolean canScreenScroll()
This should return true if pixel scrolling of the on-screen data is allowed.


scroll

public boolean scroll(int dx,
                      int dy)
Scroll the panel - this does not update the ScrollBars. To do so you should call checkScrolls().

Parameters:
dx - The x distance to move.
dy - The y distance to move.
Returns:
true if a scroll was done, false if not.

getPercent

protected int getPercent(int size,
                         int percent,
                         int minimum)

doScroll

public void doScroll(int which,
                     int action,
                     int value)
Specified by:
doScroll in interface ScrollClient

doBorder

public void doBorder(Graphics g)
Overrides:
doBorder in class Control

getScrollClient

public ScrollClient getScrollClient()
Return a fully implemented ScrollClient for this Control. This will return this Control if it fully implements ScrollClient otherwise it will return a ScrollableHolder containing this Control.


getScrollablePanel

public ScrollablePanel getScrollablePanel()
Return a ScrollablePanel (usually a ScrollBarPanel) which contains this Control.


scrollToVisible

public boolean scrollToVisible(int x,
                               int y,
                               int width,
                               int height)
Overrides:
scrollToVisible in class Container