sglib.h

Go to the documentation of this file.
00001 // $Id: sglib.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Super Gallery Library DisplayItem stuff
00099 
00100 #ifndef INC_SGLIB
00101 #define INC_SGLIB
00102 
00103 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "sgtree.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "sgscan.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "camnet.h"
00108 
00109 /************************************************************************************/
00110 
00111 // The various valid display modes. Note that FullInfo defaults to using the medium
00112 // thumbnail. 
00113 enum LibDisplayType
00114 {
00115     LibDisplay_Default = 0,
00116     LibDisplay_SmallThumb,
00117     LibDisplay_MediumThumb,
00118     LibDisplay_LargeThumb,
00119     LibDisplay_SmallThumbText,
00120     LibDisplay_MediumThumbText,
00121     LibDisplay_LargeThumbText,
00122     LibDisplay_SmallThumbTextUnder,
00123     LibDisplay_MediumThumbTextUnder,
00124     LibDisplay_LargeThumbTextUnder,
00125     LibDisplay_FullInfo,
00126     LibDisplay_JustText,
00127     LibDisplay_SingleLineFullInfo
00128 };
00129     
00130 /***********************************************************************************************
00131 
00132 >   class SGLibDisplayItem : public SGDisplayItem
00133 
00134     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00135     Created:    27/01/95
00136     Purpose:    This DisplayTree node is used by Library SuperGalleries
00137                 It is responsible for providing the ability to handle/redraw one Library item
00138                 displayed in said gallery.
00139                 It is a base class to be used by all library display items, though many
00140                 gallery types may nmot need to derive a new class from it - it's generic
00141                 handling of display may be adequate.
00142 
00143     SeeAlso:    LibClipartSGallery; SuperGallery; SGDisplayItem
00144 
00145 ***********************************************************************************************/
00146 
00147 class OpThumbDownload;
00148 
00149 class CCAPI SGLibDisplayItem : public SGDisplayItem
00150 {
00151     CC_DECLARE_DYNAMIC(SGLibDisplayItem);
00152 
00153 public:
00154     SGLibDisplayItem();
00155     SGLibDisplayItem(LibraryIndex LibraryIndexToDisplay, BOOL bIsNew = FALSE);
00156     ~SGLibDisplayItem();
00157 
00158 protected:
00159     // Event handler
00160     virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo);
00161 
00162     // Shared code to use before starting an item drag (sets drag bmp up, and returns size)
00163     virtual BOOL StartDrag(SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo,
00164         INT32 *XSize, INT32 *YSize);
00165 
00166     // Determines the width of the text to display for this item
00167     virtual INT32 GetTextWidth(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo);
00168 
00169     // Determines item size for the current DisplayMode and calculates FormatRect
00170     virtual void CalculateMyRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo);
00171 
00172     // Redraws the item into the current FormatRect
00173     virtual void HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo);
00174 
00175 
00176     // Specialisations of this class
00177 
00178     // Draw a thumbnail for this item
00179     virtual BOOL DrawThumb(RenderRegion *Renderer, SGRedrawInfo *RedrawInfo,
00180             SGMiscInfo *MiscInfo, DocRect *Rectangle, BOOL Background = FALSE);
00181 
00182 public:
00183     // Draw a null bitmap rectangle if we couldn't draw a proper one
00184     static void DrawNullBitmapRect(RenderRegion *Renderer,
00185             SGMiscInfo *MiscInfo, DocRect *Rectangle, BOOL Background);
00186 
00187     virtual void DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo);
00188 
00189 protected:
00190 
00191     // Draw the text for this item
00192     virtual void DrawItemText(RenderRegion *Renderer, SGRedrawInfo *RedrawInfo,
00193             SGMiscInfo *MiscInfo, DocRect *Rectangle, DocRect *BmpRect, BOOL Selected);
00194 
00195     virtual void DrawPlaceholder(RenderRegion *Renderer, SGMiscInfo *MiscInfo, DocRect *Rectangle, BOOL Background);
00196 
00197     virtual void DrawItemThumbnail(SGRedrawInfo* pRedrawInfo, SGMiscInfo* pMiscInfo, DocRect* pRect);
00198     
00199     // return the display type to use - this should really be overridden
00200     virtual LibDisplayType GetDisplayType(SGMiscInfo *MiscInfo);
00201 
00202     // generic searching and redraw function (which works properly !)
00203     virtual void GetFullInfoText(String_256 *Result);
00204 
00205     // generic searching and redraw function
00206     virtual void GetFullInfoText(String_256 *Result, INT32 Line = 0);
00207 
00208     // generic searching function
00209     virtual void GetKeyWords(String_256 *Result);
00210 
00211     // for sorting
00212     virtual INT32 CompareTo(SGDisplayNode *Other, INT32 SortKey);
00213 
00214 
00215 public:
00216 
00217     // Find the LibraryIndex which indexes the item we are displaying
00218     inline LibraryIndex GetDisplayedLibraryIndex(void);
00219 
00220     // Returns size, scale, aspectm, translation details of a thumbnail and a rectangle
00221     BOOL GetThumbSize(SGMiscInfo *MiscInfo, DocRect *Rectangle,
00222         KernelBitmap *Bitmap, INT32 *XSize, INT32 *YSize, double *Scale = NULL,
00223         INT32 *XTrans = NULL, INT32 *YTrans = NULL, BOOL *Outline = NULL);
00224 
00225     // Finds the parent SGSubLib library (by asking our parent group)
00226     Library *GetParentLibrary(void);
00227 
00228     // generic searching and redraw function
00229     virtual void GetFileName(String_256 *Result);
00230 
00231     // Get item's thumb filename (WEBSTER)
00232     virtual BOOL GetThumbFileName(String_256* path);
00233 
00234     virtual BOOL ShouldDownloadThumb();
00235 
00236     virtual BOOL DownloadThumbnail();
00237 
00238     virtual void OnThumbDownloadComplete();
00239 
00240     virtual void OnThumbDownloadProgress(const INT32 nPercentageCompleted);
00241 
00242     virtual BOOL ShouldIDrawForeground(BOOL ForceForeground);
00243 
00244     inline BOOL IsDownloadingThumb() { return bIsDownloadingThumb;}
00245 
00246     // generic searching and redraw function
00247     virtual BOOL GetFileNamePtr(TCHAR **Result);
00248 
00249     // generic searching and redraw function
00250     virtual void GetNameText(String_256 *Result);
00251 
00252     // Return a pointer to the filename for this item (wont work with diskfile indexes)
00253     virtual BOOL GetNameTextPtr(TCHAR **Result);
00254     
00255     // Finds the text description for the displayed item
00256     virtual BOOL GetDisplayedTextDescription(String_256 *Result);
00257 
00258     // Returns pointer to text description (only if index cached)
00259     virtual BOOL GetDisplayedTextDescription(TCHAR **Result);
00260 
00261     // Return the actual text which will be displayed for this item in the current mode
00262     // New Line default can be used for multi-line full info strings. The first line is
00263     // always 1, and if no info can be found for the line, we return FALSE.
00264     // 0 is a special value for Line which returns all the text, as the default used to
00265     // do.
00266     virtual BOOL GetActualDisplayedText(String_256 *String, INT32 Line = 0);
00267 
00268     // Return a pointer to the actual text which will be displayed for this item
00269     virtual BOOL GetActualDisplayedTextPtr(TCHAR **String, INT32 Line = 0);
00270 
00271     // Get the item's full filename
00272     BOOL GetFileName(PathName *Result);
00273 
00274     // Finds the thumbnail bitmap (if any) for the displayed item
00275     KernelBitmap *GetDisplayedKernelBitmap(SGMiscInfo *MiscInfo, BOOL Background = FALSE);
00276 
00277     // Get the item's file size (Lib can be null, but it will be quicker if it's not)
00278     INT32 GetFileSize(Library *Lib = NULL);
00279 
00280     // Bubble help for library item
00281     virtual BOOL GetBubbleHelp(DocCoord *MousePos, String_256 *Result);
00282 
00283     // Status line help for library item
00284     virtual BOOL GetStatusLineHelp(DocCoord *MousePos, String_256 *Result);
00285                                                                                                 
00286 protected:
00287     // Special member variables
00288     BOOL bIsDownloadingThumb;
00289     INT32 nPercentageDownloaded;
00290     BOOL bIsNew;
00291     OpThumbDownload* pDownloadOp;
00292     LibraryIndex TheLibraryIndex;
00293 
00294     friend class OpThumbDownload;
00295 };
00296 
00297 
00298 
00299 /********************************************************************************************
00300 
00301 >   inline LibraryIndex SGLibDisplayItem::GetDisplayedLibraryIndex(void)
00302 
00303     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00304     Created:    27/1/95
00305 
00306     Returns:    A pointer to the LibraryIndex which this Display Item is used to display.
00307             
00308     Purpose:    To find out the LibraryIndex this object is responsible for displaying
00309 
00310 ********************************************************************************************/
00311 
00312 LibraryIndex SGLibDisplayItem::GetDisplayedLibraryIndex(void)
00313 {
00314     return(TheLibraryIndex);
00315 }
00316 
00317 /***********************************************************************************************
00318 
00319 >   class SGLibGroup : public SGDisplayGroup
00320 
00321     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00322     Created:    20/4/95
00323     Purpose:    This is a display tree group specifically for library galleries
00324                 The main reason for implementing it was to receive library group messages
00325     SeeAlso:    SuperGallery; SGDisplayGroup;
00326 
00327 ***********************************************************************************************/
00328 
00329 class CCAPI SGLibGroup : public SGDisplayGroup
00330 {
00331     CC_DECLARE_DYNAMIC(SGLibGroup);
00332 public:
00333     SGLibGroup(SuperGallery *ParentGal, Document *ParentDoc, Library *ParentLib);
00334     virtual void ReadGroupTitle(void);
00335     virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo);
00336 
00337     // Bubble help for library groups
00338     virtual BOOL GetBubbleHelp(DocCoord *MousePos, String_256 *Result);
00339 
00340     // Status line help for library groups
00341     virtual BOOL GetStatusLineHelp(DocCoord *MousePos, String_256 *Result);
00342 
00343     // Can this group virtualise out to disk ?
00344     virtual BOOL CanVirtualise(void);
00345 
00346     // Virtualise back in
00347     virtual BOOL DeVirtualise(void);
00348 
00349 public:
00350     // ini file option for libraries
00351     static BOOL LibraryVirtualisingEnabled;
00352 
00353 };
00354             
00355 
00356 #endif  // INC_SGLIB

Generated on Sat Nov 10 03:46:56 2007 for Camelot by  doxygen 1.4.4