CBGDDWxBitmapItem Class Reference

#include <bitmapgriddropdown.h>

Inheritance diagram for CBGDDWxBitmapItem:

CBGDDItemInfo CGridComboUserData CBGDDResourceItem List of all members.

Public Member Functions

 CBGDDWxBitmapItem (wxBitmap *pBitmap, BOOL bAutodelete=TRUE, String_256 strLabel=String_256(), BOOL bStretch=TRUE)
virtual ~CBGDDWxBitmapItem ()
virtual void DrawItem (wxDC &dc, const wxRect &rect, INT32 iFlags) const

Protected Attributes

wxBitmap * m_pBitmap
BOOL m_bDelete
BOOL m_bStretch

Detailed Description

Class : CBGDDWxBitmapItem Base Class : public CBGDDItemInfo Author : Mikhail Tatarnikov Description : Item for displaying a wxBitmap. Pure Virtual : None Known Issues : None Usage Notes : None Override Notes: None

Definition at line 149 of file bitmapgriddropdown.h.


Constructor & Destructor Documentation

CBGDDWxBitmapItem::CBGDDWxBitmapItem wxBitmap *  pBitmap,
BOOL  bAutodelete = TRUE,
String_256  strLabel = String_256(),
BOOL  bStretch = TRUE
 

Definition at line 163 of file bitmapgriddropdown.cpp.

00166     : CBGDDItemInfo(strLabel)
00167 {
00168     m_pBitmap  = pBitmap;
00169     m_bDelete  = bAutodelete;
00170     m_bStretch = bStretch;
00171 }

CBGDDWxBitmapItem::~CBGDDWxBitmapItem  )  [virtual]
 

Definition at line 173 of file bitmapgriddropdown.cpp.

00174 {
00175     if (m_bDelete)
00176         delete m_pBitmap;
00177 }


Member Function Documentation

void CBGDDWxBitmapItem::DrawItem wxDC &  dc,
const wxRect &  rect,
INT32  iFlags
const [virtual]
 

Function : CBGDDWxBitmapItem::DrawItem Author : Mikhail Tatarnikov Purpose : Draws this item into dc Returns : void Exceptions: Parameters: [in] wxDC& dc - device context to draw to; [in] const wxRect& rect - area occupied by the item; [in] INT32 iFlags - drawing parameters. Notes :

Implements CBGDDItemInfo.

Definition at line 191 of file bitmapgriddropdown.cpp.

00192 {
00193     // If the item isn't enabled just don't draw it
00194     // TODO: grey out the current bitmap instead.
00195     if (iFlags & wxGridComboPopup::keDisabled)
00196         return;
00197 
00198 
00199     // Draw to the memory bitmap first (so we can be sure the borders
00200     // isn't eated by the scaling.
00201     wxMemoryDC dcMem;
00202     wxBitmap oMemBitmap(rect.width, rect.height);
00203     dcMem.SelectObject(oMemBitmap);
00204 
00205 
00206     static wxPen   penBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
00207     static wxBrush brBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
00208 
00209     // Erase with background (by default it's grey).
00210     dcMem.SetPen(penBackground);
00211     dcMem.SetBrush(brBackground);
00212 
00213     dcMem.DrawRectangle(0, 0, rect.width, rect.height);
00214 
00215     double dXScale = 1.0;
00216     double dYScale = 1.0;
00217 
00218     if (m_bStretch)
00219     {
00220         dXScale = (double)rect.width  / (double)m_pBitmap->GetWidth();
00221         dYScale = (double)rect.height / (double)m_pBitmap->GetHeight();
00222     }
00223 
00224     dcMem.SetUserScale(dXScale, dYScale);
00225 
00226     dcMem.DrawBitmap(*m_pBitmap, 0, 0, TRUE);
00227 
00228 
00229     dcMem.SetBrush(wxNullBrush);
00230     dcMem.SetPen(wxNullPen);
00231     dcMem.SelectObject(wxNullBitmap);
00232     
00233     // Now we can draw bitmap without scaling - it has been scaled while
00234     // drawing to the memory DC.
00235     dc.SetUserScale(1.0, 1.0);
00236     dc.DrawBitmap(oMemBitmap, rect.x, rect.y, false);
00237 }


Member Data Documentation

BOOL CBGDDWxBitmapItem::m_bDelete [protected]
 

Definition at line 161 of file bitmapgriddropdown.h.

BOOL CBGDDWxBitmapItem::m_bStretch [protected]
 

Definition at line 162 of file bitmapgriddropdown.h.

wxBitmap* CBGDDWxBitmapItem::m_pBitmap [protected]
 

Definition at line 160 of file bitmapgriddropdown.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:51:55 2007 for Camelot by  doxygen 1.4.4