Exemplo n.º 1
0
KernelBitmap* SGNameDrag::MakeImage(UINT32 nDepth)
{
	// If there's no current View, or no Spread, then fail.
	DocView* pView = DocView::GetCurrent();
	if (pView == 0) return 0;
	Spread* pSpread = pView->FindEnclosingSpread(OilCoord(0, 0));
	if (pSpread == 0) return 0;

	// Create a device context for the display.
	CDC sdc;
	sdc.CreateDC("DISPLAY", 0, 0, 0); 

	// Calculate the size of the rendering and set up the rendering matrix etc.
	Matrix matConvert;
	FIXED16 fxScale = 1;
	INT32 nSel = NameGallery::Instance()->GetSelectedItemCount();
	DocRect drClip(0, 0, SG_DefaultNameText, nSel * SG_DefaultSmallIcon);

	// Work out the destination bitmap's characteristics.
	double dpi = (double) GetDeviceCaps(sdc.m_hDC, LOGPIXELSX);
	if (nDepth == 0)
			nDepth = GetDeviceCaps(sdc.m_hDC, BITSPIXEL) * GetDeviceCaps(sdc.m_hDC, PLANES);

	// Create a render region with the given properties of the display etc.
	GRenderBitmap* pRenderer = new GRenderBitmap(drClip, matConvert, fxScale, nDepth, dpi);
	ERRORIF(pRenderer == 0, _R(IDE_NOMORE_MEMORY), 0);
	pRenderer->AttachDevice(pView, &sdc, pSpread);
	pRenderer->StartRender();
	pRenderer->SaveContext();

	// Blank the background.
	pRenderer->SetLineWidth(0);
	pRenderer->SetLineColour(COLOUR_WHITE);
	pRenderer->SetFillColour(COLOUR_WHITE);
	pRenderer->DrawRect(&drClip);

	// Render the item's name.
	DocColour dcText(COLOUR_BLACK), dcBack(COLOUR_WHITE);
	pRenderer->SetFixedSystemTextColours(&dcText, &dcBack);

	String_256 strName;
	m_pSourceItem->GetNameText(&strName);
	pRenderer->DrawFixedSystemText(&strName, drClip);

	// Create a kernel bitmap from the OIL bitmap and return it.
	pRenderer->RestoreContext();
	pRenderer->StopRender();
	OILBitmap* pOilMaskBmp = pRenderer->ExtractBitmap();
	delete pRenderer;

	KernelBitmap* pkb = new KernelBitmap(pOilMaskBmp, TRUE);
	ERRORIF(pkb == 0, _R(IDE_NOMORE_MEMORY), 0);
	return pkb;
}
Exemplo n.º 2
0
KernelBitmap* GalleryLineDragInfo::GetSolidDragMask()
{
	// Note we abuse this call (like our base class abuses this call) to create the bitmap
	// itself. We don't use DragMask itself anymore (i.e. it stays NULL)
	if (!DragMask && !TheBitmap)
	{
		DocView *View = DocView::GetCurrent();
		if (View == NULL)
		{
			return NULL;
		}
		
		Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
		if (pSpread == NULL)
		{
			return NULL;
		}

		// Find the size of the rendered item.
		DocRect ClipRegion(0,0, 750*100, 750*50);
//		ClipRegion.lo.x = ClipRegion.lo.y = 0;
//		SourceItem->GetSize(c_eLineAttrDragTextPos, &ClipRegion.hi.x, &ClipRegion.hi.y);
		Matrix ConvertMatrix;
		FIXED16 ViewScale = 1;

		wxScreenDC DisplayDC;
		double dpi = (double) OSRenderRegion::GetFixedDCPPI(DisplayDC).GetWidth();

		GRenderBitmap* pMaskRegion 	= new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale, 
														32, dpi);

		pMaskRegion->SetDoCompression(TRUE); // misnamed call to indicate we want transparency
		pMaskRegion->AttachDevice(View, &DisplayDC, pSpread);

		// Make a Mask Bitmap
		pMaskRegion->StartRender();
	  	SourceItem->Render(pMaskRegion, ClipRegion, c_eLineAttrDragTextPos);
		pMaskRegion->StopRender();

		OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
		TheBitmap = new KernelBitmap(pOilMaskBmp, TRUE);	

		delete pMaskRegion;
	}

	return BitmapDragInformation::GetSolidDragMask();
}
Exemplo n.º 3
0
OilCoord WinCoord::ToOil(View *pView, BOOL PixelCentre) const
{
	// Note that we have to negate the y coord, because Windows starts with 0 at the top
	// and then positive coordinates in a downward direction, i.e. the opposite to
	// Camelot's coordinate systems.
	// NB. More importantly, we add 1 to the y coord, because the flipping of the y axis
	//     causes a misalignment in the pixel systems.  This is because Camelot coords
	//	   specify the bottom left of the pixel, whereas GDI coords specify the top-left.
	//	   (See coord.doc for more details)
//	return OilCoord(LongMulFixed16(x, OilCoord::PixelWidth()),
//				   -LongMulFixed16(y + 1, OilCoord::PixelHeight()));

	// New info: (Phil, 17/11/94)
	// The one pixel bodge is no longer required because the pixel model has been modified
	// so that pixel coordinates are in the centres of pixels, not on any edge.
	// This allows coordinate systems to be negated without any extra work.
//	return OilCoord(LongMulFixed16(x, OilCoord::PixelWidth()),
//				   -LongMulFixed16(y, OilCoord::PixelHeight()));
	
	FIXED16 PixelWidth, PixelHeight;
	pView->GetPixelSize(&PixelWidth, &PixelHeight);
	OilCoord temp = OilCoord(LongMulFixed16(x, PixelWidth),
				   			-LongMulFixed16(y, PixelHeight)
				   			);
	if (PixelCentre)
	{
		// Coordinate is a click coord which is different than normal rectangle coords
		// Rectangle coords need to specify the joints between pixels
		// Click coords need to specify pixel centres
		// So shift this coord to the centre of the pixel above and to the right of the
		// joint specified by the raw OilCoord.
		// The amount added is just less than half a pixel so that GDraw's anti-aliasing
		// will draw thin lines predictably.
		temp.x += (PixelWidth.MakeLong()*15)/32;
		temp.y -= (PixelHeight.MakeLong()*15)/32;
	}

	return temp;
}