#include <sgdfonts.h>
Inheritance diagram for GalleryLibFontsDragInfo:
Public Member Functions | |
GalleryLibFontsDragInfo () | |
Default constructor - do not call this constructor. | |
~GalleryLibFontsDragInfo () | |
Destructor - reclaim temporary bitmap memory. | |
GalleryLibFontsDragInfo (SGLibFontItem *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 library font is dropped onto the page. | |
SGLibFontItem * | GetDraggedFont () |
INT32 | GetDragTransparency () |
Determines how transparent the dragged font will be. | |
KernelBitmap * | GetSolidDragMask () |
Makes a 1bpp KernelBitmap mask for the Font preview solid drag. | |
Protected Attributes | |
SGLibFontItem * | SourceItem |
SGMouseInfo | MouseInfo |
SGMiscInfo | MiscInfo |
Definition at line 168 of file sgdfonts.h.
|
Default constructor - do not call this constructor.
Definition at line 713 of file sgdfonts.cpp. 00714 { 00715 ERROR3("Default GalleryLibFontsDragInfo constructor called"); 00716 }
|
|
Destructor - reclaim temporary bitmap memory.
Definition at line 729 of file sgdfonts.cpp. 00730 { 00731 if(LibraryGallery::TmpDraggingBitmap != NULL) 00732 { 00733 delete LibraryGallery::TmpDraggingBitmap; 00734 LibraryGallery::TmpDraggingBitmap = NULL; 00735 } 00736 }
|
|
Constructor.
Definition at line 760 of file sgdfonts.cpp. 00763 : BitmapDragInformation(LibraryGallery::TmpDraggingBitmap, XSize, YSize, 00764 FontsSGallery::GetDragFontOffset(LibraryGallery::TmpDraggingBitmap), 0, 00765 IsAdjust) 00766 { 00767 SourceItem = pSourceItem; // Copy the source item pointer 00768 00769 MouseInfo = *pMouseInfo; // Duplicate the structures (they may cease to exist 00770 MiscInfo = *pMiscInfo; // soon after the drag is started) 00771 }
|
|
Reimplemented from DragInformation. Definition at line 184 of file sgdfonts.h. 00184 { return TRUE; }
|
|
Set cursor over this target.
Reimplemented from BitmapDragInformation. Definition at line 807 of file sgdfonts.cpp. 00808 { 00809 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget)) 00810 { 00811 PageDropInfo PageDropInfo; 00812 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo); 00813 00814 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit; 00815 ObjectDragTarget TargetHit = PageDropInfo.TargetHit; 00816 00817 String_256 Desc256; 00818 SourceItem->GetNameText(&Desc256); 00819 if (pObjectHit && !FontsSGallery::IsFontAlreadyInstalled(&Desc256, SourceItem->GetType()) && SourceItem->GetParentLibrary() && SourceItem->GetParentLibrary()->IsWebLibrary()) 00820 return _R(IDC_CANTDROP); 00821 00822 00823 // if (pObjectHit && pObjectHit->IS_KIND_OF(TextChar)) 00824 if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface))) 00825 TargetHit = FILL_TARGET; 00826 else 00827 TargetHit = NO_TARGET; 00828 00829 switch (TargetHit) 00830 { 00831 case FILL_TARGET: 00832 return _R(IDC_CANDROPONFILL); 00833 00834 case NO_TARGET: 00835 return _R(IDC_CANDROPONPAGE); 00836 }; 00837 00838 return _R(IDC_CANDROPONPAGE); 00839 } 00840 00841 return _R(IDC_CANTDROP); 00842 }
|
|
Definition at line 187 of file sgdfonts.h. 00187 { return(SourceItem); }
|
|
Determines how transparent the dragged font will be.
Reimplemented from BitmapDragInformation. Definition at line 1003 of file sgdfonts.cpp. 01004 { 01005 // If there's no preview, it looks best if the rectangle is transparent 01006 if(TheBitmap == NULL) 01007 return 50; 01008 01009 // Font drags look better as solid masked bmps 01010 return 0; 01011 }
|
|
Makes a 1bpp KernelBitmap mask for the Font preview solid drag.
Reimplemented from BitmapDragInformation. Definition at line 1030 of file sgdfonts.cpp. 01031 { 01032 if(TheBitmap == NULL) 01033 { 01034 DragMask = NULL; 01035 return NULL; 01036 } 01037 01038 if (DragMask == NULL) 01039 { 01040 // First set up a 1bpp Gavin Bitmap to render into 01041 Matrix ConvertMatrix; 01042 FIXED16 ViewScale = 1; 01043 01044 CDC* pDisplayDC = new CDC(); 01045 if (pDisplayDC == NULL) 01046 return NULL; 01047 01048 pDisplayDC->CreateDC("DISPLAY", NULL, NULL, NULL); 01049 01050 INT32 dpi = GetDeviceCaps( pDisplayDC->m_hDC, LOGPIXELSX ); 01051 01052 // Make life easy by making the Redraw Rectangle start at 0,0 01053 INT32 PixelSize = 72000/dpi; 01054 DocRect ClipRegion(0,0, SolidDragSize.cx*PixelSize, SolidDragSize.cy*PixelSize); 01055 01056 GRenderBitmap* pMaskRegion = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale, 01057 1, dpi); 01058 if (pMaskRegion == NULL) 01059 { 01060 delete pDisplayDC; 01061 return NULL; 01062 } 01063 01064 // Make a Dummy view and spread to attach, just to keep it happy 01065 DocView *View = DocView::GetCurrent(); 01066 if (View == NULL) 01067 { 01068 delete pMaskRegion; 01069 delete pDisplayDC; 01070 return NULL; // Must have a DocView 01071 } 01072 01073 Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0)); 01074 if (pSpread == NULL) 01075 { 01076 delete pMaskRegion; 01077 delete pDisplayDC; 01078 return NULL; // Must have a Spread 01079 } 01080 01081 pMaskRegion->AttachDevice(View, pDisplayDC, pSpread); 01082 01083 // ****** Start of Bodge ******* 01084 01085 // To make the font mask look correct, we'll make use of the fact 01086 // that we know it's an 8bpp grey scale bitmap. 01087 // First we'll copy the existing palette, then temporarily set the 01088 // palette so all the colours are Black. 01089 // This should mean that everything except the White background of the 01090 // font bitmap will be rendered as Black. 01091 01092 // This hopefully won't be needed when 'Proper' mask render regions are done 01093 WinBitmap* WinBM = (WinBitmap*)TheBitmap->ActualBitmap; 01094 01095 RGBQUAD* Palette = WinBM->BMInfo->bmiColors; 01096 RGBQUAD OldPalette[256]; 01097 01098 // Make a copy of the existing palette 01099 for (INT32 i=0; i<256; i++) 01100 { 01101 OldPalette[i] = Palette[i]; 01102 } 01103 01104 // Now set all but the last few palette entries to 0 01105 // (The font bitmaps seems to use 253 for the background colour) 01106 for (i=0; i<256; i++) 01107 { 01108 Palette[i].rgbBlue = ((i < 253) ? 0 : 255); 01109 Palette[i].rgbGreen = ((i < 253) ? 0 : 255); 01110 Palette[i].rgbRed = ((i < 253) ? 0 : 255); 01111 } 01112 01113 // ****** End of Bodge ******* 01114 01115 // Render the bitmap into the MaskRegion to create the 1bpp mask 01116 pMaskRegion->StartRender(); 01117 pMaskRegion->DrawBitmap(DocCoord(0,0), TheBitmap); 01118 pMaskRegion->StopRender(); 01119 01120 // Restore the Proper Palatte values, so the bitmap can be 01121 // rendered properly 01122 for (i=0; i<256; i++) 01123 { 01124 Palette[i] = OldPalette[i]; 01125 } 01126 01127 // Get the 1bpp Mask bitmap out of the Render Region 01128 OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap(); 01129 DragMask = new KernelBitmap(pOilMaskBmp, TRUE); 01130 01131 // Tidy up 01132 delete pMaskRegion; 01133 delete pDisplayDC; 01134 } 01135 01136 return DragMask; 01137 }
|
|
provide status line text for this target
Reimplemented from BitmapDragInformation. Definition at line 855 of file sgdfonts.cpp. 00856 { 00857 #ifdef STANDALONE 00858 return FALSE; 00859 #else 00860 ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()"); 00861 00862 if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL) 00863 return FALSE; 00864 00865 String_256 DragString; 00866 String_256 ItemName; 00867 SourceItem->GetNameText(&ItemName); 00868 NodeRenderableInk* pObjectHit = NULL; 00869 PageDropInfo PageDropInfo; 00870 ObjectDragTarget TargetHit; 00871 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget)) 00872 { 00873 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo); 00874 pObjectHit = PageDropInfo.pObjectHit; 00875 TargetHit = PageDropInfo.TargetHit; 00876 } 00877 if (pObjectHit && !FontsSGallery::IsFontAlreadyInstalled(&ItemName, SourceItem->GetType()) && SourceItem->GetParentLibrary() && SourceItem->GetParentLibrary()->IsWebLibrary()) 00878 DragString = String_256(_R(IDS_MUST_DOWNLOAD)); 00879 else 00880 { 00881 // "Dragging font '#1%s'" 00882 DragString.MakeMsg(_R(IDS_FONTS_DRAGGING), (TCHAR *)ItemName); 00883 00884 if (pDragTarget && pDragTarget->IS_KIND_OF(SGFontsDragTarget)) 00885 { 00886 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP)); //" : "; 00887 00888 // + "Drop to Install this font" 00889 String_64 DropToInstall(_R(IDS_FONTS_DROP_TO_INSTALL)); 00890 DragString += DropToInstall; 00891 00892 *TheText = DragString; 00893 return TRUE; 00894 } 00895 00896 if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget)) 00897 { 00898 DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP)); //" : "; 00899 00900 00901 if (pObjectHit && pObjectHit->RequiresAttrib(CC_RUNTIME_CLASS(AttrTxtFontTypeface))) 00902 TargetHit = FILL_TARGET; 00903 else 00904 TargetHit = NO_TARGET; 00905 00906 switch (TargetHit) 00907 { 00908 case FILL_TARGET: 00909 00910 if (IS_A(pObjectHit,CaretNode)) 00911 { 00912 // + "Drop to apply this font to the caret"; 00913 String_64 DropToCaret(_R(IDS_FONTS_DROP_TO_APPLY_CARET)); 00914 DragString += DropToCaret; 00915 } 00916 else 00917 { 00918 if(pObjectHit->IsSelected()) 00919 { 00920 // + "Drop to apply this font to the text selection"; 00921 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_SEL)); 00922 DragString += DropToText; 00923 } 00924 else 00925 if (KeyPress::IsConstrainPressed()) 00926 { 00927 // + "Drop to apply this font to this character"; 00928 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_CHAR)); 00929 DragString += DropToText; 00930 } 00931 else 00932 { 00933 // + "Drop to apply this font to the text story"; 00934 String_64 DropToText(_R(IDS_FONTS_DROP_TO_APPLY_TEXT)); 00935 DragString += DropToText; 00936 } 00937 } 00938 break; 00939 00940 case NO_TARGET: 00941 { 00942 // + "Drop to set the current font style"; 00943 String_64 DropToCurrent(_R(IDS_FONTS_DROP_TO_APPLY_CURRENT)); 00944 DragString += DropToCurrent; 00945 } 00946 break; 00947 }; 00948 00949 *TheText = DragString; 00950 return TRUE; 00951 } 00952 } 00953 00954 *TheText = DragString; 00955 return TRUE; 00956 #endif 00957 }
|
|
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.
Reimplemented from BitmapDragInformation. Definition at line 790 of file sgdfonts.cpp. 00791 { 00792 if (SourceItem != NULL) 00793 SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo); 00794 }
|
|
Called when a library font is dropped onto the page.
Reimplemented from DragInformation. Definition at line 975 of file sgdfonts.cpp. 00976 { 00977 #ifdef STANDALONE 00978 return FALSE; 00979 #else 00980 PageDropInfo PageDropInfo; 00981 ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo); 00982 NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit; 00983 SGLibFontItem *FontItem = SourceItem; 00984 00985 // Install the font then apply it 00986 return(FontsSGallery::ApplyFont(TRUE, (SGDisplayNode *)FontItem, pObjectHit)); 00987 #endif 00988 }
|
|
Definition at line 196 of file sgdfonts.h. |
|
Definition at line 195 of file sgdfonts.h. |
|
Definition at line 194 of file sgdfonts.h. |