1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: Samples description
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) wxWindows team
9 %% Licence: wxWindows licence
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{wxWindows samples
}\label{samples
}
14 Probably the best way to learn wxWindows is by reading the source of some
50+
15 samples provided with it. Many aspects of wxWindows programming can be learnt
16 from them, but sometimes it is not simple to just choose the right sample to
17 look at. This overview aims at describing what each sample does/demonstrates to
18 make it easier to find the relevant one if a simple grep through all sources
19 didn't help. They also provide some notes about using the samples and what
20 features of wxWindows are they supposed to test.
22 \subsection{DnD sample
}\label{samplednd
}
24 This sample shows both clipboard and drag and drop in action. It is quite non
25 trivial and may be safely used as a basis for implementing the clipboard and
26 drag and drop operations in a real-life program.
28 When you run the sample, its screen is split in several parts. On the top,
29 there are two listboxes which show the standard derivations of
30 \helpref{wxDropTarget
}{wxdroptarget
}:
31 \helpref{wxTextDropTarget
}{wxtextdroptarget
} and
32 \helpref{wxFileDropTarget
}{wxfiledroptarget
}.
34 The middle of the sample window is taken by the log window which shows what is
35 going on (of course, this only works in debug builds) and may be helpful to see
36 the sequence of steps of data transfer.
38 Finally, the last part is used for two things: you can drag text from it to
39 either one of the listboxes (only one will accept it) or another application
40 and, also, bitmap pasted from clipboard will be shown there.
42 So far, everything we mentioned was implemented with minimal amount of code
43 using standard wxWindows classes. The more advanced features are demonstrated
44 if you create a shape frame from the main frame menu. A shape is a geometric
45 object which has a position, size and
color. It models some
46 application-specific data in this sample. A shape object supports its own
47 private
\helpref{wxDataFormat
}{wxdataformat
} which means that you may cut and
48 paste it or drag and drop (between one and the same or different shapes) from
49 one sample instance to another (or the same). However, chances are that no
50 other program supports this format and so shapes can also be rendered as
51 bitmaps which allows them to be pasted/dropped in many other applications.
53 Take a look at DnDShapeDataObject class to see how you may use
54 \helpref{wxDataObject
}{wxdataobject
} to achieve this.