WxPerlTablet
From WxPerl wiki
This is a kind of WxPerl cheat sheet. Its a translation of a German page. Something similar is the latest wxWidgets docs wiki page.
Contents |
Widget Classes
Any classname and function has to be written Wx::name. Some of the classes are in the core (loaded via module Wx.pm) and some are stored in separate modules and have to be loaded with use/require but "use Wx qw[:allclasses];" loads all installed Wx::Modules at once. And yes, CamelCase is convention for classes, method names and functions. Some classes are linked to further explanation as under SomeDocs.
Windows
Frame. . . . . . . main window of an application, can hold statusbars, toolbar, menu bar MiniFrame. . . . . window with minimal border and no further capabilities MDIParentFrame . . rootwindow for MDI (multi document interface) MDIChildFrame. . . window that will only be displayed inside the area of the parent Dialog . . . . . . window with a panel, that doesn't end the application process when closing Wizard . . . . . . dialog with several main panel a navigation for it TopLevelWindow . . base class for all windows (icon, titel, resize, display mode, shape) Window . . . . . . base class to all visible objects (widget), creates only in older version a window
Dialogs
No classes, but functions that call a dialog immediately and return just a value after closed:
MessageBox( $msg, $caption, $flags, $parent, $x, $y); AboutBox ShowTip DirSelector FileSelector GetColourFromUser GetFontFromUser GetMultipleChoices GetNumberFromUser GetPasswordFromUser GetTextFromUser GetSingleChoice
modal, more complex, class based dialogs, that will generated, displayed later and evaluated even after closed by user:
MessageDialog SingleChoiceDialog MultiChoiceDialog TextEntryDialog PasswordEntryDialog FileDialog DirDialog FontDialog PrintDialog ColourDialog
Panel
Areas inside of a window.
Panel . . . . . . . . borderless area with a defined background color to place widgets and sizers with widgets on ScrolledWindow. . . panel with scrollbars that has a virtual size, greater then visible size VScrolledWindow . . ScrolledWindow with more laziness in declaration SplitterWindow. . . movable small column or row that separates a Panel into two areas
Decoration
StaticText. . . . . . text label StaticLine. . . . . . horizontal or vertical line/rectangle with variable witdh StaticBox . . . . . . labeled rectangle for widget grouping Gauge . . . . . . . . a progress bar StaticBitmap. . . . . picture AnimationCtrl . . . . film that runs without control of the user
Choice
Button. . . . . . . . simple button with a text label BitmapButton. . . . . button with a picture/icon as label SpinButton. . . . . . 2 buttons with arrows for left/right or up/down choices CheckBox. . . . . . . labeled small box to check or uncheck it RadioButton . . . . . labeled small box where only one of a group can be checked ListBox . . . . . . . list of text labels that allow multiple choices Slider. . . . . . . . movable button with a textfield that shows the current value CalendarCtrl. . . . . pick a date FileCtrl. . . . . . . pick a file, content of the Wx::FileDialog FilePickerCtrl. . . . button which calls a Wx::FileDialog DirPickerCtrl . . . . button which calls a Wx::DirDialog FontPickerCtrl. . . . button which calls a Wx::FontDialog ColourPickerCtrl. . . button which calls a Wx::ColourDialog
Panel Selection
These are more complex widgets, containing an area to display a panel and an area where to select which panel of a group to show. They are derived from Wx::BookCtrl.
Notebook . . . . . . . uses a tabbar Listbook . . . . . . . uses a list aka Wx::ListCtrl Choicebook . . . . . . uses Wx::Choice Treebook . . . . . . . uses a tree structure aka Wx::TreeCtrl Toolbook . . . . . . . uses Wx::ToolBar
Input
TextCtrl . . . . . . . multi and single line text input RichTextCtrl . . . . . Textcontrol with more formating abilities StyledTextCtrl . . . . aka Wx::STC aka Scintilla, a textcontrol with syntaxhighlighting and many more features SpinCtrl . . . . . . . small TextCtrl with a SpinButton to change a value
Sizer
are no widgets, meaning not visible, but do organise the arrangement, position and size of widgets.
BoxSizer. . . . . . . . . onedimensional, linear sizer StaticBoxSizer. . . . . . BoxSizer with an labeled rectangle around StdDialogButtonSizer. . . for a button row with standart buttons in the standart layout of the OS GridSizer . . . . . . . . simple table, all cells are equal in size FlexGridSizer . . . . . . like GridSizer, but some rows and colums may be flexible in size GridBagSizer. . . . . . . FlexGridSizer where widgets can cross cell border (like col- and rowspan in html)
Method Parameter
... have a strict order (positional parameter - as long you don't use wxPerl::Constructors). The general pattern is:
$obj->Methodname(parentwidget, WidgetID, Input, Pos, Size, Style, Addons ....);
Constants
All constants are exported from module Wx::Wx_Exp.pm. Import them via "use Wx qw( constants, );" or be lazy with "use Wx qw(:everything);". If imported, they can be written as shown here, otherwise "&Wx::wxCONSTANT" (see Wx).
Spacing
These constants define in which direction a size gives a widget additional space.
wxALL = wxTOP | wxBOTTOM | wxLEFT | wxRIGHT aka wxNORTH,wxSOUTH, wxWEST, wxEAST
Alignment
wxALIGN_LEFT wxALIGN_RIGHT wxALIGN_TOP wxALIGN_BOTTOM wxALIGN_CENTER_VERTICAL aka wxALIGN_CENTRE_VERTICAL wxALIGN_CENTER_HORIZONTAL aka wxALIGN_CENTRE_HORIZONTAL wxALIGN_CENTER aka wxALIGN_CENTRE = ...ENTER_HORIZONTAL | ...ENTER_VERTICAL
default : wxALIGN_LEFT | wxALIGN_TOP
Size
wxEXPAND aka wxGROW . . . eats all space it can get wxSHAPED. . . . . . . . . like wxEXPAND, but preserving height/width ratio wxFIXED_MINSIZE . . . . . size keeps unchanged after first calculation
Mainwindow
wxDEFAULT_FRAME_STYLE = wxCAPTION | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER
Widget ID
ID .. wxID_ANY aka -1 . . . . . . get you a unused wxID_LOWEST .. wxID_HIGHEST . . . predefined, reserved ID wxID_NONE
MsgBoxes
wxYES_NO wxYES wxNO wxCANCEL wxOK wxICON_EXCLAMATION wxICON_HAND wxICON_ERROR wxICON_QUESTION wxICON_INFORMATION
Keycodes
WXK_SHIFT WXK_ALT WXK_CONTROL WXK_BACK WXK_TAB WXK_RETURN WXK_ESCAPE WXK_SPACE WXK_SCROLL WXK_NUMLOCK '#' => 47 tilde => 92 WXK_DELETE WXK_INSERT WXK_PAGEUP WXK_PAGEDOWN WXK_HOME WXK_END WXK_LEFT WXK_UP WXK_RIGHT WXK_DOWN WXK_F1 .. WXK_F12 WXK_NUMPAD_SPACE WXK_NUMPAD_TAB WXK_NUMPAD_ENTER WXK_NUMPAD_F1
Menu item
wxID_ABOUT wxID_ADD wxID_APPLY wxID_BOLD wxID_CANCEL wxID_CLEAR wxID_CLOSE wxID_COPY wxID_CUT wxID_DELETE wxID_EDIT wxID_FIND wxID_FILE wxID_REPLACE wxID_BACKWARD wxID_DOWN wxID_FORWARD wxID_UP wxID_HELP wxID_HOME wxID_INDENT wxID_INDEX wxID_ITALIC wxID_JUSTIFY_CENTER wxID_JUSTIFY_FILL wxID_JUSTIFY_LEFT wxID_JUSTIFY_RIGHT wxID_NEW wxID_NO wxID_OK wxID_OPEN wxID_PASTE wxID_PREFERENCES wxID_PRINT wxID_PREVIEW wxID_PROPERTIES wxID_EXIT wxID_REDO wxID_REFRESH wxID_REMOVE wxID_REVERT_TO_SAVED wxID_SAVE wxID_SAVEAS wxID_SELECTALL wxID_STOP wxID_UNDELETE wxID_UNDERLINE wxID_UNDO wxID_UNINDENT wxID_YES wxID_ZOOM_100 wxID_ZOOM_FIT wxID_ZOOM_IN wxID_ZOOM_OUT
Events
has to be used as Wx::Event::eventname or import them as constants from Wx::Event. Lazy people use "use Wx::Event qw(:everything);". More details in the Event List. All event constants are also to be found in "Wx::Wx_Exp.pm"; Some Events take an exta event ID as second parameter.
All Widgets
EVT_SIZE( $widget, \&$callback ); # while size changes EVT_SIZING EVT_SET_FOCUS # widget gets focus EVT_KILL_FOCUS # widget looses focus EVT_IDLE # when $app and children do nothing EVT_DESTROY # too late to veto
Windows
hav all events of normal widgets (called windows in Wx) plus:
EVT_MOVE # triggered 100 times/second while win moving EVT_MOVE_START # EVT_MOVE_END # EVT_CLOSE # prevent closing with $event->veto
Keyboard
EVT_KEY_DOWN( $widget, \&$callback ); EVT_KEY_UP EVT_CHAR
Mouse
EVT_LEFT_UP( $widget, \&$callback ); EVT_LEFT_DOWN EVT_MIDDLE_UP EVT_MIDDLE_DOWN EVT_RIGHT_UP EVT_RIGHT_DOWN EVT_MOUSEWHEEL # while mousewheel moving EVT_MOTION # triggered when cursor is moving over an widget EVT_ENTER_WINDOW # curser reached widget EVT_LEAVE_WINDOW # cursor left EVT_MOUSE_EVENTS # capture all mouse events
Timer
my $timer = Wx::Timer->new( $widget, $timerID ); $timer->Start( $milliseconds, $TriggerOneTimeOnly ); $timer->Stop;
EVT_TIMER( $widget, $timerID , \&$callback );
Menu
First is triggered by selection, second while hover over the item.
EVT_MENU( $widget, $itemID , \&$callback ); EVT_MENU_HIGHLIGHT
Contribs
Extentions of the core with mighty features.
AUI
XRC
Wx::InitAllImageHandlers();
my $xr = Wx::XmlResource->new();
$xr->InitAllHandlers();
$xr->Load('file.xrc'); # its readonly
my $frame = $xr->LoadFrame(undef, 'ConFrame');
my $buttonID = Wx::XmlResource::GetXRCID('Button1')
my $button = $frame->FindWindow($buttonID);
LoadBitmap('ElementID');
LoadDialog($parent, 'ElementID');
LoadFrame($parent, 'ElementID');
LoadIcon('ElementID');
LoadMenu('ElementID');
LoadMenuBar($parent, 'ElementID');
LoadPanel($parent, 'ElementID');
LoadToolBar($parent, 'ElementID');
