]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tguide.tex
Added wxPATH_NORM_SHORTCUT
[wxWidgets.git] / docs / latex / wx / tguide.tex
CommitLineData
a660d684
KB
1\section{Writing a wxWindows application: a rough guide}\label{roughguide}
2
f6bcfd97 3To set a wxWindows application going, you will need to derive a \helpref{wxApp}{wxapp} class and
a660d684
KB
4override \helpref{wxApp::OnInit}{wxapponinit}.
5
9a05fd8d
JS
6An application must have a top-level \helpref{wxFrame}{wxframe} or \helpref{wxDialog}{wxdialog} window.
7Each frame may contain one or more instances of classes such as \helpref{wxPanel}{wxpanel}, \helpref{wxSplitterWindow}{wxsplitterwindow}\rtfsp
a660d684
KB
8or other windows and controls.
9
9a05fd8d 10A frame can have a \helpref{wxMenuBar}{wxmenubar}, a \helpref{wxToolBar}{wxtoolbar}, a status line, and a \helpref{wxIcon}{wxicon} for
a660d684
KB
11when the frame is iconized.
12
13A \helpref{wxPanel}{wxpanel} is used to place controls (classes derived from \helpref{wxControl}{wxcontrol})
14which are used for user interaction. Examples of controls are \helpref{wxButton}{wxbutton},
15\rtfsp\helpref{wxCheckBox}{wxcheckbox}, \helpref{wxChoice}{wxchoice}, \helpref{wxListBox}{wxlistbox},
16\rtfsp\helpref{wxRadioBox}{wxradiobox}, \helpref{wxSlider}{wxslider}.
17
9a05fd8d 18Instances of \helpref{wxDialog}{wxdialog} can also be used for controls and they have
a660d684
KB
19the advantage of not requiring a separate frame.
20
21Instead of creating a dialog box and populating it with items, it is possible to choose
22one of the convenient common dialog classes, such as \helpref{wxMessageDialog}{wxmessagedialog}\rtfsp
23and \helpref{wxFileDialog}{wxfiledialog}.
24
9a05fd8d 25You never draw directly onto a window - you use a {\it device context} (DC). \helpref{wxDC}{wxdc} is
a660d684 26the base for \helpref{wxClientDC}{wxclientdc}, \helpref{wxPaintDC}{wxpaintdc}, \helpref{wxMemoryDC}{wxmemorydc}, \helpref{wxPostScriptDC}{wxpostscriptdc},
e2a6f233 27\rtfsp\helpref{wxMemoryDC}{wxmemorydc}, \helpref{wxMetafileDC}{wxmetafiledc} and \helpref{wxPrinterDC}{wxprinterdc}.
a660d684
KB
28If your drawing functions have {\bf wxDC} as a parameter, you can pass any of these DCs
29to the function, and thus use the same code to draw to several different devices.
30You can draw using the member functions of {\bf wxDC}, such as \helpref{wxDC::DrawLine}{wxdcdrawline}\rtfsp
fe604ccd 31and \helpref{wxDC::DrawText}{wxdcdrawtext}. Control colour on a window (\helpref{wxColour}{wxcolour}) with
a660d684
KB
32brushes (\helpref{wxBrush}{wxbrush}) and pens (\helpref{wxPen}{wxpen}).
33
34To intercept events, you add a DECLARE\_EVENT\_TABLE macro to the window class declaration,
35and put a BEGIN\_EVENT\_TABLE ... END\_EVENT\_TABLE block in the implementation file. Between these
36macros, you add event macros which map the event (such as a mouse click) to a member function.
f4fcc291
JS
37These might override predefined event handlers such as for \helpref{wxKeyEvent}{wxkeyevent} and
38\rtfsp\helpref{wxMouseEvent}{wxmouseevent}.
a660d684
KB
39
40Most modern applications will have an on-line, hypertext help system; for this, you
6fb26ea3 41need wxHelp and the \helpref{wxHelpController}{wxhelpcontroller} class to control
9a05fd8d 42wxHelp.
a660d684
KB
43
44GUI applications aren't all graphical wizardry. List and hash table needs are
e676441f 45catered for by \helpref{wxList}{wxlist}, \helpref{wxStringList}{wxstringlist} and \helpref{wxHashMap}{wxhashmap}.
a660d684
KB
46You will undoubtedly need some platform-independent \helpref{file functions}{filefunctions},
47and you may find it handy to maintain and search a list of paths using \helpref{wxPathList}{wxpathlist}.
48There's a \helpref{miscellany}{miscellany} of operating system and other functions.
49
9a05fd8d 50See also \helpref{Classes by Category}{classesbycat} for a list of classes.
a660d684 51