public class Window extends ContentPanel implements ActivateEvent.HasActivateHandlers<Window>, DeactivateEvent.HasDeactivateHandlers<Window>, MaximizeEvent.HasMaximizeHandlers, MinimizeEvent.HasMinimizeHandlers, RestoreEvent.HasRestoreHandlers
A specialized content panel intended for use as an application window.
Code snippet:
Window w = new Window();
w.setHeading("Product Information");
w.setModal(true);
w.setPixelSize(600, 400);
w.setMaximizable(true);
w.setToolTip("The GXT product page...");
w.setWidget(new Frame("http://www.sencha.com/products/gxt"));
w.show();
In this case, the window contains a single Frame widget, as specified in the call to setWidget
. To
display multiple widgets, use setWidget to add a container to the window and then add widgets to the container. Once
the window is shown, if you add or remove widgets from the container, be sure to invoke ContentPanel.forceLayout()
to
instruct the window to update its layout.
The Component.setPixelSize(int, int)
method specifies the size of the window. This size, adjusted for the frame and
heading, is propagated to the window's content. If the content is a ResizeContainer
like
VerticalLayoutContainer
the container lays out the children and propagates the size to them, in a top-down
fashion, as specified by the child's LayoutData
.
Alternatively, either dimension in the call to setPixelSize
may be specified as -1. This enables auto
sizing for that dimension. Auto sizing is generally used with a container that is not a ResizeContainer
,
like FlowLayoutContainer
. In this case the children determine their own size and this determines the size
of the window, in a bottom-up fashion.
To configure auto size for a particular dimension, you must also set the minimum size for that dimension to zero and turn off the resizable property so that the user cannot resize the window (which would turn auto size off). For example, to auto size both the width and the height, set the following window properties as indicated:
w.setPixelSize(-1, -1);
w.setMinWidth(0);
w.setMinHeight(0);
w.setResizable(false);
Note: even with auto size configured, you must still invoke ContentPanel.forceLayout()
as described above if you add or
remove widgets from a container that is displayed in a window. Failure to do so may result in unexpected visual
effects, such as an incomplete window shadow or buttons that are not positioned correctly. Furthermore, you must
ensure that the size of the window cannot grow beyond the viewport (e.g. the browser window).
Modifier and Type | Class and Description |
---|---|
protected class |
Window.DefaultWindowMessages |
static interface |
Window.WindowAppearance |
static interface |
Window.WindowMessages |
ContentPanel.ContentPanelAppearance, ContentPanel.ContentPanelMessages, ContentPanel.DefaultContentPanelMessages, ContentPanel.PanelHeaderAppearance
Modifier and Type | Field and Description |
---|---|
protected int |
ariaMoveResizeDistance |
protected ToolButton |
closeBtn |
protected Draggable |
dragger |
protected WindowManager |
manager |
protected boolean |
removeFromParentOnHide |
protected ToolButton |
restoreBtn |
buttonBar, header, secondPassRequired
resize, widget
forceLayoutCommand, forceLayoutOnResize, hadLayoutRunning, layoutCommand, layoutRequiredThisEventLoop, layoutRunning
adjustSize, allowTextSelection, cacheSizes, disableContextMenu, disabled, disabledStyle, ensureVisibilityOnSizing, height, hidden, lastSize, layer, left, mask, maskMessage, monitorWindowResize, pageX, pageY, shim, tabIndex, toolTip, toolTipConfig, top, width, windowResizeDelay, windowResizeTask
Constructor and Description |
---|
Window()
Creates a new window with the default appearance.
|
Window(Window.WindowAppearance appearance)
Creates a new window with the specified appearance.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addActivateHandler(ActivateEvent.ActivateHandler<Window> handler)
Adds a
ActivateEvent handler. |
HandlerRegistration |
addDeactivateHandler(DeactivateEvent.DeactivateHandler<Window> handler)
Adds a
DeactivateEvent handler. |
HandlerRegistration |
addMaximizeHandler(MaximizeEvent.MaximizeHandler handler)
Adds a
MaximizeEvent handler. |
HandlerRegistration |
addMinimizeHandler(MinimizeEvent.MinimizeHandler handler)
Adds a
MinimizeEvent handler. |
HandlerRegistration |
addRestoreHandler(RestoreEvent.RestoreHandler handler)
Adds a
RestoreEvent.RestoreHandler handler for RestoreEvent events. |
protected void |
afterShow() |
void |
alignTo(Element elem,
Style.AnchorAlignment alignment,
int offsetX,
int offsetY)
Aligns the window to the specified element.
|
void |
center()
Centers the window in the viewport.
|
protected Layer |
createGhost() |
protected void |
doFocus() |
protected void |
doLayout() |
protected void |
fitContainer() |
void |
focus()
Focus the window.
|
Window.WindowAppearance |
getAppearance()
Gets a reference to the appearance this object was instantiated with
|
boolean |
getConstrain()
Returns true if the window is constrained.
|
Element |
getContainer()
Returns the windows's container element.
|
Draggable |
getDraggable()
Returns the window's draggable instance.
|
Widget |
getFocusWidget()
Returns the focus widget.
|
int |
getMinHeight()
Returns the minimum height.
|
int |
getMinWidth()
Returns the minimum width.
|
protected ModalPanel |
getModalPanel() |
Resizable |
getResizable()
Returns the window's resizable instance.
|
protected Window.WindowMessages |
getWindowMessages()
Returns the window messages.
|
protected Layer |
ghost() |
void |
hide()
Hide this widget.
|
protected void |
initTools() |
boolean |
isAutoHide()
Returns true if auto hide is enabled.
|
boolean |
isBlinkModal()
Returns true if modal blinking is enabled.
|
boolean |
isClosable()
Returns true if the window is closable.
|
boolean |
isDraggable()
Returns true if the panel is draggable.
|
boolean |
isMaximizable()
Returns true if window maximizing is enabled.
|
boolean |
isMaximized()
Returns true if the window is maximized.
|
boolean |
isMinimizable()
Returns true if window minimizing is enabled.
|
boolean |
isModal()
Returns true if modal behavior is enabled.
|
boolean |
isOnEsc()
Returns true if the window is closed when the esc key is pressed.
|
boolean |
isResizable()
Returns true if window resizing is enabled.
|
void |
maximize()
Fits the window within its current container and automatically replaces the 'maximize' tool button with the
'restore' tool button.
|
void |
minimize()
Placeholder method for minimizing the window.
|
protected void |
onAfterFirstAttach()
Called immediately after the first time the widget becomes attached to the browser's document only the first time.
|
void |
onBrowserEvent(Event event) |
protected void |
onDetach() |
protected void |
onDragCancel(DragCancelEvent event) |
protected void |
onDragEnd(DragEndEvent de) |
protected void |
onDragMove(DragMoveEvent de) |
protected void |
onDragStart(DragStartEvent de) |
protected void |
onEndResize(ResizeEndEvent re) |
protected void |
onKeyPress(Event event) |
protected void |
onStartResize(ResizeStartEvent re) |
protected void |
onWindowResize(int width,
int height) |
void |
restore()
Restores a maximized window back to its original size and position prior to being maximized and also replaces the
'restore' tool button with the 'maximize' tool button.
|
void |
setActive(boolean active)
Makes this the active window by showing its shadow, or deactivates it by hiding its shadow.
|
void |
setAutoHide(boolean autoHide)
True to hide the window when the user clicks outside of the window's bounds (defaults to false, pre-render).
|
void |
setBlinkModal(boolean blinkModal)
True to blink the window when the user clicks outside of the windows bounds (defaults to false).
|
void |
setClosable(boolean closable)
True to display the 'close' tool button and allow the user to close the window, false to hide the button and
disallow closing the window (default to true).
|
void |
setConstrain(boolean constrain)
True to constrain the window to the
XDOM.getViewportSize() , false to allow it to fall outside of the
Viewport (defaults to true). |
void |
setContainer(Element container)
Sets the container element to be used to size and position the window when maximized.
|
void |
setDraggable(boolean draggable)
True to enable dragging of this Panel (defaults to false).
|
void |
setFocusWidget(Widget focusWidget)
Widget to be given focus when the window is focused).
|
void |
setMaximizable(boolean maximizable)
True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button and
disallow maximizing the window (defaults to false).
|
void |
setMinHeight(int minHeight)
The minimum height in pixels allowed for this window (defaults to 100).
|
void |
setMinimizable(boolean minimizable)
True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button and
disallow minimizing the window (defaults to false).
|
void |
setMinWidth(int minWidth)
The minimum width in pixels allowed for this window (defaults to 200).
|
void |
setModal(boolean modal)
True to make the window modal and mask everything behind it when displayed, false to display it without restricting
access to other UI elements (defaults to false).
|
void |
setOnEsc(boolean onEsc)
True to close the window when the escape key is pressed (defaults to true).
|
void |
setPagePosition(int x,
int y)
Sets the page XY position of the widget.
|
void |
setPosition(int left,
int top)
Sets the left and top of the widget.
|
void |
setResizable(boolean resizable)
True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
|
void |
setWindowMessages(Window.WindowMessages windowMessages)
Sets the window messages.
|
void |
setZIndex(int zIndex)
Sets the z-index for the window.
|
void |
show()
Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
|
protected void |
showWindow(boolean show) |
void |
toBack()
Sends this window to the back of (lower z-index than) any other visible windows.
|
void |
toFront()
Brings this window to the front of any other visible windows.
|
protected void |
unghost(DragEndEvent de) |
addBeforeCollapseHandler, addBeforeExpandHandler, addButton, addCollapseHandler, addExpandHandler, addTool, adjustBodySize, afterCollapse, afterExpand, collapse, doAttachChildren, doDetachChildren, doLayoutButtonBar, expand, forceLayout, getAnimationDuration, getBody, getButtonAlign, getButtonBar, getContainerTarget, getFrameSize, getHeader, getHeading, getMessages, getMinButtonWidth, isAnimCollapse, isCollapsed, isCollapsible, isExpanded, isHideCollapseTool, isTitleCollapse, layoutBars, onClick, onCollapse, onDisable, onEnable, onExpand, onResize, setAnimationDuration, setAnimCollapse, setBodyBorder, setBodyStyle, setBodyStyleName, setButtonAlign, setCollapsible, setExpanded, setHeaderVisible, setHeading, setHideCollapseTool, setMessages, setMinButtonWidth, setTitleCollapse
add, add, getWidget, isResize, onRemove, setElement, setResize, setWidget, setWidget
applyLayout, applyLayout, forceLayoutOnChildren, forceLayoutOnChildren, getLeftRightMargins, getParentLayoutWidget, getSideMargins, getTopBottomMargins, isLayoutRunning, isOrWasLayoutRunning, isWidgetVisible, onBeforeDoLayout, onLoad, onResize
addAddHandler, addBeforeAddHandler, addBeforeRemoveHandler, addContainerHandler, addRemoveHandler, adjustIndex, adopt, checkIndexBoundsForInsertion, clear, disable, doPhysicalAttach, doPhysicalDetach, enable, ensureGroupingHandlerRegistration, findWidget, getChildren, getItemByItemId, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, iterator, onInsert, onWidgetHide, onWidgetShow, orphan, remove, remove, remove
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addGestureRecognizer, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleDependentName, addStyleOnOver, adjustPosition, adjustSize, applyState, assertAfterRender, assertPreRender, blur, clearSizeCache, disableContextMenu, disableEvents, enableEvents, fireCancellableEvent, fireEvent, getData, getElement, getFocusEl, getFocusSupport, getGestureRecognizer, getGestureRecognizerCount, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getPositionEl, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hideShadow, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, notifyHide, notifyShow, onAttach, onBlur, onFocus, onHide, onHideContextMenu, onPosition, onRightClick, onShow, onShowContextMenu, onTouch, onUnload, removeStyleDependentName, removeStyleOnOver, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setMonitorWindowResize, setPixelSize, setShadow, setShadowPosition, setSize, setStateful, setStateId, setStyleDependentName, setTabIndex, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, sync, syncSize, unmask
protected Draggable dragger
protected WindowManager manager
protected ToolButton restoreBtn
protected ToolButton closeBtn
protected int ariaMoveResizeDistance
protected boolean removeFromParentOnHide
public Window()
public Window(Window.WindowAppearance appearance)
appearance
- the window appearancepublic HandlerRegistration addActivateHandler(ActivateEvent.ActivateHandler<Window> handler)
ActivateEvent.HasActivateHandlers
ActivateEvent
handler.addActivateHandler
in interface ActivateEvent.HasActivateHandlers<Window>
handler
- the handlerpublic HandlerRegistration addDeactivateHandler(DeactivateEvent.DeactivateHandler<Window> handler)
DeactivateEvent.HasDeactivateHandlers
DeactivateEvent
handler.addDeactivateHandler
in interface DeactivateEvent.HasDeactivateHandlers<Window>
handler
- the handlerpublic HandlerRegistration addMaximizeHandler(MaximizeEvent.MaximizeHandler handler)
MaximizeEvent.HasMaximizeHandlers
MaximizeEvent
handler.addMaximizeHandler
in interface MaximizeEvent.HasMaximizeHandlers
handler
- the handlerpublic HandlerRegistration addMinimizeHandler(MinimizeEvent.MinimizeHandler handler)
MinimizeEvent.HasMinimizeHandlers
MinimizeEvent
handler.addMinimizeHandler
in interface MinimizeEvent.HasMinimizeHandlers
handler
- the handlerpublic HandlerRegistration addRestoreHandler(RestoreEvent.RestoreHandler handler)
RestoreEvent.HasRestoreHandlers
RestoreEvent.RestoreHandler
handler for RestoreEvent
events.addRestoreHandler
in interface RestoreEvent.HasRestoreHandlers
handler
- the handlerpublic void alignTo(Element elem, Style.AnchorAlignment alignment, int offsetX, int offsetY)
elem
- the element to align to.alignment
- the position to align to (see XElement.alignTo(Element, com.sencha.gxt.core.client.Style.AnchorAlignment, int, int)
for more details)offsetX
- X offsetoffsetY
- Y offsetpublic void center()
public void focus()
public Window.WindowAppearance getAppearance()
ContentPanel
getAppearance
in class ContentPanel
public boolean getConstrain()
public Element getContainer()
public Draggable getDraggable()
public Widget getFocusWidget()
public int getMinHeight()
public int getMinWidth()
public Resizable getResizable()
public void hide()
Component
public boolean isAutoHide()
public boolean isBlinkModal()
public boolean isClosable()
public boolean isDraggable()
public boolean isMaximizable()
public boolean isMaximized()
public boolean isMinimizable()
public boolean isModal()
public boolean isOnEsc()
public boolean isResizable()
public void maximize()
public void minimize()
public void onBrowserEvent(Event event)
onBrowserEvent
in class ContentPanel
public void restore()
public void setActive(boolean active)
active
- true to make the window activepublic void setAutoHide(boolean autoHide)
autoHide
- true for auto hidepublic void setBlinkModal(boolean blinkModal)
blinkModal
- true to blinkpublic void setClosable(boolean closable)
closable
- true to enable closingpublic void setConstrain(boolean constrain)
XDOM.getViewportSize()
, false to allow it to fall outside of the
Viewport (defaults to true). Note, when using window.getDraggable().setContainer(container) will override
setConstrain(false) and constrain the window to the container given during dragging.constrain
- true to constrain, otherwise falsepublic void setContainer(Element container)
container
- the container elementpublic void setDraggable(boolean draggable)
draggable
- the draggable to statepublic void setFocusWidget(Widget focusWidget)
focusWidget
- the focus widgetpublic void setMaximizable(boolean maximizable)
maximizable
- the maximizable statepublic void setMinHeight(int minHeight)
minHeight
- the min heightpublic void setMinimizable(boolean minimizable)
minimizable
- true to enabled minimizingpublic void setMinWidth(int minWidth)
minWidth
- the minimum heightpublic void setModal(boolean modal)
modal
- true for modalpublic void setOnEsc(boolean onEsc)
ContentPanel.setCollapsible(boolean)
is true.onEsc
- true to close window on escape key presspublic void setPagePosition(int x, int y)
Component
Component.setPosition(int, int)
.setPagePosition
in class Component
x
- the x coordinatey
- the y coordinatepublic void setPosition(int left, int top)
Component
Component.setPagePosition(int, int)
.setPosition
in class Component
left
- the new lefttop
- the new toppublic void setResizable(boolean resizable)
resizable
- true to enabled resizingpublic void setWindowMessages(Window.WindowMessages windowMessages)
windowMessages
- the window messagespublic void setZIndex(int zIndex)
zIndex
- the z-index (stacking order) of the windowpublic void show()
public void toBack()
public void toFront()
protected void afterShow()
protected Layer createGhost()
protected void doFocus()
protected void doLayout()
doLayout
in class ContentPanel
protected void fitContainer()
protected ModalPanel getModalPanel()
protected Window.WindowMessages getWindowMessages()
protected Layer ghost()
protected void initTools()
initTools
in class ContentPanel
protected void onAfterFirstAttach()
Component
onAfterFirstAttach
in class ContentPanel
protected void onDragCancel(DragCancelEvent event)
protected void onDragEnd(DragEndEvent de)
protected void onDragMove(DragMoveEvent de)
protected void onDragStart(DragStartEvent de)
protected void onEndResize(ResizeEndEvent re)
protected void onKeyPress(Event event)
protected void onStartResize(ResizeStartEvent re)
protected void onWindowResize(int width, int height)
onWindowResize
in class Component
protected void showWindow(boolean show)
protected void unghost(DragEndEvent de)
Copyright © 2018. All rights reserved.