colmenu.cpp

Go to the documentation of this file.
00001 // $Id: colmenu.cpp 1149 2006-05-22 08:50:00Z 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 the Colour Editor
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 #include "coldlog.h"
00107 #include "colmenu.h"
00108 //#include "galstr.h"
00109 //#include "jason.h"
00110 
00111 //#include "will2.h"
00112 
00113 DECLARE_SOURCE("$Revision: 1149 $");
00114 
00115 
00116 CC_IMPLEMENT_MEMDUMP(ColEditContextMenu, ContextMenu)
00117 CC_IMPLEMENT_DYNCREATE(OpColEditCommand, Operation);
00118 
00119 
00120 #define new CAM_DEBUG_NEW
00121 
00122 
00123 
00124 String_32 ColCmd_Help(_T("ColEdit:Help"));
00125 String_32 ColCmd_Name(_T("ColEdit:Name"));
00126 String_32 ColCmd_HSV(_T("ColEdit:HSV"));
00127 String_32 ColCmd_RGB(_T("ColEdit:RGB"));
00128 String_32 ColCmd_CMYK(_T("ColEdit:CMYK"));
00129 String_32 ColCmd_Grey(_T("ColEdit:Grey"));
00130 String_32 ColCmd_EditParent(_T("ColEdit:EditParent"));
00131 #ifdef WEBSTER
00132 String_32 ColCmd_NewNColour(_T("ColEdit:NewNColour"));
00133 #endif //WEBSTER
00134 
00135 
00136 
00137 /********************************************************************************************
00138 
00139 >   ColEditContextMenu::ColEditContextMenu()
00140 
00141     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00142     Created:    3/10/95
00143 
00144     Purpose:    To construct ;-)
00145 
00146 ********************************************************************************************/
00147 
00148 ColEditContextMenu::ColEditContextMenu()
00149 {
00150 }
00151 
00152 
00153 
00154 /********************************************************************************************
00155 
00156 >   virtual BOOL ColEditContextMenu::Build(void)
00157 
00158     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00159     Created:    3/10/95
00160 
00161     Returns:    TRUE if menu built OK
00162                 FALSE (and sets error) otherwise
00163 
00164     Purpose:    To build the colour editor pop-up menu. (Called when the window is adjust-clicked)
00165 
00166 ********************************************************************************************/
00167 
00168 BOOL ColEditContextMenu::Build(void)
00169 {
00170     BOOL ok = TRUE;
00171 
00172 // WEBSTER - Martin 11/07/97
00173 // Edit of the drop down colour model menu list
00174 #ifdef WEBSTER
00175     if (ok) ok = ok && BuildCommand(ColCmd_NewNColour);         // New named colour
00176 #endif // WEBSTER
00177     if (ok) ok = ok && BuildCommand(ColCmd_Name);               // Rename
00178     if (ok) ok = ok && BuildCommand(ColCmd_EditParent, TRUE);   // Edit Parent - With a separator
00179 
00180     if (ok) ok = ok && BuildCommand(ColCmd_HSV);                // Change colour model
00181     if (ok) ok = ok && BuildCommand(ColCmd_RGB,TRUE);
00182 
00183 #ifndef WEBSTER
00184     if (ok) ok = ok && BuildCommand(ColCmd_CMYK);
00185     if (ok) ok = ok && BuildCommand(ColCmd_Grey, TRUE);         // Plus a separator
00186 #endif // WEBSTER
00187 
00188     if (ok) ok = ok && BuildCommand(ColCmd_Help);               // Help
00189     
00190     return(ok);
00191 }
00192 
00193 
00194 
00195 
00196 
00197 
00198 //-------------------------------------------------------------------------------------------
00199 //- Polymorphic gallery menu-item Ops
00200 
00201 
00202 /********************************************************************************************
00203 
00204 >   static BOOL OpColEditCommand::InitPolymorphicCommand(StringBase *OpToken, UINT32 MenuTextID)
00205 
00206     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00207     Created:    3/10/95
00208 
00209     Inputs:     OpToken - The OpToken for the new Op - use "ColEdit_Command"
00210 
00211                 MenuTextID - A String Resource ID for the menu item text
00212 
00213     Returns:    TRUE if it succeeded, FALSE if not enough memory to register the OpDescriptor
00214 
00215     Purpose:    Given a command OpToken, this creates a new OpDescriptor for the OpColEditCommand Op.
00216                 This in turn will provide an Upcall to the Editor containing the given command
00217                 string, whenever the Op is invoked.
00218 
00219 ********************************************************************************************/
00220 
00221 BOOL OpColEditCommand::InitPolymorphicCommand(StringBase *OpToken, UINT32 MenuTextID)
00222 {
00223     return(RegisterOpDescriptor(0,                                  // Tool ID 
00224                                 MenuTextID,                         // String resource ID
00225                                 CC_RUNTIME_CLASS(OpColEditCommand), // Runtime class
00226                                 (TCHAR *) (*OpToken),               // Token string
00227                                 OpColEditCommand::GetCommandState,  // GetState function
00228                                 0,                                  // help ID
00229                                 0,                                  // bubble help
00230                                 0,                                  // resource ID
00231                                 0,                                  // control ID
00232                                 SYSTEMBAR_ILLEGAL,                  // Bar ID
00233                                 FALSE,                              // Recieve system messages
00234                                 FALSE,                              // Smart duplicate operation
00235                                 TRUE,                               // Clean operation
00236                                 NULL,                               // No vertical counterpart
00237                                 0,                                  // String for one copy only error
00238                                 DONT_GREY_WHEN_SELECT_INSIDE        // Auto state flags
00239                                 ));
00240 }
00241 
00242 
00243 
00244 /********************************************************************************************
00245 
00246 >   static BOOL OpColEditCommand::Init(void)
00247 
00248     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00249     Created:    3/10/95
00250 
00251     Returns:    TRUE if the operation could be successfully initialised 
00252                 FALSE if no more memory could be allocated 
00253 
00254     Purpose:    OpColEditCommand initialiser method.
00255 
00256     Notes:      Initialises all of the commands available to the colour editor
00257 
00258     SeeAlso:    SuperGallery::InitMenuCommand
00259 
00260 ********************************************************************************************/
00261 
00262 BOOL OpColEditCommand::Init(void)
00263 {
00264 #ifdef WEBSTER
00265     InitPolymorphicCommand((StringBase *) &ColCmd_NewNColour, _R(IDS_NEWCOLOUR));
00266 #endif // WEBSTER
00267     InitPolymorphicCommand((StringBase *) &ColCmd_Name, _R(IDS_SGMENU_RENAME));
00268     InitPolymorphicCommand((StringBase *) &ColCmd_EditParent, _R(IDS_COLMENU_EDITPARENT));
00269 
00270     InitPolymorphicCommand((StringBase *) &ColCmd_HSV, _R(IDS_COLMODEL_HSVT));
00271     InitPolymorphicCommand((StringBase *) &ColCmd_RGB, _R(IDS_COLMODEL_RGBT));
00272     InitPolymorphicCommand((StringBase *) &ColCmd_CMYK, _R(IDS_COLMODEL_CMYK));
00273     InitPolymorphicCommand((StringBase *) &ColCmd_Grey, _R(IDS_COLMODEL_GREY));
00274 
00275     InitPolymorphicCommand((StringBase *) &ColCmd_Help, _R(IDS_COLMENU_HELP));
00276 
00277     return (TRUE);
00278 }               
00279 
00280 
00281 
00282 /********************************************************************************************
00283 
00284 >   static OpState OpColEditCommand::GetCommandState(String_256 *UIDescription,
00285                                                         OpDescriptor *pOpDesc)
00286 
00287     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00288     Created:    3/10/95
00289 
00290     Inputs:     UIDescription - ptr to a string to place a description of what went wrong (if it did!)
00291                 OpDesc  - The OpDescriptor for which we need the state
00292 
00293     Outputs:    UIDescription is updated appropriately
00294 
00295     Returns:    The state of the OpColEditCommand operation for the given OpDescriptor
00296     Purpose:    For finding OpColEditCommand's state. 
00297 
00298 ********************************************************************************************/
00299 
00300 OpState OpColEditCommand::GetCommandState(String_256 *UIDescription, OpDescriptor *pOpDesc)
00301 {
00302     if (ColourEditDlg::TheEditor != NULL)
00303         return(ColourEditDlg::TheEditor->GetCommandState(&pOpDesc->Token, UIDescription));
00304 
00305     // else return a "safe" shaded state
00306     OpState OpSt;
00307     OpSt.Greyed = TRUE;
00308     *UIDescription = String_256(_R(IDS_K_COLMENU_NOEDITOR));
00309     return (OpSt); 
00310 }
00311 
00312 
00313 
00314 /********************************************************************************************
00315 
00316 >   void OpColEditCommand::Do(OpDescriptor* pOpDesc)
00317 
00318     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00319     Created:    3/10/95
00320     Inputs:     pOpDesc = ptr to the op descriptor
00321     Outputs:    -
00322     Returns:    -
00323     Purpose:    The nudge op's Do() function.
00324     Errors:     -
00325     SeeAlso:    -
00326 
00327 ********************************************************************************************/
00328 
00329 void OpColEditCommand::Do(OpDescriptor* pOpDesc)
00330 {  
00331     if (ColourEditDlg::TheEditor != NULL)
00332         ColourEditDlg::TheEditor->DoCommand(&pOpDesc->Token);
00333 
00334     End();
00335 }
00336 

Generated on Sat Nov 10 03:44:51 2007 for Camelot by  doxygen 1.4.4