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