window_set
window_set (window, attr, value, …)
This function sets the values of the specified attributes for the specified window. Several attributes are generic and apply to all window classes. Other attributes are specific to a particular window class, for example, edit and list.
If attr is a set option, this function sets the window or view scope value of the option. If attr is a set option with a document local scope or no local scope, no value is set.
Window Class Attributes
Name
|
Value Type
|
background
|
color
|
canvasbackground
|
color
|
canvasforeground
|
color
|
caretMovedCallback
|
function name
|
destroyCallback
|
function name
|
focusCallback
|
function name
|
foreground
|
color
|
geometry
|
string
|
menuPostCallback
|
function name
|
message
|
string
|
parentWindow
|
window ID
|
quitCallback
|
function name
|
title
|
string
|
Edit Class Only Attributes
Name
|
Value Type
|
prompt
|
string
|
List Class Windows Only Attributes
Name
|
Value Type
|
appendItem
|
string
|
applyLabel
|
string
|
callback
|
function name
|
cancelLabel
|
string
|
default
|
string
|
deleteItem
|
string
|
embedded
|
0 or 1
|
helpLabel
|
string
|
items
|
array name or 0
|
label
|
string
|
okLabel
|
string
|
selection
|
string
|
verifyItem
|
boolean
|
Description of attributes:
appendItemstring — Appends a new item with the specified value to the list displayed in the specified list class window.
applyLabelstring — Sets the label on the APPLY button of the list class window to the specified string.
backgroundcolor — Sets the background color for the entire dialog box specified by window. color is either a named color or an RGB specification preceded by #.
callback func(winbutselnpos) — Specifies the name of a function to be called when a button is pressed in the specified list class window. The function is called with four arguments:
• win — The identifier of the list window
• but — A code indicating which button was pressed:
◦ 0 — Cancel
◦ 1 — OK
◦ 2 — Apply
◦ 3 — Help
◦ -1 — The window was dismissed using the window manager.
• seln — A string giving the current selection.
• pos — The ordinal number of the selection within the list or 0 if the selection is not a element of the list (verifyItem must be 0 in this case).
The callback function should act on the button as follows:
• -1 — Destroy the window using window_destroy.
• 0 — Dismiss the window using window_show(win, 0) or destroy it with window_destroy.
• 1 — Act on the selection and dismiss or destroy the window.
• 2 — Act on the selection and leave the window up.
• 3 — Display a help message only.
This recommended behavior assumes the default button labels.
canvasbackgroundcolor — Sets the background color for the edit canvas specified by window. color is either a named color or an RGB specification preceded by #.
canvasforegroundcolor — Sets the foreground color for the edit canvas specified by window. color is either a named color or an RGB specification preceded by #. Setting the foreground color is only effective when editing in ASCII mode. canvasforeground cannot be set when editing in SGML or XML mode
caretMovedCallbackfunc(winnewold[, oldpos]) — Specifies the name of a function to be called when the cursor is moved such that either the containing OID or the OID to the right of the cursor has changed. The function is passed up to four arguments:
• win — The identifier of the window.
• new (optional) — The new OID, that is, oid_caret.
• old (optional) — The old value of oid_caret.
• oldpos (optional) — The old position of the cursor as would be returned by oid_caret_pos(OID).
If a cut operation causes the cursor to be moved, the old object identifier old may no longer be valid. The callback function should call oid_valid(old) before using old. Since computing the old position oldpos could be time consuming in large flat documents, it is recommended that the oldpos argument not be used unless necessary, for example, if the callback function may need to restore the old cursor position, in effect, cancelling the cursor movement.
cancelLabelstring — Sets the label on the CANCEL button of the list class window to the specified string.
defaultstring — Sets the default selection for the list class window to the specified string (which must be a member of the list). Normally, this attribute should be set when the window is created, before it is displayed.
deleteItemstring — Removes the first item matching the specified string from the list displayed in the specified list class window.
destroyCallbackfunc(win) — Specifies the name of a function to be called when the window is destroyed. The function is passed a single argument, the ID of the window being destroyed.
embedded — Determines the type of
Arbortext Editor window. This is a read-only attribute that can only be used by the
window_get function. Returns
0 for a full frame or normal
Arbortext Editor window. Returns
1 for an embedded frame
Arbortext Editor window running in an ActiveX control.
focusCallbackfunc(win) — Specifies the name of a function to be called when the window obtains focus. The function will be called only when the window changes from an unfocused state to a focused state. The function is not called when Arbortext Editor receives focus and the desired window had focus the last time Arbortext Editor had focus. The function is passed a single argument, the ID of the window receiving focus.
geometrystring — Sets the geometry of the window to the specified value, which is a string of the form WxH+X+Y, where W and H are the width and height of the window in pixels, and X and Y give the location of the upper left corner of the window. The format of the string allows just the width and height and/or position to be set by omitting fields, for example:
window_set(w, "geometry", "500x350")
window_set(w, "geometry", "+5-5")
foregroundcolor — Sets the foreground color for the entire dialog box specified by window. color is either a named color or an RGB specification preceded by #. Setting the foreground color will only affect those dialog box elements that inherit the window color. For example, scrollbars and toolbars will not respond to foreground color changes.
helpLabelstring — Sets the label on the HELP button of the list class window to the specified string.
itemsarray or 0 — Sets the list of items displayed in the list class window to the contents of the specified array. The first element is stored at index 1. If the attribute value is 0 or the null string instead of an array name, then an empty list replaces the contents of the scrolling list.
labelstring — Sets the label displayed at the top of the list class window to the specified value.
menuPostCallbackfunc(win, menu) — Specifies the name of a function to be called when a top level menu is posted from the menu bar associated with the window. The function is passed two arguments: win is the identifier of the window and menu is the name of the menu being posted, for example, “File”. The callback function may use the menu_change command to disable or enable menu items, change item labels, and so on. The function may not change the menu bar using the menu_load, menu_reset, or menu_delete commands. The function is not called for shortcut menus.
messagestring — Sets the left field message footer to the specified string. The message will appear immediately after the window_set function is executed since a call to window_sync is done automatically. This makes the message footer useful for status messages as a script progresses. The message is erased automatically when the next key or button event is received in the window. If the specified window does not have a message footer, that is, (window_mask(w) & 8) == 0 then this attribute is ignored.
parentWindowwindowID — Sets the parent window to the window identified by parenwindowID.
okLabelstring — Sets the label on the OK button of the list class window to the specified string.
optionvalue — Sets the specified
option to the specified
value. The
option must be one of the
Arbortext Editor set options (see the
set command). The specified
option must have a local scope of either window or view. For options that take string values, enter the value. For options that take a boolean value (that is,
on or
off), enter either a one (
1) or a zero (
0).
promptstring — Sets the command window prompt (which is normally Command:) associated with the specified edit (or cmd) class window. If the value is a null string "", then the prompt is erased. This attribute is ignored if the window does not have a cmd subwindow.
quitCallbackfunc(win, code) — Specifies the name of a function to be called when the window receives a quit event, that is, the window is dismissed from the window manager or by a key or menu mapped to the quit or exit commands. The function is then passed two arguments:
• The ID of the window being dismissed.
• A code that indicates how the window is dismissed and has one of the values:
◦ 0 — Prompt about unsaved changes [quit].
◦ 1 — Save without prompting [exit].
◦ 2 — Don't save, don't prompt [quit ok].
If this function returns -1, then quit will be cancelled.
selectionstring — Sets the selection (the type-in field) of the list class window to the specified string.
titlestring — Sets the window manager title for the window to the specified string. For example:
window_set(w, "title", main::progname . " Messages")
Once a window has its title set with the window_set function, Arbortext Editor will no longer change the window's title on its own (as it normally does when a new document is loaded or following a SaveAs). To get Arbortext Editor to resume setting the window title, use window_set(win, 'title', ''). An empty title sent to the window_set function will not cause the window title to be blanked, but instead clears the state that says the title can only get updated through window_set. If a user really wants a blank title, then window_set(win, 'title', ' ') would work.
verifyItemvalue — Changes the verification mode of the list class window. If the value is true (non-zero), then any input typed in the selection field must be an element of the list displayed. If false (0), then the selection does not need to be a member of the list. Normally, this attribute should be set when the window is created, before it is displayed.
viewvalue — Changes the current view to the indicated value. The following values are supported:
• edit — Changes the current view to Edit view.
• docmap — Changes the current view to Document Map.
• column — Changes the current view to Column view.
viewmodevalue — Changes the view in the current window based on the indicated value. The following values are supported:
• edit — Changes the window to Edit view.
• docmap — Changes the window to a split view with Document Map and Edit view positioned based on the current settings of the docmapside and docmappercent options.
• column — Changes the window to a split view with Column view and Edit view positioned based on the current settings of the docmapside and docmappercent options.
Related Topics