File: wx35.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (124 lines) | stat: -rw-r--r-- 5,582 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<HTML>
<head><title>wxBitmapDataObject</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxbitmapdataobject"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx34.htm#wxbitmapbutton"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx36.htm#wxbrush"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxBitmapDataObject</H2>
<P>
wxBitmapDataObject is a specialization of wxDataObject for bitmap data. It can be
used without change to paste data into the <A HREF="wx44.htm#wxclipboard">wxClipboard</A>
or a <A HREF="wx81.htm#wxdropsource">wxDropSource</A>. A user may wish to derive a new class
from this class for providing a bitmap on-demand in order to minimize memory consumption
when offering data in several formats, such as a bitmap and GIF.<P>
In order to offer bitmap data on-demand <A HREF="wx35.htm#wxbitmapdataobjectgetsize">GetSize</A> 
and <A HREF="wx35.htm#wxbitmapdataobjectwritedata">WriteData</A> will have to be overridden.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx61.htm#wxdataobject">wxDataObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/dataobj.h&gt;<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx61.htm#wxdataobject">wxDataObject</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxbitmapdataobjectwxbitmapdataobject">wxBitmapDataObject::wxBitmapDataObject</A><BR>
<A HREF="#wxbitmapdataobjectgetsize">wxBitmapDataObject::GetSize</A><BR>
<A HREF="#wxbitmapdataobjectgettext">wxBitmapDataObject::GetBitmap</A><BR>
<A HREF="#wxbitmapdataobjectsetbitmap">wxBitmapDataObject::SetBitmap</A><BR>
<A HREF="#wxbitmapdataobjectwritedata">wxBitmapDataObject::WriteData</A><BR>
<A HREF="#wxbitmapdataobjectwritebitmap">wxBitmapDataObject::WriteBitmap</A><BR>
<P>

<HR>
<A NAME="wxbitmapdataobjectwxbitmapdataobject"></A>
<H3>wxBitmapDataObject::wxBitmapDataObject</H3>
<P>
<B></B> <B>wxBitmapDataObject</B>()<P>
Default constructor. Call <A HREF="wx35.htm#wxbitmapdataobjectsetbitmap">SetBitmap</A> later
or override <A HREF="wx35.htm#wxbitmapdataobjectwritedata">WriteData</A> and 
<A HREF="wx35.htm#wxbitmapdataobjectgetsize">GetSize</A> for providing data on-demand.<P>
<B></B> <B>wxBitmapDataObject</B>(<B>const wxBitmap&amp; </B><I>bitmap</I>)<P>
Constructor, passing a bitmap.<P>

<HR>
<A NAME="wxbitmapdataobjectgetsize"></A>
<H3>wxBitmapDataObject::GetSize</H3>
<P>
<B>virtual size_t</B> <B>GetSize</B>() <B>const</B><P>
Returns the data size. By default, returns the size of the bitmap data
set in the constructor or using <A HREF="wx35.htm#wxbitmapdataobjectsetbitmap">SetBitmap</A>.
This can be overridden to provide size data on-demand. Note that you'd
have to call the inherited GetSize method as this is the only way
to get to know the transfer size of the bitmap in a platform dependent
way - a bitmap has different size under GTK and Windows. In practice, 
this would look like this:<P>
<PRE>
size_t MyBitmapDataObject::GetSize()
{
  // Get bitmap from global container. This container
  // should be able to "produce" data in all formats
  // offered by the application but store it only in
  // one format to reduce memory consumption.

  wxBitmap my_bitmap = my_global_container-&gt;GetBitmap();
  
  // temporarily set bitmap
  
  SetBitmap( my_bitmap );

  size_t ret = wxBitmapDataObject::GetSize();
  
  // unset bitmap again
  
  SetBitmap( wxNullBitmap );

  retrun ret;
}
</PRE>
TODO: Offer a nicer way to do this. Maybe by providing a platform
dependent function in this class like <P>
<PRE>
size_t GetBitmapSize( const wxBitmap &bitmap )
</PRE>

<HR>
<A NAME="wxbitmapdataobjectgettext"></A>
<H3>wxBitmapDataObject::GetBitmap</H3>
<P>
<B>virtual wxBitmap</B> <B>GetBitmap</B>() <B>const</B><P>
Returns the bitmap associated with the data object. You may wish to override
this method when offering data on-demand, but this is not required by
wxWindows' internals. Use this method to get data in bitmap form from
the <A HREF="wx44.htm#wxclipboard">wxClipboard</A>.<P>

<HR>
<A NAME="wxbitmapdataobjectsetbitmap"></A>
<H3>wxBitmapDataObject::SetBitmap</H3>
<P>
<B>virtual void</B> <B>SetBitmap</B>(<B>const wxBitmap&amp; </B><I>bitmap</I>)<P>
Sets the bitmap associated with the data object. This method is called
internally when retrieving data from the <A HREF="wx44.htm#wxclipboard">wxClipboard</A>
and may be used to paste data to the clipboard directly (instead of
on-demand).<P>

<HR>
<A NAME="wxbitmapdataobjectwritedata"></A>
<H3>wxBitmapDataObject::WriteData</H3>
<P>
<B>virtual void</B> <B>WriteData</B>(<B>void</B><I>*dest</I> ) <B>const</B><P>
Write the data owned by this class to <I>dest</I>. By default, this
calls <A HREF="wx35.htm#wxbitmapdataobjectwritebitmap">WriteBitmap</A> with the bitmap
set in the constructor or using <A HREF="wx35.htm#wxbitmapdataobjectsetbitmap">SetBitmap</A>.
This can be overridden to provide bitmap data on-demand; in this case
<A HREF="wx35.htm#wxbitmapdataobjectwritebitmap">WriteBitmap</A> must be called from
within th overriding WriteData() method.<P>

<HR>
<A NAME="wxbitmapdataobjectwritebitmap"></A>
<H3>wxBitmapDataObject::WriteBitmap</H3>
<P>
<B>void</B> <B>WriteBitmap</B>(<B>const wxBitmap&amp; </B><I>bitmap</I><B>void</B><I>*dest</I> ) <B>const</B><P>
Writes the the bitmap <I>bitmap</I> to <I>dest</I>. This method must be called
from <A HREF="wx35.htm#wxbitmapdataobjectwritedata">WriteData</A>.<P>

</BODY></HTML>