WxPerlTablet

From WxPerl wiki

Jump to: navigation, search

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 seperate 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 . . 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
Panel. . . . . . . borderless area with a defined background color to place widgets and sizers with widgets on
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

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

Decoration

StaticText . . . . . a label
StaticLine . . . . . vertical or horizontal line in any color
StaticBox. . . . . . labeled rectangle drawn around other panel items to denote a logical grouping
Gauge. . . . . . . . progressbar, illustrates a percentage
StaticBitmap . . . . a picture
AnimationCtrl. . . . small Film played without direct control of the user

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). The general pattern is:

$obj->Mothodename(parentwidet, 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 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

default: 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

more Details

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

Menuitem

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";

Generic

triggered when size of a widget changes

EVT_SIZE( $widget, \&$callback );
EVT_SIZING

Keyboard

EVT_KEY_DOWN( $widget, \&$callback );
EVT_KEY_UP
EVT_CHAR

Mouse

EVT_LEFT_UP( $widget, \&$callback );
EVT_LEFT_DOWN EVT_RIGHT_UP EVT_RIGHT_DOWN EVT_MOTION 

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
Personal tools
Google AdSense