Routines (alphabetical) > Routines: W > WINDOW

WINDOW

The WINDOW function creates an empty graphics window. The WINDOW function is useful if you want to set up a graphics area, perhaps add some text or polygon annotations, and then later add graphics.

Brief Example

The following lines create the window shown at the top of this topic.

; Create the window

w = WINDOW(WINDOW_TITLE="My Window", $

    DIMENSIONS=[500,300])

 

; Set some properties

w.BACKGROUND_COLOR = "thistle"

 

; Add some annotations

p = POLYGON([50,450,450,50],[50,50,8,8],0, /DEVICE)

t = TEXT(250, 25, "$\it Global Map$", $

    ALIGNMENT=0.5, /DEVICE)

mapimage = FILEPATH('Day.jpg', $

SUBDIRECTORY=['examples','data'])

i = image(mapimage, /OVERPLOT)

Syntax

graphic = (WINDOW [, Keywords=value] [, Properties=variable])

Keywords

Keywords are applied only during the initial creation of the graphic.

([, /BUFFER] [, DIMENSIONS=array] [, LOCATION=array] [, WINDOW_TITLE=string]

Properties

Properties can be set as keywords to the function during creation, or retrieved or changed using the "." notation after creation.

BACKGROUND_COLOR, EVENT_HANDLER, FONT_COLOR, FONT_NAME, FONT_SIZE, FONT_STYLE, KEYBOARD_HANDLER, MOUSE_DOWN_HANDLER, MOUSE_MOTION_HANDLER, MOUSE_UP_HANDLER, MOUSE_WHEEL_HANDLER, NAME, RESOLUTION, SELECTION_CHANGE_HANDLER, TITLE, UVALUE

Methods

Close

ConvertCoord

CopyWindow

Erase

GetSelect

HitTest

Print

Refresh

Save

SetCurrent

Show

Return Value

The WINDOW function returns a reference to the created graphic window. Use the returned reference to manipulate the window after creation by changing properties or calling methods.

Arguments

None.

Keywords

Keywords are applied only during the initial creation of the graphic.

BUFFER

Set this keyword to 1 to direct the graphics to an off-screen buffer instead of creating a window.

DIMENSIONS

Set this keyword to a two-element vector of the form [width, height] to specify the window dimensions in pixels.

LOCATION

Set this keyword to a two-element vector [X offset, Y offset] giving the window's screen offset in pixels.

WINDOW_TITLE

Set this keyword to the title of the IDL Graphic window. The title is displayed in the window's title bar. This keyword is ignored if BUFFER is set.

Note: On initial creation, setting the NAME property will also set the WINDOW_TITLE, and vice versa. After creation, the two can be set independently from each other.

Properties

BACKGROUND_COLOR

Set this property to a string or RGB vector that specifies the window's background color. The default value is "white".

EVENT_HANDLER

Set this property to an object reference to be used when events are received by the window. The object must be a subclass of GraphicsEventAdapter. See Creating a Graphics Event Handler Class for details on how to write this object class.

Note: The EVENT_HANDLER class is intended to be a convenient alternative to the procedural event handlers. If you specify both the EVENT_HANDLER property and an event handler function (MOUSE_DOWN_HANDLER for example), then the object method will be called first. If the object method returns a value of 1, then execution will continue and the handler function will then be called. If the object method returns 0, then the handler function will not be called and the default event handling will also be skipped.

FONT_COLOR

Set this property to a string or RGB vector that specifies the title text color. The default value is "black".

This property is ignored if TITLE is not specified.

FONT_NAME

Set this property equal to a string specifying the IDL or system font for the title text. The default value is “Helvetica”.

This property is ignored if TITLE is not specified.

FONT_SIZE

Set this property equal to an integer specifying the font size for the title text. The default value is 16 points.

This property is ignored if TITLE is not specified.

FONT_STYLE

Set this property equal to an integer or a string specifying the font style for the title text. Allowed values are:

Integer

String

Resulting Style

0

"Normal" or "rm"

Default (roman)

1

"Bold" or "bf"

Bold

2

"Italic" or "it"

Italic

3

"Bold italic" or "bi"

Bold italic

This property is ignored if TITLE is not specified.

KEYBOARD_HANDLER

Set this property to the name of a function that will be called when a key is pressed or released. See Creating Keyboard Event Functions for details on how to write these functions.

Tip: Instead of writing separate functions for each of the event handlers, you may find it convenient to create a single object class and use the EVENT_HANDLER property instead.


MOUSE_DOWN_HANDLER

Set this property to the name of a user-defined function that is called when the mouse button is pressed.

MOUSE_MOTION_HANDLER

Set this property to the name of a user-defined function that is called when the mouse is moved.

MOUSE_UP_HANDLER

Set this property to the name of a user-defined function that is called when the mouse button is released.

MOUSE_WHEEL_HANDLER

Set this property to the name of a user-defined function that is called when the mouse wheel is moved.

Note: See Creating Mouse Event Functions for details on how to write the mouse event functions.

Tip: Instead of writing separate functions for each of the mouse event handlers, you may find it convenient to create a single object class and use the EVENT_HANDLER property instead.

NAME

A string that specifies the name of the window. The name can be used to retrieve the window using the GETWINDOWS function. If NAME is not set then the default is "Graphic".

Note: On initial creation, setting the NAME property will also set the WINDOW_TITLE, and vice versa. After creation the two properties can be set independently from each other.

RESOLUTION (Get only)

A two-element floating-point vector of the form [xres, yres] that specifies the device resolution in centimeters per pixel. The default value is: [0.035277778, 0.035277778] (72 DPI).

SELECTION_CHANGE_HANDLER

Set this property to the name of a function that is called when a graphic is selected or deselected. See  Creating Selection Change Event Handlers for details on how to write these functions.

Tip: Instead of writing separate functions for each of the event handlers, you may find it convenient to create a single object class and use the EVENT_HANDLER property instead.

TITLE

Set this property to a string specifying a title. If TITLE is specified, you can also specify any of the FONT_COLOR, FONT_NAME, FONT_SIZE, and FONT_STYLE properties to control the title appearance.

You can also add Greek letters and mathematical symbols using a TeX-like syntax. These symbols need to be enclosed within a pair of "$" characters. See Adding Mathematical Symbols and Greek Letters to the Text String for details on the available symbols.

UVALUE

Set this property to an IDL variable of any data type.

Version History

8.0 Introduced
8.1

Properties added: KEYBOARD_HANDLER, MOUSE_DOWN_HANDLER, MOUSE_MOTION_HANDLER, MOUSE_UP_HANDLER, MOUSE_WHEEL_HANDLER, SELECTION_CHANGE_HANDLER, UVALUE

Methods added: GetSelect, HitTest, Show

8.2

Methods added: CopyWindow, Erase, Refresh, SetCurrent

Properties added: RESOLUTION

8.2.1

Properties added: EVENT_HANDLER

See Also

PLOT, Using IDL Graphics, GETWINDOWS, WIDGET_WINDOW