00001 // $Id: prpsgds.cpp 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 // Implementation of the Guides properties tab of the layer properties dialog box 00100 00101 /* 00102 00103 */ 00104 00105 #include "camtypes.h" 00106 00107 // WEBSTER - markn 15/1/97 00108 // Don't need this tab in Webster 00109 #ifndef WEBSTER 00110 00111 #include "layer.h" 00112 #include "layerprp.h" 00113 //#include "lyrprop.h" // dialog/gadget ids 00114 //#include "nev.h" // error messages 00115 #include "prpsgds.h" 00116 #include "guides.h" 00117 #include "coldrop.h" 00118 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00119 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00120 //#include "markn.h" 00121 #include "sglayer.h" 00122 #include "colourix.h" 00123 //#include "jason.h" 00124 #include "layermsg.h" 00125 00126 CC_IMPLEMENT_DYNAMIC(GuidesPropertiesTab, LayerPropertyTabs) 00127 CC_IMPLEMENT_DYNCREATE(LayerColourAction, Action) 00128 CC_IMPLEMENT_MEMDUMP(OpChangeLayerColourParam, OpParam) 00129 CC_IMPLEMENT_DYNCREATE(OpChangeLayerColour, UndoableOperation) 00130 00131 // This is not compulsory, but you may as well put it in so that the correct version 00132 // of your file can be registered in the .exe 00133 DECLARE_SOURCE("$Revision: 1282 $"); 00134 00135 #define new CAM_DEBUG_NEW 00136 00137 /******************************************************************************************** 00138 00139 > GuidesPropertiesTab::GuidesPropertiesTab() 00140 00141 00142 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00143 Created: 28/09/95 00144 Inputs: - 00145 Outputs: - 00146 Returns: - 00147 Purpose: GuidesPropertiesTab constructor. Creates a non-undoable operation 00148 Errors: - 00149 SeeAlso: LayerPropertyTabsDlg; LayerPropertyTabs; 00150 00151 ********************************************************************************************/ 00152 00153 GuidesPropertiesTab::GuidesPropertiesTab() 00154 { 00155 GuideType = GUIDELINE_HORZ; 00156 pColourDropDown = NULL; 00157 } 00158 00159 /******************************************************************************************** 00160 00161 > GuidesPropertiesTab::~GuidesPropertiesTab() 00162 00163 00164 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00165 Created: 28/09/95 00166 Inputs: - 00167 Outputs: - 00168 Returns: - 00169 Purpose: GuidesPropertiesTab destructor 00170 Errors: - 00171 SeeAlso: LayerPropertyTabsDlg; LayerPropertyTabs; 00172 00173 ********************************************************************************************/ 00174 00175 GuidesPropertiesTab::~GuidesPropertiesTab() 00176 { 00177 if (pColourDropDown != NULL) 00178 delete pColourDropDown; 00179 00180 GuidelineList.DeleteAll(); 00181 } 00182 00183 /******************************************************************************************** 00184 00185 > BOOL GuidesPropertiesTab::Init() 00186 00187 00188 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00189 Created: 28/09/95 00190 Inputs: - 00191 Outputs: - 00192 Returns: True if initialised ok, False if failed. 00193 Purpose: GuidesPropertiesTab initialisation routine 00194 Errors: - 00195 SeeAlso: LayerPropertyTabsDlg::Init; LayerPropertyTabs::Init; 00196 00197 ********************************************************************************************/ 00198 00199 BOOL GuidesPropertiesTab::Init() 00200 { 00201 return TRUE; 00202 } 00203 00204 /****************************************************************************************** 00205 00206 > CDlgResID GuidesPropertiesTab::GetPageID()() 00207 00208 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00209 Created: 28/09/95 00210 Inputs: - 00211 Outputs: - 00212 Returns: The dialog ID of this tab section. 00213 Purpose: Allows the options dialog code to determine the dialog ID of this section. 00214 Errors: - 00215 SeeAlso: - 00216 00217 ******************************************************************************************/ 00218 00219 CDlgResID GuidesPropertiesTab::GetPageID() 00220 { 00221 return _R(IDD_TAB_GUIDELINE_PROPERTIES); 00222 } 00223 00224 /****************************************************************************************** 00225 00226 > BOOL GuidesPropertiesTab::IsPropertyRequired() 00227 00228 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00229 Created: 28/09/95 00230 Returns: Returns True if this tab is a program option. 00231 Purpose: Allows the layer propertiesto determine if this tab is required. 00232 00233 ******************************************************************************************/ 00234 00235 BOOL GuidesPropertiesTab::IsPropertyRequired() 00236 { 00237 return TRUE; 00238 } 00239 00240 00241 /****************************************************************************************** 00242 00243 > BOOL GuidesPropertiesTab::CommitSection() 00244 00245 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00246 Created: 28/09/95 00247 Inputs: - 00248 Outputs: - 00249 Returns: True if values in dialog box ok, False otherwise. 00250 Purpose: Takes the values in this tab of the layer properties dialog box. 00251 Called when ok or apply now is pressed on the main dialog box. 00252 Errors: - 00253 SeeAlso: GuidesPropertiesTab::InitSection() 00254 00255 ******************************************************************************************/ 00256 00257 BOOL GuidesPropertiesTab::CommitSection() 00258 { 00259 TRACEUSER( "Neville", _T("GuidesPropertiesTab::CommitSection\n")); 00260 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::CommitSection called with no dialog pointer"); 00261 00262 BOOL ok = pPropertiesDlg->TalkToPage(GetPageID()); 00263 if (!ok) 00264 return TRUE; // Talk to page failed to return now 00265 00266 00267 return TRUE; 00268 } 00269 00270 /******************************************************************************************** 00271 00272 > BOOL GuidesPropertiesTab::GreySection() 00273 00274 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00275 Created: 28/09/95 00276 Inputs: - 00277 Outputs: - 00278 Returns: - 00279 Purpose: Called when the user has closed all documents 00280 Errors: - 00281 SeeAlso: GuidesPropertiesTab::UngreySection; 00282 00283 ********************************************************************************************/ 00284 00285 BOOL GuidesPropertiesTab::GreySection() 00286 { 00287 TRACEUSER( "Neville", _T("GreySection in GuidesPropertiesTab section\n")); 00288 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::GreySection called with no dialog pointer"); 00289 00290 BOOL ok = pPropertiesDlg->TalkToPage(GetPageID()); 00291 if (!ok) 00292 return TRUE; // Talk to page failed to return now 00293 00294 // Only update if we are not already grey 00295 if (GreyStatus == TRUE) 00296 return TRUE; 00297 00298 // Call our central greying/ungreying function 00299 ok = ChangeControlStatus(FALSE); 00300 00301 GreyStatus = TRUE; 00302 00303 return ok; 00304 } 00305 00306 /******************************************************************************************** 00307 00308 > BOOL GuidesPropertiesTab::UngreySection() 00309 00310 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00311 Created: 28/09/95 00312 Inputs: - 00313 Outputs: - 00314 Returns: - 00315 Purpose: Called when the user has selected a new document 00316 Errors: - 00317 SeeAlso: GuidesPropertiesTab::UngreySection; 00318 00319 ********************************************************************************************/ 00320 00321 BOOL GuidesPropertiesTab::UngreySection() 00322 { 00323 TRACEUSER( "Neville", _T("UngreySection in GuidesPropertiesTab section\n")); 00324 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::UngreySection called with no dialog pointer"); 00325 00326 BOOL ok = pPropertiesDlg->TalkToPage(GetPageID()); // The GuidesPropertiesTab identifier 00327 if (!ok) 00328 return TRUE; // Talk to page failed to return now 00329 00330 // Only update if we are not already ungrey 00331 if (GreyStatus == FALSE) 00332 return TRUE; 00333 00334 // Call our central greying/ungreying function 00335 ok = ChangeControlStatus(TRUE); 00336 00337 GreyStatus = FALSE; 00338 00339 return ok; 00340 } 00341 00342 /******************************************************************************************** 00343 00344 > BOOL GuidesPropertiesTab::ChangeControlStatus(const BOOL Status) 00345 00346 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00347 Created: 28/09/95 00348 Inputs: - 00349 Outputs: - 00350 Returns: - 00351 Purpose: Called to grey/ungrey all controls on this tab. 00352 Errors: - 00353 SeeAlso: GuidesPropertiesTab::GreySection; GuidesPropertiesTab::UngreySection; 00354 00355 ********************************************************************************************/ 00356 00357 BOOL GuidesPropertiesTab::ChangeControlStatus(const BOOL Status) 00358 { 00359 BOOL Enable; 00360 00361 Layer* pLayer = GetGuideLayer(); 00362 Enable = (pLayer != NULL) && Status; 00363 00364 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_GUIDELINELIST),Enable); 00365 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_HORZ), Enable); 00366 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_VERT), Enable); 00367 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_COLOURLIST), Enable); 00368 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_COLOURTEXT), Enable); 00369 00370 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_NEW), Status); // Always available 00371 00372 INT32 SelCount = pPropertiesDlg->GetSelectedCount(_R(IDC_GUIDETAB_GUIDELINELIST)); 00373 00374 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_DELETE), Enable && (SelCount >= 1)); 00375 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_PROPERTIES), Enable && (SelCount == 1)); 00376 00377 if (!Enable) 00378 pPropertiesDlg->DeleteAllValues(_R(IDC_GUIDETAB_GUIDELINELIST)); 00379 00380 return TRUE; 00381 } 00382 00383 /******************************************************************************************** 00384 00385 > BOOL GuidesPropertiesTab::UpdateSection() 00386 00387 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00388 Created: 28/09/95 00389 Returns: - 00390 Purpose: Called when we have switched to a new document and need to update all the 00391 controls on this tab. Should only init the tab if the page is present. 00392 The document name allows the info field on the tab to be filled in correctly. 00393 Errors: - 00394 SeeAlso: GuidesPropertiesTab::GreySection; GuidesPropertiesTab::UngreySection; GuidesPropertiesTab::InitSection; 00395 00396 ********************************************************************************************/ 00397 00398 BOOL GuidesPropertiesTab::UpdateSection() 00399 { 00400 TRACEUSER( "Neville", _T("GuidesPropertiesTab::UpdateSection\n")); 00401 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::UpdateSection called with no dialog pointer"); 00402 00403 BOOL ok = pPropertiesDlg->TalkToPage(GetPageID()); 00404 if (!ok) 00405 return TRUE; // page not present 00406 00407 00408 // Update our controls here 00409 00410 // We are happy with what happened 00411 return TRUE; 00412 } 00413 00414 /******************************************************************************************** 00415 00416 > BOOL GuidesPropertiesTab::BuildGuidelineList(Layer* pLayer) 00417 00418 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00419 Created: 5/10/95 00420 Inputs: pLayer = ptr layer that contains guidelines 00421 Outputs: - 00422 Returns: - 00423 Purpose: Builds a list of the guidelines in the given layer 00424 Uses member var GuidelineList 00425 Errors: - 00426 SeeAlso: 00427 00428 ********************************************************************************************/ 00429 00430 BOOL GuidesPropertiesTab::BuildGuidelineList(Layer* pLayer) 00431 { 00432 GuidelineList.DeleteAll(); 00433 pPropertiesDlg->DeleteAllValues(_R(IDC_GUIDETAB_GUIDELINELIST)); 00434 00435 ERROR2IF(pLayer == NULL, FALSE,"pLayer is NULL"); 00436 00437 Node* pNode = pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGuideline)); 00438 while (pNode != NULL) 00439 { 00440 NodeGuideline* pGuideline = (NodeGuideline*) pNode; 00441 if (pGuideline->GetType() == GuideType) 00442 { 00443 GuidelineListItem* pItem = (GuidelineListItem*)GuidelineList.GetHead(); 00444 while (pItem != NULL && (pItem->pGuideline->GetOrdinate() < pGuideline->GetOrdinate())) 00445 pItem = (GuidelineListItem*)GuidelineList.GetNext(pItem); 00446 00447 GuidelineListItem* pNewItem = new GuidelineListItem(pGuideline); 00448 00449 if (pNewItem != NULL) 00450 { 00451 if (pItem == NULL) 00452 GuidelineList.AddTail(pNewItem); 00453 else 00454 GuidelineList.InsertBefore(pItem,pNewItem); 00455 } 00456 } 00457 00458 pNode = pNode->FindNext(CC_RUNTIME_CLASS(NodeGuideline)); 00459 } 00460 00461 return TRUE; 00462 } 00463 00464 /******************************************************************************************** 00465 00466 > BOOL GuidesPropertiesTab::ShowGuidelines(Layer* pLayer) 00467 00468 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00469 Created: 3/10/95 00470 Inputs: pLayer = ptr layer that contains guidelines 00471 Outputs: - 00472 Returns: - 00473 Purpose: Shows the guidelines in the guideline list 00474 Errors: - 00475 SeeAlso: 00476 00477 ********************************************************************************************/ 00478 00479 BOOL GuidesPropertiesTab::ShowGuidelines(Layer* pLayer) 00480 { 00481 ERROR2IF(pLayer == NULL, FALSE,"pLayer is NULL"); 00482 00483 BuildGuidelineList(pLayer); 00484 00485 GuidelineListItem* pItem = (GuidelineListItem*)GuidelineList.GetHead(); 00486 while (pItem != NULL) 00487 { 00488 NodeGuideline* pGuideline = pItem->pGuideline; 00489 00490 MILLIPOINT Ordinate = NodeGuideline::ToUserOrdinate(pGuideline->FindParentSpread(),pGuideline->GetOrdinate(),GuideType); 00491 pPropertiesDlg->SetDimensionGadgetValue(_R(IDC_GUIDETAB_GUIDELINELIST),Ordinate,pGuideline); 00492 00493 pItem = (GuidelineListItem*)GuidelineList.GetNext(pItem); 00494 } 00495 00496 return TRUE; 00497 } 00498 00499 /******************************************************************************************** 00500 00501 > BOOL GuidesPropertiesTab::ShowColours() 00502 00503 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00504 Created: 4/10/95 00505 Inputs: - 00506 Outputs: - 00507 Returns: - 00508 Purpose: Shows the colours of the doc in the colour list 00509 Errors: - 00510 SeeAlso: GuidesPropertiesTab 00511 00512 ********************************************************************************************/ 00513 00514 BOOL GuidesPropertiesTab::ShowColours() 00515 { 00516 if (pColourDropDown != NULL) 00517 { 00518 IndexedColour* pIndexedColour = NULL; 00519 Layer* pLayer = GetGuideLayer(); 00520 if (pLayer != NULL) 00521 { 00522 DocColour* pDocColour = pLayer->GetGuideColour(); 00523 if (pDocColour != NULL) 00524 { 00525 pIndexedColour = pDocColour->FindParentIndexedColour(); 00526 if (pIndexedColour->IsDeleted()) 00527 { 00528 pLayer->SetGuideColour(NULL); 00529 pIndexedColour = NULL; 00530 } 00531 } 00532 } 00533 00534 pColourDropDown->ClearAllSpecialEntries(); 00535 00536 if (pIndexedColour != NULL) 00537 { 00538 if (!pIndexedColour->IsNamed()) 00539 { 00540 String_256 LocalColourText(_R(IDS_LOCALCOLOUR)); 00541 DocColour LocalColour; 00542 LocalColour.MakeRefToIndexedColour(pIndexedColour); 00543 00544 pColourDropDown->AddSpecialEntry(&LocalColourText,&LocalColour); 00545 } 00546 00547 pColourDropDown->FillInColourList(pIndexedColour); 00548 } 00549 else 00550 pColourDropDown->FillInColourList(NULL,0); 00551 } 00552 return TRUE; 00553 } 00554 00555 /******************************************************************************************** 00556 00557 > BOOL GuidesPropertiesTab::ShowDetails() 00558 00559 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00560 Created: 3/10/95 00561 Inputs: - 00562 Outputs: - 00563 Returns: - 00564 Purpose: Shows the details of the associated layer in this tab 00565 Errors: - 00566 SeeAlso: GuidesPropertiesTab 00567 00568 ********************************************************************************************/ 00569 00570 BOOL GuidesPropertiesTab::ShowDetails() 00571 { 00572 Layer* pLayer = GetGuideLayer(); 00573 if (pLayer != NULL) 00574 { 00575 ShowGuidelines(pLayer); 00576 ShowColours(); 00577 00578 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_GUIDETAB_HORZ),GuideType == GUIDELINE_HORZ); 00579 pPropertiesDlg->SetBoolGadgetSelected(_R(IDC_GUIDETAB_VERT),GuideType == GUIDELINE_VERT); 00580 } 00581 00582 ChangeControlStatus(!GreyStatus); 00583 00584 return TRUE; 00585 } 00586 00587 /******************************************************************************************** 00588 00589 > BOOL GuidesPropertiesTab::UpdateLayerSection() 00590 00591 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00592 Created: 4/10/95 00593 Inputs: - 00594 Outputs: - 00595 Returns: TRUE if ok, FALSE otherwise 00596 Purpose: Called when the layer-related section of the tab should be updated. 00597 Errors: - 00598 SeeAlso: LayerPropertyTabsDlg; LayerPropertyTabs; 00599 00600 ********************************************************************************************/ 00601 00602 BOOL GuidesPropertiesTab::UpdateLayerSection() 00603 { 00604 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::UpdateLayerSection() called with no dialog pointer"); 00605 return (pPropertiesDlg->TalkToPage(GetPageID()) && ShowDetails()); 00606 } 00607 00608 /******************************************************************************************** 00609 00610 > BOOL GuidesPropertiesTab::UpdateGuidelineSection() 00611 00612 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00613 Created: 4/10/95 00614 Inputs: - 00615 Outputs: - 00616 Returns: TRUE if ok, FALSE otherwise 00617 Purpose: Called when the guideline-related section of the tab should be updated. 00618 Errors: - 00619 SeeAlso: LayerPropertyTabsDlg; LayerPropertyTabs; 00620 00621 ********************************************************************************************/ 00622 00623 BOOL GuidesPropertiesTab::UpdateGuidelineSection() 00624 { 00625 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::UpdateGuidelineSection() called with no dialog pointer"); 00626 return (pPropertiesDlg->TalkToPage(GetPageID()) && ShowDetails()); 00627 } 00628 00629 /****************************************************************************************** 00630 00631 > virtual BOOL GuidesPropertiesTab::ColourListChanged(Document* pDoc) 00632 00633 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00634 Created: 9/10/95 00635 inputs: pDoc = ptr to document that contains the changed list, or NULL if there's no longer a list 00636 Returns: TRUE if successful, else FALSE 00637 Purpose: Called when the colour list changes in some way. 00638 pDoc points to the doc that contains the list that's changed. 00639 If pDoc is NULL, then there is no longer a colour list (e.g. all docs closed) 00640 Errors: - 00641 SeeAlso: - 00642 00643 ******************************************************************************************/ 00644 00645 BOOL GuidesPropertiesTab::ColourListChanged(Document* pDoc) 00646 { 00647 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::UpdateGuidelineSection() called with no dialog pointer"); 00648 ERROR2IF(pColourDropDown == NULL,FALSE,"ptr to 'colour drop down' is NULL"); 00649 00650 if (pPropertiesDlg->TalkToPage(GetPageID())) 00651 { 00652 BOOL Enable = (pDoc != NULL); 00653 00654 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_COLOURLIST),Enable); 00655 pPropertiesDlg->EnableGadget(_R(IDC_GUIDETAB_COLOURTEXT),Enable); 00656 00657 if (Enable) 00658 ShowColours(); 00659 else 00660 pColourDropDown->ClearList(); 00661 } 00662 return TRUE; 00663 } 00664 00665 /******************************************************************************************** 00666 00667 > BOOL GuidesPropertiesTab::HandleMsg(DialogMsg* Msg) 00668 00669 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00670 Created: 28/09/95 00671 Inputs: - 00672 Outputs: - 00673 Returns: - 00674 Purpose: Handles all the messages for this layer property tab 00675 Errors: - 00676 SeeAlso: LayerPropertyTabsDlg; LayerPropertyTabs; 00677 00678 ********************************************************************************************/ 00679 00680 BOOL GuidesPropertiesTab::HandleMsg(DialogMsg* Msg) 00681 { 00682 TRACEUSER( "Neville", _T("GuidesPropertiesTab::HandleMsg\n")); 00683 ERROR2IF(Msg == NULL,FALSE,"GuidesPropertiesTab::Message null message received"); 00684 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::HandleMsg called with no dialog pointer"); 00685 00686 BOOL ok = pPropertiesDlg->TalkToPage(GetPageID()); 00687 if (!ok) 00688 return TRUE; // no page present = handled message 00689 00690 switch(Msg->DlgMsg) 00691 { 00692 case DIM_CREATE: // Initialise controls 00693 GreyStatus = FALSE; // we are ungreyed by default 00694 ok = InitSection(); 00695 if (!ok) 00696 InformError(); 00697 break; 00698 case DIM_LFT_BN_CLICKED: 00699 //LayerPropertyTabs::SetApplyNowState(TRUE); 00700 if (FALSE) {} 00701 else if (Msg->GadgetID == _R(IDC_GUIDETAB_HORZ)) 00702 { 00703 if (GuideType != GUIDELINE_HORZ) 00704 { 00705 GuideType = GUIDELINE_HORZ; 00706 ShowDetails(); 00707 } 00708 } 00709 else if (Msg->GadgetID == _R(IDC_GUIDETAB_VERT)) 00710 { 00711 if (GuideType != GUIDELINE_VERT) 00712 { 00713 GuideType = GUIDELINE_VERT; 00714 ShowDetails(); 00715 } 00716 } 00717 else if (Msg->GadgetID == _R(IDC_GUIDETAB_PROPERTIES)) 00718 { 00719 PropertiesClicked(); 00720 ShowDetails(); 00721 } 00722 else if (Msg->GadgetID == _R(IDC_GUIDETAB_NEW)) 00723 { 00724 NewClicked(); 00725 ShowDetails(); 00726 } 00727 else if (Msg->GadgetID == _R(IDC_GUIDETAB_DELETE)) 00728 { 00729 DeleteClicked(); 00730 ShowDetails(); 00731 } 00732 break; 00733 00734 case DIM_SELECTION_CHANGED: 00735 case DIM_TEXT_CHANGED: 00736 //LayerPropertyTabs::SetApplyNowState(TRUE); 00737 if (FALSE) {} 00738 else if (Msg->GadgetID == _R(IDC_GUIDETAB_GUIDELINELIST)) 00739 { 00740 ChangeControlStatus(!GreyStatus); 00741 } 00742 else if (Msg->GadgetID == _R(IDC_GUIDETAB_COLOURLIST)) 00743 { 00744 ColourChanged(pPropertiesDlg->GetSelectedValueIndex(Msg->GadgetID)); 00745 ShowDetails(); 00746 } 00747 break; 00748 default: 00749 break; 00750 } 00751 return TRUE; 00752 } 00753 00754 /****************************************************************************************** 00755 00756 > BOOL GuidesPropertiesTab::ColourChanged(INT32 Index) 00757 00758 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00759 Created: 4/10/95 00760 Inputs: Index = index of selected item (Values < 0 will return FALSE); 00761 Outputs: - 00762 Returns: TRUE if successful, else FALSE 00763 Purpose: Handles a change in the colour list selection 00764 Errors: - 00765 SeeAlso: - 00766 00767 ******************************************************************************************/ 00768 00769 BOOL GuidesPropertiesTab::ColourChanged(INT32 Index) 00770 { 00771 if (pColourDropDown == NULL || Index < 0) 00772 return FALSE; 00773 00774 IndexedColour* pNewColour = pColourDropDown->DecodeSelection(Index); 00775 00776 Layer* pLayer = GetGuideLayer(); 00777 if (pLayer != NULL) 00778 { 00779 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CHANGELAYERCOLOUR); 00780 ERROR3IF(pOpDesc == NULL,"FindOpDescriptor(OPTOKEN_CHANGELAYERCOLOUR) failed"); 00781 00782 if (pOpDesc != NULL) 00783 { 00784 OpChangeLayerColourParam ChangeColourParam(pDocument,pLayer,pNewColour); 00785 pOpDesc->Invoke(&ChangeColourParam); 00786 } 00787 // pLayer->SetGuideColour(pNewColour); 00788 // LayerSGallery::ForceRedrawLayer(pDocument,pLayer); 00789 } 00790 return TRUE; 00791 } 00792 00793 /****************************************************************************************** 00794 00795 > BOOL GuidesPropertiesTab::DeleteClicked() 00796 00797 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00798 Created: 3/10/95 00799 Inputs: - 00800 Outputs: - 00801 Returns: TRUE if successful, else FALSE 00802 Purpose: Allows you to delete the selected Guidelines 00803 Errors: - 00804 SeeAlso: - 00805 00806 ******************************************************************************************/ 00807 00808 BOOL GuidesPropertiesTab::DeleteClicked() 00809 { 00810 INT32* pIndexList = pPropertiesDlg->GetSelectedItems(_R(IDC_GUIDETAB_GUIDELINELIST)); 00811 INT32 Count = GuidelineList.GetCount(); 00812 00813 INT32 i; 00814 00815 BOOL ok = (pIndexList != NULL && Count > 0); 00816 NodeGuideline** pGuidelineList = NULL; 00817 00818 if (ok) 00819 { 00820 pGuidelineList = (NodeGuideline**)CCMalloc(sizeof(NodeGuideline*)*(Count+1)); 00821 00822 ok = (pGuidelineList != NULL); 00823 00824 if (ok) 00825 { 00826 for (i=0; (pIndexList[i] >= 0) && (i < Count);i++) 00827 { 00828 GuidelineListItem* pItem = (GuidelineListItem*)GuidelineList.FindItem(pIndexList[i]); 00829 if (pItem != NULL) 00830 pGuidelineList[i] = pItem->pGuideline; 00831 else 00832 { 00833 pGuidelineList[i] = NULL; 00834 ERROR3_PF(("List item at index [%d] is NULL",i)); 00835 } 00836 } 00837 00838 pGuidelineList[i] = NULL; 00839 } 00840 } 00841 else 00842 ok = FALSE; 00843 00844 if (ok) 00845 { 00846 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_GUIDELINE); 00847 ERROR3IF(pOpDesc == NULL,"FindOpDescriptor(OPTOKEN_GUIDELINE) failed"); 00848 00849 if (pOpDesc != NULL) 00850 { 00851 OpGuidelineParam GuidelineParam; 00852 00853 GuidelineParam.Method = GUIDELINEOPMETHOD_DELETE; 00854 GuidelineParam.pGuidelineList = pGuidelineList; 00855 00856 pOpDesc->Invoke(&GuidelineParam); 00857 } 00858 } 00859 00860 if (pGuidelineList != NULL) 00861 CCFree(pGuidelineList); 00862 00863 if (pIndexList != NULL) 00864 delete [] pIndexList; 00865 00866 return ok; 00867 } 00868 00869 /****************************************************************************************** 00870 > BOOL GuidesPropertiesTab::NewClicked() 00871 00872 Author: Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com> 00873 Created: 12/10/95 00874 Returns: FALSE if fails 00875 Purpose: Allows you to create a new Guideline 00876 ******************************************************************************************/ 00877 00878 BOOL GuidesPropertiesTab::NewClicked() 00879 { 00880 // set guideline to be at user ordinate 0 00881 Spread* pSpread = Document::GetSelectedSpread(); 00882 MILLIPOINT Ordinate = NodeGuideline::ToSpreadOrdinate(pSpread,0,GuideType); 00883 GuidelinePropDlg::SetNewGuidelineParams(GuideType,Ordinate); 00884 00885 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_NEWGUIDELINEPROPDLG); 00886 if (pOpDesc!=NULL) 00887 pOpDesc->Invoke(); 00888 else 00889 ERROR3("GuidesPropertiesTab::NewClicked() - OpDescriptor::FindOpDescriptor(OPTOKEN_NEWGUIDELINEPROPDLG) - failed"); 00890 00891 return TRUE; 00892 } 00893 00894 /****************************************************************************************** 00895 > BOOL GuidesPropertiesTab::PropertiesClicked() 00896 00897 Author: Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com> 00898 Created: 12/10/95 00899 Returns: FALSE if fails 00900 Purpose: Opens up the guideline properties dlg for the first selected item in the guideline list box 00901 ******************************************************************************************/ 00902 00903 BOOL GuidesPropertiesTab::PropertiesClicked() 00904 { 00905 INT32 Index = pPropertiesDlg->GetFirstSelectedItem(_R(IDC_GUIDETAB_GUIDELINELIST)); 00906 Layer* pLayer = GetGuideLayer(); 00907 if (Index < 0 || pLayer == NULL) return FALSE; 00908 00909 BOOL Valid; 00910 /*MILLIPOINT Ordinate =*/ pPropertiesDlg->GetDimensionGadgetValue(_R(IDC_GUIDETAB_GUIDELINELIST),pLayer,&Valid,Index); 00911 00912 if (Valid) 00913 { 00914 GuidelineListItem* pItem = (GuidelineListItem*)GuidelineList.FindItem(Index); 00915 if (pItem!=NULL && pItem->pGuideline!=NULL) 00916 { 00917 GuidelinePropDlg::SetEditGuidelineParams(pItem->pGuideline); 00918 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_EDITGUIDELINEPROPDLG); 00919 if (pOpDesc != NULL) 00920 pOpDesc->Invoke(); 00921 else 00922 ERROR3("GuidesPropertiesTab::PropertiesClicked() - OpDescriptor::FindOpDescriptor(OPTOKEN_EDITGUIDELINEPROPDLG) failed"); 00923 } 00924 else 00925 ERROR3_PF(("Unable to find guideline item at index (%d)",Index)); 00926 } 00927 00928 return TRUE; 00929 } 00930 00931 00932 /****************************************************************************************** 00933 00934 > NodeGuideline* GuidesPropertiesTab::FindClosestGuideline(MILLIPOINT UserOrdinate) 00935 00936 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00937 Created: 3/10/95 00938 Inputs: UserOrdinate = Ordinate of guideline in UserCoord space 00939 Outputs: - 00940 Returns: Ptr to nearest guideline to the given ordinate, or NULL if not found 00941 Purpose: This hunts the current layer for guidelines of type GuideType, and returns the nearest 00942 one to the given ordinate of that type 00943 Errors: - 00944 SeeAlso: - 00945 00946 ******************************************************************************************/ 00947 00948 /* 00949 NodeGuideline* GuidesPropertiesTab::FindClosestGuideline(MILLIPOINT UserOrdinate) 00950 { 00951 NodeGuideline* pNearestGuideline = NULL; 00952 MILLIPOINT SmallestDelta; 00953 00954 Layer* pLayer = GetGuideLayer(); 00955 if (pLayer != NULL) 00956 { 00957 Node* pNode = pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGuideline)); 00958 while (pNode != NULL) 00959 { 00960 NodeGuideline* pGuideline = (NodeGuideline*)pNode; 00961 00962 if (pGuideline->GetType() == GuideType) 00963 { 00964 MILLIPOINT Ordinate = NodeGuideline::ToSpreadOrdinate(pGuideline->FindParentSpread(),UserOrdinate,GuideType); 00965 MILLIPOINT Delta = abs(pGuideline->GetOrdinate() - Ordinate); 00966 00967 if ((pNearestGuideline == NULL) || (Delta < SmallestDelta)) 00968 { 00969 pNearestGuideline = pGuideline; 00970 SmallestDelta = Delta; 00971 } 00972 } 00973 00974 pNode = pNode->FindNext(CC_RUNTIME_CLASS(NodeGuideline)); 00975 } 00976 } 00977 00978 return pNearestGuideline; 00979 } 00980 */ 00981 00982 /****************************************************************************************** 00983 00984 > BOOL GuidesPropertiesTab::InitSection() 00985 00986 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00987 Created: 28/09/95 00988 Inputs: - 00989 Outputs: - 00990 Returns: TRUE if successful, else FALSE 00991 Purpose: Sets initial values for this tab on the layer properties dialog box. 00992 Errors: - 00993 SeeAlso: LayerPropertyTabsDlg; LayerPropertyTabs; 00994 00995 ******************************************************************************************/ 00996 00997 BOOL GuidesPropertiesTab::InitSection() 00998 { 00999 TRACEUSER( "Neville", _T("GuidesPropertiesTab::InitSection\n")); 01000 ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::InitSection called with no dialog pointer"); 01001 01002 pColourDropDown = new ColourDropDown; 01003 if (pColourDropDown != NULL) 01004 pColourDropDown->Init(pPropertiesDlg->GetReadWriteWindowID(),_R(IDC_GUIDETAB_COLOURLIST)); 01005 01006 ShowDetails(); 01007 01008 return TRUE; 01009 } 01010 01011 01012 //-------------------------------------------------------- 01013 //-------------------------------------------------------- 01014 01015 /******************************************************************************************** 01016 01017 > LayerColourAction::LayerColourAction() 01018 01019 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01020 Created: 11/10/95 01021 Inputs: - 01022 Outputs: - 01023 Returns: - 01024 Purpose: Constructor for the action 01025 Errors: - 01026 SeeAlso: - 01027 01028 ********************************************************************************************/ 01029 01030 LayerColourAction::LayerColourAction() 01031 { 01032 } 01033 01034 01035 /******************************************************************************************** 01036 01037 > ActionCode LayerColourAction::Init(UndoableOperation* pOp, 01038 ActionList* pActionList, 01039 OpChangeLayerColourParam EntryParam) 01040 01041 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01042 Created: 11/10/95 01043 Inputs: pOp = ptr to the operation to which this action belongs 01044 pActionList = ptr to action list to which this action should be added 01045 Param = Contains all the info needed to change the layer's colour 01046 Outputs: - 01047 Returns: ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL 01048 Purpose: The action that does the layer colour change biz 01049 Errors: - 01050 SeeAlso: Action::Init() 01051 01052 ********************************************************************************************/ 01053 01054 01055 01056 ActionCode LayerColourAction::Init( UndoableOperation* pOp, 01057 ActionList* pActionList, 01058 OpChangeLayerColourParam EntryParam) 01059 { 01060 UINT32 ActSize = sizeof(LayerColourAction); 01061 01062 LayerColourAction* pNewAction; 01063 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(LayerColourAction),(Action**)&pNewAction); 01064 01065 if (Ac != AC_FAIL && pNewAction != NULL) 01066 { 01067 OpChangeLayerColourParam& Param = ((LayerColourAction*)pNewAction)->Param; 01068 01069 Document* pDoc = EntryParam.pDoc; 01070 Layer* pLayer = EntryParam.pLayer; 01071 01072 Param.pDoc = pDoc; 01073 Param.pLayer = pLayer; 01074 01075 if (pDoc != NULL && pLayer != NULL) 01076 { 01077 DocColour* pDocColour = pLayer->GetGuideColour(); 01078 Param.pColour = pDocColour->FindParentIndexedColour(); 01079 01080 pLayer->SetGuideColour(EntryParam.pColour); 01081 LayerSGallery::ForceRedrawLayer(pDoc,pLayer); 01082 BROADCAST_TO_ALL(LayerMsg(pLayer,LayerMsg::GUIDELINES_CHANGED)); 01083 } 01084 01085 ERROR3IF(pDoc == NULL, "pDoc is NULL"); 01086 ERROR3IF(pLayer == NULL,"pLayer is NULL"); 01087 } 01088 01089 return Ac; 01090 } 01091 01092 /******************************************************************************************** 01093 01094 > ActionCode LayerColourAction::Execute(); 01095 01096 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01097 Created: 11/10/95 01098 Inputs: - 01099 Outputs: - 01100 Returns: ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL 01101 Purpose: Executes the action. 01102 Puts the action's layer's visible state to the opposite setting. 01103 Errors: - 01104 SeeAlso: Action::Init() 01105 01106 ********************************************************************************************/ 01107 01108 ActionCode LayerColourAction::Execute() 01109 { 01110 ActionCode Ac = AC_FAIL; 01111 01112 if (pOperation->IS_KIND_OF(UndoableOperation)) 01113 { 01114 Ac = LayerColourAction::Init((UndoableOperation*)pOperation,pOppositeActLst,Param); 01115 01116 } 01117 else 01118 { 01119 ERROR3("LayerColourAction::Execute() called with op that's not an undoable op"); 01120 } 01121 01122 return Ac; 01123 } 01124 01125 LayerColourAction::~LayerColourAction() 01126 { 01127 } 01128 01129 //----------------------------------------------------------------------- 01130 //----------------------------------------------------------------------- 01131 01132 01133 /******************************************************************************************** 01134 01135 > OpChangeLayerColour::OpChangeLayerColour() 01136 01137 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01138 Created: 11/10/95 01139 Purpose: Default constructor 01140 01141 ********************************************************************************************/ 01142 01143 OpChangeLayerColour::OpChangeLayerColour() 01144 { 01145 UndoIDS = _R(IDS_OPCHANGEGUIDELAYERCOLOUR); 01146 } 01147 01148 /******************************************************************************************** 01149 01150 > OpChangeLayerColour::~OpChangeLayerColour() 01151 01152 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01153 Created: 11/10/95 01154 Purpose: Default destructor 01155 01156 ********************************************************************************************/ 01157 01158 OpChangeLayerColour::~OpChangeLayerColour() 01159 { 01160 } 01161 01162 /******************************************************************************************** 01163 01164 > void OpChangeLayerColour::DoWithParam(OpDescriptor* pOpDesc,OpParam* pOpParam) 01165 01166 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01167 Created: 11/10/95 01168 Inputs: pOpDesc = ptr to op descriptor 01169 pOpParam = ptr to the params (should be a OpChangeLayerColourParam) 01170 Outputs: - 01171 Return: - 01172 Purpose: Does the changing of the layer's colour 01173 pOpParam should point to a OpChangeLayerColourParam 01174 01175 ********************************************************************************************/ 01176 01177 void OpChangeLayerColour::DoWithParam(OpDescriptor* pOpDesc,OpParam* pOpParam) 01178 { 01179 OpChangeLayerColourParam* pParam = (OpChangeLayerColourParam*)pOpParam; 01180 01181 ActionCode Ac = LayerColourAction::Init(this,&UndoActions,*pParam); 01182 01183 if (Ac == AC_FAIL) 01184 FailAndExecute(); 01185 01186 End(); 01187 } 01188 01189 /******************************************************************************************** 01190 01191 > static BOOL OpChangeLayerColour::Init() 01192 01193 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01194 Created: 11/10/95 01195 Inputs: - 01196 Outputs: - 01197 Return: TRUE if initialised properly, FALSE otherwise 01198 Purpose: Initialises the operation by registering an op descriptor for it 01199 01200 ********************************************************************************************/ 01201 01202 BOOL OpChangeLayerColour::Init() 01203 { 01204 return (RegisterOpDescriptor( 01205 0, 01206 0, 01207 CC_RUNTIME_CLASS(OpChangeLayerColour), 01208 OPTOKEN_CHANGELAYERCOLOUR, 01209 OpChangeLayerColour::GetState, 01210 0, /* help ID */ 01211 0, /* bubble ID */ 01212 0 /* bitmap ID */ 01213 ) 01214 ); 01215 01216 } 01217 01218 /******************************************************************************************** 01219 01220 > static OpState OpChangeLayerColour::GetState(String_256* Description, OpDescriptor*) 01221 01222 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01223 Created: 11/10/95 01224 Inputs: Description = place to put reason why you are greyed out 01225 Outputs: - 01226 Return: The state of this op 01227 Purpose: Func for finding out whether this op is useable or not 01228 01229 ********************************************************************************************/ 01230 01231 OpState OpChangeLayerColour::GetState(String_256* Description, OpDescriptor*) 01232 { 01233 OpState State; 01234 return State; 01235 } 01236 01237 /******************************************************************************************** 01238 01239 > void OpChangeLayerColour::GetOpName(String_256* OpName) 01240 01241 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01242 Created: 11/10/95 01243 Inputs: OpName = place to put name of op in 01244 Outputs: - 01245 Return: - 01246 Purpose: Gets the name of the op for the undo/redo menu item 01247 01248 ********************************************************************************************/ 01249 01250 void OpChangeLayerColour::GetOpName(String_256* OpName) 01251 { 01252 *OpName = String_256(UndoIDS); 01253 } 01254 01255 #endif // WEBSTER