The WINDOW function creates an empty graphics window. The WINDOW function is useful for setting 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.
w = WINDOW(WINDOW_TITLE="My Window", $
DIMENSIONS=[500,300])
w.BACKGROUND_COLOR = "thistle"
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=value])
Keywords
Keywords are applied only during the initial creation of the graphic.
/BUFFER, DIMENSIONS=array, LOCATION=array, /NO_TOOLBAR, /WIDGETS
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, WINDOW_TITLE
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.
Tip: The minimum width is set by the toolbar in the window, usually around 400 pixels. To create a smaller graphics window, use the NO_TOOLBAR keyword.
LOCATION
Set this keyword to a two-element vector [X offset, Y offset] giving the window's screen offset in pixels.
NO_TOOLBAR
By default the graphics window will have a toolbar containing some common tools such as Print and Save. Set this keyword to remove the toolbar. This keyword has no effect if the window is already created.
Tip: When the toolbar exists, the minimum window width is set to the toolbar's width, usually around 400 pixels. To create a smaller graphics window, use the NO_TOOLBAR keyword.
WIDGETS
By default, when running from the IDL Workbench, the graphics window will use the native widgets for your platform. Set this keyword to instead use IDL widgets for the graphics window. This keyword is ignored when running from the IDL command line, since IDL widgets are always used in that case.
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 an Event Handler Class to Control Events 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".
FONT_NAME
Set this property equal to a string specifying the IDL or system font for the title text. The default value is "DejaVuSans".
FONT_SIZE
Set this property equal to an integer specifying the font size for the title text. The default value is 11 points.
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 |
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 Functions to Control Mouse Events 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 add Greek letters and mathematical symbols using a TeX-like syntax, enclosed within a pair of "$" characters. See Adding Mathematical Symbols and Greek Letters to the Text String for details.
UVALUE
Set this property to an IDL variable of any data type.
WINDOW_TITLE
Set this property 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.
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
|
8.4.1 |
Added WIDGETS keyword |
8.6 |
Changed default font name and font size. |
See Also
!COLOR, PLOT, Using IDL graphics, GETWINDOWS, WIDGET_WINDOW