00001 // $Id: snapops.cpp 1785 2007-11-07 00:46:08Z martin $ 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 // Implement the ops that are associated with snapping (e.g. the "snap to grid" menu op) 00099 00100 /* 00101 */ 00102 00103 #include "camtypes.h" 00104 #include "snapops.h" 00105 //#include "markn.h" 00106 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 #include "grid.h" 00109 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00110 //#include "barsdlgs.h" 00111 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00112 #include "layer.h" 00113 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00114 #include "sglayer.h" 00115 #include "sprdmsg.h" 00116 #include "bubbleid.h" 00117 00118 DECLARE_SOURCE("$Revision: 1785 $"); 00119 00120 CC_IMPLEMENT_DYNCREATE(OpShowGrid, Operation) 00121 CC_IMPLEMENT_DYNCREATE(OpSnapToGrid, Operation) 00122 // WEBSTER - markn 15/1/97 00123 // Removed some op that no longer used in Webster 00124 #ifndef WEBSTER 00125 CC_IMPLEMENT_DYNCREATE(OpShowGuides, Operation) 00126 CC_IMPLEMENT_DYNCREATE(OpSnapToObjects, Operation) 00127 CC_IMPLEMENT_DYNCREATE(OpSnapToGuides, Operation) 00128 #endif 00129 00130 #define new CAM_DEBUG_NEW 00131 00132 /******************************************************************************************** 00133 00134 > static BOOL OpShowGrid::Init() 00135 00136 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00137 Created: 11/2/94 00138 Inputs: None 00139 Outputs: None 00140 Returns: TRUE if worked, FALSE if failed (out of memory) 00141 Purpose: Declares op descriptors for show grid toggle op 00142 Errors: Returns FALSE on failure. 00143 Scope: Static 00144 00145 ********************************************************************************************/ 00146 00147 00148 BOOL OpShowGrid::Init() 00149 { 00150 return RegisterOpDescriptor( 0, // Tool ID 00151 _R(IDS_SHOWGRID), // String resource ID 00152 CC_RUNTIME_CLASS(OpShowGrid),// Runtime class 00153 OPTOKEN_SHOWGRID, // Token string 00154 GetState, // GetState function 0, // help ID 00155 0, // help ID 00156 _R(IDBBL_SHOWGRIDOP), // bubble help 00157 _R(IDD_BARCONTROLSTORE), // resource ID 00158 _R(IDC_BTN_WINDOWGRID), // control ID 00159 SYSTEMBAR_WINDOW, // Bar ID 00160 TRUE, // Recieve system messages 00161 FALSE, // Smart duplicate operation 00162 TRUE, // Clean operation 00163 0, // No vertical counterpart 00164 0, // String for one copy only error 00165 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags 00166 TRUE // fCheckable 00167 ); 00168 } 00169 00170 /******************************************************************************************** 00171 00172 > OpShowGrid::OpShowGrid() 00173 00174 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00175 Created: 11/2/94 00176 Inputs: 00177 Outputs: 00178 Returns: 00179 Purpose: Constructor for OpShowGrid operation. It is not undoable. 00180 Errors: None 00181 00182 ********************************************************************************************/ 00183 00184 OpShowGrid::OpShowGrid() 00185 { 00186 } 00187 00188 /******************************************************************************************** 00189 00190 > void OpShowGrid::Do(OpDescriptor*) 00191 00192 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00193 Created: 11/2/94 00194 Inputs: None 00195 Outputs: None 00196 Returns: None 00197 Purpose: Forces a redraw of the selected DocView and toggles the NodeGrid::RenderFlag flag 00198 Errors: None 00199 00200 ********************************************************************************************/ 00201 00202 void OpShowGrid::Do(OpDescriptor*) 00203 { 00204 DocView *pDocView = DocView::GetSelected(); 00205 00206 if (pDocView != NULL) 00207 { 00208 if (Tool::GetCurrentID() != TOOLID_GRID) 00209 NodeGrid::ForceRedrawAllGrids(); 00210 00211 pDocView->SetShowGridState(!pDocView->GetShowGridState()); 00212 } 00213 00214 End(); 00215 } 00216 00217 /******************************************************************************************** 00218 00219 > OpState OpShowGrid::GetState(String_256*, OpDescriptor*) 00220 00221 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00222 Created: 11/2/94 00223 Inputs: 00224 Outputs: 00225 Returns: 00226 Purpose: This item is always available, so long as a document is visible. 00227 Errors: None 00228 00229 ********************************************************************************************/ 00230 00231 OpState OpShowGrid::GetState(String_256*, OpDescriptor*) 00232 { 00233 OpState OpSt; 00234 00235 DocView *pDocView = DocView::GetSelected(); 00236 if (pDocView != NULL) 00237 OpSt.Ticked = pDocView->GetShowGridState(); 00238 00239 return OpSt; 00240 } 00241 00242 00243 //-------------------------------------------------------------------------------------------- 00244 00245 00246 /******************************************************************************************** 00247 00248 > static BOOL OpSnapToGrid::Init() 00249 00250 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00251 Created: 11/2/94 00252 Inputs: None 00253 Outputs: None 00254 Returns: TRUE if worked, FALSE if failed (out of memory) 00255 Purpose: Declares op descriptors for snap to grid toggle op 00256 Errors: Returns FALSE on failure. 00257 Scope: Static 00258 00259 ********************************************************************************************/ 00260 00261 00262 BOOL OpSnapToGrid::Init() 00263 { 00264 return RegisterOpDescriptor(0, // tool id 00265 _R(IDS_SNAPTOGRID), // String resource ID 00266 CC_RUNTIME_CLASS(OpSnapToGrid),// Runtime class 00267 OPTOKEN_SNAPTOGRID, // Token string 00268 GetState, // GetState function 0, // help ID 00269 0, // help ID 00270 _R(IDBBL_SNAPTOGRIDOP), // bubble help 00271 _R(IDD_BARCONTROLSTORE), // resource ID 00272 _R(IDC_BTN_WINDOWSNAP), // control ID 00273 SYSTEMBAR_WINDOW, // Bar ID 00274 TRUE, // Recieve system messages 00275 FALSE, // Smart duplicate operation 00276 TRUE, // Clean operation 00277 0, // No vertical counterpart 00278 0, // String for one copy only error 00279 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags 00280 TRUE // fCheckable 00281 ); 00282 } 00283 00284 /******************************************************************************************** 00285 00286 > OpSnapToGrid::OpSnapToGrid() 00287 00288 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00289 Created: 11/2/94 00290 Inputs: 00291 Outputs: 00292 Returns: 00293 Purpose: Constructor for OpSnapToGrid operation. It is not undoable. 00294 Errors: None 00295 00296 ********************************************************************************************/ 00297 00298 OpSnapToGrid::OpSnapToGrid() 00299 { 00300 } 00301 00302 /******************************************************************************************** 00303 00304 > void OpSnapToGrid::Do(OpDescriptor*) 00305 00306 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00307 Created: 11/2/94 00308 Inputs: None 00309 Outputs: None 00310 Returns: None 00311 Purpose: Toggles the "snap to grid" flag in the selected DocView 00312 Errors: None 00313 00314 ********************************************************************************************/ 00315 00316 void OpSnapToGrid::Do(OpDescriptor*) 00317 { 00318 DocView *pDocView = DocView::GetSelected(); 00319 00320 if (pDocView != NULL) 00321 pDocView->SetSnapToGridState(!pDocView->GetSnapToGridState()); 00322 00323 End(); 00324 } 00325 00326 /******************************************************************************************** 00327 00328 > OpState OpSnapToGrid::GetState(String_256*, OpDescriptor*) 00329 00330 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00331 Created: 11/2/94 00332 Inputs: 00333 Outputs: 00334 Returns: 00335 Purpose: This item is always available, so long as a document is visible. 00336 Errors: None 00337 00338 ********************************************************************************************/ 00339 00340 OpState OpSnapToGrid::GetState(String_256*, OpDescriptor*) 00341 { 00342 OpState OpSt; 00343 00344 DocView *pDocView = DocView::GetSelected(); 00345 if (pDocView != NULL) 00346 OpSt.Ticked = pDocView->GetSnapToGridState(); 00347 00348 return OpSt; 00349 } 00350 00351 //-------------------------------------------------------------------------------------------- 00352 00353 // WEBSTER - markn 15/1/97 00354 // Removed some op that no longer used in Webster 00355 #ifndef WEBSTER 00356 00357 00358 /******************************************************************************************** 00359 00360 > static BOOL OpSnapToObjects::Init() 00361 00362 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00363 Created: 21/9/94 00364 Inputs: None 00365 Outputs: None 00366 Returns: TRUE if worked, FALSE if failed (out of memory) 00367 Purpose: Declares op descriptors for snap to objects toggle op 00368 Errors: Returns FALSE on failure. 00369 Scope: Static 00370 00371 ********************************************************************************************/ 00372 00373 00374 BOOL OpSnapToObjects::Init() 00375 { 00376 return RegisterOpDescriptor(0, // Tool ID 00377 _R(IDS_SNAPTOOBJECTS), // String resource ID 00378 CC_RUNTIME_CLASS(OpSnapToObjects),// Runtime class 00379 OPTOKEN_SNAPTOOBJECTS, // Token string 00380 GetState, // GetState function 00381 0, // help ID 00382 _R(IDBBL_SNAPTOOBJECTS), // Bubble ID 00383 _R(IDD_BARCONTROLSTORE), // resource ID 00384 0, // control ID 00385 SYSTEMBAR_WINDOW, // Bar ID 00386 TRUE, // Recieve system messages 00387 FALSE, // Smart duplicate operation 00388 TRUE, // Clean operation 00389 0, // No vertical counterpart 00390 0, // String for one copy only error 00391 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags 00392 TRUE // fCheckable 00393 ); 00394 } 00395 00396 /******************************************************************************************** 00397 00398 > OpSnapToObjects::OpSnapToObjects() 00399 00400 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00401 Created: 21/9/94 00402 Inputs: 00403 Outputs: 00404 Returns: 00405 Purpose: Constructor for OpSnapToObjects operation. It is not undoable. 00406 Errors: None 00407 00408 ********************************************************************************************/ 00409 00410 OpSnapToObjects::OpSnapToObjects() 00411 { 00412 } 00413 00414 /******************************************************************************************** 00415 00416 > void OpSnapToObjects::Do(OpDescriptor*) 00417 00418 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00419 Created: 21/9/94 00420 Inputs: None 00421 Outputs: None 00422 Returns: None 00423 Purpose: Toggles the "snap to objects" flag in the selected DocView 00424 Errors: None 00425 00426 ********************************************************************************************/ 00427 00428 void OpSnapToObjects::Do(OpDescriptor*) 00429 { 00430 DocView *pDocView = DocView::GetSelected(); 00431 00432 if (pDocView != NULL) 00433 { 00434 // Find out the new value for the magnetic snapping 00435 BOOL NewState = !pDocView->GetSnapToObjectsState(); 00436 pDocView->SetSnapToObjectsState(NewState); 00437 00438 // update all slider controls that show the view quality 00439 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SNAPTOOBJECTS); 00440 if (pOpDesc!=NULL) 00441 { 00442 // Found the opdescriptor. Now find all the gadgets associated with it 00443 List Gadgets; 00444 if (pOpDesc->BuildGadgetList(&Gadgets)) 00445 { 00446 // Found some. Set the controls position according to the quality 00447 GadgetListItem* pGadgetItem = (GadgetListItem*) Gadgets.GetHead(); 00448 00449 while (pGadgetItem!=NULL) 00450 { 00451 // Set the sliders position 00452 pGadgetItem->pDialogOp->SetLongGadgetValue(pGadgetItem->gidGadgetID, NewState, FALSE); 00453 00454 // go find the next gadget 00455 pGadgetItem = (GadgetListItem*) Gadgets.GetNext(pGadgetItem); 00456 } 00457 00458 // Clean out the list 00459 Gadgets.DeleteAll(); 00460 } 00461 } 00462 } 00463 00464 End(); 00465 } 00466 00467 /******************************************************************************************** 00468 00469 > OpState OpSnapToObjects::GetState(String_256*, OpDescriptor*) 00470 00471 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00472 Created: 21/9/94 00473 Inputs: 00474 Outputs: 00475 Returns: 00476 Purpose: This item is always available, so long as a document is visible. 00477 Errors: None 00478 00479 ********************************************************************************************/ 00480 00481 OpState OpSnapToObjects::GetState(String_256*, OpDescriptor*) 00482 { 00483 OpState OpSt; 00484 00485 DocView *pDocView = DocView::GetSelected(); 00486 if (pDocView != NULL) 00487 OpSt.Ticked = pDocView->GetSnapToObjectsState(); 00488 00489 return OpSt; 00490 } 00491 00492 //-------------------------------------------------------------------------------------------- 00493 00494 /******************************************************************************************** 00495 00496 > static BOOL OpSnapToGuides::Init() 00497 00498 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00499 Created: 22/9/95 00500 Inputs: None 00501 Outputs: None 00502 Returns: TRUE if worked, FALSE if failed (out of memory) 00503 Purpose: Declares op descriptors for snap to guides toggle op 00504 Errors: Returns FALSE on failure. 00505 Scope: Static 00506 00507 ********************************************************************************************/ 00508 00509 00510 BOOL OpSnapToGuides::Init() 00511 { 00512 return RegisterOpDescriptor(0, // Tool ID 00513 _R(IDS_SNAPTOGUIDES), // String resource ID 00514 CC_RUNTIME_CLASS(OpSnapToGuides),// Runtime class 00515 OPTOKEN_SNAPTOGUIDES, // Token string 00516 GetState, // GetState function 00517 0, // help ID 00518 _R(IDBBL_SNAPTOGUIDES), // Bubble ID 00519 _R(IDD_BARCONTROLSTORE), // resource ID 00520 0, // control ID 00521 SYSTEMBAR_WINDOW, // Bar ID 00522 TRUE, // Recieve system messages 00523 FALSE, // Smart duplicate operation 00524 TRUE, // Clean operation 00525 0, // No vertical counterpart 00526 0, // String for one copy only error 00527 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags 00528 TRUE // fCheckable 00529 ); 00530 } 00531 00532 /******************************************************************************************** 00533 00534 > OpSnapToGuides::OpSnapToGuides() 00535 00536 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00537 Created: 22/9/95 00538 Inputs: 00539 Outputs: 00540 Returns: 00541 Purpose: Constructor for OpSnapToGuides operation. It is not undoable. 00542 Errors: None 00543 00544 ********************************************************************************************/ 00545 00546 OpSnapToGuides::OpSnapToGuides() 00547 { 00548 } 00549 00550 /******************************************************************************************** 00551 00552 > void OpSnapToGuides::Do(OpDescriptor*) 00553 00554 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00555 Created: 22/9/95 00556 Inputs: None 00557 Outputs: None 00558 Returns: None 00559 Purpose: Toggles the "snap to guides" flag in the selected DocView 00560 Errors: None 00561 00562 ********************************************************************************************/ 00563 00564 void OpSnapToGuides::Do(OpDescriptor*) 00565 { 00566 DocView *pDocView = DocView::GetSelected(); 00567 00568 if (pDocView != NULL) 00569 pDocView->SetSnapToGuidesState(!pDocView->GetSnapToGuidesState()); 00570 00571 End(); 00572 } 00573 00574 /******************************************************************************************** 00575 00576 > OpState OpSnapToGuides::GetState(String_256*, OpDescriptor*) 00577 00578 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00579 Created: 22/9/95 00580 Inputs: 00581 Outputs: 00582 Returns: 00583 Purpose: This item is always available, so long as a document is visible. 00584 Errors: None 00585 00586 ********************************************************************************************/ 00587 00588 OpState OpSnapToGuides::GetState(String_256* pUIDescription, OpDescriptor*) 00589 { 00590 OpState OpSt; 00591 00592 DocView *pDocView = DocView::GetSelected(); 00593 if (pDocView != NULL) 00594 OpSt.Ticked = pDocView->GetSnapToGuidesState(); 00595 00596 Spread* pSpread = Document::GetSelectedSpread(); 00597 if (pSpread != NULL) 00598 { 00599 // if we have a guide layer, then make the menu item available, if not, grey it 00600 // and give a reason. 00601 if (pSpread->FindFirstGuideLayer() != NULL) 00602 { 00603 OpSt.Greyed = FALSE; 00604 } 00605 else 00606 { 00607 OpSt.Greyed = TRUE; 00608 *pUIDescription = String_256 (_R(IDS_NO_GUIDES)); 00609 } 00610 } 00611 00612 return OpSt; 00613 } 00614 00615 //-------------------------------------------------------------------------------------------- 00616 00617 /******************************************************************************************** 00618 00619 > static BOOL OpShowGuides::Init() 00620 00621 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00622 Created: 27/9/95 00623 Inputs: None 00624 Outputs: None 00625 Returns: TRUE if worked, FALSE if failed (out of memory) 00626 Purpose: Declares op descriptors for show grid toggle op 00627 Errors: Returns FALSE on failure. 00628 Scope: Static 00629 00630 ********************************************************************************************/ 00631 00632 00633 BOOL OpShowGuides::Init() 00634 { 00635 return RegisterOpDescriptor( 0, // Tool ID 00636 _R(IDS_SHOWGUIDES), // String resource ID 00637 CC_RUNTIME_CLASS(OpShowGuides),// Runtime class 00638 OPTOKEN_SHOWGUIDES, // Token string 00639 GetState, // GetState function 0, // help ID 00640 0, // help ID 00641 _R(IDBBL_SHOWGUIDES), // bubble help 00642 _R(IDD_BARCONTROLSTORE), // resource ID 00643 _R(IDC_BTN_WINDOWGRID), // control ID 00644 SYSTEMBAR_WINDOW, // Bar ID 00645 TRUE, // Recieve system messages 00646 FALSE, // Smart duplicate operation 00647 TRUE, // Clean operation 00648 0, // No vertical counterpart 00649 0, // String for one copy only error 00650 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC), // Auto state flags 00651 TRUE // fCheckable 00652 ); 00653 } 00654 00655 /******************************************************************************************** 00656 00657 > OpShowGuides::OpShowGuides() 00658 00659 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00660 Created: 27/9/95 00661 Inputs: 00662 Outputs: 00663 Returns: 00664 Purpose: Constructor for OpShowGuides operation. It is not undoable. 00665 Errors: None 00666 00667 ********************************************************************************************/ 00668 00669 OpShowGuides::OpShowGuides() 00670 { 00671 } 00672 00673 /******************************************************************************************** 00674 00675 > void OpShowGuides::Do(OpDescriptor*) 00676 00677 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00678 Created: 27/9/95 00679 Inputs: None 00680 Outputs: None 00681 Returns: None 00682 Purpose: Forces a redraw of the selected DocView and toggles the view's ShowGuides flag 00683 Errors: None 00684 00685 ********************************************************************************************/ 00686 00687 void OpShowGuides::Do(OpDescriptor*) 00688 { 00689 DocView *pDocView = DocView::GetSelected(); 00690 00691 if (pDocView != NULL) 00692 { 00693 pDocView->SetShowGuidesState(!pDocView->GetShowGuidesState()); 00694 00695 Spread* pSpread = Document::GetSelectedSpread(); 00696 Document* pDoc = Document::GetSelected(); 00697 if (pSpread != NULL && pDoc != NULL) 00698 { 00699 Layer* pLayer = pSpread->FindFirstGuideLayer(); 00700 if (pLayer != NULL) 00701 LayerSGallery::ForceRedrawLayer(pDoc,pLayer); 00702 } 00703 00704 BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES)); 00705 } 00706 00707 End(); 00708 } 00709 00710 /******************************************************************************************** 00711 00712 > OpState OpShowGuides::GetState(String_256*, OpDescriptor*) 00713 00714 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00715 Created: 27/9/95 00716 Inputs: 00717 Outputs: 00718 Returns: 00719 Purpose: This item is always available, so long as a document is visible. 00720 Errors: None 00721 00722 ********************************************************************************************/ 00723 00724 OpState OpShowGuides::GetState(String_256* pUIDescription, OpDescriptor*) 00725 { 00726 OpState OpSt; 00727 00728 DocView *pDocView = DocView::GetSelected(); 00729 if (pDocView != NULL) 00730 OpSt.Ticked = pDocView->GetShowGuidesState(); 00731 00732 Spread* pSpread = Document::GetSelectedSpread(); 00733 if (pSpread != NULL) 00734 { 00735 // if we have a guide layer, then make the menu item available, if not, grey it 00736 // and give a reason. 00737 if (pSpread->FindFirstGuideLayer() != NULL) 00738 { 00739 OpSt.Greyed = FALSE; 00740 } 00741 else 00742 { 00743 OpSt.Greyed = TRUE; 00744 *pUIDescription = String_256 (_R(IDS_NO_GUIDES)); 00745 } 00746 00747 } // if (pSpread != NULL) 00748 00749 return OpSt; 00750 } 00751 00752 #endif // WEBSTER