00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #ifndef INC_CAMRESOURCE
00100 #define INC_CAMRESOURCE
00101
00102
00103
00104 #if 0 != wxUSE_UNICODE
00105 #define _RESQUOTE(x) L ## #x
00106 #else
00107 #define _RESQUOTE(x) #x
00108 #endif
00109 #define _R(x) ( CamResource::GetResourceID( _RESQUOTE(x)) )
00110
00111 #include "ccobject.h"
00112
00113 class CCLexFile;
00114 class wxFSFile;
00115 class wxBimtap;
00116 class wxAdvSplashScreen;
00117 class wxHelpProvider;
00118
00119 typedef UINT32 ResourceID;
00120
00121
00122 typedef const TCHAR * ResourceString;
00123
00124
00125 WX_DECLARE_HASH_MAP( ResourceID, ResourceString, wxIntegerHash, wxIntegerEqual, ResIDToString );
00126 WX_DECLARE_HASH_MAP( ResourceString, wxImage *, wxStringHash, wxStringEqual, ResourceStringToBitmap);
00127
00128
00129 extern wxImage imageBevelTool;
00130 extern wxImage imageBezTool;
00131 extern wxImage imageBlendTool;
00132
00133
00134
00135 extern wxImage imageContourTool;
00136 extern wxImage imageElipTool;
00137 extern wxImage imageFHandTool;
00138 extern wxImage imageGradTool;
00139 extern wxImage imageLiveEffectTool;
00140 extern wxImage imageMouldTool;
00141 extern wxImage imagePenTool;
00142 extern wxImage imagePush;
00143 extern wxImage imageRectTool;
00144 extern wxImage imageRegShapeTool;
00145 extern wxImage imageSelTool;
00146 extern wxImage imageShadrwTool;
00147 extern wxImage imageSlicetool;
00148 extern wxImage imageTextTool;
00149 extern wxImage imageTransTool;
00150 extern wxImage imageZoomTool;
00151
00152 class CamResourceRemember;
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 class CamResource : public CCObject
00200 {
00201 CC_DECLARE_DYNCREATE( CamResource )
00202
00203
00204
00205 public:
00206 CamResource();
00207 virtual ~CamResource();
00208
00209 private:
00210 CCLexFile * pFile;
00211 void * pMemory;
00212 UINT32 Size;
00213 wxFSFile * pwxFSFile;
00214 static wxFileSystem * pwxFileSystem;
00215 static wxLocale * m_pLocale;
00216 static wxHelpProvider * m_pHelpProvider;
00217 static BOOL s_GenerateXRCCheck;
00218
00219 public:
00220 CCLexFile * Open ( ResourceID ID, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE);
00221 CCLexFile * Open ( const TCHAR * pFileName, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE);
00222 wxFSFile * OpenwxFSFile (ResourceID ID);
00223 wxFSFile * OpenwxFSFile (const TCHAR * pFileName);
00224 void Close();
00225 CCLexFile * Get () {return pFile;}
00226 wxFSFile * GetwxFSFile () {return pwxFSFile;}
00227
00228
00229
00230 private:
00231 static void AddStringResource(const TCHAR * name, const TCHAR * text, ResourceID r=0);
00232 static void RememberDuringStaticInit(const TCHAR * ObjectName);
00233 static BOOL ReadStringTableFile();
00234 static void ProcessWindowAndChildren(wxWindow * pWindow);
00235 static void GetBinaryFileInfo (void **pPtr, UINT32 *pSize);
00236 static BOOL InitXmlResource();
00237 static BOOL Splash();
00238 static BOOL CheckResourcePath( const wxString &str1, const wxString &str2 );
00239 static const TCHAR * FixObjectName(const TCHAR * ObjectName);
00240 static BOOL AddBitmaps(wxString &Path);
00241 static BOOL LoadBitmaps();
00242 static void DeleteBitmapHashEntries();
00243 static void MakeVariantBitmaps(ResourceStringToBitmap::iterator * it=NULL);
00244
00245 static ResIDToString * pHash;
00246 static ResIDToString * pObjectNameHash;
00247 static TCHAR * DefaultString;
00248 static TCHAR * DefaultObjectName;
00249 static wxString * pResourcePath;
00250 static BOOL HaveCheckedResourcePath;
00251 static CamResourceRemember * pFirstRemember;
00252
00253 static wxBitmap * pSplashBitmap;
00254 static wxAdvSplashScreen * pSplashScreen;
00255
00256 static ResourceStringToBitmap * pBitmapHash;
00257
00258 public:
00259 static BOOL LoadwxImage (wxImage & rImage, const TCHAR * pFileName, BOOL Grey=FALSE);
00260 static BOOL LoadwxBitmap (wxBitmap & rBitmap, const TCHAR * pFileName, BOOL Grey=FALSE);
00261
00262 static wxImage* GetCachedBitmap(const TCHAR * pName);
00263
00264 static void MakeGreyImage (wxImage & rImage);
00265 static void MakeHotImage (wxImage & rImage);
00266
00267 static inline ResourceID GetResourceID(const TCHAR * ObjectName)
00268 {
00269 const TCHAR * fObjectName=FixObjectName(ObjectName);
00270 ResourceID Resource = wxXmlResource::GetXRCID(fObjectName);
00271
00272
00273
00274 if (pObjectNameHash)
00275 {
00276 ResIDToString::iterator i=pObjectNameHash->find(Resource);
00277 if (i==pObjectNameHash->end()) (*pObjectNameHash)[Resource]=camStrdup(fObjectName);
00278 }
00279 else RememberDuringStaticInit(fObjectName);
00280 return Resource;
00281 }
00282 static inline const TCHAR * GetTextFail(ResourceID Resource)
00283 {
00284 if (!pHash) return NULL;
00285 ResIDToString::iterator i=pHash->find(Resource);
00286 return (const TCHAR *)((i==pHash->end())?NULL:i->second);
00287 };
00288 static inline const TCHAR * GetText(ResourceID Resource)
00289 {
00290 if (!pHash) return DefaultString;
00291 ResIDToString::iterator i=pHash->find(Resource);
00292 const TCHAR * text = (const TCHAR *)((i==pHash->end())?NULL:i->second);
00293 return text?text:DefaultString;
00294 };
00295 static inline const TCHAR * GetObjectNameFail(ResourceID Resource)
00296 {
00297 if (!pObjectNameHash) return NULL;
00298 ResIDToString::iterator i=pObjectNameHash->find(Resource);
00299 return (const TCHAR *)((i==pObjectNameHash->end())?NULL:i->second);
00300 };
00301 static inline const TCHAR * GetObjectName(ResourceID Resource)
00302 {
00303 if (!pObjectNameHash) return DefaultString;
00304 ResIDToString::iterator i=pObjectNameHash->find(Resource);
00305 const TCHAR * text = (const TCHAR *)((i==pObjectNameHash->end())?NULL:i->second);
00306 return text?text:DefaultString;
00307 };
00308
00309 static wxString GetResourceFilePath( const wxString &str, BOOL AllowOverride=TRUE );
00310 static void SetResourceFilePath( const wxString &str );
00311
00312
00313 static BOOL IsBitmapName(const wxString &str);
00314 static wxString GetBitmapExtension(const wxString &str);
00315 static wxString GetBitmapBaseName(const wxString &str);
00316 static wxString GetBitmapFlagString(const wxString & str);
00317 static wxString MakeBitmapString(const wxString base, const wxString flags, const wxString ext)
00318 {
00319 if (flags.IsEmpty())
00320 return base+wxString(_T("."))+ext;
00321 else
00322 return base+wxString(_T("-"))+flags+wxString(_T("."))+ext;
00323 }
00324
00325 static BOOL Init();
00326 static BOOL DeInit();
00327
00328 static BOOL DoneInit(BOOL CanYield=TRUE);
00329
00330 static wxLocale * GetLocale() {return m_pLocale;}
00331
00332 static wxArrayString BitmapExtensions;
00333
00334 static void SetGenerateXRCCheck(BOOL flag) {s_GenerateXRCCheck=flag;}
00335 static void * LoadFile( const wxString &str1, UINT32 * pSize );
00336 };
00337
00338
00339 class CamResourceRemember
00340 {
00341 friend class CamResource;
00342
00343 private:
00344 CamResourceRemember * next;
00345 TCHAR * text;
00346 };
00347
00348
00349
00350 #endif
00351