1 \chapter{Introducing wxWindows
}\label{chapintro
}
2 \pagenumbering{arabic
}%
3 \setheader{{\it CHAPTER
\thechapter: INTRODUCING wxWINDOWS
}}{}{}{}{}{{\it CHAPTER
\thechapter: INTRODUCING wxWINDOWS
}}%
4 \setfooter{\thepage}{}{}{}{}{\thepage}%
6 \section{The need for portability
}
8 Not so long ago, it seemed as though Microsoft was on course to
9 take over the desktop for good with the Windows range of
10 operating systems. Unix was retreating to server territory and
11 had all but given up the fight against NT. Apple was sickening
12 and it seemed almost common sense that the quirky Mac had had
15 At the start of the new century, the picture has changed quite
16 dramatically. Linux is advancing from its position of strength
17 in the server market and is poised to make inroads on the
18 desktop, where the high price of Windows gives it an advantage.
19 Apple has made an impressive comeback and is revamping its own
20 operating system. The embedded market continues to explode and
21 has given rise to new niches for specialist operating systems.
22 The keyword bow is diversity, when the best guess of a few years
23 was that Microsoft would conquer all. More than ever,
24 application developers need to keep their options open and
25 targeting one platform only can be a recipe for commercial (or
26 open source) disaster.
28 In the light of this change in the computing landscape,
29 cross-platform development (or multiplatform development as we
30 call it in this book) has become quite a hot and sometimes
31 bitterly controversial topic. There are a number of ways to
32 achieve the goal of portability, and many tools and languages to choose from.
33 However, it is still generally agreed wisdom that C++ is the
34 language of choice for desktop applications that depend on
35 speed, ease of delivery and compatibility with billions of lines
36 of existing code. Plus, there are many hundreds of thousands of
37 developers now experienced in C++ programming.
39 The purpose of this book is to give you (the developer or
40 interested manager) a solid grounding in one increasingly
41 popular multiplatform solution: wxWindows. wxWindows is an open
42 source GUI toolkit that has been on the scene since
1993 and has
43 reached a high degree of stability and functionality. It is
44 available for Linux (and most other Unix variants), all desktop
45 versions of Microsoft Windows, and Mac. Other ports are in
48 \section{Why wxWindows?
}
50 While wxWindows is labelled a GUI development toolkit, it is in
51 fact much more than that and has many features that are useful
52 for many aspects of application development. This has to
53 be the case, since the whole of a wxWindows application needs to
54 be portable to different platforms, and not just the GUI
55 component. So wxWindows provides classes for working with files
56 and streams, multithreading, management of application settings,
57 interprocess communication, and much else.
59 wxWindows is open source, with a vibrant developer and user
60 community, and may be used in any proprietary or non-proprietary
61 project. wxWindows encompasses the whole spectrum of users from
62 one-man software outfits to big-name companies such as Xerox,
63 Lockheed-Martin, Pratt and Whitney, and Motorola; from computer
64 science departments to medical research groups; from ecological
65 research, to the telecommunications industry, and in a myriad of
68 When you use wxWindows you tap into an astonishing talent pool,
69 with contributors from a wide range of backgrounds. Many aspects
70 of application development that you might otherwise have to
71 laboriously code yourself have been encapsulated by these
72 developers in easy-to-use classes that you can plug into your
73 code. Since there are a lot of people subscribed to the mailing
74 lists, you'll enjoy discussions not only about wxWindows but
75 often other matters close to the hearts of both experienced and
76 inexperienced developers. And hopefully, one day you'll join in the
77 success of wxWindows and become a contributor yourself!
79 \section{The history of wxWindows
}
81 wxWindows was started in
1992 at the Artificial Intelligence
82 Applications Institute, University of Edinburgh, by Julian
83 Smart. Julian was designing a kind of meta-CASE tool called
84 Hardy which needed to run on Windows as well as X-based Unix
85 workstations. The existing commercial cross-platform tools were
86 deemed too expensive for an in-house experimental project, so
87 the only alternative was to build one. wxWindows (w for Microsoft
88 Windows, x for the X Windowing System) started off with support for XView and MFC
1.0, and
89 AIAI allowed it to be released to the Internet. As it became
90 clear that XView was doomed, a Motif port was written. Borland
91 C++ users began to request a version that was not dependent on
92 MFC, so the Windows port was rewritten to use the native Windows
93 API. Over time, a small but enthusiastic community of wxWindows
94 users was established and a mailing list set up. Contributions
95 and fixes were sent in, the largest contributions being the Mac
96 and Xt ports. wxWindows gradually picked up more and more users
97 from all over the world: commercial, government, and - most
98 gratifying of all - company users who found that wxWindows
99 offered a better product, and better support, than the
100 commercial products they had looked at or used.
102 During
1995, Markus Holzem released his port of wxWindows to Xt,
103 the X toolkit. This meant that software could be written that
104 would work on X systems without the need for installing Motif,
105 which is a commercial product.
107 In
1996, Julian left AIAI to pursue freelance consultancy, and
108 there were few new releases. The seemingly unstoppable advance
109 of Java was throwing some doubt on the future of C++ libraries.
110 After many contributions, the wxWindows code was looking rather
111 tired and in need of a serious rethink. At the start of
1997 it
112 was make or break time - call it a day and move onto other
113 things, or commit to re-engineering wxWindows with an API that
114 was flexible enough for current and future user interface
115 trends, with more 'widgets', and better use of C++. After an
116 exchange between Julian Smart and Markus Holzem (the author of
117 the Xt port), it was decided that it was worthwhile. Julian
118 would do the Windows port, Markus the combined Motif/Xt port,
119 with both contributing to the generic parts. wxWindows
2 API
120 ideas and code started to take shape.
122 During
1997 an effort to produce a standard Linux desktop
123 environment was underway - GNOME. Its widget set was GTK+, built
124 on top of X11 and it looked as though GTK+-based apps were to
125 become the standard in the Linux universe. Its one major problem
126 - GTK+ was C-based, and only a thin (and unportable) C++ wrapper
127 existed for it. In August
1997, Wolfram Gloger made a suggestion
128 that wxWindows
2 should be ported to GTK+ - Robert Roebling had
129 initial reservations, but in general supported the idea. He
130 became the prime mover for wxGTK and alphas were made available
131 at the beginning of
1998. In May
1998 the Windows and GTK+ ports
132 were merged and put into a CVS repository made available to all
133 contributors to wxWindows.
135 Markus Holzem had to drop out of the wxWindows
2 effort in early
136 1998, but Julian Smart started a new wxMotif port. The idea of
137 an Xt port was dropped, since there remain two possibilities for
138 free Unix programming with wxWindows: wxGTK, and wxMotif with
139 the Motif clone Lesstif.
141 In September
1998, Stefan Csomor started a new version of the
142 wxMac
2 port based in part on Greg Whitehead's initial work.
143 Several releases have been made and the code will be integrated
144 into the main CVS stream in Summer
2000.
146 David Webster and Stefan Neis are working on an OS/
2 port, and
147 interest has been expressed in ports to other systems, such as
150 wxWindows
2.1.11 saw the bundling of Vaclav Slavik's impressive
151 wxHTML classes, with subsequent enhancements including
152 print/preview ability, and a helpview application and help
153 controller class for cross-platform HTML help. wxHTML gives
154 applications easy access to enviable formatted text viewing and
155 reporting capabilities.
157 During
2000 wxWindows will adopt Vaclav's XML resource system
158 as a replacement for the WXR system; this will allow much
159 greater flexibility and portability with support for
160 sizers and many more controls than WXR.
162 \section{How to use this book
}
164 The chapters in this book are meant to be fairly independent, but
165 as usual, the ordering reflects a progression from basic concepts
166 to more advanced ones, so the first few chapters at least
167 should be read consecutively for best effect.