Bugfix : Zooming works correct, no more errors on screen.
[xara-cairo.git] / wxOil / fixst256.cpp
blobaa68dc68daef57b0ce3237343a5a5cb4cbc9b0bb
1 // $Id: fixst256.cpp 1283 2006-06-09 10:45:34Z alex $
2 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
3 ================================XARAHEADERSTART===========================
5 Xara LX, a vector drawing and manipulation program.
6 Copyright (C) 1993-2006 Xara Group Ltd.
7 Copyright on certain contributions may be held in joint with their
8 respective authors. See AUTHORS file for details.
10 LICENSE TO USE AND MODIFY SOFTWARE
11 ----------------------------------
13 This file is part of Xara LX.
15 Xara LX is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License version 2 as published
17 by the Free Software Foundation.
19 Xara LX and its component source files are distributed in the hope
20 that it will be useful, but WITHOUT ANY WARRANTY; without even the
21 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License along
25 with Xara LX (see the file GPL in the root directory of the
26 distribution); if not, write to the Free Software Foundation, Inc., 51
27 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 ADDITIONAL RIGHTS
31 -----------------
33 Conditional upon your continuing compliance with the GNU General Public
34 License described above, Xara Group Ltd grants to you certain additional
35 rights.
37 The additional rights are to use, modify, and distribute the software
38 together with the wxWidgets library, the wxXtra library, and the "CDraw"
39 library and any other such library that any version of Xara LX relased
40 by Xara Group Ltd requires in order to compile and execute, including
41 the static linking of that library to XaraLX. In the case of the
42 "CDraw" library, you may satisfy obligation under the GNU General Public
43 License to provide source code by providing a binary copy of the library
44 concerned and a copy of the license accompanying it.
46 Nothing in this section restricts any of the rights you have under
47 the GNU General Public License.
50 SCOPE OF LICENSE
51 ----------------
53 This license applies to this program (XaraLX) and its constituent source
54 files only, and does not necessarily apply to other Xara products which may
55 in part share the same code base, and are subject to their own licensing
56 terms.
58 This license does not apply to files in the wxXtra directory, which
59 are built into a separate library, and are subject to the wxWindows
60 license contained within that directory in the file "WXXTRA-LICENSE".
62 This license does not apply to the binary libraries (if any) within
63 the "libs" directory, which are subject to a separate license contained
64 within that directory in the file "LIBS-LICENSE".
67 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
68 ----------------------------------------------
70 Subject to the terms of the GNU Public License (see above), you are
71 free to do whatever you like with your modifications. However, you may
72 (at your option) wish contribute them to Xara's source tree. You can
73 find details of how to do this at:
74 http://www.xaraxtreme.org/developers/
76 Prior to contributing your modifications, you will need to complete our
77 contributor agreement. This can be found at:
78 http://www.xaraxtreme.org/developers/contribute/
80 Please note that Xara will not accept modifications which modify any of
81 the text between the start and end of this header (marked
82 XARAHEADERSTART and XARAHEADEREND).
85 MARKS
86 -----
88 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
89 designs are registered or unregistered trademarks, design-marks, and/or
90 service marks of Xara Group Ltd. All rights in these marks are reserved.
93 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
94 http://www.xara.com/
96 =================================XARAHEADEREND============================
99 #include "camtypes.h"
100 //#include "fixst256.h" - in camtypes.h [AUTOMATICALLY REMOVED]
102 DEFINE_BUFSIZE(256);
105 /**************************************************************************************
106 > String_256::String_256(const TCHAR* psz = 0)
108 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
109 Created: 12th August 1993
110 Inputs: An optional pointer to a (constant) Unicode character array - if
111 omitted then the String becomes empty (NOT the null pointer).
112 Purpose: Constructs a string of the appropriate maximum length.
113 Errors: ASSERTion failure if the passed character array is too long for
114 this length of string, or if psz is NULL.
115 Scope: Public
116 ***************************************************************************************/
118 String_256::String_256(const TCHAR* psz)
120 *(text = fixedbuf) = 0;
121 length = FIX_LEN_BUFSIZE;
122 if (psz != 0)
124 ERROR3IF(camStrlen(psz) >= length, "String_256::String_256 overflow");
125 camStrcpy(text, psz);
131 /**************************************************************************************
132 > String_256::String_256( PCSTR psz )
134 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
135 Created: 12th August 1993
136 Inputs: An optional pointer to a (constant) Unicode character array - if
137 omitted then the String becomes empty (NOT the null pointer).
138 Purpose: Constructs a string of the appropriate maximum length.
139 Errors: ASSERTion failure if the passed character array is too long for
140 this length of string, or if psz is NULL.
141 Scope: Public
142 ***************************************************************************************/
144 #if 0 != wxUSE_UNICODE
145 String_256::String_256( PCSTR psz )
147 *(text = fixedbuf) = 0;
148 length = FIX_LEN_BUFSIZE;
149 if (psz != 0)
151 ERROR3IF( strlen(psz) >= length, "String_256::String_256 overflow" );
152 camMbstowcs( text, psz, FIX_LEN_BUFSIZE );
155 #endif
157 /**************************************************************************************
158 > String_256::String_256(const StringBase& other)
160 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
161 Created: 12th August 1993
162 Inputs: A constant reference to another string (can be of any length)
163 Purpose: Duplicates the text of the other string.
164 Errors: ASSERTion failure if this string is not long enough to hold a copy
165 of the other string's text, or if the copied String has not been
166 allocated.
167 Scope: Public
168 ***************************************************************************************/
170 void String_256::CopyConstruct( const StringBase &other )
172 *(text = fixedbuf) = 0;
173 length = FIX_LEN_BUFSIZE;
174 ERROR3IF((const TCHAR*) other == 0, "StringBase to be copied has not been ALLOCated");
175 ERROR3IF(camStrlen((const TCHAR*) other) >= length,
176 "Constructed String_256 not large enough to hold StringBase copy");
177 camStrcpy(text, (const TCHAR*) other);
183 /**************************************************************************************
184 > String_256::String_256(UINT32 resID, UINT32 hinst = 0)
186 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
187 Created: 12th August 1993
188 Inputs: A string resource numeric identifier, an optional resource module
189 handle (if not supplied, the default resource module is used).
190 Purpose: Loads the string resource into this String.
191 Errors: ENSURE failure if this string is not long enough to hold the
192 resource, or if the resource cannot be found in the module. If it cannot
193 be found, a very short temp string is built of the form "<%X:%X>" containing
194 the ID and the module number, or if that is too long then simply "!".
195 Scope: Public
196 SeeAlso: SmartLoadString
197 ***************************************************************************************/
199 String_256::String_256(UINT32 resID, UINT32 hinst)
201 *(text = fixedbuf) = 0;
202 length = FIX_LEN_BUFSIZE;
203 if (!Load(resID, hinst))
205 ERROR3("String resource failed to load");
206 TCHAR buf[128];
207 camSnprintf(buf, 128, TEXT("<%X:%X>"), (INT32) resID, (INT32) hinst);
208 camStrcpy(text, (camStrlen(buf) <= 256) ? buf : TEXT("!"));
214 /**************************************************************************************
215 > String_256::String_256(const wxString& wxs)
217 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
218 Created: 28th January 2006
219 Inputs: A wxString
220 Purpose: Constructs a string of the appropriate maximum length.
221 Errors: ASSERTion failure if the passed character array is too long for
222 this length of string, or if psz is NULL.
223 Scope: Public
224 ***************************************************************************************/
226 String_256::String_256(const wxString& wxs)
228 *(text = fixedbuf) = 0;
229 length = FIX_LEN_BUFSIZE;
230 ERROR3IF(wxs.Len() >= length, "String_256::String_256 overflow");
231 camStrcpy(text, (LPCTSTR)wxs);
236 /**************************************************************************************
237 > virtual BOOL String_256::Alloc(INT32 nSize)
239 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> & Andy
240 Created: 12th August 1993
241 Purpose: Fixes Alloc() for fixed-length strings, which CAN be safely changed#
242 to use a buffer on the heap.
243 Scope: Public
244 SeeAlso: StringBase::Alloc
245 ***************************************************************************************/
247 BOOL String_256::Alloc(INT32 nSize)
249 if (text == fixedbuf) text = 0;
250 return StringBase::Alloc(nSize);