]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/bmpdatob.tex
Small Tex2RTF fixes; wxMotif compile fixes (motif.inc, wxCheckListBox);
[wxWidgets.git] / docs / latex / wx / bmpdatob.tex
1 \section{\class{wxBitmapDataObject}}\label{wxbitmapdataobject}
2
3 wxBitmapDataObject is a specialization of wxDataObject for bitmap data. It can be
4 used without change to paste data into the \helpref{wxClipboard}{wxclipboard}
5 or a \helpref{wxDropSource}{wxdropsource}. A user may wish to derive a new class
6 from this class for providing a bitmap on-demand in order to minimize memory consumption
7 when offering data in several formats, such as a bitmap and GIF.
8
9 In order to offer bitmap data on-demand \helpref{GetSize}{wxbitmapdataobjectgetsize}
10 and \helpref{WriteData}{wxbitmapdataobjectwritedata} will have to be overridden.
11
12 \wxheading{Derived from}
13
14 \helpref{wxDataObject}{wxdataobject}
15
16 \wxheading{See also}
17
18 \helpref{wxDataObject}{wxdataobject}
19
20 \latexignore{\rtfignore{\wxheading{Members}}}
21
22 \membersection{wxBitmapDataObject::wxBitmapDataObject}\label{wxbitmapdataobjectwxbitmapdataobject}
23
24 \func{}{wxBitmapDataObject}{\void}
25
26 Default constructor. Call \helpref{SetBitmap}{wxbitmapdataobjectsetbitmap} later
27 or override \helpref{WriteData}{wxbitmapdataobjectwritedata} and
28 \helpref{GetSize}{wxbitmapdataobjectgetsize} for providing data on-demand.
29
30 \func{}{wxBitmapDataObject}{\param{const wxBitmap\& }{bitmap}}
31
32 Constructor, passing a bitmap.
33
34 \membersection{wxBitmapDataObject::GetSize}\label{wxbitmapdataobjectgetsize}
35
36 \constfunc{virtual size\_t}{GetSize}{\void}
37
38 Returns the data size. By default, returns the size of the bitmap data
39 set in the constructor or using \helpref{SetBitmap}{wxbitmapdataobjectsetbitmap}.
40 This can be overridden to provide size data on-demand. Note that you'd
41 have to call the inherited GetSize method as this is the only way
42 to get to know the transfer size of the bitmap in a platform dependent
43 way - a bitmap has different size under GTK and Windows. In practice,
44 this would look like this:
45
46 \begin{verbatim}
47 size_t MyBitmapDataObject::GetSize()
48 {
49 // Get bitmap from global container. This container
50 // should be able to "produce" data in all formats
51 // offered by the application but store it only in
52 // one format to reduce memory consumption.
53
54 wxBitmap my_bitmap = my_global_container->GetBitmap();
55
56 // temporarily set bitmap
57
58 SetBitmap( my_bitmap );
59
60 size_t ret = wxBitmapDataObject::GetSize();
61
62 // unset bitmap again
63
64 SetBitmap( wxNullBitmap );
65
66 retrun ret;
67 }
68 \end{verbatim}
69
70 TODO: Offer a nicer way to do this. Maybe by providing a platform
71 dependent function in this class like
72
73 \begin{verbatim}
74 size_t GetBitmapSize( const wxBitmap &bitmap )
75 \end{verbatim}
76
77 \membersection{wxBitmapDataObject::GetBitmap}\label{wxbitmapdataobjectgettext}
78
79 \constfunc{virtual wxBitmap}{GetBitmap}{\void}
80
81 Returns the bitmap associated with the data object. You may wish to override
82 this method when offering data on-demand, but this is not required by
83 wxWindows' internals. Use this method to get data in bitmap form from
84 the \helpref{wxClipboard}{wxclipboard}.
85
86 \membersection{wxBitmapDataObject::SetBitmap}\label{wxbitmapdataobjectsetbitmap}
87
88 \func{virtual void}{SetBitmap}{\param{const wxBitmap\& }{bitmap}}
89
90 Sets the bitmap associated with the data object. This method is called
91 internally when retrieving data from the \helpref{wxClipboard}{wxclipboard}
92 and may be used to paste data to the clipboard directly (instead of
93 on-demand).
94
95 \membersection{wxBitmapDataObject::WriteData}\label{wxbitmapdataobjectwritedata}
96
97 \constfunc{virtual void}{WriteData}{\param{void}{*dest} }
98
99 Write the data owned by this class to {\it dest}. By default, this
100 calls \helpref{WriteBitmap}{wxbitmapdataobjectwritebitmap} with the bitmap
101 set in the constructor or using \helpref{SetBitmap}{wxbitmapdataobjectsetbitmap}.
102 This can be overridden to provide bitmap data on-demand; in this case
103 \helpref{WriteBitmap}{wxbitmapdataobjectwritebitmap} must be called from
104 within th overriding WriteData() method.
105
106 \membersection{wxBitmapDataObject::WriteBitmap}\label{wxbitmapdataobjectwritebitmap}
107
108 \constfunc{void}{WriteBitmap}{\param{const wxBitmap\& }{bitmap}\param{void}{*dest} }
109
110 Writes the the bitmap {\it bitmap} to {\it dest}. This method must be called
111 from \helpref{WriteData}{wxbitmapdataobjectwritedata}.
112