BitmapDragInformation Class Reference

Contains info that a Bitmapdrag may find useful. More...

#include <dragbmp.h>

Inheritance diagram for BitmapDragInformation:

DragInformation CCObject SimpleCCObject GalleryBitmapDragInfo GalleryClipartDragInfo GalleryFillsDragInfo GalleryFontsDragInfo GalleryLibFontsDragInfo GalleryLineDragInfo GalleryNameDragInfo SGNameDrag List of all members.

Public Member Functions

 BitmapDragInformation ()
 Conmstructor - do not call this default constructor.
 BitmapDragInformation (KernelBitmap *Bitmap, INT32 xSize, INT32 ySize, INT32 xOffset, INT32 yOffset, BOOL IsAdjust=FALSE)
 Constructor.
 ~BitmapDragInformation ()
 Destructor.
BOOL StartGalleryItemDrag (SGDisplayItem *)
void OnClick (INT32 Flags, POINT Point)
 This is called if a drag was attempted but never started because it was a click all along. In the base class, the default action is to make the Bitmap bar think that the dragged Bitmap has been clicked.
virtual UINT32 GetCursorID (void)
 Determines what cursor to display during a Bitmap drag.
virtual BOOL GetStatusLineText (String_256 *TheText)
 provide status line text for this drag
virtual BOOL OnDrawSolidDrag (wxPoint Origin, wxDC *TheDC)
 allows the drag to draw into a Device Context - DragManager will look after painting the background etc.
virtual UINT32 GetCursorID (DragTarget *pDragTarget)
 Determines what cursor to display during a Bitmap drag.
virtual BOOL GetStatusLineText (String_256 *TheText, DragTarget *pDragTarget)
 provide status line text for this drag
virtual BOOL OnDrawSolidDrag (wxPoint Origin, wxDC *TheDC, DragTarget *pDragTarget)
 allows the drag to draw into a Device Context - DragManager will look after painting the background etc.
virtual BOOL HasTransparentMask ()
virtual wxBitmap * GetTransparentMask ()
virtual KernelBitmapGetSolidDragMask ()
 Get a 1 bpp mask to use for the solid drag.
KernelBitmapGetTheBitmap (void)
void ApplyBitmapToSelection (void)
 Applies the dragged Bitmap to the current selection.
virtual INT32 GetDragTransparency ()
 Specifies how transparent a drag should be. A value of 0, will cause a normal solid blit. Any other value (between 0 and 100), will cause a masked blit.

Static Public Member Functions

static BOOL Init ()
 Initialise any Bitmap Drag stuff. (eg. ini file preferences).

Protected Member Functions

BOOL PlotBitmap (CWxBitmap *WinBM, wxPoint Origin, wxSize Size, wxDC *RenderDC)
 Plots the specified Bitmap into the DC, during a solid drag.

Protected Attributes

KernelBitmapTheBitmap
KernelBitmapDragMask
wxSize DragRect
LPBITMAPINFO TempInfo
LPBYTE TempBits
UINT32 DIBPal
wxDC * MemDC
wxBitmap * Bitmap
wxBitmap * OldBmp
wxBitmap * MaskBitmap

Static Protected Attributes

static INT32 DragTransparency = 50

Detailed Description

Contains info that a Bitmapdrag may find useful.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/05/94

Definition at line 123 of file dragbmp.h.


Constructor & Destructor Documentation

BitmapDragInformation::BitmapDragInformation  ) 
 

Conmstructor - do not call this default constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95

Definition at line 151 of file dragbmp.cpp.

00152 {
00153 //  ERROR3("Default BitmapDragInformation constructor called"); 
00154 }

BitmapDragInformation::BitmapDragInformation KernelBitmap DragBitmap,
INT32  xSize,
INT32  ySize,
INT32  xOffset,
INT32  yOffset,
BOOL  IsAdjust = FALSE
 

Constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
Bitmap - The KernelBitmap being dragged [INPUTS] xSize - The Width (in Pixels) of the Drag Rectangle. ySize - The Height (in Pixels) of the Drag Rectangle. xOffset - The offset (in Pixels) from the mouse to the top of the bitmap. yOffset - The offset (in Pixels) from the mouse to the left edge of the bitmap. IsAdjust - TRUE if this is an adjust-drag

Definition at line 181 of file dragbmp.cpp.

00187     :DragInformation(IsAdjust)
00188 {
00189     // The Kernel Bitmap we are dragging
00190     TheBitmap = DragBitmap;
00191 
00192     TempInfo = NULL;
00193     TempBits = NULL;
00194 
00195     MemDC = NULL;
00196     Bitmap = NULL;
00197     DragMask = NULL;
00198     MaskBitmap = NULL;
00199 
00200     // Set up a few things about this drag
00201     DoesSolidDrag = TRUE;
00202     
00203     // offset of Bitmap swatch from the pointer
00204     SolidDragOffset.x = 0;
00205     SolidDragOffset.y = 16;    
00206     
00207     BitmapInfo Info;
00208 
00209     INT32 BitmapWidth  = (TheBitmap != NULL) ? CellSize : NullSize;
00210     INT32 BitmapHeight = (TheBitmap != NULL) ? CellSize : NullSize;
00211 
00212     // The aspect ratio of the bitmap
00213     double Ratio = 1.0;
00214 
00215     if (ySize == 0 && 
00216         TheBitmap != NULL &&
00217         TheBitmap->ActualBitmap != NULL &&
00218         TheBitmap->ActualBitmap->GetInfo( &Info ))
00219     {
00220         BitmapWidth  = Info.PixelWidth;
00221         BitmapHeight = Info.PixelHeight;
00222 
00223         // Calculate the aspect ratio of the bitmap
00224         Ratio = double(Info.RecommendedWidth)/double(Info.RecommendedHeight);
00225     }
00226 
00227     // If the user supplied the sizes, keep their aspect    
00228     if(xSize > 0 && ySize > 0)
00229         Ratio = double(xSize) / double(ySize);
00230 
00231     // size of the solid drag redraw
00232     SolidDragSize.x = (xSize > 0) ? xSize : BitmapWidth;
00233     SolidDragSize.y = (ySize > 0) ? ySize : BitmapHeight;
00234 
00235     if (xSize > 0 && ySize == 0)
00236         SolidDragSize.y = INT32(SolidDragSize.x / Ratio);
00237 
00238     if (SolidDragSize.x > CellSize)
00239     {
00240         SolidDragSize.x = CellSize;
00241         SolidDragSize.y = INT32(SolidDragSize.x / Ratio);
00242     }
00243 
00244     if (SolidDragSize.y > CellSize)
00245     {
00246         SolidDragSize.y = CellSize;
00247         SolidDragSize.x = INT32(SolidDragSize.y * Ratio);
00248     }
00249 
00250     // Offset relative to bitmap centre
00251     SolidDragOffset.x += (xOffset - SolidDragSize.x/2);
00252     SolidDragOffset.y += (yOffset - SolidDragSize.y/2);    
00253 
00254     DragRect.x = SolidDragSize.x;
00255     DragRect.y = SolidDragSize.y;
00256 }

BitmapDragInformation::~BitmapDragInformation  ) 
 

Destructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95

Definition at line 269 of file dragbmp.cpp.

00270 {
00271     if (Bitmap)
00272     {
00273 //      Bitmap->DeleteObject();
00274         delete Bitmap;
00275     }
00276 
00277     if (MaskBitmap)
00278     {
00279         delete MaskBitmap;
00280     }
00281 
00282     if (DragMask)
00283     {
00284 //      DragMask->ActualBitmap->IsTemp = TRUE;
00285 //      DragMask->ActualBitmap->Detach();
00286         delete DragMask;
00287     }
00288 }


Member Function Documentation

void BitmapDragInformation::ApplyBitmapToSelection void   ) 
 

Applies the dragged Bitmap to the current selection.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Returns:
Apply current drag Bitmap to selection - set current fill/stroke attributes

Definition at line 301 of file dragbmp.cpp.

00302 {
00303 }

UINT32 BitmapDragInformation::GetCursorID DragTarget pDragTarget  )  [virtual]
 

Determines what cursor to display during a Bitmap drag.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Returns:
a cursor ID to set during this drag

Reimplemented from DragInformation.

Reimplemented in SGNameDrag, GalleryBitmapDragInfo, GalleryClipartDragInfo, GalleryFillsDragInfo, GalleryNameDragInfo, GalleryFontsDragInfo, GalleryLibFontsDragInfo, and GalleryLineDragInfo.

Definition at line 360 of file dragbmp.cpp.

00361 {
00362     return 0;
00363 }

UINT32 BitmapDragInformation::GetCursorID void   )  [virtual]
 

Determines what cursor to display during a Bitmap drag.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Returns:
a cursor ID to set during this drag

Reimplemented from DragInformation.

Definition at line 318 of file dragbmp.cpp.

00319 {
00320     return GetCursorID(NULL);
00321 }

INT32 BitmapDragInformation::GetDragTransparency  )  [virtual]
 

Specifies how transparent a drag should be. A value of 0, will cause a normal solid blit. Any other value (between 0 and 100), will cause a masked blit.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Returns:
-
See also:
-

Reimplemented from DragInformation.

Reimplemented in SGNameDrag, GalleryNameDragInfo, GalleryFontsDragInfo, GalleryLibFontsDragInfo, and GalleryLineDragInfo.

Definition at line 906 of file dragbmp.cpp.

00907 {
00908     return BitmapDragInformation::DragTransparency;
00909 }

KernelBitmap * BitmapDragInformation::GetSolidDragMask  )  [virtual]
 

Get a 1 bpp mask to use for the solid drag.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Returns:
-
See also:
-
We (ab)use this call to ensure an initial plot is done, which in turn sets up the mask, which has to be done before the first plot (on setup)

Reimplemented from DragInformation.

Reimplemented in SGNameDrag, GalleryNameDragInfo, GalleryFontsDragInfo, GalleryLibFontsDragInfo, and GalleryLineDragInfo.

Definition at line 879 of file dragbmp.cpp.

00880 {
00881     if (TheBitmap != NULL && TheBitmap->ActualBitmap != NULL)
00882     {   
00883         wxBitmap bitmap(1,1);
00884         wxMemoryDC DC;
00885         DC.SelectObject(bitmap);
00886         PlotBitmap((CWxBitmap*)TheBitmap->ActualBitmap, wxPoint(0,0), DragRect, &DC);
00887     }
00888     
00889     return DragMask;
00890 }

BOOL BitmapDragInformation::GetStatusLineText String_256 TheText,
DragTarget pDragTarget
[virtual]
 

provide status line text for this drag

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Parameters:
TheText - If it returns TRUE, this is filled in with status line text [OUTPUTS]
Returns:
Whether String is valid

Reimplemented from DragInformation.

Reimplemented in SGNameDrag, GalleryBitmapDragInfo, GalleryClipartDragInfo, GalleryFillsDragInfo, GalleryNameDragInfo, GalleryFontsDragInfo, GalleryLibFontsDragInfo, and GalleryLineDragInfo.

Definition at line 379 of file dragbmp.cpp.

00380 {
00381     if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00382         return FALSE;
00383 
00384     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00385 
00386     return FALSE;
00387 }

BOOL BitmapDragInformation::GetStatusLineText String_256 TheText  )  [virtual]
 

provide status line text for this drag

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Parameters:
TheText - If it returns TRUE, this is filled in with status line text [OUTPUTS]
Returns:
Whether String is valid

Reimplemented from DragInformation.

Definition at line 339 of file dragbmp.cpp.

00340 {
00341     if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00342         return FALSE;
00343 
00344     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00345 
00346     return GetStatusLineText(TheText, NULL);
00347 }

KernelBitmap* BitmapDragInformation::GetTheBitmap void   )  [inline]
 

Definition at line 155 of file dragbmp.h.

00155 { return TheBitmap; }

virtual wxBitmap* BitmapDragInformation::GetTransparentMask  )  [inline, virtual]
 

Reimplemented from DragInformation.

Definition at line 151 of file dragbmp.h.

00151 { return (MaskBitmap); }

virtual BOOL BitmapDragInformation::HasTransparentMask  )  [inline, virtual]
 

Reimplemented from DragInformation.

Definition at line 150 of file dragbmp.h.

00150 { return (MaskBitmap != NULL); }

BOOL BitmapDragInformation::Init void   )  [static]
 

Initialise any Bitmap Drag stuff. (eg. ini file preferences).

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Returns:
-
See also:
-

Reimplemented from SimpleCCObject.

Definition at line 923 of file dragbmp.cpp.

00924 {
00925     // Setup preference for drag transparency
00926     if (GetApplication()->DeclareSection(_T("Dragging"), 1))
00927     {
00928         GetApplication()->DeclarePref( NULL, _T("BitmapDragTransparency"), 
00929                                 &DragTransparency, 0, 100);
00930     }
00931 
00932     return TRUE;
00933 }

void BitmapDragInformation::OnClick INT32  Flags,
POINT  Point
 

This is called if a drag was attempted but never started because it was a click all along. In the base class, the default action is to make the Bitmap bar think that the dragged Bitmap has been clicked.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
[INPUTS] 
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented in SGNameDrag, GalleryBitmapDragInfo, GalleryClipartDragInfo, GalleryFillsDragInfo, GalleryNameDragInfo, GalleryFontsDragInfo, GalleryLibFontsDragInfo, and GalleryLineDragInfo.

Definition at line 409 of file dragbmp.cpp.

00410 {
00411     if(KeyPress::IsAdjustPressed())
00412         Flags = -1;
00413 }

BOOL BitmapDragInformation::OnDrawSolidDrag wxPoint  Origin,
wxDC *  TheDC,
DragTarget pDragTarget
[virtual]
 

allows the drag to draw into a Device Context - DragManager will look after painting the background etc.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
TheDC - pointer to a DC ready to draw into. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from DragInformation.

Definition at line 483 of file dragbmp.cpp.

00484 {
00485     return OnDrawSolidDrag(Origin, TheDC);
00486 }

BOOL BitmapDragInformation::OnDrawSolidDrag wxPoint  Origin,
wxDC *  TheDC
[virtual]
 

allows the drag to draw into a Device Context - DragManager will look after painting the background etc.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
TheDC - pointer to a DC ready to draw into. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from DragInformation.

Reimplemented in SGNameDrag.

Definition at line 504 of file dragbmp.cpp.

00505 {
00506 //  CPalette * OldPal = NULL;
00507 
00508 //  if (PaletteManager::UsePalette())
00509 //  {
00510 //      OldPal = PaletteManager::StartPaintPalette( TheDC);
00511 //  }
00512 
00513     if (TheBitmap != NULL && TheBitmap->ActualBitmap != NULL)
00514     {   
00515         PlotBitmap((CWxBitmap*)TheBitmap->ActualBitmap, Origin, DragRect, TheDC);
00516     }
00517     else
00518     {
00519         // get a gbrush brush
00520         GBrush GDrawBrush;
00521         GDrawBrush.Init(TheDC);
00522         GDrawBrush.Start();
00523 
00524         DWORD ScreenWord = 0x007F7F7F;
00525 
00526         wxBrush *pDragBrush = NULL;
00527 
00528         pDragBrush = new wxBrush;
00529     
00530         BOOL BrushCreate = TRUE;
00531 
00532         if (pDragBrush != NULL )
00533         {
00534             // create the Brush and Pen
00535             if (GDrawBrush.Available())
00536             {
00537                 GDrawBrush.GetLogBrush((COLORREF)(ScreenWord), pDragBrush);
00538             }
00539             else
00540                 *pDragBrush=wxBrush(wxColour(0x7F,0x7F,0x7F));
00541             
00542             wxPen MyPen(*wxBLACK);
00543         
00544             //the rectangle to draw into
00545             wxRect DrawRect;
00546 
00547             if(DragRect.GetWidth() == 0 || DragRect.GetHeight() == 0)
00548                 DrawRect = wxRect(Origin.x,Origin.y, NullSize, NullSize);
00549             else
00550                 DrawRect = wxRect(Origin.x,Origin.y, DragRect.GetWidth(), DragRect.GetHeight());
00551 
00552             // select brushes and pens ..
00553             TheDC->SetBrush(*pDragBrush);
00554             TheDC->SetPen(MyPen);
00555 
00556             // draw an ellipse
00557             // TheDC->Ellipse(&DrawRect);
00558 
00559             // draw some text
00560             // String_256 Str("Blobby");
00561             // TheDC->TextOut(Origin.x, Origin.y, (TCHAR *)Str, Str.Length());      
00562 
00563             // draw a rectangle                     
00564             TheDC->DrawRectangle(DrawRect);
00565 
00566             TheDC->SetBrush(*wxTRANSPARENT_BRUSH);
00567             TheDC->SetPen(*wxTRANSPARENT_PEN);
00568 
00569             delete pDragBrush;
00570         }
00571         else
00572             BrushCreate = FALSE;
00573 
00574         // Finish with GBrush
00575         GDrawBrush.Stop();
00576     }
00577 
00578 //  if (OldPal)
00579 //      PaletteManager::StopPaintPalette(TheDC, OldPal);
00580     
00581     return TRUE;
00582 }

BOOL BitmapDragInformation::PlotBitmap CWxBitmap wxBM,
wxPoint  Origin,
wxSize  Size,
wxDC *  RenderDC
[protected]
 

Plots the specified Bitmap into the DC, during a solid drag.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
RenderDC - pointer to a DC ready to draw into. [INPUTS]
- [OUTPUTS]
Returns:
FALSE, if the plot failed.

Errors: -

See also:
-

Definition at line 602 of file dragbmp.cpp.

00605 {
00606     if ((wxBM == NULL) ||
00607         (wxBM->BMInfo==NULL) ||
00608         (wxBM->BMBytes==NULL)
00609        )
00610         return FALSE;
00611 
00612     wxPoint TopLeft  = Origin;
00613 
00614     wxPoint BottomLeft;
00615     BottomLeft.x = TopLeft.x;
00616     BottomLeft.y = TopLeft.y + Size.y;
00617 
00618     wxPoint BottomRight;
00619     BottomRight.x = TopLeft.x + Size.x;
00620     BottomRight.y = TopLeft.y + Size.y;
00621 
00622     INT32 DestWidth  = BottomRight.x - BottomLeft.x;
00623     INT32 DestHeight = BottomLeft.y  - TopLeft.y;
00624 
00625 // This has been commented out because the hPal is only used inside a comment
00626 // If it is needed then just use *(pPal) and let MFC sort it out...
00627 
00628     // get the HPALETTE to pass to the plot bitmap call - crucial for quality Win32s DDB plotting
00629     // uses sneaky HPALETTE operator
00630 //  HPALETTE hPal = NULL;
00631 //  if (PaletteManager::UsePalette())
00632 //      hPal = *(PaletteManager::GetPalette());
00633 
00634     wxMemoryDC MemDC;
00635 
00636     // Get the palette to use (will be NULL if palette not needed)
00637     wxPalette* pPal = PaletteManager::GetPalette();
00638 
00639     // If this is the first time, then we need to create the Cached Bitmap
00640     if (Bitmap == NULL)
00641     {
00642         Bitmap = new wxBitmap(DestWidth, DestHeight);
00643         if (Bitmap == NULL)
00644         {
00645             return FALSE;
00646         }
00647 
00648         INT32 bpp = wxBM->GetBPP();
00649 
00650         if (MaskBitmap)
00651         {
00652             delete MaskBitmap;
00653             MaskBitmap = NULL;
00654         }
00655 
00656         // For now, only do the mask bitmap where we have a 32bpp representation
00657         // as I haven't tested whether Gavin works OK with (say) a palette with
00658         // transparency in it
00659         if ((bpp==32) && TheBitmap->IsTransparent())
00660         {
00661             // If this fails, we simply treat it as non-transparent. Hey ho
00662             MaskBitmap = new wxBitmap(DestWidth, DestHeight);
00663         }
00664 
00665         MemDC.SelectObject(*Bitmap);
00666 
00667 PORTNOTE("other", "disabled palettes in dragbmp")
00668 #ifndef EXCLUDE_FROM_XARALX
00669         if (PaletteManager::UsePalette())
00670             MemDC.SelectPalette(pPal, FALSE);
00671 #endif
00672 
00673         // Since the GDI cannot cope with anything other than very simple bitmaps,
00674         // we will get GDraw to render the bitmap into a screen compatible DIB, and
00675         // then get the GDI to plot that
00676 
00677         GDrawContext* GD = GRenderRegion::GetStaticDrawContext();
00678 
00679         // Setup a default matrix (we'll do everything in pixel-speak)
00680 
00681         GMATRIX GMatrix;
00682 
00683         GMatrix.AX = 1<<(16 + FX);
00684         GMatrix.AY = 0;
00685         GMatrix.BX = 0;
00686         GMatrix.BY = 1<<(16 + FX);
00687 
00688         GMatrix.CX = 0;
00689         GMatrix.CY = 0;
00690 
00691     // Create a Tempory bitmap compatible with the output device
00692 
00693         INT32 DeviceDepth;
00694 
00695 PORTNOTE("other", "Assume 24bpp intermediate bitmap in DragBmp");
00696 #ifndef EXCLUDE_FROM_XARALX
00697         DeviceDepth = GetDeviceCaps( RenderDC->m_hDC, BITSPIXEL ) * 
00698                                         GetDeviceCaps( RenderDC->m_hDC, PLANES );
00699 #else
00700         DeviceDepth = 24;
00701 #endif
00702 
00703         if (DeviceDepth == 24)
00704             DeviceDepth = 32;   // GDraw cannot plot to 24-bit bitmaps
00705 
00706         TempInfo = AllocDIB(DestWidth, DestHeight, DeviceDepth, &TempBits);
00707         if (TempInfo==NULL)
00708         {
00709             TRACEALL( _T("Out of memory during BitmapDragInformation::PlotBitmap"));
00710             return FALSE;
00711         }
00712 
00713 #ifdef _DEBUG
00714         *((DWORD *)(void *)(TempBits))=0xDEADBEEF;
00715 #endif
00716 
00717         // We may need to get a palette for the DIB.
00718 
00719         DIBPal = DIB_RGB_COLORS;
00720 
00721         if (DeviceDepth <= 8)   // We only need a palette for 256 colours or less.
00722         {
00723             DIBPal = GRenderRegion::SetPaletteEntries( TempInfo, RenderDC );
00724         }
00725 
00726     // Setup GDraw with our Tempory Bitmap and Identity Matrix
00727 
00728         GD->SetupBitmap(TempInfo->bmiHeader.biWidth,
00729                         TempInfo->bmiHeader.biHeight,
00730                         TempInfo->bmiHeader.biBitCount, 
00731                         TempBits );
00732 
00733         GD->SetMatrix( &GMatrix );
00734 
00735         COLORREF DefaultColour = 0xFFFFFFFF;
00736 
00737         RGBQUAD TempPalette[256];
00738         RGBQUAD* Palette = wxBM->BMInfo->bmiColors;
00739     
00740         if (bpp <= 8)
00741         {
00742             INT32 NumCols;
00743             switch (bpp)
00744             {
00745                 case 1:
00746                     NumCols = 2;
00747                     break;
00748 
00749                 case 2:
00750                     NumCols = 4;
00751                     break;
00752 
00753                 case 4:
00754                     NumCols = 16;
00755                     break;
00756 
00757                 case 8:
00758                     NumCols = 256;
00759                     break;
00760 
00761                 default:
00762                     NumCols = 256;
00763                     break;
00764             }
00765 
00766             for (INT32 i=0; i<NumCols; i++)
00767             {
00768                 if (Palette[i].rgbReserved == 0xFF)
00769                 {
00770                     // We'll use a copy of the palette ...
00771                     memcpy(TempPalette, Palette, NumCols*sizeof(RGBQUAD));
00772 
00773                     // so we can force this entry to be white
00774                     TempPalette[i].rgbRed       = 0xFF;
00775                     TempPalette[i].rgbGreen     = 0xFF;
00776                     TempPalette[i].rgbBlue      = 0xFF;
00777 
00778                     Palette = TempPalette;
00779                     break;
00780                 }
00781             }
00782         }
00783 
00784     // Now set the bitmap fill
00785 
00786         POINT PGram[3];
00787         PGram[0].x = 0;             PGram[0].y = 0;
00788         PGram[1].x = DestWidth;     PGram[1].y = 0;
00789         PGram[2].x = 0;             PGram[2].y = DestHeight;
00790 
00791         GD->SetDefaultBitmapParameters();
00792         GD->SetTileSmoothingFlag(TRUE/*FALSE*/);
00793         GD->SetTileFilteringFlag(TRUE/*FALSE*/);
00794 
00795 
00796         GD->SetBitmapFill(  &(wxBM->BMInfo->bmiHeader),
00797                             wxBM->BMBytes,
00798                             1,
00799                             PGram,
00800                             DefaultColour,
00801                             Palette,
00802                             NULL, NULL, NULL,
00803                             NULL,
00804                             0
00805                             );
00806 
00807     // Now plot a filled rectangle
00808 
00809         RECT BmpRect;
00810         BmpRect.left    =  0;
00811         BmpRect.top     =  DestHeight;
00812         BmpRect.right   =  DestWidth;
00813         BmpRect.bottom  =  0;
00814 
00815         GD->FillRectangle(&BmpRect);
00816 
00817         // Now we use GRenderRegion to plot it (far easier than farting about
00818         // with conversion which was the previous technique...)
00819 
00820         GRenderRegion::StaticPlotBitmap(&MemDC, DIBPal, TempInfo, TempBits, 0, 0, DestWidth, DestHeight, pPal, 0, 0);
00821 
00822         if (MaskBitmap)
00823         {
00824             // Make the rectangle black
00825             MemDC.SelectObject(*MaskBitmap);
00826             GD->SetColour(0);
00827             GD->FillRectangle(&BmpRect);
00828 
00829             // Contone between white and white, but use the transparency values
00830             GD->SetColour(0xFFFFFF);
00831             GD->SetContone(1, 0xFFFFFF, 0xFFFFFF);
00832             GD->SetBias(3, 0.0);
00833             GD->SetGain(3, 0.0);
00834             GD->SetTileSmoothingFlag(TRUE/*FALSE*/);
00835             GD->SetTileFilteringFlag(TRUE/*FALSE*/);
00836             GD->SetBitmapFill(  &(wxBM->BMInfo->bmiHeader),
00837                                 wxBM->BMBytes,
00838                                 0x4000,
00839                                 PGram,
00840                                 DefaultColour,
00841                                 Palette,
00842                                 NULL, NULL, NULL,
00843                                 NULL,
00844                                 0
00845                                 );
00846             GD->FillRectangle(&BmpRect);
00847 
00848             GRenderRegion::StaticPlotBitmap(&MemDC, DIBPal, TempInfo, TempBits, 0, 0, DestWidth, DestHeight, pPal, 0, 0);
00849         }
00850 
00851         GD->SetDefaultBitmapParameters(); // restore this, as else it upsets things
00852 
00853         FreeDIB(TempInfo, TempBits);
00854 
00855     }
00856     // Finally plot the Bitmap onto the output RenderDC
00857     if (RenderDC)
00858         RenderDC->DrawBitmap(*Bitmap, TopLeft.x, TopLeft.y, true);
00859 
00860     // Yipeee !! We done it
00861     return TRUE;
00862 }

BOOL BitmapDragInformation::StartGalleryItemDrag SGDisplayItem  ) 
 

Definition at line 415 of file dragbmp.cpp.

00416 {
00417 /*
00418 //  pGalleryItem->CalculateMyRect(&FormatInfo, &MiscInfo);
00419 
00420     DocRect ClipRegion(0,0, 100*750,100*750);
00421 
00422     Matrix ConvertMatrix;
00423     FIXED16 ViewScale = 1;
00424 
00425     CDC* pDisplayDC = new CDC();
00426     pDisplayDC->CreateDC("DISPLAY", NULL, NULL, NULL); 
00427 
00428     UINT32 Depth = GetDeviceCaps( pDisplayDC->m_hDC, BITSPIXEL ) * 
00429                                     GetDeviceCaps( pDisplayDC->m_hDC, PLANES );
00430 
00431     INT32 dpi   = GetDeviceCaps( pDisplayDC->m_hDC, LOGPIXELSX );
00432 
00433     GRenderBitmap* pRegion      = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale, 
00434                                                 Depth, dpi);
00435 
00436     GRenderBitmap* pMaskRegion  = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale, 
00437                                                     1, dpi);
00438 
00439     DocView *View = DocView::GetCurrent();
00440     Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
00441 
00442     pRegion->AttachDevice(View, pDisplayDC, pSpread);
00443     pMaskRegion->AttachDevice(View, pDisplayDC, pSpread);
00444 
00445     // Make a Mask Bitmap
00446     pMaskRegion->StartRender();
00447     ((SGDisplayLineAttrItem*)pGalleryItem)->Render(pMaskRegion, ClipRegion);
00448 
00449     // Make the Drag Bitmap
00450     pRegion->StartRender();
00451     ((SGDisplayLineAttrItem*)pGalleryItem)->Render(pRegion, ClipRegion);
00452 
00453     OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
00454     DragMask = new KernelBitmap(pOilMaskBmp);   
00455 
00456     OILBitmap* pOilDragBmp = pRegion->ExtractBitmap();
00457     TheBitmap = new KernelBitmap(pOilDragBmp);  
00458 
00459     delete pMaskRegion;
00460     delete pRegion;
00461     delete pDisplayDC;
00462 
00463 */
00464     return TRUE;
00465 }


Member Data Documentation

wxBitmap* BitmapDragInformation::Bitmap [protected]
 

Definition at line 180 of file dragbmp.h.

UINT32 BitmapDragInformation::DIBPal [protected]
 

Definition at line 177 of file dragbmp.h.

KernelBitmap* BitmapDragInformation::DragMask [protected]
 

Definition at line 170 of file dragbmp.h.

wxSize BitmapDragInformation::DragRect [protected]
 

Definition at line 172 of file dragbmp.h.

INT32 BitmapDragInformation::DragTransparency = 50 [static, protected]
 

Definition at line 184 of file dragbmp.h.

wxBitmap* BitmapDragInformation::MaskBitmap [protected]
 

Definition at line 182 of file dragbmp.h.

wxDC* BitmapDragInformation::MemDC [protected]
 

Definition at line 179 of file dragbmp.h.

wxBitmap* BitmapDragInformation::OldBmp [protected]
 

Definition at line 181 of file dragbmp.h.

LPBYTE BitmapDragInformation::TempBits [protected]
 

Definition at line 175 of file dragbmp.h.

LPBITMAPINFO BitmapDragInformation::TempInfo [protected]
 

Definition at line 174 of file dragbmp.h.

KernelBitmap* BitmapDragInformation::TheBitmap [protected]
 

Definition at line 169 of file dragbmp.h.


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