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