2004-05-04 04:27:20 -04:00
\section { Writing a wxWidgets application: a rough guide} \label { roughguide}
1998-05-20 10:25:30 -04:00
2004-05-04 04:27:20 -04:00
To set a wxWidgets application going, you will need to derive a \helpref { wxApp} { wxapp} class and
1998-05-20 10:25:30 -04:00
override \helpref { wxApp::OnInit} { wxapponinit} .
1999-02-28 18:39:59 -05:00
An application must have a top-level \helpref { wxFrame} { wxframe} or \helpref { wxDialog} { wxdialog} window.
Each frame may contain one or more instances of classes such as \helpref { wxPanel} { wxpanel} , \helpref { wxSplitterWindow} { wxsplitterwindow} \rtfsp
1998-05-20 10:25:30 -04:00
or other windows and controls.
1999-02-28 18:39:59 -05:00
A frame can have a \helpref { wxMenuBar} { wxmenubar} , a \helpref { wxToolBar} { wxtoolbar} , a status line, and a \helpref { wxIcon} { wxicon} for
1998-05-20 10:25:30 -04:00
when the frame is iconized.
A \helpref { wxPanel} { wxpanel} is used to place controls (classes derived from \helpref { wxControl} { wxcontrol} )
which are used for user interaction. Examples of controls are \helpref { wxButton} { wxbutton} ,
\rtfsp \helpref { wxCheckBox} { wxcheckbox} , \helpref { wxChoice} { wxchoice} , \helpref { wxListBox} { wxlistbox} ,
\rtfsp \helpref { wxRadioBox} { wxradiobox} , \helpref { wxSlider} { wxslider} .
1999-02-28 18:39:59 -05:00
Instances of \helpref { wxDialog} { wxdialog} can also be used for controls and they have
1998-05-20 10:25:30 -04:00
the advantage of not requiring a separate frame.
Instead of creating a dialog box and populating it with items, it is possible to choose
one of the convenient common dialog classes, such as \helpref { wxMessageDialog} { wxmessagedialog} \rtfsp
and \helpref { wxFileDialog} { wxfiledialog} .
1999-02-28 18:39:59 -05:00
You never draw directly onto a window - you use a { \it device context} (DC). \helpref { wxDC} { wxdc} is
1998-05-20 10:25:30 -04:00
the base for \helpref { wxClientDC} { wxclientdc} , \helpref { wxPaintDC} { wxpaintdc} , \helpref { wxMemoryDC} { wxmemorydc} , \helpref { wxPostScriptDC} { wxpostscriptdc} ,
1999-01-25 13:33:08 -05:00
\rtfsp \helpref { wxMemoryDC} { wxmemorydc} , \helpref { wxMetafileDC} { wxmetafiledc} and \helpref { wxPrinterDC} { wxprinterdc} .
1998-05-20 10:25:30 -04:00
If your drawing functions have { \bf wxDC} as a parameter, you can pass any of these DCs
to the function, and thus use the same code to draw to several different devices.
You can draw using the member functions of { \bf wxDC} , such as \helpref { wxDC::DrawLine} { wxdcdrawline} \rtfsp
1998-06-14 16:48:39 -04:00
and \helpref { wxDC::DrawText} { wxdcdrawtext} . Control colour on a window (\helpref { wxColour} { wxcolour} ) with
1998-05-20 10:25:30 -04:00
brushes (\helpref { wxBrush} { wxbrush} ) and pens (\helpref { wxPen} { wxpen} ).
To intercept events, you add a DECLARE\_ EVENT\_ TABLE macro to the window class declaration,
and put a BEGIN\_ EVENT\_ TABLE ... END\_ EVENT\_ TABLE block in the implementation file. Between these
macros, you add event macros which map the event (such as a mouse click) to a member function.
2002-04-08 12:46:27 -04:00
These might override predefined event handlers such as for \helpref { wxKeyEvent} { wxkeyevent} and
\rtfsp \helpref { wxMouseEvent} { wxmouseevent} .
1998-05-20 10:25:30 -04:00
Most modern applications will have an on-line, hypertext help system; for this, you
1998-11-17 17:44:47 -05:00
need wxHelp and the \helpref { wxHelpController} { wxhelpcontroller} class to control
1999-02-28 18:39:59 -05:00
wxHelp.
1998-05-20 10:25:30 -04:00
GUI applications aren't all graphical wizardry. List and hash table needs are
2005-02-07 17:42:42 -05:00
catered for by \helpref { wxList} { wxlist} and \helpref { wxHashMap} { wxhashmap} .
1998-05-20 10:25:30 -04:00
You will undoubtedly need some platform-independent \helpref { file functions} { filefunctions} ,
and you may find it handy to maintain and search a list of paths using \helpref { wxPathList} { wxpathlist} .
There's a \helpref { miscellany} { miscellany} of operating system and other functions.
1999-02-28 18:39:59 -05:00
See also \helpref { Classes by Category} { classesbycat} for a list of classes.
1998-05-20 10:25:30 -04:00