viewmenu.cpp

Go to the documentation of this file.
00001 // $Id: viewmenu.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 // Context sensitive menu for DocViews
00100 //
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 #include "viewmenu.h"
00106 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "menuops.h"
00108 #include "coldlog.h"
00109 #include "snapops.h"
00110 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "blobs.h"
00113 #include "mkshapes.h"
00114 #include "mkstroke.h"
00115 #include "combshps.h"
00116 #include "selector.h"
00117 #include "appprefs.h"   // OPTOKEN_PAGESIZEDLG
00118 #include "guides.h"
00119 #include "makebmp.h"
00120 #include "opimgset.h"
00121 #include "hlinkdlg.h"
00122 #include "layergal.h"   // OPTOKEN_DELETEPAGEBACKGROUND
00123 //#include "brushdlg.h"
00124 #include "brushop.h"
00125 #include "cutop.h"      // OPTOKEN_PASTE    matt-23/08/2000
00126 
00127 // This is not compulsory, but you may as well put it in so that the correct version
00128 // of your file can be registered in the .exe
00129 DECLARE_SOURCE("$Revision: 1282 $");
00130 
00131 // An implement to match the Declare in the .h file.
00132 // If you have many classes, it is recommended to place them all together, here at the start of the file
00133 CC_IMPLEMENT_MEMDUMP(ViewContextMenu, ContextMenu)
00134 
00135 // This will get Camelot to display the filename and linenumber of any memory allocations
00136 // that are not released at program exit
00137 #define new CAM_DEBUG_NEW
00138 
00139 
00140 
00141 
00142 /********************************************************************************************
00143 
00144 >   BOOL ViewContextMenu::BuildOverView(Spread* pSpread, DocCoord ClickPos, ClickModifiers ClickMods)
00145 
00146     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00147     Created:    17/03/95
00148     Inputs:     -
00149     Outputs:    -
00150     Returns:    TRUE if menu built OK
00151                 FALSE (and sets error) otherwise
00152     Purpose:    To build the View pop-up menu.
00153                 This function is complicated by the fact that it offers the current tool
00154                 a chance to build menu items for any section of the view pop-up menu.
00155     Errors:     -
00156 
00157 ********************************************************************************************/
00158 
00159 BOOL ViewContextMenu::BuildOverView(Spread* pSpread, DocCoord ClickPos, ClickModifiers ClickMods)
00160 {
00161     ERROR2IF(pSpread==NULL,FALSE,"BuildOverView passed NULL spread pointer");
00162 
00163     BOOL ok = TRUE;
00164 
00165     //---------------------------------------------//
00166     // First ask selected nodes if they want to supply items and if so show the blob menu...
00167     if (AskBlobsForItems(pSpread, ClickPos, ClickMods))
00168     {
00169         // If they supply items then we won't add the normal items about the selection
00170         return TRUE;
00171     }
00172 
00173     //---------------------------------------------//
00174     // Find what the click was on and show the object menu...
00175 //  NodeRenderableInk* pHitNode = NodeRenderableInk::FindSimpleAtPoint(pSpread, ClickPos);
00176 
00177     NodeRenderableInk* pHitNode = FindNodeAtPoint(pSpread,ClickPos);
00178     if (pHitNode)
00179     {
00180         BOOL HitNodeIsGuideline = IS_A(pHitNode,NodeGuideline);
00181 
00182         if (!HitNodeIsGuideline)        // BODGE so that guidelines (which can't be selected) can have a pop-up menu
00183         {
00184             // Now find out if there's just one node selected and if so ask it for some items...
00185             SelRange* pSel = GetApplication()->FindSelection();
00186             if (pSel!=NULL)
00187             {
00188                 Node* pNode = pSel->FindFirst();
00189                 if (pNode && pSel->FindNext(pNode) == NULL)
00190                 {
00191                     // There's only one object selected so let's ask it about itself...
00192                     ((NodeRenderableInk*) pNode)->OnNodePopUp(pSpread, ClickPos, this);
00193                 }
00194             }
00195         }
00196         else
00197             pHitNode->OnNodePopUp(pSpread, ClickPos, this);
00198 
00199         if (!HitNodeIsGuideline)        // BODGE to stop guideline pop-up menus having irrelevant menu items
00200         {
00201             // Build the rest of the standard object menu...
00202             // Effect commands
00203             ok = ok && BuildEffectCommands();
00204             // Edit commands
00205             ok = ok && BuildTransferCommands(TRUE);
00206             // Arrange commands
00207         //  WEBSTER-ranbirr-13/11/96
00208 //  #ifndef WEBSTER
00209             ok = ok && BuildCommand(OPTOKEN_MAKE_SHAPES);
00210 //  #endif //webster
00211             ok = ok && BuildCommand(OPTOKEN_CONVERTTOBITMAP);
00212     // WEBSTER-ranbirr-13/11/96
00213     // Now Taken out by vector stroking code Neville 2/10/97
00214     #ifdef VECTOR_STROKING
00215         //  ok = ok && BuildCommand(OPTOKEN_MAKE_STROKE);
00216     #endif // VECTOR_STROKING
00217             ok = ok && BuildCommand(OPTOKEN_COMBINESHAPES,TRUE);
00218             MenuItem* pCombineRoot = GetLastItem();
00219     //  WEBSTER-ranbirr-13/11/96
00220 //  #ifndef WEBSTER
00221                 ok = ok && BuildCommand(OPTOKEN_ADDSHAPES, FALSE, pCombineRoot);
00222                 ok = ok && BuildCommand(OPTOKEN_SUBTRACTSHAPES, FALSE, pCombineRoot);
00223                 ok = ok && BuildCommand(OPTOKEN_INTERSECTSHAPES, FALSE, pCombineRoot);
00224                 ok = ok && BuildCommand(OPTOKEN_SLICESHAPES, FALSE, pCombineRoot);
00225 //  #endif //webster
00226 
00227     #ifndef WEBSTER
00228             // Imagesetting submenu
00229             ok = ok && BuildCommand(OPTOKEN_IMAGESETTING, TRUE);
00230             pCombineRoot = GetLastItem();
00231                 ok = ok && BuildCommand(OPTOKEN_OVERPRINTFILL,    FALSE, pCombineRoot);
00232                 ok = ok && BuildCommand(OPTOKEN_OVERPRINTLINE,    TRUE,  pCombineRoot);
00233                 ok = ok && BuildCommand(OPTOKEN_PRINTONALLPLATES, FALSE, pCombineRoot);
00234     #endif //webster
00235             // Utils commands
00236             ok = ok && BuildCommand(OPTOKEN_WEBADDRESSDLG);
00237             ok = ok && BuildCommand(OPTOKEN_COLOUREDITDLG, TRUE);
00238 PORTNOTE("other", "Removed brush edit dialog from popup menu")
00239 #ifndef EXCLUDE_FROM_XARALX
00240             ok = ok && BuildCommand(OPTOKEN_BRUSHEDIT_DLG);
00241 #endif
00242             ok = ok && BuildCommand(OPTOKEN_SELECTBRUSH);
00243         }
00244 
00245         return ok;
00246     }
00247 
00248     //---------------------------------------------//
00249     // If on white space then show the white space menu...
00250     // Window commands
00251 //  MENUITEM OPTOKEN_TOOLBARDLG
00252 //      MENUITEM OPTOKEN_VIEWCOLOURBAR      
00253 //      MENUITEM OPTOKEN_VIEWSTATUSBAR
00254 //      MENUITEM OPTOKEN_VIEWSCROLLBARS
00255 //  WEBSTER-ranbirr-13/11/96
00256 #ifndef WEBSTER
00257     ok = ok && BuildCommand(OPTOKEN_WINDOWNEWVIEW);
00258     ok = ok && BuildCommand(OPTOKEN_VIEWFULLSCREEN,TRUE);
00259 #else
00260     ok = ok && BuildCommand(OPTOKEN_WINDOWNEWVIEW,TRUE);
00261 #endif //webster
00262 
00263     // Paste option - we don't need to do the
00264     // BuildTransferCommands as the Cut and Copy operations
00265     // are never applicable here... matt-23/08/2000
00266     ok = ok && BuildCommand(OPTOKEN_PASTE, TRUE);
00267 
00268     // View quality
00269     ok = ok && BuildCommand(OPTOKEN_WINDOWQUALITY,FALSE);
00270     MenuItem* pQualityRoot = GetLastItem();
00271     ok = ok && BuildCommand(OPTOKEN_QUALITYANTIALIASED, FALSE, pQualityRoot);
00272     ok = ok && BuildCommand(OPTOKEN_QUALITYNORMAL, FALSE, pQualityRoot);
00273     ok = ok && BuildCommand(OPTOKEN_QUALITYSIMPLE, FALSE, pQualityRoot);
00274     ok = ok && BuildCommand(OPTOKEN_QUALITYOUTLINE, FALSE, pQualityRoot);
00275     // View commands
00276 //  WEBSTER-ranbirr-13/11/96
00277 #ifndef WEBSTER
00278     ok = ok && BuildCommand(OPTOKEN_SHOWGRID);
00279     ok = ok && BuildCommand(OPTOKEN_SHOWGUIDES,TRUE);
00280 #else
00281     ok = ok && BuildCommand(OPTOKEN_SHOWGRID,TRUE);
00282 #endif //webster
00283 //  WEBSTER-ranbirr-13/11/96
00284 #ifndef WEBSTER
00285     ok = ok && BuildCommand(OPTOKEN_SNAPTOGRID);
00286     ok = ok && BuildCommand(OPTOKEN_SNAPTOGUIDES);
00287     ok = ok && BuildCommand(OPTOKEN_SNAPTOOBJECTS,TRUE);
00288 #else
00289     ok = ok && BuildCommand(OPTOKEN_SNAPTOGRID,TRUE);
00290 #endif //webster
00291     ok = ok && BuildCommand(OPTOKEN_DELETEPAGEBACKGROUND);
00292     // Page commands (almost "Properties...")
00293     ok = ok && BuildCommand(OPTOKEN_PAGESIZEDLG);
00294 
00295     return ok;
00296 }
00297 
00298 
00299 
00300 
00301 /********************************************************************************************
00302 
00303 >   NodeRenderableInk* ViewContextMenu::FindNodeAtPoint(Spread* pSpread, DocCoord ClickPos)
00304 
00305     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00306     Created:    26/09/95
00307     Inputs:     pSpread = ptr to spread
00308                 ClickPos = pos of click within the given spread
00309     Outputs:    -
00310     Returns:    ptr to node under click, or NULL if none found
00311     Purpose:    This copes with finding which node is under a click.
00312                 It uses SelectorTool::FindPreProcessClickNode() to see if there is a node
00313                 that would not get detected by a straight call to NodeRenderableInk::FindSimpleAtPoint()
00314 
00315                 If this fails, it then returns the result returned by NodeRenderableInk::FindSimpleAtPoint()
00316 
00317     Errors:     -
00318 
00319 ********************************************************************************************/
00320 
00321 NodeRenderableInk* ViewContextMenu::FindNodeAtPoint(Spread* pSpread, DocCoord ClickPos)
00322 {
00323 #ifndef STANDALONE
00324 // selector tool not present in stand alone version
00325     NodeRenderableInk* pNode = SelectorTool::FindPreProcessClickNode(pSpread,ClickPos);
00326 #else
00327     NodeRenderableInk* pNode = NULL;
00328 #endif
00329 
00330     if (pNode == NULL)
00331         pNode = NodeRenderableInk::FindSimpleAtPoint(pSpread,ClickPos);
00332 
00333     return pNode;
00334 }
00335 
00336 /********************************************************************************************
00337 
00338 >   BOOL ViewContextMenu::AskBlobsForItems(Spread* pSpread, DocCoord ClickPos, ClickModifiers ClickMods)
00339 
00340     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00341     Created:    07/04/95
00342     Inputs:     -
00343     Outputs:    -
00344     Returns:    TRUE if node-related menu is allowed to be opened
00345                 FALSE otherwise
00346     Purpose:    Ask the selected nodes whether they want the menu to appear and if so
00347                 to add some menu items.
00348     Errors:     -
00349 
00350 ********************************************************************************************/
00351 
00352 BOOL ViewContextMenu::AskBlobsForItems( Spread* pSpread,
00353                                         DocCoord ClickPos,
00354                                         ClickModifiers ClickMods
00355                                         )
00356 {
00357     // Test for a click on a fill attribute first, as they aren't NodeRenderableInks, and so
00358     // won't be included in the tests below.
00359 //  if (AttrFillGeometry::CheckAttrClick(ClickStart, TypeOfClick, ClickMods, StartSpread))
00360 //  {
00361 //      return TRUE;
00362 //  }
00363 
00364     // Look for a selected object to pass the click to.
00365     SelRange* pSel = GetApplication()->FindSelection();
00366     if (pSel==NULL)
00367         return FALSE;
00368 
00369     Node* pNode = pSel->FindFirst();
00370     if (pNode == NULL)
00371         return FALSE;
00372 
00373     // Providing we are displaying object blobs, try passing the click on to each object
00374     // in the selection.
00375     BlobManager* pBlobs = GetApplication()->GetBlobManager();
00376     if (pBlobs && pBlobs->GetCurrentInterest().Object)
00377     {
00378         // For all selected objects . . .
00379         while (pNode != NULL)
00380         {
00381             // Is this node ink-renderable?
00382             if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableInk)))
00383             {
00384                 // Yes.  Does it want the click?
00385                 if (((NodeRenderableInk*) pNode)->OnBlobPopUp(pSpread, ClickPos, this))
00386                 {
00387                     // An object processed the click, so indicate that there's no more to do.
00388                     return TRUE;
00389                 }
00390             }
00391 
00392             // Try the next object in the selection.
00393             pNode = pSel->FindNext(pNode);
00394         }
00395     }
00396 
00397     return FALSE;
00398 }
00399 
00400 
00401 
00402 

Generated on Sat Nov 10 03:47:21 2007 for Camelot by  doxygen 1.4.4