selall.cpp

Go to the documentation of this file.
00001 // $Id: selall.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 // SelAll.cpp
00100 //
00101 // Operations to Select All and Select none
00102 //
00103 /*
00104 */
00105 
00106 #include "camtypes.h"
00107 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "selall.h"
00109 //#include "phil.h"
00110 #include "helpids.h"
00111 //#include "resource.h"
00112 //#include "barsdlgs.h"
00113 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00117 //#include "simon.h"
00118 #include "blobs.h"
00119 
00121 //                                  SelectAllOp
00122 
00123 /******************************************************************************************
00124 >   SelectAllOp::SelectAllOp()
00125 
00126     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00127     Created:    24/5/94
00128     Purpose:    Constructs a new SelectAllOp object: setting default operation flags, and 
00129                 adding it to the Live list. 
00130 ******************************************************************************************/
00131 
00132 CC_IMPLEMENT_DYNCREATE(SelectAllOp, Operation)
00133 
00134 SelectAllOp::SelectAllOp(): Operation()
00135 {
00136 }
00137 
00138 
00139 /******************************************************************************************
00140 >   void SelectAllOp::Do(OpDescriptor*)
00141 
00142     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00143     Created:    24/5/94
00144     Inputs:     An Operation Descriptor
00145     Purpose:    Actually "DO" a select all operation.
00146 ********************************************************************************************/
00147 
00148 void SelectAllOp::Do(OpDescriptor*)
00149 {
00150     Spread* pSelSpread = Document::GetSelectedSpread();
00151 //  Document * pDoc = Document::GetCurrent();
00152 
00153     // Only select all if we have a selected spread
00154     if (pSelSpread != NULL)
00155     {
00156         // Get the current tool
00157         Tool* pTool = Tool::GetCurrent();
00158         BlobManager* pBlobManager = Camelot.GetBlobManager();
00159         ENSURE(pBlobManager, "Can't get BlobManager");
00160 
00161         // Render off tool blobs if the tool dosen't do it itself on SelChange messages
00162         if (pTool!=NULL && !pTool->AreToolBlobsRenderedOnSelection())
00163 //          pTool->RenderToolBlobsOff(pSelSpread,NULL);
00164             pBlobManager->RenderToolBlobsOff(pTool, pSelSpread, NULL);
00165 
00166         // ensures all blobs removed
00167         NodeRenderableInk::DeselectAll(TRUE);
00168 
00169         // get a rect encompassing the whole spread (and all objects on it)
00170         // NB just getting bounds of all objects => blob redraw probs
00171         DocRect PasteBounds = pSelSpread->GetBoundingRect();
00172         DocRect PasteRect   = pSelSpread->GetPasteboardRect();
00173         PasteBounds = PasteBounds.Union(PasteRect);
00174 
00175         // Convert those Document Coords into Spread Coords
00176         pSelSpread->DocCoordToSpreadCoord(&PasteBounds);
00177 
00178         // select all selectable objects in the spread
00179         NodeRenderableInk::SelectAllInRect(PasteBounds,pSelSpread,NodeRenderableInk::SET);
00180 
00181         // Get the current tool to put its blobs back on
00182         if (pTool!=NULL && !pTool->AreToolBlobsRenderedOnSelection())
00183 //          pTool->RenderToolBlobsOn(pSelSpread,NULL);
00184             pBlobManager->RenderToolBlobsOn(pTool, pSelSpread, NULL);
00185 
00186     }
00187     End();
00188 }
00189 
00190 
00191 /********************************************************************************************
00192 >   OpState SelectAllOp::GetState(String_256* UIDescription, OpDescriptor*)
00193 
00194     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00195     Created:    24/5/94
00196     Inputs:     String - representing the operation description which may be updated
00197                 OpDescriptor - To help update the state
00198     Purpose:    Find the state of the SelectAllOp operation.
00199 ********************************************************************************************/
00200 
00201 OpState SelectAllOp::GetState(String_256* UIDescription, OpDescriptor*)
00202 {
00203     return OpState(FALSE,FALSE);        // Never ticked, never greyed!
00204 }
00205 
00206 
00207 /********************************************************************************************
00208 >   BOOL SelectAllOp::Init()
00209 
00210     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00211     Created:    24/5/94
00212     Purpose:    Create an OpDescriptor for the Select All operation
00213 ********************************************************************************************/
00214 
00215 BOOL SelectAllOp::Init()
00216 {
00217     BTNOP(EDITSELECTALL,SelectAllOp,EDIT);
00218     return(TRUE);
00219 }
00220 
00221 
00223 //                                  SelectNoneOp
00224 
00225 /******************************************************************************************
00226 >   SelectNoneOp::SelectNoneOp()
00227 
00228     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00229     Created:    24/5/94
00230     Purpose:    Constructs a new SelectNoneOp object: setting default operation flags, and 
00231                 adding it to the Live list. 
00232 ******************************************************************************************/
00233 
00234 CC_IMPLEMENT_DYNCREATE(SelectNoneOp, Operation)
00235 
00236 SelectNoneOp::SelectNoneOp(): Operation()
00237 {
00238 }
00239 
00240 
00241 /******************************************************************************************
00242 >   void SelectNoneOp::Do(OpDescriptor*)
00243 
00244     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00245     Created:    24/5/94
00246     Inputs:     An Operation Descriptor
00247     Purpose:    Actually "DO" a select all operation.
00248 ********************************************************************************************/
00249 
00250 void SelectNoneOp::Do(OpDescriptor*)
00251 {
00252     Spread* pSelSpread = Document::GetSelectedSpread();
00253 
00254     // Only deselect all if we have a selected spread
00255     if (pSelSpread != NULL)
00256     {
00257         // Get the current tool
00258         Tool* pTool = Tool::GetCurrent();
00259 
00260         NodeRenderableInk::DeselectAll(TRUE);
00261 
00262         // Get the tool to remove all its blobs before we deselect the nodes.
00263         // Only do this if the current tool dosent update itself on sel changed messages
00264         if (pTool!=NULL && !pTool->AreToolBlobsRenderedOnSelection())
00265             pTool->RenderToolBlobs(pSelSpread,NULL);
00266     }
00267 
00268     End();
00269 }
00270 
00271 
00272 /********************************************************************************************
00273 >   OpState SelectNoneOp::GetState(String_256* UIDescription, OpDescriptor*)
00274 
00275     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00276     Created:    24/5/94
00277     Inputs:     String - representing the operation description which may be updated
00278                 OpDescriptor - To help update the state
00279     Purpose:    Find the state of the SelectNoneOp operation.
00280 ********************************************************************************************/
00281 
00282 OpState SelectNoneOp::GetState(String_256* UIDescription, OpDescriptor*)
00283 {
00284     INT32 NumSelObjs=GetApplication()->FindSelection()->Count();
00285 
00286     // If no objects are selected, state this as the reason why it's disabled..
00287     if (NumSelObjs==0)
00288     {
00289         *UIDescription = String_256 (_R(IDS_NO_OBJECTS_SELECTED));
00290     }
00291 
00292     // Never ticked, greyed if no selected objects
00293     return OpState(FALSE, NumSelObjs==0);
00294 }
00295 
00296 
00297 /********************************************************************************************
00298 >   BOOL SelectNoneOp::Init()
00299 
00300     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00301     Created:    24/5/94
00302     Purpose:    Create an OpDescriptor for the Select All operation
00303 ********************************************************************************************/
00304 
00305 BOOL SelectNoneOp::Init()
00306 {
00307     BTNOP(EDITSELECTNONE,SelectNoneOp,EDIT);
00308     return(TRUE);
00309 }
00310 
00311 
00312 
00313 
00314 

Generated on Sat Nov 10 03:46:48 2007 for Camelot by  doxygen 1.4.4