Window

The Window class creates a new toplevel window.

A window is similar to a frame except that it is created as a top-level widget. The primary purpose of a toplevel is to serve as a container for dialog boxes and other collections of widgets.

Constructors

this
this(Window parent, string title, bool waitForWindow)

Constructor.

this
this(string title, bool waitForWindow)

Constructor.

Members

Functions

deiconify
auto deiconify()

Restore the window's state to before it was minimised or withdrawn.

iconify
auto iconify()

Minimise the window.

isAbove
bool isAbove(Window other)

Determine if this window is above another.

isBelow
bool isBelow(Window other)

Determine if this window is below another.

removeProtocolCommand
auto removeProtocolCommand(string protocol)

Remove a previously set protocol command.

setDefaultIcon
auto setDefaultIcon(Image[] images)

Set the default icon for this window. This is applied to all future child windows as well.

setDisabled
auto setDisabled(bool disabled)

Handle disabling the window. Windows only.

setFullscreen
auto setFullscreen(bool fullscreen)

Handle setting the window to fullscreen.

setGeometry
auto setGeometry(int width, int height, int xPos, int yPos)

Set the size and postition of the window.

setIcon
auto setIcon(Image[] images)

Set the icon for this window, this overrides the default icon.

setIdleCommand
auto setIdleCommand(CommandCallback callback, int msDelay)

Set a callback to be executed after a delay and after processing all other events. The callback is executed only once and discarded. This is useful for refreshing the GUI at regular intervals when monitoring something or to schedule a future action.

setMaxSize
auto setMaxSize(int width, int height)

Set the maximum size of the window.

setMinSize
auto setMinSize(int width, int height)

Set the minimum size of the window.

setModified
auto setModified(bool modified)

Set the modified state of the window. Mac OSX only.

setNotify
auto setNotify(bool modified)

Set the notify state of the window. On Mac OS it usually bounces the dock icon. Mac OSX only.

setOpacity
auto setOpacity(double opacity)

Set the opacity of the window.

setProtocolCommand
auto setProtocolCommand(string protocol, CommandCallback callback)

This command is used to manage window manager protocols such as WM_DELETE_WINDOW. Protocol is the name of an atom corresponding to a window manager protocol, such as WM_DELETE_WINDOW or WM_SAVE_YOURSELF or WM_TAKE_FOCUS.

setResizable
auto setResizable(bool resizeWidth, bool resizeHeight)

Set if the width and height can be resized.

setTitle
auto setTitle(string title)

Set the title of the window.

setToolWindow
auto setToolWindow(bool toolWindow)

Handle changing the window to a tool window. Windows only.

setTopmost
auto setTopmost(bool topmost)

Handle setting the window to be the top-most. This makes the window not able to be lowered behind any others.

wait
auto wait()

Wait until this window has been destroyed.

withdraw
auto withdraw()

Withdraw a window from being displayed/mapped by the window manager.

Mixins

__anonymous
mixin Color

Mixin common commands.

Static functions

getMainWindow
Window getMainWindow()

Get the main window of the application. This is just a convenience method and shouldn't really be used. Instead use the mainWindow property of the TkdApplication class.

Mixed In Members

From mixin Color

setForegroundColor
auto setForegroundColor(string color)

Set the foreground color of the widget.

setBackgroundColor
auto setBackgroundColor(string color)

Set the background color of the widget.

setInsertColor
auto setInsertColor(string color)

Set the insert cursor color of the widget.

Inherited Members

From UiElement

getClass
string getClass()

Get the widget's class.

setCursor
auto setCursor(string cursor)

Set the widget's cursor.

getCursor
string getCursor()

Get the widget's cursor.

bind
auto bind(string binding, CommandCallback callback)

Bind a callback to a particular event triggered by this element.

unbind
auto unbind(string binding)

Unbind a previous event binding.

destroy
void destroy()

Destroy this element and remove it from the GUI.

getChildIds
string[] getChildIds()

Get the string id's of the immediate children elements.

getWidth
int getWidth()

Get the width of the element.

getHeight
int getHeight()

Get the height of the element.

hwnd
size_t hwnd [@property getter]

Get the platform specific window id. This is equal to the hwnd on Windows or the x11 window id on Linux.

getCursorPos
int[] getCursorPos()

Get the position of the cursor over the element. The cursor position returned is relative to the screen. It is only returned if the cursor is over the element.

getCursorXPos
int getCursorXPos()

Get the horizontal position of the cursor over the element. The cursor position returned is relative to the screen. It is only returned if the cursor is over the element.

getCursorYPos
int getCursorYPos()

Get the vertical position of the cursor over the element. The cursor position returned is relative to the screen. It is only returned if the cursor is over the element.

getScreenWidth
int getScreenWidth()

Get the width of the screen this element is displayed on.

getScreenHeight
int getScreenHeight()

Get the height of the screen this element is displayed on.

getXPos
int getXPos(bool relativeToParent)

Get the horizontal position of the element. The number returned is calculated using the top, left-most pixel of the element including border if one exists.

getYPos
int getYPos(bool relativeToParent)

Get the vertical position of the element. The number returned is calculated using the top, left-most pixel of the element including border if one exists.

enableGeometryAutoSize
auto enableGeometryAutoSize(bool enable)

Set if the element should change it size when requested to do so by a geometry manager.

configureGeometryColumn
auto configureGeometryColumn(int index, int weight, int minSize, int uniformGroup, int pad)

Used by the grid geometry manager. Sets options for grid columns that contain child widgets.

configureGeometryRow
auto configureGeometryRow(int index, int weight, int minSize, int uniformGroup, int pad)

Used by the grid geometry manager. Sets options for grid rows that contain child widgets.

setBusy
auto setBusy(bool busy, string cursor)

Provides a simple means to block keyboard, button, and pointer events from elements, while overriding the cursor with a configurable busy cursor.

isBusy
bool isBusy()

Gets if the element is busy or not.

generateEvent
void generateEvent(string event)

Generates an event and arranges for it to be processed just as if it had come from the operating system. Event provides a basic description of the event, such as <Shift-Button-2> or <<Paste>>. The event argument may have any of the forms allowed for the binding argument of the bind method except that it must consist of a single event pattern only. Certain events, such as key events, require that the window has focus to receive the event properly.

focus
auto focus(bool force)

Set the element to take focus so any key press or key release events for the application are sent to that element. It is also possible to force the operating system to apply focus to the element immediately.

setGrab
auto setGrab(bool enable, bool global)

This command implements simple pointer and keyboard grabs. When a grab is set for a particular element, it restricts all pointer events to the grab window and its descendants. Whenever the pointer is within the grab element, the pointer will behave exactly the same as if there had been no grab at all and all events will be reported in the normal fashion. When the pointer is outside the element, button presses, releases and mouse motion events are reported to the element, and element entry and exit events are ignored. The grab 'owns' the pointer: elements outside the grab will be visible on the screen but they will be insensitive until the grab is released. The tree of elements underneath the grab element can include windows, in which case all windows and their descendants will continue to receive mouse events during the grab.

isGrabbing
bool isGrabbing()

Gets if the element is currently grabbing all events or not.

lower
auto lower(UiElement element)

Lower a window's position in the stacking order.

raise
auto raise(UiElement element)

Raise a window's position in the stacking order.

Examples

auto window = new Window("New window")
	.setGeometry(640, 480, 10, 10)
	.setDefaultIcon(new Png!("icon.png"))
	.setMaxSize(1024, 768)
	.setProtocolCommand(WindowProtocol.deleteWindow, delegate(CommandArgs args){ ... });

Common Commands

These are injected common commands that can also be used with this widget.

Color

Additional Events

Additional events that can also be bound to using the bind method.

<<PrevWindow>>, <Alt-Key>, <Key-Tab>, <Key-F10>,

See Also

Meta