]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/tech/tn0008.htm
- applied patch that adds more i18n support to XRC handlers
[wxWidgets.git] / docs / tech / tn0008.htm
... / ...
CommitLineData
1<HTML>
2
3<HEAD>
4<TITLE>How to learn wxWindows programming</TITLE>
5</HEAD>
6
7<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#FF0000 VLINK=#000000>
8
9<font face="Arial, Lucida Sans, Helvetica">
10
11<a name="top"></a>
12
13<table align=center width=100% border=4 cellpadding=5 cellspacing=0>
14<tr>
15<td bgcolor="#660000" align=left colspan=2>
16<font size=+1 face="Arial, Lucida Sans, Helvetica" color="#FFFFFF">
17How to learn wxWindows programming
18</font>
19</td>
20</tr>
21</table>
22
23<P>
24
25The following is a response by Edward Ream to a common question,
26"What's the best way to learn wxWindows [and C++]?".<P>
27
28Date: Sun, 04 Jun 2000 14:37:06 -0500<BR>
29From: "Edward K. Ream" <edream@tds.net> <BR>
30To: wx-users@wxwindows.org<BR>
31Subject: Re: [wx-users] How to learn using wx-windows <BR>
32Reply-To: wx-users@wxwindows.org<P>
33
34&gt; Reading the Linux Journal article on wxpython, and having used wxclips<BR>
35&gt; I got interested in wxwindows as a development interface. However, the<BR>
36&gt; programming experience I got is old, and from a former generation (For-<BR>
37&gt; tran). I'd like to refresh my experience and start in C++. Will<BR>
38&gt; wx-windows be a very high step to take?<P>
39
40I'm new to wxWindows myself, but I'd like to answer this question
41anyway. In the past two years I've learned two similar frameworks
42(Apple's Yellow Box, aka NextStep/OpenStep and Borland's C++
43Builder/Delphi) and last year I became a C++ enthusiast after 20 years
44of using C.<P>
45
46<B>About C++.</B><P>
47
48The major Aha for me was that the complexity of C++ doesn't matter in
49practice. What _does_ matter is that C++ allows you to do simple things
50simply, more simply than C. With a system like wxWindows you will be
51creating objects and then using those objects to call methods. So don't
52be afraid of C++: you'll only be using the easy tip of the
53iceberg.<P>
54
55Besides the C++ Programming Language, by Bjarne Stroustrup, the
56"official" guide to C++, I highly recommend Inside the C++ Object Model,
57by Stanley B. Lippman. (Lippman was one of the C++ honchos at Bell
58Labs.) This book will tell you what _not_ to do, as well as why
59everything in C++ is as it is. If you are confused by anything in C++,
60Lippman's book is the cure.<P>
61
62<B>About applications frameworks.</B><P>
63
64Application frameworks such as wxWindows are organized around a set of
65cooperating classes. Take a look at the main application class, wxApp,
66some frame and panel classes, graphics classes, menu classes, control
67classes, etc. In general, to do anything in a framework involves
68creating an object of the specified type, then doing something with that
69object.<P>
70
71For example, suppose you want to create a menu bar. A menu bar is
72composed of a single menu bar object of type(class) wxMenuBar that
73contains menu objects of type wxMenu. Each menu object contains menu
74item objects of type wxMenuItem. So you create the menu bar object,
75then create all the menu objects (creating the menu item objects along
76the way) and finally "attach" the menu objects to the menu bar object
77using a call to the wxMenuBar::Append method.<P>
78
79As an overview I would look at the "Alphabetical class reference"
80section of the reference manual. I find the HTML version to be the
81easiest to use: you can browse very quickly through it. Here's how to
82read this (very large) reference:<P>
83
84<ol>
85<li>Get an overview of the kinds of classes involved. The class names
86will tell you a lot about what each class does. Open some of the
87classes, in particular, wxApp (the main application object), wxFrame,
88wxControl (the base class for all controls) and one or two controls,
89like wxButton.
90
91<li>When scanning a class for the first several times, read the
92introductory remarks and quickly scan the list of methods of the class
93to get a general idea about what kinds of operations can be done to
94objects of the class. You are not looking for detail at this stage,
95just for the big picture. In particular, what classes exist and how do
96they work together.
97
98<li>Pay particular attention to the classes from which a class is
99derived. For example, a button (an object of type wxButton) is derived
100from the wxControl, wxWindow, wxEvtHandler and wxObject classes. What
101does this mean? It means that a button _is_ a control, and a button
102_is_ a window, and a button _is_ an event handler and a button _is_ an
103object. So you must understand the parent classes of an object to
104understand the object itself.
105
106For example, if b is a button you can invoke b.m for any of method m of
107the wxControl, wxWindow, wxEvtHandler or wxObject classes. You are not
108limited to just the methods of wxButton! This is one of the keys of
109object oriented programming.
110</ol>
111
112Some other tips:<P>
113
114Read some sample code. You will find that almost none of the C++
115language is actually being used; it's just endlessly creating objects
116and then calling methods using those objects.<P>
117
118Learn as much as you can about the String class; after using a good
119String class you'll never want to use C's string functions again.
120wxWindows contains other nifty utility classes as well.<P>
121
122The application class, wxApp, contains the main event loop. Learn about
123event handling and event tables (reading sample code will help). Almost
124everything in this kind of application framework happens as the result
125of an event and your app is essentially doing nothing but responding to
126events. Having the event loop written for you is a major, major
127benefit.<P>
128
129I hope this helps. Perhaps we can work together in learning about
130wxWindows. Please feel free to ask me any questions you might have. If
131I've made any blunders in this posting I hope the wxWindows experts will
132correct me gently.<P>
133
134Edward<BR>
135--------------------------------------------------------------------<BR>
136Edward K. Ream email: edream@tds.net<BR>
137Leo: Literate Editor with Outlines<BR>
138Leo: http:&#47;&#47;personalpages.tds.net/~edream/front.html<BR>
139--------------------------------------------------------------------<P>
140
141</font>
142
143</body>
144</html>