| EVENT_WINDOWACCEPT | A file was dropped onto a Window with the WINDOW_ACCEPTFILES style. The event Extra object holds the filepath. |
See Also: WindowMenu, UpdateWindowMenu, PopupWindowMenu, ActivateWindow, SetStatusText, WindowStatusText,
SetMinWindowSize, SetMaxWindowSize, MinimizeWindow, MaximizeWindow, RestoreWindow, WindowMinimized
and WindowMaximized.
Example
' createwindow.bmx
Import MaxGui.Drivers
Strict
AppTitle = "CreateWindow() Example"
Global FLAGS:Int
' Comment/uncomment any of the following lines to experiment with the different styles.
FLAGS:| WINDOW_TITLEBAR
FLAGS:| WINDOW_RESIZABLE
FLAGS:| WINDOW_MENU
FLAGS:| WINDOW_STATUS
FLAGS:| WINDOW_CLIENTCOORDS
'FLAGS:| WINDOW_HIDDEN
FLAGS:| WINDOW_ACCEPTFILES
'FLAGS:| WINDOW_TOOL
'FLAGS:| WINDOW_CENTER
Local window:TGadget = CreateWindow( AppTitle, 100, 100, 320, 240, Null, FLAGS )
If (FLAGS & WINDOW_STATUS) Then
SetStatusText( window, "Left alignedtCenter alignedtRight aligned" )
EndIf
Repeat
WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_APPTERMINATE, EVENT_WINDOWCLOSE
End
End Select
Forever
Function WindowMenu:TGadget( window:TGadget )
Returns a window's main-menu handle.
Required when a root menu is to be added to a window using CreateMenu. This function
should not be used for sub-menus - the sub-menu should be parented directly to its parent menu.
It should also be mentioned that this function isn't required when creating popup menus - Null should
instead be passed as the parent of the root menu.
To avoid any unexpected behavior, make sure that the window specified was created with the WINDOW_MENU
style flag.
See Also: CreateMenu and UpdateWindowMenu
Function UpdateWindowMenu( window:TGadget )
Update a window's menu hierachy.
Required after changing a window's menu properties/structure for the changes to become visible.
To avoid any unexpected behavior, make sure that the window specified was created with the WINDOW_MENU
style flag.
See Also: WindowMenu and CreateMenu
Function PopupWindowMenu( window:TGadget,menu:TGadget,extra:Object=Null )
Display a popup menu.
A popup context-menu is displayed on the screen at the user's current mouse position.
See Also: CreateMenu
Example
Strict
Import MaxGui.Drivers
Local menu:TGadget
Local window:TGadget
Local panel:TGadget
menu=CreateMenu("popup",0,Null)
CreateMenu("Load",101,menu)
CreateMenu("Save",102,menu)
window=CreateWindow("Test PopupWindowMenu",20,20,200,200)
' create a panel to capture some mouse events
panel=CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_ACTIVE)
While True
WaitEvent
Select EventID()
Case EVENT_MOUSEDOWN
If EventData()=2 PopupWindowMenu window,menu
Case EVENT_WINDOWCLOSE
End
Case EVENT_MENUACTION
Print "EVENT_MENUACTION: eventdata()="+EventData()
End Select
Wend
Function ActivateWindow( window:TGadget )
Activate a window gadget.
This function has been superseded by ActivateGadget, but is available for backwards compatability.
Function WindowStatusText$( window:TGadget )
Retrieve a window's status-bar text.
Can only be used with windows created with the WINDOW_STATUS flag (see CreateWindow). Tab characters
delimit between the three alignments of text. See SetStatusText for more information.
Function SetStatusText( window:TGadget,Text$ )
Set a window's status bar text.
Can only be used with windows created with the WINDOW_STATUS flag (see CreateWindow). Use tab characters
to delimit between the three alignments of text. For example:
SetStatusText( window, "Left Aligned Only" )
SetStatusText( window, "Left Aligned~tCenter Aligned~tRight Aligned" )
SetStatusText( window, "~tCenter Aligned Only" )
SetStatusText( window, "~t~tRight Aligned Only" )
````
See Also: [WindowStatusText](../../maxgui/maxgui.maxgui/#function-windowstatustext-window-tgadget)
<br/>
### `Function SetMinWindowSize( window:TGadget,w,h )`
Set a window's minimum size.
Only useful for resizable windows (i.e. windows created with the WINDOW_RESIZABLE flag, see [CreateWindow](../../maxgui/maxgui.maxgui/#function-createwindow-tgadget-titletext-x-y-w-h-group-tgadget-null-style-window-default)).
<br/>
### `Function SetMaxWindowSize( window:TGadget,w,h )`
Set a window's maximum size.
Only useful for resizable windows (i.e. windows created with the WINDOW_RESIZABLE flag, see [CreateWindow](../../maxgui/maxgui.maxgui/#function-createwindow-tgadget-titletext-x-y-w-h-group-tgadget-null-style-window-default)).
Calling this function will disable the Maximize button window hint on Windows, and will limit the window zoom size on Mac OS X.
<br/>
### `Function MinimizeWindow( window:TGadget )`
Minimize a window.
A minimized window can be restored by the user to its previous state, typically by clicking on the icon representation
of the window in the taskbar or dock. The same effect can be obtained programatically by calling [RestoreWindow](../../maxgui/maxgui.maxgui/#function-restorewindow-window-tgadget).
See Also: [WindowMinimized](../../maxgui/maxgui.maxgui/#function-windowminimized-window-tgadget).
<br/>
### `Function MaximizeWindow( window:TGadget )`
Maximize a window.
Maximizing a window makes the window visible and sizes it to fill the current desktop. [RestoreWindow](../../maxgui/maxgui.maxgui/#function-restorewindow-window-tgadget) can be used to
programatically restore a window to its previous unmaximized state, although the window will still remain unhidden.
See Also: [WindowMaximized](../../maxgui/maxgui.maxgui/#function-windowmaximized-window-tgadget).
<br/>
### `Function RestoreWindow( window:TGadget )`
Restore a window from a minimized or maximized state.
See Also: [MinimizeWindow](../../maxgui/maxgui.maxgui/#function-minimizewindow-window-tgadget) and [MaximizeWindow](../../maxgui/maxgui.maxgui/#function-maximizewindow-window-tgadget).
<br/>
### `Function WindowMinimized( window:TGadget )`
Detect if a window is minimized.
#### Returns
[True](../../brl/brl.blitz/#true) if the window is currently minimized, [False](../../brl/brl.blitz/#false) if not.
<br/>
### `Function WindowMaximized( window:TGadget )`
Detect if a window is maximized.
A maximized window fills the entire desktop. A window may
be maximized with the [MaximizeWindow](../../maxgui/maxgui.maxgui/#function-maximizewindow-window-tgadget) command or by the user if
[CreateWindow](../../maxgui/maxgui.maxgui/#function-createwindow-tgadget-titletext-x-y-w-h-group-tgadget-null-style-window-default) was called with the WINDOW_RESIZABLE flag.
#### Returns
[True](../../brl/brl.blitz/#true) if the window is currently maximized, [False](../../brl/brl.blitz/#false) if not.
<br/>
### `Function CreateButton:TGadget(label$,x,y,w,h,group:TGadget,style=BUTTON_PUSH)`
Create a Button gadget.
A Button generates an EVENT_GADGETACTION [TEvent](../../brl/brl.event/tevent) whenever it is pushed.
<table><tr><td> <b>Style</b></td><td><b>Meaning</b></td></tr><tr><td> BUTTON_PUSH</td><td>Standard push button.</td></tr><tr><td> BUTTON_CHECKBOX</td><td>A check box button that displays a tick when its state is [True](../../brl/brl.blitz/#true).</td></tr><tr><td> BUTTON_RADIO</td><td>A radio button is accompanied by a small circular indicator, filled when its state is [True](../../brl/brl.blitz/#true).</td></tr><tr><td> BUTTON_OK</td><td>Standard push button that is also activated when the user presses the RETURN key.</td></tr><tr><td> BUTTON_CANCEL</td><td>Standard push button that is also activated when the user presses the ESCAPE key.</table>
On certain platforms, the BUTTON_PUSH flag can be combined with either BUTTON_CHECKBOX or BUTTON_RADIO to obtain
a button looking similar to standard push-buttons, but mimicking the behaviour of the checkbox or radio button.
See Also: [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text), [SetButtonState](../../maxgui/maxgui.maxgui/#function-setbuttonstate-button-tgadget-checked), [ButtonState](../../maxgui/maxgui.maxgui/#function-buttonstate-button-tgadget) and [SetGadgetPixmap](../../maxgui/maxgui.maxgui/#function-setgadgetpixmap-gadget-tgadget-pixmap-tpixmap-flags-gadgetpixmap-icon).
#### Example
blitzmax
' createbutton.bmx
Import MaxGui.Drivers
Strict
Global window:TGadget = CreateWindow("MaxGUI Buttons",40,40,400,330,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS)
CreateButton("Std. Button",10,10,120,30,window,BUTTON_PUSH)
CreateButton("OK Button",140,10,120,30,window,BUTTON_OK)
CreateButton("Cancel Button",270,10,120,30,window,BUTTON_CANCEL)
Global panel:TGadget[4]
panel[0]=CreatePanel(10,50,380,60,window,PANEL_GROUP,"Checkbox")
FillPanelWithButtons(panel[0], BUTTON_CHECKBOX, "Checkbox")
panel[1]=CreatePanel(10,120,380,60,window,PANEL_GROUP,"Checkbox (with Push Button Style)")
FillPanelWithButtons(panel[1], BUTTON_CHECKBOX|BUTTON_PUSH, "Toggle")
panel[2]=CreatePanel(10,190,380,60,window,PANEL_GROUP,"Radio Buttons")
FillPanelWithButtons(panel[2], BUTTON_RADIO, "Option ")
panel[3]=CreatePanel(10,260,380,60,window,PANEL_GROUP,"Radio Buttons (with Push Button Style)")
FillPanelWithButtons(panel[3], BUTTON_RADIO|BUTTON_PUSH, "Option")
Repeat
Select WaitEvent()
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
End
Case EVENT_GADGETACTION
Print "EVENT_GADGETACTIONn" + ..
"GadgetText(): q" + GadgetText(TGadget(EventSource())) + "q t " + ..
"ButtonState(): "+ ButtonState(TGadget(EventSource()))
EndSelect
Forever
Function FillPanelWithButtons( pPanel:TGadget, pStyle%, pText$ = "Button" )
Local buttonwidth% = (pPanel.width-10)/3
For Local i% = 0 Until 3
CreateButton( pText + " " + (i+1), 5+(i*buttonwidth), 5, buttonwidth-10, 26, pPanel, pStyle )
Next
EndFunction
<br/>
### `Function SetButtonState( button:TGadget,checked )`
Set a button's state.
Buttons created with the BUTTON_CHECKBOX and BUTTON_RADIO styles are able to show a selected state.
In addition, the BUTTON_CHECKBOX style may also be able to distinguish an indeterminate state from that
of a checked state through the use of the CHECK_INDETERMINATE (-1) constant, depending on the platform.
See Also: [CreateButton](../../maxgui/maxgui.maxgui/#function-createbutton-tgadget-label-x-y-w-h-group-tgadget-style-button-push), [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text), [ButtonState](../../maxgui/maxgui.maxgui/#function-buttonstate-button-tgadget) and [SetGadgetPixmap](../../maxgui/maxgui.maxgui/#function-setgadgetpixmap-gadget-tgadget-pixmap-tpixmap-flags-gadgetpixmap-icon).
<br/>
### `Function ButtonState( button:TGadget )`
Retrieve a button's state.
Returns a non-zero value if a checkbox or radio button is selected or false if it isn't.
On certain platforms, if a checkbox is set using [SetButtonState](../../maxgui/maxgui.maxgui/#function-setbuttonstate-button-tgadget-checked) to have an indeterminant
state (CHECK_INDETERMINATE), then this function will return CHECK_INDETERMINATE too.
See Also: [CreateButton](../../maxgui/maxgui.maxgui/#function-createbutton-tgadget-label-x-y-w-h-group-tgadget-style-button-push), [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text), [SetButtonState](../../maxgui/maxgui.maxgui/#function-setbuttonstate-button-tgadget-checked) and [SetGadgetPixmap](../../maxgui/maxgui.maxgui/#function-setgadgetpixmap-gadget-tgadget-pixmap-tpixmap-flags-gadgetpixmap-icon).
<br/>
### `Function CreatePanel:TGadget(x,y,w,h,group:TGadget,style=0,title$="")`
Create a Panel gadget.
A Panel is a general purpose gadget that can be used to group other gadgets.
Background colours and images can be set using [SetGadgetColor](../../maxgui/maxgui.maxgui/#function-setgadgetcolor-gadget-tgadget-r-g-b-bg-true) and [SetPanelPixmap](../../maxgui/maxgui.maxgui/#function-setpanelpixmap-panel-tgadget-pixmap-tpixmap-flags-panelpixmap-tile).
A panel can be created with any one of the following <i>optional</i> styles:
<table><tr><td> <b>Style</b></td><td><b>Meaning</b></td></tr><tr><td> PANEL_SUNKEN</td><td>Panel is drawn with a sunken border (or just a simple border on OS X).</td></tr><tr><td> PANEL_RAISED</td><td>Panel is drawn with a raised border (or just a simple border on OS X).</td></tr><tr><td> PANEL_GROUP</td><td>Panel is drawn with a titled etched border.</table>
The PANEL_ACTIVE flag can be combined with any other style flags, or specified on its own,
to generate mouse and key events (equivalent to calling [SetGadgetSensitivity](../../maxgui/maxgui.maxgui/#function-setgadgetsensitivity-gadget-tgadget-flags) immediately
after creation):
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_MOUSEDOWN</td><td>Mouse button pressed. Event data contains mouse button code.</td></tr><tr><td> EVENT_MOUSEUP</td><td>Mouse button released. Event data contains mouse button code.</td></tr><tr><td> EVENT_MOUSEMOVE</td><td>Mouse moved. Event x and y contain mouse coordinates.</td></tr><tr><td> EVENT_MOUSEWHEEL</td><td>Mouse wheel spun. Event data contains delta clicks.</td></tr><tr><td> EVENT_MOUSEENTER</td><td>Mouse entered gadget area.</td></tr><tr><td> EVENT_MOUSELEAVE</td><td>Mouse left gadget area.</td></tr><tr><td> EVENT_KEYDOWN</td><td>Key pressed. Event data contains keycode.</td></tr><tr><td> EVENT_KEYUP</td><td>Key released. Event data contains keycode.</td></tr><tr><td> EVENT_KEYCHAR</td><td>Key character. Event data contains unicode value.</table>
<i>Note: The PANEL_SUNKEN / PANEL_RAISED style flags cannot be used with PANEL_GROUP.</i>
See Also: [SetPanelColor](../../maxgui/maxgui.maxgui/#function-setpanelcolor-panel-tgadget-r-g-b) and [SetPanelPixmap](../../maxgui/maxgui.maxgui/#function-setpanelpixmap-panel-tgadget-pixmap-tpixmap-flags-panelpixmap-tile).
#### Example
blitzmax
' createpanel.bmx
Strict
Import MaxGui.Drivers
AppTitle = "Panel Example"
Local window:TGadget = CreateWindow( AppTitle, 100, 100, 440, 240, Null, WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_RESIZABLE )
' create an active panel that occupies entire window client area
Local panel:TGadget = CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_ACTIVE)
SetGadgetLayout panel, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED
' and add to it a smaller green panel with a sunken edge
Local panel2:TGadget = CreatePanel(10,10,200,200,panel,PANEL_ACTIVE|PANEL_SUNKEN)
SetGadgetColor(panel2,160,255,160)
' and finally a group panel with a child button
Local group:TGadget = CreatePanel(220,10,200,200,panel,PANEL_GROUP,"Group Label")
Local button:TGadget = CreateButton("Push Button",0,10,ClientWidth(group)-20,26,group)
Repeat
WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
End
End Select
Forever
<br/>
### `Function SetPanelColor( panel:TGadget,r,g,b )`
Set the color of a Panel.
This function has been superseded by [SetGadgetColor](../../maxgui/maxgui.maxgui/#function-setgadgetcolor-gadget-tgadget-r-g-b-bg-true), but is available for backwards compatability.
See Also: [CreatePanel](../../maxgui/maxgui.maxgui/#function-createpanel-tgadget-x-y-w-h-group-tgadget-style-0-title) and [SetPanelPixmap](../../maxgui/maxgui.maxgui/#function-setpanelpixmap-panel-tgadget-pixmap-tpixmap-flags-panelpixmap-tile)
<br/>
### `Function SetPanelPixmap( panel:TGadget,pixmap:TPixmap,flags=PANELPIXMAP_TILE)`
Set panel's background image to a pixmap.
This function has been superseded by [SetGadgetPixmap](../../maxgui/maxgui.maxgui/#function-setgadgetpixmap-gadget-tgadget-pixmap-tpixmap-flags-gadgetpixmap-icon), but is available for backwards compatability.
<table><tr><td> <b>Flags</b></td><td><b>Description</b></td></tr><tr><td> PANELPIXMAP_TILE</td><td>The panel is filled with repeating tiles.</td></tr><tr><td> PANELPIXMAP_CENTER</td><td>The pixmap is positioned at the center of the panel.</td></tr><tr><td> PANELPIXMAP_FIT</td><td>The pixmap is scaled to best fit the panel size.</td></tr><tr><td> PANELPIXMAP_FIT2</td><td>A variant of PANELPIXMAP_FIT where clipping can occur to achieve a better fit.</td></tr><tr><td> PANELPIXMAP_STRETCH</td><td>The pixmap is stretched to fit the entire panel.</table>
The function can be passed 'Null' as the parameter for <b>pixmap</b>, in which case the pixmap should be removed.
See Also: [CreatePanel](../../maxgui/maxgui.maxgui/#function-createpanel-tgadget-x-y-w-h-group-tgadget-style-0-title) and [SetPanelColor](../../maxgui/maxgui.maxgui/#function-setpanelcolor-panel-tgadget-r-g-b)
<br/>
### `Function CreateTextField:TGadget(x,y,w,h,group:TGadget,style=0)`
Create a TextField gadget.
A TextField is a single line text entry gadget and currently has only one style flag:
<table><tr><td> <b>Flags</b></td><td><b>Description</b></td></tr><tr><td> TEXTFIELD_PASSWORD</td><td>Masks characters being typed as a string as asterisks.</table>
Irrespective of the flag used, the TextField gadget will emit the following event(s):
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_GADGETACTION</td><td>The user has edited the text in the TextField.</table>
It is also possible to validate any typed input before it reaches the TextArea using
the [SetGadgetFilter](../../maxgui/maxgui.maxgui/#function-setgadgetfilter-gadget-tgadget-callback-event-tevent-context-object-context-object-null) command.
See Also: [GadgetText](../../maxgui/maxgui.maxgui/#function-gadgettext-gadget-tgadget), [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text), [SetGadgetFilter](../../maxgui/maxgui.maxgui/#function-setgadgetfilter-gadget-tgadget-callback-event-tevent-context-object-context-object-null).
#### Example
blitzmax
' createtextfield.bmx
Import MaxGui.Drivers
Strict
Local window:TGadget
Local textfield:TGadget
Local button:TGadget
window=CreateWindow("My Window",30,20,320,200)
textfield=CreateTextField(4,4,120,22,window)
SetGadgetText( textfield,"A textfield gadget" )
' we need an OK button to catch return key
button=CreateButton("OK",130,4,80,24,window,BUTTON_OK)
ActivateGadget textfield
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_GADGETACTION
Select EventSource()
Case textfield
Print "textfield updated"
Case button
Print "return key / OK button pressed"
End Select
Case EVENT_WINDOWCLOSE
End
End Select
Wend
<br/>
### `Function TextFieldText$( textfield:TGadget )`
Get the current text in a TextField gadget.
This function has been superseded by [GadgetText](../../maxgui/maxgui.maxgui/#function-gadgettext-gadget-tgadget), but is available for backwards compatability.
See Also: [CreateTextField](../../maxgui/maxgui.maxgui/#function-createtextfield-tgadget-x-y-w-h-group-tgadget-style-0) and [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text)
<br/>
### `Function CreateTextArea:TGadget(x,y,w,h,group:TGadget,style=0)`
Create a TextArea gadget.
A TextArea gadget is a multiline text editor with commands that allow control
over the contents, style and selection of the text it contains.
A TextArea gadget may have the following optional styles:
<table><tr><td> <b>Style</b></td><td><b>Meaning</b></td></tr><tr><td> TEXTAREA_WORDWRAP</td><td>Long lines of text 'wrap round' onto the next lines.</td></tr><tr><td> TEXTAREA_READONLY</td><td>The text cannot be edited by the user.</table>
A TextArea gadget can generate the following events:
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_GADGETACTION</td><td>The user has modified the text in a TextArea.</td></tr><tr><td> EVENT_GADGETSELECT</td><td>The text-cursor has moved or a selection of text is made by the user.</td></tr><tr><td> EVENT_GADGETMENU</td><td>The user has right-clicked somewhere in the TextArea.</table>
It is also possible to validate any typed input before it reaches the TextArea using
the [SetGadgetFilter](../../maxgui/maxgui.maxgui/#function-setgadgetfilter-gadget-tgadget-callback-event-tevent-context-object-context-object-null) command.
See Also: [SetTextAreaText](../../maxgui/maxgui.maxgui/#function-settextareatext-textarea-tgadget-text-pos-0-length-textarea-all-units-textarea-chars), [AddTextAreaText](../../maxgui/maxgui.maxgui/#function-addtextareatext-textarea-tgadget-text), [TextAreaText](../../maxgui/maxgui.maxgui/#function-textareatext-textarea-tgadget-pos-0-length-textarea-all-units-textarea-chars), [TextAreaLen](../../maxgui/maxgui.maxgui/#function-textarealen-textarea-tgadget-units-textarea-chars), [LockTextArea](../../maxgui/maxgui.maxgui/#function-locktextarea-textarea-tgadget),
[UnlockTextArea](../../maxgui/maxgui.maxgui/#function-unlocktextarea-textarea-tgadget), [SetTextAreaTabs](../../maxgui/maxgui.maxgui/#function-settextareatabs-textarea-tgadget-tabwidth), [SetGadgetFont](../../maxgui/maxgui.maxgui/#function-setgadgetfont-gadget-tgadget-font-tguifont-applytochildren-int-false), [SetGadgetColor](../../maxgui/maxgui.maxgui/#function-setgadgetcolor-gadget-tgadget-r-g-b-bg-true), [TextAreaCursor](../../maxgui/maxgui.maxgui/#function-textareacursor-textarea-tgadget-units-textarea-chars),
[TextAreaSelLen](../../maxgui/maxgui.maxgui/#function-textareasellen-textarea-tgadget-units-textarea-chars), [FormatTextAreaText](../../maxgui/maxgui.maxgui/#function-formattextareatext-textarea-tgadget-r-g-b-flags-pos-0-length-textarea-all-units-textarea-chars), [SelectTextAreaText](../../maxgui/maxgui.maxgui/#function-selecttextareatext-textarea-tgadget-pos-0-length-textarea-all-units-textarea-chars), [TextAreaChar](../../maxgui/maxgui.maxgui/#function-textareachar-textarea-tgadget-line), [TextAreaLine](../../maxgui/maxgui.maxgui/#function-textarealine-textarea-tgadget-index),
[TextAreaCharX](../../maxgui/maxgui.maxgui/#function-textareacharx-textarea-tgadget-char) and [TextAreaCharY](../../maxgui/maxgui.maxgui/#function-textareachary-textarea-tgadget-char).
#### Example
blitzmax
' createtextarea.bmx
Import MaxGui.Drivers
Strict
Global window:TGadget = CreateWindow( "My Window", 130, 20, 400, 400 )
Global textarea:TGadget = CreateTextArea( 0, 0, ClientWidth(window), ClientHeight(window), window )
SetGadgetLayout( textarea, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED )
SetGadgetText( textarea, "A TextArea gadget. :-)nnOne line...n...and then another!")
ActivateGadget( textarea )
' Select the entire third (index: 2 [base-0]) line.
SelectTextAreaText( textarea, 2, 1, TEXTAREA_LINES )
' Output the properties of the current text selection (should be 1, 1 as set above).
Print "TextAreaCursor(): " + TextAreaCursor( textarea, TEXTAREA_LINES )
Print "TextAreaSelLen(): " + TextAreaSelLen( textarea, TEXTAREA_LINES )
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_APPTERMINATE
End
End Select
Wend
<br/>
### `Function SetTextAreaText( textarea:TGadget,Text$,pos=0,length=TEXTAREA_ALL,units=TEXTAREA_CHARS )`
Set the contents of a TextArea gadget.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0), [AddTextAreaText](../../maxgui/maxgui.maxgui/#function-addtextareatext-textarea-tgadget-text) and [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text)
<br/>
### `Function AddTextAreaText( textarea:TGadget,Text$ )`
Append text to the contents of a TextArea gadget.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0), [SetTextAreaText](../../maxgui/maxgui.maxgui/#function-settextareatext-textarea-tgadget-text-pos-0-length-textarea-all-units-textarea-chars) and [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text)
<br/>
### `Function TextAreaText$( textarea:TGadget,pos=0,length=TEXTAREA_ALL,units=TEXTAREA_CHARS )`
Get the contents of a TextArea gadget.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0), [AddTextAreaText](../../maxgui/maxgui.maxgui/#function-addtextareatext-textarea-tgadget-text), [SetTextAreaText](../../maxgui/maxgui.maxgui/#function-settextareatext-textarea-tgadget-text-pos-0-length-textarea-all-units-textarea-chars) and [SetGadgetText](../../maxgui/maxgui.maxgui/#function-setgadgettext-gadget-tgadget-text)
<br/>
### `Function TextAreaLen( textarea:TGadget,units=TEXTAREA_CHARS )`
Get the number of characters in a TextArea gadget.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function LockTextArea( textarea:TGadget )`
Lock a TextArea gadget for improved performance when formatting.
See Also: [UnlockTextArea](../../maxgui/maxgui.maxgui/#function-unlocktextarea-textarea-tgadget) and [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function UnlockTextArea( textarea:TGadget )`
Unlock a previously locked TextArea gadget.
See Also: [LockTextArea](../../maxgui/maxgui.maxgui/#function-locktextarea-textarea-tgadget) and [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function SetTextAreaTabs( textarea:TGadget,tabwidth )`
Set the tab stops of a TextArea gadget measured in pixels.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0) SetIndents
<br/>
### `Function SetMargins( textarea:TGadget,leftmargin )`
Set left margin of a TextArea measured in pixels.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0) and [SetTextAreaTabs](../../maxgui/maxgui.maxgui/#function-settextareatabs-textarea-tgadget-tabwidth)
<br/>
### `Function SetTextAreaFont( textarea:TGadget,font:TGuiFont )`
Set the font of a TextArea gadget.
This function has been superseded by [SetGadgetFont](../../maxgui/maxgui.maxgui/#function-setgadgetfont-gadget-tgadget-font-tguifont-applytochildren-int-false), but is available for backwards compatability.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function SetTextAreaColor( textarea:TGadget,r,g,b,bg=False )`
Set the background or foreground colors of a TextArea gadget.
This function has been superseded by [SetGadgetColor](../../maxgui/maxgui.maxgui/#function-setgadgetcolor-gadget-tgadget-r-g-b-bg-true), but is available for backwards compatability.
See Also: [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function TextAreaCursor( textarea:TGadget,units=TEXTAREA_CHARS )`
Find the position of the cursor in a TextArea gadget.
Use the default TEXTAREA_CHARS units argument to find out which character
(column) in the line the cursor is on and use TEXTAREA_LINES to find out
which line (row) the cursor is on.
See Also: [TextAreaSelLen](../../maxgui/maxgui.maxgui/#function-textareasellen-textarea-tgadget-units-textarea-chars) and [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function TextAreaSelLen( textarea:TGadget,units=TEXTAREA_CHARS )`
Find the size of the selected text in a TextArea gadget.
The TEXTAREA_CHARS option returns the number of characters currently
highlighted by the user where as TEXTAREA_LINES will specify the
function returns the number of lines selected.
See Also: [TextAreaCursor](../../maxgui/maxgui.maxgui/#function-textareacursor-textarea-tgadget-units-textarea-chars) and [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function FormatTextAreaText( textarea:TGadget,r,g,b,flags,pos=0,length=TEXTAREA_ALL,units=TEXTAREA_CHARS )`
Format the color and style of some text in a TextArea gadget.
The <b>r</b>, <b>g</b> and <b>b</b> parameters represent the <b>r</b>ed, <b>g</b>reen and <b>b</b>lue components (0..255)
which, when combined, represent the new text color for the the sepecified region
of characters.
The <b>flags</b> parameter can be a combination of the following values:
<table><tr><td> <b>Constant</b></td><td><b>Meaning</b></td></tr><tr><td> TEXTFORMAT_BOLD</td><td>Bold</td></tr><tr><td> TEXTFORMAT_ITALIC</td><td>Italic</td></tr><tr><td> TEXTFORMAT_UNDERLINE</td><td>Underline</td></tr><tr><td> TEXTFORMAT_STRIKETHROUGH</td><td>StrikeThrough</table>
Depending on the value of the units parameter the position and length parameters specify
the character position and number of characters or the starting line and the number
of lines that FormatTextAreaText will modify.
See Also: [LockTextArea](../../maxgui/maxgui.maxgui/#function-locktextarea-textarea-tgadget) and [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function SelectTextAreaText( textarea:TGadget,pos=0,length=TEXTAREA_ALL,units=TEXTAREA_CHARS )`
Select a range of text in a TextArea gadget.
Depending on the value of the units the position and length parameters specify
the character position and number of characters or the starting line and the number
of lines that SelextTextAreaText will highlight.
See Also: [TextAreaCursor](../../maxgui/maxgui.maxgui/#function-textareacursor-textarea-tgadget-units-textarea-chars), [TextAreaSelLen](../../maxgui/maxgui.maxgui/#function-textareasellen-textarea-tgadget-units-textarea-chars) and [CreateTextArea](../../maxgui/maxgui.maxgui/#function-createtextarea-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function TextAreaChar( textarea:TGadget,Line )`
Find the character position of a given line in a TextArea gadget.
<br/>
### `Function TextAreaLine( textarea:TGadget,index )`
Find the line of a given character position in a TextArea gadget.
<br/>
### `Function TextAreaCharX( textarea:TGadget, char )`
Find the x-coordinate of a textarea character position, relative to the upper left corner of the gadget.
The returned value may be greater than the width of the gadget (or even negative) if the specified character
index is positioned outside the immediately visible area of a scrollable TextArea.
<br/>
### `Function TextAreaCharY( textarea:TGadget, char )`
Find the y-coordinate of a textarea character position, relative to the upper left corner of the gadget.
The returned value may be greater than the height of the gadget (or even negative) if the specified character
index is positioned outside the immediately visible area of a scrollable TextArea.
<br/>
### `Function SetTextAreaCaretWidth( textarea:TGadget, width:Int )`
Sets the caret width in a TextArea gadget.
<br/>
### `Function SetTextAreaCaretColor( textarea:TGadget, r:Int, g:Int, b:Int )`
Sets the caret color in a TextArea gadget.
<br/>
### `Function TextAreaHasUndoRedo:Int(textarea:TGadget)`
The TextArea gadget provides its own Undo/Redo facility.
<br/>
### `Function TextAreaEnableUndoRedo(textarea:TGadget, enable:Int)`
Enables or disables undo/redo actions for the specified TextArea gadget.
<br/>
### `Function TextAreaUndoRedoEnabled:Int(textarea:TGadget)`
Returns whether undo/redo actions for the specified TextArea gadget are enabled.
<br/>
### `Function TextAreaUndo(textarea:TGadget)`
Performs an undo action for the given TextArea gadget.
<br/>
### `Function TextAreaRedo(textarea:TGadget)`
Performs a redo action for the given TextArea gadget.
<br/>
### `Function TextAreaCanUndo:Int(textarea:TGadget)`
Returns [True](../../brl/brl.blitz/#true) if the TextArea can perform an undo action.
<br/>
### `Function TextAreaCanRedo:Int(textarea:TGadget)`
Returns [True](../../brl/brl.blitz/#true) if the TextArea can perform a redo action.
<br/>
### `Function TextAreaClearUndoRedo(textarea:TGadget)`
Clears any cached undo/redo actions for the TextArea.
<br/>
### `Function CreateComboBox:TGadget(x,y,w,h,group:TGadget,style=0)`
Create a ComboBox gadget.
A ComboBox gadget provides a dropdown list of items to the user.
The ComboBox supports the following styles:
<table><tr><td> <b>Style</b></td><td><b>Meaning</b></td></tr><tr><td> COMBOBOX_EDITABLE</td><td>Allows the ComboBox to behave similar to a TextField, by allowing typed user input also.</table>
And emits the following events:
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_GADGETACTION</td><td>The selection has been cleared, or the text has changed.</table>
See Also: [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null), [ClearGadgetItems](../../maxgui/maxgui.maxgui/#function-cleargadgetitems-gadget-tgadget), [ModifyGadgetItem](../../maxgui/maxgui.maxgui/#function-modifygadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null), [SelectGadgetItem](../../maxgui/maxgui.maxgui/#function-selectgadgetitem-gadget-tgadget-index),
[RemoveGadgetItem](../../maxgui/maxgui.maxgui/#function-removegadgetitem-gadget-tgadget-index), [SelectedGadgetItem](../../maxgui/maxgui.maxgui/#function-selectedgadgetitem-gadget-tgadget) and [SetGadgetIconStrip](../../maxgui/maxgui.maxgui/#function-setgadgeticonstrip-gadget-tgadget-iconstrip-ticonstrip).
#### Example
blitzmax
' createcombobox.bmx
Strict
Import MaxGui.Drivers
AppTitle = "ComboBox Style Example"
Global window:TGadget = CreateWindow( AppTitle, 100, 100, 300, 200, Null, WINDOW_TITLEBAR|WINDOW_STATUS )
CreateLabel( "No Style (0): ", 5, 5, ClientWidth(window)-10, 24, window, LABEL_LEFT )
Global stdComboBox:TGadget = CreateComboBox( 5, 29, ClientWidth(window)-10, 26, window, 0 )
AddGadgetItem stdComboBox, "Short"
AddGadgetItem stdComboBox, "Medium"
AddGadgetItem stdComboBox, "Fat", True
AddGadgetItem stdComboBox, "Humungous"
CreateLabel( "COMBOBOX_EDITABLE: ", 5, 59, ClientWidth(window)-10, 24, window, LABEL_LEFT )
Global editcombobox:TGadget = CreateComboBox( 5, 83, ClientWidth(window)-10, 26, window, COMBOBOX_EDITABLE )
AddGadgetItem editcombobox, "United Kingdom"
AddGadgetItem editcombobox, "United States", True
Local tmpText$
Repeat
WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
'Combobox Event(s)
'EventData() holds the index of the selected item (or -1 if no item is currently selected)
Case EVENT_GADGETACTION
Select EventSource()
Case stdComboBox
tmpText = ""
If EventData() > -1 Then
tmpText = GadgetItemText(TGadget(EventSource()), EventData())
EndIf
SetStatusText window, "Weight chosen: " + tmpText
Case editComboBox
tmpText = ""
If EventData() > -1 Then
tmpText = GadgetItemText(TGadget(EventSource()), EventData())
Else
tmpText = GadgetText(TGadget(EventSource())) + " [user text]"
EndIf
SetStatusText window, "Country chosen: " + tmpText
EndSelect
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
End
EndSelect
Forever
<br/>
### `Function CreateListBox:TGadget(x,y,w,h,group:TGadget,style=0)`
Create a ListBox gadget.
A ListBox gadget displays a scrollable list of items and generates the following events:
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_GADGETSELECT</td><td>An item has been selected, or the selection has been cleared.</td></tr><tr><td> EVENT_GADGETACTION</td><td>An item has been double-clicked.</td></tr><tr><td> EVENT_GADGETMENU</td><td>The user has right-clicked somewhere in the listbox.</table>
See Also: [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null), [ClearGadgetItems](../../maxgui/maxgui.maxgui/#function-cleargadgetitems-gadget-tgadget), [ModifyGadgetItem](../../maxgui/maxgui.maxgui/#function-modifygadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null), [SelectGadgetItem](../../maxgui/maxgui.maxgui/#function-selectgadgetitem-gadget-tgadget-index),
[RemoveGadgetItem](../../maxgui/maxgui.maxgui/#function-removegadgetitem-gadget-tgadget-index), [SelectedGadgetItem](../../maxgui/maxgui.maxgui/#function-selectedgadgetitem-gadget-tgadget), [SelectedGadgetItems](../../maxgui/maxgui.maxgui/#function-selectedgadgetitems-gadget-tgadget) and [SetGadgetIconStrip](../../maxgui/maxgui.maxgui/#function-setgadgeticonstrip-gadget-tgadget-iconstrip-ticonstrip).
#### Example
blitzmax
' createlistbox.bmx
Strict
Import MaxGui.Drivers
AppTitle = "ListBox Example"
Global window:TGadget = CreateWindow( AppTitle, 100, 100, 200, 200, Null, WINDOW_TITLEBAR|WINDOW_STATUS|WINDOW_RESIZABLE )
Global listbox:TGadget = CreateListBox( 0, 0, ClientWidth(window), ClientHeight(window), window )
SetGadgetLayout listbox, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED
SetGadgetIconStrip listbox, LoadIconStrip("toolbar.png")
AddGadgetItem listbox, "New", False, 0, "Create something."
AddGadgetItem listbox, "Open", False, 1, "Open something."
AddGadgetItem listbox, "Save", False, 2, "Save something.", "Extra Item Object!"
AddGadgetItem listbox, "No Icon", False, -1, "This should not have an icon set."
SelectGadgetItem listbox, 2
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE;End
'ListBox Event(s)
'EventData() holds the index of the corresponding listbox item.
Case EVENT_GADGETSELECT
SetStatusText window, "Selected Item Index: " + EventData()
Case EVENT_GADGETACTION
SetStatusText window, "Double-Clicked Item Index: " + EventData()
Case EVENT_GADGETMENU
SetStatusText window, "Right-Clicked Item Index: " + EventData()
End Select
Wend
<br/>
### `Function CreateTabber:TGadget(x,y,w,h,group:TGadget,style=0)`
Create a Tabber gadget.
A Tabber gadget shows a list of tabs above a client area, typically used for
handling multiple documents/panels.
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_GADGETACTION</td><td>A new tab has been selected. Event data contains the tab index.</td></tr><tr><td> EVENT_GADGETMENU</td><td>A tab has been right-clicked. Event data contains the tab index.</table>
Event extra for both events point to the [GadgetItemExtra](../../maxgui/maxgui.maxgui/#function-gadgetitemextra-object-gadget-tgadget-index) object set for the corresponding tab item index in the latest call
to [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null) / [InsertGadgetItem](../../maxgui/maxgui.maxgui/#function-insertgadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null) or [ModifyGadgetItem](../../maxgui/maxgui.maxgui/#function-modifygadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null).
It is important to note also that, similar to [SelectedGadgetItem](../../maxgui/maxgui.maxgui/#function-selectedgadgetitem-gadget-tgadget), either event may be emitted with the event
data set to '-1'. This either means that somehow the user has deselected a tab, or that the user
has right-clicked on an area of the tabber which doesn't represent a particular tab item index. As
such, your MaxGUI applications should check the value before proceeding to use it with any of the
standard [GadgetItemText](../../maxgui/maxgui.maxgui/#function-gadgetitemtext-gadget-tgadget-index), [GadgetItemExtra](../../maxgui/maxgui.maxgui/#function-gadgetitemextra-object-gadget-tgadget-index) etc. commands.
See Also: [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null), [ClearGadgetItems](../../maxgui/maxgui.maxgui/#function-cleargadgetitems-gadget-tgadget), [ModifyGadgetItem](../../maxgui/maxgui.maxgui/#function-modifygadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null), [SelectGadgetItem](../../maxgui/maxgui.maxgui/#function-selectgadgetitem-gadget-tgadget-index),
[RemoveGadgetItem](../../maxgui/maxgui.maxgui/#function-removegadgetitem-gadget-tgadget-index), [SelectedGadgetItem](../../maxgui/maxgui.maxgui/#function-selectedgadgetitem-gadget-tgadget) and [SetGadgetIconStrip](../../maxgui/maxgui.maxgui/#function-setgadgeticonstrip-gadget-tgadget-iconstrip-ticonstrip).
#### Example
blitzmax
' createtabber.bmx
Import MaxGui.Drivers
Strict
Local window:TGadget
Local tabber:TGadget
Local document:TGadget[3]
Local currentdocument:TGadget
' CreateDocument creates a hidden panel that fills entire tabber client area
Function CreateDocument:TGadget(tabber:TGadget)
Local panel:TGadget
panel=CreatePanel(0,0,ClientWidth(tabber),ClientHeight(tabber),tabber)
SetGadgetLayout panel,1,1,1,1
HideGadget panel
Return panel
End Function
' create a default window with a tabber gadget that fills entire client area
window=CreateWindow("My Window",30,20,400,300)
tabber=CreateTabber(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetLayout tabber,1,1,1,1
' add three items and corresponding document panels to the tabber
AddGadgetItem tabber,"Document 0 R",False,-1,""
AddGadgetItem tabber,"Document 1 G",False,-1,"Tabber Tip 1"
AddGadgetItem tabber,"Document 2 B",False,-1,"tips 4 2"
document[0]=CreateDocument(tabber)
document[1]=CreateDocument(tabber)
document[2]=CreateDocument(tabber)
SetPanelColor document[0],255,200,200
SetPanelColor document[1],200,255,200
SetPanelColor document[2],200,200,255
' our documents start off hidden so make first one current and show
currentdocument=document[0]
ShowGadget currentdocument
' standard message loop with special tabber EVENT_GADGETACTION and EVENT_GADGETMENU handling
While WaitEvent()
Select EventID()
Case EVENT_GADGETACTION
If EventSource()=tabber
HideGadget currentdocument
currentdocument=document[EventData()]
ShowGadget currentdocument
EndIf
Case EVENT_GADGETMENU
If EventSource()=tabber
Notify "You right clicked the tab with index " + EventData() + "!"
EndIf
Case EVENT_WINDOWCLOSE
End
End Select
Wend
<br/>
### `Function ClearGadgetItems(gadget:TGadget)`
Remove all items added to a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function AddGadgetItem(gadget:TGadget,Text$,flags=0,icon=-1,tip$="",extra:Object=Null)`
Add an item to a list based gadget.
An item can be added to the ComboBox, ListBox, Tabber and Toolbar list based gadgets.
Its <b>text</b> parameter is used as its label.
The <b>flags</b> parameter can be a combination of the following values:
<table><tr><td> <b>Flag</b></td><td><b>Meaning</b></td></tr><tr><td> GADGETITEM_NORMAL</td><td>A plain gadget item.</td></tr><tr><td> GADGETITEM_DEFAULT</td><td>The item defaults to a selected state.</td></tr><tr><td> GADGETITEM_TOGGLE</td><td>The item alternates between selected states when pressed.</td></tr><tr><td> GADGETITEM_LOCALIZED</td><td>The item text and tooltip are localization strings.</table>
The <b>tip</b>$ parameter attaches an optional tooltip to the item.
The optional <b>icon</b> parameter specifies an icon from the gadget's IconStrip (see [SetGadgetIconStrip](../../maxgui/maxgui.maxgui/#function-setgadgeticonstrip-gadget-tgadget-iconstrip-ticonstrip)).
The <b>extra</b> parameter is supplied in the EventExtra field of any Event generated by the Item.
See Also: [InsertGadgetItem](../../maxgui/maxgui.maxgui/#function-insertgadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null), [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [SetGadgetIconStrip](../../maxgui/maxgui.maxgui/#function-setgadgeticonstrip-gadget-tgadget-iconstrip-ticonstrip).
<br/>
### `Function InsertGadgetItem(gadget:TGadget,index,Text$,flags=0,icon=-1,tip$="",extra:Object=Null)`
Inserts an item in a list based gadget at the specified index.
An item can be inserted in a ComboBox, ListBox, Tabber and Toolbar list based gadgets.
See [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null) for a description of the parameters.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0) and [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function ModifyGadgetItem( gadget:TGadget,index,Text$,flags=0,icon=-1,tip$="",extra:Object=Null )`
Modify the properties of a gadget-item.
See [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null) for a description of the parameters.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0) and [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function RemoveGadgetItem( gadget:TGadget,index )`
Remove a gadget-item from a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0) and [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function EnableGadgetItem( gadget:TGadget,index )`
Enable a particular item in a list based gadget.
Typically, this can only be used on toolbars.
See Also: [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function DisableGadgetItem( gadget:TGadget,index )`
Disable a particular item in a list based gadget.
Typically, this can only be used on toolbars.
See Also: [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function SelectGadgetItem(gadget:TGadget,index)`
Select an item in a list based gadget.
See Also: [DeselectGadgetItem](../../maxgui/maxgui.maxgui/#function-deselectgadgetitem-gadget-tgadget-index), [ToggleGadgetItem](../../maxgui/maxgui.maxgui/#function-togglegadgetitem-gadget-tgadget-index), [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function DeselectGadgetItem(gadget:TGadget,index)`
Deselect an item in a list based gadget.
See Also: [SelectGadgetItem](../../maxgui/maxgui.maxgui/#function-selectgadgetitem-gadget-tgadget-index), [ToggleGadgetItem](../../maxgui/maxgui.maxgui/#function-togglegadgetitem-gadget-tgadget-index), [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function ToggleGadgetItem(gadget:TGadget,index)`
Invert the selected state of an item in a list based gadget.
See Also: [SelectGadgetItem](../../maxgui/maxgui.maxgui/#function-selectgadgetitem-gadget-tgadget-index), [DeselectGadgetItem](../../maxgui/maxgui.maxgui/#function-deselectgadgetitem-gadget-tgadget-index) and [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function SelectedGadgetItem(gadget:TGadget)`
Get the index of the first selected item in a list based gadget.
SelectedGadgetItem will return -1 if the list based gadget has no selected items.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function SelectedGadgetItems[](gadget:TGadget)`
Returns an integer array of the selected item indexes in a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function CountGadgetItems( gadget:TGadget )`
Get the number of items in a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0) and [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function GadgetItemText$( gadget:TGadget,index )`
Get the text of a given item in a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function GadgetItemTooltip$( gadget:TGadget,index )`
Get the tooltip of a given item in a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function GadgetItemIcon( gadget:TGadget,index )`
Get the icon of a given item in a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function GadgetItemExtra:Object( gadget:TGadget,index )`
Get the extra data of a given item in a list based gadget.
See Also: [CreateComboBox](../../maxgui/maxgui.maxgui/#function-createcombobox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateListBox](../../maxgui/maxgui.maxgui/#function-createlistbox-tgadget-x-y-w-h-group-tgadget-style-0), [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0) and [CreateTabber](../../maxgui/maxgui.maxgui/#function-createtabber-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function GadgetItemFlags( gadget:TGadget,index )`
Get the flags parameter of a given item in a list based gadget.
See Also: [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null)
<br/>
### `Function CreateToolBar:TGadget(source:Object,x,y,w,h,window:TGadget,style=0)`
Creates a window toolbar.
A Toolbar is created from an iconstrip - an image that contains a row of equally shaped icons.
Any images in the row left blank are treated as Toolbar separators.
Toolbars are positioned along the top of the <b>window</b> and either the client-area and/or window frame will be
resized so that the client area of the window will begin just below the toolbar.
At present, MaxGUI windows only support one toolbar at a time.
A Toolbar generates the following events:
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_GADGETACTION</td><td>A toolbar item has been selected/clicked. Event data contains the item index.</table>
The <b>source</b> parameter can be a previously loaded <b>TIconStrip</b>, a [TPixmap](../../brl/brl.pixmap/tpixmap) or a URL to an image
file which <b>CreateToolBar</b> will attempt to load an icon-strip from automatically.
The recommended icon size is 24x24 pixels which seems to work well on most platforms. Using a
different icon size may result in the pixmaps being scaled before being set depending on the OS.
The <b>x</b>, <b>y</b>, <b>w</b>, <b>h</b> parameters are all ignored and are simply there to make the CreateToolbar() system call
consistent with the other <b>CreateGadget()</b> calls.
The toolbar can be alterted during runtime using the [ClearGadgetItems](../../maxgui/maxgui.maxgui/#function-cleargadgetitems-gadget-tgadget), [InsertGadgetItem](../../maxgui/maxgui.maxgui/#function-insertgadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null), [ModifyGadgetItem](../../maxgui/maxgui.maxgui/#function-modifygadgetitem-gadget-tgadget-index-text-flags-0-icon-1-tip-extra-object-null) etc.
functions. Use the GADGETICON_SEPARATOR constant as an item's icon if you want it to be a separator, or
GADGETICON_BLANK if you would like a blank square icon instead.
<i>IMPORTANT: Toolbars should only be parented to window gadgets. Parenting a toolbar to a panel is not
officially supported - users are strongly advised to instead use push-buttons with pixmap icons set. Debug builds
will output a warning message to standard error if toolbars are parented otherwise.</i>
See Also: [AddGadgetItem](../../maxgui/maxgui.maxgui/#function-addgadgetitem-gadget-tgadget-text-flags-0-icon-1-tip-extra-object-null), [EnableGadgetItem](../../maxgui/maxgui.maxgui/#function-enablegadgetitem-gadget-tgadget-index), [DisableGadgetItem](../../maxgui/maxgui.maxgui/#function-disablegadgetitem-gadget-tgadget-index) and [SetToolbarTips](../../maxgui/maxgui.maxgui/#function-settoolbartips-toolbar-tgadget-tips).
#### Example
blitzmax
' createtoolbar.bmx
Strict
Import MaxGui.Drivers
AppTitle = "ToolBar Example"
Global window:TGadget = CreateWindow( AppTitle, 100, 100, 400, 32, Null, WINDOW_TITLEBAR|WINDOW_STATUS|WINDOW_RESIZABLE|WINDOW_CLIENTCOORDS )
Global toolbar:TGadget = CreateToolBar( "toolbar.png", 0, 0, 0, 0, window )
DisableGadgetItem toolbar, 2
SetToolBarTips toolbar, ["New", "Open", "Save should be disabled."]
AddGadgetItem toolbar, "", 0, GADGETICON_SEPARATOR 'Add a separator.
AddGadgetItem toolbar, "Toggle", GADGETITEM_TOGGLE, 2, "This toggle button should change to a light bulb when clicked."
Global button:TGadget = CreateButton( "Show/Hide Toolbar", 2, 2, 180, 28, window )
SetGadgetLayout button, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE;End
'ToolBar Event(s)
'EventData() holds the index of the toolbar item clicked.
Case EVENT_GADGETACTION
Select EventSource()
Case button
If GadgetHidden(toolbar) Then ShowGadget(toolbar) Else HideGadget(toolbar)
Case toolbar
SetStatusText window, "Toolbar Item Clicked: " + EventData()
EndSelect
End Select
Wend
<br/>
### `Function SetToolBarTips( toolbar:TGadget,tips$[] )`
Attach a list of tips to a Toolbar gadget.
Simply provides a quick way to set the tooltips of a toolbar's items after them being added.
See Also: [CreateToolbar](../../maxgui/maxgui.maxgui/#function-createtoolbar-tgadget-source-object-x-y-w-h-window-tgadget-style-0)
<br/>
### `Function CreateTreeView:TGadget(x,y,w,h,group:TGadget,style=0)`
Create a TreeView gadget.
A TreeView provides a view of an expandable list of nodes populated with the
[AddTreeViewNode](../../maxgui/maxgui.maxgui/#function-addtreeviewnode-tgadget-text-node-tgadget-icon-1-extra-object-null) command. TreeView nodes can themselves contain nodes providing
a flexible method of displaying a hierachy of information.
<table><tr><td> <b>Event ID</b></td><td><b>Description</b></td></tr><tr><td> EVENT_GADGETSELECT</td><td>The user has selected a node.</td></tr><tr><td> EVENT_GADGETACTION</td><td>The user has double-clicked a node.</td></tr><tr><td> EVENT_GADGETOPEN</td><td>The user has expanded a node, revealing its children.</td></tr><tr><td> EVENT_GADGETCLOSE</td><td>The user has collapsed a node, hiding its children.</td></tr><tr><td> EVENT_GADGETMENU</td><td>The user has right-clicked somewhere in the TreeView.</table>
Each event will have the containing TreeView gadget as the event source and the concerned
node gadget in the EventExtra field of the [TEvent](../../brl/brl.event/tevent).
See Also: [AddTreeViewNode](../../maxgui/maxgui.maxgui/#function-addtreeviewnode-tgadget-text-node-tgadget-icon-1-extra-object-null), [InsertTreeViewNode](../../maxgui/maxgui.maxgui/#function-inserttreeviewnode-tgadget-index-text-node-tgadget-icon-1-extra-object-null), [ModifyTreeViewNode](../../maxgui/maxgui.maxgui/#function-modifytreeviewnode-node-tgadget-text-icon-1), [TreeViewRoot](../../maxgui/maxgui.maxgui/#function-treeviewroot-tgadget-treeview-tgadget),
[SelectedTreeViewNode](../../maxgui/maxgui.maxgui/#function-selectedtreeviewnode-tgadget-treeview-tgadget) and [CountTreeViewNodes](../../maxgui/maxgui.maxgui/#function-counttreeviewnodes-node-tgadget), [SelectTreeViewNode](../../maxgui/maxgui.maxgui/#function-selecttreeviewnode-node-tgadget), [ExpandTreeViewNode](../../maxgui/maxgui.maxgui/#function-expandtreeviewnode-node-tgadget),
[CollapseTreeViewNode](../../maxgui/maxgui.maxgui/#function-collapsetreeviewnode-node-tgadget) and [FreeTreeViewNode](../../maxgui/maxgui.maxgui/#function-freetreeviewnode-node-tgadget).
#### Example
blitzmax
' createtreeview.bmx
Import MaxGui.Drivers
Strict
Local window:TGadget=CreateWindow("My Window",50,50,240,240,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS)
Local treeview:TGadget=CreateTreeView(5,5,ClientWidth(window)-10,ClientHeight(window)-10,window)
SetGadgetLayout treeview, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED
Local root:TGadget=TreeViewRoot(treeview)
Local help:TGadget=AddTreeViewNode("Help",root)
AddTreeViewNode "Topic 1",help
AddTreeViewNode "Topic 2",help
AddTreeViewNode "Topic 3",help
Local projects:TGadget=AddTreeViewNode("Projects",root)
AddTreeViewNode("Sub Project",AddTreeViewNode("Project 1",projects))
AddTreeViewNode("Project 2",projects)
AddTreeViewNode("Project 3",projects)
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Wend
<br/>
### `Function AddTreeViewNode:TGadget( Text$,node:TGadget,icon=-1,extra:Object=Null )`
Add a node to a TreeView gadget.
The optional <b>extra</b> parameter is for convenience and is equivalent to calling
[SetGadgetExtra](../../maxgui/maxgui.maxgui/#function-setgadgetextra-gadget-tgadget-extra-object) immediately after the node is created.
See Also: [CreateTreeView](../../maxgui/maxgui.maxgui/#function-createtreeview-tgadget-x-y-w-h-group-tgadget-style-0), [InsertTreeViewNode](../../maxgui/maxgui.maxgui/#function-inserttreeviewnode-tgadget-index-text-node-tgadget-icon-1-extra-object-null)
<br/>
### `Function InsertTreeViewNode:TGadget( index,Text$,node:TGadget,icon=-1,extra:Object=Null )`
Insert a node at a given index in a TreeView gadget.
The optional <b>extra</b> parameter is for convenience and is equivalent to calling
[SetGadgetExtra](../../maxgui/maxgui.maxgui/#function-setgadgetextra-gadget-tgadget-extra-object) immediately after the node is created.
See Also: [CreateTreeView](../../maxgui/maxgui.maxgui/#function-createtreeview-tgadget-x-y-w-h-group-tgadget-style-0), [AddTreeViewNode](../../maxgui/maxgui.maxgui/#function-addtreeviewnode-tgadget-text-node-tgadget-icon-1-extra-object-null)
<br/>
### `Function ModifyTreeViewNode( node:TGadget,Text$,icon=-1 )`
Modify a node.
See Also: [CreateTreeView](../../maxgui/maxgui.maxgui/#function-createtreeview-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function ClearTreeView( treeview:TGadget )`
Frees all the nodes of a TreeView.
See Also: [CreateTreeView](../../maxgui/maxgui.maxgui/#function-createtreeview-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function TreeViewRoot:TGadget( treeview:TGadget )`
Get the root node of a TreeView gadget.
This is required to parent the first nodes of a blank treeview to.
A treeview's root node can also be used to deselect any currently selected
nodes (see [SelectTreeViewNode](../../maxgui/maxgui.maxgui/#function-selecttreeviewnode-node-tgadget) for more information).
See Also: [CreateTreeView](../../maxgui/maxgui.maxgui/#function-createtreeview-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function SelectedTreeViewNode:TGadget( treeview:TGadget )`
Get the node currently selected in a TreeView gadget.
Will return [Null](../../brl/brl.blitz/#null) if there aren't any nodes currently selected.
See Also: [CreateTreeView](../../maxgui/maxgui.maxgui/#function-createtreeview-tgadget-x-y-w-h-group-tgadget-style-0), [SelectTreeViewNode](../../maxgui/maxgui.maxgui/#function-selecttreeviewnode-node-tgadget)
<br/>
### `Function CountTreeViewNodes( node:TGadget )`
Get the number of children of a Node gadget.
See Also: [CreateTreeView](../../maxgui/maxgui.maxgui/#function-createtreeview-tgadget-x-y-w-h-group-tgadget-style-0)
<br/>
### `Function SelectTreeViewNode( node:TGadget )`
Selects/highlights a treeview node.
It is possible to deselect a selection by selecting a treeview's root node.
For example:
SelectTreeViewNode( TreeViewRoot( myTree ) )
````
See Also: CreateTreeView, SelectedTreeViewNode
Function ExpandTreeViewNode( node:TGadget )
Expands a treeview node in a TreeView gadget.
See Also: CreateTreeView, CollapseTreeViewNode
Function CollapseTreeViewNode( node:TGadget )
Collapses a treeview node in a TreeView gadget.
See Also: CreateTreeView, ExpandTreeViewNode
Function FreeTreeViewNode( node:TGadget )
Removes a treeview node from a TreeView gadget.
This function has been superseded by FreeGadget, but is available for backwards compatability.
See Also: CreateTreeView
Function CreateHTMLView:TGadget(x,y,w,h,group:TGadget,style=0)
Create an HTMLView gadget.
The HTMLView is a complete web browser object inside a MaxGUI gadget. The HTML
page displayed is controlled with the HTMLViewGo command or from the user navigating
from within the currently viewed page.
CreateHTMLView supports the following styles:
| Style | Meaning |
| HTMLVIEW_NOCONTEXTMENU | The webpage's default context menu is disabled. |
| HTMLVIEW_NONAVIGATE | User navigation is disabled and EVENT_GADGETACTION is generated instead. |
| Event ID | Description |
| EVENT_GADGETDONE | Generated when a webpage has finished loading or a page anchor has been scrolled to. |
| EVENT_GADGETACTION | Generated when a user clicks a link. Event Text contains the requested URL. |
Note: EVENT_GADGETACTION requires the HTMLVIEW_NONAVIGATE style flag.
See Also: HtmlViewGo, HtmlViewBack, HtmlViewForward, HtmlViewStatus and HtmlViewCurrentURL.
Example
' createhtmlview.bmx
Import MaxGui.Drivers
Strict
Local window:TGadget
Local htmlview:TGadget
window=CreateWindow("My Window",30,20,600,440,,15|WINDOW_ACCEPTFILES)
htmlview=CreateHTMLView(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetLayout htmlview,1,1,1,1
HtmlViewGo htmlview,"www.blitzmax.com"
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Wend
Function HtmlViewGo( view:TGadget,url$ )
Direct the HTMLView gadget to a new URL.
See Also: CreateHTMLView
Function HtmlViewBack( view:TGadget )
Go back a page in an HTMLView gadget.
See Also: CreateHTMLView
Function HtmlViewForward( view:TGadget )
Go forward a page in an HTMLView gadget.
See Also: CreateHTMLView
Function HtmlViewStatus( view:TGadget )
Get the status of an HTMLView gadget.
See Also: CreateHTMLView
Function HtmlViewCurrentURL$( view:TGadget )
Get the current URL of an HTMLView gadget.
See Also: CreateHTMLView
Function HtmlViewRun$( view:TGadget,script$ )
Run a script in an HTMLView gadget.
See Also: CreateHTMLView
Function CreateLabel:TGadget( name$,x,y,w,h,group:TGadget,style=LABEL_LEFT )
Create a Label gadget.
A Label gadget is used to place static text or frames in a MaxGUI user interface. They do not
generate any events.
Labels support these optional styles:
| Style | Meaning |
| LABEL_FRAME | The label has a simple border. |
| LABEL_SUNKENFRAME | The label has a sunken border. |
| LABEL_SEPARATOR | The label is an etched box with no text useful for drawing separators. |
| LABEL_LEFT | The label's text is left-aligned. This is the default. |
| LABEL_CENTER | The label's text is center-aligned. |
| LABEL_RIGHT | The label's text is right-aligned. |
See Also: SetGadgetText, SetGadgetTextColor, SetGadgetFont and SetGadgetColor.
Example
' createlabel.bmx
Import MaxGui.Drivers
Strict
Local window:TGadget
window=CreateWindow("My Window",30,20,320,480)
CreateLabel("A plain label",10,10,280,52,window)
CreateLabel("A label with LABEL_FRAME",10,80,280,60,window,LABEL_FRAME)
CreateLabel("A label with LABEL_SUNKENFRAME",10,150,280,60,window,LABEL_SUNKENFRAME)
CreateLabel("not applicable",10,220,280,54,window,LABEL_SEPARATOR)
While WaitEvent()<>EVENT_WINDOWCLOSE
Wend
Function CreateSlider:TGadget( x,y,w,h,group:TGadget,style=0 )
Create a Slider gadget.
A Slider gadget supports the following styles:
| Style | Meaning |
| SLIDER_HORIZONTAL | The slider is moved left and right. |
| SLIDER_VERTICAL | The slider is moved up and down. |
| SLIDER_SCROLLBAR | The slider uses a proportional size knob. |
| SLIDER_TRACKBAR | The slider uses a fixed size knob. |
| SLIDER_STEPPER | The slider has no knob, just arrow buttons. |
A slider only emits one type of event:
| Event ID | Description |
| EVENT_GADGETACTION | The user has changed the slider's value. Event Data contains the SliderValue. |
See Also: SetSliderRange, SetSliderValue and SliderValue
Example
' createslider.bmx
Import MaxGui.Drivers
Strict
Local window:TGadget=CreateWindow("My Window",0,0,240,240,,WINDOW_TITLEBAR)
Local slider:TGadget[3]
' standard vertical and horizontal scroll bars
slider[0]=CreateSlider(10,10,16,100,window,SLIDER_VERTICAL)
slider[1]=CreateSlider(30,10,100,16,window,SLIDER_HORIZONTAL)
' a horizontal trackbar
slider[2]=CreateSlider(30,30,100,24,window,SLIDER_HORIZONTAL|SLIDER_TRACKBAR)
' a row of vertical trackbars
Local trackbar:TGadget[5]
For Local i=0 To 4
trackbar[i]=CreateSlider(30+i*20,50,16,60,window,SLIDER_VERTICAL|SLIDER_TRACKBAR)
Next
' a single stepper
Local stepper:TGadget
stepper=CreateSlider(10,120,24,24,window,SLIDER_STEPPER)
SetSliderValue stepper,4
Print SliderValue(stepper)
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Wend
Function SetSliderRange( slider:TGadget,range0,range1 )
Set the range of a Slider gadget.
For the default SLIDER_SCROLLBAR style the range0,range1 parameters are treated
as a visible / total ratio which dictates both the size of the knob and it's
maximum value. The default value is 1,10 which displays a Slider with a knob
that occupies 1/10th the area and with a SliderValue range of 0..9.
For the SLIDER_TRACKBAR and SLIDER_STEPPER styles the range0,range1 parameters
are treated as the minimum and maximum SliderValue range inclusive.
See Also: CreateSlider, SliderValue and SetSliderValue
Function SetSliderValue( slider:TGadget,value )
Set the position of a Slider gadget.
See Also: CreateSlider, SetSliderRange and SliderValue
Function SliderValue( slider:TGadget )
Get the position of a Slider gadget.
See Also: CreateSlider, SetSliderRange and SetSliderValue
Function CreateProgBar:TGadget( x,y,w,h,group:TGadget,style=0 )
Create a Progress Bar gadget.
Similar to Labels, Progress Bar gadgets do not generate any events themselves.
See Also: UpdateProgBar
Example
' createprogbar.bmx
Import MaxGui.Drivers
Strict
Local window:TGadget=CreateWindow("My Window",50,50,240,100,,WINDOW_TITLEBAR)
Local progbar:TGadget=CreateProgBar(10,10,200,20,window)
CreateLabel "Please Wait",10,40,200,20,window
CreateTimer 10
While WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_TIMERTICK
Local t=EventData()
If t=50 End
UpdateProgBar progbar,t/50.0
End Select
Wend
Function UpdateProgBar( progbar:TGadget,value# )
Update the display of a ProgressBar gadget.
See Also: CreateProgBar
Function LoadIconStrip:TIconStrip( source:Object )
Creates an icon strip from an image file.
An icon strip is a series of small images that can be attached to item-based gadgets.
Icons must be square, and arranged in a single horizontal strip across the source image.
The number of icons in an iconstrip is determined by dividing the image width by its height. For example,
an iconstrip 64 wide by 8 high is assumed to contain 64/8=8 icons.
Once an icon strip has been loaded, it can be attached to item-based gadgets using SetGadgetIconStrip.
See Also: SetGadgetIconStrip and PixmapFromIconStrip
Function SetGadgetIconStrip( gadget:TGadget,iconstrip:TIconStrip )
Attaches an icon strip to an item-based gadget.
Once attached, icons can be specified when items are added or modified with the AddGadgetItem,
InsertGadgetItem and ModifyGadgetItem commands.
This command may only be used with the ComboBox, ListBox, Tabber and TreeNode gadgets.
Note: It is highly recommended that icon-strips are set before any items are added to a gadget.
See Also: LoadIconStrip
Function PixmapFromIconStrip:TPixmap( iconstrip:TIconStrip, index = -1 )
Returns a pixmap containing either a copy of the original icon-strip or just the specified icon.
iconstrip: The icon-strip to return a pixmap from.
index: The index (base 0) of the icon to extract. If this is negative, a copy of the
original pixmap used to create the iconstrip is returned.
This function will return Null if no iconstrip is passed, or if the icon index is invalid.
See Also: LoadIconStrip
Function CreateCanvas:TGadget( x,y,w,h,group:TGadget,style=0 )
Create a Canvas gadget.
A Canvas provides a Graphics interface for realtime drawing purposes.
Once a Canvas is created, the CanvasGraphics() Function can be used with the
SetGraphics command to direct Max2D drawing commands to be
drawn directly on the Canvas.
An EVENT_GADGETPAINT event is generated whenever the gadget must be redrawn by either
the system (for instance when it is first shown) or due to the RedrawGadget command.
An EVENT_GADGETPAINT handler should always call SetGraphics
with the canvas's Max2D graphics context to ensure the viewport and similar
properties are in their correct state.
When a Canvas is active using either the ActivateGadget command or clicking
on the Canvas when the application is running, the following events will also
be sent from the Canvas:
| Event ID | Description |
| EVENT_MOUSEDOWN | Mouse button pressed. Event data contains mouse button code. |
| EVENT_MOUSEUP | Mouse button released. Event data contains mouse button code. |
| EVENT_MOUSEMOVE | Mouse moved. Event x and y contain mouse coordinates. |
| EVENT_MOUSEWHEEL | Mouse wheel spun. Event data contains delta clicks. |
| EVENT_MOUSEENTER | Mouse entered gadget area. |
| EVENT_MOUSELEAVE | Mouse left gadget area. |
| EVENT_KEYDOWN | Key pressed. Event data contains keycode. |
| EVENT_KEYUP | Key released. Event data contains keycode. |
| EVENT_KEYCHAR | Key character. Event data contains unicode value. |
See Also: ActivateGadget, RedrawGadget, CanvasGraphics
Example
' createcanvas.bmx
Import MaxGui.Drivers
Strict
Global GAME_WIDTH=320
Global GAME_HEIGHT=240
' create a centered window with client size GAME_WIDTH,GAME_HEIGHT
Local wx=(ClientWidth(Desktop())-GAME_WIDTH)/2
Local wy=(ClientHeight(Desktop())-GAME_HEIGHT)/2
Local window:TGadget=CreateWindow("My Canvas",wx,wy,GAME_WIDTH,GAME_HEIGHT,Null,WINDOW_TITLEBAR)'|WINDOW_CLIENTCOORDS)
' create a canvas for our game
Local canvas:TGadget=CreateCanvas(0,0,320,240,window)
' create an update timer
CreateTimer 60
While WaitEvent()
Select EventID()
Case EVENT_TIMERTICK
RedrawGadget canvas
Case EVENT_GADGETPAINT
SetGraphics CanvasGraphics(canvas)
SetOrigin 160,120
SetLineWidth 5
Cls
Local t=MilliSecs()
DrawLine 0,0,120*Cos(t),120*Sin(t)
DrawLine 0,0,80*Cos(t/60),80*Sin(t/60)
Flip
Case EVENT_MOUSEMOVE
Print "MOVE!"
Case EVENT_WINDOWCLOSE
FreeGadget canvas
End
Case EVENT_APPTERMINATE
End
End Select
Wend
Function CanvasGraphics:TGraphics( gadget:TGadget )
Retrieve a Canvas gadget's Graphics context.
The RedrawGadget example shows an alternative method for drawing to Canvas
gadgets utilizing the EVENT_GADGETPAINT event.
See Also: CreateCanvas
Function QueryGadget:Byte Ptr( gadget:TGadget,queryid )
Return internal gadget handle.
QueryGadget retrieves system handles for use with API specific functions.
| Constant | Return Value |
| QUERY_HWND | A Windows API HWND handle. |
| QUERY_HWND_CLIENT | A Windows API HWND handle representing a gadget's client area. |
| QUERY_NSVIEW | A Cocoa NSView handle. |
| QUERY_NSVIEW_CLIENT | A Cocoa NSView representing a gadget's client area. |
| QUERY_FLWIDGET | An FL_WIDGET handle. |
| QUERY_FLWIDGET_CLIENT | An FL_WIDGET handle representing a gadget's client area. |
Function GadgetScaleFactor:Int( gadget:TGadget )
Returns the gadget scale factor that maps from window coordiantes to the actual device pixels.
On traditional systems this is 1, but on very high density outputs this can be a higher value (often 2).