The following documents some miscellaneous C++ issues.
-\subsection{Templates}
+\subsection{Templates}\label{templates}
wxWidgets does not use templates (except for some advanced features that
are switched off by default) since it is a notoriously unportable feature.
-\subsection{RTTI}
+\subsection{RTTI}\label{rtti}
wxWidgets does not use C++ run-time type information since wxWidgets provides
its own run-time type information system, implemented using macros.
-\subsection{Type of NULL}
+\subsection{Type of NULL}\label{null}
Some compilers (e.g. the native IRIX cc) define NULL to be 0L so that
no conversion to pointers is allowed. Because of that, all these
It is recommended to adhere to this in all code using wxWidgets as
this make the code (a bit) more portable.
-\subsection{Precompiled headers}
+\subsection{Precompiled headers}\label{precompiledheaders}
Some compilers, such as Borland C++ and Microsoft C++, support
precompiled headers. This can save a great deal of compiling time. The
\section{Strategies for reducing programming errors}\label{reducingerrors}
-\subsection{Use ASSERT}
+\subsection{Use ASSERT}\label{useassert}
Although I haven't done this myself within wxWidgets, it is good
practice to use ASSERT statements liberally, that check for conditions that
and your application. Using ASSERT is an example of `defensive programming':
it can alert you to problems later on.
-\subsection{Use wxString in preference to character arrays}
+\subsection{Use wxString in preference to character arrays}\label{usewxstring}
Using wxString can be much safer and more convenient than using char *.
Again, I haven't practiced what I'm preaching, but I'm now trying to use
\section{Strategies for portability}\label{portability}
-\subsection{Use relative positioning or constraints}
+\subsection{Use relative positioning or constraints}\label{userelativepositioning}
Don't use absolute panel item positioning if you can avoid it. Different GUIs have
very differently sized panel items. Consider using the constraint system, although this
platforms, with slightly different dimensions in each. Or space your panel items out
to avoid problems.
-\subsection{Use wxWidgets resource files}
+\subsection{Use wxWidgets resource files}\label{useresources}
Use .xrc (wxWidgets resource files) where possible, because they can be easily changed
independently of source code.
\section{Strategies for debugging}\label{debugstrategies}
-\subsection{Positive thinking}
+\subsection{Positive thinking}\label{positivethinking}
It is common to blow up the problem in one's imagination, so that it seems to threaten
weeks, months or even years of work. The problem you face may seem insurmountable:
isn't painful at the time. Try not to worry -- there are many more important
things in life.
-\subsection{Simplify the problem}
+\subsection{Simplify the problem}\label{simplifyproblem}
Reduce the code exhibiting the problem to the smallest program possible
that exhibits the problem. If it is not possible to reduce a large and
to the problem. In some cases though, such as memory leaks or wrong
deallocation, this can still give totally spurious results!
-\subsection{Use a debugger}
+\subsection{Use a debugger}\label{usedebugger}
This sounds like facetious advice, but it is surprising how often people
don't use a debugger. Often it is an overhead to install or learn how to
use a debugger, but it really is essential for anything but the most
trivial programs.
-\subsection{Use logging functions}
+\subsection{Use logging functions}\label{uselogging}
There is a variety of logging functions that you can use in your program:
see \helpref{Logging functions}{logfunctions}.
in some circumstances (such as when your debugger doesn't support a lot
of debugging code, or you wish to print a bunch of variables).
-\subsection{Use the wxWidgets debugging facilities}
+\subsection{Use the wxWidgets debugging facilities}\label{usedebuggingfacilities}
You can use wxDebugContext to check for
memory leaks and corrupt memory: in fact in debugging mode, wxWidgets will
Here is the list of preprocessor symbols used in the wxWidgets source grouped
by category (and sorted by alphabetical order inside each category).
-\subsection{GUI system}
+\subsection{GUI system}\label{guisystemconst}
\begin{twocollist}\itemsep=0pt
\twocolitem{\_\_WINDOWS\_\_}{any Windows, yom may also use \_\_WXMSW\_\_}
In fact, they should better all start with \_\_WX instead of \_\_ only,
so please start any new defines with \_\_WX.
-\subsection{Operating systems}
+\subsection{Operating systems}\label{osconst}
\begin{twocollist}\itemsep=0pt
\twocolitem{\_\_APPLE\_\_}{any Mac OS version}
\twocolitem{\_\_WINDOWS\_\_}{any Windows}
\end{twocollist}
-\subsection{Hardware architectures}
+\subsection{Hardware architectures}\label{hardwareconst}
Note that not all of these symbols are always defined, it depends on the
compiler used.
\twocolitem{\_\_POWERPC\_\_}{Motorola Power PC}
\end{twocollist}
-\subsection{Compilers}
+\subsection{Compilers}\label{compilerconst}
\begin{twocollist}\itemsep=0pt
\twocolitem{\_\_BORLANDC\_\_}{Borland C++. The value of the macro corresponds
\twocolitem{\_WIN32\_WCE}{Windows CE version}
\end{twocollist}
-\subsection{Miscellaneous}
+\subsection{Miscellaneous}\label{miscellaneousconst}
\begin{twocollist}\itemsep=0pt
\twocolitem{\_\_WXWINDOWS\_\_}{always defined in wxWidgets applications, see
\docparam{name}{The dialog name, not used.}
-\membersection{wxDirDialog::\destruct{wxDirDialog}}
+\membersection{wxDirDialog::\destruct{wxDirDialog}}\label{wxdirdialogdtor}
\func{}{\destruct{wxDirDialog}}{\void}
The new stream position or wxInvalidOffset on error.
-\membersection{wxOutputStream::TellO}
+\membersection{wxOutputStream::TellO}\label{wxoutputstreamtello}
\constfunc{off\_t}{TellO}{\void}
\helpref{wxRegEx}{wxregex}
-\subsection{Different Flavors of REs}
+\subsection{Different Flavors of REs}\label{differentflavors}
\helpref{Syntax of the builtin regular expression library}{wxresyn}
they will be discussed at the \helpref{end}{wxresynbre}. POSIX EREs are almost an exact subset
of AREs. Features of AREs that are not present in EREs will be indicated.
-\subsection{Regular Expression Syntax}
+\subsection{Regular Expression Syntax}\label{resyntax}
\helpref{Syntax of the builtin regular expression library}{wxresyn}
(i.e. the number is in the legal range for a back reference), and otherwise
is taken as octal.
-\subsection{Metasyntax}
+\subsection{Metasyntax}label{remetasyntax}
\helpref{Syntax of the builtin regular expression library}{wxresyn}
this affects {\bf \caret} and {\bf \$} as with newline-sensitive matching, but not {\bf .} and bracket
expressions. This isn't very useful but is provided for symmetry.
-\subsection{Limits And Compatibility}
+\subsection{Limits And Compatibility}\label{relimits}
\helpref{Syntax of the builtin regular expression library}{wxresyn}
\helpref{Layout}{wxwindowlayout} yourself if the parent window is not a
frame, panel or dialog).
-\subsection{Constraint layout: more detail}
+\subsection{Constraint layout: more details}\label{constraintlayoutdetails}
By default, windows do not have a wxLayoutConstraints object. In this case, much layout
must be done explicitly, by performing calculations in OnSize members, except
\subsection{Window layout examples}\label{layoutexamples}
-\subsubsection{Example 1: subwindow layout}
+\subsubsection{Example 1: subwindow layout}\label{subwindowlayoutexample}
This example specifies a panel and a window side by side,
with a text subwindow below it.
frame->text_window->SetConstraints(c3);
\end{verbatim}
-\subsubsection{Example 2: panel item layout}
+\subsubsection{Example 2: panel item layout}\label{panelitemlayoutexample}
This example sizes a button width to 80 percent of the panel width, and centres
it horizontally. A listbox and multitext item are placed below it. The listbox
\helpref{Database classes overview}{odbcoverview}
-\subsubsection{Create}
+\subsubsection{Create}\label{odbccreateexample}
Creates a table.
)
\end{verbatim}
-\subsubsection{Insert}
+\subsubsection{Insert}\label{odbcinsertexample}
Inserts records into a table.
VALUES(5, 'HR', 'The Lark Ascending')
\end{verbatim}
-\subsubsection{Select}
+\subsubsection{Select}\label{odbcselectexample}
The Select operation retrieves rows and columns from a table. The criteria
for selection and the columns returned may be specified.
Selects records where RetailPriceAmount conforms to the WHERE expression.
-\subsubsection{Update}
+\subsubsection{Update}\label{odbcupdateexample}
Updates records in a table.
Classes: \helpref{wxEvtHandler}{wxevthandler}, \helpref{wxWindow}{wxwindow}, \helpref{wxEvent}{wxevent}
-\subsection{Introduction}
+\subsection{Introduction}\label{eventintroduction}
Before version 2.0 of wxWidgets, events were handled by the application
either by supplying callback functions, or by overriding virtual member
% requests, so no extra coding is required to support them in your menus and
% toolbars.
-\subsection{Pluggable event handlers}
+\subsection{Pluggable event handlers}\label{pluggablehandlers}
In fact, you don't have to derive a new class from a window class
if you don't want to. You can derive a new class from wxEvtHandler instead,
\section{C++ exceptions overview}\label{exceptionsoverview}
-\subsection{Introduction}
+\subsection{Introduction}\label{exceptionintroduction}
wxWidgets had been started long before the exceptions were introduced in C++ so
it is not very surprizing that it is not built around using them as some more
note that making the library exception-safe is still work in progress.
-\subsection{Strategies for exceptions handling}
+\subsection{Strategies for exceptions handling}\label{exceptionstrategies}
There are several choice for using the exceptions in wxWidgets programs. First
of all, you may not use them at all. As stated above, the library doesn't throw
all the exceptions thrown by any event handler.
-\subsection{Technicalities}
+\subsection{Technicalities}\label{exceptionstechnicalities}
To use any kind of exception support in the library you need to build it with
\texttt{wxUSE\_EXCEPTIONS} set to $1$. This should be the case by default but
Classes: \helpref{wxGrid}{wxgrid}
-\subsection{Introduction}
+\subsection{Introduction}\label{introductiontowxgrid}
wxGrid and its related classes are used for displaying and editing tabular data.
-\subsection{Getting started: a simple example}
+\subsection{Getting started: a simple example}\label{simplewxgridexample}
For simple applications you need only refer to the wxGrid class in your
code. This example shows how you might create a grid in a frame or
dialog constructor and illustrates some of the formatting functions.
\end{verbatim}
-\subsection{A more complex example}
+\subsection{A more complex example}\label{complexwxgridexample}
Yet to be written
-\subsection{How the wxGrid classes relate to each other}
+\subsection{How the wxGrid classes relate to each other}\label{wxgridclassesrelations}
Yet to be written
-\subsection{Keyboard and mouse actions}
+\subsection{Keyboard and mouse actions}\label{keyboardandmouseinwxgrid}
Yet to be written
\item Use the wxConnection member functions to send messages to the server.
\end{enumerate}
-\subsection{Data transfer}
+\subsection{Data transfer}\label{datatransfer}
These are the ways that data can be transferred from one
application to another. These are methods of wxConnection.
size is the length of the null-terminated string. Windows-specific data
types could also be used on the PC.
-\subsection{Examples}
+\subsection{Examples}\label{ipcexamples}
See the sample programs {\it server}\/ and {\it client}\/ in the IPC
samples directory. Run the server, then the client. This demonstrates
with an Advise loop: selecting an item in the server list box causes
that item to be highlighted in the client list box.
-\subsection{More DDE details}
+\subsection{More DDE details}\label{ddedetails}
A wxClient object initiates the client part of a client-server
DDE-like (Dynamic Data Exchange) conversation (available in both
easily convert between Unicode and the variety of 8-bit encoding systems still
in use.
-\subsection{Background: The need for conversion}
+\subsection{Background: The need for conversion}\label{needforconversion}
As programs are becoming more and more globalized, and users exchange documents
across country boundaries as never before, applications increasingly need to
8-bit multibyte encoding (UTF-7 or UTF-8 is typically used for this purpose), to
pass unhindered through any traditional transport channels.
-\subsection{Background: The wxString class}
+\subsection{Background: The wxString class}\label{conversionandwxstring}
If you have compiled wxWidgets in Unicode mode, the wxChar type will become
identical to wchar\_t rather than char, and a wxString stores wxChars. Hence,
need a way to quickly convert your easily-handled Unicode data to and from a
traditional 8-bit-encoding. And this is what the wxMBConv classes do.
-\subsection{wxMBConv classes}
+\subsection{wxMBConv classes}\label{wxmbconvclasses}
The base class for all these conversions is the wxMBConv class (which itself
implements standard libc locale conversion). Derived classes include
for your own custom encoding and use it, should you need it. All you need to do
is override the MB2WC and WC2MB methods.
-\subsection{wxMBConv objects}
+\subsection{wxMBConv objects}\label{wxmbconvobjects}
Several of the wxWidgets-provided wxMBConv classes have predefined instances
(wxConvLibc, wxConvFile, wxConvUTF7, wxConvUTF8, wxConvLocal). You can use
Unicode-based (like with GTK+ 1.2). By default, it points to wxConvLibc or
wxConvLocal, depending on which works best on the current platform.
-\subsection{wxCSConv}
+\subsection{wxCSConv}\label{wxcsconvclass}
The wxCSConv class is special because when it is instantiated, you can tell it
which character set it should use, which makes it meaningful to keep many
default user character set, but you should rarely need to use it directly,
it is better to go through wxConvCurrent.
-\subsection{Converting strings}
+\subsection{Converting strings}\label{convertingstrings}
Once you have chosen which object you want to use to convert your text,
here is how you would use them with wxString. These examples all assume
of the conversion, you need to explicitly cast it to const char* if you use
it in a vararg context (like with printf).
-\subsection{Converting buffers}
+\subsection{Converting buffers}\label{convertingbuffers}
If you have specialized needs, or just don't want to use wxString, you
can also use the conversion methods of the conversion objects directly.
See also \helpref{wxObject}{wxobject} and \helpref{wxCreateDynamicObject}{wxcreatedynamicobject}.
-\subsection{Example}
+\subsection{Example}\label{runtimeclassinformationexample}
In a header file frame.h:
Read it if you want to know more about how to write programs able to work with
characters from languages other than English.
-\subsection{What is Unicode?}
+\subsection{What is Unicode?}\label{whatisunicode}
Starting with release 2.1 wxWidgets has support for compiling in Unicode mode
on the platforms which support it. Unicode is a standard for character
need for the system to convert all strings the program uses to/from Unicode
each time a system call is made.
-\subsection{Unicode and ANSI modes}
+\subsection{Unicode and ANSI modes}\label{unicodeandansi}
As not all platforms supported by wxWidgets support Unicode (fully) yet, in
many cases it is unwise to write a program which can only work in Unicode
program would have had!). Luckily, there is another way - see the next
section.
-\subsection{Unicode support in wxWidgets}
+\subsection{Unicode support in wxWidgets}\label{unicodeinsidewxw}
In wxWidgets, the code fragment from above should be written instead:
\item Use {\tt wxString} instead of C style strings.
\end{itemize}
-\subsection{Unicode and the outside world}
+\subsection{Unicode and the outside world}\label{unicodeoutsidewxw}
We have seen that it was easy to write Unicode programs using wxWidgets types
and macros, but it has been also mentioned that it isn't quite enough.
% TODO describe fn_str(), wx_str(), wxCharBuf classes, ...
-\subsection{Unicode-related compilation settings}
+\subsection{Unicode-related compilation settings}\label{unicodesettings}
You should define {\tt wxUSE\_UNICODE} to $1$ to compile your program in
Unicode mode. Note that it currently only works in Win32 and GTK 2.0 and