tmpltarg.cpp

Go to the documentation of this file.
00001 // $Id: tmpltarg.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 
00100 
00101 #include "camtypes.h"
00102 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00103 #include "tmpltarg.h"
00104 
00105 #if defined( __WXMSW__ )
00106 #include <comcat.h>     // should be in the slick oil registry.cpp
00107 #endif
00108 
00109 //#include "registry.h"
00110 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 
00112 
00113 /********************************************************************************************
00114 
00115 >   class WizOpProbe : public ClassCategoryProbe
00116 
00117     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
00118     Created:    09/06/97
00119 
00120     Purpose:    Searches through the (local) registry returning entries in the WizOp 
00121                 category.
00122 
00123 ********************************************************************************************/
00124 PORTNOTE("other","Removed WizOpProbe - derived from ClassCategoryProbe")
00125 #ifndef EXCLUDE_FROM_XARALX
00126 class WizOpProbe : public ClassCategoryProbe
00127 {
00128 protected:
00129     virtual const CATID& GetCategoryID() const  {   return s_WizOpCategoryCLSID;    }
00130 
00131 private:
00132     static const CATID s_WizOpCategoryCLSID;
00133 };
00134 #endif
00135 
00136 
00137 /********************************************************************************************
00138 
00139 >   class WizOpRegistryEntry : public ClassRegistryEntry
00140 
00141     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from assorted dialog classes)
00142     Created:    09/06/97
00143 
00144     Purpose:    When the WizOpProbe returns a ClassRegistryEntry it returns one of these
00145                 which can then be used to extract WizOp specific bits from the registry.
00146 
00147 ********************************************************************************************/
00148 PORTNOTE("other","Removed WizOpRegistryEntry - derived from ClassRegistryEntry")
00149 #ifndef EXCLUDE_FROM_XARALX
00150 class WizOpRegistryEntry : public ClassRegistryEntry
00151 {
00152 public:
00153     BOOL GetInternalName(StringBase* const pValue);
00154     BOOL GetUserName(StringBase* const pValue);
00155     BOOL GetParamHint(StringBase* const pValue);
00156 
00157 private:
00158 //  static const String_8 s_InternalNameKey;
00159     static const String_16 s_UserNameKey;
00160     static const String_16 s_ParamHintKey;
00161 };
00162 #endif
00163 
00164 // Place any IMPLEMENT type statements here
00165 CC_IMPLEMENT_MEMDUMP(WizOp, ListItem)
00166 CC_IMPLEMENT_MEMDUMP(WizOps, List)
00167 
00168 PORTNOTE("other","Removed bulk of WizOp*")
00169 #ifndef EXCLUDE_FROM_XARALX
00170 
00171 #ifdef TEST_WIZOPS
00172 const CATID WizOpProbe::s_WizOpCategoryCLSID = {0x40fc6ed5,0x2438,0x11cf,{0xA3,0xDB,0x08,0x00,0x36,0xF1,0x25,0x02}};
00173 #else
00174 // {21451410-E7E2-11d0-9AF6-0020AFE14B3D}
00175 const CATID WizOpProbe::s_WizOpCategoryCLSID = { 0x21451410, 0xe7e2, 0x11d0, { 0x9a, 0xf6, 0x0, 0x20, 0xaf, 0xe1, 0x4b, 0x3d } };
00176 #endif
00177 
00178 const String_16 WizOpRegistryEntry::s_UserNameKey = TEXT("UserName");
00179 const String_16 WizOpRegistryEntry::s_ParamHintKey = TEXT("ParamHint");
00180 //const String_8 WizOpRegistryEntry::s_InternalNameKey = TEXT("");
00181 
00182 
00183 // We want better memory tracking
00184 // Declare smart memory handling in Debug builds
00185 #define new CAM_DEBUG_NEW
00186 
00187 
00188 
00189 // Functions follow
00190 
00191 /********************************************************************************************
00192 
00193 >   BOOL WizOpRegistryEntry::GetInternalName(StringBase* const pValue)
00194 
00195     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00196     Created:    09/06/97
00197     
00198     Purpose:    Provides a string from this registry entry for the internal name
00199 
00200     Returns:    TRUE if it worked, FALSE if it didn't
00201     Outputs:    pValue: The string of the internal name.
00202 
00203 ********************************************************************************************/
00204 BOOL WizOpRegistryEntry::GetInternalName(StringBase* const pValue)
00205 {
00206     BOOL Ok = TRUE;
00207 
00208     VersionIndependentProgID VIPID(*this);
00209     String_128 WholeEntry;
00210 
00211     Ok = VIPID.GetName(&WholeEntry);
00212 
00213     if (Ok)
00214     {
00215         // The entry is of the form "ProgID.LongName". We want the LongName bit
00216         static const TCHAR ProgIDDelimiter = TEXT('.');
00217 
00218         INT32 StartDelimiterPosition = WholeEntry.FindNextChar(ProgIDDelimiter);
00219 
00220         const UINT32 LengthToCopy = WholeEntry.Length() - StartDelimiterPosition - 1;
00221 
00222         if (StartDelimiterPosition >= 0 && LengthToCopy > 0)
00223         {
00224             WholeEntry.Mid(pValue, StartDelimiterPosition + 1, LengthToCopy);
00225         }
00226         else
00227         {
00228             TRACE( _T("WizOpRegistryEntry::GetInternalName - no name\n"));
00229             Ok = FALSE;
00230         }
00231     }
00232 
00233     return Ok;
00234 }
00235 
00236 
00237 /********************************************************************************************
00238 
00239 >   BOOL WizOpRegistryEntry::GetUserName(StringBase* const pValue)
00240 
00241     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00242     Created:    09/06/97
00243     
00244     Purpose:    Provides a string from this registry entry for the user name
00245 
00246     Returns:    TRUE if it worked, FALSE if it didn't
00247     Outputs:    pString:    The string of the user name.
00248 
00249 ********************************************************************************************/
00250 BOOL WizOpRegistryEntry::GetUserName(StringBase* const pValue)
00251 {
00252     return GetValue(s_UserNameKey, pValue);
00253 }
00254 
00255 
00256 /********************************************************************************************
00257 
00258 >   BOOL WizOpRegistryEntry::GetParamHint(StringBase* const pValue)
00259 
00260     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00261     Created:    09/06/97
00262     
00263     Purpose:    Provides a string from this registry entry for the parameter hint
00264 
00265     Returns:    TRUE if it worked, FALSE if it didn't
00266     Outputs:    pString:    The string of the parameter hint
00267 
00268 ********************************************************************************************/
00269 BOOL WizOpRegistryEntry::GetParamHint(StringBase* const pValue)
00270 {
00271     return GetValue(s_ParamHintKey, pValue);
00272 }
00273 
00274 
00275 
00276 /*
00277 WizOps& g_WizOps()
00278 {
00279     static WizOps g_WizOps;
00280 
00281     return g_WizOps;
00282 }
00283 */
00284 
00285 #endif
00286 
00287 WizOps& GetWizOps()
00288 {
00289     // This static dummy object is used for returning in the ERROR2 case
00290     // The original used to return a ptr to a local variable, which is a tad dangerous.
00291     // This solution is not ideal, because there's a permanent instance of an object
00292     // that will probably never be used.
00293     static WizOps DummyOps;
00294 
00295     WizOps* const pWizOps = GetApplication()->GetWizOps();
00296     ERROR2IF(pWizOps == NULL, DummyOps, "No WizOps");
00297 
00298     return *pWizOps;
00299 }
00300 
00301 
00302 
00303 
00304 /********************************************************************************************
00305 
00306 >   WizOps::~WizOps()
00307 
00308     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00309     Created:    09/06/97
00310     
00311     Purpose:    We need an overridden destructor to delete the WizOp's we stuck on the heap.
00312 
00313 ********************************************************************************************/
00314 WizOps::~WizOps()
00315 {
00316 //  TRACE( _T("Deleting those WizOps now\n"));
00317     DeleteAll();
00318 }
00319 
00320 
00321 
00322 /********************************************************************************************
00323 
00324 >   BOOL WizOps::InitializeFromRegistry()
00325 
00326     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00327     Created:    09/06/97
00328     
00329     Purpose:    Goes whizzing through the registry to find all the WizOp's in it. Then
00330                 builds this WizOps collection using those entries.
00331 
00332 ********************************************************************************************/
00333 BOOL WizOps::InitializeFromRegistry()
00334 {
00335 
00336     PORTNOTETRACE("other"," WizOps::InitializeFromRegistry - do nothing");
00337 #ifndef EXCLUDE_FROM_XARALX
00338     BOOL Ok = TRUE;
00339     WizOpProbe Probe;
00340     GetLocalRegistry()->InitializeProbe(Probe);
00341     
00342     while (!Probe.IsLast() && Ok)
00343     {
00344         WizOpRegistryEntry Entry;
00345         // The internal name is given by the registry entry
00346         Ok = Probe.GetNextEntry(&Entry);
00347         
00348         String_64 InternalName;
00349         if (Ok)
00350         {   
00351             Ok = Entry.GetInternalName(&InternalName);
00352         }
00353 
00354         String_64 UserName;
00355         if (Ok)
00356         {   
00357             Entry.GetUserName(&UserName);
00358             if (UserName.IsEmpty())
00359             {
00360                 UserName = InternalName;
00361             }
00362         }
00363 
00364         String_256 ParamHint;
00365         if (Ok)
00366         {   
00367             Entry.GetParamHint(&ParamHint);
00368         }
00369 
00370         if (Ok)
00371         {   
00372             Ok = AddWizOp(InternalName, UserName, ParamHint);
00373         }
00374     }
00375 
00376     if (!Ok)
00377     {
00378         TRACE( _T("Not all WizOps were created properly\n"));
00379     }
00380 #endif
00381     return TRUE;    // we'll pretend it worked 'cos otherwise camelot won't start
00382 }
00383 
00384 
00385 /********************************************************************************************
00386 
00387 >   BOOL WizOps::AddWizOp(  const StringBase& InternalName, const StringBase& UserName,
00388                             const StringBase& ParamHint)
00389 
00390     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00391     Created:    09/06/97
00392     
00393     Purpose:    Adds a WizOp with the given gubbins to this set.
00394 
00395     Returns:    TRUE if if worked FALSE if it didn't
00396 
00397 ********************************************************************************************/
00398 BOOL WizOps::AddWizOp(  const StringBase& InternalName, const StringBase& UserName,
00399                         const StringBase& ParamHint)
00400 {
00401     BOOL Success = TRUE;
00402 
00403     WizOp* const pNewWizOp = new WizOp(InternalName, UserName, ParamHint);
00404 
00405     if (pNewWizOp != NULL)
00406     {
00407         AddTail(pNewWizOp);
00408     }
00409     else
00410     {
00411         Success = FALSE;
00412     }
00413 
00414     return Success;
00415 }
00416 
00417 
00418 
00419 /********************************************************************************************
00420 
00421 >   WizOp* WizOps::GetFirstWizOp() const
00422 
00423     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00424     Created:    09/06/97
00425     
00426     Purpose:    Cheapskate duplicate code container enumeration
00427 
00428     Returns:    The first WizOp in the set
00429 
00430 ********************************************************************************************/
00431 WizOp* WizOps::GetFirstWizOp() const
00432 {
00433     return (WizOp*)GetHead();
00434 }
00435 
00436 
00437 /********************************************************************************************
00438 
00439 >   WizOp* WizOps::GetNextWizOp(const WizOp* const pWizOp) const
00440 
00441     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00442     Created:    09/06/97
00443     
00444     Purpose:    Cheapskate duplicate code container enumeration
00445 
00446     Inputs:     pWizOp: Don't know why it's a pointer.
00447     Returns:    The WizOp after the given one in the set
00448 
00449 ********************************************************************************************/
00450 WizOp* WizOps::GetNextWizOp(const WizOp* const pWizOp) const
00451 {
00452     return (WizOp*)GetNext(pWizOp);
00453 }
00454 
00455 
00456 /********************************************************************************************
00457 
00458 >   WizOp* WizOps::FindWizOpFromInternalName(const StringBase& InternalName) const
00459 
00460     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00461     Created:    09/06/97
00462     
00463     Purpose:    Allows access to the WizOp's vital statistics
00464 
00465     Inputs:     InternalName :  The InternalName of the desired WizOp
00466     Returns:    NULL if none found
00467                 The WizOp with the InternalName (CLSID), given in the constructor,
00468                 InternalName.
00469 
00470 ********************************************************************************************/
00471 WizOp* WizOps::FindWizOpFromInternalName(const StringBase& InternalName) const
00472 {
00473     WizOp* pWizOp = GetFirstWizOp();
00474 
00475     BOOL Found = FALSE;
00476     while (pWizOp != NULL && !Found)
00477     {
00478         if (pWizOp->GetInternalName() == InternalName)
00479         {
00480             Found = TRUE;
00481         }
00482 
00483         if (!Found)
00484         {
00485             pWizOp = GetNextWizOp(pWizOp);
00486         }
00487     }
00488 
00489     return pWizOp;
00490 }
00491 
00492 
00493 
00494 
00495 
00496 
00497 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00498 //                                  W  I  Z  O  P
00499 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00500 
00501 
00502 
00503 
00504 
00505 
00506 /********************************************************************************************
00507 
00508 >   WizOp::WizOp(   const StringBase& InternalName, const StringBase& UserName, 
00509                     const StringBase& ParamHint)
00510 
00511     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00512     Created:    09/06/97
00513     
00514     Purpose:    This constructor provides the Wizard Properties with something to talk about.
00515 
00516     Inputs:     InternalName :  a persistant identifier for the WizOp. The CLSID of the entry
00517                                 extracted from the registry would be good.
00518                 UserName :      the text that will appear in the Wizard Properties dialog.
00519                                 The "UserName" subkey under the InternalName (CLSID) is good.
00520                 ParamHint:      If the WizOp can accept a parameter this string should
00521                                 contain some text explaining what it is.
00522 
00523 ********************************************************************************************/
00524 WizOp::WizOp(   const StringBase& InternalName, const StringBase& UserName, 
00525                 const StringBase& ParamHint) :
00526     m_Name(InternalName),
00527     m_UserName(UserName),
00528     m_ParamHint(ParamHint)
00529 {
00530 }
00531 
00532 
00533 /********************************************************************************************
00534 
00535 >   const StringBase& WizOp::GetInternalName() const
00536 >   const StringBase& WizOp::GetUserName() const
00537 >   const StringBase& WizOp::GetParamHint() const
00538 
00539     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00540     Created:    09/06/97
00541     
00542     Purpose:    Allows access to the WizOp's vital statistics
00543 
00544     Returns:    Strings of things
00545 
00546 ********************************************************************************************/
00547 const StringBase& WizOp::GetInternalName() const
00548 {
00549     return (StringBase&)m_Name;
00550 }
00551 
00552 
00553 const StringBase& WizOp::GetUserName() const
00554 {
00555     return (StringBase&)m_UserName;
00556 }
00557 
00558 
00559 const StringBase& WizOp::GetParamHint() const
00560 {
00561     return (StringBase&)m_ParamHint;
00562 }

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