SGDisplayPreviewFonts Class Reference

This is the base-class for the installed font items in the fonts gallery. An instance of this class should never be created, instead SGTTFItem and SGATMItem's should be used. More...

#include <sgfonts.h>

Inheritance diagram for SGDisplayPreviewFonts:

SGDisplayItem SGDisplayNode CCObject SimpleCCObject SGATMItem SGTTFItem List of all members.

Public Member Functions

 SGDisplayPreviewFonts ()
 SGDisplayPreviewFonts constructor DON'T call this constructor. It ERROR3's. Call the other constructor.
 ~SGDisplayPreviewFonts ()
 SGDisplayPreviewFonts destructor General memory and object tidy up - all thumbnails are vaped...
virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event.
void DragWasReallyAClick (SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
 Handles a mouse click event. This is a callback function - drags of bitmaps from galleries will call this function back if the drag turns out to just be a click.
virtual void GetNameText (String_256 *Result)
 Returns the name text for this item, to support simple searching and sorting operations, with redraw methods for font items. Notes:.
virtual void GetFullInfoText (String_256 *Result)
 Returns the full-info text for this item, to support simple searching operations, and redraw methods for font items. Notes:.
virtual INT32 CompareTo (SGDisplayNode *Other, INT32 SortKey)
 Compares this node to the 'other' node, to determine their relative positions in the display tree. Returns a value which usually indicates that the other node should be inserted before (-1, or 0) or after (+1) this item.
virtual BOOL CreateThumbnail (KernelBitmap **Bitmap)
 Creates a bitmap for this font We assume the item contains a valid logfont structure.
KernelBitmapGetDisplayedKernelBitmap (SGMiscInfo *MiscInfo, BOOL Background)
 To find out the KernelBitmap this object is responsible for displaying.
String_64GetDisplayedTextDescription (void)
 To find the Text description for this object.
virtual void GetKeyWords (String_256 *Result)
 To determine the keywords for this node. Generally, this is used for a simple searching mechanism.
BOOL IsFontBeingUsed (void)

Static Public Member Functions

static LibDisplayType GetDisplayType (SGMiscInfo *MiscInfo)
 Return the display type to use - similar to the library item ones Notes:.
static BOOL GetThumbnailDetails (INT32 Mode, UINT32 *X, UINT32 *Y, String_256 *Text)
 Quick way of returning size and information details regarding the font preview thumbnails.
static void DrawTypeIcon (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo, DocRect *TypeRect, FontClass Type)
 Draws / Plots the 'ATM' or 'TTF' icon itself into the gallery.

Public Attributes

KernelBitmapFontBitmap
String_64 FontDescription
UINT32 ID
FontClass Type
LOGFONTCachedLogFont
INT32 IntLeading
BOOL Invalid

Static Public Attributes

static INT32 DMode

Protected Member Functions

virtual void CalculateMyRect (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
 Shared code for PreviewFonts items to calculate where they will appear in the grand scheme of things.
virtual void HandleRedraw (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
 SGDisplayPreviewFonts item redraw method - removed from the main HandleEvent method merely to make the code tidier.
virtual BOOL DrawThumb (RenderRegion *Renderer, SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo, DocRect *Rectangle, BOOL Background=FALSE)
 Draws a thumbnail for the library item. This can be overridden, so the colour library for instance would plot a rectangle instead of a bitmap.
virtual void DrawItemText (RenderRegion *Renderer, SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo, DocRect *Rectangle, DocRect *BmpRect, BOOL Selected)
 Plots the item text in the position as required by the GetDisplayType. Notes:.
void MoveAfter (SGDisplayNode *NodeToMove)
 MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.
void MoveBefore (SGDisplayNode *NodeToMove)
 MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.
BOOL GetBubbleHelp (DocCoord *MousePos, String_256 *Result)
 Called by the parent gallery when bubble help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.
BOOL GetStatusLineHelp (DocCoord *MousePos, String_256 *Result)
 Called by the parent gallery when status line help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.

Private Member Functions

 CC_DECLARE_DYNAMIC (SGDisplayPreviewFonts)

Detailed Description

This is the base-class for the installed font items in the fonts gallery. An instance of this class should never be created, instead SGTTFItem and SGATMItem's should be used.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/02/95
See also:
FontsSGallery; SuperGallery; SGDisplayItem

Definition at line 175 of file sgfonts.h.


Constructor & Destructor Documentation

SGDisplayPreviewFonts::SGDisplayPreviewFonts  ) 
 

SGDisplayPreviewFonts constructor DON'T call this constructor. It ERROR3's. Call the other constructor.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 591 of file sgfonts.cpp.

00592 {
00593     FontBitmap = NULL;
00594     FontDescription = _T("");
00595     CachedLogFont = NULL;
00596     ID = 0;
00597     IntLeading = 0;
00598     Type = FC_UNDEFINED;
00599     Invalid = FALSE;
00600 }

SGDisplayPreviewFonts::~SGDisplayPreviewFonts  ) 
 

SGDisplayPreviewFonts destructor General memory and object tidy up - all thumbnails are vaped...

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

Definition at line 616 of file sgfonts.cpp.

00617 {
00618     // The FontBitmap is also referenced in the thumbnail cache, and that's where its
00619     // memory is free'd
00620     FontBitmap = NULL;
00621     FontDescription = _T("");
00622 
00623     if(CachedLogFont != NULL)
00624     {
00625         delete CachedLogFont;
00626         CachedLogFont = NULL;
00627     }
00628 
00629     ID = 0;
00630     IntLeading = 0;
00631 }


Member Function Documentation

void SGDisplayPreviewFonts::CalculateMyRect SGFormatInfo FormatInfo,
SGMiscInfo MiscInfo
[protected, virtual]
 

Shared code for PreviewFonts items to calculate where they will appear in the grand scheme of things.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
FormatInfo - The formatting info from which to calculate my position/size [INPUTS] MiscInfo - As usual, the useful misc info struct
member variable FormatRect - is returned filled in with the size/position of [OUTPUTS] this PreviewFonts item's display area. This is dependent upon the current display mode and format state
FormatInfo will be updated as a result of the formatting operation

Notes: Scope: private (for use of SGDisplayPreviewFonts class only)

Definition at line 708 of file sgfonts.cpp.

00709 {
00710     UINT32 XSize = SG_InfiniteWidth;
00711     UINT32 YSize = SG_DefaultLargeIcon;
00712     
00713     DMode = MiscInfo->DisplayMode;
00714 
00715     // Get the relevant size details for the current mode (pixels)
00716     GetThumbnailDetails(DMode, &XSize, &YSize, NULL);
00717 
00718     INT32 OnePixel  = (INT32) DevicePixels(MiscInfo, 1);
00719 
00720     // Convert pixel values into millipoint measurements
00721     switch(DMode)
00722     {
00723         case 1:
00724             // Full info mode requires more text description space
00725             //XSize = SG_InfiniteWidth;
00726             XSize = (XSize * OnePixel) + (SG_DefaultNameText * 2);
00727             break;
00728 
00729         case 3:
00730             // No description requires no text description space
00731             XSize = (XSize * OnePixel) + (SGF_SURROUND * OnePixel * 2) + (SGF_TYPE_WIDTH * OnePixel);
00732             break;
00733 
00734         case 4:
00735             // Just text
00736             YSize = GridLock(MiscInfo, 18 * OnePixel);
00737             XSize = GridLock(MiscInfo, SG_DefaultNameText);
00738             CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00739             return;
00740 
00741         default:
00742             // Normal and Small modes just have the font name at present
00743             XSize = (XSize * OnePixel) + (INT32)((float) SG_DefaultNameText * 1.1);
00744             break;
00745     }
00746 
00747     YSize = (YSize + (SGF_SURROUND * 2)) * OnePixel;
00748 
00749     // Snap to gridpoints
00750     XSize = GridLock(MiscInfo, XSize);
00751     YSize = GridLock(MiscInfo, YSize);
00752 
00753     CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00754 }

SGDisplayPreviewFonts::CC_DECLARE_DYNAMIC SGDisplayPreviewFonts   )  [private]
 

INT32 SGDisplayPreviewFonts::CompareTo SGDisplayNode Other,
INT32  SortKey
[virtual]
 

Compares this node to the 'other' node, to determine their relative positions in the display tree. Returns a value which usually indicates that the other node should be inserted before (-1, or 0) or after (+1) this item.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/4/95
Parameters:
Other - the node to compare this node to [INPUTS] SortKey - An integer identifying how to compare the items 0 = No sorting (always returns 0) 1 = Sort-by-name 2 = Sort-by-size 3 = Sort-by-namelength 4 = Sort-by-type (ATM / TTF) Other values will return 0, unless the derived class overrides this method in order to provide other sort modes.
Returns:
negative (I am lesser), 0 (we are equal), or positive (I am greater)
See also:
SGDisplayNode::AddItem

Reimplemented from SGDisplayNode.

Definition at line 1285 of file sgfonts.cpp.

01286 {
01287     switch(SortKey)
01288     {
01289         case 1:
01290             // Sort by name - override default and make 'FRED' and 'fred' equal...
01291             {
01292                 String_256 MyName;
01293                 String_256 ItsName;
01294 
01295                 GetNameText(&MyName);
01296                 MyName.toLower();
01297                 Other->GetNameText(&ItsName);
01298                 ItsName.toLower();
01299 
01300                 return(MyName.CompareTo(ItsName, FALSE));
01301             }
01302 
01303         case 2:
01304             // Search by size
01305             // We could hunt for the ttf file and find it's size, maybe in future versions
01306             return 0;
01307 
01308         case 3:
01309             {
01310                 String_256 MyName;
01311                 String_256 ItsName;
01312 
01313                 GetNameText(&MyName);
01314                 Other->GetNameText(&ItsName);
01315 
01316                 return (MyName.Length() - ItsName.Length());
01317             }
01318             break;
01319     
01320         case 4:
01321         {
01322             SGDisplayPreviewFonts *OtherFont = (SGDisplayPreviewFonts *)Other;
01323 
01324             if(Type == OtherFont->Type)
01325                 return 0;
01326             if(Type == FC_ATM && OtherFont->Type == FC_TRUETYPE)
01327                 return -1;
01328             return 1;
01329             break;
01330         }
01331 
01332     }
01333 
01334     return (SGDisplayNode::CompareTo(Other, SortKey));
01335 }

BOOL SGDisplayPreviewFonts::CreateThumbnail KernelBitmap **  Bitmap  )  [virtual]
 

Creates a bitmap for this font We assume the item contains a valid logfont structure.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/2/95
Parameters:
- [INPUTS]
*Bitmap contains the bitmap on exit [OUTPUTS]
Returns:
TRUE if the bmp was created successfully FALSE if it was not
Notes: Only works with 8 and 32 bpp bmps at the mo.

Reimplemented in SGTTFItem, and SGATMItem.

Definition at line 1355 of file sgfonts.cpp.

01356 {
01357     ERROR3("SGDisplayPreviewFonts::CreateThumbnail should be overridden");
01358  
01359     // we've created a thumbnail - if ok is false then it's not got much in, but it's there...
01360     return TRUE;
01361 }

void SGDisplayPreviewFonts::DragWasReallyAClick SGMouseInfo Mouse,
SGMiscInfo MiscInfo
[virtual]
 

Handles a mouse click event. This is a callback function - drags of bitmaps from galleries will call this function back if the drag turns out to just be a click.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/4/95
Parameters:
Mouse - The mouse info passed to the original click handler [INPUTS] MiscInfo - The misc info passed to the original click handler
See also:
SGDisplayPreviewFonts::HandleEvent; GalleryFontsDragInfo::OnClick

Reimplemented from SGDisplayNode.

Definition at line 1516 of file sgfonts.cpp.

01517 {
01518     // Just get default selection action to be applied for this click
01519     DefaultClickHandler(Mouse, MiscInfo, TRUE);
01520 }

void SGDisplayPreviewFonts::DrawItemText RenderRegion Renderer,
SGRedrawInfo RedrawInfo,
SGMiscInfo MiscInfo,
DocRect Rectangle,
DocRect BmpRect,
BOOL  Selected
[protected, virtual]
 

Plots the item text in the position as required by the GetDisplayType. Notes:.

Parameters:
Renderer - Pointer to RenderRegion in which to plot the bitmap rect [INPUTS] RedrawInfo - Various bits of Redraw information such as colours MiscInfo - Miscellaneous info as passed to the redraw handler by the sgallery code Rectangle - Pointer to a DocRect the size and position of which the selected rectangle will use, so we need to draw our thumbnail inside this. BmpRect - Bitmap rectangle Selected - Should the text be drawn in a selected state ?
[OUTPUTS] 
Returns:
See also:
SGLibDisplayItem::HandleRedraw

Definition at line 823 of file sgfonts.cpp.

00825 {
00826     LibDisplayType DType = GetDisplayType(MiscInfo);
00827 
00828     switch(DType)
00829     {
00830         case LibDisplay_SmallThumb:
00831         case LibDisplay_MediumThumb:
00832         case LibDisplay_LargeThumb:
00833             return; // No text
00834         default:
00835             break;
00836     }
00837 
00838     INT32 OnePixel  = (INT32) DevicePixels(MiscInfo, 1);
00839 
00840     // Work out the text rectangle and stick it here
00841     DocRect TextRect(*Rectangle);
00842     TextRect.lo.x = BmpRect->hi.x + SG_GapBeforeText;
00843 
00844     GridLockRect(MiscInfo, &TextRect);
00845 
00846     Renderer->SetLineWidth(0);
00847     Renderer->SetLineColour(RedrawInfo->Transparent);
00848 
00849     // Set up the colours for rendering our text, and fill the background if selected
00850     if (Selected)
00851     {    
00852         Renderer->SetFillColour(RedrawInfo->SelBackground);
00853             
00854         DocRect SelRect(TextRect);
00855 
00856         // Text not in gallery, don't redraw
00857         if(TextRect.lo.x > Rectangle->hi.x) return;
00858 
00859         SelRect.hi.y = TextRect.lo.y + TextRect.Height()/2 - (OnePixel * 2);
00860         SelRect.lo.y = TextRect.lo.y + TextRect.Height()/2 + (OnePixel * 2);
00861         SelRect.hi.y += SG_DefaultLargeIcon/2;
00862         SelRect.lo.y -= (SG_DefaultLargeIcon/2 + OnePixel);
00863         SelRect.hi.x = TextRect.hi.x;
00864                 
00865         GridLockRect(MiscInfo, &SelRect);
00866     
00867         Renderer->DrawRect(&SelRect);
00868 
00869         Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
00870     }
00871     else
00872         Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background);
00873 
00874     Renderer->SetFillColour(RedrawInfo->Foreground);    
00875 
00876     // No point drawing the text, etc...
00877     if(TextRect.lo.x + (OnePixel * 4) > Rectangle->hi.x)
00878         return;
00879 
00880     // Work out proper text string to display and display it
00881     String_256 DisplayText;
00882 
00883     if(DMode == 1)
00884         GetFullInfoText(&DisplayText);
00885     else
00886         GetNameText(&DisplayText);
00887     
00888     // Left justified text
00889     TextRect.lo.x += (OnePixel * 4);
00890     Renderer->DrawFixedSystemText(&DisplayText, TextRect);
00891 }

BOOL SGDisplayPreviewFonts::DrawThumb RenderRegion Renderer,
SGRedrawInfo RedrawInfo,
SGMiscInfo MiscInfo,
DocRect Rectangle,
BOOL  Background = FALSE
[protected, virtual]
 

Draws a thumbnail for the library item. This can be overridden, so the colour library for instance would plot a rectangle instead of a bitmap.

Parameters:
Renderer - Pointer to RenderRegion in which to plot the bitmap rect [INPUTS] RedrawInfo - Various bits of Redraw information such as colours MiscInfo - Miscellaneous info as passed to the redraw handler by the sgallery code Rectangle - Pointer to a DocRect the size and position of which the selected rectangle will use, so we need to draw our thumbnail inside this. Background - TRUE if redrawing in backgrounding - return FALSE if not in buffer
[OUTPUTS] 
Returns:
TRUE if things went OK, FALSE otherwise
For bitmaps, drawing them at a 1:1 aspect ratio looks much better than simply squashing them into an arbitrary rectangle. Notes:
See also:
SGLibDisplayItem::HandleRedraw

Definition at line 918 of file sgfonts.cpp.

00920 {
00921     LibDisplayType DType = GetDisplayType(MiscInfo);
00922 
00923     if(DType == LibDisplay_JustText)
00924         return TRUE;
00925 
00926     FontBitmap = GetDisplayedKernelBitmap(MiscInfo, Background);
00927                           
00928     // Bitmap not there...
00929     if(FontBitmap == NULL)
00930         return FALSE;
00931 
00932     if(FontBitmap->ActualBitmap == NULL)
00933         return FALSE;
00934 
00935     DMode = MiscInfo->DisplayMode;
00936 //  FontsSGallery *FSGallery = FontsSGallery::ThisGallery;
00937     
00938     DocRect BmpRect(*Rectangle);
00939 
00940     INT32 OnePixel  = (INT32) DevicePixels(MiscInfo, 1);
00941 
00942     UINT32 XSize = 0;
00943     UINT32 YSize = 0;
00944     
00945     Renderer->SetLineWidth(0);
00946     DocColour trans(COLOUR_TRANS);
00947     Renderer->SetLineColour(trans);
00948 
00949     BOOL ThumbnailOK = TRUE;
00950 
00951     BitmapInfo Info;
00952 
00953     BOOL InfoOK = FontBitmap->ActualBitmap->GetInfo( &Info );
00954 
00955     if(InfoOK)
00956     {
00957         // Get the details for the bitmap 
00958         XSize = (UINT32)Info.PixelWidth;
00959         YSize = (UINT32)Info.PixelHeight;               
00960         ThumbnailOK = TRUE;
00961     }
00962     else
00963     {
00964         // Get the default details for this mode
00965         GetThumbnailDetails(DMode, &XSize, &YSize, NULL);       
00966         ThumbnailOK = FALSE;
00967     }
00968 
00969     XSize *= OnePixel;
00970 //  YSize *= OnePixel;
00971 
00972     // Thumbnail rectangle... space around edges but don't scale thumbnail
00973     BmpRect.lo.x += (3 * OnePixel);
00974     BmpRect.hi.x  = BmpRect.lo.x + XSize ;
00975     BmpRect.Inflate(0, -(3 * OnePixel));
00976     GridLockRect(MiscInfo, &BmpRect);           // Ensure it maps exactly to specific pixels
00977 
00978     NodeBitmap* DummyBmp = NULL;
00979 
00980     if(Invalid)
00981         return FALSE;
00982 
00983     if(ThumbnailOK)
00984     {
00985         // Setup the bitmap ready for plotting
00986         DummyBmp = new NodeBitmap();
00987         if (DummyBmp == NULL)
00988         {
00989             ThumbnailOK = FALSE;
00990         }
00991         else
00992         {
00993             // Need to clip to MyRect.hi.x at some point;
00994             DummyBmp->SetUpPath();
00995             DummyBmp->CreateShape(BmpRect);
00996             DummyBmp->GetBitmapRef()->SetBitmap(FontBitmap);
00997 
00998             // Now render the bitmap
00999             DummyBmp->Render(Renderer);
01000 
01001             // Unscaled version - problems with win32s
01002             // Renderer->DrawBitmap(IconRect.LowCorner(), FontBitmap);
01003 
01004             delete DummyBmp;
01005         }
01006     }
01007 
01008     // This could happen in the last block. Basically, we haven't got a bitmap, or had
01009     // problems creating one...
01010     if(!ThumbnailOK)
01011     {
01012         // NULL bitmap, just draw rectangle                                           
01013         DocColour NullBitmapColour(230L, 230L, 230L);
01014 
01015         // Draw the 'blank' bitmap
01016         Renderer->SetFillColour(NullBitmapColour);  // RedrawInfo->Background//);
01017 
01018         GridLockRect(MiscInfo, &BmpRect);       // Ensure we're on a pixel
01019         Renderer->DrawRect(&BmpRect);
01020     }
01021 
01022     // Drawn bitmap preview ok
01023     return TRUE;
01024 }

void SGDisplayPreviewFonts::DrawTypeIcon SGRedrawInfo RedrawInfo,
SGMiscInfo MiscInfo,
DocRect TypeRect,
FontClass  Type
[static]
 

Draws / Plots the 'ATM' or 'TTF' icon itself into the gallery.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/10/95
Parameters:
RedrawInfo - The information on the kernel-rendered redraw area [INPUTS] FormatInfo - The formatting information structure TypeRect - A small rectangle to the left of the main display item Type - The FontClass for the item

Definition at line 1182 of file sgfonts.cpp.

01183 {
01184     INT32 BitmapID = 0;                 // Work out the bmp ID, if not known, simply return...
01185     if(Type == FC_ATM)
01186         BitmapID = _R(IDB_ATM_SYMBOL);
01187     else if(Type == FC_TRUETYPE)
01188         BitmapID = _R(IDB_TTF_SYMBOL);
01189     else return;
01190 
01191     DocRect GlyphRect(*TypeRect);
01192 
01193     INT32 OnePixel = (INT32) MiscInfo->PixelSize;
01194     INT32 Centre = GlyphRect.lo.y + ((GlyphRect.hi.y - GlyphRect.lo.y) / 2);
01195     GlyphRect.lo.y = Centre - ((SGF_TYPE_WIDTH / 2) * OnePixel);
01196     GlyphRect.hi.y = Centre + (((SGF_TYPE_WIDTH / 2) + 1) * OnePixel);      // Always round up...
01197 
01198     // Bodge so 'text only' mode has space to left of icon...
01199     LibDisplayType DType = SGDisplayPreviewFonts::GetDisplayType(MiscInfo);
01200 
01201     if(DType == LibDisplay_JustText)
01202         GlyphRect.lo.x += (6 * OnePixel);
01203 
01204     RedrawInfo->Renderer->DrawBitmap(GlyphRect.lo, BitmapID);
01205 }

BOOL SGDisplayPreviewFonts::GetBubbleHelp DocCoord MousePos,
String_256 Result
[protected, virtual]
 

Called by the parent gallery when bubble help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/4/95
Parameters:
MousePos - The current mouse position. This will generally be expected [INPUTS] to lie inside this item's FormatRect. With it, this item can provide help on specific areas of an item.
On exit, if the return value is TRUE, the string pointed at by Result [OUTPUTS] will contain a bubble help string for this item
Returns:
TRUE if it filled in the string, FALSE if it did not
Notes: The base class returns FALSE (i.e. provides no help) If you can provide help, then override the base class method to do so.

See also:
SGDisplayNode::GetStatusLineHelp

Reimplemented from SGDisplayNode.

Definition at line 1719 of file sgfonts.cpp.

01720 {
01721     ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01722 
01723     *Result = *GetDisplayedTextDescription();
01724 
01725     return(TRUE);
01726 }

KernelBitmap * SGDisplayPreviewFonts::GetDisplayedKernelBitmap SGMiscInfo MiscInfo,
BOOL  Background
 

To find out the KernelBitmap this object is responsible for displaying.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/04/95
Parameters:
MiscInfo - misc info given to the gallery redraw code [INPUTS] Background - if false then redrawing in foreground - only return bmp if in cache
[OUTPUTS] 
Returns:
A pointer to the KernelBitmap which this Display Item is used to display, or NULL if there is no thumbnail (e.g. a colour library has no thumbs), or the thumbnail failed to load/cache

Definition at line 654 of file sgfonts.cpp.

00655 {
00656     // Invalid font - don't display thumbnail, or allow it to be dragged...
00657     if(Invalid)
00658         return NULL;
00659 
00660     LibDisplayType DType = GetDisplayType(MiscInfo);
00661 
00662     if(DType == LibDisplay_JustText)
00663         return NULL;
00664 
00665     FontsSGallery *FSGallery = FontsSGallery::ThisGallery;
00666     ERROR3IF(FSGallery == NULL, "SGDisplayPreviewFonts::GetDisplayedKernelBitmap, FontsSGallery::ThisGallery is NULL");
00667 
00668     // We haven't got the bmp from the cache yet
00669     FontBitmap = NULL;
00670 
00671     if(FSGallery->InsCache != NULL)
00672     {
00673         // Depending on 'Background' return the thumbnail from the cache (or generate a new one and add
00674         // it to the cache) or return NULL if we're in a hurry...
00675         FSGallery->InsCache->SetSize((SGThumbSize)MiscInfo->DisplayMode);
00676         if(!FSGallery->InsCache->GetThumbnail(ID, Background, &FontBitmap, NULL, (LP_SGTHUMBS_MOREINFO)this))
00677             FontBitmap = NULL;
00678     }
00679 
00680     return FontBitmap;
00681 }

String_64 * SGDisplayPreviewFonts::GetDisplayedTextDescription void   )  [inline]
 

To find the Text description for this object.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
03/02/95
Returns:
A pointer to the Description string which this Display Item uses.

Definition at line 331 of file sgfonts.h.

00332 {
00333     return(&FontDescription);
00334 }

LibDisplayType SGDisplayPreviewFonts::GetDisplayType SGMiscInfo MiscInfo  )  [static]
 

Return the display type to use - similar to the library item ones Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/5/95
Parameters:
MiscInfo - Contains a few useful bits of info that may be [INPUTS] needed for all event types.
[OUTPUTS] 
Returns:
The display mode type to use (position of text, and size of thumb)
See also:

Definition at line 774 of file sgfonts.cpp.

00775 {
00776     switch(MiscInfo->DisplayMode)
00777     {
00778         case 4:
00779             return LibDisplay_JustText;
00780             break;
00781         case 3:
00782             return LibDisplay_MediumThumb;
00783             break;
00784         case 2:
00785             return LibDisplay_SmallThumbText;
00786             break;
00787         case 1:
00788             // return LibDisplay_FullInfo;
00789             return LibDisplay_SingleLineFullInfo;
00790             break;
00791         case 0:
00792         default:
00793             return LibDisplay_LargeThumbText;
00794             break;
00795     }
00796 
00797     return LibDisplay_LargeThumbTextUnder;
00798 }

void SGDisplayPreviewFonts::GetFullInfoText String_256 Result  )  [virtual]
 

Returns the full-info text for this item, to support simple searching operations, and redraw methods for font items. Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/95
Parameters:
[INPUTS] 
Result - String to place resulting text in [OUTPUTS]
Returns:
The display mode type to use (position of text, and size of thumb)
See also:

Reimplemented from SGDisplayNode.

Reimplemented in SGTTFItem, and SGATMItem.

Definition at line 1250 of file sgfonts.cpp.

01251 {
01252     ERROR3IF(Result == NULL, "SGDisplayPreviewFonts::GetFullInfoText given null ptr");
01253 
01254     // This is usually overridden to give better descriptions...
01255     *Result = (String_256)FontDescription;
01256 }

void SGDisplayPreviewFonts::GetKeyWords String_256 Result  )  [virtual]
 

To determine the keywords for this node. Generally, this is used for a simple searching mechanism.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/3/95
Parameters:
On exit, the string pointed at by Result will contain either a blank [OUTPUTS] string, or a list of | seperated keywords associated with the item
Notes: The base class returns a blank string. If you can provide a better name string, then override the base class method to do so.

See also:
SGDisplayNode::GetFullInfoText

Reimplemented from SGDisplayNode.

Definition at line 1603 of file sgfonts.cpp.

01604 {
01605     ERROR3IF(Result == NULL, "SGDisplayPreviewFonts::GetKeywords given a NULL param");
01606     if(Result == NULL)
01607         return; 
01608 
01609     // We don't support keyword searching on the installed fonts !
01610     *Result = "";
01611 }

void SGDisplayPreviewFonts::GetNameText String_256 Result  )  [virtual]
 

Returns the name text for this item, to support simple searching and sorting operations, with redraw methods for font items. Notes:.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/4/95
Parameters:
[INPUTS] 
Result - String to place resulting text in [OUTPUTS]
Returns:
See also:

Reimplemented from SGDisplayNode.

Definition at line 1225 of file sgfonts.cpp.

01226 {
01227     ERROR3IF(Result == NULL, "SGDisplayPreviewFonts::GetNameText given null ptr");
01228 
01229     *Result = (String_256)FontDescription;
01230 }

BOOL SGDisplayPreviewFonts::GetStatusLineHelp DocCoord MousePos,
String_256 Result
[protected, virtual]
 

Called by the parent gallery when status line help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/4/95
Parameters:
MousePos - The current mouse position. This will generally be expected [INPUTS] to lie inside this item's FormatRect. With it, this item can provide help on specific areas of an item.
On exit, if the return value is TRUE, the string pointed at by Result [OUTPUTS] will contain a status line help string for this item
Returns:
TRUE if it filled in the string, FALSE if it did not
Notes: The base class returns FALSE (i.e. provides no help) If you can provide help, then override the base class method to do so.

See also:
SGDisplayNode::GetBubbleHelp

Reimplemented from SGDisplayNode.

Definition at line 1757 of file sgfonts.cpp.

01758 {
01759     ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01760 
01761     // "'<FontName>'; Click, then use the Deinstall button to remove font"
01762     Result->MakeMsg(_R(IDS_FONTS_INSTALLED_STATUS), ((TCHAR *)(*GetDisplayedTextDescription())));
01763 
01764     return(TRUE);
01765 }

BOOL SGDisplayPreviewFonts::GetThumbnailDetails INT32  Mode,
UINT32 X,
UINT32 Y,
String_256 Text
[static]
 

Quick way of returning size and information details regarding the font preview thumbnails.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95
Parameters:
Mode - Mode of display (Small, medium, large -> 0-2) [INPUTS] X - Location for return of X size (pixels) Y - Location for return of Y size (pixels) Text - Pointer to font name (used in full info mode)
Returns:
Text - Text to use as for thumbnail
Parameters:
Returns TRUE if things went OK. [OUTPUTS]

Definition at line 1539 of file sgfonts.cpp.

01540 {
01541     if(X == NULL || Y == NULL) return FALSE;
01542 
01543     switch(Mode)
01544     {
01545         case 0:                     // Large (Normal)
01546             *X = SGF_NORMAL_X;
01547             *Y = SGF_NORMAL_Y;
01548             if(Text != NULL)
01549                 *Text = _R(IDS_LARGEFONTDISPLAYSTRING);
01550             break;
01551 
01552         case 1:                     // Full info
01553             *X = SGF_FULL_X;
01554             *Y = SGF_FULL_Y;
01555             // Text inserted beforehand
01556             //if(Text != NULL) *Text = _R(IDS_FONTS_GALLERY_LARGE_TEXT);
01557             break;
01558 
01559         case 2:                     // Small (with description)
01560             *X = SGF_SMALL_X;
01561             *Y = SGF_SMALL_Y;
01562             if(Text != NULL) *Text = _R(IDS_FONTS_GALLERY_SMALL_TEXT);
01563             break;
01564 
01565         case 3:                     // Small (with no description)
01566             *X = SGF_FULL_X;
01567             *Y = SGF_FULL_Y;
01568             //if(Text != NULL) *Text = _R(IDS_FONTS_GALLERY_SMALL_TEXT);
01569             break;
01570 
01571         case 4:                     // No icon mode...
01572             *X = 0;
01573             *Y = 0;
01574             break;
01575 
01576     }
01577 
01578     return TRUE;
01579 }       

BOOL SGDisplayPreviewFonts::HandleEvent SGEventType  EventType,
void *  EventInfo,
SGMiscInfo MiscInfo
[virtual]
 

Handles a SuperGallery DisplayTree event.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
EventType - An enumerated value describing what type of event is to be processed [INPUTS]
EventInfo - A structure describing the event (may be NULL). The exact thing pointed at by this pointer depends upon the event type:

MonoOn Event Thing EventInfo points at SGEVENT_FORMAT (SGFormatInfo *) SGEVENT_REDRAW (SGRedrawInfo *) SGEVENT_MOUSECLICK (SGMouseInfo *) MonoOff Use the provided SGDisplayNode::Get[Format]Info() inlines to retrieve this information - they provide useful error/type checking, and hide the cast

MiscInfo - always provided. Contains a few useful bits of info that may be needed for all event types.

Parameters:
FormatInfo is updated as appropriate [OUTPUTS]
Returns:
TRUE if the event was handled successfully FALSE if it was not
Notes: This overrides the pure virtual SGDisplayNode::HandleEvent method

A node need not handle a specific event - if it does not handle it, it should return FALSE.

Redraw and Formatting handlers should never return TRUE, as this will prevent the event from continuing through the tree.

Non-leaf-nodes must call SGDisplayNode::GiveEventToMyChildren in order to pass the event dow the tree. THIS node is a leaf-node, so it doesn't.

See also:
SGDisplayNode::HandleEvent

Reimplemented from SGDisplayItem.

Definition at line 1411 of file sgfonts.cpp.

01412 {
01413     switch (EventType)
01414     {
01415         case SGEVENT_FORMAT:
01416             {
01417                 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
01418                 CalculateMyRect(FormatInfo, MiscInfo);      // Cache our FormatRect for later use
01419             }
01420             break;
01421 
01422 
01423         case SGEVENT_REDRAW:
01424             {
01425                 DocRect MyRect(FormatRect);     // Rely on FormatRect being cached from above
01426                 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
01427 
01428                 RedrawInfo->Renderer->SaveContext();
01429 
01430                 if (IMustRedraw(RedrawInfo))    // only redraw if we intersect the clip rect
01431                     HandleRedraw(RedrawInfo, MiscInfo);
01432 
01433                 RedrawInfo->Renderer->RestoreContext();
01434             }
01435             break;      // exit and return FALSE to pass the redraw event on
01436 
01437 
01438         case SGEVENT_MOUSECLICK:
01439             {
01440                 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
01441 
01442                 if (FormatRect.ContainsCoord(Mouse->Position))
01443                 {
01444                     if(Mouse->DoubleClick)
01445                         DefaultClickHandler(Mouse, MiscInfo);
01446                     else
01447                     {
01448                         DefaultPreDragHandler(Mouse, MiscInfo);
01449 
01450                         // Grab a copy of the bitmap required for dragging
01451                         GalleryFontsDragInfo *DragFont;
01452                         KernelBitmap *DispBmp = GetDisplayedKernelBitmap(MiscInfo, TRUE);
01453                         if(DispBmp)
01454                         {
01455                             LibraryGallery::TmpDraggingBitmap = DIBUtil::CopyKernelBitmap(DispBmp, TRUE);
01456                             DragFont = new GalleryFontsDragInfo(this, Mouse, MiscInfo,
01457                                                                 Mouse->MenuClick, 0, 0);
01458                         }
01459                         else
01460                         {
01461                             // Null rectangle - give a specific size
01462                             LibraryGallery::TmpDraggingBitmap = NULL;
01463 
01464                             // Get the relevant size details for the current mode (pixels)
01465                             UINT32 XSize = SG_InfiniteWidth;
01466                             UINT32 YSize = SG_DefaultLargeIcon;
01467                             INT32 DisplayMode = MiscInfo->DisplayMode;
01468                             SGDisplayPreviewFonts::GetThumbnailDetails(DisplayMode, &XSize, &YSize, NULL);
01469 
01470                             if(XSize == 0 || YSize == 0)
01471                             {
01472                                 XSize = SGF_SMALL_X;
01473                                 YSize = SGF_SMALL_Y;
01474                             }
01475 
01476                             // Create the drag object...
01477                             DragFont = new GalleryFontsDragInfo(this, Mouse, MiscInfo,
01478                                                                 Mouse->MenuClick, XSize, YSize);
01479                         }
01480 
01481                         if (DragFont != NULL)
01482                             DragManagerOp::StartDrag(DragFont, GetListWindow());
01483                     }
01484                     return(TRUE);       // Claim this event - nobody else can own this click
01485                 }
01486             }
01487             break;
01488 
01489         default:
01490             return SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo);
01491     }
01492 
01493     // Default return value: We do not claim this event, so it will be passed on to others
01494     return FALSE;
01495 }

void SGDisplayPreviewFonts::HandleRedraw SGRedrawInfo RedrawInfo,
SGMiscInfo MiscInfo
[protected, virtual]
 

SGDisplayPreviewFonts item redraw method - removed from the main HandleEvent method merely to make the code tidier.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
RedrawInfo - The information on the kernel-rendered redraw area [INPUTS] FormatInfo - The formatting information structure
member variable FormatRect should be set up (before calling this method) to be the rectangle in which to draw this item

If the item has a null preview bitmap, but all the info required to generate a bitmap, then we go ahead and generate the bitmap ourselves and cache it with the item.

Scope: private

Definition at line 1051 of file sgfonts.cpp.

01052 {
01053     // First, inform the system that we are about to start rendering this item
01054     StartRendering(RedrawInfo, MiscInfo);
01055 
01056     RenderRegion *Renderer = RedrawInfo->Renderer;
01057     INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1);
01058     Renderer->SetLineWidth(0);
01059     Renderer->SetLineColour(RedrawInfo->Transparent);
01060 
01061     LibDisplayType DType = GetDisplayType(MiscInfo);
01062 
01063     // Exclude the 'TTF' / 'ATM' bmp space from the Format Rect, so as not to confuse things
01064     DocRect NewFormatRect(FormatRect);
01065 
01066     // Space for icon
01067     NewFormatRect.lo.x += (SGF_TYPE_WIDTH * OnePixel);
01068 
01069     GridLockRect(MiscInfo, &NewFormatRect);
01070 
01071     DocRect TypeRect(FormatRect);
01072     TypeRect.hi.x = NewFormatRect.lo.x;
01073 
01074     DrawTypeIcon(RedrawInfo, MiscInfo, &TypeRect, Type);
01075 
01076     // Use NewFormatRect from here on...
01077     DocRect BmpRect(NewFormatRect);
01078     DocRect UnscaledRect(NewFormatRect);
01079 
01080     if(DType == LibDisplay_JustText)
01081     {
01082         // No bitmap, so don't reserve much space for it...
01083         BmpRect.hi.x = BmpRect.lo.x + OnePixel;
01084     }
01085     else
01086     {
01087 
01088         UINT32 XSize = 0;
01089         UINT32 YSize = 0;
01090         DMode = MiscInfo->DisplayMode;
01091 
01092         // Get the relevant size details for the current mode (pixels)
01093         GetThumbnailDetails(DMode, &XSize, &YSize, NULL);
01094     
01095         // Convert pixels to millipoints
01096         XSize *= OnePixel;
01097 
01098         // Thumbnail rectangle... space around edges but don't scale thumbnail
01099         BmpRect.hi.x = BmpRect.lo.x + XSize + (6 * OnePixel);
01100 
01101         // Space for selection rectangle
01102         BmpRect.Inflate(-(OnePixel * 3));
01103 
01104         // Ensure it maps exactly to specific pixels
01105         GridLockRect(MiscInfo, &BmpRect);
01106 
01107         // Draw bmp outline it if selected
01108         if (Flags.Selected)
01109         {   
01110             if(BmpRect.hi.x > UnscaledRect.hi.x) BmpRect.hi.x = UnscaledRect.hi.x;
01111   
01112             BmpRect.Inflate(OnePixel * 3);
01113             GridLockRect(MiscInfo, &BmpRect);       // Ensure we're on a pixel
01114             DrawSelectionOutline(RedrawInfo, MiscInfo, &BmpRect);
01115 
01116             BmpRect.Inflate(-(OnePixel * 3));
01117         }
01118 
01119         // Not drawn a bitmap yet
01120         BOOL DrawnBitmap = FALSE;
01121 
01122         // The thumbnail drawing section...
01123         if(Library::BackgroundRedraw && DType != LibDisplay_JustText)
01124         {
01125             // Try to draw the thumb from cache. If it's not available in the cache, then
01126             // we'll register for background redraw and draw the blank box. Note that
01127             // ShouldIDraw... will also force us to always draw the thumb for selected items etc
01128             DrawnBitmap = DrawThumb(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, FALSE);
01129 
01130             if (ShouldIDrawForeground(DrawnBitmap))
01131             {
01132                 if (!DrawnBitmap)
01133                 {
01134                     // We failed to draw anything before, so we must try again, forcing the thumb to
01135                     // be cached if it is necessary - if this fails we draw a crossed box
01136                     if (!DrawThumb(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, TRUE))
01137                         SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &BmpRect, FALSE);
01138                 }
01139             }
01140             else
01141             {
01142                 if (!DrawnBitmap)
01143                 {
01144                     // We should background render, so we just draw a blank grey box
01145                     SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &BmpRect, TRUE);
01146                 }
01147             }
01148         }
01149         else
01150         {
01151             // We're not doing this background stuff... Force a thumbnail to be drawn right this second !
01152             if (!DrawThumb(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, TRUE))
01153                 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &BmpRect, FALSE);
01154         }
01155     }
01156 
01157     // Draw the text
01158     DrawItemText(Renderer, RedrawInfo, MiscInfo, &UnscaledRect, &BmpRect, Flags.Selected);
01159 
01160     // Finally, inform the system that we have completed rendering this item
01161     StopRendering(RedrawInfo, MiscInfo);
01162 
01163 }

BOOL SGDisplayPreviewFonts::IsFontBeingUsed void   ) 
 

void SGDisplayPreviewFonts::MoveAfter SGDisplayNode NodeToMove  )  [protected, virtual]
 

MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/3/95
Parameters:
NodeToMove - the node to move [INPUTS]
Notes: This base class method simply delinks the item and relinks it elsewhere in the display tree. However, derived classes will override this method so that moving display items can have a further effect of also rearranging the displayed "real" items. Before/After moving the real item, the derived class can then call this baseclass method to complete the action.

Take care when moving items between groups (e.g. if an item is "moved" from one docuemnt to another, it could be a bad thing, so be very careful in derived classes to take appropriate action)

Any attempt to move an item after *itself* is quietly ignored

Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SuperGallery; SGDisplayColour::InsertAfter; SGDisplayColour::AddItem

Reimplemented from SGDisplayNode.

Definition at line 1647 of file sgfonts.cpp.

01648 {
01649     SGDisplayNode::MoveAfter(NodeToMove);
01650 }

void SGDisplayPreviewFonts::MoveBefore SGDisplayNode NodeToMove  )  [protected, virtual]
 

MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/3/95
Parameters:
NodeToMove - the node to move [INPUTS]
Notes: This base class method simply delinks the item and relinks it elsewhere in the display tree. However, derived classes will override this method so that moving display items can have a further effect of also rearranging the displayed "real" items. Before/After moving the real item, the derived class can then call this baseclass method to complete the action.

Take care when moving items between groups (e.g. if an item is "moved" from one docuemnt to another, it could be a bad thing, so be very careful in derived classes to take appropriate action)

Any attempt to move an item before *itself* is queitly ignored

Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SuperGallery; SGDisplayColour::InsertBefore; SGDisplayColour::AddItem

Reimplemented from SGDisplayNode.

Definition at line 1685 of file sgfonts.cpp.

01686 {
01687     SGDisplayNode::MoveBefore(NodeToMove);
01688 }


Member Data Documentation

LOGFONT* SGDisplayPreviewFonts::CachedLogFont
 

Definition at line 257 of file sgfonts.h.

INT32 SGDisplayPreviewFonts::DMode [static]
 

Definition at line 251 of file sgfonts.h.

KernelBitmap* SGDisplayPreviewFonts::FontBitmap
 

Definition at line 242 of file sgfonts.h.

String_64 SGDisplayPreviewFonts::FontDescription
 

Definition at line 243 of file sgfonts.h.

UINT32 SGDisplayPreviewFonts::ID
 

Definition at line 248 of file sgfonts.h.

INT32 SGDisplayPreviewFonts::IntLeading
 

Definition at line 258 of file sgfonts.h.

BOOL SGDisplayPreviewFonts::Invalid
 

Definition at line 261 of file sgfonts.h.

FontClass SGDisplayPreviewFonts::Type
 

Definition at line 254 of file sgfonts.h.


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