00001 // $Id: gallery.cpp 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 // This file implements the gallery classes 00099 00100 /* 00101 */ 00102 00103 #include "camtypes.h" 00104 00105 #include "gallery.h" 00106 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 #include "camelot.h" 00108 //#include "galres.h" 00109 //#include "galstr.h" 00110 //#include "jason.h" 00111 #include "mainfrm.h" 00112 //#include "resource.h" // _R(IDD_GALDISPLAYDLG) 00113 //#include "barsdlgs.h" 00114 00115 // This is not compulsory, but you may as well put it in so that the correct version 00116 // of your file can be registered in the .exe 00117 DECLARE_SOURCE("$Revision: 1282 $"); 00118 00119 #if FALSE 00120 // **** GALLERIES ARE DEFUNCT - SEE THE NEW SUPERGALLERY CLASS INSTEAD **** 00121 00122 // An implement to match the Declare in the .h file. 00123 // If you have many classes, it is recommended to place them all together, here at the start of the file 00124 CC_IMPLEMENT_MEMDUMP(GalleryBodge, CC_CLASS_MEMDUMP) 00125 CC_IMPLEMENT_MEMDUMP(GalleryDisplayListPtr, ListItem) 00126 CC_IMPLEMENT_MEMDUMP(GalleryDisplayItem, ListItem) 00127 CC_IMPLEMENT_DYNCREATE(Gallery, DialogBarOp) 00128 CC_IMPLEMENT_DYNCREATE(GalleryDisplayDlg, DialogOp) 00129 00130 00131 // This will get Camelot to display the filename and linenumber of any memory allocations 00132 // that are not released at program exit 00133 #define new CAM_DEBUG_NEW 00134 00135 00136 // --------------------------------------------------------------------------------------------- 00137 // GalleryDisplayListPtr methods 00138 00139 00140 /*********************************************************************************************** 00141 00142 > GalleryDisplayListPtr::GalleryDisplayListPtr(OrderedList *ListPtr) 00143 00144 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00145 Created: 1/8/94 00146 Inputs: ListPtr - The list to set this object to point at 00147 Purpose: Constructor for a GalleryDisplayListPtr. 00148 Sets the ptr item to point at the given OrderedList 00149 00150 ***********************************************************************************************/ 00151 00152 GalleryDisplayListPtr::GalleryDisplayListPtr(OrderedList *ListPtr) 00153 { 00154 ERROR3IF(ListPtr == NULL, "Attempt to create NULL GalleryDisplayListPtr!\n"); 00155 DisplayList = ListPtr; 00156 } 00157 00158 00159 00160 /*********************************************************************************************** 00161 00162 > GalleryDisplayListPtr::~GalleryDisplayListPtr() 00163 00164 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00165 Created: 2/9/94 00166 Purpose: Destructor for a GalleryDisplayListPtr. 00167 00168 ***********************************************************************************************/ 00169 00170 GalleryDisplayListPtr::~GalleryDisplayListPtr() 00171 { 00172 if (DisplayList != NULL) 00173 delete DisplayList; 00174 } 00175 00176 00177 00178 00179 // --------------------------------------------------------------------------------------------- 00180 // GalleryDisplayItem methods 00181 00182 00183 /*********************************************************************************************** 00184 00185 > GalleryDisplayItem::GalleryDisplayItem() 00186 00187 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00188 Created: 12/7/94 00189 Purpose: Default constructor for a GalleryDisplayItem. UNSUPPORTED. DO NOT USE. 00190 There is an overloaded constructor which should be used in preference 00191 00192 ***********************************************************************************************/ 00193 00194 GalleryDisplayItem::GalleryDisplayItem() 00195 { 00196 // There is currently no way to set the RealItem value other than by the 00197 // overloaded constructor below. 00198 ERROR3("Unsupported call to GalleryDisplayItem constructor"); 00199 Selected = FALSE; 00200 RealItem = NULL; 00201 } 00202 00203 00204 00205 /*********************************************************************************************** 00206 00207 > GalleryDisplayItem::GalleryDisplayItem(ListItem *TheRealItem) 00208 00209 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00210 Created: 12/7/94 00211 Inputs: TheRealItem - The Real Item which the Gallery should display in its 00212 list box. 00213 Purpose: Constructor for a GalleryDisplayItem. Initialises it to reference the 00214 given ListItem. 00215 Scope: private: Use the Gallery interface, which manages the Gallery display 00216 list internally on your behalf. You should not need to know about the 00217 internal representation. 00218 SeeAlso: Gallery 00219 00220 ***********************************************************************************************/ 00221 00222 GalleryDisplayItem::GalleryDisplayItem(ListItem *TheRealItem) 00223 { 00224 ERROR3IF(TheRealItem == NULL, "GalleryDisplayItem initialised with NULL pointer"); 00225 Selected = FALSE; 00226 RealItem = TheRealItem; 00227 } 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 // --------------------------------------------------------------------------------------------- 00243 // Gallery methods 00244 00245 00246 /******************************************************************************************** 00247 00248 > Gallery::Gallery(CCRuntimeClass *Class = CC_RUNTIME_CLASS(DialogBarOp)): DialogBarOp(Class) 00249 00250 Author: Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com> 00251 Created: 22/6/94 - Source derived from InformationBarOp 00252 Inputs: - 00253 Outputs: - 00254 Returns: - 00255 Purpose: Gallery constructor (Identical to DialogOp) 00256 Errors: - 00257 SeeAlso: - 00258 00259 ********************************************************************************************/ 00260 00261 Gallery::Gallery(CCRuntimeClass *Class): DialogBarOp(Class) 00262 { 00263 GallerySize = CSize(0,0); 00264 00265 DisplayList = NULL; 00266 DisplaySequence = NULL; 00267 CurrentDisplayMode = 0; 00268 IsShaded = FALSE; 00269 } 00270 00271 00272 00273 /******************************************************************************************** 00274 00275 > Gallery::Gallery(String_32 &NewName,CCRuntimeClass *Class = CC_RUNTIME_CLASS(DialogBarOp): 00276 DialogBarOp(NewName, Class) 00277 00278 Author: Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com> 00279 Created: 22/6/94 - Source derived from InformationBarOp 00280 Inputs: - 00281 Outputs: - 00282 Returns: - 00283 Purpose: Gallery constructor (Identical to DialogOp) 00284 Errors: - 00285 SeeAlso: - 00286 00287 ********************************************************************************************/ 00288 00289 Gallery::Gallery(String_32 &NewName,CCRuntimeClass *Class) 00290 : DialogBarOp(NewName, Class) 00291 { 00292 GallerySize = CSize(0,0); 00293 00294 DisplayList = NULL; 00295 DisplaySequence = NULL; 00296 CurrentDisplayMode = 0; 00297 IsShaded = FALSE; 00298 } 00299 00300 00301 00302 /******************************************************************************************** 00303 00304 > Gallery::~Gallery() 00305 00306 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00307 Created: 30/7/94 00308 Purpose: Gallery destructor. 00309 Errors: This method checks that the DisplayList has been properly deallocated 00310 by derived classes. They should set DisplayList == NULL before they 00311 exit in order to avoid this ENSURE. If DisplayList is non-NULL, it will 00312 be deleted and an ENSURE generated. 00313 00314 ********************************************************************************************/ 00315 00316 Gallery::~Gallery() 00317 { 00318 // Deselect any sort sequence we might be using 00319 SelectDisplayList(NULL); 00320 00321 // Delete any Document DisplayList caches that exist for 'this' gallery 00322 List *DocList = &GetApplication()->Documents; 00323 Document *DocPtr = (Document *) DocList->GetHead(); 00324 OrderedList *TheDisplayList; 00325 00326 while (DocPtr != NULL) 00327 { 00328 TheDisplayList = FindDisplayListInDoc(DocPtr); 00329 00330 if (TheDisplayList != NULL) 00331 { 00332 if (TheDisplayList == DisplayList) // Remember we've deleted THE DisplayList 00333 DisplayList = NULL; 00334 00335 DeleteDisplayListFromDoc(DocPtr); // And delete the cached display list 00336 } 00337 00338 DocPtr = (Document *) DocList->GetNext(DocPtr); 00339 } 00340 00341 00342 // Ensure that the DisplayList has been deallocated by someone 00343 if (DisplayList != NULL) 00344 { 00345 // Remind the programmer to add code to deallocate the list for himself 00346 ERROR3("Gallery DisplayList memory leak on delete! Hit Ignore to continue"); 00347 00348 // And clean up 00349 delete DisplayList; 00350 DisplayList = NULL; 00351 } 00352 } 00353 00354 00355 /******************************************************************************************** 00356 00357 > virtual MsgResult Gallery::Message(Msg* Message) 00358 00359 Author: Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>/Jason 00360 Created: 22/6/94 - Source derived from InformationBarOp 00361 Inputs: Message - The message to handle 00362 Outputs: - 00363 Returns: - 00364 Purpose: A standard message handler, really. If you override this in a derived 00365 class, you must pass any unhandled event on to this base class method 00366 after handling the messages you are interested in. 00367 Errors: - 00368 SeeAlso: DialogOp::Message 00369 00370 ********************************************************************************************/ 00371 00372 MsgResult Gallery::Message(Msg* Message) 00373 { 00374 // allow BarDeath messages through even for ops with no window 00375 if (IS_OUR_DIALOG_MSG(Message)|| 00376 (((Message)->IsKindOf(CC_RUNTIME_CLASS(DialogMsg))) && 00377 ((DialogMsg*)Message)->DlgMsg == DIM_BAR_DEATH)) 00378 { 00379 00380 DialogMsg* Msg = (DialogMsg*)Message; 00381 00382 DialogBarOp::Message( Msg); 00383 00384 if(Msg->DlgMsg == DIM_BAR_DEATH) 00385 return OK; 00386 00387 switch (Msg->DlgMsg) 00388 { 00389 // case DIM_COMMIT: // OK clicked 00390 // case DIM_SOFT_COMMIT: // OK "adjust clicked" 00391 // break; 00392 00393 case DIM_CREATE: 00394 ForceRedrawOfList(); // Ensure list is redrawn with correct selection etc 00395 break; 00396 00397 case DIM_CANCEL: 00398 { 00399 /* KernelBarPos* pKernelBarPos; 00400 DockBarType Dock; 00401 if (GetMainFrame()->GetBarPosInfo(WindowID,&Dock,&pKernelBarPos)) 00402 { 00403 SetDockBarType(Dock); 00404 SetFloatingCPoint(CPoint(pKernelBarPos->x,pKernelBarPos->y)); 00405 } 00406 // Report bar is closing to interested parties 00407 BROADCAST_TO_CLASS(BarMsg(BAR_CLOSE,this),DialogOp); 00408 WindowID = NULL; 00409 */ 00410 00411 if (DisplaySequence != NULL ) 00412 { 00413 if (DisplayList != NULL) 00414 DisplayList->DeselectOrder(SortFunction, FALSE); 00415 DisplaySequence = NULL; 00416 } 00417 00418 } 00419 break; 00420 00421 00422 case DIM_SELECTION_CHANGED_COMMIT: // List item double-clicked 00423 if (Msg->GadgetID == _R(IDC_GALLERY_LISTBOX)) 00424 { 00425 // Double-click on an item makes it the only selected item, and 00426 // then applies it (in the same way as the 'apply' button) 00427 WORD Index; 00428 GetValueIndex(_R(IDC_GALLERY_LISTBOX), &Index); 00429 if (Index >= 0) 00430 { 00431 RescanSelection(); 00432 ApplyApplyItem(); 00433 } 00434 } 00435 break; 00436 00437 00438 case DIM_SELECTION_CHANGED: // List: Selection change 00439 if (Msg->GadgetID == _R(IDC_GALLERY_LISTBOX)) 00440 { 00441 RescanSelection(); 00442 DoSelectionChanged(); 00443 } 00444 break; 00445 00446 00447 case DIM_SELECTION_CANCELED: // List: All items deselected 00448 if (Msg->GadgetID == _R(IDC_GALLERY_LISTBOX)) 00449 { 00450 // Update display list selection states to keep in step with listbox 00451 SequenceItem *Ptr = FindFirstSelected(); 00452 while (Ptr != NULL) 00453 { 00454 ERROR3IF(Ptr->GetItem() == NULL, "NULL SequenceItem link in Gallery"); 00455 ((GalleryDisplayItem *) Ptr->GetItem())->SetSelected(FALSE); 00456 Ptr = FindNextSelected(Ptr); 00457 } 00458 } 00459 break; 00460 00461 00462 00463 case DIM_LFT_BN_CLICKED: 00464 switch(Msg->GadgetID) 00465 { 00466 case _R(IDC_GALLERY_APPLY): 00467 ApplyApplyItem(); 00468 break; 00469 00470 case _R(IDC_GALLERY_NEW): 00471 ApplyNewItem(); 00472 break; 00473 00474 case _R(IDC_GALLERY_DELETE): 00475 ApplyDeleteSelection(); 00476 break; 00477 00478 case _R(IDC_GALLERY_REDEFINE): 00479 ApplyRedefineItem(); 00480 break; 00481 00482 case _R(IDC_GALLERY_UNDO): 00483 ApplyUndo(); 00484 break; 00485 00486 case _R(IDC_GALLERY_MENU): 00487 ApplyGalleryMenu(); 00488 break; 00489 } 00490 break; 00491 00492 } // endswitch 00493 00494 return (DLG_EAT_IF_HUNGRY(Msg)); 00495 } // endif (IS_OUR_DIALOG_MSG) 00496 00497 00498 if (MESSAGE_IS_A(Message, DocChangingMsg)) 00499 { 00500 DocChangingMsg *Msg = (DocChangingMsg *) Message; 00501 00502 switch (Msg->State) 00503 { 00504 case DocChangingMsg::ABOUTTODIE: 00505 // If a document dies, we should delete any cached display lists 00506 // from it before it goes. (The doc will clean up, but only as an 00507 // emergency measure if we failed to do so first) 00508 00509 if (Msg->pChangingDoc != NULL) 00510 DeleteDisplayListFromDoc(Msg->pChangingDoc); 00511 break; 00512 00513 case DocChangingMsg::SELCHANGED: 00514 // If the selected document is changing to NULL then there are no 00515 // documents open/available, so the gallery should shade itself 00516 // until a new document becomes available 00517 if (Msg->pNewDoc == NULL) 00518 { 00519 SelectDisplayList(NULL); 00520 ShadeGallery(); 00521 } 00522 break; 00523 } 00524 } 00525 00526 00527 if (MESSAGE_IS_A(Message,DeathMsg)) // We must destroy the dialog if the application is dying 00528 { 00529 End(); 00530 return(OK); 00531 } 00532 00533 return(OK); 00534 } 00535 00536 00537 00538 /******************************************************************************************** 00539 00540 > BOOL Gallery::Create(void) 00541 00542 Author: Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>/Jason 00543 Created: 22/6/94 - Source derived from InformationBarOp 00544 Returns: TRUE if the window was successfully created 00545 FALSE => ERROR2 00546 Purpose: The Gallery Create method 00547 This method has been overridden to de-specialize the DialogBarOp. 00548 00549 Notes: Before doing anything else, the PreCreate handler is called. 00550 The last thing done is to invoke the PostCreate method 00551 (these should be overridden by derived classes to do stuff) 00552 SeeAlso: Gallery::PreCreate; Gallery::PostCreate 00553 00554 ********************************************************************************************/ 00555 00556 BOOL Gallery::Create(void) 00557 { 00558 // Call derived class PreCreate handler to set up the DisplayList etc 00559 if (!PreCreate()) 00560 return(FALSE); 00561 00562 ERROR2IF(DisplayList == NULL, FALSE, "NULL DisplayList in Gallery::Create"); 00563 00564 // Must set up the SortFunction with defaults, and init DisplaySequence 00565 EnsureDisplaySequence(); 00566 00567 // Bar initialisation and creation 00568 SetDockBarType(Dock); 00569 SetSlot(Slot); 00570 SetOffset(Offset); 00571 SetFloatingCPoint(FloatPos); 00572 00573 BOOL returnval = DialogOp::Create(); 00574 00575 // Call derived class PostCreate handler to fill the DisplayList etc 00576 if (returnval && !PostCreate()) 00577 return(FALSE); 00578 00579 return(returnval); 00580 } 00581 00582 00583 00584 /*********************************************************************************************** 00585 00586 > ListItem *Gallery::FindRealItem(SequenceItem *DisplayItem) 00587 00588 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00589 Created: 12/7/94 00590 Returns: NULL, or the related listitem 00591 (NULL => ERROR2) 00592 00593 Purpose: Given a Gallery Display SequenceItem, find the real ListItem object 00594 which is being displayed by the gallery. 00595 SeeAlso: Gallery::FindSequenceItem 00596 00597 ***********************************************************************************************/ 00598 00599 ListItem *Gallery::FindRealItem(SequenceItem *DisplayItem) 00600 { 00601 ERROR2IF(DisplayItem == NULL, NULL, "Gallery::FindRealItem - source item is NULL"); 00602 ERROR2IF(DisplayItem->GetItem() == NULL, NULL, "Gallery::FindRealItem - source item has NULL display item"); 00603 return( ((GalleryDisplayItem *) DisplayItem->GetItem())->GetRealItem() ); 00604 } 00605 00606 00607 00608 /*********************************************************************************************** 00609 00610 > ListItem *Gallery::FindRealItem(GalleryDisplayItem *DisplayItem) 00611 00612 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00613 Created: 12/7/94 00614 Returns: NULL, or the real ListItem 00615 NULL => ERROR2 00616 00617 Purpose: Given a Gallery Display Item, find the real ListItem object 00618 which is being displayed by the gallery. 00619 SeeAlso: Gallery::FindSequenceItem 00620 00621 ***********************************************************************************************/ 00622 00623 ListItem *Gallery::FindRealItem(GalleryDisplayItem *DisplayItem) 00624 { 00625 ERROR2IF(DisplayItem == NULL, NULL, "Gallery::FindRealItem - source item is NULL"); 00626 return( DisplayItem->GetRealItem() ); 00627 } 00628 00629 00630 00631 /*********************************************************************************************** 00632 00633 > SequenceItem *Gallery::FindSequenceItem(ListItem *TheItem) 00634 00635 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00636 Created: 12/7/94 00637 Inputs: TheItem - The ListItem for which you want to find the related display item 00638 Returns: The Display SequenceItem by which the Gallery references TheItem, 00639 or NULL if it can't be found 00640 Purpose: Given a real item, determines what item of the Gallerys Display list 00641 refers to it. You must use the SequenceItem when asking the Gallery 00642 to apply most actions to TheItem 00643 SeeAlso: Gallery::FindRealItem 00644 00645 ***********************************************************************************************/ 00646 00647 SequenceItem *Gallery::FindSequenceItem(ListItem *TheItem) 00648 { 00649 // Search for TheItem, and return a pointer to the SequenceItem which 00650 // references it, if any 00651 00652 ERROR3IF(TheItem == NULL, "NULL parameter passed to Gallery::FindSequenceItem"); 00653 EnsureDisplaySequence(); 00654 if (DisplaySequence == NULL) 00655 return(NULL); 00656 00657 SequenceItem *Ptr = (SequenceItem *) DisplaySequence->GetHead(); 00658 while (Ptr != NULL) 00659 { 00660 if (FindRealItem(Ptr) == TheItem) 00661 break; 00662 00663 Ptr = (SequenceItem *) DisplaySequence->GetNext(Ptr); 00664 } 00665 00666 return(Ptr); 00667 } 00668 00669 00670 00671 /*********************************************************************************************** 00672 00673 > DWORD Gallery::GetSelectedItemCount(void) 00674 00675 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00676 Created: 12/7/94 00677 Returns: The count (0 or positive integer) 00678 Purpose: Returns the number of items which are currently selected within the 00679 gallery displayed listbox. 00680 SeeAlso: Gallery::FindFirstSelected 00681 00682 ***********************************************************************************************/ 00683 00684 DWORD Gallery::GetSelectedItemCount(void) 00685 { 00686 ERROR3IF(DisplaySequence == NULL, "Gallery DisplaySequence is NULL!"); 00687 00688 DWORD Count = 0; 00689 00690 SequenceItem *Ptr = FindFirstSelected(); 00691 while (Ptr != NULL) 00692 { 00693 Count++; 00694 Ptr = FindNextSelected(Ptr); 00695 } 00696 00697 return(Count); 00698 } 00699 00700 00701 00702 /*********************************************************************************************** 00703 00704 > SequenceItem *Gallery::FindFirstSelected(void) 00705 00706 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00707 Created: 12/7/94 00708 Returns: NULL if no selection, else a pointer to the first selected item 00709 Purpose: Finds the first item which is selcted in the Gallery's listbox 00710 SeeAlso: Gallery::FindLastSelected; Gallery::FindNextSelected; 00711 Gallery::GetSelectedItemCount; Gallery::FindRealItem 00712 00713 ***********************************************************************************************/ 00714 00715 SequenceItem *Gallery::FindFirstSelected(void) 00716 { 00717 // **** This may be optimised in future if we actually cache the selstart 00718 // and selend items... 00719 00720 EnsureDisplaySequence(); 00721 00722 SequenceItem *Ptr = FindFirstDisplayed(); 00723 while (Ptr != NULL) 00724 { 00725 ERROR3IF(Ptr->GetItem() == NULL, "NULL SequenceItem link in Gallery"); 00726 if ( ((GalleryDisplayItem *) Ptr->GetItem())->IsSelected() ) 00727 return(Ptr); 00728 00729 Ptr = FindNextDisplayed(Ptr); 00730 } 00731 00732 return(NULL); 00733 } 00734 00735 00736 00737 /*********************************************************************************************** 00738 00739 > SequenceItem *Gallery::FindLastSelected(void) 00740 00741 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00742 Created: 12/7/94 00743 Returns: NULL if no selection, else a pointer to the last selected item 00744 Purpose: Finds the first item which is selcted in the Gallery's listbox 00745 SeeAlso: Gallery::FindFirstSelected; Gallery::FindNextSelected; 00746 Gallery::GetSelectedItemCount; Gallery::FindRealItem 00747 00748 ***********************************************************************************************/ 00749 00750 SequenceItem *Gallery::FindLastSelected(void) 00751 { 00752 // **** This may be optimised in future if we actually cache the selstart 00753 // and selend items... 00754 00755 EnsureDisplaySequence(); 00756 00757 SequenceItem *Ptr = FindLastDisplayed(); 00758 while (Ptr != NULL) 00759 { 00760 ERROR3IF(Ptr->GetItem() == NULL, "NULL SequenceItem link in Gallery"); 00761 if ( ((GalleryDisplayItem *) Ptr->GetItem())->IsSelected() ) 00762 return(Ptr); 00763 00764 Ptr = FindPreviousDisplayed(Ptr); 00765 } 00766 00767 return(NULL); 00768 } 00769 00770 00771 00772 /*********************************************************************************************** 00773 00774 > SequenceItem *Gallery::FindNextSelected(SequenceItem *CurItem) 00775 00776 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00777 Created: 12/7/94 00778 Returns: NULL if no selection or have passed the last selected item, else a 00779 pointer to the selected item 00780 Purpose: Given a selected Gallery display item, returns the next selected item 00781 SeeAlso: Gallery::FindFistSelected; Gallery::FindLastSelected; 00782 Gallery::FindPreviousSelected 00783 00784 ***********************************************************************************************/ 00785 00786 SequenceItem *Gallery::FindNextSelected(SequenceItem *CurItem) 00787 { 00788 ERROR3IF(DisplaySequence == NULL, "Gallery DisplaySequence is NULL!"); 00789 00790 CurItem = FindNextDisplayed(CurItem); 00791 while (CurItem != NULL) 00792 { 00793 ERROR3IF(CurItem->GetItem() == NULL, "NULL SequenceItem link in Gallery"); 00794 if ( ((GalleryDisplayItem *) CurItem->GetItem())->IsSelected() ) 00795 return(CurItem); 00796 00797 CurItem = FindNextDisplayed(CurItem); 00798 } 00799 00800 return(NULL); 00801 } 00802 00803 00804 00805 /*********************************************************************************************** 00806 00807 > SequenceItem *Gallery::FindPreviousSelected(SequenceItem *CurItem) 00808 00809 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00810 Created: 12/7/94 00811 Returns: NULL if no selection or have passed the first selected item, else a 00812 pointer to the selected item 00813 Purpose: Given a selected Gallery display item, returns the previous selected item 00814 SeeAlso: Gallery::FindFistSelected; Gallery::FindLastSelected; 00815 Gallery::FindNextSelected 00816 00817 ***********************************************************************************************/ 00818 00819 SequenceItem *Gallery::FindPreviousSelected(SequenceItem *CurItem) 00820 { 00821 ERROR3IF(DisplaySequence == NULL, "Gallery DisplaySequence is NULL!"); 00822 00823 CurItem = FindPreviousDisplayed(CurItem); 00824 while (CurItem != NULL) 00825 { 00826 ERROR3IF(CurItem->GetItem() == NULL, "NULL SequenceItem link in Gallery"); 00827 if ( ((GalleryDisplayItem *) CurItem->GetItem())->IsSelected() ) 00828 return(CurItem); 00829 00830 CurItem = FindPreviousDisplayed(CurItem); 00831 } 00832 00833 return(NULL); 00834 } 00835 00836 00837 00838 /*********************************************************************************************** 00839 00840 > void Gallery::DeselectAllItems(void) 00841 00842 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00843 Created: 12/7/94 00844 Purpose: Clears the selection in the Gallery listbox so that there is no selection 00845 Notes: May be called even when the gallery window is not visible 00846 SeeAlso: Gallery::SetDisplayItemSelState 00847 00848 ***********************************************************************************************/ 00849 00850 void Gallery::DeselectAllItems(void) 00851 { 00852 SequenceItem *Ptr = FindFirstSelected(); 00853 00854 while (Ptr != NULL) 00855 { 00856 ERROR3IF(Ptr->GetItem() == NULL, "NULL SequenceItem link in Gallery"); 00857 ((GalleryDisplayItem *) Ptr->GetItem())->SetSelected(FALSE); 00858 00859 Ptr = FindNextSelected(Ptr); 00860 } 00861 00862 // And if the window is open, clear the selection out of the list box 00863 if (IsVisible()) 00864 SetBoolGadgetSelected(_R(IDC_GALLERY_LISTBOX), FALSE, -1); 00865 } 00866 00867 00868 00869 /*********************************************************************************************** 00870 00871 > INT32 Gallery::CalculateListIndex(SequenceItem *TheItem) 00872 00873 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00874 Created: 14/7/94 00875 Inputs: TheItem - Points to the item you want the list index of 00876 Returns: -1 (item not in display!), or the index (0 .. NumDisplayItems-1) 00877 Purpose: Determines what position (0 .. NumDisplayItems-1) the given item 00878 is in the gallery display ListBox. 00879 00880 ***********************************************************************************************/ 00881 00882 INT32 Gallery::CalculateListIndex(SequenceItem *TheItem) 00883 { 00884 INT32 Index = 0; 00885 SequenceItem *Ptr = FindFirstDisplayed(); 00886 00887 while (Ptr != NULL) 00888 { 00889 if (Ptr == TheItem) 00890 return(Index); 00891 00892 Index++; 00893 Ptr = FindNextDisplayed(Ptr); 00894 } 00895 00896 return(-1); 00897 } 00898 00899 00900 00901 /*********************************************************************************************** 00902 00903 > SequenceItem *Gallery::FindItemByIndex(INT32 ItemIndex) 00904 00905 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00906 Created: 10/10/94 00907 Inputs: ItemIndex - the index of the item you wish to find 00908 Returns: NULL (Out of range index), or a pointer to the indexed item 00909 Purpose: Given a position (0 .. NumDisplayItems-1), finds the given item 00910 in the gallery display ListBox. 00911 00912 ***********************************************************************************************/ 00913 00914 SequenceItem *Gallery::FindItemByIndex(INT32 ItemIndex) 00915 { 00916 SequenceItem *Ptr = FindFirstDisplayed(); 00917 INT32 Index = 0; 00918 00919 while (Ptr != NULL) 00920 { 00921 if (Index == ItemIndex) // Have found the item - return it 00922 return(Ptr); 00923 00924 Ptr = FindNextDisplayed(Ptr); 00925 Index++; 00926 } 00927 00928 return(NULL); // Item not found 00929 } 00930 00931 00932 00933 /*********************************************************************************************** 00934 00935 > void Gallery::SetDisplayItemSelState(SequenceItem *TheItem, BOOL IsSelected) 00936 00937 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00938 Created: 12/7/94 00939 Inputs: TheItem - Points to the item to select/deselect 00940 IsSelected - TRUE to select, FALSE to deselect, the item 00941 Purpose: Sets the selection state of a given Gallery display item 00942 00943 Notes: May be called even when the gallery window is not open on screen 00944 Errors: An ERROR2 is reported if a NULL item is passed in - the function 00945 returns without doing anything in this case. 00946 00947 SeeAlso: Gallery::DeselectAllItems 00948 00949 ***********************************************************************************************/ 00950 00951 void Gallery::SetDisplayItemSelState(SequenceItem *TheItem, BOOL IsSelected) 00952 { 00953 if (TheItem == NULL) 00954 { 00955 ERROR2RAW("NULL GalleryDisplayItem passed to Gallery::SetDisplayItemSelState"); 00956 return; 00957 } 00958 00959 ((GalleryDisplayItem *) TheItem->GetItem())->SetSelected(IsSelected); 00960 00961 // And update the listbox selection state 00962 DWORD Index = CalculateListIndex(TheItem); 00963 if (Index >= 0 && IsVisible() && !IsShaded) 00964 SetBoolGadgetSelected(_R(IDC_GALLERY_LISTBOX), IsSelected, (INT32)Index); 00965 } 00966 00967 00968 00969 /*********************************************************************************************** 00970 00971 > void Gallery::SetDisplayItemSelState(INT32 ItemIndex, BOOL IsSelected) 00972 00973 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00974 Created: 12/7/94 00975 Inputs: ItemIndex - Indexes the item to select/deselect in the DisplayList 00976 IsSelected - TRUE to select, FALSE to deselect, the item 00977 00978 Purpose: Sets the selection state of a given Gallery display item 00979 00980 Notes: May be called even when the gallery window is not open on screen 00981 SeeAlso: Gallery::DeselectAllItems 00982 00983 ***********************************************************************************************/ 00984 00985 void Gallery::SetDisplayItemSelState(INT32 ItemIndex, BOOL IsSelected) 00986 { 00987 SequenceItem *TheItem = FindItemByIndex(ItemIndex); 00988 00989 ERROR3IF(ItemIndex < 0 || TheItem == NULL, 00990 "Out of range item index passed to Gallery::SetDisplayItemSelState"); 00991 if (TheItem != NULL) 00992 { 00993 ((GalleryDisplayItem *) TheItem->GetItem())->SetSelected(IsSelected); 00994 00995 // And update the listbox selection state 00996 if (IsVisible() && !IsShaded) 00997 SetBoolGadgetSelected(_R(IDC_GALLERY_LISTBOX), IsSelected, (INT32)ItemIndex); 00998 } 00999 } 01000 01001 01002 01003 /*********************************************************************************************** 01004 01005 > DWORD Gallery::GetDisplayedItemCount(void) 01006 01007 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01008 Created: 12/7/94 01009 Returns: The number of items in the Gallery display (0 or positive number) 01010 Purpose: Find out how many items are being displayed by the gallery 01011 01012 ***********************************************************************************************/ 01013 01014 DWORD Gallery::GetDisplayedItemCount(void) 01015 { 01016 if (DisplayList == NULL) 01017 return(0); 01018 01019 EnsureDisplaySequence(); 01020 return(DisplaySequence->GetCount()); 01021 } 01022 01023 01024 01025 /*********************************************************************************************** 01026 01027 > BOOL Gallery::AddItemToDisplay(ListItem *TheItem) 01028 01029 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01030 Created: 12/7/94 01031 Inputs: TheItem - The real item which you wish to add to the Gallerys list box 01032 Returns: TRUE if it succeeded 01033 FALSE => ERROR1 01034 Purpose: Adds the given item to the displayed list of items. This creates a 01035 SequenceItem by which you will refer to the real item in the future. 01036 The item will be added to the Gallery display list (this will *not* affect 01037 the item's presence in any other lists - the Gallery uses a pointer to 01038 it from a display list). The exact position of the item i this list 01039 is determined by the current sort order applied to the gallery, so 01040 you cannot assume that it will appear anywhere in particular. 01041 SeeAlso: Gallery::AddListToDisplay 01042 01043 ***********************************************************************************************/ 01044 01045 BOOL Gallery::AddItemToDisplay(ListItem *TheItem) 01046 { 01047 // Adds the given item to the display list, returning FALSE if it fails 01048 01049 ERROR3IF(TheItem == NULL, 01050 "Gallery::AddItemToDisplay would appreciate being passed a non-NULL item!"); 01051 01052 ERROR3IF(DisplayList == NULL, "Gallery DisplayList is NULL!"); 01053 01054 GalleryDisplayItem *NewDItem = new GalleryDisplayItem(TheItem); 01055 if (NewDItem == NULL || !DisplayList->AddItem(NewDItem)) 01056 return(FALSE); 01057 01058 return(TRUE); 01059 } 01060 01061 01062 01063 /*********************************************************************************************** 01064 01065 > BOOL Gallery::AddListToDisplay(List *TheList) 01066 01067 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01068 Created: 12/7/94 01069 Inputs: TheList - The list of real items which you wish to add to the Gallerys list box 01070 Returns: TRUE if it succeeded 01071 Purpose: Adds the given items to the displayed list of items. This creates a 01072 SequenceItem by which you will refer to the real item in the future. 01073 The item will be added to the Gallery display list (this will *not* affect 01074 the item's presence in any other lists - the Gallery uses a pointer to 01075 it from a display list). The exact position of the items in this list 01076 is determined by the current sort order applied to the gallery, so 01077 you cannot assume that they will appear anywhere in particular. 01078 SeeAlso: Gallery::AddItemToDisplay 01079 01080 ***********************************************************************************************/ 01081 01082 BOOL Gallery::AddListToDisplay(List *TheList) 01083 { 01084 // Adds all items in the list to the display list 01085 // Returns TRUE for success 01086 01087 ERROR3IF(TheList == NULL, 01088 "Gallery::AddListToDisplay would appreciate being passed a non-NULL list ptr!"); 01089 01090 ERROR3IF(DisplayList == NULL, "Gallery DisplayList is NULL!"); 01091 01092 ListItem *SourcePtr = TheList->GetHead(); 01093 while (SourcePtr != NULL) 01094 { 01095 if (!AddItemToDisplay(SourcePtr)) 01096 return(FALSE); 01097 01098 SourcePtr = TheList->GetNext(SourcePtr); 01099 } 01100 01101 return(TRUE); 01102 } 01103 01104 01105 01106 /*********************************************************************************************** 01107 01108 > BOOL Gallery::RemoveItemFromDisplay(SequenceItem *TheSeqItem) 01109 01110 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01111 Created: 12/7/94 01112 Inputs: TheSeqItem - The display item to remove from the display 01113 Returns: TRUE if it succeeds 01114 01115 Purpose: Removes the given item from the display. This does NOT affect the 01116 original (real) item, just stops displaying it in the Gallery list box. 01117 01118 ***********************************************************************************************/ 01119 01120 BOOL Gallery::RemoveItemFromDisplay(SequenceItem *TheSeqItem) 01121 { 01122 // Deletes the given DisplayItem, effectively removing its master item from display 01123 // DOES NOT delete the master item 01124 01125 ERROR3IF(DisplayList == NULL, "Gallery DisplayList is NULL!"); 01126 if (TheSeqItem != NULL) 01127 { 01128 DisplayList->RemoveItem(TheSeqItem); 01129 return(TRUE); 01130 } 01131 01132 return(FALSE); 01133 } 01134 01135 01136 01137 /*********************************************************************************************** 01138 01139 > BOOL Gallery::RemoveItemFromDisplay(ListItem *TheItem) 01140 01141 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01142 Created: 12/7/94 01143 Inputs: TheItem - The real item to remove from the display 01144 Returns: TRUE if it succeeds 01145 01146 Purpose: Removes the given item from the display. This does NOT affect the 01147 original (real) item, just stops displaying it in the Gallery list box. 01148 01149 Notes: If you have a pointer to the SequenceItem associated with TheItem, you 01150 should pass that into the overloaded function instead, as it is a 01151 much more efficient way of removing the item. 01152 01153 ***********************************************************************************************/ 01154 01155 BOOL Gallery::RemoveItemFromDisplay(ListItem *TheItem) 01156 { 01157 return(RemoveItemFromDisplay(FindSequenceItem(TheItem))); 01158 } 01159 01160 01161 01162 /*********************************************************************************************** 01163 01164 > void Gallery::RemoveAllItemsFromDisplay(void) 01165 01166 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01167 Created: 18/7/94 01168 Purpose: Removes all items from the display, effectively clearing the listbox. 01169 This does NOT affect the original (real) items, just stops displaying 01170 them in the Gallery list box. 01171 01172 ***********************************************************************************************/ 01173 01174 void Gallery::RemoveAllItemsFromDisplay(void) 01175 { 01176 if (DisplayList != NULL) 01177 DisplayList->DeleteAll(); 01178 } 01179 01180 01181 01182 /*********************************************************************************************** 01183 01184 > void Gallery::ForceRedrawOfItem(SequenceItem* pThisSeqItem) 01185 01186 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (Recoded by Jason) 01187 Created: 9/8/94 01188 Inputs: pThisSeqItem = item that specifies the item to be redrawn 01189 Outputs: - 01190 Returns: - 01191 Purpose: Redraws the given item in the list 01192 01193 ***********************************************************************************************/ 01194 01195 void Gallery::ForceRedrawOfItem(SequenceItem* pThisSeqItem) 01196 { 01197 INT32 Index = CalculateListIndex(pThisSeqItem); 01198 01199 if (Index >= 0) 01200 { 01201 StringBase* pText = GetItemText(FindRealItem(pThisSeqItem)); 01202 01203 if (pText != NULL) 01204 SetStringGadgetValue(_R(IDC_GALLERY_LISTBOX), pText, FALSE, Index); 01205 #ifdef _DEBUG 01206 else 01207 { 01208 String_64 Bob("Unknown Gallery item"); 01209 SetStringGadgetValue(_R(IDC_GALLERY_LISTBOX), &Bob, FALSE, Index); 01210 } 01211 #endif 01212 } 01213 } 01214 01215 01216 01217 /*********************************************************************************************** 01218 01219 > void Gallery::ForceRedrawOfItem(INT32 Index) 01220 01221 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (Recoded by Jason) 01222 Created: 9/8/94 01223 Inputs: Index - index into the DisplayList specifying the item to be redrawn 01224 Outputs: - 01225 Returns: - 01226 Purpose: Redraws the given item in the list 01227 01228 ***********************************************************************************************/ 01229 01230 void Gallery::ForceRedrawOfItem(INT32 Index) 01231 { 01232 SequenceItem *pSeqItem = FindItemByIndex(Index); 01233 01234 if (pSeqItem != NULL) 01235 { 01236 StringBase* pText = GetItemText(FindRealItem(pSeqItem)); 01237 01238 if (pText != NULL) 01239 SetStringGadgetValue(_R(IDC_GALLERY_LISTBOX), pText, FALSE, Index); 01240 #ifdef _DEBUG 01241 else 01242 { 01243 String_64 Bob("Unknown Gallery item"); 01244 SetStringGadgetValue(_R(IDC_GALLERY_LISTBOX), &Bob, FALSE, Index); 01245 } 01246 #endif 01247 } 01248 } 01249 01250 01251 01252 /*********************************************************************************************** 01253 01254 > void Gallery::ForceRedrawOfList(void) 01255 01256 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01257 Created: 12/7/94 01258 Purpose: Causes the Gallerys list box to be redrawn. After some operations, 01259 the list box is not automatically invalidated for redraw so that 01260 many operations can be applied to it in one go. Maybe. 01261 01262 ***********************************************************************************************/ 01263 01264 void Gallery::ForceRedrawOfList(void) 01265 { 01266 // re-paints the gallery list box to show the new gallery information 01267 if (DisplayList == NULL) 01268 return; 01269 01270 if (DisplaySequence == NULL) 01271 DisplaySequence = DisplayList->SelectOrder(SortFunction, FALSE); 01272 else 01273 DisplayList->ReSortOrder(SortFunction, FALSE); 01274 01275 01276 // **** Temporary bodge! The list will be owner-drawn later **** 01277 // We re-create the entire listbox list from our display list 01278 if (IsVisible()) 01279 { 01280 // GadgetRedraw(_R(IDC_GALLERY_LISTBOX), FALSE); // Disable redraw for a while 01281 DeleteAllValues(_R(IDC_GALLERY_LISTBOX)); 01282 01283 DWORD Index = 0; 01284 StringBase *TheText; 01285 SequenceItem *Ptr = FindFirstDisplayed(); 01286 while (Ptr) 01287 { 01288 TheText = GetItemText(FindRealItem(Ptr)); 01289 01290 if (TheText != NULL) 01291 SetStringGadgetValue(_R(IDC_GALLERY_LISTBOX), TheText); 01292 #ifdef _DEBUG 01293 else 01294 { 01295 String_64 Bob("Unknown Gallery item"); 01296 SetStringGadgetValue(_R(IDC_GALLERY_LISTBOX), &Bob); 01297 } 01298 #endif 01299 // Chris .. Commented out for Jason 01300 // And ensure the item is not marked as selected 01301 //((GalleryDisplayItem *) Ptr->GetItem())->SetSelected(FALSE); 01302 01303 Ptr = FindNextDisplayed(Ptr); 01304 Index++; 01305 } 01306 01307 // GadgetRedraw(_R(IDC_GALLERY_LISTBOX), TRUE); // Re-enable redraw 01308 01309 SetSelectionFromDisplayList(); 01310 } 01311 } 01312 01313 01314 01315 /******************************************************************************************** 01316 01317 > void Gallery::ShadeGallery(void) 01318 01319 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01320 Created: 5/9/94 01321 Purpose: Shades the gallery - this ensures that all buttons/lists are 01322 shaded and non-clickable by the user. If the gallery is already 01323 in this state, nothing happens. Used by derived gallery classes 01324 to ensure that they are shaded when no scope document is available. 01325 SeeAlso: Gallery::UnshadeGallery 01326 01327 ********************************************************************************************/ 01328 01329 void Gallery::ShadeGallery(void) 01330 { 01331 if (IsVisible()) 01332 { 01333 DeleteAllValues(_R(IDC_GALLERY_LISTBOX)); // Blank out the list box 01334 UnshadeGallery(FALSE); // Shade all the buttons and listbox 01335 } 01336 IsShaded = TRUE; 01337 } 01338 01339 01340 01341 /******************************************************************************************** 01342 01343 > void Gallery::UnshadeGallery(BOOL UnshadeIt = TRUE) 01344 01345 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01346 Created: 5/9/94 01347 Inputs: UnshadeIt - You can ignore this. (Used internally to allow 01348 one generic routine to serve both shading and unshading) 01349 01350 Purpose: Unshades the gallery - this ensures that all buttons/lists are 01351 unshaded and clickable by the user. If the gallery is already 01352 in this state, nothing happens. Used by derived gallery classes 01353 to ensure that they are unshaded when a scope document is available. 01354 01355 SeeAlso: Gallery::ShadeGallery 01356 01357 ********************************************************************************************/ 01358 01359 void Gallery::UnshadeGallery(BOOL UnshadeIt) 01360 { 01361 if (IsVisible()) 01362 { 01363 EnableGadget(_R(IDC_GALLERY_APPLY), UnshadeIt); 01364 EnableGadget(_R(IDC_GALLERY_NEW), UnshadeIt); 01365 EnableGadget(_R(IDC_GALLERY_DELETE), UnshadeIt); 01366 EnableGadget(_R(IDC_GALLERY_REDEFINE), UnshadeIt); 01367 EnableGadget(_R(IDC_GALLERY_UNDO), UnshadeIt); 01368 EnableGadget(_R(IDC_GALLERY_MENU), UnshadeIt); 01369 01370 EnableGadget(_R(IDC_GALLERY_LISTBOX), UnshadeIt); 01371 01372 DoShadeGallery(!UnshadeIt); // Call derived gallery to handle its shading stuff 01373 } 01374 IsShaded = !UnshadeIt; 01375 } 01376 01377 01378 01379 /******************************************************************************************** 01380 01381 > INT32 Gallery::SortFunction(OrderedList *Parent, ListItem *Item1, ListItem *Item2) 01382 01383 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01384 Created: 12/7/94 01385 Inputs: Parent - the OrderedList which the items are in 01386 Item1, Item2 - The two items to be compared 01387 Outputs: - 01388 Returns: A Negative/Zero/Positive result to indicate the result of comparing 01389 the two items. 01390 Purpose: Special multi-key list comparator function. 01391 This provides the sort mode which has been set by the derived Gallery 01392 class, using the OrderedList::SortMode sort key array provided in the 01393 Display OrderedList. 01394 Scope: private 01395 SeeAlso: OrderedList; keyword ListComparator 01396 01397 ********************************************************************************************/ 01398 01399 INT32 Gallery::SortFunction(OrderedList *Parent, ListItem *Item1, ListItem *Item2) 01400 { 01401 ListComparator SortFn; 01402 INT32 result = 0; 01403 INT32 i = 0; 01404 01405 ERROR3IF(Parent == NULL || Item1 == NULL || Item2 == NULL, 01406 "NULL parameter(s) passed to Gallery SortFunction!"); 01407 01408 while (i < MaxSortKeys && result == 0) 01409 { 01410 if (Parent->SortMode[i].Info != NULL) 01411 { 01412 SortFn = Parent->SortMode[i].Info->GetSortFn(); 01413 01414 if (Parent->SortMode[i].Reversed) 01415 result = SortFn(Parent, Item2, Item1); 01416 else 01417 result = SortFn(Parent, Item1, Item2); 01418 } 01419 01420 i++; 01421 } 01422 return(result); 01423 } 01424 01425 01426 01427 /*********************************************************************************************** 01428 01429 > void Gallery::ApplyApplySelection(void) 01430 01431 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01432 Created: 20/7/94 01433 Purpose: Calls the overridden methods which deal with applying the selection 01434 Scope: private subroutine for gallery base class 01435 01436 ***********************************************************************************************/ 01437 01438 void Gallery::ApplyApplyItem(void) 01439 { 01440 SequenceItem *Ptr = FindFirstSelected(); 01441 01442 if (Ptr != NULL) 01443 DoApplyItem(FindRealItem(Ptr)); 01444 } 01445 01446 01447 01448 /*********************************************************************************************** 01449 01450 > void Gallery::ApplyNewItem(void) 01451 01452 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01453 Created: 20/7/94 01454 Purpose: Calls the overridden methods which deal with creating a new item 01455 Scope: private subroutine for gallery base class 01456 01457 ***********************************************************************************************/ 01458 01459 void Gallery::ApplyNewItem(void) 01460 { 01461 SequenceItem *Ptr = FindFirstSelected(); 01462 01463 ListItem *BasedOnItem = (Ptr == NULL) ? NULL : FindRealItem(Ptr); 01464 01465 ListItem *NewItem = DoCreateNewItem(BasedOnItem); 01466 } 01467 01468 01469 01470 /*********************************************************************************************** 01471 01472 > void Gallery::ApplyDeleteSelection(void) 01473 01474 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01475 Created: 12/7/94 01476 Purpose: Calls the overridden methods which deal with deletion of the selection 01477 Scope: private subroutine for gallery base class 01478 01479 ***********************************************************************************************/ 01480 01481 void Gallery::ApplyDeleteSelection(void) 01482 { 01483 if (PrepareToDelete() && DoDeleteSelection()) 01484 { 01485 // Should update the listbox by removing the killed items... **** !!!! 01486 // (The deleted items are the current selection) 01487 // Note that this should tie in with ForceRedrawOfList in some way to stop 01488 // rebuilding of the list all the time 01489 } 01490 } 01491 01492 01493 01494 /*********************************************************************************************** 01495 01496 > void Gallery::ApplyRedefineSelection(void) 01497 01498 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01499 Created: 20/7/94 01500 Purpose: Calls the overridden methods which deal with redefining (editing) the 01501 selection. 01502 Scope: private subroutine for gallery base class 01503 01504 ***********************************************************************************************/ 01505 01506 void Gallery::ApplyRedefineItem(void) 01507 { 01508 SequenceItem *Ptr = FindFirstSelected(); 01509 01510 if (Ptr != NULL) 01511 DoRedefineItem(FindRealItem(Ptr)); 01512 } 01513 01514 01515 01516 /*********************************************************************************************** 01517 01518 > void Gallery::ApplyUndo(void) 01519 01520 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01521 Created: 20/7/94 01522 Purpose: Deals with UNDOing actions which were DOne with this Gallery 01523 Notes: Currently not fully implemented - undoes everything just as the normal undo 01524 button does (i.e. does not stop at stuff this gallery created) 01525 Scope: private subroutine for gallery base class 01526 01527 ***********************************************************************************************/ 01528 01529 void Gallery::ApplyUndo(void) 01530 { 01531 if (GetGalleryDocument() != NULL) 01532 GetGalleryDocument()->GetOpHistory().UndoPrev(); 01533 01534 // !!!! ToDo: Should only undo actions that were done by this gallery 01535 } 01536 01537 01538 01539 /*********************************************************************************************** 01540 01541 > void Gallery::ApplyGalleryMenu(void) 01542 01543 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01544 Created: 20/7/94 01545 Purpose: Calls the overridden methods which deal with showing the Gallery menu 01546 Scope: private subroutine for gallery base class 01547 01548 ***********************************************************************************************/ 01549 01550 void Gallery::ApplyGalleryMenu(void) 01551 { 01552 01553 // !!!! ToDo 01554 #if FALSE 01555 DoShowMenu(); // Call the derived DoShowMenu method to show the menu 01556 01557 #else 01558 01559 // a menu item. maybe. perhaps. dunno really. 01560 01561 // Create a Gallery display options dialogue 01562 GalleryDisplayDlg *DisplayDlg = new GalleryDisplayDlg; 01563 01564 01565 if (DisplayDlg != NULL) 01566 { 01567 // Set its parent gallery to be us. 01568 DisplayDlg->SetParentGallery(this); 01569 01570 // And attempt to show it. 01571 if (DisplayDlg->Create()) 01572 DisplayDlg->Open(); 01573 else 01574 DisplayDlg->End(); 01575 } 01576 01577 #endif 01578 } 01579 01580 01581 01582 /*********************************************************************************************** 01583 01584 > void Gallery::SetSelectionFromDisplayList(void) 01585 01586 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01587 Created: 11/10/94 01588 Purpose: Sets the list box selection to the same state as the DisplayList's 01589 selection cache. 01590 SeeAlso: Gallery:RescanSelection 01591 01592 ***********************************************************************************************/ 01593 01594 void Gallery::SetSelectionFromDisplayList(void) 01595 { 01596 if (DisplayList == NULL || !IsVisible()) 01597 return; 01598 01599 // GadgetRedraw(_R(IDC_GALLERY_LISTBOX), FALSE); // Disable listbox redraw 01600 SetBoolGadgetSelected(_R(IDC_GALLERY_LISTBOX), FALSE, -1); // First, clear the selection 01601 01602 INT32 Index = 0; 01603 SequenceItem *Ptr = FindFirstDisplayed(); 01604 01605 while (Ptr != NULL) 01606 { 01607 if ( ((GalleryDisplayItem *) Ptr->GetItem())->IsSelected() ) 01608 SetBoolGadgetSelected(_R(IDC_GALLERY_LISTBOX), TRUE, Index); 01609 01610 Ptr = FindNextDisplayed(Ptr); 01611 Index++; 01612 } 01613 01614 // GadgetRedraw(_R(IDC_GALLERY_LISTBOX), TRUE); // Re-enable listbox redraw 01615 01616 #ifdef _DEBUG 01617 INT32 Count; 01618 GetValueCount(_R(IDC_GALLERY_LISTBOX), &Count); 01619 ERROR3IF(Index != (INT32) Count, 01620 "Gallery::SetSelectionFromDisplayList: Disparity between DisplayList and ListBox list!"); 01621 #endif 01622 } 01623 01624 01625 /*********************************************************************************************** 01626 01627 > DWORD Gallery::RescanSelection(void) 01628 01629 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01630 Created: 20/7/94 01631 Purpose: Scans the list box to bring the DisplayList's selction cache into 01632 line with the current list box state. 01633 SeeAlso: Gallery::SetSelectionFromDisplayList 01634 01635 ***********************************************************************************************/ 01636 01637 void Gallery::RescanSelection(void) 01638 { 01639 if (DisplayList == NULL || !IsVisible()) 01640 return; 01641 01642 BOOL IsSelected; 01643 BOOL Valid; 01644 UINT32 Index = 0; 01645 SequenceItem *Ptr = FindFirstDisplayed(); 01646 01647 while (Ptr != NULL) 01648 { 01649 IsSelected = GetBoolGadgetSelected(_R(IDC_GALLERY_LISTBOX), 0, &Valid, Index); 01650 ERROR3IF(!Valid, "Gallery::RescanSelection is scanning invalid items!"); 01651 01652 ((GalleryDisplayItem *) Ptr->GetItem())->SetSelected(IsSelected); 01653 01654 Ptr = FindNextDisplayed(Ptr); 01655 Index++; 01656 } 01657 01658 01659 #ifdef _DEBUG 01660 INT32 Count; 01661 GetValueCount(_R(IDC_GALLERY_LISTBOX), &Count); 01662 ERROR3IF(Index != (UINT32) Count, 01663 "Gallery::RescanSelection: Disparity between DisplayList and ListBox list!"); 01664 #endif 01665 } 01666 01667 01668 01669 01670 01671 01672 /******************************************************************************************** 01673 01674 > virtual BOOL Gallery::PreCreate(void) 01675 01676 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01677 Created: 18/7/94 01678 Returns: TRUE if it is successful; FALSE to abort creation of the window 01679 01680 Purpose: Example Gallery PreCreate handler 01681 01682 Notes: This method is called whenever the gallery window is about to be 01683 created. It should be overridden by derived classes. 01684 01685 At this point, the gallery should set up data structures - it is 01686 *essential* that DisplayList is set up by the end of this method. 01687 (As it is used in the creation of the window) 01688 Note that you cannot AddItemToDisplay etc in this method, as 01689 although the display list exists, the related window controls 01690 do not yet exist, and ENSURE failures will result. 01691 01692 ********************************************************************************************/ 01693 01694 BOOL Gallery::PreCreate(void) 01695 { 01696 return(TRUE); 01697 } 01698 01699 01700 01701 /******************************************************************************************** 01702 01703 > virtual BOOL Gallery::PostCreate(void) 01704 01705 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01706 Created: 18/7/94 01707 Returns: TRUE if it is successful; FALSE to abort creation of the window 01708 01709 Purpose: Example Gallery PostCreate handler 01710 01711 Notes: This method is called whenever the gallery window is created, AFTER 01712 the window has been brought into existence. It should be overridden 01713 by derived classes. 01714 01715 At this point (and henceforth), the gallery can add items to 01716 the DisplayList, etc. as the display controls now exist. 01717 01718 ********************************************************************************************/ 01719 01720 BOOL Gallery::PostCreate(void) 01721 { 01722 return(TRUE); 01723 } 01724 01725 01726 01727 /*********************************************************************************************** 01728 01729 > virtual BOOL Gallery::DoRedrawAnItem(ListItem *Item, BOOL Large, UINT32 DisplayMode); 01730 01731 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01732 Created: 12/7/94 01733 Inputs: Item - The item to be redrawn 01734 Large - TRUE for large mode, FALSE for small mode redraw 01735 DisplayMode - derived gallery defined display mode index which 01736 determines how the item is redrawn (icon only, name only, full info) 01737 01738 Returns: TRUE if it redraws successfully 01739 Purpose: Redraws a display list item. MUST be overridden by derived class 01740 (it would be pure virtual but for DYNCREATE) 01741 01742 ***********************************************************************************************/ 01743 01744 BOOL Gallery::DoRedrawAnItem(ListItem *Item, BOOL Large, UINT32 DisplayMode) 01745 { 01746 ERROR3("Unimplemented Gallery::RedrawAnItem override!"); 01747 return(FALSE); 01748 } 01749 01750 01751 01752 /*********************************************************************************************** 01753 01754 > virtual BOOL Gallery::PrepareToDelete(void) 01755 01756 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01757 Created: 12/7/94 01758 Returns: TRUE if it is OK to go ahead and delete the current selection 01759 Purpose: Checks if it is OK to delete the selection. Should be overridden 01760 by the derived class. If not overridden, will return TRUE, so that 01761 it is always "ok" to delete the selection. 01762 01763 ***********************************************************************************************/ 01764 01765 BOOL Gallery::PrepareToDelete(void) 01766 { 01767 return(TRUE); 01768 } 01769 01770 01771 01772 /*********************************************************************************************** 01773 01774 > virtual StringBase *Gallery::GetItemText(ListItem *TheItem) 01775 01776 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01777 Created: 19/7/94 01778 Returns: NULL, or a pointer to the item's text 01779 01780 Purpose: STAGE 1 - SIMPLE GALLERY IMPLEMENTATION 01781 01782 This method is overridden by derived galleries to provide text 01783 for each displayed item. This will not be used once user-redraw 01784 has been implemented, but is used for the time being. 01785 01786 ***********************************************************************************************/ 01787 01788 StringBase *Gallery::GetItemText(ListItem *TheItem) 01789 { 01790 return(NULL); 01791 } 01792 01793 01794 01795 /*********************************************************************************************** 01796 01797 > virtual BOOL Gallery::DoDeleteSelection(void) 01798 01799 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01800 Created: 12/7/94 01801 Returns: TRUE if the selected items were successfully deleted 01802 Purpose: Deletes the selection. This function MUST be overridden by the 01803 derived class. (it would be pure virtual but for DYNCREATE) 01804 SeeAlso: ColourGallery::DoDeleteSelection 01805 01806 ***********************************************************************************************/ 01807 01808 BOOL Gallery::DoDeleteSelection(void) 01809 { 01810 ERROR3("Unimplemented Gallery::DoDeleteSelection override!"); 01811 return(TRUE); 01812 } 01813 01814 01815 01816 /*********************************************************************************************** 01817 01818 > virtual ListItem *Gallery::DoCreateNewItem(ListItem *BasedOn) 01819 01820 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01821 Created: 20/7/94 01822 Inputs: BasedOn - This is the item in the gallery display on which the 01823 new item should be based. If there is no Gallery selection, this parameter 01824 will be NULL, in which case you should read the sttributes of the current 01825 selection of object(s) in the document to determine what to base your 01826 new item on. If this fails, then you should create a new item with some 01827 kind of default settings. 01828 01829 Returns: NULL, or the newly created real item 01830 Purpose: This function is meant to be overridden in derived classes 01831 It creates a new item and adds it to the Gallery DisplayList 01832 The item may be created by cloning/deriving/basing-on the 01833 selected item, depending on the type of Gallery concerned. 01834 01835 ***********************************************************************************************/ 01836 01837 ListItem *Gallery::DoCreateNewItem(ListItem *BasedOn) 01838 { 01839 return(NULL); 01840 } 01841 01842 01843 01844 /*********************************************************************************************** 01845 01846 > virtual void Gallery::DoApplyItem(ListItem *ItemToApply) 01847 01848 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01849 Created: 20/7/94 01850 Inputs: ItemToApply - The item to apply 01851 Purpose: This function is meant to be overridden in derived classes 01852 It applies the selected item to the document in whatever way 01853 is appropriate to its particular data item type. 01854 01855 ***********************************************************************************************/ 01856 01857 void Gallery::DoApplyItem(ListItem *ItemToApply) 01858 { 01859 } 01860 01861 01862 01863 /*********************************************************************************************** 01864 01865 > virtual BOOL Gallery::DoRedefineItem(ListItem *ItemToRedefine) 01866 01867 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01868 Created: 20/7/94 01869 01870 Inputs: ItemToRedefine - The item which should be redefined 01871 01872 Returns: TRUE if the item was changed (or if you're not sure). 01873 FALSE if the item definitely was not changed (to save us 01874 re-sorting and drawing the displayed list) 01875 01876 Purpose: This function is meant to be overridden in derived classes 01877 It allows the user to 'redefine' the item in some way, using 01878 an item editor (such as a colour picker) 01879 01880 ***********************************************************************************************/ 01881 01882 BOOL Gallery::DoRedefineItem(ListItem *ItemToRedefine) 01883 { 01884 return(TRUE); 01885 } 01886 01887 01888 01889 /*********************************************************************************************** 01890 01891 > virtual void Gallery::DoSpecialClick(ListItem *ClickedItem) 01892 01893 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01894 Created: 7/10/94 01895 Inputs: ClickedItem - The item which has been special clicked 01896 01897 Purpose: This function is meant to be overridden in derived classes 01898 It handles a special (alt-) click on a list item. This is generally used 01899 as a short-cut to bring up an editor on the clicked item, but the exact 01900 interpretation is left to the derived gallery to decide. 01901 01902 ***********************************************************************************************/ 01903 01904 void Gallery::DoSpecialClick(ListItem *ClickedItem) 01905 { 01906 } 01907 01908 01909 01910 /*********************************************************************************************** 01911 01912 > virtual void Gallery::DoSelectionChanged(void) 01913 01914 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01915 Created: 8/8/94 01916 Inputs: - 01917 Outputs: - 01918 Returns: - 01919 Purpose: This method is called by the base class when the gallery receives a 01920 selection change message on the list box, to inform interested derived 01921 galleries of the change in the selection. 01922 01923 ***********************************************************************************************/ 01924 01925 void Gallery::DoSelectionChanged(void) 01926 { 01927 } 01928 01929 01930 01931 /*********************************************************************************************** 01932 01933 > virtual void Gallery::DoShadeGallery(BOOL ShadeIt) 01934 01935 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01936 Created: 6/9/94 01937 Inputs: ShadeIt - TRUE if the gallery is being shaded 01938 FALSE if the gallery is being unshaded 01939 Purpose: Called by the base class whenever the shaded status of the gallery 01940 is changed, to allow derived galleries to shade/unshade any extra 01941 controls that they provide in the window. ONLY called if the gallery 01942 is actually open/visible. 01943 01944 Notes: Need not be overridden - the default action is to do nothing extra 01945 to the normal shade/unshade operation. 01946 SeeAlso: Gallery::ShadeGallery; Gallery::UnshadeGallery 01947 01948 ***********************************************************************************************/ 01949 01950 void Gallery::DoShadeGallery(BOOL ShadeIt) 01951 { 01952 } 01953 01954 01955 01956 01957 01958 01959 01960 void Gallery::PaintText(INT32 XOffset, INT32 YOffset, StringBase *TheText) 01961 { 01962 // Using the current drawing (DC), plot the given text string at the given offset 01963 } 01964 01965 01966 01967 01968 01969 /*********************************************************************************************** 01970 01971 > BOOL Gallery::AddDisplayListToDoc(Document *ScopeDoc, OrderedList *NewList = NULL) 01972 01973 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01974 Created: 15/7/94 01975 Inputs: ScopeDoc - The document you wish to add your list to 01976 NewList - NULL, or a pointer to an OrderedList (or derivative) which you want 01977 added to ScopeDoc's list of cached DisplayLists. 01978 01979 Returns: TRUE if it succeeds 01980 FALSE => ERROR2 01981 01982 Purpose: Interface by which derived Gallery classes can add a cached display 01983 list to the given document. Should be called on document created 01984 broadcasts to add your gallery's display list to a new doc. 01985 01986 Notes: If NewList is NULL, a new (blank) OrderedList will be created on your behalf 01987 01988 You should call FindDisplayListInDoc first to ensure that you do not 01989 attempt to add more than one displaylist to any given document. 01990 01991 The Gallery destructor will remove any display caches owned by your 01992 gallery when it is deleted. 01993 01994 SeeAlso: Gallery::FindDisplayListInDoc; Gallery::SelectMyDocDisplayList 01995 01996 ***********************************************************************************************/ 01997 01998 BOOL Gallery::AddDisplayListToDoc(Document *ScopeDoc, OrderedList *NewList) 01999 { 02000 ERROR2IF(ScopeDoc == NULL, FALSE, "Gallery::AddDisplayListToDoc needs non-NULL Doc pointer"); 02001 02002 if (ScopeDoc->GalleryDisplays == NULL) 02003 ScopeDoc->GalleryDisplays = new List; 02004 02005 if (ScopeDoc->GalleryDisplays == NULL) 02006 return(FALSE); 02007 02008 OrderedList *NewDisplayList; 02009 if (NewList != NULL) 02010 NewDisplayList = NewList; 02011 else 02012 NewDisplayList = new OrderedList; 02013 02014 if (NewDisplayList == NULL) 02015 return(FALSE); 02016 02017 NewDisplayList->SetOwner(this); 02018 GalleryDisplayListPtr *NewItem = new GalleryDisplayListPtr(NewDisplayList); 02019 if (NewItem == NULL) 02020 { 02021 delete NewDisplayList; 02022 return(FALSE); 02023 } 02024 02025 ScopeDoc->GalleryDisplays->AddTail(NewItem); 02026 return(TRUE); 02027 } 02028 02029 02030 02031 /*********************************************************************************************** 02032 02033 > BOOL Gallery::DeleteDisplayListFromDoc(Document *ScopeDoc) 02034 02035 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02036 Created: 15/7/94 02037 Inputs: ScopeDoc - The document you wish to delete your list from 02038 Purpose: Interface by which derived Gallery classes can add a cached display 02039 list to the given document. Should be called on document created 02040 broadcasts to add your gallery's display list to a new doc. 02041 SeeAlso: Gallery::AddDisplayListToDoc; Gallery::FindDisplayListInDoc; 02042 02043 ***********************************************************************************************/ 02044 02045 void Gallery::DeleteDisplayListFromDoc(Document *ScopeDoc) 02046 { 02047 ERROR3IF(ScopeDoc == NULL, "Gallery::DeleteDisplayListFromDoc needs non-NULL Doc pointer"); 02048 02049 if (ScopeDoc->GalleryDisplays == NULL) 02050 return; 02051 02052 GalleryDisplayListPtr *Ptr = (GalleryDisplayListPtr *) ScopeDoc->GalleryDisplays->GetHead(); 02053 02054 while (Ptr != NULL) 02055 { 02056 if (Ptr->DisplayList->GetOwner() == this) 02057 break; 02058 02059 Ptr = (GalleryDisplayListPtr *) ScopeDoc->GalleryDisplays->GetNext(Ptr); 02060 } 02061 02062 if (Ptr != NULL) 02063 { 02064 if (ScopeDoc == GetGalleryDocument()) // If in use, stop using this list! 02065 SelectDisplayList(NULL); 02066 02067 ScopeDoc->GalleryDisplays->RemoveItem(Ptr); 02068 delete Ptr; 02069 02070 // If this has emptied the list of display caches, delete the list too 02071 if (ScopeDoc->GalleryDisplays->IsEmpty()) 02072 { 02073 delete ScopeDoc->GalleryDisplays; 02074 ScopeDoc->GalleryDisplays = NULL; 02075 } 02076 } 02077 } 02078 02079 02080 02081 /*********************************************************************************************** 02082 02083 > OrderedList *Gallery::FindDisplayListInDoc(Document *ScopeDoc) 02084 02085 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02086 Created: 15/7/94 02087 Inputs: ScopeDoc - The document you wish to find your list in 02088 Returns: NULL, or a pointer to a Gallery DisplayList OrderedList 02089 Purpose: Given a document, attempts to find the display list which this gallery 02090 has added to it. This is an easy way for derived galleries to cache 02091 a display list for each doc and find it again later, without having 02092 to check out & change document.cpp or anything 02093 02094 SeeAlso: Gallery::AddDisplayListToDoc; Gallery::SelectMyDocDisplayList 02095 02096 ***********************************************************************************************/ 02097 02098 OrderedList *Gallery::FindDisplayListInDoc(Document *ScopeDoc) 02099 { 02100 ERROR3IF(ScopeDoc == NULL, "Gallery::FindDisplayListInDoc needs non-NULL Doc pointer"); 02101 02102 if (ScopeDoc->GalleryDisplays == NULL) 02103 return(NULL); 02104 02105 GalleryDisplayListPtr *Ptr = (GalleryDisplayListPtr *) ScopeDoc->GalleryDisplays->GetHead(); 02106 02107 while (Ptr != NULL) 02108 { 02109 if (Ptr->DisplayList->GetOwner() == this) 02110 return(Ptr->DisplayList); 02111 02112 Ptr = (GalleryDisplayListPtr *) ScopeDoc->GalleryDisplays->GetNext(Ptr); 02113 } 02114 02115 return(NULL); 02116 } 02117 02118 02119 02120 /*********************************************************************************************** 02121 02122 > void Gallery::SelectDisplayList(OrderedList *NewDisplayList) 02123 02124 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02125 Created: 15/7/94 02126 Inputs: NewDisplayList - The display list which you want the Gallery to 02127 use from now onwards. 02128 02129 Purpose: This deselects the existing Gallery DisplayList and selects the 02130 new DisplayList for all future operations. 02131 02132 Notes: 1 You can pass in NULL to just deselect the existing list. 02133 02134 2 This does not affect the OrderedLists in any way, just links/delinks 02135 them as the current DisplayList. 02136 02137 3 This does NOT affect the visible state of the - you should combine 02138 this call with a ForceRedraw operation. 02139 02140 4 This shades/unshades the gallery for NULL/non-NULL NewDisplayLists 02141 02142 SeeAlso: Gallery::ForceRedrawOfList; Gallery::ShadeGallery 02143 02144 ***********************************************************************************************/ 02145 02146 void Gallery::SelectDisplayList(OrderedList *NewDisplayList) 02147 { 02148 if (DisplayList != NULL && DisplaySequence != NULL) 02149 { 02150 DisplayList->DeselectOrder(SortFunction, FALSE); 02151 DisplaySequence = NULL; 02152 } 02153 02154 DisplayList = NewDisplayList; 02155 if (DisplayList != NULL) 02156 { 02157 DisplaySequence = DisplayList->SelectOrder(SortFunction, FALSE); 02158 UnshadeGallery(); 02159 } 02160 else 02161 ShadeGallery(); 02162 } 02163 02164 02165 02166 /*********************************************************************************************** 02167 02168 > void Gallery::SelectMyDocDisplayList(Document *ScopeDoc) 02169 02170 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02171 Created: 15/7/94 02172 Inputs: ScopeDoc - The document you wish to find your list in 02173 Purpose: Given a document, attempts to find the display list which this gallery 02174 has added to it, and then swaps the Gallery over to using this new 02175 display list - should therefore be called on DocChangingMsgs. 02176 Will shade/unshade the gallery as appropriate 02177 02178 SeeAlso: Gallery::AddDisplayListToDoc; Gallery::FindDisplayListInDoc; 02179 Gallery::SelectDisplayList 02180 02181 ***********************************************************************************************/ 02182 02183 void Gallery::SelectMyDocDisplayList(Document *ScopeDoc) 02184 { 02185 SelectDisplayList(FindDisplayListInDoc(ScopeDoc)); 02186 } 02187 02188 02189 02190 /*********************************************************************************************** 02191 02192 > virtual void Gallery::SortModeHasBeenChanged(BOOL SetDerivedSortsToo) 02193 02194 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02195 Created: 29/7/94 02196 Inputs: SetDerivedSortsToo - If FALSE, only the base gallery class' Display List 02197 sort mode should be changed. If TRUE, then any other things that can 02198 depend upon this sort mode should also be updated (e.g. ColourGallery 02199 will update the colour bar sortmode if this is TRUE). 02200 02201 NOTE - this will ALWAYS be false unless you set up an 'also' button 02202 by providing a derived SetAlsoButton method 02203 02204 Purpose: Called when the GalleryDisplayDlg has chnaged the gallery DisplayList 02205 SortMode array to a new sort. The gallery will cause a re-sort and 02206 update of its list display. 02207 02208 Notes: The base class functionality MUST be provided in derived classes. Thus, 02209 you should call the base class method from any derived version. 02210 If SetDerivedSorts == FALSE, derived methods probably should do nothing. 02211 Otherwise, you should copy the DisplayList->SortMode array into any other 02212 SortModes you may have for external entities such as the colour bar, and 02213 cause them to update themselves for the new sort too. 02214 02215 SeeAlso: Gallery::SetAlsoButton 02216 02217 ***********************************************************************************************/ 02218 02219 void Gallery::SortModeHasBeenChanged(BOOL SetDerivedSortsToo) 02220 { 02221 // The display sequence is wrong now, so deselect it to be on the safe side 02222 if (DisplaySequence != NULL) 02223 { 02224 if (DisplayList != NULL) 02225 DisplayList->DeselectOrder(SortFunction, FALSE); 02226 DisplaySequence = NULL; 02227 } 02228 02229 // Force redraw/re-filling of the gallery list in the new sort order 02230 ForceRedrawOfList(); 02231 } 02232 02233 02234 02235 /*********************************************************************************************** 02236 02237 > virtual BOOL Gallery::DoSetDisplayModes(GalleryDisplayDlg *TheDialogue) 02238 02239 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02240 Created: 29/7/94 02241 Inputs: TheDialogue - The Gallery Display dialogue to call 02242 SetDisplayModeName for. 02243 02244 Returns: TRUE if the gallery has a choice of display modes, 02245 FALSE if not (in which case the combo box list is greyed) 02246 02247 Purpose: This derived function is called by the base class when the 02248 GallerySortDlg is opened. It is a request from the gallery 02249 for you to fill in the list of available display modes. e.g 02250 you may provide icon-only, name-only, icon-and-name, full info 02251 modes for displaying the gallery items. 02252 02253 For each mode you support, call SetDisplayModeName to add it to 02254 the list. Return TRUE when you're done. 02255 02256 If you don't support anything other than one display mode, then you 02257 should just return FALSE (the base class default does this for you) 02258 02259 SeeAlso: GalleryDisplayDlg::SetDisplayModeName; Gallery::DoDisplayModeChange 02260 02261 ***********************************************************************************************/ 02262 02263 BOOL Gallery::DoSetDisplayModes(GalleryDisplayDlg *TheDialogue) 02264 { 02265 // Example: 02266 // String_64 Text(_R(IDS_DISPLAY_NAMES_ONLY)); 02267 // TheDialogue->SetDisplayModeName(Text); 02268 02269 return(FALSE); // By default, the gallery will have no choice of modes 02270 } 02271 02272 02273 02274 /*********************************************************************************************** 02275 02276 > virtual void Gallery::DoDisplayModeChange(UINT32 NewDisplayMode) 02277 02278 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02279 Created: 29/7/94 02280 Inputs: NewDisplayMode - this number is an index [0..MaxDisplayModes] into 02281 the list of display names you gave in DoSetDisplayModes 02282 Returns: - 02283 02284 Purpose: This function probably won't be needed, but it is called if the 02285 display mode is changed in the gallery display dialogue. You may 02286 want to cache new values or something before the next time your 02287 redraw code is called, in which case this is the place to do it. 02288 02289 SeeAlso: GalleryDisplayDlg::SetDisplayModeName; Gallery::DoSetDisplayModes 02290 02291 ***********************************************************************************************/ 02292 02293 void Gallery::DoDisplayModeChange(UINT32 NewDisplayMode) 02294 { 02295 // By default, no action is taken for display mode changes 02296 } 02297 02298 02299 02300 /*********************************************************************************************** 02301 02302 > virtual void Gallery::DoShowMenu(void) 02303 02304 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02305 Created: 29/7/94 02306 Inputs: - 02307 Returns: - 02308 02309 Purpose: Creates and shows your gallery-specific menu. 02310 This is in reaction to clicking the gallery menu button - you should 02311 pop up a menu under the pointer. How to do this is a complete mystery 02312 to me! I guess the menu items should be connected to actions via the 02313 standard Op system, so this is the only call the Gallery provides 02314 for you. 02315 02316 ***********************************************************************************************/ 02317 02318 void Gallery::DoShowMenu(void) 02319 { 02320 // By default, no menu is shown 02321 } 02322 02323 02324 02325 /*********************************************************************************************** 02326 02327 > virtual BOOL Gallery::SetAlsoButton(String_64 *TextToPutIn) 02328 02329 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02330 Created: 29/7/94 02331 Inputs: - 02332 Outputs: TextToPutIn - Fill this in with the text you want on the 02333 'also' option button 02334 Returns: TRUE if it wants an 'also' button, FALSE if not 02335 02336 Purpose: If your gallery sort mode can also be applied to other entities 02337 (e.g. the Colour Gallery display mode can also be applied to the 02338 colour bar) then return TRUE from this function after filling in 02339 the text parameter with a string (e.g. "Also apply this sort to 02340 the colour bar" 02341 02342 If you want more control than this, you'll need to override the 02343 GalleryDisplayDlg class and get your hands dirty. 02344 02345 By default (if you don't override this method) there is no button 02346 02347 SeeAlso: Gallery::SortModeHasBeenChanged 02348 02349 ***********************************************************************************************/ 02350 02351 BOOL Gallery::SetAlsoButton(String_64 *TextToPutIn) 02352 { 02353 return(FALSE); // By default, Galleries do not support an 'also' button 02354 } 02355 02356 02357 02358 02359 02360 02361 02362 02363 02364 02365 02366 02367 02368 02369 02370 02371 02372 02373 02374 //----------------------------------------------------------------------------------------- 02375 02376 02377 02378 const CDlgMode GalleryDisplayDlg::Mode = MODELESS; // Mode of the dialog 02379 02380 const UINT32 GalleryDisplayDlg::IDD = _R(IDD_GALDISPLAYDLG); 02381 02382 02383 // --- GallerySorts 02384 // The GallerySorts array holds the current window state. Similar arrays (of 02385 // SortKeys only) are held by each instantiation of Gallery, which define 02386 // their current sort settings. 02387 02388 GalSortInfo GalleryDisplayDlg::GallerySorts[MaxSortKeys] = 02389 { 02390 { {NULL, FALSE}, _R(IDC_GALSORT_SORT1), _R(IDC_GALSORT_REVERSE1) }, 02391 { {NULL, FALSE}, _R(IDC_GALSORT_SORT2), _R(IDC_GALSORT_REVERSE2) } 02392 }; 02393 02394 02395 02396 /******************************************************************************************** 02397 02398 > static INT32 GalleryDisplayDlg::FindIndexFromCI(List *Sorts, INT32 SortInfoIndex) 02399 02400 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02401 Created: 27/5/94 02402 Inputs: Sorts - The list of available sorts (ComparatorInfos) 02403 SortInfoIndex - the index in GallerySorts[] of the control you 02404 need the index for (as each one is a slightly different list) 02405 Outputs: - 02406 Returns: The index of the given GalSortInfo item in the given list of sorts 02407 (This is almost a List::GetPosition, but returns 0 if the item is 02408 not found) 02409 Purpose: Conversion between a ComparatorInfo pointer and a combo box index for 02410 the Gallery Display (Sort) Dialogue. 02411 Scope: private 02412 SeeAlso: FindCIFromIndex 02413 02414 ********************************************************************************************/ 02415 02416 INT32 GalleryDisplayDlg::FindIndexFromCI(List *Sorts, INT32 SortInfoIndex) 02417 { 02418 #if FALSE 02419 ComparatorInfo *SortInfo = GallerySorts[SortInfoIndex].Key.Info; 02420 02421 if (Sorts == NULL || SortInfo == NULL) 02422 return(0); 02423 02424 ComparatorInfo *Ptr = (ComparatorInfo *) Sorts->GetHead(); 02425 INT32 index = 0; 02426 while (Ptr != NULL) 02427 { 02428 if (Ptr == SortInfo) // Have found this item in the list 02429 break; 02430 02431 Ptr = (ComparatorInfo *) Sorts->GetNext(Ptr); 02432 index++; 02433 } 02434 02435 if (Ptr == NULL) 02436 return(0); 02437 02438 if (SortInfoIndex != 0) // In all but 1st control, add 1 for 'None' entry 02439 index++; 02440 02441 return(index); 02442 #else 02443 return(0); 02444 #endif 02445 } 02446 02447 02448 02449 /******************************************************************************************** 02450 02451 > static ComparatorInfo *GalleryDisplayDlg::FindCIFromName(List *Sorts, StringBase *Name) 02452 02453 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02454 Created: 27/5/94 02455 Inputs: Sorts - The list of available sorts (ComparatorInfos) 02456 Name - The string of the selected sort in the combo box 02457 Outputs: - 02458 Returns: The appropriate ComparatorInfo for the selected Combo-box item. 02459 This will return NULL if anything goes wrong, or if the combo box 02460 is not the primary sort and the 'None' item was selected 02461 Purpose: Conversion between a ComparatorInfo pointer and a combo box index for 02462 the Gallery Display (Sort) Dialogue. 02463 Scope: private 02464 SeeAlso: FindIndexFromCI 02465 02466 ********************************************************************************************/ 02467 02468 ComparatorInfo *GalleryDisplayDlg::FindCIFromName(List *Sorts, StringBase &Name) 02469 { 02470 #if FALSE 02471 // All controls but the first have an extra 'None' field, for which we return NULL 02472 String_32 Test(_R(IDS_SORTBY_NONE)); 02473 if (Test == Name) 02474 return(NULL); 02475 02476 ComparatorInfo *Ptr = (ComparatorInfo *) Sorts->GetHead(); 02477 while (Ptr != NULL) 02478 { 02479 if (Ptr->GetSortName() == Name) 02480 break; 02481 02482 Ptr = (ComparatorInfo *) Sorts->GetNext(Ptr); 02483 } 02484 02485 return(Ptr); 02486 #else 02487 return(NULL); 02488 #endif 02489 } 02490 02491 02492 02493 /******************************************************************************************** 02494 02495 > GalleryDisplayDlg::GalleryDisplayDlg(): DialogOp(GalleryDisplayDlg::IDD, GalleryDisplayDlg::Mode) 02496 02497 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02498 Created: 26/5/94 02499 Inputs: - 02500 Outputs: - 02501 Returns: - 02502 Purpose: Constructor for the colour manager dialogue class 02503 Errors: - 02504 SeeAlso: - 02505 02506 ********************************************************************************************/ 02507 02508 GalleryDisplayDlg::GalleryDisplayDlg() : DialogOp(GalleryDisplayDlg::IDD, GalleryDisplayDlg::Mode) 02509 { 02510 ParentGallery = NULL; 02511 } 02512 02513 02514 02515 /******************************************************************************************** 02516 02517 > void GalleryDisplayDlg::InitValues(void) 02518 02519 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02520 Created: 26/5/94 02521 Outputs: - 02522 Returns: - 02523 Purpose: Initialises the gallery display dialogue, and sets its controls 02524 Scope: private 02525 Errors: - 02526 SeeAlso: GalleryDisplayDlg::SetControls 02527 02528 ********************************************************************************************/ 02529 02530 void GalleryDisplayDlg::InitValues(void) 02531 { 02532 #if FALSE 02533 ERROR3IF(ParentGallery == NULL, 02534 "GalleryDisplayDlg MUST be given a valid parent pointer"); 02535 02536 if (ParentGallery->DisplayList == NULL) 02537 return; 02538 02539 // Copy the parent gallery's display list sortmode 02540 for (INT32 i = 0; i < MaxSortKeys; i++) 02541 { 02542 GallerySorts[i].Key.Info = ParentGallery->DisplayList->SortMode[i].Info; 02543 GallerySorts[i].Key.Reversed = ParentGallery->DisplayList->SortMode[i].Reversed; 02544 } 02545 02546 // Fill in the combo boxes etc with the current settings 02547 SetControls(); 02548 #endif 02549 } 02550 02551 02552 02553 /******************************************************************************************** 02554 02555 > void GalleryDisplayDlg::SetParentGallery(Gallery *Parent) 02556 02557 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02558 Created: 26/5/94 02559 Inputs: Parent - the parent (owner) of this display dialogue. This pointer 02560 is used to inform the parent of changes to display/sort modes. 02561 Outputs: - 02562 Returns: - 02563 Purpose: Sets the parent gallery of this dialogue. If this is not done 02564 then ensure failures will occur when you try to open (Do) the dlg. 02565 02566 ********************************************************************************************/ 02567 02568 void GalleryDisplayDlg::SetParentGallery(Gallery *Parent) 02569 { 02570 // Remember who our parent Gallery is so we can set their sort mode 02571 ParentGallery = Parent; 02572 } 02573 02574 02575 02576 /******************************************************************************************** 02577 02578 > void GalleryDisplayDlg::SetDisplayModeName(StringBase *EntryName) 02579 02580 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02581 Created: 29/7/94 02582 Inputs: EntryName - The name to set as the next item 02583 Outputs: - 02584 Returns: - 02585 Purpose: Called (multiple times) by derived gallery classes in response to 02586 a call we make upon opening the dialogue. Each call appends another 02587 display mode name to the display mode combo box list in the GalDispDlg 02588 window. 02589 02590 ********************************************************************************************/ 02591 02592 void GalleryDisplayDlg::SetDisplayModeName(StringBase *EntryName) 02593 { 02594 #if FALSE 02595 SetStringGadgetValue(_R(IDC_GALSORT_MODES), EntryName, FALSE, 0); 02596 #endif 02597 } 02598 02599 02600 02601 /******************************************************************************************** 02602 02603 > void GalleryDisplayDlg::SetControls(void) 02604 02605 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02606 Created: 26/5/94 02607 Inputs: - 02608 Outputs: - 02609 Returns: - 02610 Purpose: (Re)Initialises the colour manager dialogue controls 02611 (This simply sets the combo boxes etc up from the current Sort Dlg 02612 settings) 02613 Scope: private 02614 Errors: - 02615 SeeAlso: - 02616 02617 ********************************************************************************************/ 02618 02619 void GalleryDisplayDlg::SetControls(void) 02620 { 02621 #if FALSE 02622 ERROR3IF(ParentGallery == NULL, "ParentGallery is NULL!"); 02623 02624 if (ParentGallery->DisplayList == NULL) 02625 return; 02626 02627 02628 // Set up the 'also' button; show it and set the text, or hide it as neccesarry 02629 SetBoolGadgetSelected(_R(IDC_GALSORT_GALONLY), TRUE); // Always defaults to being on 02630 02631 String_64 ButtonText; 02632 if (ParentGallery->SetAlsoButton(&ButtonText)) 02633 { 02634 HideGadget(_R(IDC_GALSORT_GALONLY), FALSE); 02635 SetStringGadgetValue(_R(IDC_GALSORT_GALONLY), (StringBase *) &ButtonText); 02636 } 02637 else 02638 HideGadget(_R(IDC_GALSORT_GALONLY), TRUE); 02639 02640 02641 // Set values in the display combo box 02642 BOOL Result = ParentGallery->DoSetDisplayModes(this); 02643 EnableGadget(_R(IDC_GALSORT_MODES), Result); 02644 if (Result) 02645 SetSelectedValueIndex(_R(IDC_GALSORT_MODES), (WORD) ParentGallery->CurrentDisplayMode); 02646 02647 02648 // And set up the sort key lists and 'reversed' option buttons 02649 List *Sorts = ParentGallery->DisplayList->GetSortOrders(); 02650 02651 if (Sorts == NULL || Sorts->IsEmpty()) 02652 { 02653 // This generally means that the programmer hasn't init'd the DisplayList correctly... 02654 TRACE( _T("\nGallery has no sort modes! Derive an OrderedList and call its Init()!\n")); 02655 return; 02656 } 02657 02658 // Add each sort name to all combo boxes... 02659 String_32 NoSortName(_R(IDS_SORTBY_NONE)); // Add 'None' to all but the 1st combo box 02660 ComparatorInfo *Info = (ComparatorInfo *) Sorts->GetTail(); 02661 INT32 i; 02662 while (Info != NULL) 02663 { 02664 for (i = 0; i < MaxSortKeys; i++) 02665 SetStringGadgetValue(GallerySorts[i].ListControlID, 02666 (StringBase *)&Info->GetSortName(), FALSE, 0); 02667 02668 Info = (ComparatorInfo *) Sorts->GetPrev(Info); 02669 } 02670 02671 for (i = 1; i < MaxSortKeys; i++) 02672 { 02673 SetStringGadgetValue(GallerySorts[i].ListControlID, &NoSortName, FALSE, 0); 02674 } 02675 02676 02677 // Set the Combo box selections and 'reversed' boxes to the current sort mode 02678 for (i = 0; i < MaxSortKeys; i++) 02679 { 02680 SetBoolGadgetSelected(GallerySorts[i].CheckControlID, GallerySorts[i].Key.Reversed); 02681 if (i > 0) 02682 EnableGadget(GallerySorts[i].CheckControlID, (GallerySorts[i].Key.Info != NULL)); 02683 02684 SetSelectedValueIndex(GallerySorts[i].ListControlID, 02685 (WORD) FindIndexFromCI(Sorts, i)); 02686 } 02687 #endif 02688 } 02689 02690 02691 02692 /******************************************************************************************** 02693 02694 > void GalleryDisplayDlg::SetSortMode(void) 02695 02696 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02697 Created: 26/5/94 02698 Inputs: - 02699 Outputs: - 02700 Returns: - 02701 Purpose: Reads the current settings from the window, and sets them as the new 02702 sort mode for the parent gallery. 02703 Scope: private 02704 Errors: - 02705 SeeAlso: - 02706 02707 ********************************************************************************************/ 02708 02709 void GalleryDisplayDlg::SetSortMode(void) 02710 { 02711 #if FALSE 02712 if (ParentGallery->DisplayList == NULL) 02713 return; 02714 02715 List *Sorts = ParentGallery->DisplayList->GetSortOrders(); 02716 02717 if (Sorts == NULL || Sorts->IsEmpty()) 02718 return; 02719 02720 // Read the SortBy Combo box selections into the current-sort-mode record 02721 String_256 Name; 02722 BOOL SetAllSortModes = GetBoolGadgetSelected(_R(IDC_GALSORT_GALONLY)); 02723 02724 for (INT32 i = 0; i < MaxSortKeys; i++) 02725 { 02726 GallerySorts[i].Key.Reversed = 02727 GetBoolGadgetSelected(GallerySorts[i].CheckControlID); 02728 02729 Name = GetStringGadgetValue(GallerySorts[i].ListControlID); 02730 GallerySorts[i].Key.Info = FindCIFromName(Sorts, Name); 02731 02732 02733 // Copy the new sort mode into the Gallery DisplayList sort mode 02734 ParentGallery->DisplayList->SortMode[i].Info = GallerySorts[i].Key.Info; 02735 ParentGallery->DisplayList->SortMode[i].Reversed = GallerySorts[i].Key.Reversed; 02736 } 02737 02738 // Ensure that the gallery list is re-sorted on next access 02739 ParentGallery->DisplayList->InvalidateCaches(); 02740 02741 // And inform the gallery that the sort mode has been changed 02742 // Pass in a flag indicating if only the DisplayList display sort mode should 02743 // be changed, or if all derived gallery sort dependencies should also be updated 02744 // (e.g. if TRUE, the ColourGallery might update the Colour Bar sort mode as well) 02745 ParentGallery->SortModeHasBeenChanged(SetAllSortModes); 02746 #endif 02747 } 02748 02749 02750 02751 /******************************************************************************************** 02752 02753 > MsgResult GalleryDisplayDlg::Message( Msg* Message) 02754 02755 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02756 Created: 26/5/94 02757 Inputs: Msg - The dialogue manager message to handle 02758 Outputs: - 02759 Returns: A MsgResult 02760 Purpose: Standard DialogOp message handler, for the Gallery display dialogue 02761 Errors: - 02762 SeeAlso: - 02763 02764 ********************************************************************************************/ 02765 02766 MsgResult GalleryDisplayDlg::Message( Msg* Message) 02767 { 02768 if (!(IS_OUR_DIALOG_MSG(Message))) 02769 return(OK); 02770 02771 DialogMsg* TheMsg = (DialogMsg*)Message; 02772 02773 #if FALSE 02774 switch(TheMsg->DlgMsg) 02775 { 02776 case DIM_COMMIT: // OK clicked 02777 SetSortMode(); 02778 // Drop through to DIM_CANCEL case to close the dlg 02779 02780 case DIM_CANCEL: // Cancel clicked 02781 Close(); 02782 End(); 02783 break; 02784 02785 case DIM_SOFT_COMMIT: // OK "adjust clicked" 02786 SetSortMode(); 02787 break; 02788 02789 case DIM_SELECTION_CHANGED: 02790 // If select in a combo box other than the primary sort key, then 02791 // we must shade/unshade the reverse checkbox depending on whether 02792 // 'None' (item 0) was selected 02793 { 02794 for (INT32 i = 1; i < MaxSortKeys; i++) 02795 { 02796 if (TheMsg->GadgetID == GallerySorts[i].ListControlID) 02797 { 02798 WORD Index; 02799 GetValueIndex(GallerySorts[i].ListControlID, &Index); 02800 EnableGadget(GallerySorts[i].CheckControlID, (Index != 0)); 02801 } 02802 } 02803 } 02804 break; 02805 } 02806 #endif 02807 02808 return(DLG_EAT_IF_HUNGRY(TheMsg)); 02809 } 02810 02811 02812 /******************************************************************************************** 02813 02814 > OpState GalleryDisplayDlg::GetState(String_256*, OpDescriptor*) 02815 02816 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02817 Created: 26/5/94 02818 Inputs: - 02819 Outputs: - 02820 Returns: - 02821 Purpose: Get the state of the Colour sort dialogue op 02822 Errors: - 02823 SeeAlso: - 02824 02825 ********************************************************************************************/ 02826 02827 OpState GalleryDisplayDlg::GetState(String_256*, OpDescriptor*) 02828 { 02829 OpState OpSt; 02830 return(OpSt); 02831 } 02832 02833 02834 /******************************************************************************************** 02835 02836 > BOOL GalleryDisplayDlg::Init() 02837 02838 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02839 Created: 26/5/94 02840 Inputs: - 02841 Outputs: - 02842 Returns: - 02843 Purpose: Initialises the colour sort dialogue op 02844 Errors: - 02845 SeeAlso: - 02846 02847 ********************************************************************************************/ 02848 02849 BOOL GalleryDisplayDlg::Init() 02850 { 02851 return (RegisterOpDescriptor( 02852 0, 02853 _R(IDS_GALDISPLAYDLG), 02854 CC_RUNTIME_CLASS(GalleryDisplayDlg), 02855 OPTOKEN_GALDISPLAYDLG, 02856 GalleryDisplayDlg::GetState, 02857 0, /* help ID */ 02858 0, // **** _R(IDBBL_GALDISPLAYDLG), 02859 0 /* bitmap ID */ 02860 )); 02861 } 02862 02863 02864 02865 /******************************************************************************************** 02866 02867 > BOOL GalleryDisplayDlg::Create() 02868 02869 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02870 Created: 26/5/94 02871 Inputs: - 02872 Outputs: - 02873 Returns: FALSE if it fails 02874 Purpose: Creates a gallery display dialogue box 02875 Errors: - 02876 SeeAlso: - 02877 02878 ********************************************************************************************/ 02879 02880 BOOL GalleryDisplayDlg::Create() 02881 { 02882 #if FALSE 02883 if (DialogOp::Create()) 02884 { 02885 InitValues(); 02886 return(TRUE); 02887 } 02888 #endif 02889 02890 return(FALSE); 02891 } 02892 02893 02894 02895 /******************************************************************************************** 02896 02897 > void GalleryDisplayDlg::Do(OpDescriptor*) 02898 02899 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 02900 Created: 26/5/94 02901 Inputs: - 02902 Outputs: - 02903 Returns: - 02904 Purpose: 'Does' a gallery display dialogue op. Shows the dialogue. 02905 Scope: private 02906 Errors: - 02907 SeeAlso: - 02908 02909 ********************************************************************************************/ 02910 02911 void GalleryDisplayDlg::Do(OpDescriptor*) 02912 { 02913 #if FALSE 02914 if (Create()) 02915 Open(); 02916 else 02917 #endif 02918 End(); 02919 } 02920 02921 02922 #endif 02923