00001 // $Id: sglcart.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 // SGLibClipart.h - the LibClipartSGallery (LibClipart SuperGallery) class 00099 00100 00101 #ifndef INC_SGLCART 00102 #define INC_SGLCART 00103 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 "sglib.h" 00108 //#include "oilfltrs.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 #include "dragbmp.h" 00110 #include "sgdrag.h" 00111 #include "sglbase.h" 00112 00113 /*********************************************************************************************** 00114 00115 > class LibClipartSGallery : public LibraryGallery 00116 00117 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason) 00118 Created: 27/1/95 (Based on the Colour SGallery code) 00119 Purpose: The LibClipart SuperGallery class 00120 00121 Notes: SuperGalleries are specced in a number of docs including 00122 specs\sgallery.doc ("super" gallery extensions) 00123 specs\propui.doc (gallery basic ui) 00124 There is also howtouse\sgallery.doc which describes creating a supergallery 00125 00126 SeeAlso: SuperGallery; SGDisplayLibClipart; LibraryGallery 00127 00128 ***********************************************************************************************/ 00129 00130 class LibClipartSGallery : public LibraryGallery 00131 { 00132 CC_DECLARE_DYNCREATE(LibClipartSGallery) 00133 00134 public: 00135 LibClipartSGallery(); 00136 ~LibClipartSGallery(); 00137 static LibClipartSGallery* Instance(); 00138 00139 // Item properties. 00140 INT32 GetClipTheme() const; 00141 INT32 SetClipTheme(INT32 nNewIndex); 00142 00143 00144 // TRUE if the SuperGallery is also a LibraryGallery & has no non-library groups 00145 virtual BOOL IsLibraryGalleryWithNonLibraryGroups(void) {return TRUE;}; 00146 00147 public: 00148 00149 // Initialise the clipart gallery 00150 static BOOL Init(void); 00151 00152 // Clipart gallery message handler 00153 virtual MsgResult Message(Msg* Message); 00154 00155 // Function for profiling redraw (normally contains no code and isn't called) 00156 void ProfileRedraw(ReDrawInfoType *Param); 00157 00158 // Can we support keywords ? 00159 virtual BOOL CanSearchKeywords(void); 00160 00161 // Override for creating clipart library groups rather than display groups 00162 virtual SGDisplayGroup *AddLibraryGroup(Library *LibraryToDisplay, INT32 NumItems); 00163 00164 public: 00165 // Library Galleries must override these 00166 00167 // Can we create indexes ? 00168 virtual BOOL CanCreateIndexes(void); 00169 00170 // Get various default bits 'n' pieces 00171 virtual BOOL GetDefaults(String_256 *DefaultIndex, String_256 *IndexDesc, SGLibType *Type); 00172 00173 // Get the default CD directory name for the gallery 00174 virtual BOOL GetLibraryDirectoryName(String_256 *LibDirName); 00175 00176 // Check the entry in the index.txt file with our gallery, and return TRUE if it's a match 00177 virtual BOOL CheckForIndexMatch(StringBase *Txt); 00178 00179 // Return a Section name for this gallery... 00180 virtual void WorkOutSectionName(String_256 *Section); 00181 00182 // Get the quiet status of the gallery 00183 virtual BOOL GetQuietStatus(void); 00184 00185 // Set the quiet status of the gallery 00186 virtual void SetQuietStatus(BOOL Status); 00187 00188 // Scan for location of default CD library 00189 virtual BOOL ScanForLocation(SGLibType Type, StringBase *Result); 00190 00191 public: // Overridden Command interface (for Ops and menu support) 00192 virtual BOOL InitMenuCommands(void); 00193 // Called on startup to initialise any desired menu commands. Will make repeated calls 00194 // to InitMenuCommand(), below. 00195 00196 virtual BOOL BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID); 00197 // Builds the command menu for the given menu pop-up (over an item, or options button) 00198 00199 virtual OpState GetCommandState(StringBase *CommandID, String_256 *ShadeReason); 00200 // Returns an OpState indicating the state of this command, much like an Op GetState 00201 00202 virtual void DoCommand(StringBase *CommandID); 00203 // Attempts to "do" the given command. Should call down to the base class to handle 00204 // any commands it can't deal with. 00205 00206 // Return gallery type 00207 virtual SGLibType GetGalleryType() 00208 { 00209 if (GetClipTheme() == 0) 00210 { 00211 return SGLib_ClipArt; 00212 } 00213 else 00214 { 00215 return SGLib_ClipArt_WebThemes; 00216 } 00217 } 00218 00219 virtual String_256* GetDefaultLibraryPath() {return &DefaultLibraryPath;} 00220 00221 // Override for button greying 00222 void SelectionHasChanged(void); 00223 00224 void ModeHasChanged(void); 00225 00226 00227 // Import all the currently selected clipart 00228 static BOOL ImportClipart(BOOL NewDocument, LibraryGallery* pSourceGallery); 00229 00230 virtual BOOL PreCreate(void); 00231 00232 virtual BOOL OnGetButtonClicked(void); 00233 00234 //Added so that they may be suitably overridden for our multiple source downloads 00235 virtual BOOL RemoveWebFolders(SGLibType type); 00236 00237 00238 00239 protected: 00240 void DoShadeGallery(BOOL ShadeIt); 00241 00242 00243 virtual BOOL ApplyAction(SGActionType Action); 00244 00245 // Adds an item to the given library display group 00246 // Must be overridden by derived galleries if they wish to handle Libraries 00247 virtual SGDisplayItem *AddLibraryItem(SGDisplayGroup *LibraryGroup, Library *ParentLib, 00248 LibraryIndex ItemIndex, BOOL bNew = FALSE); 00249 00250 00251 // Load and save all the currently selected clipart 00252 BOOL LoadAndSave(void); 00253 00254 void HandleDragStart(DragMessage *DragMsg); 00255 00256 SGDisplayItem *CopyDisplayItem(SGDisplayItem *SourceItem, 00257 SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition); 00258 00259 protected: 00260 00261 // Handle clicks on the browse button 00262 BOOL BrowseClicked(void); 00263 00264 // Sort the entire gallery alphabetically 00265 void SortGallery(void); 00266 00267 public: // ini file stuff 00268 // Where to find the default library 00269 static String_256 DefaultLibraryPath; 00270 static String_256 ClipartPath; 00271 static String_256 WebThemePath; 00272 00273 // For keeping the last display mode 00274 static INT32 DefaultDisplayMode; 00275 00276 // For storing sort modes across quits 00277 static UINT32 DefaultSortKeys; 00278 00279 // Optional location for batching system to save its babies 00280 static String_256 BatchSaveLocation; 00281 00282 // If the index contains sounds, should we play them ? 00283 static BOOL DoSounds; 00284 00285 00286 public: // general statics 00287 00288 // Pointer to the last created clipart gallery (or null) 00289 static LibClipartSGallery *ThisGallery; 00290 00291 // Quiet status of the gallery 00292 static BOOL QuietStatus; 00293 bool m_bRedraw; 00294 bool m_bRestore; 00295 00296 00297 private: 00298 static LibClipartSGallery* m_pInstance; // the global instance of the gallery 00299 INT32 m_nClipTheme; // whether displaying clipart or web themes 00300 }; 00301 00302 00303 00304 /******************************************************************************************** 00305 > class CCAPI OpLibGalClipTheme : public OpDescriptor 00306 00307 Author: Priestley (Xara Group Ltd) <camelotdev@xara.com> 00308 Created: 18/09/2000 00309 Purpose: Manages the clipart gallery's clipart/web themes combo-box. 00310 ********************************************************************************************/ 00311 00312 #define OPTOKEN_LIBGAL_CLIPTHEME _T("LibGalClipTheme") 00313 00314 class CCAPI OpLibGalClipTheme : public OpDescriptor 00315 { 00316 CC_DECLARE_DYNCREATE(OpLibGalClipTheme); 00317 00318 public: 00319 // Creation & destruction. 00320 OpLibGalClipTheme(); 00321 00322 private: 00323 // Event handlers. 00324 virtual void OnControlCreate(OpDescControlCreateMsg* pCreateMsg); 00325 virtual void OnSelectionChange(OpDescControlMsg* pSelChangedMsg, List* pGadgetList); 00326 00327 // Helpers. 00328 void UpdateGadgets(); 00329 00330 }; 00331 00332 00333 00334 00335 00336 00337 /******************************************************************************************** 00338 00339 > class OpDisplayLibClipartGallery: public Operation 00340 00341 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00342 Created: 9/2/95 (Based on the Colour SGallery code) 00343 00344 Purpose: Displays the LibClipart gallery. 00345 This op can be attached to a menu, button or keypress 00346 SeeAlso: LibClipartSGallery 00347 00348 ********************************************************************************************/ 00349 00350 #define OPTOKEN_DISPLAYCLIPARTGALLERY _T("DisplayClipartGallery") 00351 00352 class CCAPI OpDisplayLibClipartGallery: public Operation 00353 { 00354 CC_DECLARE_DYNCREATE( OpDisplayLibClipartGallery ); 00355 00356 public: 00357 static BOOL Init(); 00358 static OpState GetState(String_256*, OpDescriptor*); 00359 void Do(OpDescriptor*); 00360 00361 private: 00362 static DialogBarOp *FindGallery(void); 00363 // Finds the LibClipart gallery class instance 00364 }; 00365 00366 /******************************************************************************************** 00367 00368 > class SGClipartItem: public SGLibDisplayItem 00369 00370 Author: Richard_Millican (Xara Group Ltd) <camelotdev@xara.com> 00371 Created: 16/3/95 00372 00373 Purpose: A clipart gallery item 00374 SeeAlso: SGClipartItem 00375 00376 ********************************************************************************************/ 00377 00378 class SGClipartItem: public SGLibDisplayItem 00379 { 00380 CC_DECLARE_DYNCREATE( SGClipartItem ); 00381 00382 public: 00383 00384 SGClipartItem(); 00385 ~SGClipartItem(); 00386 00387 SGClipartItem(LibraryIndex LibraryIndexToDisplay, BOOL bNew = FALSE); 00388 00389 LibDisplayType GetDisplayType(SGMiscInfo *MiscInfo); 00390 00391 // void DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo); 00392 00393 protected: 00394 00395 virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, 00396 SGMiscInfo *MiscInfo); 00397 00398 }; 00399 00400 /******************************************************************************************** 00401 00402 > class GalleryClipartDragInfo : public BitmapDragInformation 00403 00404 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00405 Created: 8/4/95 00406 Purpose: A fill drag, which was started from the fill gallery 00407 SeeAlso: BitmapDragInformation 00408 00409 ********************************************************************************************/ 00410 00411 class GalleryClipartDragInfo : public BitmapDragInformation 00412 { 00413 CC_DECLARE_DYNCREATE(GalleryClipartDragInfo) 00414 00415 public: 00416 GalleryClipartDragInfo(); 00417 GalleryClipartDragInfo( SGClipartItem *pSourceItem, 00418 SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo, 00419 BOOL IsAdjust = FALSE, INT32 XSize = 0, INT32 YSize = 0); 00420 ~GalleryClipartDragInfo(); 00421 00422 virtual void OnClick(INT32 Flags, POINT Point); 00423 00424 virtual UINT32 GetCursorID(DragTarget* pDragTarget); 00425 virtual BOOL GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget); 00426 00427 virtual BOOL CanDropOnPage() { return TRUE; } 00428 virtual BOOL OnPageDrop(ViewDragTarget*); 00429 00430 virtual BOOL OnMainFrameDrop(DragTarget* pDragTarget); 00431 00432 SGClipartItem* GetDraggedClipart() { return(SourceItem); } 00433 00434 public: 00435 SGClipartItem* SourceItem; 00436 protected: 00437 SGMouseInfo MouseInfo; 00438 SGMiscInfo MiscInfo; 00439 }; 00440 00441 /********************************************************************************************* 00442 00443 > class SGClipartDragTarget : public SGListDragTarget 00444 00445 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00446 Created: 8/4/95 00447 00448 Purpose: An instantiation of this class is created by each entity which wishes to 00449 provide a 'destination' to which the mouse can go to complete a drag. 00450 00451 This particular target is used for handling drags of BitmapSGalllery items 00452 within their displayed list. It automatically handles drags with draginfo 00453 derived from BitmapDragInformation. 00454 00455 Notes: Drag targets are destructed automatically when a drag finishes by the drag 00456 manager with which they were registered. 00457 00458 To remove a drag target at any time, destruct it - it automatically deregisters 00459 and cleans up. 00460 00461 SeeAlso: DragManagerOp::StartDrag; DragInformation; DragTarget; 00462 SGBitmapDragTarget::ProcessEvent 00463 00464 Documentation: Docs\Specs\DragMan.doc; Docs\HowToUse\SGallery.doc 00465 00466 *********************************************************************************************/ 00467 00468 class SGClipartDragTarget : public SGListDragTarget 00469 { 00470 friend class DragManagerOp; 00471 00472 CC_DECLARE_DYNAMIC(SGClipartDragTarget) 00473 00474 public: // Public interface 00475 SGClipartDragTarget(DialogOp *TheDialog, CGadgetID TheGadget = NULL); 00476 00477 protected: 00478 // Process a drag-related event 00479 virtual BOOL ProcessEvent(DragEventType Event, 00480 DragInformation *pDragInfo, 00481 OilCoord *pMousePos, KeyPress* pKeyPress); 00482 }; 00483 00484 00485 00486 /********************************************************************************************* 00487 00488 > class SGOilClipartDragTarget : public WinoilDragTarget 00489 00490 Author: Richard_Millican (Xara Group Ltd) <camelotdev@xara.com> 00491 Created: 12/12/95 00492 00493 Purpose: Drag Target for the mainframe, so dragging clipart into a null document 00494 situation (behind all the docs) will load a new document 00495 00496 Notes: Drag targets are destructed automatically when a drag finishes by the drag 00497 manager with which they were registered. 00498 00499 To remove a drag target at any time, destruct it - it automatically deregisters 00500 and cleans up. 00501 00502 SeeAlso: DragManagerOp::StartDrag; DragInformation; DragTarget; 00503 SGColourDragTarget::ProcessEvent 00504 00505 Documentation: Docs\Specs\DragMan.doc; Docs\HowToUse\SGallery.doc 00506 00507 *********************************************************************************************/ 00508 00509 class SGOilClipartDragTarget : public WinoilDragTarget 00510 { 00511 friend class DragManagerOp; 00512 00513 CC_DECLARE_DYNAMIC(SGOilClipartDragTarget) 00514 00515 00516 public: // Public interface 00517 SGOilClipartDragTarget(HWND TheWindow, CRect *ClientArea = NULL); 00518 00519 virtual UINT32 GetCursorID(); 00520 virtual BOOL GetStatusLineText(String_256 * TheText); 00521 00522 protected: 00523 // Process a drag-related event 00524 virtual BOOL ProcessEvent(DragEventType Event, 00525 DragInformation *pDragInfo, 00526 CPoint *pMousePos, KeyPress* pKeyPress); 00527 }; 00528 00529 00530 #endif 00531