#include <sglib.h>
Inheritance diagram for SGLibDisplayItem:

Public Member Functions | |
| SGLibDisplayItem () | |
| SGLibDisplayItem constructor DON'T call this constructor. It ERROR3's. Call the other constructor. | |
| SGLibDisplayItem (LibraryIndex LibraryIndexToDisplay, BOOL bIsNew=FALSE) | |
| SGLibDisplayItem constructor. | |
| ~SGLibDisplayItem () | |
| SGLibDisplayItem destructor. | |
| 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. | |
| LibraryIndex | GetDisplayedLibraryIndex (void) |
| To find out the LibraryIndex this object is responsible for displaying. | |
| BOOL | GetThumbSize (SGMiscInfo *MiscInfo, DocRect *Rectangle, KernelBitmap *Bitmap, INT32 *XSize, INT32 *YSize, double *Scale=NULL, INT32 *XTrans=NULL, INT32 *YTrans=NULL, BOOL *Outline=NULL) |
| Returns the size of thumbnail to render. For thumbnails, drawing them at a 1:1 aspect ratio looks much better than simply squashing them into an arbitrary rectangle. This code handles that... | |
| Library * | GetParentLibrary (void) |
| Finds the library for which this DisplayItem displays an item. | |
| virtual void | GetFileName (String_256 *Result) |
| Returns the filename (without path) for the given item This is needed by the searching code. | |
| virtual BOOL | GetThumbFileName (String_256 *path) |
| To find the corresponding filename for this object's thumb. | |
| virtual BOOL | ShouldDownloadThumb () |
| Used to decide whether or not to (re)start a thumbnail download. | |
| virtual BOOL | DownloadThumbnail () |
| Starts to download the item's thumbnail. | |
| virtual void | OnThumbDownloadComplete () |
| Should be called when the thumbnail download is over - it will force a redraw among other things. | |
| virtual void | OnThumbDownloadProgress (const INT32 nPercentageCompleted) |
| Called on thumbnail download progress - it will update the thumbnail's placeholder. NB: the background is not erased to prevent flickering. | |
| virtual BOOL | ShouldIDrawForeground (BOOL ForceForeground) |
| overrides the base class version to force foreground mode if the item is downloading its thumbnail. This is necessary to avoid flickering. | |
| BOOL | IsDownloadingThumb () |
| virtual BOOL | GetFileNamePtr (TCHAR **Result) |
| Returns the filename (without path) for the given item This is needed by the searching code. | |
| virtual void | GetNameText (String_256 *Result) |
| Returns the name text for this item, to support simple searching and sorting operations, and generic redraw methods for library items. | |
| virtual BOOL | GetNameTextPtr (TCHAR **Result) |
| Returns a pointer to the filename for this item... The main use of this call is to speed sorting up, since passing pointers about is much quicker than constructing strings.... | |
| virtual BOOL | GetDisplayedTextDescription (String_256 *Result) |
| To find the Text description for this object. | |
| virtual BOOL | GetDisplayedTextDescription (TCHAR **Result) |
| To find the Text description for this object. | |
| virtual BOOL | GetActualDisplayedText (String_256 *String, INT32 Line=0) |
| Returns the mode-sensitive string that will actually be displayed. This is handy for sorting methods, etc... | |
| virtual BOOL | GetActualDisplayedTextPtr (TCHAR **String, INT32 Line=0) |
| Returns the mode-sensitive string ptr that will actually be displayed. This is handy for sorting methods, etc... | |
| BOOL | GetFileName (PathName *Result) |
| To find the corresponding filename for this object. | |
| KernelBitmap * | GetDisplayedKernelBitmap (SGMiscInfo *MiscInfo, BOOL Background=FALSE) |
| To find out the KernelBitmap this object is responsible for displaying. | |
| INT32 | GetFileSize (Library *Lib=NULL) |
| To determine the keywords for this node. Generally, this is used for a simple searching mechanism. | |
| virtual 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. | |
| 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. | |
Static Public Member Functions | |
| static void | DrawNullBitmapRect (RenderRegion *Renderer, SGMiscInfo *MiscInfo, DocRect *Rectangle, BOOL Background) |
| Draws a rectangle with two lines crossing it, to signify that the thumbnail could not be found, or could not be generated. | |
Protected Member Functions | |
| virtual BOOL | HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo) |
| Handles a SuperGallery DisplayTree event. | |
| virtual BOOL | StartDrag (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo, INT32 *XSize, INT32 *YSize) |
| Sets the TmpDraggingBitmap up, and returns the sizes to the caller. | |
| virtual INT32 | GetTextWidth (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo) |
| An overridable way of returning the width of the text description. | |
| virtual void | CalculateMyRect (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo) |
| Shared code for LibraryIndex items to calculate where they will appear in the grand scheme of things. | |
| virtual void | HandleRedraw (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo) |
| SGLibDisplayItem item redraw method - removed from the main HandleEvent method merely to make the code tidier. Notes: Scope: private. | |
| 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:. | |
| virtual void | DrawPlaceholder (RenderRegion *Renderer, SGMiscInfo *MiscInfo, DocRect *Rectangle, BOOL Background) |
| Draws a thumbnail placeholder if the actual thumbnail is not available. If the thumb is downloading, it displays the percentage downloaded so far. | |
| virtual void | DrawItemThumbnail (SGRedrawInfo *pRedrawInfo, SGMiscInfo *pMiscInfo, DocRect *pRect) |
| draws the item's thumbnail Scope: protected | |
| virtual LibDisplayType | GetDisplayType (SGMiscInfo *MiscInfo) |
| Return the display type to use - this should be overridden by the library gallery using the code. | |
| virtual void | GetFullInfoText (String_256 *Result) |
| Returns the full-info text for this item, to support simple searching operations, and generic redraw methods for library items. Notes: This overrides the sgdisplaynode version to give full information... | |
| virtual void | GetFullInfoText (String_256 *Result, INT32 Line=0) |
| Returns the full-info text for this item, to support simple searching operations, and generic redraw methods for library items. Notes:. | |
| virtual void | GetKeyWords (String_256 *Result) |
| To determine the keywords for this node. Generally, this is used for a simple searching mechanism. | |
| 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. | |
Protected Attributes | |
| BOOL | bIsDownloadingThumb |
| INT32 | nPercentageDownloaded |
| BOOL | bIsNew |
| OpThumbDownload * | pDownloadOp |
| LibraryIndex | TheLibraryIndex |
Private Member Functions | |
| CC_DECLARE_DYNAMIC (SGLibDisplayItem) | |
Friends | |
| class | OpThumbDownload |
Definition at line 149 of file sglib.h.
|
|
SGLibDisplayItem constructor DON'T call this constructor. It ERROR3's. Call the other constructor.
Definition at line 166 of file sglib.cpp. 00167 { 00168 ERROR3("Illegal call on default SGLibDisplayItem constructor - call the other one!"); 00169 TheLibraryIndex = NULL; 00170 00171 }
|
|
||||||||||||
|
SGLibDisplayItem constructor.
Definition at line 189 of file sglib.cpp. 00190 { 00191 TheLibraryIndex = LibraryIndexToDisplay; 00192 bIsDownloadingThumb = FALSE; 00193 pDownloadOp = NULL; 00194 nPercentageDownloaded = 0; 00195 bIsNew = bNew; 00196 }
|
|
|
SGLibDisplayItem destructor.
Definition at line 210 of file sglib.cpp. 00211 { 00212 if (IsDownloadingThumb() && pDownloadOp) 00213 pDownloadOp->Abort(); 00214 }
|
|
||||||||||||
|
Shared code for LibraryIndex items to calculate where they will appear in the grand scheme of things.
Notes: LibraryIndexs supply only one display mode ("full info") Scope: private (for use of SGLibDisplayItem class only) Reimplemented in SGLibFontItem. Definition at line 310 of file sglib.cpp. 00311 { 00312 INT32 XSize = SG_InfiniteWidth; 00313 INT32 YSize = SG_DefaultLargeIcon; 00314 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1); 00315 Library *ParentLib = GetParentLibrary(); 00316 00317 // If we're displaying text underneath the thumbnail, add some space for it 00318 LibDisplayType DType = GetDisplayType(MiscInfo); 00319 00320 // Get width of text 00321 XSize = GetTextWidth(FormatInfo, MiscInfo); 00322 00323 // Extra space required by the text 00324 switch(DType) 00325 { 00326 case LibDisplay_SmallThumbTextUnder: 00327 case LibDisplay_MediumThumbTextUnder: 00328 case LibDisplay_LargeThumbTextUnder: 00329 // Text is underneath 00330 YSize = SG_GapAboveText + SG_SPACE_UNDER; 00331 break; 00332 00333 default: 00334 // Text is to the right 00335 YSize = 0; 00336 break; 00337 } 00338 00339 // Lock the current sizes to the grid 00340 YSize = GridLock(MiscInfo, YSize); 00341 00342 // Extra Space required if selected 00343 YSize += (3 * 2 * OnePixel); 00344 00345 // Add in space required by the bitmap itself 00346 switch(DType) 00347 { 00348 case LibDisplay_SmallThumbTextUnder: 00349 case LibDisplay_SmallThumbText: 00350 case LibDisplay_SmallThumb: 00351 YSize += GridLock(MiscInfo, ParentLib->PreviewBMPHeight(SGThumb_Small) * OnePixel); 00352 XSize += GridLock(MiscInfo, ParentLib->PreviewBMPWidth(SGThumb_Small) * OnePixel); 00353 break; 00354 00355 case LibDisplay_LargeThumbTextUnder: 00356 case LibDisplay_Default: 00357 case LibDisplay_LargeThumbText: 00358 case LibDisplay_LargeThumb: 00359 YSize += GridLock(MiscInfo, ParentLib->PreviewBMPHeight(SGThumb_Large) * OnePixel); 00360 XSize += GridLock(MiscInfo, ParentLib->PreviewBMPWidth(SGThumb_Large) * OnePixel); 00361 break; 00362 00363 case LibDisplay_MediumThumbTextUnder: 00364 case LibDisplay_MediumThumbText: 00365 case LibDisplay_MediumThumb: 00366 YSize += GridLock(MiscInfo, ParentLib->PreviewBMPHeight(SGThumb_Medium) * OnePixel); 00367 XSize += GridLock(MiscInfo, ParentLib->PreviewBMPWidth(SGThumb_Medium) * OnePixel); 00368 break; 00369 00370 case LibDisplay_FullInfo: 00371 case LibDisplay_SingleLineFullInfo: 00372 YSize += GridLock(MiscInfo, ParentLib->PreviewBMPHeight(SGThumb_Medium) * OnePixel); 00373 XSize += GridLock(MiscInfo, ParentLib->PreviewBMPWidth(SGThumb_Medium) * OnePixel); 00374 //XSize = SG_InfiniteWidth; 00375 break; 00376 00377 case LibDisplay_JustText: 00378 // No description requires no text description space 00379 YSize = GridLock(MiscInfo, 18 * OnePixel); 00380 XSize = GridLock(MiscInfo, SG_DefaultNameText); 00381 break; 00382 } 00383 00384 // Calculate a proper rectangle for the item 00385 CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize); 00386 }
|
|
|
|
|
||||||||||||
|
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.
Reimplemented from SGDisplayNode. Reimplemented in SGLibFontItem. Definition at line 2224 of file sglib.cpp. 02225 { 02226 switch(SortKey) 02227 { 02228 case 1: 02229 // Sort by name - override default and make 'FRED' and 'fred' equal... 02230 // Note - we should really make "'Fred'" and "Fred'" equal, since full info sorting 02231 // can be a bit rampant if you don't know what's going on... 02232 { 02233 BOOL FoundPtr = FALSE; 02234 02235 #ifndef _BATCHING 02236 // Normal, quick alphabetic sorting 02237 02238 TCHAR *pOurName = NULL; 02239 TCHAR *pTheirName = NULL; 02240 FoundPtr = GetActualDisplayedTextPtr(&pOurName); 02241 if(FoundPtr) 02242 { 02243 FoundPtr = ((SGLibDisplayItem *)Other)->GetActualDisplayedTextPtr(&pTheirName); 02244 if(FoundPtr) 02245 { 02246 // Two TCHAR *'s... 02247 INT32 Value = 0; 02248 02249 // This little beastie (below) is the DBCS string comparison flob which we should 02250 // be using for the Jap's, and so forth... 02251 // 1 if pOurName < pTheirName 02252 // 2 if pOutName == pTheirName 02253 // 3 if pOutName > pTheirName 02254 Value = CompareString(LOCALE_USER_DEFAULT, 02255 (NORM_IGNORECASE | NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH), 02256 pOurName, -1, pTheirName, -1); // 1.42 02257 Value -= 2; 02258 02259 return (Value); 02260 } 02261 } 02262 02263 // Fields not found, or index file not cached in memory 02264 String_256 MyName; 02265 String_256 ItsName; 02266 02267 GetActualDisplayedText(&MyName); 02268 MyName.toLower(); 02269 ((SGLibDisplayItem *)Other)->GetActualDisplayedText(&ItsName); 02270 ItsName.toLower(); 02271 02272 return(MyName.CompareTo(ItsName)); 02273 #else 02274 // Not so quick, special alphabetic sorting (fred20 > fred10 > fred5 > fred) 02275 String_256 MyName; 02276 String_256 ItsName; 02277 02278 GetActualDisplayedText(&MyName); 02279 MyName.toLower(); 02280 ((SGLibDisplayItem *)Other)->GetActualDisplayedText(&ItsName); 02281 ItsName.toLower(); 02282 02283 if(Library::MaxFieldCacheEntries == 50 && MyName == ItsName) 02284 { 02285 ERROR3_PF(("Identical sort entries found: '%s'", (TCHAR *)MyName)); 02286 } 02287 02288 INT32 FSize = GetFileSize(NULL); 02289 if(FSize == 0) 02290 { 02291 ERROR3_PF(("Filesize <= 0 found: '%s'", (TCHAR *)MyName)); 02292 } 02293 02294 INT32 MRCount = MyName.Length() - 1; 02295 BOOL MFound = FALSE; 02296 TCHAR TheChar = ((TCHAR *)MyName)[MRCount]; 02297 02298 while(((TheChar == ' ') || (TheChar >= '0' && TheChar <= '9')) && MRCount > 0) 02299 { 02300 if(TheChar != ' ') 02301 MFound = TRUE; 02302 TheChar = ((TCHAR *)MyName)[--MRCount]; 02303 } 02304 02305 INT32 IRCount = ItsName.Length() - 1; 02306 BOOL IFound = FALSE; 02307 TheChar = ((TCHAR *)ItsName)[IRCount]; 02308 02309 while(((TheChar == ' ') || (TheChar >= '0' && TheChar <= '9')) && IRCount > 0) 02310 { 02311 if(TheChar != ' ') 02312 IFound = TRUE; 02313 TheChar = ((TCHAR *)ItsName)[--IRCount]; 02314 } 02315 02316 if(IFound && MFound) 02317 { 02318 String_256 MyLeft; 02319 String_256 ItsLeft; 02320 02321 MyName.Left(&MyLeft, MRCount + 1); 02322 ItsName.Left(&ItsLeft, IRCount + 1); 02323 02324 if(MyLeft == ItsLeft) 02325 { 02326 String_256 MyRight; 02327 String_256 ItsRight; 02328 02329 MyName.Right(&MyRight, MyName.Length() - MRCount - 1); 02330 ItsName.Right(&ItsRight, ItsName.Length() - IRCount - 1); 02331 02332 INT32 Me = _ttoi((TCHAR *)MyRight); 02333 INT32 It = _ttoi((TCHAR *)ItsRight); 02334 02335 if(Me > It) 02336 return 1; 02337 else if(Me < It) 02338 return -1; 02339 } 02340 } 02341 02342 return(MyName.CompareTo(ItsName, FALSE)); 02343 #endif 02344 } 02345 case 2: 02346 // Sort by size 02347 { 02348 Library *Lib = GetParentLibrary(); 02349 return(GetFileSize(Lib) - ((SGLibDisplayItem *)Other)->GetFileSize(Lib)); 02350 } 02351 02352 case 3: 02353 // Sort by name length 02354 { 02355 String_256 MyName; 02356 String_256 ItsName; 02357 02358 GetActualDisplayedText(&MyName); 02359 ((SGLibDisplayItem *)Other)->GetActualDisplayedText(&ItsName); 02360 02361 return (MyName.Length() - ItsName.Length()); 02362 } 02363 break; 02364 02365 case 4: 02366 // Sort by file type 02367 { 02368 PathName MyPath; 02369 PathName ItsPath; 02370 02371 GetFileName(&MyPath); 02372 ((SGLibDisplayItem *)Other)->GetFileName(&ItsPath); 02373 02374 Error::ClearError(); 02375 02376 if(MyPath.IsValid() && ItsPath.IsValid()) 02377 { 02378 String_8 MyType(MyPath.GetType()); 02379 String_8 ItsType(ItsPath.GetType()); 02380 02381 return(MyType.CompareTo(ItsType, FALSE)); 02382 } 02383 } 02384 break; 02385 } 02386 return (SGDisplayNode::CompareTo(Other, SortKey)); 02387 }
|
|
|
Starts to download the item's thumbnail.
Definition at line 2794 of file sglib.cpp. 02795 { 02796 nPercentageDownloaded = 0; 02797 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpThumbDownload)); 02798 if (pOpDesc != NULL) 02799 { 02800 ThumbDownloadParam* Param = new ThumbDownloadParam; 02801 ERROR3IF(!Param, "Memory allocation error"); 02802 Param->pItem = this; 02803 Param->type = GetParentLibrary()->GetType(); 02804 // Invoke the operation 02805 pOpDesc->Invoke((OpParam*) Param); 02806 if (Param->bSuccess) 02807 { 02808 pDownloadOp = Param->pOp; 02809 bIsDownloadingThumb = TRUE; 02810 return TRUE; 02811 } 02812 } 02813 return FALSE; 02814 }
|
|
||||||||||||
|
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.
Reimplemented from SGDisplayNode. Definition at line 2409 of file sglib.cpp. 02410 { 02411 // Just get default selection action to be applied for this click 02412 DefaultClickHandler(Mouse, MiscInfo, TRUE); 02413 }
|
|
||||||||||||||||||||||||||||
|
Plots the item text in the position as required by the GetDisplayType. Notes:.
Definition at line 630 of file sglib.cpp. 00632 { 00633 LibDisplayType DType = GetDisplayType(MiscInfo); 00634 00635 // Work out the text rectangle and stick it here 00636 DocRect TextRect(*Rectangle); 00637 00638 INT32 OnePixel = (INT32) DevicePixels(MiscInfo, 1); 00639 00640 switch(DType) 00641 { 00642 case LibDisplay_SmallThumbTextUnder: 00643 case LibDisplay_MediumThumbTextUnder: 00644 case LibDisplay_LargeThumbTextUnder: 00645 TextRect = *Rectangle; 00646 00647 // Give some extra space above and below the clipart 00648 TextRect.lo.y = TextRect.lo.y + SG_SPACE_UNDER; 00649 00650 TextRect.hi.y = TextRect.lo.y + SG_GapAboveText; 00651 00652 // give the text a little space below the piccy frame, and more below to the next 00653 TextRect.Inflate(0, -OnePixel); 00654 break; 00655 00656 case LibDisplay_SmallThumb: 00657 case LibDisplay_MediumThumb: 00658 case LibDisplay_LargeThumb: 00659 // No text 00660 return; 00661 break; 00662 00663 default: 00664 TextRect = *Rectangle; 00665 TextRect.lo.x = BmpRect->hi.x + SG_GapBeforeText; 00666 break; 00667 } 00668 00669 GridLockRect(MiscInfo, &TextRect); 00670 00671 Renderer->SetLineWidth(0); 00672 Renderer->SetLineColour(RedrawInfo->Transparent); 00673 DocColour red(0xFF, 0, 0); // for new items 00674 00675 // Set up the colours for rendering our text, and fill the background if selected 00676 if (Selected) 00677 { 00678 Renderer->SetFillColour(RedrawInfo->SelBackground); 00679 00680 switch(DType) 00681 { 00682 case LibDisplay_SmallThumbTextUnder: 00683 case LibDisplay_MediumThumbTextUnder: 00684 case LibDisplay_LargeThumbTextUnder: 00685 Renderer->DrawRect(&TextRect); 00686 break; 00687 00688 case LibDisplay_FullInfo: 00689 { 00690 // Two line full info selection rectangle 00691 DocRect SelRect(TextRect); 00692 00693 // Text not in gallery, don't redraw 00694 if(TextRect.lo.x > Rectangle->hi.x) return; 00695 00696 SelRect.hi.y = TextRect.lo.y + TextRect.Height()/2 - (OnePixel * 2); 00697 SelRect.lo.y = TextRect.lo.y + TextRect.Height()/2 + (OnePixel * 2); 00698 SelRect.hi.y += SG_DefaultLargeIcon + OnePixel*4; 00699 SelRect.lo.y -= (SG_DefaultLargeIcon + OnePixel*5); 00700 SelRect.hi.x = TextRect.hi.x; 00701 00702 GridLockRect(MiscInfo, &SelRect); 00703 00704 Renderer->DrawRect(&SelRect); 00705 } 00706 break; 00707 00708 default: 00709 { 00710 DocRect SelRect(TextRect); 00711 00712 // Text not in gallery, don't redraw 00713 if(TextRect.lo.x > Rectangle->hi.x) return; 00714 00715 SelRect.hi.y = TextRect.lo.y + TextRect.Height()/2 - (OnePixel * 2); 00716 SelRect.lo.y = TextRect.lo.y + TextRect.Height()/2 + (OnePixel * 2); 00717 SelRect.hi.y += SG_DefaultLargeIcon/2; 00718 SelRect.lo.y -= (SG_DefaultLargeIcon/2 + OnePixel); 00719 SelRect.hi.x = TextRect.hi.x; 00720 00721 GridLockRect(MiscInfo, &SelRect); 00722 00723 Renderer->DrawRect(&SelRect); 00724 } 00725 break; 00726 } 00727 Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground); 00728 } 00729 else 00730 Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background); 00731 00732 00733 // No point drawing the text, etc... 00734 if(TextRect.lo.x + (OnePixel * 4) > Rectangle->hi.x) 00735 return; 00736 00737 // Get the text into the text strings... 00738 String_256 DisplayText; 00739 String_256 DisplayText2; 00740 00741 switch(DType) 00742 { 00743 case LibDisplay_FullInfo: 00744 // Work out proper text strings to display and display it 00745 // This string is also used by the sorting code, so use a common function to get it... 00746 if(!GetActualDisplayedText(&DisplayText, 1)) 00747 DisplayText = TEXT(""); 00748 00749 if(!GetActualDisplayedText(&DisplayText2, 2)) 00750 DisplayText2 = TEXT(""); 00751 break; 00752 00753 default: 00754 if(!GetActualDisplayedText(&DisplayText, 0)) 00755 DisplayText = TEXT(""); 00756 break; 00757 } 00758 00759 if (bIsNew) 00760 { 00761 String_256 strTemp(_R(IDS_FOLDERNEW)); 00762 strTemp += _T(" "); 00763 strTemp += DisplayText; 00764 DisplayText = strTemp; 00765 } 00766 00767 00768 // And finally plot the text itself 00769 switch(DType) 00770 { 00771 case LibDisplay_SmallThumbTextUnder: 00772 case LibDisplay_MediumThumbTextUnder: 00773 case LibDisplay_LargeThumbTextUnder: 00774 { 00775 // Centred plot 00776 00777 // Get the size of the text string 00778 DocRect TextBoundRect; 00779 Renderer->GetFixedSystemTextSize(&DisplayText, &TextBoundRect); 00780 00781 // Centre the TextBoundRect about the TextRect 00782 TextBoundRect.Translate(TextRect.lo.x + (TextRect.Width()-TextBoundRect.Width())/2, 00783 TextRect.lo.y + (TextRect.Height()-TextBoundRect.Height())/2); 00784 00785 // Ooops, too big... Use initial rectangle 00786 if(TextBoundRect.Width() > TextRect.Width() || TextBoundRect.Height() > TextRect.Height()) 00787 TextBoundRect = TextRect; 00788 00789 // Draw the text 00790 Renderer->DrawFixedSystemText(&DisplayText, TextBoundRect); 00791 if (bIsNew) 00792 { 00793 *camStrchr(DisplayText, _T(' ')) = 0x00; 00794 Renderer->SetFixedSystemTextColours(&red, &RedrawInfo->Background); 00795 Renderer->DrawFixedSystemText(&DisplayText, TextBoundRect); 00796 Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background); 00797 } 00798 } 00799 break; 00800 00801 case LibDisplay_FullInfo: 00802 { 00803 // Two line full info plot 00804 00805 // Get the size of the text string 00806 DocRect TextBoundRect; 00807 Renderer->GetFixedSystemTextSize(&DisplayText, &TextBoundRect); 00808 00809 // Work out the two bounding rectangles 00810 TextRect.lo.x += (OnePixel * 4); 00811 DocRect TopTextRect(TextRect); 00812 DocRect BottomTextRect(TextRect); 00813 INT32 Shift = (TextBoundRect.Height()/2) + (OnePixel * 2); 00814 00815 TopTextRect.lo.y += Shift; 00816 TopTextRect.hi.y += Shift; 00817 BottomTextRect.lo.y -= Shift; 00818 BottomTextRect.hi.y -= Shift; 00819 00820 // Draw the text 00821 Renderer->DrawFixedSystemText(&DisplayText, TopTextRect); 00822 if (bIsNew) 00823 { 00824 *camStrchr(DisplayText, _T(' ')) = 0x00; 00825 Renderer->SetFixedSystemTextColours(&red, &RedrawInfo->Background); 00826 Renderer->DrawFixedSystemText(&DisplayText, TopTextRect); 00827 Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background); 00828 } 00829 Renderer->DrawFixedSystemText(&DisplayText2, BottomTextRect); 00830 } 00831 break; 00832 00833 default: 00834 // Left justified plot 00835 TextRect.lo.x += (OnePixel * 4); //SG_GapBeforeText; 00836 Renderer->DrawFixedSystemText(&DisplayText, TextRect); 00837 if (bIsNew) 00838 { 00839 *camStrchr(DisplayText, _T(' ')) = 0x00; 00840 Renderer->SetFixedSystemTextColours(&red, &RedrawInfo->Background); 00841 Renderer->DrawFixedSystemText(&DisplayText, TextRect); 00842 Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background); 00843 } 00844 00845 break; 00846 } 00847 }
|
|
||||||||||||||||
|
draws the item's thumbnail Scope: protected
Definition at line 540 of file sglib.cpp. 00541 { 00542 RenderRegion* pRenderer = pRedrawInfo->Renderer; 00543 if (Library::BackgroundRedraw) 00544 { 00545 BOOL DrawnBitmap = DrawThumb(pRenderer, pRedrawInfo, pMiscInfo, pDocRect, FALSE); 00546 if (ShouldDownloadThumb()) 00547 DownloadThumbnail(); 00548 if (ShouldIDrawForeground(DrawnBitmap)) 00549 { 00550 if (!DrawnBitmap) 00551 { 00552 if (!DrawThumb(pRenderer, pRedrawInfo, pMiscInfo, pDocRect, TRUE)) 00553 { 00554 if (IsDownloadingThumb()) // draw grey rectangle if we're still waiting for the thumbnail 00555 DrawPlaceholder(pRenderer, pMiscInfo, pDocRect, TRUE); 00556 else // draw a crossed box 00557 DrawPlaceholder(pRenderer, pMiscInfo, pDocRect, FALSE); 00558 } 00559 } 00560 } 00561 else if (!DrawnBitmap) 00562 DrawPlaceholder(pRenderer, pMiscInfo, pDocRect, TRUE); 00563 } 00564 else if (!DrawThumb(pRenderer, pRedrawInfo, pMiscInfo, pDocRect, TRUE)) 00565 DrawPlaceholder(pRenderer, pMiscInfo, pDocRect, FALSE); 00566 }
|
|
||||||||||||||||||||
|
Draws a rectangle with two lines crossing it, to signify that the thumbnail could not be found, or could not be generated.
Definition at line 1115 of file sglib.cpp. 01117 { 01118 01119 if(Renderer == NULL || MiscInfo == NULL || Rectangle == NULL) 01120 { 01121 ERROR3("SGLibDisplayItem::DrawNullBitmapRect null params are BAD"); 01122 return; 01123 } 01124 01125 01126 01127 // Draw the 'blank' bitmap 01128 01129 if(!Background) 01130 Renderer->SetFillColour(COLOUR_GREY); 01131 else 01132 { 01133 DocColour NullBitmapColour(230L, 230L, 230L); 01134 Renderer->SetFillColour(NullBitmapColour); 01135 } 01136 01137 GridLockRect(MiscInfo, Rectangle); 01138 Renderer->DrawRect(Rectangle); 01139 01140 // Yes I know it's horrible, but since we're now a static, DevicePixels doesn't seem to work 01141 INT32 OnePixel = MiscInfo->PixelSize; 01142 01143 Renderer->SetLineWidth(0); 01144 Renderer->SetLineColour(DocColour(COLOUR_TRANS)); 01145 Renderer->SetFillColour(DocColour(COLOUR_BLACK)); 01146 01147 DocRect TempRect(*Rectangle); // Left 01148 TempRect.hi.x = TempRect.lo.x + OnePixel; 01149 Renderer->DrawRect(&TempRect); 01150 01151 TempRect = *Rectangle; // Top 01152 TempRect.lo.y = TempRect.hi.y - OnePixel; 01153 Renderer->DrawRect(&TempRect); 01154 01155 TempRect = *Rectangle; // Right 01156 TempRect.lo.x = TempRect.hi.x - OnePixel; 01157 Renderer->DrawRect(&TempRect); 01158 01159 TempRect = *Rectangle; // Bottom 01160 TempRect.hi.y = TempRect.lo.y + OnePixel; 01161 Renderer->DrawRect(&TempRect); 01162 01163 if(!Background) 01164 { 01165 // Pop two intersecting lines through the centre of the rectangle to signify 01166 // that the item doesn't have a thumbnail 01167 TempRect = *Rectangle; // Middle X 01168 TempRect.hi.y = TempRect.lo.y + (TempRect.Height() / 2); 01169 TempRect.lo.y = TempRect.hi.y; 01170 GridLockRect(MiscInfo, &TempRect); 01171 TempRect.hi.y += OnePixel; 01172 Renderer->DrawRect(&TempRect); 01173 01174 TempRect = *Rectangle; // Middle Y 01175 TempRect.hi.x = TempRect.lo.x + (TempRect.Width() / 2); 01176 TempRect.lo.x = TempRect.hi.x; 01177 GridLockRect(MiscInfo, &TempRect); 01178 TempRect.hi.x += OnePixel; 01179 Renderer->DrawRect(&TempRect); 01180 } 01181 }
|
|
||||||||||||||||||||
|
Draws a thumbnail placeholder if the actual thumbnail is not available. If the thumb is downloading, it displays the percentage downloaded so far.
Definition at line 2895 of file sglib.cpp. 02897 { 02898 if (Renderer == NULL || MiscInfo == NULL || Rectangle == NULL) 02899 { 02900 ERROR3("Illegal NULL pointer"); 02901 return; 02902 } 02903 #ifdef _WIN32 02904 if (Background) 02905 { 02906 DocColour NullBitmapColour(230L, 230L, 230L); 02907 Renderer->SetFillColour(NullBitmapColour); 02908 GridLockRect(MiscInfo, Rectangle); 02909 Renderer->DrawRect(Rectangle); 02910 INT32 OnePixel = MiscInfo->PixelSize; 02911 Renderer->SetLineWidth(0); 02912 Renderer->SetLineColour(DocColour(COLOUR_TRANS)); 02913 Renderer->SetFillColour(DocColour(COLOUR_BLACK)); 02914 DocRect TempRect(*Rectangle); // Left 02915 TempRect.hi.x = TempRect.lo.x + OnePixel; 02916 Renderer->DrawRect(&TempRect); 02917 TempRect = *Rectangle; // Top 02918 TempRect.lo.y = TempRect.hi.y - OnePixel; 02919 Renderer->DrawRect(&TempRect); 02920 TempRect = *Rectangle; // Right 02921 TempRect.lo.x = TempRect.hi.x - OnePixel; 02922 Renderer->DrawRect(&TempRect); 02923 TempRect = *Rectangle; // Bottom 02924 TempRect.hi.y = TempRect.lo.y + OnePixel; 02925 Renderer->DrawRect(&TempRect); 02926 if (IsDownloadingThumb()) 02927 { 02928 String_32 strLabel(GetStringField(0, _R(IDS_LOADINGTHUMB))); 02929 DocRect rcText; 02930 Renderer->DrawFixedSystemText(&strLabel, rcText, FORMAT_NOPREFIX | FORMAT_CALCRECT | FORMAT_SINGLELINE | FORMAT_CENTER | FORMAT_VCENTER); 02931 if (rcText.Width() >= Rectangle->Width()) // we have to draw multiline 02932 { 02933 camSprintf((TCHAR*) strLabel, _T("%s%d%%"), (TCHAR*) (String_256) GetStringField(1, _R(IDS_LOADINGTHUMB)), nPercentageDownloaded); 02934 // DrawFixedSystemText can't center multiline text, so we'll have to adjust the rect 02935 Renderer->DrawFixedSystemText(&strLabel, rcText, FORMAT_NOPREFIX | FORMAT_CALCRECT); 02936 DocRect rcAdjusted = *Rectangle; 02937 rcAdjusted.hi.y -= ((rcAdjusted.hi.y - rcAdjusted.lo.y) - (rcText.hi.y - rcText.lo.y))/2; 02938 Renderer->DrawFixedSystemText(&strLabel, rcAdjusted, FORMAT_NOPREFIX | FORMAT_CENTER); 02939 } 02940 else 02941 { 02942 camSprintf((TCHAR*) strLabel, _T("%s%d%%"), (TCHAR*) (String_256) GetStringField(2, _R(IDS_LOADINGTHUMB)), nPercentageDownloaded); 02943 Renderer->DrawFixedSystemText(&strLabel, *Rectangle, FORMAT_NOPREFIX | FORMAT_SINGLELINE | FORMAT_CENTER | FORMAT_VCENTER); 02944 } 02945 } 02946 } 02947 else 02948 { 02949 DrawNullBitmapRect(Renderer, MiscInfo, Rectangle, Background); 02950 } 02951 #else 02952 DrawNullBitmapRect(Renderer, MiscInfo, Rectangle, Background); 02953 #endif 02954 }
|
|
||||||||||||||||||||||||
|
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.
Definition at line 980 of file sglib.cpp. 00982 { 00983 KernelBitmap *Bitmap = GetDisplayedKernelBitmap(MiscInfo, Background); 00984 00985 // Bitmap not there... 00986 if(Bitmap == NULL) 00987 return FALSE; 00988 00989 INT32 XSize = 0; 00990 INT32 YSize = 0; 00991 double Scale = (double)1; 00992 INT32 XTrans = 0; 00993 INT32 YTrans = 0; 00994 BOOL Outline = FALSE; 00995 00996 if(!GetThumbSize(MiscInfo, Rectangle, Bitmap, &XSize, &YSize, &Scale, &XTrans, &YTrans, &Outline)) 00997 return FALSE; 00998 00999 DocRect BmpRect(0, 0, XSize, YSize); 01000 BmpRect.Translate(XTrans, YTrans); 01001 01002 #if 0 01003 |