SGDisplayKernelBitmap Class Reference

This DisplayTree node is used by the Bitmap SuperGallery It is responsible for providing the ability to handle/redraw one KernelBitmap displayed in said gallery. More...

#include <sgbitmap.h>

Inheritance diagram for SGDisplayKernelBitmap:

SGDisplayItem SGDisplayNode CCObject SimpleCCObject List of all members.

Public Member Functions

 SGDisplayKernelBitmap ()
 SGDisplayKernelBitmap constructor DON'T call this constructor. It ERROR3's. Call the other constructor.
 SGDisplayKernelBitmap (KernelBitmap *KernelBitmapToDisplay)
 SGDisplayKernelBitmap constructor.
virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event.
virtual 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)
 To determine a name string for this node. Generally, this is used for a simple mechanism which searches for display items whose names match given search parameters in some way. It is also used in libraries to provide default redraw methods.
virtual void GetFullInfoText (String_256 *Result)
 To determine a full-info string for this node. Generally, this is used for a simple mechanism which searches for display items whose info matches given search parameters in some way. It is also used in libraries to provide default redraw methods.
virtual 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.
virtual 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.
virtual 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.
KernelBitmapGetDisplayedKernelBitmap (void)
 To find out the KernelBitmap this object is responsible for displaying.

Protected Member Functions

virtual void CalculateMyRect (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
 Shared code for KernelBitmap items to calculate where they will appear in the grand scheme of things.
virtual void HandleRedraw (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
 SGDisplayKernelBitmap item redraw method - removed from the main HandleEvent method merely to make the code tidier.

Private Member Functions

 CC_DECLARE_DYNAMIC (SGDisplayKernelBitmap)

Private Attributes

KernelBitmapTheKernelBitmap

Detailed Description

This DisplayTree node is used by the Bitmap SuperGallery It is responsible for providing the ability to handle/redraw one KernelBitmap displayed in said gallery.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
27/01/95
See also:
BitmapSGallery; SuperGallery; SGDisplayItem

Definition at line 214 of file sgbitmap.h.


Constructor & Destructor Documentation

SGDisplayKernelBitmap::SGDisplayKernelBitmap  ) 
 

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

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)

Definition at line 599 of file sgbitmap.cpp.

00600 {
00601     ERROR3("Illegal call on default SGDisplayKernelBitmap constructor - call the other one!");
00602     TheKernelBitmap = NULL;
00603 }

SGDisplayKernelBitmap::SGDisplayKernelBitmap KernelBitmap KernelBitmapToDisplay  ) 
 

SGDisplayKernelBitmap constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
KernelBitmapToDisplay - The KernelBitmap this item will display [INPUTS]

Definition at line 619 of file sgbitmap.cpp.

00620 {
00621     ERROR3IF(KernelBitmapToDisplay == NULL,
00622                 "SGDisplayKernelBitmap - trying to construct me with a NULL parameter is bad");
00623 
00624     TheKernelBitmap = KernelBitmapToDisplay;
00625 }


Member Function Documentation

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

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

Author:
Will_Cowling (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 KernelBitmap 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: KernelBitmaps supply only one display mode ("full info")

Scope: private (for use of SGDisplayKernelBitmap class only)

Definition at line 655 of file sgbitmap.cpp.

00656 {
00657     INT32 XSize;
00658     INT32 YSize;
00659 
00660     switch (MiscInfo->DisplayMode)
00661     {
00662         case 1:                     // 1 - Small full info
00663             XSize = GridLock(MiscInfo, SG_InfiniteWidth);
00664             YSize = GridLock(MiscInfo, SG_DefaultSmallBmp);
00665             break;
00666 
00667         case 2:                     // 2 - Large icon with name
00668             XSize = GridLock(MiscInfo, SG_DefaultLargeBmpText);
00669             YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00670             break;
00671 
00672         default:                    // 0 - Full Info
00673             XSize = GridLock(MiscInfo, SG_InfiniteWidth);
00674             YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00675             break;
00676     }
00677 
00678     BitmapInfo Info;
00679     INT32 MaxYSize = YSize;
00680 
00681     if (TheKernelBitmap->ActualBitmap &&
00682         TheKernelBitmap->ActualBitmap->GetInfo( &Info )
00683         )
00684     {
00685         // We will adjust the Height of the format rect
00686         // according to the Height of the bitmap.
00687 
00688         double BitmapWidth  = Info.RecommendedWidth;
00689         double BitmapHeight = Info.RecommendedHeight;
00690 
00691         // Calculate the spect ratio of the bitmap
00692         double Ratio = BitmapHeight/BitmapWidth;
00693 
00694         YSize = INT32(YSize * Ratio);
00695 
00696         // ... set a minimum height for each item
00697         INT32 SelHeight = 16000;
00698 
00699         if (YSize < SelHeight*3)
00700             YSize = SelHeight*3;
00701 
00702         if (YSize > MaxYSize)
00703             YSize = MaxYSize;
00704     }
00705 
00706     CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00707 }

SGDisplayKernelBitmap::CC_DECLARE_DYNAMIC SGDisplayKernelBitmap   )  [private]
 

void SGDisplayKernelBitmap::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:
19/3/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:
SGDisplayKernelBitmap::HandleEvent; GalleryBitmapDragInfo::OnClick

Reimplemented from SGDisplayNode.

Definition at line 1265 of file sgbitmap.cpp.

01266 {
01267     // Just get default selection action to be applied for this click
01268     DefaultClickHandler(Mouse, MiscInfo, TRUE);
01269 }

KernelBitmap * SGDisplayKernelBitmap::GetDisplayedKernelBitmap void   )  [inline]
 

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

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
27/1/95
Returns:
A pointer to the KernelBitmap which this Display Item is used to display.

Definition at line 269 of file sgbitmap.h.

00270 {
00271     return(TheKernelBitmap);
00272 }

void SGDisplayKernelBitmap::GetFullInfoText String_256 Result  )  [virtual]
 

To determine a full-info string for this node. Generally, this is used for a simple mechanism which searches for display items whose info matches given search parameters in some way. It is also used in libraries to provide default redraw methods.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
On exit, the string pointed at by Result will contain either a blank [OUTPUTS] string, or the full-information text associated with this item (if any)
See also:
SGDisplayKernelBitmap::GetNameText

Reimplemented from SGDisplayNode.

Definition at line 1440 of file sgbitmap.cpp.

01441 {
01442     ERROR3IF(Result == NULL, "Illegal NULL param");
01443 
01444     *Result = TheKernelBitmap->ActualBitmap->GetName();
01445 }

void SGDisplayKernelBitmap::GetNameText String_256 Result  )  [virtual]
 

To determine a name string for this node. Generally, this is used for a simple mechanism which searches for display items whose names match given search parameters in some way. It is also used in libraries to provide default redraw methods.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
On exit, the string pointed at by Result will contain either a blank [OUTPUTS] string, or the name text associated with this item (if any)
See also:
SGDisplayKernelBitmap::GetFullInfoText

Reimplemented from SGDisplayNode.

Definition at line 1412 of file sgbitmap.cpp.

01413 {
01414     ERROR3IF(Result == NULL, "Illegal NULL param");
01415 
01416     *Result = TheKernelBitmap->ActualBitmap->GetName();
01417 }

BOOL SGDisplayKernelBitmap::GetStatusLineHelp DocCoord MousePos,
String_256 Result
[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:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/7/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.

Reimplemented from SGDisplayNode.

Definition at line 1599 of file sgbitmap.cpp.

01600 {
01601     ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01602 
01603     String_256 Name;
01604     GetNameText(&Name);
01605 
01606     // "'Bitmapname'"
01607     Result->MakeMsg(_R(IDS_SGBITMAP_STATLINE), (TCHAR *)Name);
01608 
01609     /* Double click, or drag and drop to apply as a fill*/
01610     *Result += String_256(_R(IDS_SGBITMAP_DOUBLE_CLICK)); //"; Double click, or drag and drop to apply this bitmap");
01611 
01612     return(TRUE);
01613 }

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

Handles a SuperGallery DisplayTree event.

Author:
Will_Cowling (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 1318 of file sgbitmap.cpp.

01320 {
01321     switch (EventType)
01322     {
01323         case SGEVENT_FORMAT:
01324             {
01325                 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
01326                 CalculateMyRect(FormatInfo, MiscInfo);      // Cache our FormatRect for later use
01327             }
01328             break;
01329 
01330 
01331         case SGEVENT_REDRAW:
01332             {
01333                 DocRect MyRect(FormatRect);     // Rely on FormatRect being cached from above
01334                 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
01335 
01336                 if (IMustRedraw(RedrawInfo))    // only redraw if we intersect the clip rect
01337                      HandleRedraw(RedrawInfo, MiscInfo);
01338             }
01339             break;      // exit and return FALSE to pass the redraw event on
01340 
01341 
01342         case SGEVENT_MOUSECLICK:
01343             {
01344                 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
01345 
01346                 if (FormatRect.ContainsCoord(Mouse->Position))
01347                 {
01348                     // If the colour is in the selected document, then it is safe to
01349                     // do a colour drag - for now, it will only allow drags for the
01350                     // selected doc.
01351                     // Otherwise, the normal click action takes place.
01352                     // If the drag fails (turns into a click) then the normal click action
01353                     // takes place, passed on by the GalleryColourDragInfo::OnClick handler
01354 //                  SGDisplayGroup *Parent = (SGDisplayGroup *) GetParent();
01355 
01356                     if (Mouse->DoubleClick) // || Parent->GetParentDocument() != Document::GetSelected())
01357                     {
01358                         // Send bitmap to Xara Photo Editor
01359 /*                      OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_XPE_EDIT);
01360                         if (pOpDesc)
01361                         {
01362                             pOpDesc->Invoke();
01363                             return TRUE;
01364                         }
01365                         else
01366 */
01367                             DefaultClickHandler(Mouse, MiscInfo);
01368                     }
01369                     else
01370                     {
01371                         DefaultPreDragHandler(Mouse, MiscInfo);
01372 
01373                         GalleryBitmapDragInfo *DragBmp;
01374                         DragBmp = new GalleryBitmapDragInfo(this, Mouse, MiscInfo,
01375                                                             Mouse->MenuClick);
01376                         if (DragBmp != NULL)
01377                             DragManagerOp::StartDrag(DragBmp, GetListWindow());
01378                     }
01379 
01380                     return(TRUE);       // Claim this event - nobody else can own this click
01381                 }
01382             }
01383             break;
01384 
01385         default:
01386             return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
01387     }
01388 
01389     // Default return value: We do not claim this event, so it will be passed on to others
01390     return(FALSE);
01391 }

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

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

Author:
Will_Cowling (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

Scope: private

Definition at line 732 of file sgbitmap.cpp.

00733 {
00734     if (TheKernelBitmap == NULL || TheKernelBitmap->ActualBitmap == NULL)
00735         return;
00736 
00737     StartRendering(RedrawInfo, MiscInfo);
00738 
00739     DocRect MyRect(FormatRect);     // Get my redraw position from the cached FormatRect
00740 
00741 
00742     // Is this a valid format rectangle ?
00743     if (MyRect.IsEmpty() || !MyRect.IsValid())
00744     {
00745         // No, so just ignore it
00746         // Erroring here is not good, as we are in the middle of a redraw loop
00747         StopRendering(RedrawInfo, MiscInfo);
00748         return;
00749     }
00750 
00751     // Check the rectangle is at least our minimum height,
00752     // and adjust it if not
00753     //INT32 SelHeight = 16000; 
00754     // Changed to allow a third line of text.
00755     INT32 SelHeight = 23000; 
00756 
00757     if (MyRect.Height() < SelHeight*3)
00758     {
00759         INT32 diff = SelHeight*3 - MyRect.Height();
00760         MyRect.Inflate(0, diff);
00761     }
00762 
00763     RenderRegion *Renderer = RedrawInfo->Renderer;
00764 
00765     INT32 OnePixel          = (INT32) DevicePixels(MiscInfo, 1);
00766     INT32 TwoPixels         = (INT32) DevicePixels(MiscInfo, 2);
00767     INT32 ThreePixels   = (INT32) DevicePixels(MiscInfo, 3);
00768 
00769     Renderer->SetLineWidth(0);
00770     Renderer->SetLineColour(RedrawInfo->Transparent);
00771 
00772     // Now calculate the rectangle to plot the bitmap into
00773     DocRect IconRect(MyRect);
00774 
00775     BitmapInfo Info;
00776 
00777     BOOL bScaleDown = FALSE;
00778 
00779     if (TheKernelBitmap->ActualBitmap &&
00780         TheKernelBitmap->ActualBitmap->GetInfo( &Info ))
00781     {
00782         // We will try and make all the bitmaps the same width on screen.
00783         double BitmapWidth  = Info.RecommendedWidth;
00784         double BitmapHeight = Info.RecommendedHeight;
00785 
00786         // Calculate the spect ratio of the bitmap
00787         double Ratio = BitmapWidth/BitmapHeight;
00788 
00789         INT32 IconWidth = INT32(IconRect.Height() * Ratio);
00790 
00791         INT32 YSize;
00792         switch (MiscInfo->DisplayMode)
00793         {
00794             case 1:                     // 1 - Small full info
00795                 YSize = GridLock(MiscInfo, SG_DefaultSmallBmp);
00796                 break;
00797 
00798             case 2:                     // 2 - Large icon with name
00799                 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00800                 break;
00801 
00802             default:                    // 0 - Full Info
00803                 YSize = GridLock(MiscInfo, SG_DefaultLargeBmp);
00804                 break;
00805         }
00806         
00807         // If the bitmap is very Wide and Thin, then we need to scale it
00808         // so it fits into out maximum icon width
00809         if (IconWidth > YSize)
00810         {
00811             Matrix Scale;
00812             Ratio = double(IconWidth)/double(YSize);
00813 
00814             Scale = Matrix(FIXED16(1)/Ratio, FIXED16(1)/Ratio);
00815 
00816             DocCoord Centre;
00817             Centre.x = IconRect.lo.x;
00818             Centre.y = IconRect.lo.y + IconRect.Height()/2;
00819 
00820             // Scale the bitmap rectangle about the Left Middle so
00821             // that it is always 'YSize' in Width
00822             IconRect.Translate(-Centre.x, -Centre.y);
00823             Scale.transform(&IconRect.lo);
00824             Scale.transform(&IconRect.hi);
00825             IconRect.Translate(Centre.x, Centre.y);
00826 
00827             IconWidth = YSize;
00828             bScaleDown = TRUE;
00829         }
00830 
00831         INT32 RightSpace = 0;
00832 
00833         if (IconWidth < YSize)
00834         {
00835             INT32 LeftSpace = TwoPixels * 4;
00836             RightSpace = YSize - IconWidth - LeftSpace;
00837             IconRect.Translate(LeftSpace, 0);   // Move it over a bit
00838         }
00839 
00840         // Now setup the IconRect
00841         IconRect.hi.x = IconRect.lo.x + IconWidth;
00842 
00843         MyRect.lo.x = IconRect.hi.x + RightSpace + TwoPixels;   // And exclude it from 'MyRect'
00844         MyRect.lo.x += TwoPixels;
00845 
00846         // Now check the Icon isn't too tall
00847 
00848         INT32 MaxYSize = YSize;
00849         INT32 IconHeight = IconRect.Height();
00850         if (IconHeight > MaxYSize)
00851         {
00852             Matrix Scale;
00853             Ratio = double(IconHeight)/double(YSize);
00854 
00855             Scale = Matrix(FIXED16(1)/Ratio, FIXED16(1)/Ratio);
00856 
00857             DocCoord Centre;
00858             Centre.x = IconRect.lo.x + IconRect.Width()/2;
00859             Centre.y = IconRect.hi.y;
00860 
00861             // Scale the bitmap rectangle about the Middle so
00862             // that it is always 'YSize' in Height
00863             IconRect.Translate(-Centre.x, -Centre.y);
00864             Scale.transform(&IconRect.lo);
00865             Scale.transform(&IconRect.hi);
00866             IconRect.Translate(Centre.x, Centre.y);
00867 
00868             MyRect.lo.y = IconRect.lo.y;
00869             MyRect.hi.y = IconRect.hi.y;
00870             bScaleDown = TRUE;
00871         }
00872     }
00873 
00874     // This section doesn't currently do anything special as we 
00875     // have gone back to using an OSRenderRegion
00876     // If the display quality is too bad then we should modify 
00877     // this code to render a high quality thumbnail and store it 
00878     // for future use, rendering the thumbnail into an OSRenderRegion
00879 /*  Renderer->SetUsingSmoothedBitmaps(bScaleDown);
00880     if (bScaleDown)
00881     {
00882         Quality qual;
00883         qual.SetQuality(QUALITY_MAX);
00884         QualityAttribute *pQuality = new QualityAttribute(qual);
00885         Renderer->SetQuality(pQuality, TRUE);           // Temp
00886     }
00887     else
00888     {
00889         Quality qual;   // QUALITY_DEFAULT is implied
00890         QualityAttribute *pQuality = new QualityAttribute(qual);
00891         Renderer->SetQuality(pQuality, TRUE);           // Temp
00892     }*/
00893 
00894     GridLockRect(MiscInfo, &MyRect);    // Ensure the new 'MyRect' is pixel-grid-aligned
00895 
00896     // If we can, we need to leave a little space around the
00897     // edges of the bitmap rect, so we can see the 'Selected' rectangle
00898     // behind it.  We only try this if the rectangle is big enough
00899     // otherwise the Inflate routine will create an invalid rectangle.
00900 
00901     if (IconRect.Height() > ThreePixels * 2)
00902         IconRect.Inflate(0, -ThreePixels);      // Leave a bit of space around the edge
00903 
00904     if (IconRect.Width() > ThreePixels * 2)
00905         IconRect.Inflate(-ThreePixels, 0);      // Leave a bit of space around the edge
00906     
00907     GridLockRect(MiscInfo, &IconRect);  // Ensure it maps exactly to specific pixels
00908 
00909     // Need to remember the icon rect size before the selection rectangle takes over...
00910     DocRect ThumbnailRect(IconRect);
00911 
00912     // In the bitmap gallery, it's better to show something than nothing
00913     // So if the thumbnail has become so thin as to be invisible
00914     // We will bodge it back into shape even if that distorts things a bit
00915     if (ThumbnailRect.Width()==0)
00916         ThumbnailRect.hi.x = ThumbnailRect.lo.x + OnePixel;
00917     if (ThumbnailRect.Height()==0)
00918         ThumbnailRect.hi.y = ThumbnailRect.lo.y + OnePixel;
00919 
00920     // Set up the colours for rendering our text, and fill the background if selected
00921     if (Flags.Selected)
00922     {
00923         // This Item is Selected
00924 
00925         // Fill the entire background with the 'selected' colour, so we don't
00926         // get gaps between bits of text or uneven rectangles in multiple selections
00927         Renderer->SetFillColour(RedrawInfo->SelBackground);
00928 
00929         Renderer->SetFillColour(COLOUR_BLACK);
00930         IconRect.Inflate(ThreePixels);
00931 
00932         // Draw a Three Pixel wide rectangle around the edge of the bitmap
00933         // (Actually we're plotting a filled rectangle which is three pixels
00934         //  bigger than the bitmap rectangle)
00935         Renderer->DrawRect(&IconRect);
00936 
00937         // If the icon rect is wider than the gallery, then MyRect could have become invalid,
00938         // so we only try to draw the selection background if any of it is actually visible
00939         if (MyRect.IsValid())
00940         {
00941             DocRect SelRect(MyRect);
00942             if (SelHeight > MyRect.Height()/2)
00943                 SelHeight = MyRect.Height()/2;
00944 
00945             SelRect.hi.y = MyRect.lo.y + MyRect.Height()/2 + SelHeight;
00946             SelRect.lo.y = MyRect.lo.y + MyRect.Height()/2 - SelHeight;
00947             SelRect.lo.x += ThreePixels;
00948             GridLockRect(MiscInfo, &SelRect);   // Ensure it maps exactly to specific pixels
00949 
00950             Renderer->SetFillColour(RedrawInfo->SelBackground);
00951             Renderer->DrawRect(&SelRect);
00952         }
00953 
00954         Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
00955     }
00956     else
00957     {
00958         // This Item is Not Selected
00959         Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background);
00960     }
00961 
00962 
00963 #ifdef SGBITMAP_BACKGROUND_REDRAW
00964 
00965     BOOL DrawnBitmap = FALSE;
00966 
00967     if (ShouldIDrawForeground(DrawnBitmap))
00968     {
00969         if(!DrawnBitmap)
00970         {
00971             // Now we need to create a temporary NodeBitmap, which we will
00972             // use to render the bitmap preview.
00973             NodeBitmap* DummyBmp = new NodeBitmap();
00974             if (DummyBmp == NULL)
00975             {
00976                 // Just exit if we're out of memory
00977                 SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &ThumbnailRect, FALSE);
00978                 StopRendering(RedrawInfo, MiscInfo);
00979                 return;
00980             }
00981 
00982             // Set the NodeBitmap path to be our IconRect, 
00983             // and attach the Bitmap to it.
00984             DummyBmp->SetUpPath();
00985             DummyBmp->CreateShape(ThumbnailRect);
00986             DummyBmp->GetBitmapRef()->SetBitmap(TheKernelBitmap);
00987 
00988             // Now render the bitmap preview
00989             DummyBmp->Render(Renderer);
00990 
00991             delete DummyBmp;
00992         }
00993     }
00994     else
00995     {
00996         // We should background render, so we just draw a blank grey box
00997         if(!DrawnBitmap)
00998             SGLibDisplayItem::DrawNullBitmapRect(Renderer, MiscInfo, &ThumbnailRect, TRUE);
00999     }
01000 
01001 #else
01002 
01003     // Now we need to create a temporary NodeBitmap, which we will
01004     // use to render the bitmap preview.
01005     NodeBitmap* DummyBmp = new NodeBitmap();
01006     if (DummyBmp == NULL)
01007     {
01008         // Just exit if we're out of memory
01009         StopRendering(RedrawInfo, MiscInfo);
01010         return;
01011     }
01012 
01013     // Set the NodeBitmap path to be our IconRect, 
01014     // and attach the Bitmap to it.
01015     DummyBmp->SetUpPath();
01016     DummyBmp->CreateShape(ThumbnailRect);
01017     DummyBmp->GetBitmapRef()->SetBitmap(TheKernelBitmap);
01018 
01019     // Now render the bitmap preview
01020     DummyBmp->Render(Renderer);
01021 
01022     delete DummyBmp;
01023 
01024 #endif
01025 
01026     // Leave a small gap before text begins
01027     MyRect.lo.x += SG_GapBeforeText*2;
01028 
01029     // And now render the text describing the bitmap
01030     // ...but only if there is any space left (i.e. MyRect is still valid)
01031     if (MyRect.IsValid())
01032     {
01033         // First get the name of the bitmap
01034         String_256 BitmapName = TheKernelBitmap->ActualBitmap->GetName();
01035 
01036         // Now find how many colours it has
01037         String_256 BitmapCols;
01038         INT32 bpp = TheKernelBitmap->GetBPP();
01039 
01040         BOOL HasTransparency = FALSE;
01041         
01042         if (bpp <= 8)
01043         {
01044             // Check to see if this is a masked bitmap
01045             INT32 Index;
01046 
01047             if (TheKernelBitmap->GetTransparencyIndex(&Index))
01048                 HasTransparency = TRUE;
01049         }
01050 
01051         switch (bpp)
01052         {
01053             case 1:
01054                 if (HasTransparency)
01055                     BitmapCols = _R(IDS_SGBITMAP_MONOCHROME_T); // "Monochrome, transparent";
01056                 else
01057                     BitmapCols = _R(IDS_SGBITMAP_MONOCHROME);   // "Monochrome";
01058                 break;
01059 
01060             case 2:
01061                 if (HasTransparency)
01062                     BitmapCols = _R(IDS_SGBITMAP_4COLOURS_T);   // "3 colours, transparent";
01063                 else
01064                     BitmapCols = _R(IDS_SGBITMAP_4COLOURS);     // "4 colours";
01065                 break;
01066 
01067             case 4:
01068                 if (HasTransparency)
01069                     BitmapCols = _R(IDS_SGBITMAP_16COLOURS_T);  // "15 colours, transparent";
01070                 else
01071                     BitmapCols = _R(IDS_SGBITMAP_16COLOURS);    // "16 colours";
01072                 break;
01073 
01074             case 8:
01075                 if (HasTransparency)
01076                     BitmapCols = _R(IDS_SGBITMAP_256COLOURS_T); // "255 colours, transparent";
01077                 else
01078                     BitmapCols = _R(IDS_SGBITMAP_256COLOURS);   // "256 colours";
01079                 break;
01080 
01081             case 16:
01082                 BitmapCols = _R(IDS_SGBITMAP_65COLOURS);        // "65K colours";
01083                 break;
01084 
01085             case 24:
01086                 BitmapCols = _R(IDS_SGBITMAP_MILLIONS_COLOURS); // "Millions of colours";
01087                 break;
01088 
01089             case 32:
01090                 BitmapCols = _R(IDS_SGBITMAP_32_BIT); // "Millions of colours";
01091                 break;
01092 
01093             default:
01094                 BitmapCols = "";
01095                 break;
01096         }
01097 
01098         // Now get its pixel Width and Height
01099         String_256 BitmapWidth;
01100         Convert::LongToString(Info.PixelWidth, &BitmapWidth);
01101         
01102         String_256 BitmapHeight;
01103         Convert::LongToString(Info.PixelHeight, &BitmapHeight);
01104 
01105         // Find the delay value;
01106         UINT32 BitmapDelay = TheKernelBitmap->ActualBitmap->GetBitmapAnimDelay();
01107         String_256 Delay;
01108         Convert::LongToString(BitmapDelay, &Delay);
01109 
01110         // And finally, work out how much memory it is using
01111         // The memory size depends on whether this is a bitmap or JPEG.
01112 
01113         INT32 Bytes = 0;
01114         BitmapSource* pSource = NULL;
01115         BaseBitmapFilter* pDummyFilter;
01116 
01117 PORTNOTE("other", "Removed XPE hook")
01118 #ifndef EXCLUDE_FROM_XARALX
01119         KernelBitmap* pMaster = NULL;
01120         IXMLDOMDocumentPtr pEdits = NULL;
01121         TheKernelBitmap->GetXPEInfo(pMaster, pEdits);
01122         BOOL bIsXPE = (pMaster!=NULL && pEdits!=NULL);
01123 #else
01124         BOOL bIsXPE = FALSE;
01125 #endif
01126 
01127         BOOL OriginalSourcePresent = TheKernelBitmap->GetOriginalSource(&pSource, &pDummyFilter);
01128         String_256 BitmapFormat;
01129         if(OriginalSourcePresent)
01130         {
01131             if (pSource != NULL)
01132             {
01133                 if (pSource->IsJPEG())
01134                 {
01135                     Bytes = pSource->GetSize();
01136                     BitmapFormat = _R(IDS_FORMAT_JPEG);
01137                 }
01138             }
01139         }
01140         else if (bIsXPE)
01141         {
01142             BitmapFormat = _R(IDS_FORMAT_XPE);
01143         }
01144         else
01145         {
01146             Bytes = (Info.PixelWidth * Info.PixelHeight * bpp)/8;
01147             BitmapFormat = _R(IDS_FORMAT_BITMAP);
01148         }
01149 
01150         String_256 MemoryUsed;
01151         Convert::BytesToString(&MemoryUsed, Bytes);
01152 
01153         if (!BaseCamelotFilter::ShouldSaveXPEBitmaps() && bIsXPE)
01154         {
01155             // If the bitmap is generated from a Master and edit list
01156             // Then don't show size in bytes 'cos it's meaningless
01157             MemoryUsed.Load(_R(IDS_SGBITMAP_XPE));
01158         }
01159 
01160         // Now we are going to plot all that information
01161         // split into two lines of text
01162         DocRect TopRect(MyRect);
01163         DocRect MiddleRect(MyRect);
01164         DocRect BottomRect(MyRect);
01165 
01166         //TopRect.lo.y  += 11000;
01167         TopRect.lo.y    += 18000;
01168         MiddleRect.hi.y     -= 5000;
01169         //MiddleRect.hi.y   -= 16000; Down
01170         BottomRect.hi.y -= 26000; 
01171 
01172         // Plot the Name and Memory used on the Top Line
01173         String_256 TopLine; // = "'"+BitmapName+"', "+BitmapFormat", "+MemoryUsed;
01174         TopLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_TOPLINE),(TCHAR *)BitmapName,(TCHAR*)BitmapFormat,(TCHAR *)MemoryUsed);
01175         Renderer->DrawFixedSystemText(&TopLine, TopRect);               
01176 
01177 
01178         // Plot the Dimensions and Colours on the Bottom Line
01179         String_256 MiddleLine; //  = BitmapWidth+" by "+BitmapHeight+" pixels,  "+BitmapCols;
01180 
01181         // Calculate the dpi of the original winbitmap...
01182         UINT32 hdpi = TheKernelBitmap->ActualBitmap->GetHorizontalDPI();
01183         UINT32 vdpi = TheKernelBitmap->ActualBitmap->GetVerticalDPI();
01184 
01185         if (hdpi == vdpi)
01186         {
01187             String_256 dpitext;
01188             Convert::LongToString(hdpi, &dpitext);
01189             MiddleLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_BOTTOMLINE), (TCHAR *)BitmapWidth, (TCHAR *)BitmapHeight, (TCHAR *)BitmapCols, (TCHAR *)dpitext);
01190         }
01191         else
01192         {
01193             String_256 dpitext;
01194             camSnprintf(dpitext, 256, _T("%u x %u"), hdpi, vdpi);
01195             MiddleLine.MakeMsg(_R(IDS_SGBITMAP_FULLINFO_BOTTOMLINE), (TCHAR *)BitmapWidth, (TCHAR *)BitmapHeight, (TCHAR *)BitmapCols, (TCHAR *)dpitext);
01196         }
01197         Renderer->DrawFixedSystemText(&MiddleLine, MiddleRect);             
01198 
01199 
01200         // Find the Restore type 
01201         GIFDisposalMethod RestoreType = TheKernelBitmap->ActualBitmap->GetAnimationRestoreType();
01202         
01203         switch(RestoreType)
01204         {
01205             case GDM_NONE:
01206             {
01207                 String_256 BottomLine;
01208                 String_256 Nothing(_R(IDS_NOTHING));
01209                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Nothing);
01210                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect); 
01211             }
01212             break;
01213             case  GDM_LEAVE:
01214             {
01215                 String_256 BottomLine;
01216                 String_256 Leave(_R(IDS_LEAVE));
01217                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Leave);
01218                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);             
01219             }
01220             break;
01221             case GDM_BACKTOBACK:
01222             {
01223                 String_256 BottomLine;
01224                 String_256 Back(_R(IDS_BACKGROUND));
01225                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Back);
01226                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);             
01227             }
01228             break;
01229             case GDM_PREVIOUS:
01230             {
01231                 String_256 BottomLine;
01232                 String_256 Previous(_R(IDS_PREVIOUS));
01233                 BottomLine.MakeMsg(_R(IDS_SGBITMAP_DELAY_RESTORE_BOTTOMLINE), (TCHAR*)Delay, (TCHAR*)Previous);
01234                 Renderer->DrawFixedSystemText(&BottomLine, BottomRect);             
01235             }
01236             break;
01237 
01238             default:
01239                 break;
01240         }
01241     }
01242 
01243     StopRendering(RedrawInfo, MiscInfo);
01244 }

void SGDisplayKernelBitmap::MoveAfter SGDisplayNode NodeToMove  )  [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:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/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 queitly ignored

Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SGDisplayKernelBitmap::MoveBefore

Reimplemented from SGDisplayNode.

Definition at line 1478 of file sgbitmap.cpp.

01479 {
01480     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01481 
01482     if (NodeToMove == this)
01483         return;
01484 
01485     KernelBitmap *BitmapToMove = ((SGDisplayKernelBitmap *) NodeToMove)->GetDisplayedKernelBitmap();
01486     ERROR3IF(BitmapToMove == NULL, "NULL displayed bitmap?!");
01487 
01488     Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01489     ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01490 
01491     if ( ((SGDisplayGroup *) ( ((SGDisplayKernelBitmap *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01492             ScopeDoc)
01493     {
01494         ERROR2RAW("Attempt to MOVE a bitmap between documents!");
01495         return;
01496     }
01497 
01498     BitmapSGallery::IgnoreBmpListChange = TRUE; 
01499 
01500     // And get the bitmap list
01501     BitmapList* BmpList = ScopeDoc->GetBitmapList();
01502     ERROR3IF(BmpList == NULL, "A document with no bitmap list?!");
01503     
01504     BmpList->MoveAfter(GetDisplayedKernelBitmap(), BitmapToMove);
01505     SGDisplayNode::MoveAfter(NodeToMove);
01506 
01507     BitmapSGallery::IgnoreBmpListChange = FALSE;    
01508 }

void SGDisplayKernelBitmap::MoveBefore SGDisplayNode NodeToMove  )  [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:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/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:
SGDisplayKernelBitmap::MoveBefore

Reimplemented from SGDisplayNode.

Definition at line 1541 of file sgbitmap.cpp.

01542 {
01543     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01544 
01545     if (NodeToMove == this)
01546         return;
01547 
01548     KernelBitmap *BitmapToMove = ((SGDisplayKernelBitmap *) NodeToMove)->GetDisplayedKernelBitmap();
01549     ERROR3IF(BitmapToMove == NULL, "NULL displayed bitmap?!");
01550 
01551     Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01552     ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01553 
01554     if ( ((SGDisplayGroup *) ( ((SGDisplayKernelBitmap *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01555             ScopeDoc)
01556     {
01557         ERROR2RAW("Attempt to MOVE a bitmap between documents!");
01558         return;
01559     }
01560 
01561     BitmapSGallery::IgnoreBmpListChange = TRUE; 
01562 
01563     // And get the bitmap list
01564     BitmapList* BmpList = ScopeDoc->GetBitmapList();
01565     ERROR3IF(BmpList == NULL, "A document with no bitmap list?!");
01566     
01567     BmpList->MoveBefore(GetDisplayedKernelBitmap(), BitmapToMove);
01568 
01569     SGDisplayNode::MoveBefore(NodeToMove);
01570 
01571     BitmapSGallery::IgnoreBmpListChange = FALSE;    
01572 }


Member Data Documentation

KernelBitmap* SGDisplayKernelBitmap::TheKernelBitmap [private]
 

Definition at line 251 of file sgbitmap.h.


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