SGDisplayDATATYPE Class Reference

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

#include <sgbase.h>

Inheritance diagram for SGDisplayDATATYPE:

SGDisplayItem SGDisplayNode CCObject SimpleCCObject List of all members.

Public Member Functions

 SGDisplayDATATYPE ()
 SGDisplayDATATYPE constructor DON'T call this constructor. It ERROR3's. Call the other constructor.
 SGDisplayDATATYPE (DATATYPE *DATATYPEToDisplay)
 SGDisplayDATATYPE constructor.
virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event.
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.
DATATYPE * GetDisplayedDATATYPE (void)
 To find out the DATATYPE this object is responsible for displaying.

Protected Member Functions

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

Private Member Functions

 CC_DECLARE_DYNAMIC (SGDisplayDATATYPE)

Private Attributes

DATATYPE * TheDATATYPE

Detailed Description

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

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

Definition at line 139 of file sgbase.h.


Constructor & Destructor Documentation

SGDisplayDATATYPE::SGDisplayDATATYPE  ) 
 

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

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

Definition at line 161 of file sgbase.cpp.

00162 {
00163     ERROR3("Illegal call on default SGDisplayDATATYPE constructor - call the other one!");
00164     TheDATATYPE = NULL;
00165 }

SGDisplayDATATYPE::SGDisplayDATATYPE DATATYPE *  DATATYPEToDisplay  ) 
 

SGDisplayDATATYPE constructor.

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

Definition at line 182 of file sgbase.cpp.

00183 {
00184     ERROR3IF(DATATYPEToDisplay == NULL,
00185                 "SGDisplayDATATYPE - trying to construct me with a NULL parameter is bad");
00186 
00187     TheDATATYPE = DATATYPEToDisplay;
00188 }


Member Function Documentation

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

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

Author:
Unattributed (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 DATATYPE 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: DATATYPEs supply only one display mode ("full info")

Scope: private (for use of SGDisplayDATATYPE class only)

Definition at line 218 of file sgbase.cpp.

00219 {
00220     INT32 XSize = SG_InfiniteWidth;
00221     INT32 YSize = SG_DefaultLargeIcon;
00222 
00223     // TO DO
00224     // Fill in code to calculate the size you need for your display item, in millipoints.
00225     // Use the SG_ constants defined in sgtree.h where possible, to retain gallery consistency
00226     // This may depend upon the current display mode, as in:
00227     //  switch(MiscInfo->DisplayMode)
00228     //  {
00229     //      case 0:     // Large icons mode
00230     //          XSize = SG_InfiniteWidth;
00231     //          YSize = 100000;
00232     //  }
00233 
00234     CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00235 }

SGDisplayDATATYPE::CC_DECLARE_DYNAMIC SGDisplayDATATYPE   )  [private]
 

DATATYPE * SGDisplayDATATYPE::GetDisplayedDATATYPE void   )  [inline]
 

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

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

Definition at line 185 of file sgbase.h.

00186 {
00187     return(TheDATATYPE);
00188 }

void SGDisplayDATATYPE::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:
Unattributed (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/3/95 (base generated in sgbase.cpp)
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)
Notes: **** TO DO **** Modify this method to return the correct text. You may also want to add an override for the GetFullInfoText() method if you can provide a full-info display mode.

See also:
SGDisplayNode::GetNameText

Reimplemented from SGDisplayNode.

Definition at line 263 of file sgbase.cpp.

00264 {
00265     ERROR3IF(Result == NULL, "Illegal NULL param");
00266 
00267     *Result = _R(IDS_SGBASE_EXAMPLE_TEXT); // TEXT("Example Item");
00268 }

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

Handles a SuperGallery DisplayTree event.

Author:
Unattributed (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 SGEVENT_FORMAT NULL SGEVENT_REDRAW (SGRedrawInfo *) SGEVENT_BGREDRAW NULL SGEVENT_BGFLUSH NULL - May have NULL MiscInfo SGEVENT_MOUSECLICK (SGMouseInfo *) SGEVENT_DRAGSTARTED (DragMessage *) SGEVENT_CLAIMPOINT (SGMouseInfo *) SGEVENT_THUMBMSG (ThumbMessage *) - May have NULL MiscInfo MonoOff

Use the provided SGDisplayNode::Get[Format]Info() inlines to retrieve this information - they provide useful error/type checking, and hide the cast

MiscInfo - almost always provided. Contains a few useful bits of info that may be needed for all event types. This may be null for special event types (see sgtree.h for the enum and information on which ones may pass NULL MiscInfo - currently this is _THUMBMSG and _BGFLUSH, neither of which should concern you - so as long as you only reference MiscInfo once you know the event type, you will be safe)

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 by calling the base class HandleEvent method, so that default actions for new/unknown events can be supplied by the base class.

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; SGDisplayItem::HandleEvent

Reimplemented from SGDisplayItem.

Definition at line 414 of file sgbase.cpp.

00416 {
00417     switch (EventType)
00418     {
00419         case SGEVENT_FORMAT:
00420             {
00421                 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
00422                 CalculateMyRect(FormatInfo, MiscInfo);      // Cache our FormatRect for later use
00423             }
00424             break;
00425 
00426 
00427         case SGEVENT_REDRAW:
00428             {
00429                 DocRect MyRect(FormatRect);     // Rely on FormatRect being cached from above
00430                 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
00431 
00432                 if (IMustRedraw(RedrawInfo))    // only redraw if we intersect the clip rect
00433                     HandleRedraw(RedrawInfo, MiscInfo);
00434             }
00435             break;      // exit and return FALSE to pass the redraw event on
00436 
00437 
00438         case SGEVENT_MOUSECLICK:
00439             {
00440                 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
00441 
00442                 if (FormatRect.ContainsCoord(Mouse->Position))
00443                 {
00444                     // Test for drag...     **** !!!! ToDo !!!! ****
00445                     // DefaultDragHandler(Mouse, MiscInfo);
00446 
00447                     // No drag, so move on to normal selection click handling
00448                     DefaultClickHandler(Mouse, MiscInfo);
00449 
00450                     return(TRUE);       // Claim this event - nobody else can own this click
00451                 }
00452             }
00453             break;
00454 
00455         default:
00456             // Let the base class handle any events we don't know about.
00457             // This includes things like hit testing (CLAIMPOINT) etc
00458             return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
00459     }
00460 
00461     // Default return value: We do not claim this event, so it will be passed on to others
00462     return(FALSE);
00463 }

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

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

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

Notes: **** TO DO **** This template method will draw an item as a red splodge with a constant text string ("Example Item") next to it. You need to replace this with proper redraw code. To see how different display modes are done take a look at the bitmap, layer, and colour supergalleries.

VERY IMPORTANT: The rendering must be enclosed by calls to StartRendering and StopRendering, to ensure that rendering works properly (in the future we may change the redraw system to use a GRenderRegion for each individual item, rather than one global one for the window, for which these calls will be essential)

Scope: private

Definition at line 304 of file sgbase.cpp.

00305 {
00306     // First, inform the system that we are about to start rendering this item
00307     StartRendering(RedrawInfo, MiscInfo);
00308 
00309     DocRect MyRect(FormatRect);     // Get my redraw position from the cached FormatRect
00310 
00311     RenderRegion *Renderer = RedrawInfo->Renderer;
00312 
00313     INT32 OnePixel  = (INT32) DevicePixels(MiscInfo, 1);
00314     INT32 TwoPixels = (INT32) DevicePixels(MiscInfo, 2);
00315 
00316     Renderer->SetLineWidth(0);
00317     Renderer->SetLineColour(RedrawInfo->Transparent);
00318 
00319     // First, render the icon at the left end of our rectangle
00320     DocRect IconRect(MyRect);
00321     IconRect.hi.x = IconRect.lo.x + IconRect.Height();  // Make it a square
00322     MyRect.lo.x = IconRect.hi.x + TwoPixels;            // And exclude it from 'MyRect'
00323 
00324     // Redraw the icon
00325     GridLockRect(MiscInfo, &IconRect);          // Ensure it maps exactly to specific pixels
00326     IconRect.Inflate(-OnePixel, -OnePixel);     // Leave a bit of space around the edge
00327 
00328     Renderer->SetFillColour(DocColour(COLOUR_RED));
00329     Renderer->DrawRect(&IconRect);
00330 
00331     GridLockRect(MiscInfo, &MyRect);            // Ensure the new 'MyRect' is pixel-grid-aligned
00332 
00333     // Set up the colours for rendering our text, and fill the background if selected
00334     if (Flags.Selected)
00335     {
00336         // Fill the entire background with the 'selected' colour, so we don't
00337         // get gaps between bits of text or uneven rectangles in multiple selections
00338         Renderer->SetFillColour(RedrawInfo->SelBackground);
00339         Renderer->DrawRect(&MyRect);
00340         Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
00341     }
00342     else
00343         Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background);
00344 
00345     MyRect.lo.x += SG_GapBeforeText;    // Leave a small gap before text begins
00346 
00347     // And render the text
00348     String_256 MyText;
00349     GetNameText(&MyText);
00350     Renderer->DrawFixedSystemText(&MyText, MyRect);             
00351 
00352     // Finally, inform the system that we have completed rendering this item
00353     StopRendering(RedrawInfo, MiscInfo);
00354 }


Member Data Documentation

DATATYPE* SGDisplayDATATYPE::TheDATATYPE [private]
 

Definition at line 167 of file sgbase.h.


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