#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 == NULL) ? NULL : (IndexedColour *) ColList->GetHead(); 02574 02575 while (CurColour != NULL) // For each colour in the doc... 02576 { 02577 // if (!CurColour->IsDeleted() && CurColour->IsNamed()) // If alive & named... 02578 02579 // WEBSTER - markn 5/12/96 02580 // New func that decides weather the colour should be added to the gallery 02581 // called CanAddColourToGallery() 02582 02583 if (CanAddColourToGallery(CurColour,ColList)) // If alive & named... 02584 { 02585 DisplayColour = new SGDisplayColour(CurColour); 02586 if (DisplayColour == NULL) 02587 { 02588 InformError(); 02589 return; 02590 } 02591 02592 DisplayDocument->AddItem(DisplayColour); // Create & add item for it 02593 } 02594 02595 CurColour = (IndexedColour *) ColList->GetNext(CurColour); // Next colour 02596 } 02597 }
|
|
An overridable veneer to the DialogOp CreateOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering.
Notes: This ovverrides the base class to do the same thing, but to make our RenderRegion use colour correction/separation options from the selected view, so that we display "document colours" correctly for the selview.
Reimplemented from SuperGallery. Definition at line 4142 of file sgcolour.cpp. 04143 { 04144 return(CreateOSRenderRegion(VirtualSize, DlgRedrawInfo, TRUE)); 04145 }
|
|
Forcibly deletes all selected colours Should be used after OKToDeleteSelection (which confirms the action).
Definition at line 3010 of file sgcolour.cpp. 03011 { 03012 if (ParentList == NULL) 03013 return(TRUE); 03014 03015 INT32 TotalItems = DocumentGroup->GetSelectedItemCount(); 03016 if (TotalItems == 0) 03017 return(TRUE); 03018 03019 IndexedColour **KillList = new IndexedColourPtr[TotalItems+1]; 03020 if (KillList == NULL) 03021 return(FALSE); 03022 03023 DWORD KillIndex = 0; 03024 SGDisplayColour *Item = (SGDisplayColour *) DocumentGroup->FindNextSelectedItem(NULL); 03025 SGDisplayColour *NextItem; 03026 IndexedColour *RefColour; 03027 03028 while (Item != NULL) 03029 { 03030 // Remember the NextItem item, cos we're about to delink/destroy this one 03031 NextItem = (SGDisplayColour *) DocumentGroup->FindNextSelectedItem(Item); 03032 03033 RefColour = Item->GetDisplayedColour()->FindParentIndexedColour(); 03034 if (RefColour != NULL) 03035 { 03036 // Add the colour to the kill list 03037 KillList[KillIndex++] = RefColour; 03038 03039 // Annihilate this item, so that it no longer references the IndexedColour 03040 Item->DestroySubtree(); 03041 } 03042 03043 // And move on to the NextItem item 03044 Item = NextItem; 03045 } 03046 03047 KillList[KillIndex] = NULL; // NULL terminate the list 03048 03049 // Now cause a redraw of the tree in its new state, before the message broadcast goes around 03050 InvalidateCachedFormat(); 03051 ReformatAndRedrawIfNecessary(); 03052 03053 // Delete (hide, with undo actually) the given colours 03054 // Our message handler will cope with redrawing the new list (we must do it this 03055 // way in case the deletion causes other changes to the list, e.g. a new 'black' 03056 // being created if we delete the default one) 03057 ColourManager::HideColours(ParentList, KillList, TRUE); 03058 03059 // HideColours has made a copy of this list for itself, so we are responsible 03060 // for deleting our original list 03061 delete [] KillList; 03062 03063 03064 return(TRUE); 03065 }
|
|
An overridable veneer to the DialogOp DestroyOSRenderRegion method. This can be overriden to use a different type of renderregion for all of your rendering.
Reimplemented from SuperGallery. Definition at line 4166 of file sgcolour.cpp. 04167 { 04168 DestroyOSRenderRegion(pRender); 04169 }
|
|
To apply a given command when it is chosen from the menu.
The base class handles all of these (maybe more - see the base class help) Properties, Sort, Find; New, Edit, Delete, Redefine; (it calls ApplyAction as appropriate) NextGroup, PrevGroup, FoldGroup, UnfoldGroup; Reimplemented from SuperGallery. Definition at line 4441 of file sgcolour.cpp. 04442 { 04443 if (*CommandID == SGCmd_Rename) 04444 { 04445 SGDisplayColour *FirstSelected = (SGDisplayColour *) // Invoke name-colour dialogue 04446 DisplayTree->FindNextSelectedItem(NULL); 04447 if (FirstSelected != NULL && !FirstSelected->IsALibraryColour()) 04448 { 04449 IndexedColour *ColToEdit = FirstSelected->GetDisplayedColour()-> 04450 FindParentIndexedColour(); 04451 04452 SGDisplayGroup *DocumentGroup = (SGDisplayGroup *) FirstSelected->GetParent(); 04453 ERROR3IF(DocumentGroup == NULL, "SGallery DisplayTree linkage corruption detected"); 04454 04455 Document *ScopeDoc = DocumentGroup->GetParentDocument(); 04456 ERROR3IF(ScopeDoc == NULL, "SGallery group is not for a document! Unimplemented! Eek!"); 04457 04458 ColourList *ColList = ScopeDoc->GetIndexedColours(); 04459 ERROR3IF(ColList == NULL, "A document with no colour list? Now I've seen it all"); 04460 04461 if (ColToEdit != NULL) 04462 ColourNameDlg::InvokeDialog(ColList, ColToEdit); 04463 } 04464 } 04465 else if (*CommandID == SGCmd_ShowInColourLine) // Toggle the show in colour line state 04466 { 04467 SGDisplayColour *pFirstSelected = (SGDisplayColour *)DisplayTree->FindNextSelectedItem(NULL); 04468 SGDisplayColourGroup *pGroup = (SGDisplayColourGroup *) DisplayTree->FindNextSelectedGroup(NULL); 04469 if (pGroup == NULL && pFirstSelected != NULL) 04470 { 04471 pGroup = (SGDisplayColourGroup *) pFirstSelected->GetParent(); 04472 } 04473 if (pGroup) 04474 { 04475 //SGDisplayLibColGroup * pLibGroup = (SGDisplayColourGroup*) pGroup; 04476 // We have a group item selected so use it 04477 // Only do this on library colour groups at present 04478 pGroup->ToggleDisplayInColourLine(); 04479 04480 // Ensure any colours libraries that are now required are loaded 04481 // This should also send a message to the colour line to force an update 04482 CColourBar::EnsureLibraryColoursPresent(); 04483 } 04484 } 04485 else if (*CommandID == SGCmd_SetBackground) // Set the page background colour 04486 { 04487 ApplySelectedAsBackground(); 04488 } 04489 else 04490 SuperGallery::DoCommand(CommandID); // Unknown command- pass to the base class 04491 }
|
|
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.
Reimplemented from SuperGallery. Definition at line 4713 of file sgcolour.cpp. 04714 { 04715 // Shade any non-standard buttons that we have on the gallery 04716 EnableGadget(_R(IDC_COLGAL_BACKGROUND), !ShadeIt); 04717 }
|
|
Opens the colour editor, and sets it to edit the given colour.
Definition at line 2876 of file sgcolour.cpp. 02877 { 02878 ColourPicker ColPicker; 02879 ColPicker.EditColour(ParentList, TheColour); 02880 }
|
|
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).
The base class handles all of these (maybe more - see the base class help) Properties, Sort, Find; New, Edit, Delete, Redefine; NextGroup, PrevGroup, FoldGroup, UnfoldGroup; Reimplemented from SuperGallery. Definition at line 4320 of file sgcolour.cpp. 04321 { 04322 OpState State; 04323 04324 if (AmShaded) // No commands available while the gallery is shaded 04325 { 04326 State.Greyed = TRUE; 04327 return(State); 04328 } 04329 04330 // Determine if the entire selection consists only of library colours... 04331 BOOL AllSelectionIsLibrary = TRUE; 04332 SGDisplayColour *Col = (SGDisplayColour *) DisplayTree->FindNextSelectedItem(NULL); 04333 SGDisplayColour *pSelectedItem = Col; 04334 if (Col == NULL) 04335 AllSelectionIsLibrary = FALSE; 04336 04337 while (Col != NULL) 04338 { 04339 if (!Col->IsALibraryColour()) 04340 AllSelectionIsLibrary = FALSE; 04341 04342 Col = (SGDisplayColour *) DisplayTree->FindNextSelectedItem(Col); 04343 } 04344 04345 // determine the command state... 04346 if (*CommandID == SGCmd_New) // --- New 04347 { 04348 if (GetSelectedItemCount() > 1) 04349 { 04350 State.Greyed = TRUE; 04351 ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLE)); 04352 } 04353 } 04354 else if (*CommandID == SGCmd_Rename) // --- Rename 04355 { 04356 if (GetSelectedItemCount() != 1) 04357 { 04358 State.Greyed = TRUE; 04359 ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLECOL)); 04360 } 04361 else if (AllSelectionIsLibrary) 04362 { 04363 State.Greyed = TRUE; 04364 ShadeReason->MakeMsg(_R(IDS_ITSALIBRARYCOLOUR)); 04365 } 04366 } 04367 else if (*CommandID == SGCmd_Edit || // --- Edit, Redefine, Delete 04368 *CommandID == SGCmd_Redefine || 04369 *CommandID == SGCmd_Delete) 04370 { 04371 // Make sure we disallow these options when the selection is a library colour 04372 if (AllSelectionIsLibrary) 04373 { 04374 State.Greyed = TRUE; 04375 ShadeReason->MakeMsg(_R(IDS_ITSALIBRARYCOLOUR)); 04376 } 04377 else 04378 return(SuperGallery::GetCommandState(CommandID, ShadeReason)); 04379 } 04380 else if (*CommandID == SGCmd_ShowInColourLine) 04381 { 04382 // Make sure we only allow these options when the selection is a library colour 04383 SGDisplayColourGroup *pGroup = (SGDisplayColourGroup *) DisplayTree->FindNextSelectedGroup(NULL); 04384 if (pGroup == NULL && pSelectedItem != NULL) 04385 { 04386 pGroup = (SGDisplayColourGroup *) pSelectedItem->GetParent(); 04387 } 04388 if (pGroup) 04389 { 04390 // We have a group item selected so use it 04391 // Only do this on library colour groups at present 04392 //SGDisplayLibColGroup * pLibGroup = (SGDisplayLibColGroup*) pGroup; 04393 State.Ticked = pGroup->DisplayInColourLine(); 04394 } 04395 else 04396 { 04397 State.Greyed = TRUE; 04398 ShadeReason->MakeMsg(_R(IDS_ITSNOTALIBRARYCOLOUR)); 04399 } 04400 } 04401 else if (*CommandID == SGCmd_SetBackground) // Set the page background colour 04402 { 04403 // Ensure we have a single selected colour and a selected document 04404 Document * pDoc = Document::GetSelected(); 04405 if (pSelectedItem == NULL || pDoc == NULL) 04406 { 04407 State.Greyed = TRUE; 04408 ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLECOL)); 04409 } 04410 } 04411 else 04412 return(SuperGallery::GetCommandState(CommandID, ShadeReason)); // Unknown command- pass to baseclass 04413 04414 return(State); 04415 }
|
|
Definition at line 536 of file sgcolour.h. 00536 { return(CurrentImportGroup); };
|
|
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.
Definition at line 4561 of file sgcolour.cpp. 04563 { 04564 ERROR2IF(pFirstSelected == NULL || pColourToApply == NULL || pDoc == NULL,FALSE,"GetDocColourToApply bad params!"); 04565 04566 // Try to get the parent item of the selected item and ask it for the associated document 04567 SGDisplayGroup * DocumentGroup = (SGDisplayGroup *) pFirstSelected->GetParent(); 04568 ERROR3IF(DocumentGroup == NULL, "SGallery DisplayTree linkage corruption detected"); 04569 04570 Document * pScopeDoc = DocumentGroup->GetParentDocument(); 04571 if (pScopeDoc == NULL) // Must be a library item, so it will affect the selected doc 04572 pScopeDoc = Document::GetSelected(); 04573 04574 // Return this to the caller 04575 *pDoc = pScopeDoc; 04576 04577 // If we have no document to work with then nothing doing 04578 if (pScopeDoc == NULL) 04579 { 04580 ERROR3("No scope document for colour gallery operation!"); 04581 return FALSE; 04582 } 04583 04584 DocColour * pTheColour = pFirstSelected->GetDisplayedColour(); 04585 ERROR3IF(pTheColour == NULL, "SGDisplayColour has no colour in it?"); 04586 04587 IndexedColour *pSelectedColour = pTheColour->FindParentIndexedColour(); 04588 04589 // Check that we have a minimal ensemble of required items 04590 if (pTheColour != NULL && (pSelectedColour != NULL || pFirstSelected->IsALibraryColour())) 04591 { 04592 if (!pFirstSelected->IsALibraryColour()) 04593 { 04594 // Normal IndexedColour item - just apply it 04595 pColourToApply->MakeRefToIndexedColour(pSelectedColour); 04596 04597 // Ensure this colour (or an equivalent) is available in the selected doc 04598 // (which is where the apply will take place), and modify ColourToApply 04599 // (if necessary) to reference the safe colour for the dest doc. 04600 ColourManager::EnsureColourIsInDocument(pScopeDoc, Document::GetSelected(), pColourToApply); 04601 } 04602 else 04603 { 04604 // A library doccolour - we must copy it into the document before trying to apply it 04605 // Make a temporary IndexedColour from the library colour 04606 IndexedColour *pNewCol = new IndexedColour(*pTheColour); 04607 04608 if (pNewCol != NULL) 04609 { 04610 SGDisplayLibColour *pLibCol = (SGDisplayLibColour *) pFirstSelected; 04611 04612 // Set the colour's name to the same as the library item 04613 String_256 Buffer; 04614 pLibCol->GetNameText(&Buffer); 04615 pNewCol->SetName(Buffer); 04616 04617 // If it's a spot colour, make it so 04618 if (pLibCol->IsASpotColour()) 04619 pNewCol->SetLinkedParent(NULL, COLOURTYPE_SPOT); 04620 04621 // Copy the colour into the destination document (merging it with existing 04622 // colours so we won't keep creating new copies of the same colour as it's applied) 04623 pColourToApply->MakeRefToIndexedColour(pNewCol); 04624 ColourManager::EnsureColourIsInDocument(NULL, Document::GetSelected(), pColourToApply); 04625 04626 // And delete the temporary IndexedColour we used 04627 delete pNewCol; 04628 pNewCol = NULL; 04629 } 04630 } 04631 04632 return TRUE; 04633 } 04634 04635 // something was a bit squiffy 04636 return FALSE; 04637 }
|
|
Gets the first colour library group node in the colour gallery.
Definition at line 2811 of file sgcolour.cpp. 02812 { 02813 return GetNextLibGroup(NULL); 02814 }
|
|
Public access function to the colour gallery.
Definition at line 2464 of file sgcolour.cpp. 02465 { 02466 return m_pTheGallery; 02467 }
|
|
Gets the next colour library group node in the colour gallery.
Definition at line 2828 of file sgcolour.cpp. 02829 { 02830 SGDisplayNode *pGroup = NULL; 02831 // If we are passed a null pointer then somebody must want the first item in the list 02832 if (pLibGroup == NULL) 02833 { 02834 if (DisplayTree == NULL) 02835 return NULL; 02836 02837 // Find the first library groups in the gallery 02838 pGroup = DisplayTree->GetChild(); 02839 } 02840 else 02841 pGroup = pLibGroup->GetNext(); 02842 02843 while (pGroup != NULL) 02844 { 02845 if (pGroup->IsKindOf(CC_RUNTIME_CLASS(SGDisplayLibColGroup))) 02846 { 02847 return (SGDisplayLibColGroup*)pGroup; 02848 } 02849 02850 pGroup = pGroup->GetNext(); 02851 } 02852 02853 // none found 02854 return NULL; 02855 }
|
|
Checks a DragMessage to see if it is a colour drag. If it is, then it creates a drag target for this gallerys listbox.
Reimplemented from SuperGallery. Definition at line 3876 of file sgcolour.cpp. 03877 { 03878 // If it's a colour drag, add a target for our window. If not, let the base class 03879 // have a look at it (to see if it is a group being dragged) 03880 if (DragMsg->pInfo->IsKindOf(CC_RUNTIME_CLASS(ColourDragInformation))) 03881 { 03882 /*SGColourDragTarget *NewTarget =*/ new SGColourDragTarget(this, GetListGadgetID()); 03883 } 03884 else 03885 SuperGallery::HandleDragStart(DragMsg); 03886 }
|
|
ColourSGallery initialisation - declares preferences etc.
Reimplemented from SimpleCCObject. Definition at line 2431 of file sgcolour.cpp. 02432 { 02433 // Declare preferences 02434 GetApplication()->DeclareSection(TEXT("Displays"), 8); 02435 GetApplication()->DeclarePref(TEXT("Displays"), TEXT("AutoScrollColours"), &AutoScrollSelection); 02436 GetApplication()->DeclarePref(TEXT("Displays"), TEXT("ColourDisplayMode"), &DefaultDisplayMode); 02437 02438 GetApplication()->DeclareSection(TEXT("ColourLine"), 4); 02439 GetApplication()->DeclarePref(TEXT("ColourLine"), TEXT("ShowDocumentColours"), &ShowDocumentColours); 02440 02441 GetApplication()->DeclareSection(TEXT("Palettes"), 2); 02442 GetApplication()->DeclarePref(TEXT("Palettes"), TEXT("Path"), &PalettePath); 02443 02444 OpBackground::Init(); 02445 02446 return(TRUE); 02447 }
|
|
Initialises any menu commands that this gallery needs.
Reimplemented from SuperGallery. Definition at line 4192 of file sgcolour.cpp. 04193 { 04194 static BOOL MenusInitialised = FALSE; 04195 04196 BOOL ok = TRUE; 04197 04198 if (!MenusInitialised) 04199 { 04200 // Edits to the pop-up menu on the colour gallery 04201 04202 // Initialise menu command Ops 04203 04204 // "Standard" entries for options menu 04205 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Find, _R(IDS_SGMENU_FIND)); 04206 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Sort, _R(IDS_SGMENU_SORT)); 04207 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties, _R(IDS_SGMENU_PROPERTIES)); 04208 04209 // "Special" entries for over-list menu 04210 ok = ok && InitMenuCommand((StringBase *) &SGCmd_New, _R(IDS_SGMENU_NEW)); 04211 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Edit, _R(IDS_SGMENU_EDIT)); 04212 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Delete, _R(IDS_SGMENU_DELETE)); 04213 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Redefine, _R(IDS_SGMENU_REDEFINE)); 04214 ok = ok && InitMenuCommand((StringBase *) &SGCmd_Rename, _R(IDS_SGMENU_RENAME)); 04215 04216 // "Standard" commands for over-list menu 04217 ok = ok && InitMenuCommand((StringBase *) &SGCmd_FoldGroup, _R(IDS_SGMENU_FOLD)); 04218 ok = ok && InitMenuCommand((StringBase *) &SGCmd_UnfoldGroup, _R(IDS_SGMENU_UNFOLD)); 04219 04220 ok = ok && InitMenuCommand((StringBase *) &SGCmd_NextGroup, _R(IDS_SGMENU_NEXTGROUP)); 04221 ok = ok && InitMenuCommand((StringBase *) &SGCmd_PrevGroup, _R(IDS_SGMENU_PREVGROUP)); 04222 04223 // Extra new group item 04224 ok = ok && InitMenuCommand((StringBase *) &SGCmd_ShowInColourLine, _R(IDS_SGMENU_SHOWINCOLOURLINE)); 04225 ok = ok && InitMenuCommand((StringBase *) &SGCmd_SetBackground, _R(IDS_SGMENU_SETBACKGROUND)); 04226 04227 MenusInitialised = TRUE; 04228 } 04229 04230 return(ok); 04231 }
|
|
This will create the gallery groups (unless they're already there) and return TRUE if ok.
Definition at line 2787 of file sgcolour.cpp. 02788 { 02789 // We will use the DisplayTree presence or absence to dictate whether the groups are 02790 // there or not. If it is there just return TRUE as everything should be fabby. 02791 if (DisplayTree != NULL) 02792 return TRUE; 02793 02794 // If not then just call PreCreate to ensure that they are present. 02795 return PreCreate(); 02796 }
|
|
A standard message handler, really.
Reimplemented from SuperGallery. Definition at line 3654 of file sgcolour.cpp. 03655 { 03656 if (IS_OUR_DIALOG_MSG(Message)) 03657 { 03658 DialogMsg* Msg = (DialogMsg*)Message; 03659 03660 switch (Msg->DlgMsg) 03661 { 03662 case DIM_CREATE: 03663 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYCOLOURGALLERY), TRUE); 03664 SetSelectionFromDocument(TRUE); 03665 break; 03666 03667 case DIM_CANCEL: 03668 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYCOLOURGALLERY), FALSE); 03669 break; 03670 03671 case DIM_LFT_BN_CLICKED: 03672 if (DisplayTree == NULL || !IsVisible()) 03673 break; 03674 03675 if (FALSE) {} 03676 else if (Msg->GadgetID == _R(IDC_GALLERY_NAME)) 03677 { 03678 SGDisplayColour *FirstSelected = (SGDisplayColour *) 03679 DisplayTree->FindNextSelectedItem(NULL); 03680 if (FirstSelected != NULL) 03681 { 03682 IndexedColour *ColToEdit = FirstSelected->GetDisplayedColour()-> 03683 FindParentIndexedColour(); 03684 03685 SGDisplayGroup *DocumentGroup = (SGDisplayGroup *) FirstSelected->GetParent(); 03686 ERROR3IF(DocumentGroup == NULL, "SGallery DisplayTree linkage corruption detected"); 03687 03688 Document *ScopeDoc = DocumentGroup->GetParentDocument(); 03689 ERROR3IF(ScopeDoc == NULL, "SGallery group is not for a document! Unimplemented! Eek!"); 03690 03691 ColourList *ColList = ScopeDoc->GetIndexedColours(); 03692 ERROR3IF(ColList == NULL, "A document with no colour list? Now I've seen it all"); 03693 03694 if (ColToEdit != NULL) 03695 ColourNameDlg::InvokeDialog(ColList, ColToEdit); 03696 } 03697 } 03698 else if (Msg->GadgetID == _R(IDC_GALLERY_HELP)) 03699 { 03700 TRACEUSER( "Markn", _T("Hello. Do you want help on this gallery?\n")); 03701 HelpUserTopic(_R(IDS_HELPPATH_Gallery_Colour)); 03702 } 03703 else if (Msg->GadgetID == _R(IDC_COLGAL_BACKGROUND)) // Set a background layer with the selected colour 03704 { 03705 ApplySelectedAsBackground(); 03706 } 03707 break; 03708 03709 default: 03710 break; 03711 } 03712 03713 return(SuperGallery::Message(Message)); 03714 } 03715 03716 03717 // If we have no displaytree, then we have not been shown, or something terrible has 03718 // happened, so we don't bother handling any of these messages. 03719 if (DisplayTree == NULL || !IsVisible()) 03720 return(SuperGallery::Message(Message)); 03721 03722 03723 if (MESSAGE_IS_A(Message, DocChangingMsg)) 03724 { 03725 DocChangingMsg *TheMsg = (DocChangingMsg *) Message; 03726 03727 switch ( TheMsg->State ) 03728 { 03729 case DocChangingMsg::BORN: // New document - add to display tree 03730 { 03731 CreateNewSubtree(TheMsg->pChangingDoc); // Add a subtree for this doc 03732 ShadeGallery(FALSE); 03733 03734 InvalidateCachedFormat(); // And redraw what is necessary 03735 ReformatAndRedrawIfNecessary(); 03736 } 03737 break; // Pass this message on to the base class as well 03738 03739 // case DocChangingMsg::DocState::ABOUTTODIE: // Document dying - remove from tree 03740 // case DocChangingMsg::DocState::KILLED: 03741 // case DocChangingMsg::DocState::SELCHANGED: 03742 // 03743 // ==== NOTE ==== 03744 // The base sgallery class handles these messages to automatically remove 03745 // the subtree for the dying doc, and/or shade the gallery if no docs are left 03746 default: 03747 break; 03748 03749 } 03750 } 03751 else if (MESSAGE_IS_A(Message, ColourChangingMsg)) 03752 { 03753 ColourChangingMsg *TheMsg = (ColourChangingMsg *) Message; 03754 03755 switch (TheMsg->State) 03756 { 03757 case ColourChangingMsg::LISTUPDATED: 03758 // A document colour list has been changed. We must recreate its display subtree 03759 if (!ISentTheMessage && TheMsg->NewColourList != NULL) 03760 { 03761 // First, try to find the document which owns the changed list 03762 Document *ScopeDoc = (Document *)TheMsg->NewColourList->GetParentDocument(); 03763 03764 // Just check that the bi-directional link is sane! 03765 ERROR3IF(ScopeDoc == NULL || 03766 ScopeDoc->GetIndexedColours() != TheMsg->NewColourList, 03767 "A Document colour list is somehow screwed up!"); 03768 03769 // If we found it, recreate the display subtree for it 03770 if (ScopeDoc != NULL) 03771 { 03772 SGDisplayNode *Ptr = DisplayTree->FindSubtree(this, ScopeDoc, NULL); 03773 CreateNewSubtree(ScopeDoc, (SGDisplayColourGroup *) Ptr); 03774 03775 // And force a redraw of the entire list 03776 //ForceRedrawOfList(); 03777 InvalidateCachedFormat(); 03778 ReformatAndRedrawIfNecessary(); 03779 } 03780 } 03781 break; 03782 03783 03784 case ColourChangingMsg::COLOURUPDATED: 03785 case ColourChangingMsg::COLOURUPDATEDINVISIBLE: 03786 if (TheMsg->NewColourList != NULL) 03787 { 03788 Document *ScopeDoc = (Document *)TheMsg->NewColourList->GetParentDocument(); 03789 RedrawColourDisplay(ScopeDoc, TheMsg->ChangedColour); 03790 } 03791 break; 03792 03793 case ColourChangingMsg::SELVIEWCONTEXTCHANGE: 03794 // Colour separation/correction options for the selected view have 03795 // changed, so redraw the entire colour list using the new options. 03796 ForceRedrawOfList(); 03797 break; 03798 03799 default: 03800 break; 03801 } 03802 } 03803 // The new CommonAttrsChanged msg replaces this messages. It handles 03804 // a change in the Current Attribute group associated with a tool, and a change in the 03805 // value of a current attribute. 03806 /*else if (MESSAGE_IS_A(Message, SelChangingMsg)) 03807 { 03808 SelChangingMsg *Msg = (SelChangingMsg *) Message; 03809 switch ( Msg->State ) 03810 { 03811 case SelChangingMsg::COLOURATTCHANGED: 03812 case SelChangingMsg::SELECTIONCHANGED: 03813 case SelChangingMsg::NODECHANGED: 03814 if (!AmShaded) // If we're open & active, set listbox selection 03815 SetSelectionFromDocument(); 03816 break; 03817 } 03818 // Drop through so the Gallery base class gets to see this message too 03819 } 03820 */ 03821 else if (MESSAGE_IS_A(Message, CommonAttrsChangedMsg)) 03822 { 03823 if (!AmShaded) // If we're open & active, set listbox selection 03824 SetSelectionFromDocument(); 03825 03826 } 03827 else if (MESSAGE_IS_A(Message, DocViewMsg)) 03828 { 03829 DocViewMsg *Msg = (DocViewMsg *) Message; 03830 03831 if (Msg->State == DocViewMsg::SELCHANGED) 03832 { 03833 // Selected DocView is changing - redraw to use the new DocView's colour context 03834 BOOL DoRedraw = TRUE; 03835 if (Msg->pOldDocView != NULL && Msg->pNewDocView != NULL) 03836 { 03837 // If we know the old & new views, then see if they have the same colour 03838 // context attached - if they do, there's no need to redraw. This eliminates 03839 // flicker when swapping normal views (the most common view-swap action) 03840 // We only check the RGB context because we assume the screen is always RGB 03841 ColourContext *OldCC = Msg->pOldDocView->GetColourContext(COLOURMODEL_RGBT, TRUE); 03842 ColourContext *NewCC = Msg->pNewDocView->GetColourContext(COLOURMODEL_RGBT, TRUE); 03843 03844 if (OldCC == NewCC) 03845 DoRedraw = FALSE; 03846 } 03847 03848 if (DoRedraw) 03849 ForceRedrawOfList(); 03850 } 03851 } 03852 03853 return(SuperGallery::Message(Message)); 03854 }
|
|
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.
Definition at line 2910 of file sgcolour.cpp. 02911 { 02912 ERROR3IF(DocumentGroup == NULL, "Illegal NULL param"); 02913 02914 SGDisplayColour *Item = (SGDisplayColour *) DocumentGroup->FindNextSelectedItem(NULL); 02915 IndexedColour *RefColour; 02916 INT32 ItemsInUse = 0; 02917 INT32 TotalItems = 0; 02918 INT32 DeletableItems = 0; 02919 02920 Document *ParentDoc = DocumentGroup->GetParentDocument(); 02921 if (ParentDoc == NULL) 02922 return(FALSE); 02923 02924 ColourList *ParentColList = ParentDoc->GetIndexedColours(); 02925 if (ParentColList == NULL) 02926 return(FALSE); 02927 02928 // Determine how many items are selected, and how many of these are in use 02929 while (Item != NULL) 02930 { 02931 if (!Item->IsALibraryColour()) 02932 { 02933 DeletableItems++; // Increment number of deletable (non-library) items 02934 02935 // Check if the colour is in use. NOTE that because it is used in this gallery 02936 // display item, it's usage count will be 1 greater than the 'real' usage 02937 // (i.e. when we delete it, the usage count will be decremented once, so 02938 // it is considered not-in-use if the usagcount is <= 1) 02939 RefColour = Item->GetDisplayedColour()->FindParentIndexedColour(); 02940 if (RefColour != NULL && ParentColList->IsColourInUseInDoc(RefColour, TRUE)) 02941 ItemsInUse++; 02942 } 02943 02944 TotalItems++; // Increment number of found items 02945 02946 Item = (SGDisplayColour *) DocumentGroup->FindNextSelectedItem(Item); 02947 } 02948 02949 if (DeletableItems == 0) 02950 return(FALSE); 02951 02952 // If some are in use, determine if the user really wants to delete them 02953 INT32 ButtonPressed = 2; 02954 if (ItemsInUse != 0) 02955 { 02956 ButtonPressed = AskQuestion(_R(IDS_COLGAL_COLINUSE), 02957 _R(IDS_COLGAL_KILL), _R(IDS_COLGAL_NOKILL), _R(IDS_CANCEL), 0, 02958 2, 3); // NOKILL=default, CANCEL=cancel 02959 02960 if (ButtonPressed == 3) // Delete was cancelled - return FALSE 02961 return(FALSE); 02962 } 02963 02964 if (ButtonPressed == 1) // Force-delete all items, so go ahead and delete 02965 return(TRUE); 02966 02967 if (ButtonPressed == 2 && DeletableItems - ItemsInUse <= 0) 02968 return(FALSE); // No items left to delete (all in use) so abort 02969 02970 // Remove all in-use items from the selection so we only delete 'free' colours 02971 Item = (SGDisplayColour *) DocumentGroup->FindNextSelectedItem(NULL); 02972 02973 while (Item != NULL) 02974 { 02975 RefColour = Item->GetDisplayedColour()->FindParentIndexedColour(); 02976 if (RefColour != NULL && ParentColList->IsColourInUseInDoc(RefColour, TRUE)) 02977 Item->SetSelected(FALSE); 02978 02979 Item = (SGDisplayColour *) DocumentGroup->FindNextSelectedItem(Item); 02980 } 02981 02982 return(TRUE); 02983 }
|
|
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.
Reimplemented from SuperGallery. Definition at line 2676 of file sgcolour.cpp. 02677 { 02678 // If there isn't already one, create a DisplayTree 02679 if (DisplayTree == NULL) 02680 { 02681 DisplayTree = new SGDisplayRootScroll(this); // New root node, with a scrollbar 02682 if (DisplayTree == NULL) 02683 return(FALSE); 02684 } 02685 02686 // We're opening the window, so we fold all groups except that for the Selected document 02687 SGDisplayGroup *Group = (SGDisplayGroup *) DisplayTree->GetChild(); 02688 while (Group != NULL) 02689 { 02690 // Set the group's folded state, but don't bother trying to redraw, because we know 02691 // that the window is not currently visible, and that we are doing this to multiple groups. 02692 Document *pDoc = Group->GetParentDocument(); 02693 02694 if (pDoc != NULL) // Leave library groups alone 02695 Group->SetFoldedState((pDoc != Document::GetSelected()), FALSE); 02696 02697 Group = (SGDisplayGroup *) Group->GetNext(); 02698 } 02699 02700 // And for each document already present, (re)create a display subtree (possibly replacing 02701 // a previous displaytree for it if we had one earlier) 02702 Document *ParentDoc = (Document *) GetApplication()->Documents.GetTail(); 02703 while (ParentDoc != NULL) 02704 { 02705 SGDisplayColourGroup *ParentGroup = (SGDisplayColourGroup *)DisplayTree->FindSubtree(this, ParentDoc, NULL); 02706 02707 CreateNewSubtree(ParentDoc, ParentGroup); 02708 ParentDoc = (Document *) GetApplication()->Documents.GetPrev(ParentDoc); 02709 } 02710 02711 // Only add the library groups if they're not already in the gallery 02712 SGDisplayNode *Ptr = DisplayTree->GetChild(); 02713 while (Ptr != NULL) 02714 { 02715 if (Ptr->IsKindOf(CC_RUNTIME_CLASS(SGDisplayLibColGroup))) 02716 break; 02717 02718 Ptr = Ptr->GetNext(); 02719 } 02720 02721 PORTNOTE("other", "Colour gallery needs to use the resource system for finding palettes when no path is specified"); 02722 #ifndef EXCLUDE_FROM_XARALX 02723 if (Ptr == NULL) 02724 { 02725 SGDisplayLibColGroup *Bob; 02726 02727 String_256 SearchPath; 02728 // If the user has set a pathname in the preference then use this, otherwise 02729 // use a Palettes directory which is sitting alongside the exe. 02730 if (PalettePath.IsEmpty()) 02731 { 02732 // Find the directory path of the .exe file 02733 CResDll::GetExecutablePath((TCHAR *) SearchPath); 02734 02735 SearchPath += TEXT("\\Palettes\\"); // This is a fixed (non-internationalised) string 02736 } 02737 else 02738 { 02739 SearchPath = PalettePath; 02740 // Add a trailing slash if it hasn't got one 02741 SGLibOil::AppendSlashIfNotPresent(&SearchPath); 02742 } 02743 02744 // Make up the search string to use so that we see all files. 02745 String_256 SearchSpec(SearchPath); 02746 SearchSpec += TEXT("*.*"); // This is a fixed (non-internationalised) string 02747 02748 if (FileUtil::StartFindingFiles(&SearchSpec)) 02749 { 02750 String_256 LeafName; 02751 02752 while (FileUtil::FindNextFile(&LeafName)) 02753 { 02754 String_256 FullPath = SearchPath; 02755 //FullPath += TEXT("\\Palettes\\"); 02756 FullPath += LeafName; 02757 02758 PathName Name(FullPath); 02759 Bob = new SGDisplayLibColGroup(this, &Name); 02760 if (Bob != NULL) 02761 DisplayTree->AddItem(Bob); 02762 } 02763 FileUtil::StopFindingFiles(); 02764 } 02765 } 02766 #endif 02767 02768 // Ensure we know we have to reformat before the next redraw 02769 InvalidateCachedFormat(); 02770 02771 return(TRUE); 02772 }
|
|
Redraws the display item for one specific colour, and all of its linked descendants (liked/tint colours) (if any) in a given document.
Definition at line 3483 of file sgcolour.cpp. 03484 { 03485 if (TheDocument == NULL || TheColour == NULL) 03486 return; 03487 03488 SGDisplayGroup *Group = DisplayTree->FindSubtree(this, TheDocument, NULL); 03489 03490 if (Group == NULL) // Can't find a group for this document 03491 return; 03492 03493 // Now search the tree for the specific items to redraw 03494 SGDisplayColour *Item = (SGDisplayColour *) Group->GetChild(); 03495 03496 // WEBSTER - markn 28/1/97 03497 // This can be NULL in webster when you edit a non-editable colour (e.g. by double-clicking 03498 // on a colour in the web palette folder) 03499 // In Camelot it expects a colour to be added to the folder containing the doc's colours, 03500 // but for Webster that is not the case. It is now (mab) Martin 15/07/97 03501 if (Item != NULL) 03502 { 03503 ERROR3IF(Item->GetChild() != NULL, "My leaf-item isn't a leaf-item! Help!"); 03504 03505 IndexedColour *RealColour; 03506 03507 while (Item != NULL) 03508 { 03509 RealColour = Item->GetDisplayedColour()->FindParentIndexedColour(); 03510 if (RealColour != NULL && RealColour->IsADescendantOf(TheColour)) 03511 Item->ForceRedrawOfMyself(); // Found it, or a descendant - redraw 03512 03513 Item = (SGDisplayColour *) Item->GetNext(); 03514 } 03515 } 03516 }
|
|
To inform the gallery that the selection has changed in some way.
Reimplemented from SuperGallery. Definition at line 4654 of file sgcolour.cpp. 04655 { 04656 if (DisplayTree == NULL || AmShaded || !IsVisible()) 04657 return; 04658 04659 INT32 Count = DisplayTree->GetSelectedItemCount(); 04660 04661 // Determine if the entire selection consists only of library colours... 04662 BOOL AllSelectionIsLibrary = TRUE; 04663 SGDisplayColour *Col = (SGDisplayColour *) DisplayTree->FindNextSelectedItem(NULL); 04664 if (Col == NULL) 04665 AllSelectionIsLibrary = FALSE; 04666 04667 while (Col != NULL) 04668 { 04669 if (!Col->IsALibraryColour()) 04670 AllSelectionIsLibrary = FALSE; 04671 04672 Col = (SGDisplayColour *) DisplayTree->FindNextSelectedItem(Col); 04673 } 04674 04675 EnableGadget(_R(IDC_GALLERY_APPLY), (Count == 1)); // Apply needs exactly 1 item 04676 04677 // Redefine, Edit, Name, all need exactly one item, and it cannot be a library item 04678 EnableGadget(_R(IDC_GALLERY_REDEFINE), (Count == 1 && !AllSelectionIsLibrary)); 04679 EnableGadget(_R(IDC_GALLERY_EDIT), (Count == 1 && !AllSelectionIsLibrary)); 04680 EnableGadget(_R(IDC_GALLERY_NAME), (Count == 1 && !AllSelectionIsLibrary)); 04681 04682 EnableGadget(_R(IDC_GALLERY_NEW), (Count <= 1)); // New needs 0 or 1 items 04683 04684 // Delete needs 1 or more items, and some of them must be document colours 04685 EnableGadget(_R(IDC_GALLERY_DELETE), (Count > 0 && !AllSelectionIsLibrary)); 04686 04687 EnableGadget(_R(IDC_GALLERY_UNDO), TRUE); // Undo/menu always available 04688 EnableGadget(_R(IDC_GALLERY_MENU), TRUE); 04689 04690 Document *pDoc = Document::GetSelected(); 04691 EnableGadget(_R(IDC_COLGAL_BACKGROUND), Count == 1 && pDoc != NULL); 04692 }
|
|
Definition at line 535 of file sgcolour.h. 00535 { CurrentImportGroup = TheGroup; };
|
|
Sets the colour gallery listbox selection state based upon the currently selected object(s) in the document (to show the current fill/stroke colours).
Definition at line 3538 of file sgcolour.cpp. 03539 { 03540 if (DisplayTree == NULL || !IsVisible()) 03541 return; 03542 03543 DocColour *SelColour[2]; 03544 BOOL AreCurrentAttrs = 03545 ColourManager::GetCurrentLineAndFillColours(&SelColour[0], &SelColour[1]); 03546 03547 SGDisplayGroup *DocGroup = NULL; 03548 if (Document::GetSelected() != NULL) 03549 DocGroup = DisplayTree->FindSubtree(this, Document::GetSelected(), NULL); 03550 SelectItems(FALSE); // Clear the current selection 03551 03552 DocRect ScrollToRect; 03553 BOOL HaveSelected = FALSE; 03554 BOOL ScrollToBottom = FALSE; // TRUE if it is more important that the bottom of 03555 // ScrollToRect, rather than the top, is visible 03556 03557 if (DocGroup != NULL) 03558 ForceGroupFolded(DocGroup, FALSE); // Ensure group is unfolded 03559 03560 ReformatNow(TRUE); // Ensure the tree format information is up to date 03561 03562 if (!AreCurrentAttrs && DocGroup != NULL) 03563 { 03564 // The line/fill colours returned are those of the selection, not the current attrs 03565 IndexedColour *Parent; 03566 03567 for (INT32 i = 0; i < 2; i++) // For each colour (line, fill) 03568 { 03569 if (SelColour[i] != NULL) // If there is a single selected colour 03570 { 03571 Parent = SelColour[i]->FindParentIndexedColour(); // Find the named IxColour 03572 if (Parent != NULL && Parent->IsNamed()) // (if any) 03573 { 03574 // See if we can find a display item for this colour, and select it 03575 SGDisplayColour *Ptr = (SGDisplayColour *)DocGroup->GetChild(); 03576 while (Ptr != NULL) 03577 { 03578 if (Ptr->GetDisplayedColour()->FindParentIndexedColour() == Parent) 03579 { 03580 // determine the rectangle to try to show on screen (the 03581 // union of both the selected items) 03582 if (!HaveSelected) 03583 Ptr->GetFormatRect(&ScrollToRect); 03584 else 03585 { 03586 DocRect TempRect; 03587 Ptr->GetFormatRect(&TempRect); 03588 03589 // We must be adding the fill colour. If this is below the 03590 // line colour, then we'd prefer to scroll to show the 03591 // bottom of the rectangle, as it is more important that 03592 // the fill rather than line is visible if won't both fit. 03593 ScrollToBottom = (TempRect.hi.y <= ScrollToRect.lo.y); 03594 03595 ScrollToRect = ScrollToRect.Union(TempRect); 03596 } 03597 03598 // And select the item, and update the selection-anchor 03599 Ptr->SetSelected(TRUE); 03600 SetLastSelectedNode(Ptr); 03601 03602 HaveSelected = TRUE; 03603 break; 03604 } 03605 03606 Ptr = (SGDisplayColour *) Ptr->GetNext(); 03607 } 03608 } 03609 } 03610 } 03611 } 03612 03613 if (AutoScrollSelection || AlwaysScroll) 03614 { 03615 if (AlwaysScroll && !HaveSelected && DocGroup != NULL) 03616 { 03617 // We didn't select anything in the gallery. In that case, scroll to the top 03618 // of the document display 03619 DocRect TempRect; 03620 DocGroup->GetFormatRect(&TempRect); 03621 DocGroup->GetChildArea(&ScrollToRect); 03622 ScrollToRect = ScrollToRect.Union(TempRect); 03623 HaveSelected = TRUE; 03624 ScrollToBottom = FALSE; 03625 } 03626 03627 if (HaveSelected) 03628 ScrollToShow(&ScrollToRect, ScrollToBottom); 03629 } 03630 // scroll to make seln visible on screen 03631 03632 SelectionHasChanged(); // Update for the new selection 03633 }
|
|
Definition at line 468 of file sgcolour.h. |
|
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. Preference: AutoScrollColGal Section: Displays Range: TRUE or FALSE This is because it can be annoying that the gallery keeps scrolling away from a colour which you were about to apply to the selection (though you'd be better off dragging the colour, rather than selecting different objects in this case) Notes: Normal preference, available from the options dialogue.
Definition at line 573 of file sgcolour.h. |
|
Definition at line 568 of file sgcolour.h. |
|
Definition at line 587 of file sgcolour.h. |
|
Definition at line 569 of file sgcolour.h. |
|
Memory of the current colour gallery display mode, saved between sessions for convenience. Not shown in the options dialogue. Preference: ColourDisplayMode Section: Displays Range: 0..2
Definition at line 577 of file sgcolour.h. |
|
Definition at line 566 of file sgcolour.h. |
|
Definition at line 601 of file sgcolour.h. |
|
The path to load the palettes from. Defaults to blank which means alongside the exe. Preference: Path Section: Palette Range: 0 .. 256 characters
Definition at line 579 of file sgcolour.h. |
|
Memory of the current state of showing document colours in the colour line. Preference: ShowDocumentColours Section: ColourLine Range: TRUE, FALSE (0,1)
Definition at line 581 of file sgcolour.h. |
|
Memory of the current state of showing Netscape colours in the colour line. Webster needs to default to True. Preference: ShowNetscapeColours Section: ColourLine Range: TRUE, FALSE (0,1)
Definition at line 583 of file sgcolour.h. |