Window Types

From Liberty BASIC Family
Revision as of 03:04, 11 October 2023 by StPendl (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

The BASIC interpreter provides four window types: Window, Graphics, Dialog, and Text.

Basic features of Window Types:

Window Most used and most useful window type.
Can contain all controls.
TAB key can be used to move focus from one control to the next.
Graphics Suitable for displaying graphics and graphical sprites.
Not intended to contain other controls.
Most controls will not work properly if placed in this window type.
Dialog Can contain all controls, but not menus.
Best suited for getting information from a user.
TAB key can be used to move focus from one control to the next.
Can contain a default button activated by user hitting ENTER key.
May display as "modal", meaning window must be closed before user can activate any other window.
Will be closed by pressing ESC key (unless you prevent it in trapclose).
Keyboard events in Graphicbox do not work in Dialog window.
Text Limited in functionality.
Can not contain other controls.
Useful for text display and editing.
Always has a menu bar with a File and Edit menu.

Syntax

  1. open "window title" for type as #handle
  2. open "window title" for type_suffix as #handle

Hints

Table of window features and attributes

Style Suffixes Features
Type _fs _nf _nsb _ins _modal _popup Sizing frame Menus Scroll bars Can contain other controls
Window X X Def/Opt Opt No Yes
Graphics X X X Def/Opt Opt Def/Opt Not intended to contain controls
Dialog X X X X No No No Yes
Text X X X Def/Opt Def Def/Opt No

Notes

Style Suffixes
_fs window is sized to fill screen
_nf window has no sizing frame and cannot be resized by user
_nsb window doesn't contain scroll bars
_ins window contains inset text editor
_modal window must be closed before another window can gain focus
_popup window has no title-bar and sizing frame
Features
Def Default appearance at window opening
Opt Optional - can be disabled
No feature NOT available for this window type
Yes feature IS available for this window type

Combined Style Suffix Cases

Graphics Text Window Dialog
graphics text window dialog
graphics_fs text_fs window_nf dialog_modal
graphics_nsb text_nsb window_popup dialog_nf
graphics_fs_nsb text_nsb_ins dialog_nf_modal
graphics_nf_nsb dialog_fs
dialog_nf_fs
dialog_popup

Example

' Run this program to see an example of the four window types.
nomainwin
UpperLeftX=DisplayWidth/2-300
UpperLeftY=DisplayHeight/2-200
WindowWidth=300
WindowHeight=200
menu #1, "Stuff"
open "Window" for window as #1
#1 "trapclose [quit]"

UpperLeftX=DisplayWidth/2
UpperLeftY=DisplayHeight/2-200
WindowWidth=300
WindowHeight=200
menu #2, "Stuff"
open "Graphic Window" for graphics as #2
#2 "trapclose [quit]"

UpperLeftX=DisplayWidth/2-300
UpperLeftY=DisplayHeight/2
WindowWidth=300
WindowHeight=200
menu #3, "Stuff"
open "Dialog Window" for dialog as #3
#3 "trapclose [quit]"

UpperLeftX=DisplayWidth/2
UpperLeftY=DisplayHeight/2
WindowWidth=300
WindowHeight=200
menu #4, "Stuff"
open "Text Window" for text as #4
#4 "!trapclose [quit]"

wait

[quit]
close #1
close #2
close #3
close #4
end

Useful Procedures

' Place a useful function using this keyword here