00001 // $Id: metaview.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 // Simple view class for metafiles to use when rendering using RenderRegions. 00100 00101 /* 00102 */ 00103 00104 #include "camtypes.h" 00105 #include "metaview.h" 00106 #include "vstate.h" 00107 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 00109 00110 CC_IMPLEMENT_DYNAMIC(MetafileView, View) 00111 00112 #define new CAM_DEBUG_NEW 00113 00114 00115 /******************************************************************************************** 00116 00117 > BOOL MetafileView::Init() 00118 00119 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00120 Created: 22/9/95 00121 Returns: TRUE if initialised ok; 00122 FALSE if not 00123 Purpose: Initialise the MetafileView for rendering. 00124 SeeAlso: MetafileView 00125 00126 ********************************************************************************************/ 00127 00128 BOOL MetafileView::Init() 00129 { 00130 // Metafiles are always exported in the same format. 00131 // This is HIENGLISH which has 1000 pixels per inch. 00132 // As a result, we know that there are 72 millipoints per pixel. 00133 PixelWidth = FIXED16(72); 00134 PixelHeight = FIXED16(72); 00135 00136 // The scaled version are the same 00137 ScaledPixelWidth = PixelWidth; 00138 ScaledPixelHeight = PixelHeight; 00139 00140 // Get ourselves a ViewState object 00141 pVState = new ViewState; 00142 if (pVState == NULL) 00143 return FALSE; 00144 00145 // Connect this view state to this view 00146 pVState->pView = this; 00147 00148 // No document for metafiles 00149 pDoc = NULL; 00150 00151 // All ok 00152 return TRUE; 00153 } 00154 00155 /******************************************************************************************** 00156 00157 > BOOL MetafileView::ViewStateChanged() 00158 00159 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00160 Created: 22/9/95 00161 Returns: TRUE (always). 00162 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00163 characteristics. 00164 SeeAlso: MetafileView 00165 00166 ********************************************************************************************/ 00167 00168 BOOL MetafileView::ViewStateChanged() 00169 { 00170 return TRUE; 00171 } 00172 00173 /******************************************************************************************** 00174 00175 > void MetafileView::SetViewPixelSize() 00176 00177 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00178 Created: 22/9/95 00179 Purpose: Sets up the pixel size for this view object. 00180 SeeAlso: MetafileView 00181 00182 ********************************************************************************************/ 00183 00184 void MetafileView::SetViewPixelSize() 00185 { 00186 // Set the scaled pixel size 00187 ScaledPixelWidth = PixelWidth; 00188 ScaledPixelHeight = PixelHeight; 00189 } 00190 00191 /******************************************************************************************** 00192 00193 > void MetafileView::ContinueRenderView(RenderRegion*, Spread*, BOOL = TRUE, BOOL = TRUE, 00194 BOOL bForceImmediate = FALSE) 00195 00196 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00197 Created: 22/9/95 00198 Inputs: N/A 00199 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00200 characteristics. 00201 SeeAlso: MetafileView 00202 Errors: Always => ERROR3 00203 00204 ********************************************************************************************/ 00205 00206 void MetafileView::ContinueRenderView(RenderRegion*, Spread*, BOOL, BOOL, 00207 BOOL bForceImmediate) 00208 { 00209 ERROR3("MetafileView::ContinueRenderView() should not be called!"); 00210 } 00211 00212 /******************************************************************************************** 00213 00214 > CDC *MetafileView::GetRenderDC() 00215 00216 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00217 Created: 22/9/95 00218 Returns: NULL (always) 00219 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00220 characteristics. 00221 SeeAlso: MetafileView 00222 00223 ********************************************************************************************/ 00224 00225 CDC *MetafileView::GetRenderDC() 00226 { 00227 return NULL; 00228 } 00229 00230 /******************************************************************************************** 00231 00232 > BOOL MetafileView::GetForeBackMode() 00233 00234 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00235 Created: 22/9/95 00236 Returns: FALSE - Metafiles don't do background rendering. 00237 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00238 characteristics. 00239 SeeAlso: MetafileView 00240 00241 ********************************************************************************************/ 00242 00243 BOOL MetafileView::GetForeBackMode() 00244 { 00245 // MetafileViews don't background render. 00246 return FALSE; 00247 } 00248 00249 /******************************************************************************************** 00250 00251 > void MetafileView::SetForeBackMode(BOOL) 00252 00253 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00254 Created: 22/9/95 00255 Inputs: N/A 00256 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00257 characteristics. 00258 SeeAlso: MetafileView 00259 Errors: ERROR3 always - dialogs cannot background render! 00260 00261 ********************************************************************************************/ 00262 00263 void MetafileView::SetForeBackMode(BOOL) 00264 { 00265 ERROR3("MetafileView::SetForeBackMode() should not be called!"); 00266 } 00267 00268 /******************************************************************************************** 00269 00270 > DocRect MetafileView::GetDocViewRect(Spread*) 00271 00272 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00273 Created: 22/9/95 00274 Inputs: N/A 00275 Returns: An empty rectangle (always). 00276 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00277 characteristics. 00278 SeeAlso: MetafileView 00279 00280 ********************************************************************************************/ 00281 00282 DocRect MetafileView::GetDocViewRect(Spread*) 00283 { 00284 DocRect Empty; 00285 return Empty; 00286 } 00287 00288 /******************************************************************************************** 00289 00290 > void MetafileView::SetExtent(DocCoord, DocCoord) 00291 00292 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00293 Created: 22/9/95 00294 Inputs: N/A 00295 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00296 characteristics. 00297 SeeAlso: MetafileView 00298 00299 ********************************************************************************************/ 00300 00301 void MetafileView::SetExtent(DocCoord, DocCoord) 00302 { 00303 } 00304 00305 /******************************************************************************************** 00306 00307 > WorkRect MetafileView::GetViewRect() 00308 00309 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00310 Created: 22/9/95 00311 Returns: An empty rectangle (always). 00312 Purpose: None - MetafileView is a skeleton class that is only used to access screen 00313 characteristics. 00314 SeeAlso: MetafileView 00315 00316 ********************************************************************************************/ 00317 00318 WorkRect MetafileView::GetViewRect() 00319 { 00320 WorkRect Empty; 00321 return Empty; 00322 } 00323 00324 00325 00326 00327 /******************************************************************************************** 00328 00329 > INT32 MetafileView::GetMetafileFlatness() 00330 00331 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00332 Created: 22/9/95 00333 Returns: The flatness to use for metafiles 00334 Purpose: Allows the format that metafiles are saved in to change, without changing 00335 everything else in the world. 00336 00337 ********************************************************************************************/ 00338 00339 INT32 MetafileView::GetMetafileFlatness() 00340 { 00341 // Say how much we are prepared to flatten paths 00342 return 1024; 00343 } 00344 00345 00346 00347 00348 /******************************************************************************************** 00349 00350 > INT32 MetafileView::GetMetafileDPI() 00351 00352 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00353 Created: 22/9/95 00354 Returns: the number of pixels per inch for the metafile we are creating 00355 Purpose: Allows the format that metafiles are saved in to change, without changing 00356 everything else in the world. 00357 00358 ********************************************************************************************/ 00359 00360 INT32 MetafileView::GetMetafileDPI() 00361 { 00362 // We are currently using HIENGLISH mapping mode, which is at 1000 dpi 00363 return 1000; 00364 } 00365 00366 00367 00368 00369 /******************************************************************************************** 00370 00371 > INT32 MetafileView::GetMetafileMapMode() 00372 00373 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00374 Created: 22/9/95 00375 Returns: The mapping mode to use for metafiles. This is currently MM_HIENGLISH 00376 Purpose: Allows the format that metafiles are saved in to change, without changing 00377 everything else in the world. 00378 00379 ********************************************************************************************/ 00380 00381 INT32 MetafileView::GetMetafileMapMode() 00382 { 00383 // return the mapping mode we want to use 00384 return MM_ANISOTROPIC; 00385 } 00386 00387 00388 00389 /******************************************************************************************** 00390 00391 > void MetafileView::GetScaleFactor(FIXED16* pXScale, FIXED16* pYScale) 00392 00393 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00394 Created: 22/9/95 00395 Outputs: pXScale, pYScale - the x and y scale factor to render the drawing to, 00396 to get the best range of values from the coord system. 00397 Purpose: Allows the format that metafiles are saved in to change, without changing 00398 everything else in the world. 00399 00400 ********************************************************************************************/ 00401 00402 void MetafileView::GetScaleFactor(FIXED16* pXScale, FIXED16* pYScale) 00403 { 00404 // boost the scale to get the most out of the coord range. 00405 // We get this figure as we need to get 1000 dpi, but a scale of 1 will give 96 dpi 00406 // ie 1000/96 = 10.42 00407 *pXScale = FIXED16(1); 00408 *pYScale = FIXED16(1); 00409 } 00410 00411