GalleryFontsDragInfo Class Reference

A fill drag, which was started from the fill gallery. More...

#include <sgdfonts.h>

Inheritance diagram for GalleryFontsDragInfo:

BitmapDragInformation DragInformation CCObject SimpleCCObject List of all members.

Public Member Functions

 GalleryFontsDragInfo ()
 Default constructor - do not call this constructor.
 ~GalleryFontsDragInfo ()
 Destructor - reclaim temporary bitmap memory.
 GalleryFontsDragInfo (SGDisplayPreviewFonts *pSourceItem, SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo, BOOL IsAdjust=FALSE, INT32 XSize=0, INT32 YSize=0)
 Constructor.
virtual void OnClick (INT32 Flags, POINT Point)
 This is called if a drag was attempted but never started because it was a click all along. It calls back the SourceItem SGDisplayBitmap, to get it to handle the click.
virtual UINT32 GetCursorID (DragTarget *pDragTarget)
 Set cursor over this target.
virtual BOOL GetStatusLineText (String_256 *TheText, DragTarget *pDragTarget)
 provide status line text for this target
virtual BOOL CanDropOnPage ()
virtual BOOL OnPageDrop (ViewDragTarget *)
 Called when a Fill is dropped onto the page.
SGDisplayPreviewFontsGetDraggedFont ()
INT32 GetDragTransparency ()
 Determines how transparent the dragged font will be.
KernelBitmapGetSolidDragMask ()
 Makes a 1bpp KernelBitmap mask for the Font preview solid drag.

Protected Attributes

SGDisplayPreviewFontsSourceItem
SGMouseInfo MouseInfo
SGMiscInfo MiscInfo

Detailed Description

A fill drag, which was started from the fill gallery.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/4/95
See also:
BitmapDragInformation

Definition at line 126 of file sgdfonts.h.


Constructor & Destructor Documentation

GalleryFontsDragInfo::GalleryFontsDragInfo  ) 
 

Default constructor - do not call this constructor.

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

Definition at line 294 of file sgdfonts.cpp.

00295 {
00296     ERROR3("Default GalleryFontsDragInfo constructor called");  
00297 }

GalleryFontsDragInfo::~GalleryFontsDragInfo  ) 
 

Destructor - reclaim temporary bitmap memory.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/4/95

Definition at line 310 of file sgdfonts.cpp.

00311 {
00312     if(LibraryGallery::TmpDraggingBitmap != NULL)
00313     {
00314         delete LibraryGallery::TmpDraggingBitmap;
00315         LibraryGallery::TmpDraggingBitmap = NULL;
00316     }
00317 }

GalleryFontsDragInfo::GalleryFontsDragInfo SGDisplayPreviewFonts pSourceItem,
SGMouseInfo pMouseInfo,
SGMiscInfo pMiscInfo,
BOOL  IsAdjust = FALSE,
INT32  XSize = 0,
INT32  YSize = 0
 

Constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
pSourceItem - The gallery item from which the drag originated [INPUTS] pMouseInfo - The mouse info which made the item start the drag pMiscInfo - The MiscInfo which accompanied the mouse event IsAdjust - TRUE if this is an adjust (line-Bitmap) drag XSize - Width in pixels of bmp to drag YSize - Height in pixels of bmp to drag

Definition at line 341 of file sgdfonts.cpp.

00344                       : BitmapDragInformation(LibraryGallery::TmpDraggingBitmap, XSize, YSize,
00345                             FontsSGallery::GetDragFontOffset(LibraryGallery::TmpDraggingBitmap), 0,
00346                             IsAdjust)
00347 {
00348     SourceItem  = pSourceItem;  // Copy the source item pointer
00349 
00350     MouseInfo   = *pMouseInfo;  // Duplicate the structures (they may cease to exist
00351     MiscInfo    = *pMiscInfo;   // soon after the drag is started)
00352 }


Member Function Documentation

virtual BOOL GalleryFontsDragInfo::CanDropOnPage  )  [inline, virtual]
 

Reimplemented from DragInformation.

Definition at line 142 of file sgdfonts.h.

00142 { return TRUE; }

UINT32 GalleryFontsDragInfo::GetCursorID DragTarget pDragTarget  )  [virtual]
 

Set cursor over this target.

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

Reimplemented from BitmapDragInformation.

Definition at line 390 of file sgdfonts.cpp.

00391 {
00392     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00393     {
00394         PageDropInfo PageDropInfo;
00395         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00396 
00397         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00398         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00399 
00400         // if (pObjectHit && pObjectHit->IS_KIND_OF(TextChar))
00401         if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface)))
00402             TargetHit = FILL_TARGET;
00403         else
00404             TargetHit = NO_TARGET;
00405 
00406         switch (TargetHit)
00407         {
00408             case FILL_TARGET:
00409                 return _R(IDC_CANDROPONFILL);
00410 
00411             case NO_TARGET:
00412                 return _R(IDC_CANDROPONPAGE);
00413         };
00414 
00415         return _R(IDC_CANDROPONPAGE);
00416     }
00417 
00418     return _R(IDC_CANTDROP);
00419 }

SGDisplayPreviewFonts* GalleryFontsDragInfo::GetDraggedFont  )  [inline]
 

Definition at line 145 of file sgdfonts.h.

00145 { return(SourceItem); }

INT32 GalleryFontsDragInfo::GetDragTransparency  )  [virtual]
 

Determines how transparent the dragged font will be.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/95
Returns:
The drag tranparency to use for a Font Drag.

Reimplemented from BitmapDragInformation.

Definition at line 560 of file sgdfonts.cpp.

00561 {
00562     // If there's no preview, it looks best if the rectangle is transparent
00563     if(TheBitmap == NULL)
00564         return 50;
00565 
00566     // Font drags look better as solid masked bmps
00567     return 0;
00568 }

KernelBitmap * GalleryFontsDragInfo::GetSolidDragMask  )  [virtual]
 

Makes a 1bpp KernelBitmap mask for the Font preview solid drag.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/95
Returns:
A pointer to the 1bpp Mask bitmap.
This version makes use of the fact that it knows the Font Bitmaps are 8bpp, and so it can alter the palette (temporarily) to make the Anti-Aliased pixels render as solid black.

See also:
-

Reimplemented from BitmapDragInformation.

Definition at line 587 of file sgdfonts.cpp.

00588 {
00589     if(TheBitmap == NULL)
00590     {
00591         DragMask = NULL;
00592         return NULL;
00593     }
00594 
00595     if (DragMask == NULL)
00596     {
00597         // First set up a 1bpp Gavin Bitmap to render into
00598         Matrix ConvertMatrix;
00599         FIXED16 ViewScale = 1;
00600 
00601         CDC* pDisplayDC = new CDC();
00602         if (pDisplayDC == NULL)
00603             return NULL;
00604 
00605         pDisplayDC->CreateDC("DISPLAY", NULL, NULL, NULL);
00606 
00607         double dpi   = (double) GetDeviceCaps( pDisplayDC->m_hDC, LOGPIXELSX );
00608 
00609         // Make life easy by making the Redraw Rectangle start at 0,0
00610         INT32 PixelSize = (INT32)(72000.0/dpi); //.MakeLong();
00611         DocRect ClipRegion(0,0, SolidDragSize.cx*PixelSize, SolidDragSize.cy*PixelSize);
00612 
00613         GRenderBitmap* pMaskRegion  = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale,
00614                                                         1, dpi);
00615         if (pMaskRegion == NULL)
00616         {
00617             delete pDisplayDC;
00618             return NULL;
00619         }
00620 
00621         // Make a Dummy view and spread to attach, just to keep it happy
00622         DocView *View = DocView::GetCurrent();
00623         if (View == NULL)
00624         {
00625             delete pMaskRegion;
00626             delete pDisplayDC;
00627             return NULL;    // Must have a DocView
00628         }
00629 
00630         Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
00631         if (pSpread == NULL)
00632         {
00633             delete pMaskRegion;
00634             delete pDisplayDC;
00635             return NULL;    // Must have a Spread
00636         }
00637 
00638         pMaskRegion->AttachDevice(View, pDisplayDC, pSpread);
00639 
00640 // ****** Start of Bodge *******
00641 
00642 // To make the font mask look correct, we'll make use of the fact
00643 // that we know it's an 8bpp grey scale bitmap.
00644 // First we'll copy the existing palette, then temporarily set the
00645 // palette so all the colours are Black.
00646 // This should mean that everything except the White background of the
00647 // font bitmap will be rendered as Black.
00648 
00649 // This hopefully won't be needed when 'Proper' mask render regions are done
00650 
00651         WinBitmap* WinBM = (WinBitmap*)TheBitmap->ActualBitmap;
00652 
00653         RGBQUAD* Palette = WinBM->BMInfo->bmiColors;
00654         RGBQUAD OldPalette[256];
00655         
00656         // Make a copy of the existing palette
00657         for (INT32 i=0; i<256; i++)
00658         {
00659             OldPalette[i] = Palette[i];
00660         }
00661 
00662         // Now set all but the last few palette entries to 0
00663         // (The font bitmaps seems to use 253 for the background colour)
00664         for (i=0; i<256; i++)
00665         {
00666             Palette[i].rgbBlue  = ((i < 253) ? 0 : 255);
00667             Palette[i].rgbGreen = ((i < 253) ? 0 : 255);
00668             Palette[i].rgbRed   = ((i < 253) ? 0 : 255);
00669         }
00670 
00671 // ****** End of Bodge *******
00672 
00673         // Render the bitmap into the MaskRegion to create the 1bpp mask
00674         pMaskRegion->StartRender();
00675         pMaskRegion->DrawBitmap(DocCoord(0,0), TheBitmap);
00676         pMaskRegion->StopRender();
00677 
00678         // Restore the Proper Palatte values, so the bitmap can be
00679         // rendered properly
00680         for (i=0; i<256; i++)
00681         {
00682             Palette[i] = OldPalette[i];
00683         }
00684 
00685         // Get the 1bpp Mask bitmap out of the Render Region
00686         OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
00687         DragMask = new KernelBitmap(pOilMaskBmp, TRUE); 
00688 
00689         // Tidy up
00690         delete pMaskRegion;
00691         delete pDisplayDC;
00692     }
00693 
00694     return DragMask;
00695 }

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

provide status line text for this target

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/3/95
Returns:
Whether String is valid

Reimplemented from BitmapDragInformation.

Definition at line 432 of file sgdfonts.cpp.

00433 {
00434 #ifdef STANDALONE
00435     return FALSE;
00436 #else
00437     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00438 
00439     if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00440         return FALSE;
00441 
00442     // "Dragging font '#1%s'"
00443     String_256 DragString;
00444     String_256 ItemName;
00445     SourceItem->GetNameText(&ItemName);
00446 //  DragString += *SourceItem->GetDisplayedTextDescription();
00447 
00448     DragString.MakeMsg(_R(IDS_FONTS_DRAGGING), (TCHAR *)ItemName);
00449 
00450 
00451     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00452     {
00453         DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP)); //" : ";
00454     
00455         PageDropInfo PageDropInfo;
00456         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00457 
00458         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00459         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00460 
00461         // if (pObjectHit && pObjectHit->IS_KIND_OF(TextChar))
00462         if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface)))
00463             TargetHit = FILL_TARGET;
00464         else
00465             TargetHit = NO_TARGET;
00466 
00467         switch (TargetHit)
00468         {
00469             case FILL_TARGET:
00470                 if (IS_A(pObjectHit,CaretNode))
00471                 {
00472                     // + "Drop to apply this font to the caret";
00473                     String_64 DropToCaret(_R(IDS_FONTS_DROP_TO_APPLY_CARET));
00474                     DragString += DropToCaret;
00475                 }
00476                 else
00477                 {
00478                     if(pObjectHit->IsSelected())
00479                     {
00480                         // + "Drop to apply this font to the text selection";
00481                         String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_SEL));
00482                         DragString += DropToText;
00483                     }
00484                     else
00485                     if (KeyPress::IsConstrainPressed())
00486                     {
00487                         // + "Drop to apply this font to this character";
00488                         String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_CHAR));
00489                         DragString += DropToText;
00490                     }
00491                     else
00492                     {
00493                         // + "Drop to apply this font to the text story";
00494                         String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_TEXT));
00495                         DragString += DropToText;
00496                     }
00497                 }
00498                 break;
00499 
00500             case NO_TARGET:
00501                 {
00502                     // + "Drop to set the current font style";
00503                     String_64 DropToCurrent(_R(IDS_FONTS_DROP_TO_APPLY_CURRENT));
00504                     DragString += DropToCurrent;
00505                 }
00506                 break;
00507         };
00508 
00509         *TheText = DragString;
00510         return TRUE;
00511     }
00512 
00513     *TheText = DragString;
00514     return TRUE;
00515 #endif
00516 }

void GalleryFontsDragInfo::OnClick INT32  Flags,
POINT  Point
[virtual]
 

This is called if a drag was attempted but never started because it was a click all along. It calls back the SourceItem SGDisplayBitmap, to get it to handle the click.

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

Errors: -

See also:
-

Reimplemented from BitmapDragInformation.

Definition at line 373 of file sgdfonts.cpp.

00374 {
00375     if (SourceItem != NULL)
00376         SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00377 }

BOOL GalleryFontsDragInfo::OnPageDrop ViewDragTarget pDragTarget  )  [virtual]
 

Called when a Fill is dropped onto the page.

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

Errors: -

See also:
-

Reimplemented from DragInformation.

Definition at line 533 of file sgdfonts.cpp.

00534 {
00535 #ifdef STANDALONE
00536     return FALSE;
00537 #else
00538     PageDropInfo PageDropInfo;
00539     ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00540     NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00541     SGDisplayPreviewFonts* SelectedNode = SourceItem;
00542 
00543     return(FontsSGallery::ApplyFont(TRUE, (SGDisplayNode *)SourceItem, pObjectHit));
00544 #endif
00545 }


Member Data Documentation

SGMiscInfo GalleryFontsDragInfo::MiscInfo [protected]
 

Definition at line 154 of file sgdfonts.h.

SGMouseInfo GalleryFontsDragInfo::MouseInfo [protected]
 

Definition at line 153 of file sgdfonts.h.

SGDisplayPreviewFonts* GalleryFontsDragInfo::SourceItem [protected]
 

Definition at line 152 of file sgdfonts.h.


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