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