#include <camresource.h>
Inheritance diagram for CamResource:
Public Member Functions | |
virtual CCRuntimeClass * | GetRuntimeClass () const |
This function allows access to the CCRuntimeClass object for this class, which in turn allows dynamic classing and construction. This function is automatically overridden on derived classes if you use the CC_DECLARE_... and CC_IMPLEMENT_... macros. | |
CamResource () | |
Constructor. | |
virtual | ~CamResource () |
Destructor. | |
CCLexFile * | Open (ResourceID ID, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE) |
Return a pointer to the open file. | |
CCLexFile * | Open (const TCHAR *pFileName, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE) |
Return a pointer to the open file. | |
wxFSFile * | OpenwxFSFile (ResourceID ID) |
Return a pointer to the open file. | |
wxFSFile * | OpenwxFSFile (const TCHAR *pFileName) |
Return a pointer to the open file. | |
void | Close () |
Close the relevant file. | |
CCLexFile * | Get () |
wxFSFile * | GetwxFSFile () |
Static Public Member Functions | |
static CCRuntimeClass * | GetMyClass () |
static void PASCAL | Construct (void *p) |
static BOOL | LoadwxImage (wxImage &rImage, const TCHAR *pFileName, BOOL Grey=FALSE) |
Static function to load a bitmap. | |
static BOOL | LoadwxBitmap (wxBitmap &rBitmap, const TCHAR *pFileName, BOOL Grey=FALSE) |
Static function to load a bitmap. | |
static wxImage * | GetCachedBitmap (const TCHAR *pName) |
Returns a pointer to the preloaded bitmap. | |
static void | MakeGreyImage (wxImage &rImage) |
Static function to grey an image. | |
static void | MakeHotImage (wxImage &rImage) |
Static function to make a hot version of an image. | |
static ResourceID | GetResourceID (const TCHAR *ObjectName) |
static const TCHAR * | GetTextFail (ResourceID Resource) |
static const TCHAR * | GetText (ResourceID Resource) |
static const TCHAR * | GetObjectNameFail (ResourceID Resource) |
static const TCHAR * | GetObjectName (ResourceID Resource) |
static wxString | GetResourceFilePath (const wxString &str, BOOL AllowOverride=TRUE) |
Destructor. | |
static void | SetResourceFilePath (const wxString &str) |
Destructor. | |
static BOOL | IsBitmapName (const wxString &str) |
Determine whether or not a path points to a bitmap. | |
static wxString | GetBitmapExtension (const wxString &str) |
Determines the extension of a bitmap. | |
static wxString | GetBitmapBaseName (const wxString &str) |
Determines the extension of a bitmap. | |
static wxString | GetBitmapFlagString (const wxString &str) |
Determines the extension of a bitmap. | |
static wxString | MakeBitmapString (const wxString base, const wxString flags, const wxString ext) |
static BOOL | Init () |
Initialize resources. | |
static BOOL | DeInit () |
Initialize resources. | |
static BOOL | DoneInit (BOOL CanYield=TRUE) |
Signals to the resouce system initialization is completed. The splah screen can thus be removed. | |
static wxLocale * | GetLocale () |
static void | SetGenerateXRCCheck (BOOL flag) |
static void * | LoadFile (const wxString &str1, UINT32 *pSize) |
Static Public Attributes | |
static CCRuntimeClass | cc_classCamResource |
static wxArrayString | BitmapExtensions |
Static Private Member Functions | |
static void | AddStringResource (const TCHAR *name, const TCHAR *text, ResourceID r=0) |
Initialize resources. | |
static void | RememberDuringStaticInit (const TCHAR *ObjectName) |
Remembers an objectname that has been GetResourceID'd prior to the ObjectHash existing. | |
static BOOL | ReadStringTableFile () |
Initialize resources. | |
static void | ProcessWindowAndChildren (wxWindow *pWindow) |
Initialize resources. | |
static void | GetBinaryFileInfo (void **pPtr, UINT32 *pSize) |
static BOOL | InitXmlResource () |
Initialize resources. | |
static BOOL | Splash () |
Put up a splash screen. | |
static BOOL | CheckResourcePath (const wxString &str1, const wxString &str2) |
static const TCHAR * | FixObjectName (const TCHAR *ObjectName) |
static BOOL | AddBitmaps (wxString &Path) |
Add all bitmaps in the path. | |
static BOOL | LoadBitmaps () |
Add internal and external bitmaps. | |
static void | DeleteBitmapHashEntries () |
Delete every bitmap hash table entry. | |
static void | MakeVariantBitmaps (ResourceStringToBitmap::iterator *it=NULL) |
Make variant copies of all bitmaps. | |
Private Attributes | |
CCLexFile * | pFile |
void * | pMemory |
UINT32 | Size |
wxFSFile * | pwxFSFile |
Static Private Attributes | |
static wxFileSystem * | pwxFileSystem = NULL |
static wxLocale * | m_pLocale = NULL |
static wxHelpProvider * | m_pHelpProvider = NULL |
static BOOL | s_GenerateXRCCheck = FALSE |
static ResIDToString * | pHash = NULL |
static ResIDToString * | pObjectNameHash = NULL |
static TCHAR * | DefaultString = _T("[Resource string not found]") |
static TCHAR * | DefaultObjectName = _T("[Object name not Found]") |
static wxString * | pResourcePath = NULL |
static BOOL | HaveCheckedResourcePath = FALSE |
static CamResourceRemember * | pFirstRemember = NULL |
static wxBitmap * | pSplashBitmap = NULL |
static wxAdvSplashScreen * | pSplashScreen = NULL |
static ResourceStringToBitmap * | pBitmapHash = NULL |
String tables
The GetText() member functions look up the integer ID's passed to it in a hash map, via inline functions, so should be pretty rapid in execution. Thus the actual mechanism of loading the strings is effectively encapsulated.
Dialogs and other resources
The GetResourceID() member function implements the _R() macro, which allows a resource in a dialog (or a stringtable resource) to be translated into the numeric ID's Camelot likes.
Example usage:
ResourceID myResource; myResource = _R("_R(IDS_BLOBBYSTRING)"); // Uses CamResource::GetResourceID()
... pass around the integer value ...
const TCHAR * myString = CamResource::GetText(myResource); // Can't fail ... do something with the text of the entry ...
Note that the _R() macros is clevere than you think. That's because it can be used as a static initializer (e.g. in wxWidgets event tables). What is happening here is that the GetXRCID() hash table gets initialized at static initialization time creating a map from the resource string (IDS_ etc.) to a unique integer value, and when the XML resources are loaded later, they are assigned that integer value.
Note this is a static class, and thus no constructors and destructors are offered.
Definition at line 199 of file camresource.h.
|
Constructor.
CamResource myResource; // Allocate a new resource object CCLexFile * myFile = myResource.Open(_R(IDB_BLOBBY)); // Open the BLOBBY bitmap Could have specified a string instead myFile->Read( ... ) // or whatever The user can either close the file, or not. However, operations must NOT be done on the file once the corresponding resource object is destroyed (as the resource object may have allocated a memory copy of the image). To prevent damage, the destructor will ALWAYS close the file and free the resources. The caller should NOT delete the open CCLexFile object that is returned. Either use our Close mechanism, or let the destructor take its course. Definition at line 1883 of file camresource.cpp. 01884 { 01885 Size = 0; 01886 pMemory = NULL; 01887 pFile = NULL; 01888 pwxFSFile = NULL; 01889 return; 01890 }
|
|
Destructor.
Definition at line 1909 of file camresource.cpp. 01910 { 01911 Close(); // releases pFile and pMemory 01912 }
|
|
Add all bitmaps in the path.
Definition at line 979 of file camresource.cpp. 00980 { 00981 ERROR2IF(!pBitmapHash, FALSE, "No bitmap hash"); 00982 ERROR2IF(!pwxFileSystem, FALSE, "No filesystem"); 00983 00984 TRACEUSER("amb",_T("Adding bitmaps from %s"),Path.c_str()); 00985 00986 wxString fn = pwxFileSystem->FindFirst(Path+_T("*.*"), wxFILE); // This isn't an MSDOS-ism - we are looking for files with an extension 00987 while (!fn.IsEmpty()) 00988 { 00989 wxString LeafName = fn.Mid(Path.Length()); 00990 00991 if (IsBitmapName(LeafName)) 00992 { 00993 00994 ResourceStringToBitmap::iterator i=pBitmapHash->find(LeafName); 00995 00996 if (i==pBitmapHash->end()) // ignore if we already have an entry 00997 { 00998 #if PRELOAD_BITMAPS 00999 wxImage * pBitmap=new wxImage; 01000 if (!pBitmap) 01001 return FALSE; 01002 01003 // TRACE(_T("Loading bitmap %s"),fn.c_str()); 01004 if (LoadwxImage(*pBitmap, LeafName)) 01005 (*pBitmapHash)[camStrdup(LeafName.c_str())]=pBitmap; 01006 else 01007 { 01008 ERROR3_PF((_T("Could not load bitmap %s"),fn.c_str())); 01009 delete pBitmap; 01010 } 01011 #else 01012 (*pBitmapHash)[camStrdup(LeafName.c_str())]=NULL; // Mark as there, but needs to be loaded 01013 #endif 01014 } 01015 } 01016 01017 fn = pwxFileSystem->FindNext(); 01018 } 01019 return TRUE; 01020 }
|
|
Initialize resources.
Definition at line 449 of file camresource.cpp. 00450 { 00451 ResourceID r2=GetResourceID(name); 00452 if (r) 00453 { 00454 if (r != r2) 00455 { 00456 TRACE(_T("Possible duplicate label %s\n"),text); 00457 } 00458 } 00459 else 00460 { 00461 r = r2; 00462 } 00463 00464 if (!name || !text) 00465 { 00466 TRACE(_T("Resource ID %d is blank\n"),r); 00467 ERROR3("Resource is blank"); 00468 } 00469 else 00470 { 00471 ResIDToString::iterator i=pHash->find(r); 00472 if (i!=pHash->end()) 00473 { 00474 TRACE(_T("Resource ID %d name <%s> has duplicate definitions: <%s> and <%s>\n"),r,name,text,i->second); 00475 } 00476 else 00477 { 00478 const TCHAR * tcopy = camStrdup(text); 00479 (*pHash)[r] = tcopy; 00480 00481 const TCHAR * t = GetText(r); 00482 if (t!=tcopy) 00483 { 00484 ERROR3("Resource string does not match local copy"); 00485 } 00486 } 00487 } 00488 }
|
|
Definition at line 878 of file camresource.cpp. 00879 { 00880 if (!pwxFileSystem) return FALSE; 00881 00882 UINT32 size1=0; 00883 UINT32 size2=0; 00884 void * mem1=LoadFile(str1, &size1); 00885 void * mem2=LoadFile(str2, &size2); 00886 00887 if (!mem1) 00888 { 00889 if (mem2) 00890 free(mem2); 00891 return FALSE; // and we can't generate an xrc.check 00892 } 00893 00894 BOOL same = mem2 && ( size1 == size2) && !memcmp(mem1, mem2, size1); 00895 00896 if (!same && s_GenerateXRCCheck) 00897 { 00898 wxMessageBox(_T("You have requested XaraLX to generate a checksum for resources which may not match the binary in question. " 00899 "A checksum will be generated, but the program may not be stable."), _T("XaraLX Resource system warning")); 00900 00901 wxFile f; 00902 f.Create(str2, wxFile::write); 00903 if (!f.IsOpened() || (f.Write(mem1, size1) != size1)) 00904 { 00905 wxMessageBox(_T("Failed to write xrc.check file ")+str2, _T("XaraLX resource system")); 00906 } 00907 f.Close(); 00908 same=TRUE; 00909 } 00910 00911 00912 if (mem1) 00913 free (mem1); 00914 00915 if (mem2) 00916 free (mem2); 00917 00918 return same; 00919 }
|
|
Close the relevant file.
Definition at line 1930 of file camresource.cpp. 01931 { 01932 if (pFile) 01933 { 01934 pFile->close(); 01935 delete (pFile); 01936 pFile = NULL; 01937 } 01938 01939 if (pwxFSFile) 01940 { 01941 delete (pwxFSFile); 01942 pwxFSFile=NULL; 01943 } 01944 01945 if (pMemory) free(pMemory); 01946 pMemory = NULL; 01947 01948 Size = 0; // leave in tidy state 01949 }
|
|
|
|
Initialize resources.
Definition at line 1672 of file camresource.cpp. 01673 { 01674 if (m_pHelpProvider) 01675 { 01676 wxHelpProvider::Set(NULL); 01677 delete m_pHelpProvider; 01678 m_pHelpProvider = NULL; 01679 } 01680 01681 if (pwxFileSystem) 01682 { 01683 delete (pwxFileSystem); 01684 pwxFileSystem = NULL; 01685 } 01686 01687 #if !defined(EXCLUDE_FROM_XARLIB) 01688 if (pBitmapHash) 01689 { 01690 DeleteBitmapHashEntries(); 01691 delete pBitmapHash; 01692 pBitmapHash = NULL; 01693 } 01694 #endif // EXCLUDE_FROM_XARLIB 01695 if (pHash) 01696 { 01697 ResIDToString::iterator current; 01698 01699 while (!pHash->empty()) 01700 { 01701 current = pHash->begin(); 01702 ResourceString s=current->second; 01703 pHash->erase(current); 01704 free((void *)s); 01705 } 01706 // for good measure 01707 pHash->clear(); 01708 01709 delete (pHash); 01710 pHash = NULL; 01711 } 01712 01713 if (pObjectNameHash) 01714 { 01715 ResIDToString::iterator current; 01716 01717 while (!pObjectNameHash->empty()) 01718 { 01719 current = pObjectNameHash->begin(); 01720 ResourceString s=current->second; 01721 pObjectNameHash->erase(current); 01722 free((void *)s); 01723 } 01724 // for good measure 01725 pObjectNameHash->clear(); 01726 01727 delete (pObjectNameHash); 01728 pObjectNameHash = NULL; 01729 } 01730 01731 #if !defined(EXCLUDE_FROM_XARLIB) 01732 if (pSplashScreen) 01733 { 01734 delete (pSplashScreen); 01735 pSplashScreen = NULL; 01736 } 01737 01738 if (pSplashBitmap) 01739 { 01740 delete (pSplashBitmap); 01741 pSplashBitmap = NULL; 01742 } 01743 #endif // EXCLUDE_FROM_XARLIB 01744 01745 if (m_pLocale) 01746 { 01747 delete (m_pLocale); 01748 m_pLocale = NULL; 01749 } 01750 01751 return TRUE; 01752 }
|
|
Delete every bitmap hash table entry.
Definition at line 1633 of file camresource.cpp. 01634 { 01635 if (pBitmapHash) 01636 { 01637 ResourceStringToBitmap::iterator current; 01638 01639 while (!pBitmapHash->empty()) 01640 { 01641 current = pBitmapHash->begin(); 01642 wxImage * b=current->second; 01643 TCHAR * s=(TCHAR *)current->first; 01644 pBitmapHash->erase(current); 01645 if (b) 01646 delete b; 01647 free(s); 01648 } 01649 // for good measure 01650 pBitmapHash->clear(); 01651 } 01652 }
|
|
Signals to the resouce system initialization is completed. The splah screen can thus be removed.
Definition at line 1827 of file camresource.cpp. 01828 { 01829 TRACET(_T("CamResource::DoneInit() called")); 01830 #if !defined(EXCLUDE_FROM_XARLIB) 01831 if (pSplashScreen) 01832 { 01833 if (CanYield) 01834 ::wxYield(); 01835 pSplashScreen->Destroy(); 01836 pSplashScreen = NULL; 01837 if (CanYield) 01838 ::wxYield(); 01839 } 01840 if (pSplashBitmap) 01841 { 01842 delete (pSplashBitmap); 01843 pSplashBitmap = NULL; 01844 } 01845 #endif // EXCLUDE_FROM_XARLIB 01846 return TRUE; 01847 }
|
|
Definition at line 354 of file camresource.cpp. 00355 { 00356 if (!CamResourceFixNameEntry::pArray) 00357 { 00358 // Don't delete the comments or normalize.pl will unhelpfully convert the bits in quotes 00359 FNOMAP("IDOK", "wxID_OK"); //NORESOURCEFIX 00360 FNOMAP("IDCANCEL", "wxID_CANCEL"); //NORESOURCEFIX 00361 FNOMAP("IDAPPLY", "wxID_APPLY"); //NORESOURCEFIX 00362 FNOMAP("ID_APPLY_NOW", "wxID_APPLY"); //NORESOURCEFIX 00363 FNOMAP("ID_CC_APPLY_NOW", "wxID_APPLY"); //NORESOURCEFIX 00364 FNOMAP("ID_FILE_OPEN", "wxID_OPEN"); //NORESOURCEFIX 00365 FNOMAP("ID_FILE_CLOSE", "wxID_CLOSE"); //NORESOURCEFIX 00366 FNOMAP("ID_FILE_SAVE", "wxID_SAVE"); //NORESOURCEFIX 00367 FNOMAP("ID_FILE_SAVE_AS", "wxID_SAVEAS"); //NORESOURCEFIX 00368 FNOMAP("ID_APP_EXIT", "wxID_EXIT"); //NORESOURCEFIX 00369 FNOMAP("ID_FILE_PRINT", "wxID_PRINT"); //NORESOURCEFIX 00370 FNOMAP("ID_FILE_PRINT_PREVIEW", "wxID_PREVIEW"); //NORESOURCEFIX 00371 FNOMAP("ID_FILE_PRINT_SETUP", "wxID_PRINT_SETUP"); //NORESOURCEFIX 00372 FNOMAP("ID_APP_ABOUT", "wxID_ABOUT"); //NORESOURCEFIX 00373 FNOMAP("ID_EDIT_UNDO", "wxID_UNDO"); //NORESOURCEFIX 00374 FNOMAP("ID_EDIT_CUT", "wxID_CUT"); //NORESOURCEFIX 00375 FNOMAP("ID_EDIT_COPY", "wxID_COPY"); //NORESOURCEFIX 00376 FNOMAP("ID_EDIT_PASTE", "wxID_PASTE"); //NORESOURCEFIX 00377 FNOMAP("IDYES", "wxID_YES"); //NORESOURCEFIX 00378 FNOMAP("IDNO", "wxID_NO"); //NORESOURCEFIX 00379 FNOMAP("IDHELP", "wxID_HELP"); //NORESOURCEFIX 00380 00381 CamResourceFixNameEntry::MakeResources(); 00382 } 00383 const TCHAR * ret= CamResourceFixNameEntry::Find(ObjectName); 00384 if (pObjectNameHash && ret !=ObjectName) // don't do during static init 00385 { 00386 TRACEUSER("amb",_T("**Mapped %s to %s"),ObjectName,ret); 00387 } 00388 return ret; 00389 }
|
|
Definition at line 225 of file camresource.h. 00225 {return pFile;}
|
|
Definition at line 50484 of file winresources.cpp.
|
|
Determines the extension of a bitmap.
Definition at line 1086 of file camresource.cpp. 01087 { 01088 // Find the rightmost dot 01089 INT32 i=str.Find(_T('.'), TRUE); 01090 if (i<0) 01091 return wxEmptyString; 01092 wxString barestr = str.Left(i); 01093 01094 // Find the rightmost "-"; 01095 i=barestr.Find(_T('-'), TRUE); 01096 if (i<0) 01097 return barestr; 01098 01099 // Now check all characters after the "-" are alphanumeric 01100 INT32 j; 01101 for (j=i+1; j<(INT32)barestr.Length(); j++) 01102 { 01103 wxChar c=barestr[j]; 01104 if ((c<_T('a')) || (c>_T('z'))) 01105 return barestr; 01106 } 01107 return barestr.Left(i); 01108 }
|
|
Determines the extension of a bitmap.
Definition at line 1060 of file camresource.cpp. 01061 { 01062 // Find the rightmost dot 01063 INT32 i=str.Find(_T('.'), TRUE); 01064 if (i<0) 01065 return wxEmptyString; 01066 else 01067 return str.Mid(i+1); 01068 }
|
|
Determines the extension of a bitmap.
Definition at line 1126 of file camresource.cpp. 01127 { 01128 // Find the rightmost dot 01129 INT32 i=str.Find(_T('.'), TRUE); 01130 if (i<0) 01131 return wxEmptyString; 01132 wxString barestr = str.Left(i); 01133 01134 // Find the rightmost "-"; 01135 i=barestr.Find(_T('-'), TRUE); 01136 if (i<0) 01137 return wxEmptyString; 01138 01139 // Now check all characters after the "-" are alphanumeric 01140 INT32 j; 01141 for (j=i+1; j<(INT32)barestr.Length(); j++) 01142 { 01143 wxChar c=barestr[j]; 01144 if ((c<_T('a')) || (c>_T('z'))) 01145 return wxEmptyString; 01146 } 01147 return barestr.Mid(i+1); 01148 }
|
|
Returns a pointer to the preloaded bitmap.
Definition at line 1280 of file camresource.cpp. 01281 { 01282 if (!pBitmapHash) return NULL; 01283 ResourceStringToBitmap::iterator i=pBitmapHash->find(pName); 01284 if (i==pBitmapHash->end()) 01285 { 01286 // We know this file does not exist in the resources. However, we might be able to 01287 // make one if it's greyed and we can get the ungreyed version 01288 01289 wxString fn(pName); 01290 01291 // Clear each of the flags in sequence 01292 BOOL Found=FALSE; 01293 // Do this entire lot for each flag 01294 CamArtFlags flag=CAF_CACHE_MAX; 01295 while ((flag=(CamArtFlags)(flag>>1)) !=0 ) 01296 { 01297 if ((flag==CAF_GREYED) || (flag!=CAF_SELECTED)) // We don't know how to produce anything else, so ignore 01298 { 01299 01300 if (IsBitmapName(fn) && (CamArtProvider::GetBitmapFlags(fn) & flag)) 01301 { 01302 // Find the ungreyed name of the bitmap 01303 wxString ugfn=MakeBitmapString(GetBitmapBaseName(fn), 01304 CamArtProvider::MakeBitmapFlagString((CamArtFlags) 01305 (CamArtProvider::GetBitmapFlags(fn) & 01306 ~flag)), 01307 GetBitmapExtension(fn)); 01308 Found = TRUE; // we should at least look for another bitmap 01309 01310 // Recursively call ourself to load the ungreyed bitmap. We don't care about the result, but this 01311 // will insert the greyed version into the cache as a byproduct 01312 01313 #ifdef _DEBUG 01314 static INT32 recursion=0; 01315 recursion++; 01316 ERROR3IF(recursion>16,"Too much recursion in CamResource::GetCachedBitmap"); 01317 #endif 01318 GetCachedBitmap(ugfn.c_str()); 01319 #ifdef _DEBUG 01320 recursion--; 01321 #endif 01322 } 01323 } 01324 } 01325 if (!Found) 01326 return NULL; 01327 01328 i=pBitmapHash->find(pName); // reset iterator 01329 if (i==pBitmapHash->end()) 01330 return NULL; // we couldn't find a greyed version 01331 } 01332 01333 if (!i->second) 01334 { 01335 // There is no bitmap there, but the name is there. We must be demand loading 01336 01337 wxImage * pBitmap = new wxImage; 01338 if (!pBitmap) return NULL; 01339 01340 if (!LoadwxImage(*pBitmap, pName)) 01341 { 01342 ERROR3_PF((_T("Could not load bitmap %s"), pName)); 01343 delete pBitmap; 01344 return NULL; 01345 } 01346 01347 // Add it to the cache 01348 i->second=pBitmap; 01349 01350 // Generate variant versions if we should 01351 MakeVariantBitmaps(&i); 01352 01353 return pBitmap; 01354 } 01355 return i->second; 01356 }
|
|
Definition at line 330 of file camresource.h. 00330 {return m_pLocale;}
|
|
Reimplemented from CCObject. |
|
Definition at line 301 of file camresource.h. 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 };
|
|
Definition at line 295 of file camresource.h. 00296 { 00297 if (!pObjectNameHash) return NULL; 00298 ResIDToString::iterator i=pObjectNameHash->find(Resource); 00299 return (const TCHAR *)((i==pObjectNameHash->end())?NULL:i->second); 00300 };
|
|
Destructor.
If an empty string is specified, it returns the overridden resource path (if one exists) (so long as the override is set to TRUE), or failing that the memory resource path Definition at line 749 of file camresource.cpp. 00750 { 00751 // If we are given a full path, then return. For the time being that's anything with a colon or a slash in it 00752 // as the resources file is flat 00753 if ( ((str.Find(_T(':')))>=0) || ((str.Find(_T('/')))>=0) || ((str.Find(_T('\\')))>=0) ) 00754 { 00755 return str; 00756 } 00757 00758 wxString mfn = _T("memory:resources#zip:"); 00759 00760 if (AllowOverride && pResourcePath && pwxFileSystem) 00761 { 00762 wxString fn = *pResourcePath + _T('/'); 00763 00764 // If we have not run the check on the checksum do it now. 00765 if (!HaveCheckedResourcePath) 00766 { 00767 if (CheckResourcePath(mfn+_T("xrc.check"),fn+_T("xrc.check"))) 00768 { 00769 HaveCheckedResourcePath = TRUE; 00770 } 00771 else 00772 { 00773 wxMessageBox(_T("Ignoring resource path specified on command line due to bad resource checksum"), _T("Resource loading error")); 00774 delete (pResourcePath); 00775 pResourcePath = NULL; 00776 } 00777 } 00778 00779 if (str.IsEmpty() && pResourcePath) 00780 return fn; 00781 00782 fn += str; 00783 00784 if (pResourcePath) // may have been cleared 00785 { 00786 wxFSFile * pTwxFSFile = pwxFileSystem->OpenFile(fn); 00787 if (pTwxFSFile) 00788 { 00789 // we found it, so close it & return 00790 delete pTwxFSFile; 00791 return fn; 00792 } 00793 } 00794 } 00795 return mfn + str; 00796 }
|
|
Definition at line 267 of file camresource.h. 00268 { 00269 const TCHAR * fObjectName=FixObjectName(ObjectName); 00270 ResourceID Resource = wxXmlResource::GetXRCID(fObjectName); 00271 // need to record it in the hash that goes the other way lest we be asked. Note this will always 00272 // work as the caller to GetObjectName can't have a ResourceID without _R()'ing it (or at least 00273 // cannot legally have one). 00274 if (pObjectNameHash) // skip on static initialization phase or we'll be dead 00275 { 00276 ResIDToString::iterator i=pObjectNameHash->find(Resource); 00277 if (i==pObjectNameHash->end()) (*pObjectNameHash)[Resource]=camStrdup(fObjectName); 00278 } 00279 else RememberDuringStaticInit(fObjectName); // add it to the hash later 00280 return Resource; 00281 }
|
|
This function allows access to the CCRuntimeClass object for this class, which in turn allows dynamic classing and construction. This function is automatically overridden on derived classes if you use the CC_DECLARE_... and CC_IMPLEMENT_... macros.
Reimplemented from CCObject. |
|
Definition at line 288 of file camresource.h. 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 };
|
|
Definition at line 282 of file camresource.h. 00283 { 00284 if (!pHash) return NULL; 00285 ResIDToString::iterator i=pHash->find(Resource); 00286 return (const TCHAR *)((i==pHash->end())?NULL:i->second); 00287 };
|
|
Definition at line 226 of file camresource.h. 00226 {return pwxFSFile;}
|
|
Initialize resources.
Reimplemented from SimpleCCObject. Definition at line 1409 of file camresource.cpp. 01410 { 01411 void * pFile=NULL; 01412 UINT32 Length=0; 01413 01414 TRACET(_T("CamResource::Init() called")); 01415 01416 pHash = new (ResIDToString); 01417 if (!pHash) return FALSE; 01418 pHash->clear(); 01419 01420 pObjectNameHash = new (ResIDToString); 01421 if (!pObjectNameHash) return FALSE; 01422 pObjectNameHash->clear(); 01423 01424 #if !defined(EXCLUDE_FROM_XARLIB) 01425 pBitmapHash = new (ResourceStringToBitmap); 01426 if (!pBitmapHash) return FALSE; 01427 pBitmapHash->clear(); 01428 #endif 01429 01430 // Now go through ID's translated before we got here 01431 CamResourceRemember * pRem = pFirstRemember; 01432 pFirstRemember = NULL; 01433 while (pRem) 01434 { 01435 if (pRem->text) 01436 { 01437 // Do not comment out the next line. It does something useful (make the inverse object 01438 // map work for static text) 01439 /*ResourceID r =*/ GetResourceID(pRem->text); 01440 // TRACEUSER("amb",_T("Fixed up static init translation from %s to %d"),pRem->text,r); 01441 free (pRem->text); 01442 } 01443 CamResourceRemember * pORem = pRem; 01444 pRem = pRem->next; 01445 delete pORem; 01446 } 01447 01448 // Initialize the handlers 01449 wxXmlResource::Get()->InitAllHandlers(); 01450 #if !defined(EXCLUDE_FROM_XARLIB) 01451 wxXmlResource::Get()->AddHandler(new wxCamArtControlXmlHandler); 01452 wxXmlResource::Get()->AddHandler(new wxCamDrawControlXmlHandler); 01453 #ifdef wxXTRA_XH_ODCOMBO 01454 wxXmlResource::Get()->AddHandler(new wxOwnerDrawnComboBoxXmlHandler); 01455 // wxXmlResource::Get()->AddHandler(new wxComboControlXmlHandler); 01456 #endif 01457 #ifdef wxXTRA_XH_SLIDERCOMBO 01458 wxXmlResource::Get()->AddHandler(new wxSliderComboXmlHandler); 01459 #endif 01460 #if WXXTRA_TREEBOOK 01461 wxXmlResource::Get()->AddHandler(new wxTreebookXmlHandler); 01462 #endif 01463 wxXmlResource::Get()->AddHandler(new wxGridComboXmlHandler); 01464 #endif 01465 01466 if (!pwxFileSystem) pwxFileSystem = new wxFileSystem; 01467 if (!pwxFileSystem) 01468 { 01469 TRACE(_T("Failed to allocate file system")); 01470 return FALSE; 01471 } 01472 01473 // Check for memory FS. If not present, load the handler: 01474 // No idea for the reason for the additional braces, but let's keep them ther 01475 { 01476 wxMemoryFSHandler::AddFile(_T("XRC_resource/dummy_file"), _T("dummy one")); 01477 wxFSFile *f = pwxFileSystem->OpenFile(_T("memory:XRC_resource/dummy_file")); 01478 wxMemoryFSHandler::RemoveFile(_T("XRC_resource/dummy_file")); 01479 if (f) delete f; 01480 else wxFileSystem::AddHandler(new wxMemoryFSHandler); 01481 } 01482 01483 TRACET(_T("CamResource::Init() added MemoryFSHandler")); 01484 01485 wxFileSystem::AddHandler(new wxZipFSHandler); 01486 01487 TRACET(_T("CamResource::Init() added Zip handler, now doing AddFile() on resources")); 01488 01489 GetBinaryFileInfo(&pFile, &Length); 01490 01491 // Do not use a file extension, as unbelievably this adds 3 seconds to startup time pre-splash box 01492 // This is because it tries to initialize the MIME system (sigh) 01493 wxMemoryFSHandler::AddFile(_T("resources"), pFile, Length); // Irritatingly does not return errors 01494 01495 wxXmlResource::Get()->SetFlags(wxXRC_NO_RELOADING); // reloading fails with assert due to missing timestamps 01496 01497 #if !defined(EXCLUDE_FROM_XARLIB) 01498 // Add bitmap extenstions 01499 BitmapExtensions.Add(_T("png")); 01500 BitmapExtensions.Add(_T("cur")); 01501 #endif 01502 01503 // Initialize locale 01504 m_pLocale = new wxLocale(); 01505 if (!m_pLocale) return FALSE; 01506 m_pLocale->Init(wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); 01507 m_pLocale->AddCatalogLookupPathPrefix(GetResourceFilePath(_T(""))); 01508 m_pLocale->AddCatalog(_T("XaraLX")); 01509 01510 #if !defined(EXCLUDE_FROM_XARLIB) 01511 TRACET(_T("CamResource::Init() launching splash screen")); 01512 if (!Splash()) return FALSE; 01513 #endif 01514 01515 #ifdef XML_STRINGS 01516 TRACET(_T("CamResource::Init() now loading internal resources, calling InitXmlResource")); 01517 // Load the internal resources 01518 // We should offer the possibility of loading them from a non-XML file here 01519 if (!InitXmlResource()) return FALSE; 01520 01521 wxYield(); // yield again to allow repaint 01522 01523 TRACET(_T("CamResource::Init() starting to load string table dialog")); 01524 01525 // Read the string table into the hash map 01526 wxDialog * pStringTable = wxXmlResource::Get()->LoadDialog(NULL, _T("STRINGTABLE")); 01527 if (!pStringTable) 01528 { 01529 // We can hardly internationalize the message box, as we have no strings to play with yet. 01530 wxMessageBox(_T("Could not load resources: Failed to locate string table"), _T("Resource loading error")); 01531 return FALSE; 01532 } 01533 wxYield(); // yield again to allow repaint 01534 01535 TRACET(_T("CamResource::Init() starting to process string table")); 01536 01537 // Now do a depth-first search of this window's children 01538 ProcessWindowAndChildren(pStringTable); 01539 01540 wxYield(); // yield again to allow repaint 01541 01542 TRACET(_T("CamResource::Init() and deleting the dialog")); 01543 01544 delete pStringTable; 01545 #else 01546 01547 TRACET(_T("CamResource::Init() now loading internal resources, calling ReadStringTableFile()")); 01548 if (!ReadStringTableFile()) 01549 { 01550 // We can hardly internationalize the message box, as we have no strings to play with yet. 01551 wxMessageBox(_T("Could not load resources: Failed to locate string table"), _T("Resource loading error")); 01552 return FALSE; 01553 } 01554 01555 #endif 01556 01557 TRACET(_T("CamResource::Init() done processing string table, starting to load bitmaps")); 01558 01559 wxYield(); // yield again to allow repaint 01560 01561 #if !defined(EXCLUDE_FROM_XARLIB) 01562 // Note this won't actually load the bitmaps if we are demand loading, but it will at least get a list of them 01563 if (!LoadBitmaps()) 01564 return FALSE; 01565 01566 TRACET(_T("CamResource::Init() done processing bitmaps, starting to load toolbar images")); 01567 01568 wxYield(); // yield again to allow repaint 01569 01570 #if 0 01571 LoadwxImage(imageBevelTool, _T("lbeveltool32.png") ); 01572 LoadwxImage(imageBezTool, _T("lbeztool32.png") ); 01573 LoadwxImage(imageBlendTool, _T("lblendtool32.png") ); 01574 LoadwxImage(imageContourTool, _T("lcontourtool32.png") ); 01575 LoadwxImage(imageElipTool, _T("leliptool32.png") ); 01576 LoadwxImage(imageFHandTool, _T("lfhandtool32.png") ); 01577 LoadwxImage(imageGradTool, _T("lgradtool32.png") ); 01578 LoadwxImage(imageLiveEffectTool, _T("lliveeffecttool32.png") ); 01579 LoadwxImage(imageMouldTool, _T("lmouldtool32.png") ); 01580 LoadwxImage(imagePenTool, _T("lpentool32.png") ); 01581 LoadwxImage(imagePush, _T("lpushtool32.png") ); 01582 LoadwxImage(imageRectTool, _T("lrecttool32.png") ); 01583 LoadwxImage(imageRegShapeTool, _T("lregshapetool32.png") ); 01584 LoadwxImage(imageSelTool, _T("lselrtool32.png") ); 01585 LoadwxImage(imageShadrwTool, _T("lsoftshadowtool32.png") ); 01586 LoadwxImage(imageSlicetool, _T("lslicetool32.png") ); 01587 LoadwxImage(imageTextTool, _T("ltexttool32.png") ); 01588 LoadwxImage(imageTransTool, _T("ltransptool32.png") ); 01589 LoadwxImage(imageZoomTool, _T("lzoomtool32.png") ); 01590 01591 TRACET(_T("CamResource::Init() Added images")); 01592 01593 wxYield(); // yield again to allow repaint 01594 #endif 01595 01596 m_pHelpProvider = new wxHelpControllerHelpProvider; 01597 if (!m_pHelpProvider) 01598 return FALSE; 01599 wxHelpProvider::Set(m_pHelpProvider); 01600 01601 if (!wxXmlResource::Get()->Load(GetResourceFilePath(_T("dialogs.xrc")))) 01602 { 01603 TRACE(_T("Could not load dialogs.xrc")); 01604 return FALSE; 01605 } 01606 01607 TRACET(_T("CamResource::Init - loaded dialogs")); 01608 01609 wxYield(); // yield again to allow repaint 01610 #endif 01611 01612 return TRUE; 01613 }
|
|
Initialize resources.
Definition at line 711 of file camresource.cpp. 00712 { 00713 TRACET(_T("CamResource::InitXmlResource() called, doing Load() of strings.xrc")); 00714 00715 if (!wxXmlResource::Get()->Load(GetResourceFilePath(_T("strings.xrc")))) 00716 { 00717 TRACE(_T("Could not load strings.xrc")); 00718 return FALSE; 00719 } 00720 00721 TRACET(_T("CamResource::InitXmlResource() called - loaded strings")); 00722 00723 return true; 00724 }
|
|
Determine whether or not a path points to a bitmap.
Definition at line 1038 of file camresource.cpp. 01039 { 01040 wxString ext=GetBitmapExtension(str); 01041 return (BitmapExtensions.Index(ext) != wxNOT_FOUND); 01042 }
|
|
Add internal and external bitmaps.
Definition at line 1375 of file camresource.cpp. 01376 { 01377 TRACET(_T("LoadBitmaps() called")); 01378 wxString ExternalRes = GetResourceFilePath(wxString(_T("")), TRUE); 01379 wxString InternalRes = GetResourceFilePath(wxString(_T("")), FALSE); 01380 TRACET(_T("LoadBitmaps() adding External bitmaps")); 01381 if (!AddBitmaps(ExternalRes)) return FALSE; 01382 TRACET(_T("LoadBitmaps() adding Internal bitmaps")); 01383 if (InternalRes != ExternalRes) 01384 if (!AddBitmaps(InternalRes)) return FALSE; 01385 TRACET(_T("LoadBitmaps() making grey copies")); 01386 MakeVariantBitmaps(); // make grey copies of each bitmap 01387 TRACET(_T("LoadBitmaps() done")); 01388 return TRUE; 01389 }
|
|
Definition at line 815 of file camresource.cpp. 00816 { 00817 wxFSFile * pTwxFSFile1 = pwxFileSystem->OpenFile(str1); 00818 if (!pTwxFSFile1) 00819 { 00820 delete pTwxFSFile1; 00821 return NULL; 00822 } 00823 00824 wxInputStream * pStream1 = pTwxFSFile1->GetStream(); // we don't have to delete this ourselves 00825 if (!pStream1) 00826 { 00827 delete (pTwxFSFile1); 00828 return NULL; 00829 } 00830 00831 UINT32 size1=pStream1->GetSize(); 00832 00833 if (!size1) 00834 { 00835 delete (pTwxFSFile1); 00836 return NULL; 00837 } 00838 00839 void * mem1 = malloc(size1+4); // safety 00840 if (!mem1) 00841 { 00842 delete (pTwxFSFile1); 00843 return NULL; 00844 } 00845 00846 memset(mem1, 0, size1); 00847 pStream1->Read(mem1, size1); // throws exceptions if can't read 00848 00849 delete (pTwxFSFile1); // Closes it 00850 00851 if (pSize) 00852 *pSize=size1; 00853 return mem1; 00854 }
|
|
Static function to load a bitmap.
Definition at line 2277 of file camresource.cpp. 02278 { 02279 // Annoyingly, wxBitmap does not support the stream class 02280 wxImage i; 02281 if (!LoadwxImage(i, pFileName)) return FALSE; 02282 wxBitmap b(i, -1); // for now, always use screen depth, not least as GDK doesn't support anything except this & 1bpp 02283 rBitmap = b; 02284 return TRUE; 02285 }
|
|
Static function to load a bitmap.
Definition at line 2246 of file camresource.cpp. 02247 { 02248 CamResource Resource; 02249 wxFSFile* f=Resource.OpenwxFSFile(pFileName); 02250 if (!f) return FALSE; 02251 wxInputStream * pStream=f->GetStream(); 02252 if (!pStream) return FALSE; 02253 if (!rImage.LoadFile(*pStream, wxBITMAP_TYPE_ANY)) return FALSE; 02254 02255 // Grey the image if required 02256 if (Grey) MakeGreyImage(rImage); 02257 02258 return TRUE; 02259 }
|
|
Definition at line 317 of file camresource.h. 00318 { 00319 if (flags.IsEmpty()) 00320 return base+wxString(_T("."))+ext; 00321 else 00322 return base+wxString(_T("-"))+flags+wxString(_T("."))+ext; 00323 }
|
|
Static function to grey an image.
Definition at line 2112 of file camresource.cpp. 02113 { 02114 // now we want to grey the thing ourselves 02115 INT32 x; 02116 INT32 y; 02117 02118 BOOL hasalpha = rImage.HasAlpha(); 02119 02120 // give it an alpha channel 02121 if (!hasalpha) rImage.InitAlpha(); // copies alpha into the mask if it had one. 02122 rImage.SetMask(FALSE); // ignore the mask - we now have alpha 02123 02124 UINT8 * p = rImage.GetData(); 02125 UINT8 * alpha = rImage.GetAlpha(); 02126 02127 INT32 w=rImage.GetWidth(); 02128 INT32 h=rImage.GetHeight(); 02129 02130 ColourMatrix Whiten = ColourMatrix::Whiten(); 02131 ColourMatrix Grey = ColourMatrix::Grey(); 02132 02133 // If we do the copy backwards we can avoid copying the data 02134 // Start off pointing at the last pixel 02135 const INT32 size = w * h; 02136 INT32 m = size - 1; 02137 INT32 n = (size - 1) * 3; 02138 02139 // Don't use SetRGB - it does funny things to the alpha channel 02140 for (y = h-1; y>=0; y--) for (x = w-1 ; x>=0; x--) 02141 { 02142 // packed bytes, same order on each platform 02143 ColourVector togrey; 02144 togrey.SetRGBA (p[n], p[n+1], p[n+2], alpha[m]); 02145 02146 togrey=togrey.Apply(Grey); 02147 02148 ColourVector towhiten(0.0,0.0,0.0,0.0); // transparent 02149 // whitened image is displaced by one pixel down and right. So we sample 02150 // from a pixel left and up (this is width + 1 pixels earlier in the image) 02151 if ((y>0) && (x>0)) 02152 { 02153 towhiten.SetRGBA(p[n-(w+1)*3], 02154 p[n-(w+1)*3+1], 02155 p[n-(w+1)*3+2], 02156 alpha[m-(w+1)]); 02157 } 02158 02159 towhiten=towhiten.Apply(Whiten); 02160 ColourVector result = towhiten.ComposeOnTop(togrey); 02161 02162 // Write the colour back into the image 02163 p[n]=result.GetR(); 02164 p[n+1]=result.GetG(); 02165 p[n+2]=result.GetB(); 02166 alpha[m]=result.GetA(); 02167 02168 // Go to "next" pixel (going backwards) 02169 n-=3; 02170 m--; 02171 } 02172 }
|
|
Static function to make a hot version of an image.
Definition at line 2188 of file camresource.cpp. 02189 { 02190 // now we want to grey the thing ourselves 02191 INT32 x; 02192 INT32 y; 02193 INT32 n=0; 02194 INT32 m=0; 02195 02196 BOOL hasalpha = rImage.HasAlpha(); 02197 02198 // give it an alpha channel 02199 if (!hasalpha) rImage.InitAlpha(); // copies alpha into the mask if it had one. 02200 rImage.SetMask(FALSE); // ignore the mask - we now have alpha 02201 02202 UINT8 * p = rImage.GetData(); 02203 UINT8 * alpha = rImage.GetAlpha(); 02204 02205 INT32 w=rImage.GetWidth(); 02206 INT32 h=rImage.GetHeight(); 02207 02208 ColourMatrix Boost = ColourMatrix::Boost(); 02209 02210 // Don't use SetRGB - it does funny things to the alpha channel 02211 for (y = 0; y<h; y++) for (x = 0 ; x<w; x++) 02212 { 02213 // packed bytes, same order on each platform 02214 ColourVector result; 02215 result.SetRGBA (p[n], p[n+1], p[n+2], alpha[m]); 02216 02217 result=result.Apply(Boost); 02218 02219 p[n]=result.GetR(); 02220 p[n+1]=result.GetG(); 02221 p[n+2]=result.GetB(); 02222 alpha[m]=result.GetA(); 02223 02224 n+=3; 02225 m++; 02226 } 02227 02228 }
|
|
Make variant copies of all bitmaps.
Definition at line 1170 of file camresource.cpp. 01171 { 01172 if (!pBitmapHash) 01173 return; 01174 01175 // Do this entire lot for each flag 01176 CamArtFlags flag=CAF_CACHE_MAX; 01177 while ((flag=(CamArtFlags)(flag>>1)) !=0 ) 01178 { 01179 if ((flag==CAF_GREYED) || (flag==CAF_SELECTED)) // We don't know how to produce anything else, so ignore 01180 { 01181 01182 // a convenient place to store the new grey bitmaps without breaking the iterator 01183 ResourceStringToBitmap NewHash; 01184 NewHash.clear(); 01185 01186 ResourceStringToBitmap::iterator current; 01187 if (it) 01188 current=*it; 01189 else 01190 current = pBitmapHash->begin(); 01191 01192 // iterate through the old hash (if needs be) 01193 while (current != pBitmapHash->end()) 01194 { 01195 if (current->second) // don't bother with bitmaps we have yet to demand load 01196 { 01197 wxString fn(current->first); 01198 //TRACEUSER("amb",_T("Trying to grey bitmap %s"),fn.c_str()); 01199 01200 // If it's a .png, but without the particular flag set 01201 if (IsBitmapName(fn) && !(CamArtProvider::GetBitmapFlags(fn) & flag)) 01202 { 01203 // Find the greyed name of the bitmap 01204 wxString gfn=MakeBitmapString(GetBitmapBaseName(fn), 01205 CamArtProvider::MakeBitmapFlagString((CamArtFlags) 01206 (CamArtProvider::GetBitmapFlags(fn) | 01207 flag)), 01208 GetBitmapExtension(fn)); 01209 ResourceStringToBitmap::iterator i=pBitmapHash->find(gfn.c_str()); 01210 if (i==pBitmapHash->end()) // ignore if we already have an entry 01211 { 01212 // TRACEUSER("amb",_T("Greying bitmap %s to bitmap %s"),fn.c_str(),gfn.c_str()); 01213 // We want to do this, but it doesn't actually copy the image data (boo hiss) 01214 // wxImage *pBitmap=new wxImage(*(current->second)); 01215 //wxBitmap b(*(current->second)); 01216 wxImage *pBitmap = new wxImage; 01217 if (pBitmap) 01218 { 01219 *pBitmap=current->second->Copy(); 01220 // WX bug - on 2.6.2 this does not copy the alpha channel. Work aroud it 01221 if (current->second->HasAlpha() && !pBitmap->HasAlpha()) 01222 { 01223 // This will never happen if wxWidgets is fixed 01224 pBitmap->SetAlpha(); 01225 memcpy( pBitmap->GetAlpha(), current->second->GetAlpha(), pBitmap->GetWidth()*pBitmap->GetHeight()); 01226 } 01227 switch (flag) 01228 { 01229 case CAF_GREYED: 01230 MakeGreyImage(*pBitmap); 01231 break; 01232 case CAF_SELECTED: 01233 MakeHotImage(*pBitmap); 01234 break; 01235 default: 01236 ERROR3("Unsupported automatic variant"); 01237 break; 01238 } 01239 NewHash[camStrdup(gfn.c_str())] = pBitmap; 01240 } 01241 } 01242 } 01243 } 01244 01245 if (it) 01246 { 01247 break; // jump out loop 01248 } 01249 else 01250 { 01251 ++current; 01252 } 01253 } 01254 01255 // Now dump the new hash into the old hash 01256 for( current = NewHash.begin(); current != NewHash.end(); ++current ) 01257 (*pBitmapHash)[current->first]=current->second; 01258 } 01259 } 01260 01261 return; 01262 }
|
|
Return a pointer to the open file.
Definition at line 1967 of file camresource.cpp. 01968 { 01969 Close(); 01970 01971 // For the time being, we always use a memory file. We load the resource in using the 01972 // wxWidgets VFS code (allowing us to load it out the Zip file), and keep the memory 01973 // around till we need to zap it. 01974 01975 wxFSFile * pTwxFSFile = pwxFileSystem->OpenFile(GetResourceFilePath(pFileName)); 01976 if (!pTwxFSFile) 01977 { 01978 return NULL; 01979 } 01980 01981 wxInputStream * pStream = pTwxFSFile->GetStream(); // we don't have to delete this ourselves 01982 if (!pStream) 01983 { 01984 delete (pTwxFSFile); 01985 return NULL; 01986 } 01987 01988 UINT32 newsize=pStream->GetSize(); 01989 01990 if (!newsize) 01991 { 01992 delete (pTwxFSFile); 01993 return NULL; 01994 } 01995 01996 void * newmem = malloc(newsize+4); // safety 01997 if (!newmem) 01998 { 01999 delete (pTwxFSFile); 02000 return NULL; 02001 } 02002 02003 memset(newmem, 0, newsize); 02004 pStream->Read(newmem, newsize); // throws exceptions if can't read 02005 02006 delete (pTwxFSFile); // which closes it 02007 02008 CCMemFile * pMemFile=new CCMemFile (newmem, newsize, CCMemRead, ErrorReporting, ExceptionThrowing); 02009 if (!pMemFile) 02010 { 02011 free(newmem); 02012 return NULL; 02013 } 02014 02015 // OK, we've done it. So we can store the variables we have 02016 pFile = pMemFile; 02017 Size = newsize; 02018 pMemory = newmem; 02019 02020 return (pFile); 02021 }
|
|
Return a pointer to the open file.
Definition at line 2040 of file camresource.cpp.
|
|
Return a pointer to the open file.
Definition at line 2082 of file camresource.cpp. 02083 { 02084 wxFSFile * pTwxFSFile = pwxFileSystem->OpenFile(GetResourceFilePath(pFileName)); 02085 if (!pTwxFSFile) 02086 { 02087 return NULL; 02088 } 02089 02090 pwxFSFile=pTwxFSFile; 02091 02092 return pwxFSFile; 02093 }
|
|
Return a pointer to the open file.
Definition at line 2061 of file camresource.cpp. 02062 { 02063 return OpenwxFSFile(GetText(ID)); 02064 }
|
|
Initialize resources.
Definition at line 664 of file camresource.cpp. 00665 { 00666 // Process this one 00667 if (pWindow->IsKindOf(CLASSINFO(wxStaticText))) 00668 { 00669 ResourceID r=(ResourceID) pWindow->GetId(); 00670 00671 // Don't be so foolish as to think the following would work. Oh no. What this would 00672 // do is return a temporary wxString, take the address of it's data member, then 00673 // mark it as discardable on the stack leaving the data member to be overwritten. 00674 // Ho de ho de ho. 00675 // const TCHAR * name = pWindow->GetName().c_str(); 00676 // const TCHAR * text = pWindow->GetLabel().c_str(); 00677 00678 wxString sname = pWindow->GetName(); 00679 wxString stext = pWindow->GetLabel(); 00680 00681 AddStringResource((const TCHAR *)sname.c_str(),(const TCHAR *)stext.c_str(), r); 00682 00683 } 00684 00685 // Now process children if any 00686 wxWindowList::Node * pNode = pWindow->GetChildren().GetFirst(); 00687 while (pNode) 00688 { 00689 ProcessWindowAndChildren(pNode->GetData()); 00690 pNode = pNode->GetNext(); 00691 } 00692 return; 00693 }
|
|
Initialize resources.
Definition at line 508 of file camresource.cpp. 00509 { 00510 TRACET(_T("ReadStringTableFile() called")); 00511 CamResource res; 00512 INT32 count=0; 00513 00514 wxFSFile* f = res.OpenwxFSFile(_T("strings.lst")); // NB destructor of 'res' deletes this 00515 if (!f) 00516 { 00517 TRACE(_T("Could not load strings.lst")); 00518 return FALSE; 00519 } 00520 00521 wxInputStream * s = f->GetStream(); 00522 if (!s) 00523 { 00524 TRACE(_T("Could not load strings.lst - no stream")); 00525 return FALSE; 00526 } 00527 00528 while (!s->Eof()) 00529 { 00530 #define MAX_TAG_LENGTH 1024 00531 char buf[MAX_TAG_LENGTH]; 00532 00533 char c=0; // Deliberate - file is not Unicode for now 00534 INT32 l=0; 00535 while (!s->Eof() && (c=s->GetC()) && (c != '\n') && (c != '\t') && (l<MAX_TAG_LENGTH)) 00536 { 00537 buf[l++]=c; 00538 } 00539 buf[l++]=0; 00540 buf[MAX_TAG_LENGTH-1]=0; 00541 if (buf[0]) 00542 { 00543 wxString name(buf, wxConvUTF8); 00544 00545 if (c == '\n') 00546 { 00547 buf[0]=0; 00548 } 00549 else 00550 { 00551 l=0; 00552 while (!s->Eof() && (c=s->GetC()) && (c != '\n') && (l<MAX_TAG_LENGTH)) 00553 { 00554 buf[l++]=c; 00555 } 00556 buf[MAX_TAG_LENGTH-1]=0; 00557 } 00558 buf[l++]=0; 00559 wxString text(buf, wxConvUTF8); 00560 00561 // Now de-XMLize it 00562 wxString otext; 00563 UINT32 n=0; 00564 while (n<text.Length()) 00565 { 00566 wxChar tc=text.GetChar(n++); 00567 if (tc==_T('&')) 00568 { 00569 // It's an ampersand escape sequence. Read till a semicolon 00570 wxString seq; 00571 while (tc !=_T(';') && n<text.Length()) 00572 { 00573 tc=text.GetChar(n++); 00574 seq+=tc; 00575 } 00576 00577 if (seq == _T("amp;")) 00578 { 00579 tc=_T('&'); 00580 } 00581 else if (seq == _T("lt;")) 00582 { 00583 tc=_T('<'); 00584 } 00585 else if (seq == _T("gt;")) 00586 { 00587 tc=_T('>'); 00588 } 00589 else if (seq == _T("quot;")) 00590 { 00591 tc=_T('"'); 00592 } 00593 else if ((seq.Length()>3) && (seq.GetChar(0)==_T('#')) && (seq.GetChar(1)==_T('x'))) 00594 { 00595 tc=_T('?'); 00596 UINT32 code=tc; 00597 // It's an alphanumeric form of a unicode character in hex 00598 #if wxUSE_UNICODE 00599 sscanf((const char*)seq.mb_str(wxConvUTF8), "#x%x;", &code); 00600 #else 00601 sscanf((const char*)seq.c_str(), "#x%x;", &code); 00602 #endif 00603 tc=(TCHAR)(code); 00604 } 00605 else if ((seq.Length()>2) && (seq.GetChar(0)==_T('#')) && ((seq.GetChar(1)>=_T('0')) && (seq.GetChar(1)<=_T('9')))) 00606 { 00607 tc=_T('?'); 00608 UINT32 code=tc; 00609 // It's an alphanumeric form of a unicode character in decimal 00610 #if wxUSE_UNICODE 00611 sscanf((const char*)seq.mb_str(wxConvUTF8), "#%d;", &code); 00612 #else 00613 sscanf((const char*)seq.c_str(), "#%d;", &code); 00614 #endif 00615 tc=(TCHAR)(code); 00616 } 00617 else 00618 { 00619 TRACE(_T("CamResource::ReadStringTableFile - Unknown XML escape sequence [&%s] in %s, %s"),seq.c_str(),name.c_str(),text.c_str()); 00620 otext+=_T('&')+seq; 00621 tc=0; // don't add 00622 } 00623 } 00624 if (tc) 00625 { 00626 otext+=tc; 00627 } 00628 } 00629 00630 // Here we could translate it using wxGetTranslation 00631 // Or we could muck around on non UTF-8 encodings 00632 // but that would be really boring. 00633 count++; 00634 AddStringResource(name.c_str(), ::wxGetTranslation(otext.c_str())); 00635 } 00636 } 00637 00638 TRACE(_T("Added %d strings"),count); 00639 if (count<1000) return FALSE; // some bad thing has happened. 00640 00641 return TRUE; 00642 }
|
|
Remembers an objectname that has been GetResourceID'd prior to the ObjectHash existing.
Definition at line 413 of file camresource.cpp. 00414 { 00415 TCHAR * text = camStrdup(ObjectName); 00416 if (!text) return; // we can't error, we can't trace, so meekly forget it 00417 CamResourceRemember * pRem = new CamResourceRemember; 00418 if (!pRem) return; // we can't error, we can't trace, so meekly forget it 00419 00420 pRem->text = text; // fill in text 00421 00422 // Now add to our linked list, and return 00423 pRem->next = pFirstRemember?pFirstRemember:NULL; 00424 pFirstRemember=pRem; 00425 return; 00426 }
|
|
Definition at line 334 of file camresource.h. 00334 {s_GenerateXRCCheck=flag;}
|
|
Destructor.
Definition at line 942 of file camresource.cpp. 00943 { 00944 if (pResourcePath) 00945 { 00946 delete (pResourcePath); 00947 pResourcePath = NULL; 00948 } 00949 00950 HaveCheckedResourcePath=FALSE; 00951 00952 if (!str.IsEmpty()) 00953 { 00954 pResourcePath = new(wxString); 00955 if (pResourcePath) *pResourcePath = str; 00956 } 00957 return; 00958 }
|
|
Put up a splash screen.
Definition at line 1773 of file camresource.cpp. 01774 { 01775 TRACET(_T("CamResource::Splash() called")); 01776 01777 if (pSplashBitmap) delete pSplashBitmap; 01778 pSplashBitmap=NULL; 01779 01780 01781 pSplashBitmap = new wxBitmap(); 01782 if (!pSplashBitmap) return FALSE; 01783 01784 // We'd like to get the bitmap name from the resources, but, urm, we haven't yet 01785 // loaded them 01786 if (!LoadwxBitmap(*pSplashBitmap, _T("startup-lx.png") )) 01787 { 01788 TRACE(_T("Cannot load splash bitmap - possible resource compilation error?")); 01789 return TRUE; 01790 } 01791 01792 if (!pSplashBitmap->Ok()) return FALSE; 01793 01794 pSplashScreen = new wxAdvSplashScreen(*pSplashBitmap, 01795 wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 01796 0, NULL, -1, wxDefaultPosition, wxDefaultSize, 01797 wxNO_BORDER 01798 #if 0 && !defined (_DEBUG) 01799 |wxSTAY_ON_TOP // Only stay on top in non-debug builds - too annoying for preinit debugging 01800 #endif 01801 ); 01802 if (!pSplashScreen) return FALSE; 01803 01804 wxYield(); 01805 01806 return TRUE; 01807 }
|
|
Definition at line 332 of file camresource.h. |
|
Definition at line 201 of file camresource.h. |
|
Definition at line 248 of file camresource.h. |
|
Definition at line 247 of file camresource.h. |
|
Definition at line 250 of file camresource.h. |
|
Definition at line 216 of file camresource.h. |
|
Definition at line 215 of file camresource.h. |
|
Definition at line 256 of file camresource.h. |
|
Definition at line 210 of file camresource.h. |
|
Definition at line 251 of file camresource.h. |
|
Definition at line 245 of file camresource.h. |
|
Definition at line 211 of file camresource.h. |
|
Definition at line 246 of file camresource.h. |
|
Definition at line 249 of file camresource.h. |
|
Definition at line 253 of file camresource.h. |
|
Definition at line 254 of file camresource.h. |
|
Definition at line 214 of file camresource.h. |
|
Definition at line 213 of file camresource.h. |
|
Definition at line 217 of file camresource.h. |
|
Definition at line 212 of file camresource.h. |