Update of /cvsroot/sharedaemon/ui-wx/src
In directory sc8-pr-cvs1:/tmp/cvs-serv31157
Modified Files:
Images.cpp Images.h
Log Message:
Moved images path making code into separate function.
Index: Images.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/Images.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- Images.cpp 21 Dec 2003 05:35:12 -0000 1.39
+++ Images.cpp 22 Dec 2003 01:55:10 -0000 1.40
@@ -52,53 +52,15 @@
* This method loads all images into the global variables.
*/
void CImages::LoadImages() {
- wxString path, apppath;
- wxChar sep;
+ wxString path;
tool_img_width = 32;
/* Just in case theres anything in there, delete it */
images.DeleteContents(true);
images.Clear();
- /**
- * We get the application binary path from argv[0], remove the binary
- * name from it, and use it as base for our resources. Needed if
- * application startup path != application binary path, which would
- * prevent us from accessing resources.
- */
- apppath = wxTheApp->argv[0];
- #if defined(__WXMSW__)
- sep = '\\';
- #else
- sep = '/';
- #endif
- while ((apppath.Last() != sep) && (apppath.Length()>1)) {
- apppath.RemoveLast();
- }
-
- #if defined(__WXMAC__) && defined(__MACH__)
- apppath.Append(wxT("../Resources/"));
- #endif
-
- m_config->Read(
- wxT("/General/IconSets/CurIconSet"), &path, wxT("Default")
- );
- path.MakeLower();
- path = wxString::Format(
- wxT("%simages/%s/"), apppath.c_str(), path.c_str()
- );
-
- /*
- * Under wxMac, the separator is :, and relative paths must be prepended
- * by :. We also prepend the path by ::Resources, as it is standard
- * under wxMac to have resources there.
- */
- #if defined(__WXMAC__) && !defined(__MACH__)
- path.Replace(wxT("/"), wxT(":"));
- path.Prepend(wxT(":"));
- path.Prepend(wxT("::Resources"));
- #endif
-
+ path = MakePath();
+
images.Append(
wxT("friend"),
new wxBitmap(path+wxT("friend.png"), wxBITMAP_TYPE_ANY)
@@ -386,3 +348,62 @@
y>tool_img_height ? tool_img_height=y : y=tool_img_width;
}
}
+
+/****************************************************************** MakePath */
+/* This method creates a platform-dependant path string for accessing images */
+/* from. Since various platforms use various standard locations for resouce */
+/* locations, this method handles it as follows: */
+/* Win32 @executable_path@/images/@iconsetname@/ */
+/* Linux @executable_path@/images/@iconsetname@/ */
+/* Mac OS X */
+/* CodeWarrior :@executable_path@::Resources:images:@iconsetname@ */
+/* GNU gcc @executable_path@/images/@iconsetname@/ */
+/* */
+/* TODO: Use /usr/share area on Linux */
+/* Check various locations, detect if images can be found. */
+/*****************************************************************************/
+wxString CImages::MakePath() {
+ wxString path, apppath;
+ wxChar sep;
+
+ /**
+ * We get the application binary path from argv[0], remove the binary
+ * name from it, and use it as base for our resources. Needed if
+ * application startup path != application binary path, which would
+ * prevent us from accessing resources.
+ */
+ apppath = wxTheApp->argv[0];
+ #if defined(__WXMSW__)
+ sep = '\\';
+ #else
+ sep = '/';
+ #endif
+ while ((apppath.Last() != sep) && (apppath.Length()>1)) {
+ apppath.RemoveLast();
+ }
+
+ #if defined(__WXMAC__) && defined(__MACH__)
+ apppath.Append(wxT("../Resources/"));
+ #endif
+
+ m_config->Read(
+ wxT("/General/IconSets/CurIconSet"), &path, wxT("Default")
+ );
+ path.MakeLower();
+ path = wxString::Format(
+ wxT("%simages/%s/"), apppath.c_str(), path.c_str()
+ );
+
+ /*
+ * Under wxMac, the separator is :, and relative paths must be prepended
+ * by :. We also prepend the path by ::Resources, as it is standard
+ * under wxMac to have resources there.
+ */
+ #if defined(__WXMAC__) && !defined(__MACH__)
+ path.Replace(wxT("/"), wxT(":"));
+ path.Prepend(wxT(":"));
+ path.Prepend(wxT("::Resources"));
+ #endif
+
+ return path;
+}
Index: Images.h
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/Images.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Images.h 20 Dec 2003 08:51:54 -0000 1.18
+++ Images.h 22 Dec 2003 01:55:10 -0000 1.19
@@ -44,7 +44,8 @@
void UpdateImages(wxWindow *parent);
void CalcToolBitmapSize(const wxArrayString &names);
private:
- ListOfBitmaps images;
+ ListOfBitmaps images;
+ wxString MakePath();
};
#endif /* __IMAGES_H__ */
|