File: wx300.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (49 lines) | stat: -rw-r--r-- 4,459 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<HTML>
<head><title>Writing a wxWindows application: a rough guide</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="roughguide"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx278.htm#overviews"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx299.htm#eventhandlingoverview"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx301.htm#ipcoverview"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>Writing a wxWindows application: a rough guide</H2>
<P>
To set a wxWindows application going, you'll need to derive a <A HREF="wx26.htm#wxapp">wxApp</A> class and
override <A HREF="wx26.htm#wxapponinit">wxApp::OnInit</A>.<P>
An application must have a top-level <A HREF="wx104.htm#wxframe">wxFrame</A> or <A HREF="wx71.htm#wxdialog">wxDialog</A> window.
Each frame may contain one or more instances of classes such as <A HREF="wx166.htm#wxpanel">wxPanel</A>, <A HREF="wx217.htm#wxsplitterwindow">wxSplitterWindow</A>
or other windows and controls.<P>
A frame can have a <A HREF="wx141.htm#wxmenubar">wxMenuBar</A>, a <A HREF="wx249.htm#wxtoolbar">wxToolBar</A>, a status line, and a <A HREF="wx114.htm#wxicon">wxIcon</A> for
when the frame is iconized.<P>
A <A HREF="wx166.htm#wxpanel">wxPanel</A> is used to place controls (classes derived from <A HREF="wx56.htm#wxcontrol">wxControl</A>)
which are used for user interaction. Examples of controls are <A HREF="wx31.htm#wxbutton">wxButton</A>,
<A HREF="wx39.htm#wxcheckbox">wxCheckBox</A>, <A HREF="wx41.htm#wxchoice">wxChoice</A>, <A HREF="wx128.htm#wxlistbox">wxListBox</A>,
<A HREF="wx190.htm#wxradiobox">wxRadioBox</A>, <A HREF="wx207.htm#wxslider">wxSlider</A>.<P>
Instances of <A HREF="wx71.htm#wxdialog">wxDialog</A> can also be used for controls and they have
the advantage of not requiring a separate frame.<P>
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 <A HREF="wx144.htm#wxmessagedialog">wxMessageDialog</A>
and <A HREF="wx90.htm#wxfiledialog">wxFileDialog</A>.<P>
You never draw directly onto a window - you use a <I>device context</I> (DC). <A HREF="wx65.htm#wxdc">wxDC</A> is
the base for <A HREF="wx43.htm#wxclientdc">wxClientDC</A>, <A HREF="wx163.htm#wxpaintdc">wxPaintDC</A>, <A HREF="wx137.htm#wxmemorydc">wxMemoryDC</A>, <A HREF="wx172.htm#wxpostscriptdc">wxPostScriptDC</A>,
<A HREF="wx137.htm#wxmemorydc">wxMemoryDC</A>, <A HREF="wx146.htm#wxmetafiledc">wxMetafileDC</A> and <A HREF="wx179.htm#wxprinterdc">wxPrinterDC</A>.
If your drawing functions have <B>wxDC</B> 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 <B>wxDC</B>, such as <A HREF="wx65.htm#wxdcdrawline">wxDC::DrawLine</A>
and <A HREF="wx65.htm#wxdcdrawtext">wxDC::DrawText</A>. Control colour on a window (<A HREF="wx46.htm#wxcolour">wxColour</A>) with
brushes (<A HREF="wx36.htm#wxbrush">wxBrush</A>) and pens (<A HREF="wx169.htm#wxpen">wxPen</A>).<P>
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.
These might override predefined event handlers such as <A HREF="wx260.htm#wxwindowonchar">wxWindow::OnChar</A> and
<A HREF="wx260.htm#wxwindowonmouseevent">wxWindow::OnMouseEvent</A>.<P>
Most modern applications will have an on-line, hypertext help system; for this, you
need wxHelp and the <A HREF="wx111.htm#wxhelpcontroller">wxHelpController</A> class to control
wxHelp.<P>
GUI applications aren't all graphical wizardry. List and hash table needs are
catered for by <A HREF="wx127.htm#wxlist">wxList</A>, <A HREF="wx225.htm#wxstringlist">wxStringList</A> and <A HREF="wx110.htm#wxhashtable">wxHashTable</A>.
You will undoubtedly need some platform-independent <A HREF="wx265.htm#filefunctions">file functions</A>,
and you may find it handy to maintain and search a list of paths using <A HREF="wx168.htm#wxpathlist">wxPathList</A>.
There's a <A HREF="wx271.htm#miscellany">miscellany</A> of operating system and other functions.<P>
See also <A HREF="wx277.htm#classesbycat">Classes by Category</A> for a list of classes.<P>

</BODY></HTML>