[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1730
Date       : Sun Sep  3 11:58:18 BST 2006

Changed paths:
   M /Trunk/XaraLX/tools/filltool.cpp
   M /Trunk/XaraLX/wxOil/bitmapgriddropdown.cpp
   M /Trunk/XaraLX/wxOil/bitmapgriddropdown.h
   M /Trunk/XaraLX/wxXtra/gridcombo.cpp

Apply Michael T's patches for dropdowns


Diff:
Index: Trunk/XaraLX/tools/filltool.cpp
===================================================================
--- Trunk/XaraLX/tools/filltool.cpp	(revision 1729)
+++ Trunk/XaraLX/tools/filltool.cpp	(revision 1730)
@@ -3439,7 +3439,7 @@
 				Str = ((KernelBitmap*)pBmp)->ActualBitmap->GetName();
 
 				KernelBitmap* bitmap = ((KernelBitmap*)pBmp);
-				m_oBitmapDropDown.AddItem(bitmap, Str);
+				m_oBitmapDropDown.AddItem(bitmap, FALSE, Str);
 				
 				Index++;
 			}
@@ -6829,7 +6829,7 @@
 				Str = ((KernelBitmap*)pBmp)->ActualBitmap->GetName();
 
 				KernelBitmap* bitmap = ((KernelBitmap*)pBmp);
-				m_oBitmapDropDown.AddItem(bitmap, Str);
+				m_oBitmapDropDown.AddItem(bitmap, FALSE, Str);
 				
 				Index++;
 			}
Index: Trunk/XaraLX/wxXtra/gridcombo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/gridcombo.cpp	(revision 1729)
+++ Trunk/XaraLX/wxXtra/gridcombo.cpp	(revision 1730)
@@ -768,7 +768,7 @@
 {
 	m_vecUserData.push_back(pUserData);
 	
-	wxGridComboPopup* pPopup = dynamic_cast<wxGridComboPopup*>(GetPopupControl());
+	wxGridComboPopup* pPopup = (wxGridComboPopup*)GetPopupControl();
 	if (pPopup)
 		pPopup->UpdateScrollers();
 }
@@ -786,7 +786,8 @@
 {
 	DeleteUserData();
 	
-	wxGridComboPopup* pPopup = dynamic_cast<wxGridComboPopup*>(GetPopupControl());
+	wxGridComboPopup* pPopup = (wxGridComboPopup*)GetPopupControl();
+
 	if (pPopup)
 		pPopup->UpdateScrollers();
 }
@@ -843,7 +844,8 @@
 {
 	m_szItem = szItem;
 
-	wxGridComboPopup* pPopup = dynamic_cast<wxGridComboPopup*>(GetPopupControl());
+	wxGridComboPopup* pPopup = (wxGridComboPopup*)GetPopupControl();
+
 	if (!pPopup)
 		return;
 
@@ -864,7 +866,8 @@
 {
 	m_iColumns = iCols;
 	
-	wxGridComboPopup* pPopup = dynamic_cast<wxGridComboPopup*>(GetPopupControl());
+	wxGridComboPopup* pPopup = (wxGridComboPopup*)GetPopupControl();
+
 	if (!pPopup)
 		return;
 
@@ -887,7 +890,8 @@
 	if (GetSelected() == iItem)
 		return;
 
-	wxGridComboPopup* pPopup = dynamic_cast<wxGridComboPopup*>(GetPopupControl());
+	wxGridComboPopup* pPopup = (wxGridComboPopup*)GetPopupControl();
+
 	if (!pPopup)
 		return;
 
Index: Trunk/XaraLX/wxOil/bitmapgriddropdown.h
===================================================================
--- Trunk/XaraLX/wxOil/bitmapgriddropdown.h	(revision 1729)
+++ Trunk/XaraLX/wxOil/bitmapgriddropdown.h	(revision 1730)
@@ -109,49 +109,158 @@
 class LineAttrItem;
 
 
-/*************************************************************************
-Class         : CBGDDItemInfo
-Base Class    : public CGridComboUserData
-Author        : Mikhail Tatarnikov
-Description   : Item information for CBitmapGridDropDown.
-Pure Virtual  : None
-Known Issues  : None
-Usage Notes   : None
-Override Notes: None
-**************************************************************************/
+/*************************************************************************
+Class         : CBGDDItemInfo
+Base Class    : public CGridComboUserData
+Author        : Mikhail Tatarnikov
+Description   : Items base class for for CBitmapGridDropDown control.
+Pure Virtual  : DrawItem - the derived classes has to implement their own drawing.
+Known Issues  : None
+Usage Notes   : None
+Override Notes: None
+**************************************************************************/
 class CBGDDItemInfo : public CGridComboUserData
 {
 public:
-	CBGDDItemInfo();
-	CBGDDItemInfo(UINT32 uiBitmapResID, String_256 strLabel = String_256());
-	CBGDDItemInfo(wxBitmap* pBitmap, BOOL bBitmapAutodelete = TRUE, String_256 strLabel = String_256());
-
+	CBGDDItemInfo(String_256 strLabel = String_256());
 	virtual ~CBGDDItemInfo();
 
-	// Accessors
-	wxBitmap*  GetBitmap();
 	String_256 GetLabel();
 
+	virtual void DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const = 0;
+
 protected:
 	String_256 m_strLabel;
-	UINT32	   m_uiBitmapResID;
-	wxBitmap*  m_pBitmap;
-	BOOL	   m_bBitmapAutodelete;
 };
 
 
 
-/*************************************************************************
-Class         : CBitmapGridDropDown
-Base Class    : public CGridDropDown
-Author        : Mikhail Tatarnikov
-Description   : Control class for wxGridCombo control that stores and displays
-				items as images.
-Pure Virtual  : None
-Known Issues  : None
-Usage Notes   : None
-Override Notes: None
-**************************************************************************/
+/*************************************************************************
+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
+**************************************************************************/
+class CBGDDWxBitmapItem : public CBGDDItemInfo
+{
+public:
+	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:
+	wxBitmap* m_pBitmap;
+	BOOL	  m_bDelete;
+	BOOL	  m_bStretch;
+};
+
+
+
+/*************************************************************************
+Class         : CBGDDResourceItem
+Base Class    : public CBGDDWxBitmapItem
+Author        : Mikhail Tatarnikov
+Description   : Item for displaying a resource-stored bitmap.
+Pure Virtual  : None
+Known Issues  : None
+Usage Notes   : None
+Override Notes: None
+**************************************************************************/
+class CBGDDResourceItem : public CBGDDWxBitmapItem
+{
+public:
+	CBGDDResourceItem(UINT32 uiBitmapResID,
+					  String_256 strLabel = String_256(),
+					  BOOL		 bStretch = TRUE);
+	virtual ~CBGDDResourceItem();
+};
+
+
+
+/*************************************************************************
+Class         : CBGDDKernelBitmapItem
+Base Class    : public CBGDDItemInfo
+Author        : Mikhail Tatarnikov
+Description   : Item for displaying a KernelBitmap.
+Pure Virtual  : None
+Known Issues  : None
+Usage Notes   : None
+Override Notes: None
+**************************************************************************/
+class CBGDDKernelBitmapItem : public CBGDDItemInfo
+{
+public:
+	CBGDDKernelBitmapItem(KernelBitmap* pKernelBitmap, BOOL bAutodelete = TRUE,
+						  String_256 strLabel = String_256(),
+						  BOOL		 bStretch = TRUE);
+	virtual ~CBGDDKernelBitmapItem();
+
+	virtual void DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const;
+
+protected:
+	// Get the representation of the item (of the Kernel Bitmap)
+	wxBitmap* GetWxBitmap(wxSize szBitmap) const;
+
+private:
+	static BOOL DoesCacheItemSizeMatch(const pair<wxSize, wxBitmap*>* poItem, wxSize szBitmap);
+
+protected:
+	KernelBitmap* m_pKernelBitmap;
+	BOOL		  m_bDeleteKernelBitmap;
+	BOOL		  m_bStretch;
+
+	typedef	std::vector<pair<wxSize, wxBitmap*>*> TDCacheCollection;
+	mutable TDCacheCollection m_colCache;
+};
+
+
+
+
+
+
+/*************************************************************************
+Class         : CBGDDStrokeItem
+Base Class    : public CBGDDItemInfo
+Author        : Mikhail Tatarnikov
+Description   : Item for displaying a stroke.
+Pure Virtual  : None
+Known Issues  : None
+Usage Notes   : None
+Override Notes: None
+**************************************************************************/
+class CBGDDStrokeItem : public CBGDDItemInfo
+{
+public:
+	CBGDDStrokeItem(LineAttrItem* plaiStroke, BOOL bAutodelete = TRUE, String_256 strLabel = String_256());
+	virtual ~CBGDDStrokeItem();
+
+	virtual void DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const;
+
+protected:
+	LineAttrItem* m_plaiStroke;
+	BOOL		  m_bDelete;
+};
+
+
+
+/*************************************************************************
+Class         : CBitmapGridDropDown
+Base Class    : public CGridDropDown
+Author        : Mikhail Tatarnikov
+Description   : Control class for wxGridCombo control that stores and displays
+				items as images.
+Pure Virtual  : None
+Known Issues  : None
+Usage Notes   : None
+Override Notes: None
+**************************************************************************/
 class CBitmapGridDropDown : public CGridDropDown
 {
 friend class DialogManager;
@@ -161,11 +270,11 @@
 	CBitmapGridDropDown();
 	virtual ~CBitmapGridDropDown();
 
-	void AddItem(UINT32 uiBitmapResID, String_256 strLabel = String_256());
-	void AddItem(wxBitmap* pBitmap, String_256 strLabel = String_256());
-	void AddItem(KernelBitmap* pBitmap, String_256 strLabel = String_256());
-	void AddItem(LineAttrItem* plaiStroke, String_256 strLabel = String_256());
-	void AddItem(AttrBrushType* pabtBrush, String_256 strLabel = String_256());
+	void AddItem(UINT32 uiBitmapResID, String_256 strLabel = String_256(), BOOL bStretch = TRUE);
+	void AddItem(wxBitmap* pBitmap, BOOL bDelete = TRUE, String_256 strLabel = String_256(), BOOL bStretch = TRUE);
+	void AddItem(KernelBitmap* pBitmap, BOOL bDelete = TRUE, String_256 strLabel = String_256(), BOOL bStretch = TRUE);
+	void AddItem(LineAttrItem* plaiStroke, BOOL bDelete = TRUE, String_256 strLabel = String_256());
+	void AddItem(AttrBrushType* pabtBrush, BOOL bDelete = TRUE, String_256 strLabel = String_256());
 
 	void SetUnselectedItem(UINT32 uiBitmapResID, String_256 strLabel = String_256());
 	void SetUnselectedItem(wxBitmap* pBitmap, String_256 strLabel = String_256());
Index: Trunk/XaraLX/wxOil/bitmapgriddropdown.cpp
===================================================================
--- Trunk/XaraLX/wxOil/bitmapgriddropdown.cpp	(revision 1729)
+++ Trunk/XaraLX/wxOil/bitmapgriddropdown.cpp	(revision 1730)
@@ -131,94 +131,200 @@
 #define new CAM_DEBUG_NEW
 
 
-CBGDDItemInfo::CBGDDItemInfo()
+CBGDDItemInfo::CBGDDItemInfo(String_256 strLabel)
 {
-	m_uiBitmapResID		= (UINT32)-1;
-	m_pBitmap			= NULL;
-	m_bBitmapAutodelete = FALSE;
+	m_strLabel = strLabel;
 }
 
 
-/******************************************************************************
-Function  : CBGDDItemInfo::CBGDDItemInfo
-Author    : Mikhail Tatarnikov
-Purpose   : Construct an item with image stored in resources
-Returns   : void
-Exceptions: 
-Parameters: [in] UINT32		uiBitmapResID - resource id with the image;
-            [in] String_256 strLabel	  - label for the item.
-Notes     : 
-******************************************************************************/
-CBGDDItemInfo::CBGDDItemInfo(UINT32 uiBitmapResID, String_256 strLabel)
+CBGDDItemInfo::~CBGDDItemInfo()
 {
-	m_uiBitmapResID		= uiBitmapResID;
-	m_pBitmap			= NULL;
-	m_bBitmapAutodelete = FALSE;
-	m_strLabel			= strLabel;
 }
 
+
+
 /******************************************************************************
-Function  : CBGDDItemInfo::CBGDDItemInfo
+Function  : CBGDDItemInfo::GetLabel
 Author    : Mikhail Tatarnikov
-Purpose   : Constructs an item with bitmap
-Returns   : void
+Purpose   : Gets the text assocciated with the item.
+Returns   : String_256 - the item label.
 Exceptions: 
-Parameters: [in] wxBitmap*	pBitmap			  - bitmap to show for the image;
-            [in] BOOL		bBitmapAutodelete - whether we own the bitmap or not;
-            [in] String_256 strLabel		  - label for the item.
+Parameters: None
 Notes     : 
 ******************************************************************************/
-CBGDDItemInfo::CBGDDItemInfo(wxBitmap* pBitmap, BOOL bBitmapAutodelete, String_256 strLabel)
+String_256 CBGDDItemInfo::GetLabel()
 {
-	m_pBitmap			= pBitmap;
-	m_uiBitmapResID		= (UINT32)-1;
-	m_bBitmapAutodelete = bBitmapAutodelete;
-	m_strLabel			= strLabel;
+	return m_strLabel;
 }
 
-CBGDDItemInfo::~CBGDDItemInfo()
+
+
+
+CBGDDWxBitmapItem::CBGDDWxBitmapItem(wxBitmap* pBitmap, BOOL bAutodelete,
+									 String_256 strLabel,
+									 BOOL bStretch)
+	: CBGDDItemInfo(strLabel)
 {
-	if (m_pBitmap && m_bBitmapAutodelete)
+	m_pBitmap  = pBitmap;
+	m_bDelete  = bAutodelete;
+	m_bStretch = bStretch;
+}
+
+CBGDDWxBitmapItem::~CBGDDWxBitmapItem()
+{
+	if (m_bDelete)
 		delete m_pBitmap;
 }
 
 
-/******************************************************************************
-Function  : CBGDDItemInfo::GetBitmap
-Author    : Mikhail Tatarnikov
-Purpose   : Gets the bitmap associated with the item
-Returns   : wxBitmap* - the item's bitmap.
-Exceptions: 
-Parameters: None
-Notes     : Loads bitmap from resources if necessary.
-******************************************************************************/
-wxBitmap* CBGDDItemInfo::GetBitmap()
+void CBGDDWxBitmapItem::DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const
 {
-	// If we are given a bitmap, just return it.
-	if (m_pBitmap)
-		return m_pBitmap;
+	// If the item isn't enabled just don't draw it
+	// TODO: grey out the current bitmap instead.
+	if (iFlags & wxGridComboPopup::keDisabled)
+		return;
 
-	//  Try to load the resource otherwise.
-	return CamArtProvider::Get()->FindBitmap(m_uiBitmapResID, CAF_DEFAULT);
+
+	// Draw to the memory bitmap first (so we can be sure the borders
+	// isn't eated by the scaling.
+	wxMemoryDC dcMem;
+	wxBitmap oMemBitmap(rect.width, rect.height);
+	dcMem.SelectObject(oMemBitmap);
+
+
+	static wxPen   penBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
+	static wxBrush brBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
+
+	// Erase with background (by default it's grey).
+	dcMem.SetPen(penBackground);
+	dcMem.SetBrush(brBackground);
+
+	dcMem.DrawRectangle(0, 0, rect.width, rect.height);
+
+	double dXScale = 1.0;
+	double dYScale = 1.0;
+
+	if (m_bStretch)
+	{
+		dXScale = (double)rect.width  / (double)m_pBitmap->GetWidth();
+		dYScale = (double)rect.height / (double)m_pBitmap->GetHeight();
+	}
+
+	dcMem.SetUserScale(dXScale, dYScale);
+
+	dcMem.DrawBitmap(*m_pBitmap, 0, 0, TRUE);
+
+
+	dcMem.SetBrush(wxNullBrush);
+	dcMem.SetPen(wxNullPen);
+	dcMem.SelectObject(wxNullBitmap);
+	
+	// Now we can draw bitmap without scaling - it has been scaled while
+	// drawing to the memory DC.
+	dc.SetUserScale(1.0, 1.0);
+	dc.DrawBitmap(oMemBitmap, rect.x, rect.y, false);
 }
 
 
+CBGDDResourceItem::CBGDDResourceItem(UINT32 uiBitmapResID, String_256 strLabel, BOOL bStretch)
+	: CBGDDWxBitmapItem(NULL, FALSE, strLabel, bStretch)
+{
+	m_pBitmap = CamArtProvider::Get()->FindBitmap(uiBitmapResID, CAF_DEFAULT);
+	m_bDelete = FALSE;
+}
+
+CBGDDResourceItem::~CBGDDResourceItem()
+{
+}
+
+
+
+
+
+
+
+
+
+CBGDDKernelBitmapItem::CBGDDKernelBitmapItem(KernelBitmap* pKernelBitmap, BOOL bAutodelete,
+											 String_256 strLabel, BOOL bStretch)
+	: CBGDDItemInfo(strLabel)
+{
+	m_pKernelBitmap		  = pKernelBitmap;
+	m_bDeleteKernelBitmap = bAutodelete;
+	m_bStretch			  = bStretch;
+}
+
+CBGDDKernelBitmapItem::~CBGDDKernelBitmapItem()
+{
+	if (m_bDeleteKernelBitmap)
+		delete m_pKernelBitmap;
+
+	TDCacheCollection::const_iterator citCur;
+	for (citCur = m_colCache.begin(); citCur != m_colCache.end(); ++citCur)
+	{
+		delete (*citCur)->second;
+		delete *citCur;
+	}
+	
+	m_colCache.clear();
+}
+
+
+BOOL CBGDDKernelBitmapItem::DoesCacheItemSizeMatch(const pair<wxSize, wxBitmap*>* poItem, wxSize szBitmap)
+{
+	return poItem->first == szBitmap;
+}
+
 /******************************************************************************
-Function  : CBGDDItemInfo::GetLabel
+Function  : CBGDDKernelBitmapItem::GetWxBitmap
 Author    : Mikhail Tatarnikov
-Purpose   : Gets the text assocciated with the item.
-Returns   : String_256 - the item label.
+Purpose   : Gets the wxBitmap representation of the currently stored KernelBitmap
+Returns   : wxBitmap* - the required version of the KernelBitmap.
 Exceptions: 
-Parameters: None
-Notes     : 
+Parameters: [in] wxSize szBitmap - the size of representation.
+Notes     : Since the KernelBitmap stored in the item can be of considerable size,
+			we have to speed up the drawing (and scaling). It's done by caching
+			the bitmap representations.
 ******************************************************************************/
-String_256 CBGDDItemInfo::GetLabel()
+wxBitmap* CBGDDKernelBitmapItem::GetWxBitmap(wxSize szBitmap) const
 {
-	return m_strLabel;
+	// Try to locate the cache.
+	TDCacheCollection::const_iterator citFound = find_if(m_colCache.begin(), m_colCache.end(),
+		bind2nd(ptr_fun(DoesCacheItemSizeMatch), szBitmap));
+
+	if (citFound != m_colCache.end())
+		return (*citFound)->second;
+
+	// Here we have a cache miss. We need to rebuild the bitmap.
+	// NOTE: the maximum size of bitmap allowed by BitmapDragInformation is 180*??? pixels!!
+	wxMemoryDC dcMem;
+	wxBitmap* pBitmap = new wxBitmap(szBitmap.x, szBitmap.y);
+	dcMem.SelectObject(*pBitmap);
+	dcMem.SetUserScale(1.0, 1.0);
+
+	wxSize szDragBitmap = szBitmap;
+	if (!m_bStretch)
+		szDragBitmap = wxSize(m_pKernelBitmap->GetWidth(), m_pKernelBitmap->GetHeight());
+
+	BitmapDragInformation oDragBitmap(m_pKernelBitmap, szDragBitmap.x, szDragBitmap.y, 0, 0);
+	oDragBitmap.OnDrawSolidDrag(wxPoint(0, 0), &dcMem);
+
+	dcMem.SelectObject(wxNullBitmap);
+
+	// Now we have a resulting bitmap. We need to cache and return it.
+	m_colCache.push_back(new pair<wxSize, wxBitmap*>(szBitmap, pBitmap));
+
+	return pBitmap;
 }
 
 
+void CBGDDKernelBitmapItem::DrawItem(wxDC& dc, const wxRect& rcDraw, INT32 iFlags) const
+{
+	wxBitmap* pBitmap = GetWxBitmap(rcDraw.GetSize());
 
+	// We don't need to scale or do anything since we already have a bitmap of the right size.
+	dc.DrawBitmap(*pBitmap, rcDraw.x, rcDraw.y, FALSE);
+}
 
 
 
@@ -226,6 +332,88 @@
 
 
 
+CBGDDStrokeItem::CBGDDStrokeItem(LineAttrItem* plaiStroke, BOOL bAutodelete, String_256 strLabel)
+	: CBGDDItemInfo(strLabel)
+{
+	m_plaiStroke = plaiStroke;
+	m_bDelete	 = bAutodelete;
+}
+
+CBGDDStrokeItem::~CBGDDStrokeItem()
+{
+	if (m_bDelete)
+		delete m_plaiStroke;
+}
+
+void CBGDDStrokeItem::DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const
+{
+	INT32 iDPI = 96;
+
+	// Since we don't have a view, we need a fake one.
+	DialogView *pDialogView = new DialogView;
+	pDialogView->Init();
+	FIXED16 Scale(1);
+
+	Matrix oMatrix(1, 0, 0, 1, 0, 0);
+
+	wxSize szItem = rect.GetSize();
+
+	// Convert the item area to millipoints
+	DocRect rcDocClip;
+	rcDocClip.lo.x = 0;
+	rcDocClip.lo.y = 0;
+
+	rcDocClip.hi.x = (szItem.x * 1000);
+	rcDocClip.hi.y = (szItem.y * 1000);
+
+
+	// Create a bitmap render region.
+	GRenderBitmap* pRenderRegion = new GRenderBitmap(rcDocClip, oMatrix, Scale, 24, iDPI, FALSE, 0, NULL, TRUE);
+	pRenderRegion->AttachDevice(pDialogView, &dc, NULL, false);
+	
+	// Prepare for the rendering.
+	pRenderRegion->InitDevice();
+	pRenderRegion->SaveContext();
+	pRenderRegion->StartRender();
+
+	// Render the stroke.
+	m_plaiStroke->Render(pRenderRegion, rcDocClip, LineAttrItem::NO_LABEL);
+
+	pRenderRegion->StopRender();
+	pRenderRegion->RestoreContext();
+
+	KernelBitmap* pKernelBitmap = new KernelBitmap(pRenderRegion->ExtractBitmap(), FALSE);
+
+	BitmapDragInformation oDragBitmap(pKernelBitmap, szItem.x, szItem.y, 0, 0);
+	oDragBitmap.OnDrawSolidDrag(rect.GetTopLeft(), &dc);
+
+	delete pKernelBitmap;
+	delete pRenderRegion;
+	delete pDialogView;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 CBitmapGridDropDown::CBitmapGridDropDown()
 {
 	m_poUnselectedItem	= NULL;
@@ -248,9 +436,9 @@
             [in] String_256 strLabel	  - label for the item.
 Notes     : 
 ******************************************************************************/
-void CBitmapGridDropDown::AddItem(UINT32 uiBitmapResID, String_256 strLabel)
+void CBitmapGridDropDown::AddItem(UINT32 uiBitmapResID, String_256 strLabel, BOOL bStretch)
 {
-	CBGDDItemInfo* pData = new CBGDDItemInfo(uiBitmapResID, strLabel);
+	CBGDDItemInfo* pData = new CBGDDResourceItem(uiBitmapResID, strLabel, bStretch);
 	CGridDropDown::AddItem(pData);
 }
 
@@ -264,9 +452,9 @@
             [in] String_256 strLabel - the item label.
 Notes     : 
 ******************************************************************************/
-void CBitmapGridDropDown::AddItem(wxBitmap* pBitmap, String_256 strLabel)
+void CBitmapGridDropDown::AddItem(wxBitmap* pBitmap, BOOL bDelete, String_256 strLabel, BOOL bStretch)
 {
-	CBGDDItemInfo* pData = new CBGDDItemInfo(pBitmap, TRUE, strLabel);
+	CBGDDItemInfo* pData = new CBGDDWxBitmapItem(pBitmap, bDelete, strLabel, bStretch);
 	CGridDropDown::AddItem(pData);
 }
 
@@ -280,21 +468,10 @@
             [in] String_256	   strLabel		 - the item label.
 Notes     : 
 ******************************************************************************/
-void CBitmapGridDropDown::AddItem(KernelBitmap* pKernelBitmap, String_256 strLabel)
+void CBitmapGridDropDown::AddItem(KernelBitmap* pKernelBitmap, BOOL bDelete, String_256 strLabel, BOOL bStretch)
 {
-	wxSize szItem =  GetItemSize();
-	wxBitmap* pBitmap = new wxBitmap(szItem.x, szItem.y);
-	wxMemoryDC dcMem;
-
-	dcMem.SelectObject(*pBitmap);
-
-	BitmapDragInformation oDragBitmap(pKernelBitmap, szItem.x, szItem.y, 0, 0);
-	oDragBitmap.OnDrawSolidDrag(wxPoint(0, 0), &dcMem);
-
-
-	dcMem.SelectObject(wxNullBitmap);
-
-	AddItem(pBitmap, strLabel);
+	CBGDDItemInfo* pData = new CBGDDKernelBitmapItem(pKernelBitmap, bDelete, strLabel, bStretch);
+	CGridDropDown::AddItem(pData);
 }
 
 
@@ -308,13 +485,10 @@
             [in] String_256	   strLabel	  - the item label.
 Notes     : 
 ******************************************************************************/
-void CBitmapGridDropDown::AddItem(LineAttrItem* plaiStroke, String_256 strLabel)
+void CBitmapGridDropDown::AddItem(LineAttrItem* plaiStroke, BOOL bDelete, String_256 strLabel)
 {
-	KernelBitmap* pBitmap = PreviewStroke(plaiStroke);
-	AddItem(pBitmap, strLabel);
-
-	delete pBitmap;
-	delete plaiStroke;
+	CBGDDStrokeItem* pStrokeItem = new CBGDDStrokeItem(plaiStroke, bDelete, strLabel);
+	CGridDropDown::AddItem(pStrokeItem);
 }
 
 
@@ -328,10 +502,10 @@
             [in] String_256		strLabel  - the item label.
 Notes     : 
 ******************************************************************************/
-void CBitmapGridDropDown::AddItem(AttrBrushType* pabtBrush, String_256 strLabel)
+void CBitmapGridDropDown::AddItem(AttrBrushType* pabtBrush, BOOL bDelete, String_256 strLabel)
 {
 	wxBitmap* pBitmap = PreviewBrush(pabtBrush);
-	AddItem(pBitmap, strLabel);
+	AddItem(pBitmap, bDelete, strLabel);
 }
 
 
@@ -347,7 +521,7 @@
 ******************************************************************************/
 void CBitmapGridDropDown::SetUnselectedItem(UINT32 uiBitmapResID, String_256 strLabel)
 {
-	m_poUnselectedItem = new CBGDDItemInfo(uiBitmapResID, strLabel);
+	m_poUnselectedItem = new CBGDDResourceItem(uiBitmapResID, strLabel);
 }
 
 
@@ -363,7 +537,7 @@
 ******************************************************************************/
 void CBitmapGridDropDown::SetUnselectedItem(wxBitmap* pBitmap, String_256 strLabel)
 {
-	m_poUnselectedItem = new CBGDDItemInfo(pBitmap, TRUE, strLabel);
+	m_poUnselectedItem = new CBGDDWxBitmapItem(pBitmap, TRUE, strLabel);
 }
 
 
@@ -373,62 +547,17 @@
 Purpose   : Draws the item core - the image itself
 Returns   : void
 Exceptions: 
-Parameters: [in] wxDC&	 dc		- the device context to draw to;
-            [in] wxRect& rect	- the area of the item;
-            [in] int	 iItem	- item index;
-            [in] int	 iFlags - additional flags (selected, highlighted, ...)
+Parameters: [in] wxDC&	 dc		- the device context to draw to;
+            [in] wxRect& rect	- the area of the item;
+            [in] int	 iItem	- item index;
+            [in] int	 iFlags - additional flags (selected, highlighted, ...)
 Notes     : 
 ******************************************************************************/
 void CBitmapGridDropDown::DrawItemCore(wxDC& dc, const wxRect& rect, int iItem, INT32 iFlags)
 {
-	// If the item isn't enabled just don't draw it
-	// TODO: grey out the current bitmap instead.
-	if (iFlags & wxGridComboPopup::keDisabled)
-		return;
+	CBGDDItemInfo* pItemData = GetItemData(iItem);
 
-	CBGDDItemInfo* pData = (CBGDDItemInfo*)GetItemData(iItem);
-	if (!pData)
-		return;
-
-	// Obtain the bitmap to draw.
-	wxBitmap* pBitmap = pData->GetBitmap();
-	if (!pBitmap)
-		return;
-
-	// Draw to the memory bitmap first (so we can be sure the borders
-	// isn't eated by the scaling.
-	wxMemoryDC dcMem;
-//	wxSize szItem =  GetItemSize();
-	wxBitmap oMemBitmap(rect.width, rect.height);
-	dcMem.SelectObject(oMemBitmap);
-
-
-	static wxPen   penBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
-	static wxBrush brBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
-
-	// Erase with background (by default it's grey).
-	dcMem.SetPen(penBackground);
-	dcMem.SetBrush(brBackground);
-
-	dcMem.DrawRectangle(0, 0, rect.width, rect.height);
-
-
-	double dXScale = (double)rect.width  / pBitmap->GetWidth();
-	double dYScale = (double)rect.height / pBitmap->GetHeight();
-
-	dcMem.SetUserScale(dXScale, dYScale);
-
-	dcMem.DrawBitmap(*pBitmap, 0, 0, TRUE);
-	
-
-	dcMem.SetBrush(wxNullBrush);
-	dcMem.SetPen(wxNullPen);
-	dcMem.SelectObject(wxNullBitmap);
-	
-	// Now we can draw bitmap without scaling - it has been scaled while
-	// drawing to the memory DC.
-	dc.DrawBitmap(oMemBitmap, rect.x, rect.y, false);
-
+	pItemData->DrawItem(dc, rect, iFlags);
 }
 
 
@@ -446,7 +575,7 @@
 	if (iItem == -1)
 		return m_poUnselectedItem;
 
-	return dynamic_cast<CBGDDItemInfo*>(CGridDropDown::GetItemData(iItem));
+	return (CBGDDItemInfo*)CGridDropDown::GetItemData(iItem);
 }
 
 /******************************************************************************
@@ -492,7 +621,7 @@
 ******************************************************************************/
 wxBitmap* CBitmapGridDropDown::PreviewBrush(AttrBrushType* pabtBrush)
 {
-	ERROR2IF(TRUE, FALSE, "CBitmapGridDropDown::PreviewBrush Not implemented yet");
+	ERROR2IF(TRUE, FALSE, "CBitmapGridDropDown::PreviewBrush Not implemented yet");
 /*
 	wxMemoryDC dcMem;
 


Xara