Contact: zeng  @  zegraph.com      Last update: 20 January 2010

wxWindows Library Reference

None-type functions

Function Parameter Type Remark
wxactive()   Returns true if the top frame is active; false otherwise. You may need to test inactive status (e.g., when the top frome is minimized) to decide whether to update some widgets.
wxcast(w) user Casts a widget, e.g., a frame, to the base window type for calling window functions. See example-1.
wxcolor()   Shows a color dialogbox and return user selected color as an array with [0]=red, [1]=green, and [2]=blue. See example-1.
wxdir([path]) string Shows a directory dialogbox and returns user selected directory name or null if canceled. See example-1.
wxevth(func) string

Sets callback function for handling events of 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-1.

wxexec(file[,args]) strings Executes the file with arguements, which is optional.
wxfile([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 cancel, string if a single file is selected, or array if multiple files are selected. See example-1.
wxfont()   Shows a font dialogbox and return user selected font data in an array, which contains info of encoding, family, face name, size, style, underlined, weight, all integers except for face name. See example-1.
wxmsg(msg) string Displays a message. See example-1.
wxframe() string

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.

wxtimer(ms) integer

Starts (ms>0) or stops (ms<=0) the timer of the main frame window. See example-1.

Top Frame/Dialog functions

Function Parameter Type Remark
.fullscreen(flag) true/false Enables/disables the fullscreen mode of the window. See example-1.
.icon(fname) string Uses the image in the file as the windows's icon. Supported image formats include ".ico", ".gif", ".xpm", and ".xbm".
.menubar([s1, s2...]) strings Creates a menubar in the window, adds menus to the menu bar, and adds items to menus. It returs an arry containing IDs for menu items. A new menu bar is always created the first time to call or for a call with no argument. The first string will be the main menu name and the rests will be menu items. If the first character of a item ">", a sub-menu will be created with the next item as the sub-menu name and the following items will be added to the sub-menu; if the first character of a item is "<", the following items will be added to the main menu; and if the first character of a item is "_", a separator bar will be added to the menu or sub-menu. See example-1.
.show(flag) true/false Shows the dialog window in modal (flag=true) or modalless mode (flag=false). See example-1.
.statusbar(n) integer, string Creates a statusbar in the window. See example-1.
.statusbar(n, s) integer, string Shows the string in the nth field of the statusbar. The first field is 0. See example-1.
.title(s) string Sets the window's title. See example-1.
.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 ".bmp", ".gif", ".xpm", ".jpg", ".png", ".tif", ".pcx", ".pnm", ".ico", and "cur". See example-1.

Widget functions

Function Parameter Type Remark
.button(caption) string Creates a button control and returns the object. See example-2.
.bitmap(fname[transparent, x, y]) string, boolean, integer, integer Fills the client area with the bitmap image. Supported image formats include ".bmp", ".gif", ".xpm", ".jpg", ".png", ".tif", ".pcx", ".pnm", ".ico", "cur". If the optional position parameters (x,y) are given, the image will not be stretched.
.bgcolor(r, g, b) integers Sets the background color of the window. A color value ranges from 0 to 255. See example-2.
.checkbox(caption, checked) string, true/false Creates a checkbox control and returns the object. See example-2.
.close()   Usually called to close the main frame window.
.combobox([item1, item2[, ...], selected) strings, integer Creates a combobox control and sets selected item index (the first one is zero) the object. See example-2.
.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-2.
.dialog([style]) true/false, string Creates a dialog box and returns it as user object, which can call frame functions and may be casted to the base window type for calling window functions. The style string can be parts of the full style string "caption|resize|close|minimize|maximize|thick|no3d" corresponding to styles of wxCAPTION | wxRESIZE_BORDER | wxCLOSE_BOX | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxTHICK_FRAME | wxSTAY_ON_TOP | wxNO_3D. See example-2.
.disable()   Disables the control.
.enable()   Enables the control.
.fgcolor(r, g, b) integers Sets the foreground color of the window. A color value ranges from 0 to 255. See example-2.
.font(fnt) integer or array Sets font size if fnt is integer; otherwise sets font using data in the array returned from fontdialog() function. See example-2.
.focus()   Sets widget to receive input events.
.get()   Gets the widget label as string. See example-2.
.grid(rows, cols) integers Creates a grid control with the specified number of rows and columns. See example-4.
.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.
.label(str) string Sets window's label. Sets text in case of text box. See example-2.
.notebook(style) string Creates a notebook control and returns the object handle. The style may be "top", "left", "right", or "bottom".
.panel()   Creates a panel and returns the object. See example-2.
.push(func, event[, id ...]) string, string, integer/array Pushes an event handler on to the window's even handler stack. The named function will be called when an event occurs. Refer to the event table for what events will be handled by the 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-1.
.radiobox(caption, style, opt1, opt2[, ...]) strings Creates a radiobox control and returns the object. If the style="rows", option radio buttons will be arranged in rows; otherwise in columns.
.radiobutton(caption) string Creates a radiobutton. See example-2.
.set(value) integer or string Sets integer value to slider, radiobutton, or checkbox; set string label to other type of widgets.
.size()   Returns the size of the client area of a widget as an array with width in [0] and height in [1].
.size(w, h) integers Set the size of the client area of a widget.
.sizer(type) string Creates a horizontal (type="horbox") or vertical (type="verbox") box sizer in the widget. See example-2.
.sizer(type, caption, width, height) string, string, integer, integer Creates a static horizontal (type="horstatic") or vertical (type="verstatic") box sizer in the widget. See example-2.
.sizer("flexgrid", rows, rowgap, cols, colgap) string, integers Creates flex grid sizer in the widget. See example-2.
.splitter(pos[,type]) integer, string Creates a vertical (type="v") or herizontal (type="h") slitter control with initial split position to be set to pos. The returned object can be used to call splitter functions. See example-3.
.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-2.
.statictext(text[, align]) string, integer Creates a static text (like a label) and returns the object. The text will be right aligned if align>0; center aligned if align=0; and left aligned otherwise. See example-2.
.style(style) string Sets the window style. The style string can be parts of the full style string "simple|double|sunken|raised|static|none|vscroll|hscroll|clip" corresponding to styles of wxSIMPLE_BORDER | DOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxSTATIC_BORDER | wxNO_BORDER | wxVSCROLL | wxHSCROLL | wxCLIP_CHILDREN.
.textbox(text[, style, width, height]); string, string, integer, integer Creates a textbox control and returns the object. The style string can be parts of the full style string "multiline|password|readonly|left|center|right" corresponding to styles of wxTE_MULTILINE | wxTE_PASSWORD | wxTE_READONLY | wxTE_LEFT | wxTE_CENTRE | wxTE_RIGHT. See example-2.
.textbox(text[, width, height]); string, integer, integer See above. See example-2.
.treeview([func]); string Creates a treeview control and returns the object. The a callback function name is provided, the function will be called with two parameters: the first being event name the second being the selected item name.
.user([object]); any Gets or sets (object specified) user object of the control.

Sizer functions

Function Parameter Type Remark
.add(obj[, flag, prop]) user, string, integer Adds a window control or sizer to the sizer. The full optional flag string The full alignment 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 optional prop sets the proportion of space that control possesses in the sizer (box sizer only). See example-2.
.add(width, height[, flag, prop]) integer, integer, string, integer Adds a spacer object to the sizer. See example-2.
.sizer(type[, flag, prop]) string, string, integer Creates a horizontal (type="horbox") or vertical (type="verbox") box sizer in the sizer. See example-2.
.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-2.
.update()   Updates layout of objects in the sizer. See example-2.

Splitter functions

Function Parameter Type Remark

.get(id)

integer Returns the first (id=1) or the second panel of the splitter. See example-3.
.set(id, w) integer, user Replace the first (id=1) or the second panel with the new window control.
.min(size) integer Sets the minimal panel size. See example-3.
.splitter(id, pos[,type]) integer, integer, string Creates a vertical (type="v") or herizontal (type="h") slitter control in the first (id=1) or second (id=2) panel with initial split position to be set to pos. The returned object can be used to call splitter functions. See example-3.

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.
.label(icol, str) integer, string Sets column label. See example-4.

Notebook functions

Function Parameter Type Remark
.add(name) string Adds a panel to the notebook and returns it, which can be used to call other window functions. See example-5.

Treeview functions

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

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.