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

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1749
Date       : Tue Sep 12 09:46:12 BST 2006

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

Apply Mikhail T's fix for brush dropdowns


Diff:
Index: Trunk/XaraLX/tools/freeinfo.cpp
===================================================================
--- Trunk/XaraLX/tools/freeinfo.cpp	(revision 1748)
+++ Trunk/XaraLX/tools/freeinfo.cpp	(revision 1749)
@@ -711,7 +711,7 @@
 		// Create the brush type combobox.
 		m_bgddBrushType.Init(WindowID, _R(IDC_BRUSHTYPE));
 		m_bgddBrushType.SetColumns(3);
-		m_bgddBrushType.SetItemSize(wxSize(50, 50));
+		m_bgddBrushType.SetItemSize(wxSize(75, 40));
 
 		// Create the stroke type combobox.
 		m_bgddStrokes.Init(WindowID, _R(IDC_STROKETYPE));
@@ -767,10 +767,10 @@
 	BrushHandle SelHandle;
 	
 	// the zeroth index is always reserved for the 'no-brush' 
-	if (iIndex == 0)
-		SelHandle = BrushHandle_NoBrush;
-	else
-		SelHandle = GetBrushHandleFromControlIndex(iIndex-1);
+//	if (iIndex == 0)
+//		SelHandle = BrushHandle_NoBrush;
+//	else
+		SelHandle = GetBrushHandleFromControlIndex(iIndex);
 	//TRACEUSER( "Diccon", _T("Brush Combo: Handle = %d, Index = %d\n"), SelHandle, Index);	
 
 	// tell the tool our selection has changed
@@ -1864,8 +1864,8 @@
 //	UINT32 Counter = 1; // the combo's indexes start at 1
 	
 	BrushHandle Handle = BrushHandle_NoBrush;
+
 	BrushList::const_iterator iter;
-
 	for (iter = m_pBrushList->begin(); iter !=m_pBrushList->end(); iter++)
 	{
 		// get the next handle
@@ -2113,7 +2113,8 @@
 	{
 		BrushHandle Handle = m_pBrushList->front();
 	
-		SetCustomComboGadgetValue(_R(IDC_BRUSHTYPE), NULL, 0, 2 );
+//		SetCustomComboGadgetValue(_R(IDC_BRUSHTYPE), NULL, 0, 2 );
+		m_bgddBrushType.SetSelected(0);
 		
 		m_DisplayBrush = Handle;
 		
@@ -2137,12 +2138,14 @@
 {
 //#ifdef BUILDNEWBRUSHES	
 	// we need to find the index for our brush
-	INT32 Index = GetControlIndexFromBrushHandle(m_DisplayBrush);
-	
+	INT32 iIndex = GetControlIndexFromBrushHandle(m_DisplayBrush);
+
+	m_bgddBrushType.SetSelected(iIndex);
+/*
 	switch (Index)
 	{
 		case -1:
-			SetCustomComboGadgetValue ( _R(IDC_BRUSHTYPE), NULL, TRUE, -2);
+//			SetCustomComboGadgetValue ( _R(IDC_BRUSHTYPE), NULL, TRUE, -2);
 		//	TRACEUSER( "Diccon", _T("Display default brush\n"));
 			break;
 		case 0: // the zeroth index is the same as the head of our selected brushes list
@@ -2154,6 +2157,7 @@
 		//	TRACEUSER( "Diccon", _T("Displayed display brush\n"));
 			break;
 	}
+*/
 //#endif
 }
 
@@ -2211,7 +2215,8 @@
 			Many.Load(_R(IDS_FILLTOOL_MANY));
 			
 			// call custom controls interface ....
-			SelectCustomComboGadgetValueOnString (_R(IDC_BRUSHTYPE), &Many);
+//			SelectCustomComboGadgetValueOnString (_R(IDC_BRUSHTYPE), &Many);
+			m_bgddBrushType.SetSelected(-1);
 			
 		}
 		break;
@@ -2612,7 +2617,8 @@
 void FreeHandInfoBarOp::SetDefaultStrokeInCombo()
 {
 //#ifdef BUILDNEWBRUSHES
-	SetCustomComboGadgetValue(_R(IDC_BRUSHTYPE), NULL, 0, 1);
+//	SetCustomComboGadgetValue(_R(IDC_BRUSHTYPE), NULL, 0, 1);
+	m_bgddBrushType.SetSelected(0);
 //#endif
 }
 
Index: Trunk/XaraLX/wxXtra/gridcombo.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/gridcombo.cpp	(revision 1748)
+++ Trunk/XaraLX/wxXtra/gridcombo.cpp	(revision 1749)
@@ -610,12 +610,12 @@
 void wxGridComboPopup::PaintComboControl(wxDC& dc, const wxRect& rect)
 {
 	int iSelected = GetSelected();
-	if (iSelected == -1)
+/*	if (iSelected == -1)
 	{
 	    wxComboPopup::PaintComboControl(dc, rect);
 		return;
 	}
-
+*/
 	int iFlags = keComboControl;
 	if (!m_pCombo->IsEnabled())
 		iFlags |= keDisabled;
Index: Trunk/XaraLX/wxOil/bitmapgriddropdown.h
===================================================================
--- Trunk/XaraLX/wxOil/bitmapgriddropdown.h	(revision 1748)
+++ Trunk/XaraLX/wxOil/bitmapgriddropdown.h	(revision 1749)
@@ -107,6 +107,7 @@
 
 
 class LineAttrItem;
+class GRenderRegion;
 
 
 /*************************************************************************
@@ -183,10 +184,44 @@
 };
 
 
+/*************************************************************************
+Class         : CBGDDCachedItem
+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: The derived classes should override either RenderItemToBitmap or
+				or GetWxBitmap method - whatever fits best.
+**************************************************************************/
+class CBGDDCachedItem : public CBGDDItemInfo
+{
+public:
+	CBGDDCachedItem(String_256 strLabel = String_256());
+	virtual ~CBGDDCachedItem();
 
+	virtual void DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const;
+
+protected:
+	// Get the representation of the item (of the Kernel Bitmap)
+	virtual wxBitmap* RenderItemToBitmap(wxSize szBitmap) const;
+	virtual void	  RenderItemToGRenderRegion(GRenderRegion* pRenderRegion, DocRect drcItem) const;
+
+private:
+	wxBitmap*	GetWxBitmap(wxSize szBitmap) const;
+	static BOOL DoesCacheItemSizeMatch(const pair<wxSize, wxBitmap*>* poItem, wxSize szBitmap);
+
+private:
+	typedef	std::vector<pair<wxSize, wxBitmap*>*> TDCacheCollection;
+	mutable TDCacheCollection m_colCache;
+};
+
+
+
 /*************************************************************************
 Class         : CBGDDKernelBitmapItem
-Base Class    : public CBGDDItemInfo
+Base Class    : public CBGDDCachedItem
 Author        : Mikhail Tatarnikov
 Description   : Item for displaying a KernelBitmap.
 Pure Virtual  : None
@@ -194,7 +229,7 @@
 Usage Notes   : None
 Override Notes: None
 **************************************************************************/
-class CBGDDKernelBitmapItem : public CBGDDItemInfo
+class CBGDDKernelBitmapItem : public CBGDDCachedItem
 {
 public:
 	CBGDDKernelBitmapItem(KernelBitmap* pKernelBitmap, BOOL bAutodelete = TRUE,
@@ -202,22 +237,13 @@
 						  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;
+	virtual wxBitmap* RenderItemToBitmap(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;
 };
 
 
@@ -227,7 +253,7 @@
 
 /*************************************************************************
 Class         : CBGDDStrokeItem
-Base Class    : public CBGDDItemInfo
+Base Class    : public CBGDDCachedItem
 Author        : Mikhail Tatarnikov
 Description   : Item for displaying a stroke.
 Pure Virtual  : None
@@ -235,13 +261,14 @@
 Usage Notes   : None
 Override Notes: None
 **************************************************************************/
-class CBGDDStrokeItem : public CBGDDItemInfo
+class CBGDDStrokeItem : public CBGDDCachedItem
 {
 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:
+	virtual void RenderItemToGRenderRegion(GRenderRegion* pRenderRegion, DocRect drcItem) const;
 
 protected:
 	LineAttrItem* m_plaiStroke;
@@ -250,7 +277,44 @@
 
 
 
+
+
 /*************************************************************************
+Class         : CBGDDBrushItem
+Base Class    : public CBGDDCachedItem
+Author        : Mikhail Tatarnikov
+Description   : Item for displaying a brush.
+Pure Virtual  : None
+Known Issues  : None
+Usage Notes   : None
+Override Notes: None
+**************************************************************************/
+class CBGDDBrushItem : public CBGDDCachedItem
+{
+public:
+	CBGDDBrushItem(AttrBrushType* pabtBrush, BOOL bAutodelete = TRUE, String_256 strLabel = String_256());
+	virtual ~CBGDDBrushItem();
+
+protected:
+	virtual void RenderItemToGRenderRegion(GRenderRegion* pRenderRegion, DocRect drcItem) const;
+
+protected:
+	AttrBrushType* m_pabtBrush;
+	BOOL		   m_bDelete;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+/*************************************************************************
 Class         : CBitmapGridDropDown
 Base Class    : public CGridDropDown
 Author        : Mikhail Tatarnikov
Index: Trunk/XaraLX/wxOil/bitmapgriddropdown.cpp
===================================================================
--- Trunk/XaraLX/wxOil/bitmapgriddropdown.cpp	(revision 1748)
+++ Trunk/XaraLX/wxOil/bitmapgriddropdown.cpp	(revision 1749)
@@ -177,6 +177,17 @@
 }
 
 
+/******************************************************************************
+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     : 
+******************************************************************************/
 void CBGDDWxBitmapItem::DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const
 {
 	// If the item isn't enabled just don't draw it
@@ -239,15 +250,169 @@
 
 
 
+CBGDDCachedItem::CBGDDCachedItem(String_256 strLabel)
+	: CBGDDItemInfo(strLabel)
+{
+}
 
+CBGDDCachedItem::~CBGDDCachedItem()
+{
+	TDCacheCollection::const_iterator citCur;
+	for (citCur = m_colCache.begin(); citCur != m_colCache.end(); ++citCur)
+	{
+		delete (*citCur)->second;
+		delete *citCur;
+	}
+	
+	m_colCache.clear();
+}
 
+/******************************************************************************
+Function  : CBGDDCachedItem::DoesCacheItemSizeMatch
+Author    : Mikhail Tatarnikov
+Purpose   : Checks whether a cache item corresponds to the specific size
+Returns   : BOOL -
+Exceptions: 
+Parameters: [in] const pair<wxSize, xBitmap*>* poItem - 
+            [in] wxSize szBitmap - 
+Notes     : 
+******************************************************************************/
+BOOL CBGDDCachedItem::DoesCacheItemSizeMatch(const pair<wxSize, wxBitmap*>* poItem, wxSize szBitmap)
+{
+	return poItem->first == szBitmap;
+}
 
 
+/******************************************************************************
+Function  : CBGDDCachedItem::GetWxBitmap
+Author    : Mikhail Tatarnikov
+Purpose   : Retrieves a representation from the cache
+Returns   : wxBitmap* - the representation with the required size.
+Exceptions: 
+Parameters: [in] wxSize szBitmap - cached image size to look for.
+Notes     : Creates a new representation if it doesn't exist.
+******************************************************************************/
+wxBitmap* CBGDDCachedItem::GetWxBitmap(wxSize szBitmap) const
+{
+	// 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;
 
+	// No bitmap found in the cache. Ask the derivide class to render its content.
+	wxBitmap* pBitmap = RenderItemToBitmap(szBitmap);
+
+	// 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 CBGDDCachedItem::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);
+}
+
+
+/******************************************************************************
+Function  : CBGDDCachedItem::RenderItemToBitmap
+Author    : Mikhail Tatarnikov
+Purpose   : Renders an item to bitmap.
+Returns   : wxBitmap* - bitmap with the rendered item.
+Exceptions: 
+Parameters: [in] wxSize szBitmap - size of the required bitmap.
+Notes     : The function prepares a GRenderRegion and asks the derived class to
+			draw itself into it.
+******************************************************************************/
+wxBitmap* CBGDDCachedItem::RenderItemToBitmap(wxSize szBitmap) const
+{
+	wxMemoryDC dcMem;
+	wxBitmap* pBitmap = new wxBitmap(szBitmap.x, szBitmap.y);
+	dcMem.SelectObject(*pBitmap);
+
+
+	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);
+
+	// Convert the item area to millipoints
+	DocRect drcDocClip;
+	drcDocClip.lo.x = 0;
+	drcDocClip.lo.y = 0;
+
+	drcDocClip.hi.x = (szBitmap.x * 1000);
+	drcDocClip.hi.y = (szBitmap.y * 1000);
+
+
+	// Create a bitmap render region.
+	GRenderBitmap* pRenderRegion = new GRenderBitmap(drcDocClip, oMatrix, Scale, 24, iDPI, FALSE, 0, NULL, TRUE);
+	pRenderRegion->AttachDevice(pDialogView, &dcMem, NULL, false);
+	
+	// Prepare for the rendering.
+	pRenderRegion->InitDevice();
+	pRenderRegion->SaveContext();
+	pRenderRegion->StartRender();
+
+
+	// Ask the derived class to render itself into GRenderRegion.
+	RenderItemToGRenderRegion(pRenderRegion, drcDocClip);
+
+	// Finalize the rendering.
+	pRenderRegion->StopRender();
+	pRenderRegion->RestoreContext();
+
+	// Extract bitmap from the render region. 
+	KernelBitmap* pKernelBitmap = new KernelBitmap(pRenderRegion->ExtractBitmap(), FALSE);
+
+	BitmapDragInformation oDragBitmap(pKernelBitmap, szBitmap.x, szBitmap.y, 0, 0);
+	oDragBitmap.OnDrawSolidDrag(wxPoint(0, 0), &dcMem);
+
+	// Free resourced and return the resulting bitmap.
+	delete pKernelBitmap;
+	delete pRenderRegion;
+	delete pDialogView;
+
+	dcMem.SelectObject(wxNullBitmap);
+
+	return pBitmap;
+}
+
+
+/******************************************************************************
+Function  : CBGDDCachedItem::RenderItemToGRenderRegion
+Author    : Mikhail Tatarnikov
+Purpose   : Renders the item into GRenderRegion.
+Returns   : void
+Exceptions: 
+Parameters: [in] GRenderRegion* pRenderRegion - Render region to draw to;
+            [in] DocRect		drcItem		  - item size.
+Notes     : The derived classes should override this function if they don't
+			override RenderItemToBitmap.
+******************************************************************************/
+void CBGDDCachedItem::RenderItemToGRenderRegion(GRenderRegion* pRenderRegion, DocRect drcItem) const
+{
+	ASSERT(FALSE);	// The derived classes should override this method
+					// Or the parent RenderItemToBitmap method.
+}
+
+
+
+
+
+
 CBGDDKernelBitmapItem::CBGDDKernelBitmapItem(KernelBitmap* pKernelBitmap, BOOL bAutodelete,
 											 String_256 strLabel, BOOL bStretch)
-	: CBGDDItemInfo(strLabel)
+	: CBGDDCachedItem(strLabel)
 {
 	m_pKernelBitmap		  = pKernelBitmap;
 	m_bDeleteKernelBitmap = bAutodelete;
@@ -258,22 +423,9 @@
 {
 	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  : CBGDDKernelBitmapItem::GetWxBitmap
@@ -286,16 +438,8 @@
 			we have to speed up the drawing (and scaling). It's done by caching
 			the bitmap representations.
 ******************************************************************************/
-wxBitmap* CBGDDKernelBitmapItem::GetWxBitmap(wxSize szBitmap) const
+wxBitmap* CBGDDKernelBitmapItem::RenderItemToBitmap(wxSize szBitmap) const
 {
-	// 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);
@@ -311,29 +455,18 @@
 
 	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);
-}
 
 
 
 
 
-
-
 CBGDDStrokeItem::CBGDDStrokeItem(LineAttrItem* plaiStroke, BOOL bAutodelete, String_256 strLabel)
-	: CBGDDItemInfo(strLabel)
+	: CBGDDCachedItem(strLabel)
 {
 	m_plaiStroke = plaiStroke;
 	m_bDelete	 = bAutodelete;
@@ -345,52 +478,83 @@
 		delete m_plaiStroke;
 }
 
-void CBGDDStrokeItem::DrawItem(wxDC& dc, const wxRect& rect, INT32 iFlags) const
+
+/******************************************************************************
+Function  : CBGDDStrokeItem::RenderItemToGRenderRegion
+Author    : Mikhail Tatarnikov
+Purpose   : Renders the stroke into GRenderRegion.
+Returns   : void
+Exceptions: 
+Parameters: [in] GRenderRegion* pRenderRegion - Render region to draw to;
+            [in] DocRect		drcItem		  - item size.
+Notes     : 
+******************************************************************************/
+void CBGDDStrokeItem::RenderItemToGRenderRegion(GRenderRegion* pRenderRegion, DocRect drcItem) const
 {
-	INT32 iDPI = 96;
+	// Render the stroke.
+	m_plaiStroke->Render(pRenderRegion, drcItem, LineAttrItem::NO_LABEL);
+}
 
-	// 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);
+CBGDDBrushItem::CBGDDBrushItem(AttrBrushType* pabtBrush, BOOL bAutodelete, String_256 strLabel)
+	: CBGDDCachedItem(strLabel)
+{
+	m_pabtBrush  = pabtBrush;
+	m_bDelete	 = bAutodelete;
+}
 
+CBGDDBrushItem::~CBGDDBrushItem()
+{
+	if (m_bDelete)
+		delete m_pabtBrush;
+}
 
-	// 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);
+/******************************************************************************
+Function  : CBGDDBrushItem::RenderItemToGRenderRegion
+Author    : Mikhail Tatarnikov
+Purpose   : Renders the brush into GRenderRegion.
+Returns   : void
+Exceptions: 
+Parameters: [in] GRenderRegion* pRenderRegion - Render region to draw to;
+            [in] DocRect		drcItem		  - item size.
+Notes     : 
+******************************************************************************/
+void CBGDDBrushItem::RenderItemToGRenderRegion(GRenderRegion* pRenderRegion, DocRect drcItem) const
+{
+	Path  pthBrush;
 
-	pRenderRegion->StopRender();
-	pRenderRegion->RestoreContext();
+	pthBrush.Initialise(8);
+	pthBrush.IsFilled  =  FALSE;
+	pthBrush.IsStroked = TRUE;
+	pthBrush.FindStartOfPath();
 
-	KernelBitmap* pKernelBitmap = new KernelBitmap(pRenderRegion->ExtractBitmap(), FALSE);
+	// avoid overhead of allocation each time ....
+	INT32 iWidth	  = drcItem.Width();
+	INT32 iHeight	  = drcItem.Height();
+	INT32 iBorderX	  = (INT32)(0.025 * iWidth);
+//	INT32 iBorderY	  = (INT32)(0.025 * iHeight);
+//	INT32 iHalfWidth  = iWidth  / 2;
+	INT32 iHalfHeight = iHeight / 2;
 
-	BitmapDragInformation oDragBitmap(pKernelBitmap, szItem.x, szItem.y, 0, 0);
-	oDragBitmap.OnDrawSolidDrag(rect.GetTopLeft(), &dc);
+	DocCoord dcrdStartPoint(iBorderX, iHalfHeight);
+	DocCoord dcrdEndPoint(iWidth - iBorderX, iHalfHeight);
 
-	delete pKernelBitmap;
-	delete pRenderRegion;
-	delete pDialogView;
+	pthBrush.InsertMoveTo(dcrdStartPoint);
+	pthBrush.InsertLineTo(dcrdEndPoint);
 
+
+	pRenderRegion->SetLineWidth(iHeight / 3);
+
+	PathProcessorBrush* pPathProc = m_pabtBrush->GetPathProcessor();
+	pPathProc->ScaleToValue(1);
+	pRenderRegion->SetLineColour(COLOUR_BLACK);
+
+	m_pabtBrush->Render(pRenderRegion);
+	pRenderRegion->DrawPath (&pthBrush);
 }
 
 
@@ -504,8 +668,8 @@
 ******************************************************************************/
 void CBitmapGridDropDown::AddItem(AttrBrushType* pabtBrush, BOOL bDelete, String_256 strLabel)
 {
-	wxBitmap* pBitmap = PreviewBrush(pabtBrush);
-	AddItem(pBitmap, bDelete, strLabel);
+	CBGDDBrushItem* pBrushItem = new CBGDDBrushItem(pabtBrush, bDelete, strLabel);
+	CGridDropDown::AddItem(pBrushItem);
 }
 
 
@@ -557,7 +721,8 @@
 {
 	CBGDDItemInfo* pItemData = GetItemData(iItem);
 
-	pItemData->DrawItem(dc, rect, iFlags);
+	if (pItemData)
+		pItemData->DrawItem(dc, rect, iFlags);
 }
 
 
@@ -610,142 +775,8 @@
 
 
 
-/******************************************************************************
-Function  : CBitmapGridDropDown::PreviewBrush
-Author    : Mikhail Tatarnikov
-Purpose   : Preview a brush into a bitmap
-Returns   : wxBitmap* - the brush preview
-Exceptions: 
-Parameters: [in] AttrBrushType* pabtBrush - brush to preview.
-Notes     : 
-******************************************************************************/
-wxBitmap* CBitmapGridDropDown::PreviewBrush(AttrBrushType* pabtBrush)
-{
-//	ERROR2IF(TRUE, FALSE, "CBitmapGridDropDown::PreviewBrush Not implemented yet");
 
-	wxMemoryDC dcMem;
 
-	// Setup a memory DC to draw into a bitmap.
-	wxSize szItem =  GetItemSize();
-	wxBitmap* pBitmap = new wxBitmap(szItem.x, szItem.y);
-
-
-	dcMem.SelectObject(*pBitmap);
-
-	// For now, clear the bitmap and return
-	dcMem.Clear();
-	return pBitmap;
-
-
-	// THIS CODE HAS A FUNDAMENTAL PROBLEM IN THAT IT TRIES TO USE THE COORDINATES IN 1:1 PIXELS
-	// THIS WON'T WORK IN THAT THEY ARE TOO LOW RESOLUTION - THEY NEED TO BE CONVERTED TO 96DPI
-	// COORDINATES (OR MORE ACCURATELY WHAT OSRenderRegion::GetFixedDCDPI RETURNS) - THAT IS
-	// WHAT IT USED TO DO WITH THE EXTAINFO STUFF - AMB
-
-//	ReDrawInfoType ExtraInfo;
-//	ExtraInfo.pMousePos = NULL;		// No mouse position info for redraw events
-
-	// Build a CC dc out of it for rendering to the screen
-	// Get a MFC CDC to put the DC in
-	CCDC MyDc(&dcMem);
-
-	// The devices DPI
-//	ExtraInfo.Dpi = OSRenderRegion::GetFixedDCPPI(MyDc).GetHeight();
-
-	// How big the window is
-//	ExtraInfo.dx = (((INT32)szItem.GetWidth())*72000) / ExtraInfo.Dpi;
-//	ExtraInfo.dy = (((INT32)szItem.GetHeight())*72000) / ExtraInfo.Dpi;
-
-	// Alternatively we can do this:
-	wxRect ClipRect(wxPoint(0, 0), szItem);
-
-
-
-	// paths should not be made static (for safety) ....
-	Path  CurvePath;
-
-	CurvePath.Initialise(8);
-	CurvePath.IsFilled  =  FALSE;
-	CurvePath.IsStroked = TRUE;
-	CurvePath.FindStartOfPath();
-
-	// avoid overhead of allocation each time ....
-	INT32 iWidth	  = szItem.x;
-	INT32 iHeight	  = szItem.y;
-	INT32 iBorderX	  = (INT32)(0.05 * iWidth);
-	INT32 iBorderY	  = (INT32)(0.05 * iHeight);
-	INT32 iHalfWidth  = szItem.x / 2;
-	INT32 iHalfHeight = szItem.y / 2;
-
-	DocCoord StartPoint2	(iBorderX, iBorderY);
-	DocCoord MiddleCP1		(iBorderX, iHalfHeight);
-	DocCoord MiddlePoint	(iHalfWidth, iHalfHeight);
-	DocCoord MiddleCP2		(iWidth-iBorderX, iHalfHeight);
-	DocCoord EndPoint2		(iWidth-iBorderX, iHeight-iBorderY);
-
-	CurvePath.InsertMoveTo	(StartPoint2);
-	CurvePath.InsertCurveTo	(StartPoint2, MiddleCP1, MiddlePoint);
-	CurvePath.InsertCurveTo	(MiddlePoint, MiddleCP2, EndPoint2);
-	CurvePath.InsertLineTo	(EndPoint2);
-
-	// render a curved line ....
-	DocRect RenderRect(0, 0, iWidth, iHeight);
-
-	DialogView *pDialogView = new DialogView;
-	pDialogView->Init();
-	FIXED16 Scale(1);
-
-	Matrix oMatrix(0, 0);
-
-
-	GRenderRegion* pRenderRegion = new GRenderDIB(RenderRect, oMatrix, Scale, 32, 96.0);
-
-	static const StockColour  kBackgroundOutline  =  COLOUR_NONE;
-	static const StockColour  kBackground         =  COLOUR_WHITE;
-	
-
-	PathProcessorBrush* pPathProc = pabtBrush->GetPathProcessor();
-	BrushAttrValue* pVal = (BrushAttrValue*)pabtBrush->GetAttributeValue();
-
-	if (pRenderRegion != 0 && pRenderRegion->AttachDevice(pDialogView, &dcMem, NULL) && pRenderRegion->StartRender())
-	{
-
-		pRenderRegion->SaveContext();
-
-		// set drawing quality
-		Quality           QualityThing( Quality::QualityMax );
-		QualityAttribute  AntiAliasQualityAttr( QualityThing );
-		pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
-
-		pRenderRegion->SetFillColour( kBackground );
-		pRenderRegion->DrawRect( &RenderRect );
-
-		pRenderRegion->SetLineWidth (1);
-		pPathProc->ScaleToValue(1);
-		pRenderRegion->SetLineColour( kBackgroundOutline );
-
-		pVal->FlushCache  ();
-		pabtBrush->Render(pRenderRegion);
-		pRenderRegion->DrawPath (&CurvePath);
-
-		pRenderRegion->RestoreContext();
-//		DestroyGRenderRegion( pRenderRegion );
-		pRenderRegion->StopRender();
-		delete pRenderRegion;
-	}
-		
-	delete pDialogView;
-
-
-	MyDc.GetDC()->EndDrawing();		
-
-	dcMem.SelectObject(wxNullBitmap);
-
-	return pBitmap;
-}
-
-
-
 /******************************************************************************
 Function  : CBitmapGridDropDown::PreviewStroke
 Author    : Mikhail Tatarnikov


Xara