![]() |
<< Index >> |
FutureBasic 5 |
window | statement | |
|
window [-] wNum[, [title][, [rect][, [windowClass][, [windowAttributes] ]]]]
window
statement combines the features of the Appearance Window
and Window
statements


Windows with and without theme backgrounds
Window's
parameters are
specified as shown.
wNum
- a positive or negative integer whose absolute value is in the range 1 through 2147483647.
title
- a string expression. As of FB 5.7.102 this must be a Core Foundation(CF) string.
rect
- a rectangle in global screen coordinates. You can express it in either of two forms:
- The
rect
parameter allows automatic centering for newly-created windows but does not for existing windows . See "Creating a New Window" for details.
(x1,y1)-(x2,y2)
Two diagonally opposite corner points.
CGRect variable
A Core Graphics rectangle of type CGRect
. A CGRect
record type ( structure ) contains x, y, width and length
windowClass
- an unsigned long integer specifying the Macintosh window type to use ( i.e. the window's class ).
To create a windowClass
variable use the following syntax:
dim as WindowClass
wc
windowClass
Description
_kAlertWindowClass
I need your attention now.
_kMovableAlertWindowClass
I need your attention now, but I'm kind enough to let you switch out of this app to do other things
_kModalWindowClass
system modal, not draggable
_kMovableModalWindowClass
application modal, draggable
_kFloatingWindowClass
floats above all other application windows. Available in OS 8.6 or later
_kDocumentWindowClass
document windows
_kDesktopWindowClass
the desktop
_kHelpWindowClass
help windows
_kSheetWindowClass
sheets
_kToolbarWindowClass
floats above docs, below floating windows
_kPlainWindowClass
plain
_kOverlayWindowClass
overlays
_kSheetAlertWindowClass
sheet alerts
_kAltPlainWindowClass
plain alerts
windowAttributes
- an array of signed integers describing
the desired window features and behaviors such as a
close box, grow box, or a collapse box. An array index, if used, holds only one window attribute. All the available window attribute constants may
be found in the FB Header, Tlbx MacWindows.incl, if the following table doesn't have what is needed.
A windowAttributes array variable is dimensioned & loaded as follows.
N.B.: the array index after the last specified attribute must have zero in it:
dim as SInt32 wa(7)
//Size the attribute array to contain the planned attributes. Extra indices are ignored
wa(0) = _kHIWindowBitStandardHandler <=========== Only one window attribute in each index
wa(1) = _kHIWindowBitCloseBox
wa(2) = _kHIWindowBitZoomBox
wa(3) = _kHIWindowBitCollapseBox
wa(4) = _kHIWindowBitResizable
wa(5) = _kHIWindowBitLiveResize
wa(6) = _kHIWindowBitCompositing
wa(7) = 0 <=========== Zero REQUIRED in the index following the last window attribute
windowAttributes
Description
_kWindowNoAttributes
none
_kHIWindowBitCloseBox
close box
_kHIWindowBitZoomBox
zoom box
_kHIWindowBitCollapseBox
collapse box (sends to MacOS X dock)
_kHIWindowBitResizable
can be resized
_kWindowSideTitlebarAttribute
title on side for floating window
_kHIWindowBitNoUpdates
does not receive update event
_kHIWindowBitNoActivates
does not receive activate event
_kHIWindowBitToolbarButton
has a toolbar button in title bar
_kHIWindowBitNoShadow
no drop shadow
_kHIWindowBitLiveResize
resize events repeatedly sent while window is being sized
_kHIWindowBitStandardHandler
receives standard Carbon Events. FB defaults to this
_kHIWindowBitCompositing
the current OS default. Uses anti-aliasing.
Creating a New Window
wNum
specifies a unique integer value(i.e. different from the integer value assigned to any other windows in the same application ).
A new window is created and assigned a positive ( takes absolute value if a negative integer is supplied )ID number from the statement's variable or constant.
Once a window is created, its ID number can be used in other FutureBasic statements and functions.
Creating a new window, makes it the current output
window, and if created visibly, it also becomes the current active window.
title
a string specifying the window's title (if the window has a title bar). If not supplied, window titles default to "Untitled".
rect
specifies the initial size and location of the window's content rectangle. Note that rect
does not include the window's frame. To automatically center a newly created window, specify an x,y ( either within the CGRect
variable or for x1, y1 in the alternate format (x1,y1)-(x2,y2 ) ) coordinate of (0,0) in rect
.
Omitting this parameter results in a default size and location.
windowClass
specifies the window type.
windowAttributes
specifies the types of window widgets (close box, grow box) and behavior ( live resize ) a window will include.
Activate an Existing Window
- Specify the (positive) ID number of an existing window in
wNum
. You do not need to specify any of the other parameters unless you also wish to to change some of the window's characteristics. The window also becomes the current output window. If the window was invisible, it becomes visible.
- The
window
statement always makes the window active, unless a negative wNum
is specified. Activating a window using the window
statement, causes the following additional behavior:
- The window also becomes the current output window. (See the
window output
statement to learn how to specify an output window that's different from the active window.)
- A dialog event of type
_wndActivate
is generated. (There are also other kinds of actions which generate _wndActivate
events; see the dialog
function for more information.)
- Any previously-active window becomes inactive (this also generates a separate
_wndActivate
dialog event).
Make an Existing Window Visible or Invisible
- Visible: specify the (positive) ID number of an existing window in
idExpr
. The window also becomes the current active window, and it becomes the current output window.
- Invisible: specify the negative of an existing window's ID number in
idExpr
. The window becomes the current output window. If it was the active window, it becomes inactive (possibly forcing another window to become active). Specifying any of the other parameters isn't required to change its visibility, unless the window's other characteristics need changing.
Creating a window invisibly, when it contains controls, edit fields and graphics that may take a long time to build, desirably hides the building process from the end user.
- Side effects: If
wNum
is negative, the window becomes invisible and the current output window. If it was previously active, it becomes inactive; if the program has other visible windows, one of them becomes the active window.
Alter the Size, Location or Title of an Existing Window
- Specify the ID number of an existing window (or its negative) in
wNum
, and specify a new title
and/or rect
parameter. Omitted parameters do not change the corresponding characteristic. Unlike its behavior at window creation, specifying (0,0) for the rect
parameter's x,y coordinates does NOT automatically center an existing window;
instead the window is moved to those coordinates, which is likely undesirable behavior.
To center an existing window( or perform other window positioning without changing its size ) on the screen, just call RepositionWindow():
// new window
window 1, @"the title", fn CGRectMake( 50,100, w, h ) // x, y, width, height
// center existing
fn RepositionWindow( window(_wndRef), NULL, _kWindowCenterOnMainScreen )
The following functions are also available for setting or copying a window's title
WindowSetTitle( SInt32 wndNum, CFStringRef title )
sets the window's title bar with the contents of the supplied CFStringRef
fn WindowCopyTitle( SInt32 wndNum ) = CFStringRef
copies the window's title into a CFString. Caller is responsible for releasing the CFStringRef
See Also:
minwindow,
maxwindow,
get window,
window close,
window output,
window function,
appearance window,
dialog function