ewe.ui
Class ControlPopupForm

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.Container
              extended byewe.ui.Canvas
                  extended byewe.ui.Panel
                      extended byewe.ui.CellPanel
                          extended byewe.ui.FormBase
                              extended byewe.ui.Form
                                  extended byewe.ui.ControlPopupForm
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, HasProperties, ImageRefresher, IScroll, LayoutManager, PopupController, ScrollClient, TimerProc, UIConstants
Direct Known Subclasses:
DateChooserPopup, DateUpDownInput.DateUpDownInputPopup, FontUpDownChooser.FontUpDownChooserPopup, InputForm, InputKeyPad, InputPopupForm, SinglePressKeyPad, TimeUpDownInput.TimeUpDownInputPopup

public abstract class ControlPopupForm
extends Form
implements PopupController

This class is used to implement a special, perhaps complex, Control which is popped up when another control is activated. For example, the DataDisplayInput control pops up a DateChooserPopup Form.

Generally you would call "attachTo()" to associate a ControlPopupForm with a Control. By default, the onEvent() method of the ControlPopupForm will listen for a ControlEvent.PRESSED event generated by the attached Control and then display itself when it is detected.

Note that a single ControlPopupForm can be attached to more than one Control. If any of the Controls is pressed, the Form will call setFor(Control who) for that particular control and then display itself.

A ControlPopupForm displays itself in a borderless Frame and modifies itself to be Flat. You will need to inherit from ControlPopupForm and add the necessary controls for whatever type of input you wish.

To close the Form simply call exit(IDOK) or exit(IDCANCEL) whenever data entry is complete. You should also then transfer (if necessary) data to the control to which the form was popped up for.


Field Summary
protected  WeakSet attachedTo
           
 Control client
          This is the client that popped up this control.
 boolean closeIfPressClient
          Normally, pressing outside the popup Form has no effect, but if this is true, then if you press the original client Control, then the popup Form will close with exit code IDCANCEL.
 boolean putByClient
          This tells the Form to place itself as close by the client as possible.
 
Fields inherited from class ewe.ui.Form
acceptsDroppedFiles, apply, back, buttons, BUTTONS_TO_SOFT_KEY_FIRST_BUTTON_SEPARATE, BUTTONS_TO_SOFT_KEY_MENU_ALWAYS, BUTTONS_TO_SOFT_KEY_USE_FIRST_SOFT_KEY, buttonsPanel, buttonsPerRow, cancel, deflt, dismantleOnClose, exitButtonDefined, exitSystemOnClose, exitValue, firstFocus, formFrame, globalIcon, handle, hasTopBar, keepFrame, moveable, no, noBorder, ok, pl, reset, resizable, resizeOnSIP, taskbarIcon, title, titleCancel, titleControls, titleOK, topControls, untitledTitle, windowFlagsToClear, windowFlagsToSet, windowIcon, windowTitle, yes
 
Fields inherited from class ewe.ui.FormBase
BACKB, CANCELB, close, cross, defaultShowOptions, DEFCANCELB, DEFOKB, EXIT_IDBACK, EXIT_IDCANCEL, EXIT_IDNO, EXIT_IDOK, EXIT_IDYES, IDBACK, IDCANCEL, IDNO, IDOK, IDYES, MBB, MBNONE, MBOK, MBOKCANCEL, MBYESNO, MBYESNOCANCEL, NOB, OKB, stop, tick, tools, YESB
 
Fields inherited from class ewe.ui.CellPanel
autoSpan, equalHeights, equalWidths, layout, mySplitter, nextSplitter, quickRecalculate
 
Fields inherited from class ewe.ui.Panel
all, backgroundImage, calculated, childListeners, defaultAddToMeCellConstraints, defaultTags, grid, lastAdded, layoutManager, made, noInsets, stretchFirstColumn, stretchFirstRow, stretchLastColumn, stretchLastRow, titleGap
 
Fields inherited from class ewe.ui.Canvas
isFullScrollClient, origin, scrollPercent, 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.PopupController
CLOSE_FOR_NEW_POPUP, FLAG_NEW_POPUP_IS_MENU
 
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.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.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
ControlPopupForm()
           
 
Method Summary
protected  void addCloseControls()
           
protected  void addCloseControls(Panel dest)
           
protected  Control addMainControls(Control main)
           
 void attachTo(Control who)
          Attach the popup form to the specified Control.
protected  Rect checkSize(Rect intended, boolean willFit)
          This method is called if the putByClient method is true.
 void close(int value)
          This closes the form unconditionally and sets the exitValue to be exitCode.
 void closePopup(int why, int flags)
          This closes the form by exiting with exit code IDCANCEL.
 void detachFrom(Control who)
          Detach the popup form from the specified Control.
protected  void doClear()
          By default this does nothing.
protected  void doInit()
          This is called after the call to popup().
protected  void doReset()
          This should reset the Form for input.
 FormFrame makeFrame(int options)
          This is used to actually create the frame for the form.
 void onControlEvent(ControlEvent ev)
          This listens for ControlEvent.PRESSED events from attached controls and calls setFor(Control who) if it detects that event.
 void onKeyEvent(KeyEvent ev)
          If the Form gets an IKeys.ESCAPE key press it will close the popup with an exit code of IDCANCEL.
protected  void popup()
          This does the work of positioning and displaying the Form.
protected  void pressedOutside(Point whereOnScreen)
           
 void setFor(Control who)
          Calling this will set the client for the Form and then causes the form to be displayed via the popup() method.
protected  void startingInput(Control who)
          This is called by setFor(Control who) and gives you an opportunity to modify the Form based on the client control.
protected  void transferToClient(Control client)
          This is called if the exit value of the Form is IDOK - it is used to indicate that data should be transferred to the client control if necessary.
 
Methods inherited from class ewe.ui.Form
_getSetField, addButton, addTabbedPanel, addToolbar, buttonsToMenu, buttonsToSoftKeyBar, buttonsToSoftKeyBar, cancelWait, canExit, checkButtons, closeAll, closeForTransfer, closeForTransfer, continueWait, createMenuItem, createMenuItem, createMenuItem, createWindow, defaultTitleTo, dismantle, doButtons, doShowExec, exec, exec, exec, exec, exec, exec, exec, exec, exec, execute, execute, execute, exit, filesDropped, formClosing, formShown, gatherButtons, getButton, getFirstFocus, getFormFrame, getProperties, getSoftKeyBarFor, getTopmostForm, handleAction, handleAction, hasExitButton, make, makeButtonForForm, makeButtonForForm, makeDefaultButton, makeDefaultButton, makeMenuItemForForm, makeMenuItemForForm, makeSoftKeys, makeSoftKeys, mb, menuItemSelected, modifyForSmartPhone, onDataChangeEvent, onEvent, onSoftKey, placeCancelOnLeft, removeSoftKeyBarFor, setOKCancel, setSoftKeyBarFor, setSoftKeyBarForAll, setTitle, setTopLevelTitle, setupFrame, show, show, show, show, show, show, shown, showWait, stopFormHandle, toolsOnBottom, waitUntilClosed, waitUntilClosed, waitUntilClosed, waitUntilClosed, waitUntilPainted
 
Methods inherited from class ewe.ui.CellPanel
calculateSizes, makeLayoutGrid, relayout, relayoutMe, removeAll, reShow, resize, resizeTo
 
Methods inherited from class ewe.ui.Panel
add, addChildListener, addDirectly, addLast, addLast, addNext, addNext, addNext, doBackground, doBorder, endRow, getControlTag, getPreferredSize, getSubControls, isEmpty, layout, remove, removeChildListener, sendToChildListeners, setText
 
Methods inherited from class ewe.ui.Canvas
canGo, canScreenScroll, checkScrolls, doScroll, fixOrigin, getActual, getBuffer, getCurrent, getDisplayedSize, getMySize, getPercent, getScrollablePanel, getScrollClient, getVisible, getVisibleArea, needScrollBar, onScroll, onSetOrigin, reduceClip, scroll, scroll, scrollToVisible, setOrigin, updateScrollServer
 
Methods inherited from class ewe.ui.Container
_paintChildren, add, containerHasFocus, dismantle, doHotKey, findChild, focusFirst, focusFirst, focusOnContainer, focusOnData, getChildren, getChildrenBackwards, getNextKeyFocus, gotFocus, lostFocus, repaintDataNow, takeFocus, takePromptControl
 
Methods inherited from class ewe.ui.Control
acceptsData, activate, addListener, addTimer, amOnTopFrame, 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, doMenu, dontAcceptDrop, doPaint, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doPaintData, doShowMenu, dragged, exitEntry, fillBackground, 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, getTag, getText, getToolTip, getWindow, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, 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, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, setTextSize, setToolTip, show, 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

putByClient

public boolean putByClient
This tells the Form to place itself as close by the client as possible. It is true by default.


closeIfPressClient

public boolean closeIfPressClient
Normally, pressing outside the popup Form has no effect, but if this is true, then if you press the original client Control, then the popup Form will close with exit code IDCANCEL. This is true by default.


client

public Control client
This is the client that popped up this control.


attachedTo

protected WeakSet attachedTo
Constructor Detail

ControlPopupForm

public ControlPopupForm()
Method Detail

attachTo

public void attachTo(Control who)
Attach the popup form to the specified Control.


detachFrom

public void detachFrom(Control who)
Detach the popup form from the specified Control.


pressedOutside

protected void pressedOutside(Point whereOnScreen)

onControlEvent

public void onControlEvent(ControlEvent ev)
This listens for ControlEvent.PRESSED events from attached controls and calls setFor(Control who) if it detects that event. This will prompt the Form to display itself and take input.

Overrides:
onControlEvent in class Form

startingInput

protected void startingInput(Control who)
This is called by setFor(Control who) and gives you an opportunity to modify the Form based on the client control.

Parameters:
who - The new client control.

doReset

protected void doReset()
This should reset the Form for input. It is called by default by doInit() and by default does nothing.


doInit

protected void doInit()
This is called after the call to popup(). By default it simply calls doReset().


doClear

protected void doClear()
By default this does nothing.


setFor

public void setFor(Control who)
Calling this will set the client for the Form and then causes the form to be displayed via the popup() method. Before calling popup() it calls startingInput() and after popup() it calls doInit().


makeFrame

public FormFrame makeFrame(int options)
Description copied from class: Form
This is used to actually create the frame for the form. The implementation of this is simply: {return new FormFrame(this,options);} but it can be overridden to return a different FormFrame.

Overrides:
makeFrame in class Form

closePopup

public void closePopup(int why,
                       int flags)
This closes the form by exiting with exit code IDCANCEL.

Specified by:
closePopup in interface PopupController
Parameters:
why - the reason for closing. This is one of the CLOSE_FOR_xxx values.
flags - any of the FLAG_xxx values ORed together.

popup

protected void popup()
This does the work of positioning and displaying the Form.


onKeyEvent

public void onKeyEvent(KeyEvent ev)
If the Form gets an IKeys.ESCAPE key press it will close the popup with an exit code of IDCANCEL.

Note that to get a key press you will probably have to do: modifyAll(SendUpKeyEvents,true) on this Form so that child controls send up key events that they do not handle.

Overrides:
onKeyEvent in class Control

checkSize

protected Rect checkSize(Rect intended,
                         boolean willFit)
This method is called if the putByClient method is true. The intended Rect is set to be the location and size that the Form would prefer to be. The willFit parameter tells if the intended Rect will actuall fit in the parent Window (the window containing the client control). This gives the Form an opportunity to modify itself if it is determined that it cannot fit in the Window. The Form can then return a new (probably smaller) Rect that WILL fit in the parent Window, which will then be used to locate the Frame containing the Form.

Generally if willFit is true, you should simply return the intended Rect. By default if willFit is false, the Form is resized to fit into the window.

Parameters:
intended - The Rect specifying the preferred location and size of the Form.
willFit - true if the intended Rect fits in the Window, false if it does not.
Returns:
either the intended Rect or a new Rect.

addCloseControls

protected void addCloseControls(Panel dest)

addCloseControls

protected void addCloseControls()

addMainControls

protected Control addMainControls(Control main)

close

public void close(int value)
Description copied from class: Form
This closes the form unconditionally and sets the exitValue to be exitCode.

Overrides:
close in class Form

transferToClient

protected void transferToClient(Control client)
This is called if the exit value of the Form is IDOK - it is used to indicate that data should be transferred to the client control if necessary.

Parameters:
client - the client control for the Popup form.