Contact: zegraph  @  yahoo.com      Last update: June 2020

wxWindows Library Reference

None-type functions

Function Parameter Type Remark
wxactive()   Returns true if the top frame is active; false otherwise. example-1.
wxcast(w) user Casts a widget, e.g., a frame, to the base window type for calling window functions. See example-1.
wxexec(cmd) string Executes a DOS command. See example-1.
wxexit()   CLoses the application window. See example-2.
wxframe()  

Returns the application's top frame window as user object, which may be used to call frame functions and may be casted to the base window type to call window functions. See example-1.

wxmsg(msg) string Displays a message. See example-1.
wxsize()  

Returns your display width and height in an array. See example-1.

wxsplit(path) string

Splits the path string and returns an array containing the parts of directory name, file name, and file extension. See example-1.

Top Frame/Dialog functions

Function Parameter Type Remark
.color()   Shows a color dialogbox and return user selected color in an array with [0]=red, [1]=green, and [2]=blue. See example-2.
.directory([path]) string Shows a directory dialogbox and returns user selected directory name or null if canceled. See example-2.
.evth(func) string

Sets callback function for handling events of the top frame. The function will get three inputs with the first being the even name, which may be "size" for sizing event, "timer" for timer event, "paint" for paint event, and "exit" for exit event. The last two inputs will be window's client width and height respectively for sizing event; milliseconds and null for timer event; the handler to the window and null for paint event, and nulls for exit event. See example-2.

.file([path, save]) string, boolean Shows an open/save file dialogbox and return user selected files. The optional parameters are for specifying default path and save mode. The return is null if canceled, string if a single file is selected, or array if multiple files are selected. See example-2.
.size(flag) integer Sets window size to full screen (flag<0), minized screen (flag=0), or maximize screen (flag>0). See example-2.
.icon(fname) string Uses the image in the file as the windows's icon. Supported image formats include "ico", "gif", "png", "xpm", and "xbm". See example-2.
.menubar([s1, s2...]) strings Adds a menu to the menu bar and adds items to menu. It returs an arry containing IDs for menu items. The first string will be the menu name and the rests will be menu item names. A ">" string indicates entering a sub-menu; "<" indicates leaving a sub-menu; "^" indicates entering or leaving a group of checkable items; "@" indicates entering or leaving a group of radio items; and "_" indicates adding a separator to the menu or sub-menu. See example-2.
.menubar()   Returns the menubar in the main frame window, which can call menubar functions. See example-2.
.push(win) user Pushs the windows behind and hides it. See example-5.
.pop(win) user Pop the windows back and shows it. See example-5.
.statusbar(n) integer, string Creates a statusbar with n fields in the window. See example-2.
.statusbar(i, s) integer, string Sets the string s in the ith field of the statusbar. The first field is 0. See example-2.
.title(s) string Sets the window's title. See example-2.
.timer(ms) integer

Starts (ms>0) or stops (ms<=0) the timer of the main frame window. The callback function set by wxevth will be called in every ms milli-seconds with the first parameter being "timer". See example-2.

.toolbar(img, tip[, img, tip...]) strings Creates a toolbar in the window, adds image buttons and tips button-tips to the toolbar bar. It returs an arry containing IDs for toobar items. If the image file name is "|", a separator bar will be added to the toolbar. Supported image formats include "ico", "gif", and "png". See example-2.

Widget functions

Function Parameter Type Remark
.button(caption[, width, height]) string, integer, integer Creates and returns a button widget. See example-3.
.bitmap(fname[transparent, x, y]) string, boolean, integer, integer Fills the client area with the bitmap image. Supported image formats include "gif", "jpeg", "png", and "tiff". If the optional position parameters x and y are given, the image will not be stretched. See example-4.
.bgcolor(red, green, blue) integers Sets the background color of the widget. A color value ranges from 0 to 255. See example-3.
.bgcolor()   Returns the background color components in an array.
.fgcolor(r, g, b) integers Sets the foreground color of the window. A color value ranges from 0 to 255. See example-3.
.fgcolor()   Returns the foreground color components in an array.
.checkbox(caption, flag) string, boolean Creates and returns a checkbox widget with checked (flag=true) or unchecked (flag=false) status. See example-3.
.combobox(items, i) array of string, integer Creates and returns a combobox widgets and sets the ith item as selected (the first one is zero). See example-3.
.cursor(type) string Sets window's cursor. The type parameter may be "arrow", "qarrow", "hand", "ibeam", "noentry", or "wait"; or a image file name. See example-3.
.disable()   Disables the widget. See example-3.
.enable()   Enables the widget. See example-3.
.font(size) integer Sets font size. See example-3.
.font()   Selects a font and sets it to the widget. See example-3.
.focus()   Sets widget to receive input events. See example-3.
.get()   Gets the widget value: integer for slider, radiobutton, and checkbox; string for other type of widgets. See example-3.
.set(value) integer or array of strings or string Sets integer value to slider, radiobutton, or checkbox; sets array of dtring to combobox; or sets string to other type of widgets. See example-3.
.grid(rows, cols) integers Creates a grid widget with the specified number of rows and columns. The widget can call grid functions to set contents in grid cells. See example-4.
.html()   Creates a HTML widget for diaplaying HTML content.
.hwnd()   Returns the window's handle as user object, which may be cast to HWND by other applications for painting.
.id()   Returns the widget ID as integer.
.notebook(style) string Creates and returns a notebook control, which may call notebook functions. The style may be "top", "left", "right", or "bottom". See example-4.
.panel()   Creates and returns a panel for adding widgets. See example-3.
.position(x, y) integers Sets the widget position to (x,y).
.position()   Returns the widget position (x,y) in an array.
.push(callback, event[, id ...]) string, string, integer or array Pushes an event handler on to the window's even handler stack. The callback function will be called when an event occurs. Refer to the event table below for what events will be handled by a handler for widget IDs. An event may be "key", "mouse", "menu", or "tool". For "key" or "mouse" event, the id parameter is not used. For "menu" event, more than one id parameters may be used. See example-2.
.radiobox(caption, style, opt1, opt2[, ...]) strings Creates and returns a radiobox widget. If the style="r", option radio buttons will be arranged in rows; otherwise in columns. See example-3.
.refresh()   Forces the widged to refresh.
.size()   Returns the width and height of the widget's client area as an array. See example-3.
.size(w, h) integers Sets the size of the client area of a widget or the widget size if it is a main frame type. See example-3.
.sizer(type) string Creates a horizontal (type="horbox") or vertical (type="verbox") box sizer. See example-3.
.sizer(type, caption, width, height) string, string, integer, integer Creates a static horizontal (type="horstatic") or vertical (type="verstatic") box sizer. See example-3.
.sizer("flexgrid", rows, rowgap, cols, colgap) string, integers Creates flex grid sizer. See example-3.
.splitter()   Creates a slitter widget. See example-4.
.slider(style, min, max, value[, freq]) string, integers Creates a slider control and returns the object. The style may be "left" for vertical layout and label on the left, "right" for vertical layout and label on the right, "top" for horizontal layout and label on the top, or "bottom" for horizontal layout and label on the bottom. The rest of parameters control the minimum, maximum, and initial values; and the frequency of sliding. See example-3.
.statictext(text[, align, transparent]) string, integer, bollean Creates a static text widget. The text will be right aligned if align>0; center aligned if align=0; and left aligned otherwise. The widget is transparent if flag=true. See example-3.
.style(style) string Sets the widget style. The style string can be parts of the full style string "simple|double|sunken|raised|static|none|vscroll|hscroll|clip", which corresponds to styles of wxSIMPLE_BORDER | DOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxSTATIC_BORDER | wxNO_BORDER | wxVSCROLL | wxHSCROLL | wxCLIP_CHILDREN. See example-3.
.textbox(text[, style, width, height]); string, string, integer, integer Creates and returns a textbox widget. The style string can be parts of the full style string "multiline|password|readonly|left|center|right", which corresponds to styles of wxTE_MULTILINE | wxTE_PASSWORD | wxTE_READONLY | wxTE_LEFT | wxTE_CENTRE | wxTE_RIGHT. The box size will be set to fit the text inside unless width and height are given. See example-3.
.textbox(text[, width, height]); string, integer, integer See above. See example-3.
.treeview([func]); string Creates and returns a treeview widget. If rhe callback function name is given, the function will be called with two parameters: the first being event name the second being the selected item name. See example-4.

Sizer functions

Function Parameter Type Remark
.add(width, height) integer, integer Adds a space sizer to the sizer. See example-3.
.add(obj[, style, prop]) user, string, integer Adds a widget or sizer to the sizer. The full style string "top|bottom|left|right|all|expand|shaped|minsize|aligncenter|alignvertical|alignhorizontal|alignleft|alignright|aligntop|alignbottom" corresponds to wxTOP | wxBOTTOM | wxLEFT | wxRIGHT | wxALL | wxEXPAND | wxSHAPED | wxFIXED_MINSIZE | wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_LEFT | wxALIGN_RIGHT wxALIGN_TOP | wxALIGN_BOTTOM; and the prop sets the proportion of space that control possesses in the sizer (box sizer only). See example-3.
.sizer(type[, style, prop]) string, string, integer Creates a horizontal (type="horbox") or vertical (type="verbox") box sizer in the sizer. See example-3.
.sizer(type, rows, rgap, cols, cgap[, flag, prop]) string, integer, integer integer integer, string, integer Creates a flexible grid (type="flexgrid") sizer in the sizer. See example-3.

Splitter functions

Function Parameter Type Remark
.min(size) integer Sets the minimal panel size. See example-4.
.horizontal(w1, w2, pos) iuser, user, integer Splits w1 and w2 herizontally and sets the split position to to pos. See example-4.
.horizontal(w1, w2, pos) user, user integer Splits w1 and w2 vertically and sets the split position to to pos. See example-4.

Grid functions

Function Parameter Type Remark

.__get(irow, icol)

integers Gets cell content. Row and column indices count from 0. See example-4.

.__set(irow, icol, value)

integer, integer, string Sets cell content. Row and column indices count from 0. See example-4.
.clear()   Clears cells's content
.rows()   Returns the number of rows.
.rows(n) integer Sets the number of rows.
.cols()   Returns the number of columns.
.cols()   Returns the number of columns.
.selcols()   Returns an array containing the seleted colunm IDs.
.width(icol, w) integer Sets the column width.
.height(icol, h) integer Sets the row height.
.enable(icol) integer Enables editting of the column.
.disable(icol) integer Disables editting of the column.
.readonly(irow, icol) integers Set the cell as read-only.

Notebook functions

Function Parameter Type Remark
.add(name,flag) string, boolean Adds a panel to the notebook and returns it, which can be used to call other window functions. If flag indicate whether the page is selected or not. See example-4.
.delete(id) integer Removes the page.
.select(id) integer Sets the page as selected. See example-4.

Treeview functions

Function Parameter Type Remark
.root(name) string Sets root item name. See example-4.
.append(node, item) strings Append a item to a node. See example-4.

Menubar functions

Function Parameter Type Remark
.check(id) integer Gets the checked status of the item. See example-2.
.check(id, flag) integer, boolean Sets the checked status of the item. See example-2.
.enable(id) integer Gets the enabled status of the item. See example-2.
.enable(id, flag) integer, boolean Sets the enabled status of the item. See example-2.
.label(id) integer Returns the label of the item.

HTML functions

Function Parameter Type Remark
.load(fname) string Loads content in the file fname.
.font(pt) integer Sets the font size.

Event Table

event name events Remark
menu wxEVT_COMMAND_MENU_SELECTED The callback function will get 1 integer parameter of the selected menu ID. See example-1.
tool wxEVT_COMMAND_TOOL_CLICKED The callback function will get 1 integer parameter of the selected tool button ID. See example-1.
key wxEVT_KEY_UP The callback function will get 4 integer parameters and a user object of the widget. The first integer is the key code (different from the ASCII code) and the rests indicate key down of control-key, alt-key, and shift-key, respectively. See example-1.
mouse wxEVT_LEFT_DOWN, wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DCLICK, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_UP, wxEVT_RIGHT_DCLICK, wxEVT_MOTION The callback function will get 6 integer parameters and a user object of the widget. The first integer represents event type: 1 to 10 corresponding to the events on the left; the next two are x-y position of mouse; and the rests indicate key down of control-key, alt-key, and shift-key, respectively. See example-1.
combo wxEVT_COMMAND_COMBOBOX_SELECTED The callback function will get 1 user object of the widget that needs painting. See example-4.
paint wxEVT_PAINT The callback function will get 1 user object of the widget that needs painting. See example-4.
size wxEVT_SIZE The callback function will get 2 integer parameters for the widget's width and height, respectively. See example-4.