00001 // $Id: prvwmenu.cpp 1482 2006-07-20 10:23:23Z luke $ 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 // A simple Dialog That does some Gavin Rendering into itself 00099 00100 /* 00101 Code for the colour selector tool added 22/07/99 ap 00102 */ 00103 00104 #include "camtypes.h" 00105 00106 #include "prvwmenu.h" 00107 #include "bmpexprw.h" 00108 //#include "exprwres.h" 00109 00110 00111 // This is not compulsory, but you may as well put it in so that the correct version 00112 // of your file can be registered in the .exe 00113 DECLARE_SOURCE("$Revision: 1482 $"); 00114 00115 // An implement to match the Declare in the .h file. 00116 // If you have many classes, it is recommended to place them all together, here at the start of the file 00117 CC_IMPLEMENT_DYNCREATE(OpPreviewPopupCommand, Operation) 00118 00119 BitmapExportPreviewDialog *OpPreviewPopupCommand::m_pDialog = NULL; 00120 00121 // This will get Camelot to display the filename and linenumber of any memory allocations 00122 // that are not released at program exit 00123 #define new CAM_DEBUG_NEW 00124 00125 00126 00127 /******************************************************************************************** 00128 > virtual BOOL PreviewContextMenu :: Build() 00129 00130 Author: Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 00131 Created: 10/5/97 00132 Inputs: - 00133 Outputs: - 00134 Returns: - 00135 Purpose: Builds the context menu 00136 ********************************************************************************************/ 00137 00138 BOOL PreviewContextMenu :: Build() 00139 { 00140 BOOL ok = TRUE; 00141 00142 if (ok) ok = ok && BuildCommand(OPTOKEN_PREVIEW_ZOOM_TOOL); 00143 if (ok) ok = ok && BuildCommand(OPTOKEN_PREVIEW_PUSH_TOOL); 00144 if (ok) ok = ok && BuildCommand(OPTOKEN_PREVIEW_COLOUR_SELECTOR_TOOL); 00145 if (ok) ok = ok && BuildCommand(OPTOKEN_PREVIEW_ZOOM_TO_FIT); 00146 if (ok) ok = ok && BuildCommand(OPTOKEN_PREVIEW_ZOOM_TO_100); 00147 if (ok) ok = ok && BuildCommand(OPTOKEN_PREVIEW_1TO1, TRUE); 00148 if (ok) ok = ok && BuildCommand(OPTOKEN_PREVIEW_HELP); 00149 00150 return (ok); 00151 } 00152 00153 00154 00155 00156 00157 /******************************************************************************************** 00158 > static BOOL OpPreviewPopupCommand::InitPolymorphicCommand(TCHAR *OpToken, UINT32 MenuTextID) 00159 00160 Author: Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 00161 Created: 10/5/97 00162 Inputs: OpToken - the token of a menu operation 00163 MenuTextID - the resource string of the menu command 00164 Outputs: - 00165 Returns: - 00166 Purpose: Registeres a menu operation 00167 ********************************************************************************************/ 00168 00169 BOOL OpPreviewPopupCommand::InitPolymorphicCommand(TCHAR *OpToken, UINT32 MenuTextID) 00170 { 00171 return(RegisterOpDescriptor(0, // Tool ID 00172 MenuTextID, // String resource ID 00173 CC_RUNTIME_CLASS(OpPreviewPopupCommand),// Runtime class 00174 OpToken, // Token string 00175 OpPreviewPopupCommand::GetCommandState, // GetState function 00176 0, // help ID 00177 0, // bubble help 00178 0, // resource ID 00179 0, // control ID 00180 SYSTEMBAR_ILLEGAL, // Bar ID 00181 FALSE, // Receive system messages 00182 FALSE, // Smart duplicate operation 00183 TRUE, // Clean operation 00184 NULL, // No vertical counterpart 00185 0, // String for one copy only error 00186 DONT_GREY_WHEN_SELECT_INSIDE // Auto state flags 00187 )); 00188 } 00189 00190 00191 00192 /******************************************************************************************** 00193 > static BOOL OpPreviewPopupCommand::Init(void) 00194 00195 Author: Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 00196 Created: 10/5/97 00197 Inputs: - 00198 Outputs: - 00199 Returns: - 00200 Purpose: Registeres all the menu operations by calling InitPolymorphicCommand 00201 ********************************************************************************************/ 00202 00203 BOOL OpPreviewPopupCommand::Init(void) 00204 { 00205 InitPolymorphicCommand(OPTOKEN_PREVIEW_ZOOM_TOOL, _R(IDS_MENU_ZOOM)); 00206 InitPolymorphicCommand(OPTOKEN_PREVIEW_PUSH_TOOL, _R(IDS_MENU_PUSH)); 00207 InitPolymorphicCommand(OPTOKEN_PREVIEW_COLOUR_SELECTOR_TOOL, _R(IDS_MENU_SELECTOR)); 00208 InitPolymorphicCommand(OPTOKEN_PREVIEW_ZOOM_TO_FIT, _R(IDS_MENU_FIT)); 00209 InitPolymorphicCommand(OPTOKEN_PREVIEW_ZOOM_TO_100, _R(IDS_MENU_100)); 00210 InitPolymorphicCommand(OPTOKEN_PREVIEW_1TO1, _R(IDS_MENU_1TO1)); 00211 InitPolymorphicCommand(OPTOKEN_PREVIEW_HELP, _R(IDS_PREVIEW_MENU_HELP)); 00212 00213 return (TRUE); 00214 } 00215 00216 00217 00218 /******************************************************************************************** 00219 00220 > static OpState OpPreviewPopupCommand::GetCommandState(String_256 *UIDescription, 00221 OpDescriptor *pOpDesc) 00222 00223 Author: Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 00224 Created: 10/5/97 00225 00226 Inputs: UIDescription - ptr to a string to place a description of what went wrong 00227 (if it did!) 00228 OpDesc - The OpDescriptor for which we need the state 00229 00230 Outputs: UIDescription is updated appropriately 00231 00232 Returns: The state of the OpPreviewPopupCommand operation for the given OpDescriptor 00233 Purpose: For finding OpPreviewPopupCommand's state. Used only to tick the proper tool, 00234 depending on the current mode 00235 00236 ********************************************************************************************/ 00237 00238 OpState OpPreviewPopupCommand::GetCommandState(String_256 *UIDescription, OpDescriptor *pOpDesc) 00239 { 00240 OpState OpSt; 00241 OpSt.Greyed = FALSE; //always active 00242 // tick either the push or the zoom tool depending on the current mode 00243 if (((pOpDesc->Token == String_256(OPTOKEN_PREVIEW_PUSH_TOOL)) && 00244 (m_pDialog->GetCurrentTool() == PREVIEW_PUSH_TOOL)) || 00245 ((pOpDesc->Token == String_256(OPTOKEN_PREVIEW_ZOOM_TOOL)) && 00246 (m_pDialog->GetCurrentTool() == PREVIEW_ZOOM_TOOL)) || 00247 ((pOpDesc->Token == String_256(OPTOKEN_PREVIEW_COLOUR_SELECTOR_TOOL)) && 00248 (m_pDialog->GetCurrentTool() == PREVIEW_COLOUR_SELECTOR_TOOL))) 00249 OpSt.Ticked = TRUE; 00250 00251 return (OpSt); 00252 } 00253 00254 00255 /******************************************************************************************** 00256 > virtual void OpPreviewPopupCommand::Do(OpDescriptor* pOpDesc) 00257 00258 Author: Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 00259 Created: 10/5/97 00260 Inputs: pOpDesc - the descriptor of the operation 00261 Outputs: - 00262 Returns: - 00263 Purpose: Passes the token of the selected menu command to the dialog so it can be 00264 handled there 00265 ********************************************************************************************/ 00266 00267 void OpPreviewPopupCommand::Do(OpDescriptor* pOpDesc) 00268 { 00269 // get the token 00270 String_256 s(pOpDesc->Token); 00271 00272 // ask the dialog to handle it 00273 m_pDialog->DoCommand(&s); 00274 00275 End(); 00276 } 00277