#include <sgcolour.h>
Inheritance diagram for ColourSGallery:

Public Member Functions | |
| ColourSGallery () | |
| ColourSGallery default constructor. | |
| ~ColourSGallery () | |
| ColourSGallery destructor. | |
| virtual MsgResult | Message (Msg *Message) |
| A standard message handler, really. | |
| virtual SGDisplayItem * | CopyDisplayItem (SGDisplayItem *SourceItem, SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition=NULL) |
| "Copies" the existing node in the tree in an appropriate fashion. | |
| virtual void | AllItemsCopied (SGDisplayGroup *DestGroup) |
| This upcall method is called after one or more items have been copied or moved by a gallery drag. It allows the gallery to do update things like broadcasting a message or getting a related window (eg colour line) to redraw at the end of a move/copy operation. This allows thousands of items to be moved/copied with only a single redraw/message-broadcast, etc at the very end. | |
| virtual BOOL | InitMenuCommands (void) |
| Initialises any menu commands that this gallery needs. | |
| virtual BOOL | BuildCommandMenu (GalleryContextMenu *TheMenu, SGMenuID MenuID) |
| To build a menu of commands to be popped up over the gallery. | |
| virtual OpState | GetCommandState (StringBase *CommandID, String_256 *ShadeReason) |
| To determine the state of a given menu item. This method is an exact parallel to an Op's GetState method (in fact, it is called by an Op's GetState). | |
| virtual void | DoCommand (StringBase *CommandID) |
| To apply a given command when it is chosen from the menu. | |
| void | SetCurrentImportGroup (SGDisplayLibColGroup *TheGroup) |
| SGDisplayLibColGroup * | GetCurrentImportGroup (void) |
| BOOL | MakeSureGroupsHaveBeenCreated () |
| This will create the gallery groups (unless they're already there) and return TRUE if ok. | |
| SGDisplayLibColGroup * | GetFirstLibGroup () |
| Gets the first colour library group node in the colour gallery. | |
| SGDisplayLibColGroup * | GetNextLibGroup (SGDisplayLibColGroup *pLibGroup) |
| Gets the next colour library group node in the colour gallery. | |
| BOOL | ApplySelectedAsBackground () |
| Takes the selected item in the gallery and tries to apply this as a new background to the spread. | |
| BOOL | GetDocColourToApply (SGDisplayColour *pFirstSelected, DocColour *pColourToApply, Document **pDoc) |
| To create a doc colour which can then be used to apply the colour in the currently selected document. Copes with the simple case of the colour being a document colour and the more complex case of teh colour being a library colour. Whereapon, a new colour must be added to the selected document which is this selected library colour. | |
Static Public Member Functions | |
| static BOOL | Init (void) |
| ColourSGallery initialisation - declares preferences etc. | |
| static ColourSGallery * | GetInstance () |
| Public access function to the colour gallery. | |
| static BOOL | CanAddColourToGallery (IndexedColour *pCol, ColourList *pColList) |
| Central point where it decides whether the colour should be displayed in the gallery. | |
Static Public Attributes | |
| static INT32 | AutoScrollSelection = TRUE |
| If TRUE, the colour gallery will automatically scroll its display list to show the currently selected line and fill colours whenever the selection changes. If FALSE, these colours will still become selected, but the gallery will not be scrolled. | |
| static INT32 | DefaultDisplayMode = 0 |
| Memory of the current colour gallery display mode, saved between sessions for convenience. Not shown in the options dialogue. | |
| static String_256 | PalettePath = TEXT("") |
| The path to load the palettes from. Defaults to blank which means alongside the exe. | |
| static BOOL | ShowDocumentColours = TRUE |
| Memory of the current state of showing document colours in the colour line. | |
| static BOOL | ShowNetscapeColours = TRUE |
| Memory of the current state of showing Netscape colours in the colour line. Webster needs to default to True. | |
Protected Member Functions | |
| virtual BOOL | PreCreate (void) |
| The ColourSGallery PreCreate handler. This overrides the base class PreCreate function. It is called at the very start of the SuperGallery::Create method, before the window has been created. | |
| virtual BOOL | ApplyAction (SGActionType Action) |
| Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc). | |
| virtual void | HandleDragStart (DragMessage *DragMsg) |
| Checks a DragMessage to see if it is a colour drag. If it is, then it creates a drag target for this gallerys listbox. | |
| virtual void | SelectionHasChanged (void) |
| To inform the gallery that the selection has changed in some way. | |
| virtual void | DoShadeGallery (BOOL ShadeIt) |
| Called by the base class whenever the shaded status of the gallery is changed, to allow derived galleries to shade/unshade any extra controls that they provide in the window. ONLY called if the gallery is actually open/visible. | |
| virtual RenderRegion * | CreateRenderRegion (DocRect *VirtualSize, ReDrawInfoType *DlgRedrawInfo) |
| An overridable veneer to the DialogOp CreateOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering. | |
| virtual void | DestroyRenderRegion (RenderRegion *pRender) |
| An overridable veneer to the DialogOp DestroyOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering. | |
| void | CreateNewSubtree (Document *ParentDoc, SGDisplayColourGroup *ExistingGroup=NULL) |
| Internal call. This takes the colour list of the given document and creates a DisplayTree subtree from it. This subtree is then added to the DisplayTree. Note that this does not force a redraw of the list - after making this call, you should also call ForceRedrawOfList. | |
| void | RedrawColourDisplay (Document *TheDocument, IndexedColour *TheColour) |
| Redraws the display item for one specific colour, and all of its linked descendants (liked/tint colours) (if any) in a given document. | |
| void | EditColour (ColourList *ParentList, IndexedColour *TheColour) |
| Opens the colour editor, and sets it to edit the given colour. | |
| BOOL | OKToDeleteSelection (SGDisplayGroup *DocumentGroup) |
| To determine if it is OK to go ahead and delete the selected colours, and to possibly modify the selection if some colours should not be deleted. | |
| BOOL | DeleteSelection (SGDisplayGroup *DocumentGroup, ColourList *ParentList) |
| Forcibly deletes all selected colours Should be used after OKToDeleteSelection (which confirms the action). | |
| void | SetSelectionFromDocument (BOOL AlwaysScroll=FALSE) |
| Sets the colour gallery listbox selection state based upon the currently selected object(s) in the document (to show the current fill/stroke colours). | |
Protected Attributes | |
| BOOL | ISentTheMessage |
| ColourListComponent * | CurrentColComp |
| SGDisplayNode * | CurrentTarget |
Static Protected Attributes | |
| static ColourSGallery * | m_pTheGallery = NULL |
Private Attributes | |
| SGDisplayLibColGroup * | CurrentImportGroup |
Friends | |
| class | SGDisplayColour |
Definition at line 466 of file sgcolour.h.
|
|
ColourSGallery default constructor.
Definition at line 2369 of file sgcolour.cpp. 02370 { 02371 DlgResID = _R(IDD_COLOURSGALLERY); 02372 02373 ISentTheMessage = FALSE; 02374 CurrentColComp = NULL; 02375 CurrentTarget = NULL; 02376 02377 // Set the display mode up from the default setting 02378 DisplayMode = DefaultDisplayMode; 02379 if (DisplayMode < 0 || DisplayMode > 2) 02380 DisplayMode = 0; 02381 02382 CurrentImportGroup = NULL; 02383 02384 // WEBSTER - markn 9/12/96 - Martin 16/07/97 same as Camelot now 02385 // Default gallery size 02386 //CSize Size(256, 256); 02387 //SetGallerySize(Size); 02388 02389 // Remember a pointer to the global instance of this gallery. 02390 ERROR3IF(m_pTheGallery != NULL, "Gallery already exists in ColourSGallery::ColourSGallery?"); 02391 m_pTheGallery = this; 02392 }
|
|
|
ColourSGallery destructor.
Definition at line 2406 of file sgcolour.cpp. 02407 { 02408 ERROR3IF(CurrentColComp != NULL, "Destructed colour gallery is still doing a component copy?!"); 02409 02410 // Remember the display mode as the default setting for next time we're created (preference) 02411 DefaultDisplayMode = DisplayMode; 02412 02413 // Make sure nothing is seriously screwed-up. 02414 ERROR3IF(m_pTheGallery == NULL, "No gallery in ColourSGallery::~ColourSGallery?"); 02415 m_pTheGallery = NULL; 02416 }
|
|
|
This upcall method is called after one or more items have been copied or moved by a gallery drag. It allows the gallery to do update things like broadcasting a message or getting a related window (eg colour line) to redraw at the end of a move/copy operation. This allows thousands of items to be moved/copied with only a single redraw/message-broadcast, etc at the very end.
Reimplemented from SuperGallery. Definition at line 4078 of file sgcolour.cpp. 04079 { 04080 ERROR3IF(DestGroup == NULL, "Illegal NULL param"); 04081 04082 BOOL OldSentState = ISentTheMessage; // Make me ignore any messages triggered by this code 04083 ISentTheMessage = TRUE; 04084 04085 // This can be called after MoveItems as well as CopyDisplayItem calls 04086 // We only have to do something if the CopyDisplayItem call has started a component copy... 04087 if (CurrentColComp != NULL) 04088 { 04089 // Merge colours, add undo record, etc. Any new colours will be inserted after the 04090 // given target position, and if any colours were merged, the user is informed 04091 IndexedColour *Target = NULL; 04092 if (CurrentTarget != NULL) 04093 Target = ((SGDisplayColour *)CurrentTarget)->GetDisplayedColour()-> 04094 FindParentIndexedColour(); 04095 04096 CurrentColComp->EndComponentCopy(Target, TRUE); 04097 CurrentColComp = NULL; 04098 CurrentTarget = NULL; 04099 04100 Document *ParentDoc = DestGroup->GetParentDocument(); 04101 if (ParentDoc != NULL) 04102 { 04103 CreateNewSubtree(ParentDoc, (SGDisplayColourGroup*)DisplayTree->FindSubtree(this, ParentDoc, NULL)); 04104 InvalidateCachedFormat(); 04105 ReformatAndRedrawIfNecessary(); 04106 } 04107 } 04108 else 04109 { 04110 // Inform the rest of the world that this colour list order has been modified 04111 Document *ParentDoc = DestGroup->GetParentDocument(); 04112 if (ParentDoc != NULL) 04113 ColourManager::ColourListHasChanged(ParentDoc->GetIndexedColours()); 04114 } 04115 04116 ISentTheMessage = OldSentState; 04117 }
|
|
|
Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc).
Reimplemented from SuperGallery. Definition at line 3088 of file sgcolour.cpp. 03089 { 03090 // No display tree? Or worse, no active docuemnts? Better forget about it then! 03091 if (DisplayTree == NULL || Document::GetSelected() == NULL) 03092 return(FALSE); 03093 03094 SGDisplayColour *FirstSelected = (SGDisplayColour *) 03095 DisplayTree->FindNextSelectedItem(NULL); 03096 03097 SGDisplayGroup *DocumentGroup = NULL; 03098 Document *ScopeDoc = NULL; 03099 ColourList *ColList = NULL; 03100 IndexedColour *SelectedColour = NULL; 03101 DocColour *TheColour = NULL; 03102 03103 if (FirstSelected != NULL) 03104 { 03105 DocumentGroup = (SGDisplayGroup *) FirstSelected->GetParent(); 03106 ERROR3IF(DocumentGroup == NULL, "SGallery DisplayTree linkage corruption detected"); 03107 03108 ScopeDoc = DocumentGroup->GetParentDocument(); 03109 if (ScopeDoc == NULL) // Must be a library item, so it will affect the selected doc 03110 ScopeDoc = Document::GetSelected(); 03111 ERROR3IF(ScopeDoc == NULL, "No scope document for colour gallery operation!"); 03112 03113 ColList = ScopeDoc->GetIndexedColours(); 03114 ERROR3IF(ColList == NULL, "A document with no colour list? Now I've seen it all"); 03115 03116 TheColour = FirstSelected->GetDisplayedColour(); 03117 ERROR3IF(TheColour == NULL, "SGDisplayColour has no colour in it?"); 03118 03119 SelectedColour = TheColour->FindParentIndexedColour(); 03120 } 03121 03122 03123 BOOL Adjust = FALSE; 03124 03125 // Now, process the action 03126 switch(Action) 03127 { 03128 case SGACTION_CREATE: 03129 ColList = Document::GetSelected()->GetIndexedColours(); 03130 ERROR3IF(ColList == NULL, "A document with no colour list? Now I've seen it all"); 03131 if (ColList != NULL) 03132 { 03133 BOOL OldSentState = ISentTheMessage; 03134 ISentTheMessage = TRUE; 03135 03136 IndexedColour *NewCol = NULL; 03137 03138 if (FirstSelected == NULL || !FirstSelected->IsALibraryColour() || TheColour == NULL) 03139 NewCol = ColourManager::GenerateNewNamedColour(ColList, SelectedColour); 03140 else 03141 { 03142 // A library doccolour - we must copy it into the document before trying to apply it 03143 // Make a temporary IndexedColour from the library colour 03144 NewCol = new IndexedColour(*TheColour); 03145 03146 if (NewCol != NULL) 03147 { 03148 SGDisplayLibColour *LibCol = (SGDisplayLibColour *) FirstSelected; 03149 03150 // Set the colour's name to the same as the library item (but make sure it's unique) 03151 String_256 Buffer; 03152 LibCol->GetNameText(&Buffer); 03153 NewCol->SetName(Buffer); 03154 if (ColList->GenerateUniqueColourName(NewCol->GetName(), (String_64 *) &Buffer)) 03155 NewCol->SetName(Buffer); 03156 03157 // If it's a spot colour, make it so 03158 if (LibCol->IsASpotColour()) 03159 NewCol->SetLinkedParent(NULL, COLOURTYPE_SPOT); 03160 03161 // Copy the colour into the destination document (merging it with existing 03162 // colours so we won't keep creating new copies of the same colour as it's applied) 03163 DocColour ColourToApply; 03164 ColourToApply.MakeRefToIndexedColour(NewCol); 03165 ColourManager::EnsureColourIsInDocument(NULL, Document::GetSelected(), &ColourToApply); 03166 03167 // Delete the temporary IndexedColour we used 03168 delete NewCol; 03169 03170 // And remember the new colour we've just made 03171 NewCol = ColourToApply.FindParentIndexedColour(); 03172 } 03173 } 03174 03175 // If NewCol == NULL, either an error occured, or more likely, the user cancelled 03176 03177 ISentTheMessage = OldSentState; 03178 03179 if (NewCol != NULL) 03180 { 03181 // Bring up the colour editor on the new colour 03182 EditColour(ColList, NewCol); 03183 03184 // And make the new item the selected one in the list 03185 SelectItems(FALSE); // Deselect everything else 03186 03187 // Find the item and select it 03188 SGDisplayGroup *DocGroup = DisplayTree->FindSubtree(this, 03189 Document::GetSelected(), NULL); 03190 if (DocGroup != NULL) 03191 { 03192 // We've found the group for the selected document 03193 SGDisplayColour *Ptr = new SGDisplayColour(NewCol); 03194 if (Ptr != NULL) 03195 { 03196 // Add the item to the group using the last applied sort mode 03197 DocGroup->AddItem(Ptr, SortKeys); 03198 03199 // And rearrange the real colour item to the same position by inserting 03200 // it after the colour which is previous in the display list. If there 03201 // is no display-list-previous-item, then we insert at the head. 03202 ColourList *ColList = ColourManager::GetColourList(); 03203 ColList->RemoveItem(NewCol); 03204 03205 if (ColList->GetHead() == NULL) 03206 { 03207 // Thanks, Mario. If you try to add an item when the list is empty 03208 // he just ignores you (no ensure, no useful default behaviour) 03209 ColList->AddItem(NewCol); 03210 } 03211 else 03212 { 03213 if (Ptr->GetPrevious() == NULL) 03214 ColList->InsertBefore(ColList->GetHead(), NewCol); 03215 else 03216 ColList->InsertAfter(((SGDisplayColour *)Ptr->GetPrevious())-> 03217 GetDisplayedColour()->FindParentIndexedColour(), NewCol); 03218 } 03219 03220 ForceGroupFolded(DocGroup, FALSE); // Ensure group is unfolded and tree reformatted 03221 03222 // Select the new node, and remember it as the new selection anchor 03223 Ptr->SetSelected(TRUE); 03224 SetLastSelectedNode(Ptr); 03225 03226 // Ensure the format is recalculated as a result of adding the new item 03227 ReformatAndRedrawIfNecessary(); 03228 03229 // And now we can get its format rect, and scroll to show it 03230 DocRect ItemFormatRect; 03231 Ptr->GetFormatRect(&ItemFormatRect); 03232 ScrollToShow(&ItemFormatRect); 03233 } 03234 } 03235 else 03236 { 03237 ERROR3("Colour DisplayGroup not found for Selected Document!"); 03238 } 03239 03240 SelectionHasChanged(); 03241 } 03242 } 03243 break; 03244 03245 03246 case SGACTION_APPLYADJUST: 03247 Adjust = TRUE; 03248 // Drop through to SGACTION_APPLY handler 03249 03250 case SGACTION_APPLY: 03251 if (TheColour != NULL && (SelectedColour != NULL || FirstSelected->IsALibraryColour())) 03252 { 03253 DocColour ColourToApply; 03254 03255 if (!FirstSelected->IsALibraryColour()) 03256 { 03257 // Normal IndexedColour item - just apply it 03258 ColourToApply.MakeRefToIndexedColour(SelectedColour); 03259 03260 // Ensure this colour (or an equivalent) is available in the selected doc 03261 // (which is where the apply will take place), and modify ColourToApply 03262 // (if necessary) to reference the safe colour for the dest doc. 03263 ColourManager::EnsureColourIsInDocument(ScopeDoc, Document::GetSelected(), &ColourToApply); 03264 } 03265 else 03266 { 03267 // A library doccolour - we must copy it into the document before trying to apply it 03268 // Make a temporary IndexedColour from the library colour 03269 IndexedColour *NewCol = new IndexedColour(*TheColour); 03270 03271 if (NewCol != NULL) 03272 { 03273 SGDisplayLibColour *LibCol = (SGDisplayLibColour *) FirstSelected; 03274 03275 // Set the colour's name to the same as the library item 03276 String_256 Buffer; 03277 LibCol->GetNameText(&Buffer); 03278 NewCol->SetName(Buffer); 03279 03280 // If it's a spot colour, make it so 03281 if (LibCol->IsASpotColour()) 03282 NewCol->SetLinkedParent(NULL, COLOURTYPE_SPOT); 03283 03284 // Copy the colour into the destination document (merging it with existing 03285 // colours so we won't keep creating new copies of the same colour as it's applied) 03286 ColourToApply.MakeRefToIndexedColour(NewCol); 03287 ColourManager::EnsureColourIsInDocument(NULL, Document::GetSelected(), &ColourToApply); 03288 03289 // And delete the temporary IndexedColour we used 03290 delete NewCol; 03291 NewCol = NULL; 03292 } 03293 } 03294 03295 if (ColourToApply.FindParentIndexedColour() != NULL) 03296 { 03297 // We've got a colour to apply, so apply it 03298 03299 NodeAttribute *Attrib; 03300 if (Adjust) 03301 { 03302 // Adjust-ed, so set the line colour 03303 Attrib = new AttrStrokeColourChange; 03304 if (Attrib == NULL) 03305 { 03306 InformError(); 03307 return(FALSE); 03308 } 03309 03310 ((AttrStrokeColourChange *)Attrib)->SetStartColour(&ColourToApply); 03311 } 03312 else 03313 { 03314 // Select-ed so set the fill colour 03315 Attrib = new AttrColourChange; 03316 if (Attrib == NULL) 03317 { 03318 InformError(); 03319 return(FALSE); 03320 } 03321 03322 ((AttrColourChange *)Attrib)->SetStartColour(&ColourToApply); 03323 } 03324 03325 // AttributeSelected knows what to do with a selected attribute 03326 AttributeManager::AttributeSelected(NULL, Attrib); 03327 } 03328 } 03329 break; 03330 03331 03332 case SGACTION_REDEFINE: 03333 if (SelectedColour != NULL && TheColour != NULL) 03334 { 03335 // First, try to find an interesting colour to redefine from 03336 DocColour SourceColour; 03337 ColourList *SrcColList; 03338 03339 ColourManager::FindColourOfInterestToUser(&SourceColour, &SrcColList); 03340 03341 if (SourceColour.FindParentIndexedColour() == SelectedColour) 03342 { 03343 // You can't redefine a colour from itself! Don't be daft! 03344 InformError(_R(IDE_COLGAL_SAMEITEM)); 03345 return(FALSE); 03346 } 03347 03348 // Copy the colour 03349 IndexedColour *NewCol = new IndexedColour(SourceColour); 03350 if (NewCol == NULL) 03351 return(FALSE); 03352 03353 if (SrcColList != ColList || NewCol->IsADescendantOf(SelectedColour)) 03354 { 03355 // We're redefining from a colour in a different document, or attempting to make a 03356 // recursive parent-pointer loop. Remove the parent linkage to make NewCol a standalone 03357 // copy of its previous parent. 03358 NewCol->SetLinkedParent(NULL, 03359 (NewCol->GetType() == COLOURTYPE_SPOT) ? COLOURTYPE_SPOT : COLOURTYPE_NORMAL); 03360 } 03361 03362 // Compose a new, unique, name for it - e.g. "Red (Redefined)" 03363 String_128 NewName(_R(IDS_UNNAMEDCOLOUR)); 03364 if (SelectedColour->IsNamed()) 03365 NewName.MakeMsg(_R(IDS_REDEFINEDCOLOUR), (TCHAR *) (*(SelectedColour->GetName())) ); 03366 03367 // Ensure the new name is unique within the destination colour list 03368 String_64 UniqueNewName; 03369 ColList->GenerateUniqueColourName(&NewName, &UniqueNewName); 03370 NewCol->SetName(UniqueNewName); 03371 03372 // And finally, apply the colour change, with UNDO 03373 // (Note that NewCol is put into the undo system, so we must not delete it) 03374 return(ColourManager::ChangeColour(ColList, NewCol, SelectedColour)); 03375 } 03376 break; 03377 03378 03379 case SGACTION_EDIT: 03380 if (ScopeDoc != Document::GetSelected()) 03381 { 03382 // **** BODGE! TO DO !!!! 03383 // This should make the appropriate document selected by chucking its window to the front, and 03384 // then invoke the colour editor on the selected colour 03385 03386 InformMessage(_R(IDS_COLGAL_NOTSELDOC), _R(IDS_CANCEL)); 03387 break; 03388 } 03389 03390 // Always show the editor, and if there is a selection, edit the 03391 // first selected colour 03392 EditColour(ColList, SelectedColour); 03393 break; 03394 03395 03396 case SGACTION_DELETE: 03397 { 03398 while (DocumentGroup != NULL) 03399 { 03400 // For each document, if there are selected items in the document, then 03401 // delete them (after asking the user for each document) TODO : Clean up!!!! 03402 03403 ScopeDoc = DocumentGroup->GetParentDocument(); 03404 if (ScopeDoc != NULL) 03405 { 03406 ColList = ScopeDoc->GetIndexedColours(); 03407 ERROR3IF(ColList == NULL, 03408 "A document with no colour list? Now I've seen it all"); 03409 03410 if (DocumentGroup->GetSelectedItemCount() > 0) 03411 { 03412 if (OKToDeleteSelection(DocumentGroup)) 03413 { 03414 if (!DeleteSelection(DocumentGroup, ColList)) 03415 return(FALSE); 03416 } 03417 } 03418 } 03419 03420 DocumentGroup = (SGDisplayGroup *) DocumentGroup->GetNext(); 03421 } 03422 03423 SelectionHasChanged(); 03424 } 03425 break; 03426 03427 03428 case SGACTION_SETOPTIONS: // Set values in the options/sort dialogue as it is opened 03429 if (CurrentOptionsDlg != NULL) 03430 { // Display Modes 03431 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_SMALL)); // 0 03432 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_FULLINFO)); // 1 03433 CurrentOptionsDlg->AddDisplayModeName(_R(IDS_GALLERYDM_ICONONLY)); // 2 03434 } 03435 break; 03436 03437 case SGACTION_SETSORTMODE: 03438 if (CurrentSortDlg != NULL) 03439 { // Sort Modes (0 = none) 03440 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_NAME)); // 1 (sort by name) 03441 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_HUE)); // 2 03442 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_INTENSITY)); // 3 03443 CurrentSortDlg->AddSortKeyName(_R(IDS_SORTBY_MODEL)); // 4 03444 } 03445 break; 03446 03447 03448 case SGACTION_DISPLAYMODECHANGED: 03449 // Ensure that the display mode is one of the supported values 03450 if (DisplayMode < 0 || DisplayMode > 2) 03451 DisplayMode = 0; 03452 break; 03453 03454 03455 default: 03456 return(FALSE); 03457 } 03458 03459 return(TRUE); 03460 }
|
|
|
Takes the selected item in the gallery and tries to apply this as a new background to the spread.
Definition at line 4507 of file sgcolour.cpp. 04508 { 04509 SGDisplayColour *pFirstSelected = (SGDisplayColour *)DisplayTree->FindNextSelectedItem(NULL); 04510 if (pFirstSelected != NULL) 04511 { 04512 // Use the first selected colour and ask a page background to be made 04513 // using this. 04514 TRACEUSER( "NEVILLE", _T("SGCmd_SetBackground")); 04515 04516 Document * pScopeDoc = NULL; 04517 DocColour ColourToApply; 04518 BOOL ok = GetDocColourToApply(pFirstSelected, &ColourToApply, &pScopeDoc); 04519 04520 // Only apply if we found a valid document and the colour was ok 04521 if (ok && pScopeDoc) 04522 { 04523 OpBackgroundParam Param; 04524 Param.pDocColour = &ColourToApply; 04525 Param.pDoc = pScopeDoc; 04526 04527 // Obtain a pointer to the op descriptor for the create operation 04528 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND); 04529 04530 // Invoke the operation, passing DocView and Pos as parameters 04531 pOpDesc->Invoke(&Param); 04532 04533 return TRUE; 04534 } 04535 04536 return FALSE; 04537 } 04538 04539 return FALSE; 04540 }
|
|
||||||||||||
|
To build a menu of commands to be popped up over the gallery.
Reimplemented from SuperGallery. Definition at line 4253 of file sgcolour.cpp. 04254 { 04255 BOOL ok = TRUE; 04256 04257 // Edits to the pop-up menu on the colour gallery 04258 04259 if (MenuID == SGMENU_OPTIONS) 04260 { 04261 // Options menu 04262 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Find); 04263 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Sort); 04264 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties); 04265 } 04266 else 04267 { 04268 // Over-list menu 04269 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_New); 04270 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Edit); 04271 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Delete); 04272 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Redefine); 04273 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Rename, TRUE); // With separator 04274 04275 SGDisplayGroup *TheGroup = FindCommandGroup(); // Fold or unfold as appropriate 04276 if (TheGroup == NULL || !TheGroup->Flags.Folded) 04277 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FoldGroup); 04278 else 04279 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_UnfoldGroup); 04280 04281 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_PrevGroup); 04282 // add 'Show in colour line' menu item in Camelot 04283 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_NextGroup, TRUE); // With separator 04284 04285 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_ShowInColourLine); 04286 ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_SetBackground); 04287 } 04288 04289 return(ok); 04290 }
|
|
||||||||||||
|
Central point where it decides whether the colour should be displayed in the gallery.
Definition at line 2619 of file sgcolour.cpp. 02620 { 02621 ERROR2IF(pCol == NULL,FALSE,"NULL colour ptr"); 02622 ERROR2IF(pColList == NULL,FALSE,"NULL colour list ptr"); 02623 02624 //#ifndef WEBSTER 02625 return (!pCol->IsDeleted() && pCol->IsNamed()); // v1.5 implementation 02626 //#else 02627 // if (!pCol->IsDeleted() && pCol->IsNamed()) 02628 // { 02629 // if (pCol->HasLinkedChildren() && pCol->FindLinkedParent() == NULL) 02630 // { 02631 // // OK, the colour has a child yet no parent, so it must be a top-level parent colour? 02632 // // Well, not quite. 02633 // // 02634 // // If the colour editor has been opened, it may have created an editing colour 02635 // // and linked it to one of the colours in the colour list *just in case* you wish to link 02636 // // it to another colour 02637 // // 02638 // // This linking is done so that it can make an intelligent choice on which colour you wish 02639 // // to link to. 02640 // // 02641 // // The following loop checks to see if there is another *real* colour (i.e. one in the document) 02642 // // that is linked to this colour 02643 // 02644 // IndexedColour *pColInList = (IndexedColour *) pColList->GetUndeletedHead(); 02645 // while (pColInList != NULL) 02646 // { 02647 // if (pColInList != pCol && pColInList->IsADescendantOf(pCol)) 02648 // return TRUE; 02649 // 02650 // pColInList = pColList->GetUndeletedNext(pColInList); 02651 // } 02652 // } 02653 // } 02654 // 02655 // return FALSE; 02656 //#endif // WEBSTER 02657 }
|
|
||||||||||||||||
|
"Copies" the existing node in the tree in an appropriate fashion.
TargetPosition - NULL (to insert at the end of the sibling list), or points to an item BEFORE which SourceItem will be copied.
Notes: This derived class override copies colours between documents. Currently, this just errors to the user, as copying between docs is not possible, due to undo going into the selected doc. **** !!!!
Reimplemented from SuperGallery. Definition at line 3923 of file sgcolour.cpp. 03925 { 03926 ERROR3IF(SourceItem == NULL || DestGroup == NULL, "Illegal NULL param"); 03927 03928 if (DestGroup->Flags.ReadOnly) 03929 { 03930 ERROR2RAW("Trying to copy a colour into a read-only (library) group"); 03931 InformError(); 03932 return(NULL); // Sanity check - disallow copy into a library group! 03933 } 03934 03935 Document *DestDoc = DestGroup->GetParentDocument(); 03936 if (DestDoc == NULL) 03937 { 03938 ERROR2RAW("No dest doc?!"); 03939 InformError(); 03940 return(NULL); 03941 } 03942 03943 // Normal colour drag between 2 documents 03944 DocColour *DocColToCopy = ((SGDisplayColour *) SourceItem)->GetDisplayedColour(); 03945 ERROR3IF(DocColToCopy == NULL, "NULL displayed colour?!"); 03946 03947 IndexedColour *ColToCopy = NULL; 03948 BOOL ColIsTemporary = FALSE; 03949 03950 if (((SGDisplayColour *) SourceItem)->IsALibraryColour()) 03951 { 03952 // The dragged item is not resident in any document - it's in a library 03953 // Create a temporary IndexedColour to be copied into the doc 03954 ColToCopy = new IndexedColour(*DocColToCopy); 03955 ColIsTemporary = TRUE; 03956 03957 if (ColToCopy != NULL) 03958 { 03959 // Set the colour's name to the same as the library item 03960 String_256 Buffer; 03961 ((SGDisplayLibColour *) SourceItem)->GetNameText(&Buffer); 03962 ColToCopy->SetName(Buffer); 03963 03964 if (((SGDisplayLibColour *) SourceItem)->IsASpotColour()) 03965 ColToCopy->SetLinkedParent(NULL, COLOURTYPE_SPOT); 03966 } 03967 else 03968 { 03969 ERROR3("No memory for copied colour"); 03970 } 03971 } 03972 else 03973 { 03974 ColToCopy = DocColToCopy->FindParentIndexedColour(); 03975 ERROR3IF(ColToCopy == NULL, "NULL displayed colour?!"); 03976 } 03977 03978 if (ColToCopy == NULL) 03979 return(NULL); 03980 03981 // If we haven't already started a component copy, set one up 03982 if (CurrentColComp == NULL) 03983 { 03984 CurrentColComp = (ColourListComponent *) 03985 DestDoc->GetDocComponent(CC_RUNTIME_CLASS(ColourListComponent)); 03986 if (CurrentColComp == NULL) 03987 { 03988 if (ColIsTemporary) 03989 delete ColToCopy; 03990 03991 ERROR2RAW("Couldn't find a colour list component for the destination document!"); 03992 InformError(); 03993 return(NULL); 03994 } 03995 03996 if (!CurrentColComp->StartComponentCopy()) // If this fails, it reports the error itself 03997 { 03998 if (ColIsTemporary) 03999 delete ColToCopy; 04000 04001 return(NULL); 04002 } 04003 04004 CurrentTarget = TargetPosition; 04005 } 04006 04007 // Create a new display item, referencing the colour to be copied 04008 SGDisplayColour *NewDisplayItem = new SGDisplayColour(ColToCopy); 04009 if (NewDisplayItem == NULL) 04010 { 04011 if (ColIsTemporary) 04012 delete ColToCopy; 04013 04014 InformError(); 04015 return(NULL); 04016 } 04017 04018 // Remap the display item to reference a safe colour for the destination document 04019 // NOTE that we use a special TRUE flag here to indicate that we know the colour 04020 // is always unique - this stops the ColComp from caching a pointer to our temporary 04021 // colour (which then is reallocated for the next colour, which then causes 04022 // all the colour mapping to get very very confused). 04023 if (CurrentColComp->CopyColourAcross(NewDisplayItem->GetDisplayedColour(), TRUE) != CCCOPY_NEWCOLOUR) 04024 { 04025 // Either the copy failed (we have no colour to display), or it was merged with 04026 // an existing colour (in which case there will already be a display item for it) 04027 delete NewDisplayItem; 04028 04029 if (ColIsTemporary) 04030 delete ColToCopy; 04031 04032 return(NULL); 04033 } 04034 04035 SuperGallery::InsertCopiedItem(NewDisplayItem, DestGroup, TargetPosition); 04036 04037 // If we copied a library item, then delete the temporary IndexedColour we created 04038 if (ColIsTemporary) 04039 { 04040 delete ColToCopy; 04041 ColToCopy = NULL; 04042 } 04043 04044 // And update the item selection states, so that the copied item is the selected one 04045 // We poke directly at the selected flag to avoid it trying to redraw itself when we know 04046 // it hasn't had a chance to format itself yet. 04047 // SourceItem->SetSelected(FALSE); 04048 // NewDisplayItem->Flags.Selected = TRUE; 04049 04050 return(NewDisplayItem); 04051 }
|
|
||||||||||||
|
Internal call. This takes the colour list of the given document and creates a DisplayTree subtree from it. This subtree is then added to the DisplayTree. Note that this does not force a redraw of the list - after making this call, you should also call ForceRedrawOfList.
It now scans the existinggroup (if any), and takes no action if it exactly matches the parent colour list.
Definition at line 2498 of file sgcolour.cpp. 02499 { 02500 ERROR3IF(ParentDoc == NULL, "ColourSGallery::CreateNewSubtree - illegal NULL parameter"); 02501 if (ParentDoc == NULL || DisplayTree == NULL) 02502 return; 02503 02504 // Don't add subtrees for clipboards! 02505 if (ParentDoc->IsAClipboard() || ParentDoc->IsAHiddenDoc()) 02506 return; 02507 02508 SGDisplayColourGroup *DisplayDocument = NULL; 02509 SGDisplayColour *DisplayColour = NULL; 02510 02511 if (ExistingGroup != NULL) 02512 { 02513 ERROR3IF(ExistingGroup->GetParentDocument() != ParentDoc, 02514 "This group is not for that document! What's going down, dude?"); 02515 DisplayDocument = ExistingGroup; // Use existing group 02516 02517 // Scan the ExistingGroup, to see if we really need to do anything 02518 BOOL DisplayCorrect = TRUE; 02519 ColourList *ColList = ParentDoc->GetIndexedColours(); 02520 IndexedColour *TheCol = ColList->GetUndeletedHead(); 02521 DisplayColour = (SGDisplayColour *) DisplayDocument->GetChild(); 02522 02523 while (TheCol != NULL && DisplayColour != NULL && DisplayCorrect) 02524 { 02525 if (TheCol != DisplayColour->GetDisplayedColour()->FindParentIndexedColour()) 02526 DisplayCorrect = FALSE; 02527 02528 TheCol = ColList->GetUndeletedNext(TheCol); 02529 DisplayColour = (SGDisplayColour *) DisplayColour->GetNext(); 02530 } 02531 02532 if (DisplayCorrect && TheCol == NULL && DisplayColour == NULL) 02533 { 02534 // The display is exactly right- we don't need to do anything 02535 return; 02536 } 02537 02538 DisplayDocument->DestroySubtree(FALSE); // Wipe any existing colour display items 02539 } 02540 else 02541 { 02542 DisplayDocument = new SGDisplayColourGroup(this, ParentDoc, NULL);// Create new Group 02543 02544 if (DisplayDocument == NULL) // Total failure - abort 02545 { 02546 InformError(); 02547 return; 02548 } 02549 02550 DisplayDocument->Flags.CanSelect = TRUE; // Group is selectable 02551 02552 // Make sure that any library groups stay at the bottom of the gallery 02553 SGDisplayNode *InsertionPos = DisplayTree->GetChild(); 02554 while (InsertionPos != NULL) 02555 { 02556 if (InsertionPos->IsKindOf(CC_RUNTIME_CLASS(SGDisplayLibColGroup))) 02557 break; 02558 02559 InsertionPos = InsertionPos->GetNext(); 02560 } 02561 02562 // And add the group to the tree 02563 if (InsertionPos != NULL) 02564 InsertionPos->InsertBefore(DisplayDocument); // Insert in front of libraries 02565 else 02566 DisplayTree->AddItem(DisplayDocument); // No libraries - just AddTail 02567 02568 // And ensure it is folded/unfolded as appropriate (but don't bother redrawing) 02569 DisplayDocument->SetFoldedState((ParentDoc != Document::GetSelected()), FALSE); 02570 } 02571 02572 ColourList *ColList = ParentDoc->GetIndexedColours(); 02573 IndexedColour *CurColour = (ColList == N |