WxPerlTablet
From WxPerl Wiki
This is a kind of WxPerl cheat sheet. It is 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.
Windows
Frame. . . . . . . main window of an application, can hold statusbars, toolbar, menu bar MiniFrame. . . . . window with minimal border and no further capabilities MDIParentFrame . . root window 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 PopupWindow. . . . borderless panel overlaying recent window, to draw and put any content on (e.g. for context menus) TopLevelWindow . . base class for all windows (icon, title, resizable, 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
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
Buttons that call a dialog when pressed and hold the selected value, (see Choice)
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
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 CollapsiblePane . . panel that can be collapsed to a label like a node of a tree 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 ListCtrl. . . . . . . list of items that can have icons and / or labels TreeCtrl. . . . . . . tree structure of similar items
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 Grid . . . . . . . . . table a la Excel HtmlWindow . . . . . . HTML render windet (can include widgets like html tags) MediaCtrl. . . . . . . video player controlable by the user (unlike AnimationCtrl)
Sizer
are not widgets, meaning not visible, but do organize the arrangement (position and size) of widgets. These parameters get useless if you choose sizers.
BoxSizer. . . . . . . . . one dimensional, linear sizer StaticBoxSizer. . . . . . BoxSizer with an labeled rectangle around StdDialogButtonSizer. . . for a button row with standard buttons in the standard layout of the OS GridSizer . . . . . . . . simple table, all cells are equal in size FlexGridSizer . . . . . . like GridSizer, but some rows and columns 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".
Spacing
These constants define in which direction a sizer 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
Colours
wxBLACK wxWHITE wxRED wxBLUE wxGREEN wxCYAN wxLIGHT_GREY
Keycodes
WXK_SHIFT WXK_ALT WXK_CONTROL wxMOD_SHIFT ... 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
Languages
WxLANGUAGE_DEFAULT wxLANGUAGE_UNKNOWN wxLANGUAGE_USER_DEFINED wxLANGUAGE_ABKHAZIAN wxLANGUAGE_AFAR wxLANGUAGE_AFRIKAANS wxLANGUAGE_ALBANIAN wxLANGUAGE_AMHARIC wxLANGUAGE_ARABIC wxLANGUAGE_ARABIC_ALGERIA wxLANGUAGE_ARABIC_BAHRAIN wxLANGUAGE_ARABIC_EGYPT wxLANGUAGE_ARABIC_IRAQ wxLANGUAGE_ARABIC_JORDAN wxLANGUAGE_ARABIC_KUWAIT wxLANGUAGE_ARABIC_LEBANON wxLANGUAGE_ARABIC_LIBYA wxLANGUAGE_ARABIC_MOROCCO wxLANGUAGE_ARABIC_OMAN wxLANGUAGE_ARABIC_QATAR wxLANGUAGE_ARABIC_SAUDI_ARABIA wxLANGUAGE_ARABIC_SUDAN wxLANGUAGE_ARABIC_SYRIA wxLANGUAGE_ARABIC_TUNISIA wxLANGUAGE_ARABIC_UAE wxLANGUAGE_ARABIC_YEMEN wxLANGUAGE_ARMENIAN wxLANGUAGE_ASSAMESE wxLANGUAGE_AYMARA wxLANGUAGE_AZERI wxLANGUAGE_AZERI_CYRILLIC wxLANGUAGE_AZERI_LATIN wxLANGUAGE_BASHKIR wxLANGUAGE_BASQUE wxLANGUAGE_BELARUSIAN wxLANGUAGE_BENGALI wxLANGUAGE_BHUTANI wxLANGUAGE_BIHARI wxLANGUAGE_BISLAMA wxLANGUAGE_BRETON wxLANGUAGE_BULGARIAN wxLANGUAGE_BURMESE wxLANGUAGE_CAMBODIAN wxLANGUAGE_CATALAN wxLANGUAGE_CHINESE wxLANGUAGE_CHINESE_SIMPLIFIED wxLANGUAGE_CHINESE_TRADITIONAL wxLANGUAGE_CHINESE_HONGKONG wxLANGUAGE_CHINESE_MACAU wxLANGUAGE_CHINESE_SINGAPORE wxLANGUAGE_CHINESE_TAIWAN wxLANGUAGE_CORSICAN wxLANGUAGE_CROATIAN wxLANGUAGE_CZECH wxLANGUAGE_DANISH wxLANGUAGE_DUTCH wxLANGUAGE_DUTCH_BELGIAN wxLANGUAGE_ENGLISH wxLANGUAGE_ENGLISH_UK wxLANGUAGE_ENGLISH_US wxLANGUAGE_ENGLISH_AUSTRALIA wxLANGUAGE_ENGLISH_BELIZE wxLANGUAGE_ENGLISH_BOTSWANA wxLANGUAGE_ENGLISH_CANADA wxLANGUAGE_ENGLISH_CARIBBEAN wxLANGUAGE_ENGLISH_DENMARK wxLANGUAGE_ENGLISH_EIRE wxLANGUAGE_ENGLISH_JAMAICA wxLANGUAGE_ENGLISH_NEW_ZEALAND wxLANGUAGE_ENGLISH_PHILIPPINES wxLANGUAGE_ENGLISH_SOUTH_AFRICA wxLANGUAGE_ENGLISH_TRINIDAD wxLANGUAGE_ENGLISH_ZIMBABWE wxLANGUAGE_ESPERANTO wxLANGUAGE_ESTONIAN wxLANGUAGE_FAEROESE wxLANGUAGE_FARSI wxLANGUAGE_FIJI wxLANGUAGE_FINNISH wxLANGUAGE_FRENCH wxLANGUAGE_FRENCH_BELGIAN wxLANGUAGE_FRENCH_CANADIAN wxLANGUAGE_FRENCH_LUXEMBOURG wxLANGUAGE_FRENCH_MONACO wxLANGUAGE_FRENCH_SWISS wxLANGUAGE_FRISIAN wxLANGUAGE_GALICIAN wxLANGUAGE_GEORGIAN wxLANGUAGE_GERMAN wxLANGUAGE_GERMAN_AUSTRIAN wxLANGUAGE_GERMAN_BELGIUM wxLANGUAGE_GERMAN_LIECHTENSTEIN wxLANGUAGE_GERMAN_LUXEMBOURG wxLANGUAGE_GERMAN_SWISS wxLANGUAGE_GREEK wxLANGUAGE_GREENLANDIC wxLANGUAGE_GUARANI wxLANGUAGE_GUJARATI wxLANGUAGE_HAUSA wxLANGUAGE_HEBREW wxLANGUAGE_HINDI wxLANGUAGE_HUNGARIAN wxLANGUAGE_ICELANDIC wxLANGUAGE_INDONESIAN wxLANGUAGE_INTERLINGUA wxLANGUAGE_INTERLINGUE wxLANGUAGE_INUKTITUT wxLANGUAGE_INUPIAK wxLANGUAGE_IRISH wxLANGUAGE_ITALIAN wxLANGUAGE_ITALIAN_SWISS wxLANGUAGE_JAPANESE wxLANGUAGE_JAVANESE wxLANGUAGE_KANNADA wxLANGUAGE_KASHMIRI wxLANGUAGE_KASHMIRI_INDIA wxLANGUAGE_KAZAKH wxLANGUAGE_KERNEWEK wxLANGUAGE_KINYARWANDA wxLANGUAGE_KIRGHIZ wxLANGUAGE_KIRUNDI wxLANGUAGE_KONKANI wxLANGUAGE_KOREAN wxLANGUAGE_KURDISH wxLANGUAGE_LAOTHIAN wxLANGUAGE_LATIN wxLANGUAGE_LATVIAN wxLANGUAGE_LINGALA wxLANGUAGE_LITHUANIAN wxLANGUAGE_MACEDONIAN wxLANGUAGE_MALAGASY wxLANGUAGE_MALAY wxLANGUAGE_MALAYALAM wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM wxLANGUAGE_MALAY_MALAYSIA wxLANGUAGE_MALTESE wxLANGUAGE_MANIPURI wxLANGUAGE_MAORI wxLANGUAGE_MARATHI wxLANGUAGE_MOLDAVIAN wxLANGUAGE_MONGOLIAN wxLANGUAGE_NAURU wxLANGUAGE_NEPALI wxLANGUAGE_NEPALI_INDIA wxLANGUAGE_NORWEGIAN_BOKMAL wxLANGUAGE_NORWEGIAN_NYNORSK wxLANGUAGE_OCCITAN wxLANGUAGE_ORIYA wxLANGUAGE_OROMO wxLANGUAGE_PASHTO wxLANGUAGE_POLISH wxLANGUAGE_PORTUGUESE wxLANGUAGE_PORTUGUESE_BRAZILIAN wxLANGUAGE_PUNJABI wxLANGUAGE_QUECHUA wxLANGUAGE_RHAETO_ROMANCE wxLANGUAGE_ROMANIAN wxLANGUAGE_RUSSIAN wxLANGUAGE_RUSSIAN_UKRAINE wxLANGUAGE_SAMOAN wxLANGUAGE_SANGHO wxLANGUAGE_SANSKRIT wxLANGUAGE_SCOTS_GAELIC wxLANGUAGE_SERBIAN wxLANGUAGE_SERBIAN_CYRILLIC wxLANGUAGE_SERBIAN_LATIN wxLANGUAGE_SERBO_CROATIAN wxLANGUAGE_SESOTHO wxLANGUAGE_SETSWANA wxLANGUAGE_SHONA wxLANGUAGE_SINDHI wxLANGUAGE_SINHALESE wxLANGUAGE_SISWATI wxLANGUAGE_SLOVAK wxLANGUAGE_SLOVENIAN wxLANGUAGE_SOMALI wxLANGUAGE_SPANISH wxLANGUAGE_SPANISH_ARGENTINA wxLANGUAGE_SPANISH_BOLIVIA wxLANGUAGE_SPANISH_CHILE wxLANGUAGE_SPANISH_COLOMBIA wxLANGUAGE_SPANISH_COSTA_RICA wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC wxLANGUAGE_SPANISH_ECUADOR wxLANGUAGE_SPANISH_EL_SALVADOR wxLANGUAGE_SPANISH_GUATEMALA wxLANGUAGE_SPANISH_HONDURAS wxLANGUAGE_SPANISH_MEXICAN wxLANGUAGE_SPANISH_MODERN wxLANGUAGE_SPANISH_NICARAGUA wxLANGUAGE_SPANISH_PANAMA wxLANGUAGE_SPANISH_PARAGUAY wxLANGUAGE_SPANISH_PERU wxLANGUAGE_SPANISH_PUERTO_RICO wxLANGUAGE_SPANISH_URUGUAY wxLANGUAGE_SPANISH_US wxLANGUAGE_SPANISH_VENEZUELA wxLANGUAGE_SUNDANESE wxLANGUAGE_SWAHILI wxLANGUAGE_SWEDISH wxLANGUAGE_SWEDISH_FINLAND wxLANGUAGE_TAGALOG wxLANGUAGE_TAJIK wxLANGUAGE_TAMIL wxLANGUAGE_TATAR wxLANGUAGE_TELUGU wxLANGUAGE_THAI wxLANGUAGE_TIBETAN wxLANGUAGE_TIGRINYA wxLANGUAGE_TONGA wxLANGUAGE_TSONGA wxLANGUAGE_TURKISH wxLANGUAGE_TURKMEN wxLANGUAGE_TWI wxLANGUAGE_UIGHUR wxLANGUAGE_UKRAINIAN wxLANGUAGE_URDU wxLANGUAGE_URDU_INDIA wxLANGUAGE_URDU_PAKISTAN wxLANGUAGE_UZBEK wxLANGUAGE_UZBEK_CYRILLIC wxLANGUAGE_UZBEK_LATIN wxLANGUAGE_VIETNAMESE wxLANGUAGE_VOLAPUK wxLANGUAGE_WELSH wxLANGUAGE_WOLOF wxLANGUAGE_XHOSA wxLANGUAGE_YIDDISH wxLANGUAGE_YORUBA wxLANGUAGE_ZHUANG wxLANGUAGE_ZULU
Events
have 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 extra 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
have 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 # cursor 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
Extensions 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');