#include <sgbase.h>
Inheritance diagram for SGDisplayDATATYPE:
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 |
Definition at line 139 of file sgbase.h.
|
SGDisplayDATATYPE constructor DON'T call this constructor. It ERROR3's. Call the other constructor.
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 constructor.
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 }
|
|
Shared code for DATATYPE items to calculate where they will appear in the grand scheme of things.
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 }
|
|
|
|
To find out the DATATYPE this object is responsible for displaying.
Definition at line 185 of file sgbase.h. 00186 { 00187 return(TheDATATYPE); 00188 }
|
|
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.
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 }
|
|
Handles a SuperGallery DisplayTree event.
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)
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.
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 }
|
|
SGDisplayDATATYPE item redraw method - removed from the main HandleEvent method merely to make the code tidier.
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 }
|
|
|