]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/forty/forty.cpp
fixes for Metrowerks command line compiler (avoid redefining stuff already defined...
[wxWidgets.git] / demos / forty / forty.cpp
index dc506c2b11a4fa4c339026d6d0a5005920a9f5f6..c71d8a241d638c877d8d03dce990300c61a67b74 100644 (file)
@@ -33,7 +33,7 @@
 #include "scoredg.h"
 
 #if wxUSE_HTML
-#include "wx/file.h"
+#include "wx/textfile.h"
 #include "wx/html/htmlwin.h"
 #endif
 
@@ -75,6 +75,13 @@ FortyApp::~FortyApp()
 bool FortyApp::OnInit()
 {
     bool largecards = false;
+#ifndef __WXWINCE__
+    m_helpFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("about.htm");
+    if (!wxFileExists(m_helpFile))
+#endif
+    {
+        m_helpFile = wxPathOnly(argv[0]) + wxFILE_SEP_PATH + wxT("about.htm");
+    }
 
     wxSize size(668,510);
 
@@ -198,7 +205,9 @@ FortyFrame::FortyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos
     SetSizer( topsizer );
     topsizer->SetSizeHints( this );
 
+#if wxUSE_STATUSBAR
     CreateStatusBar();
+#endif // wxUSE_STATUSBAR
 }
 
 FortyFrame::~FortyFrame()
@@ -231,7 +240,7 @@ void
 FortyFrame::Help(wxCommandEvent& event)
 {
 #if wxUSE_HTML
-    if (wxFileExists(wxT("about.htm")))
+    if (wxFileExists(wxGetApp().GetHelpFile()))
     {
         FortyAboutDialog dialog(this, wxID_ANY, wxT("Forty Thieves Instructions"));
         if (dialog.ShowModal() == wxID_OK)
@@ -322,22 +331,16 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
 {
 #if wxUSE_HTML
     wxString htmlText;
-    wxString htmlFile(wxT("about.htm"));
+    wxString htmlFile = wxGetApp().GetHelpFile();
 
-    //if (!wxGetApp().GetMemoryTextResource(wxT("about.htm"), htmlText))
     {
-//        wxSetWorkingDirectory(wxGetApp().GetAppDir());
-//        wxString htmlFile(wxGetApp().GetFullAppPath(wxT("about.htm")));
-        
-        if (wxFileExists(htmlFile))
+        wxTextFile file(htmlFile);
+        if (file.Exists())
         {
-            wxFile file;
-            file.Open(htmlFile, wxFile::read);
-            long len = file.Length();
-            wxChar* buf = htmlText.GetWriteBuf(len + 1);
-            file.Read(buf, len);
-            buf[len] = 0;
-            htmlText.UngetWriteBuf();
+            file.Open();
+            for ( htmlText = file.GetFirstLine(); 
+                  !file.Eof(); 
+                  htmlText << file.GetNextLine() << _T("\n") ) ;
         }
     }
 
@@ -347,11 +350,6 @@ bool FortyAboutDialog::AddControls(wxWindow* parent)
     }
 
     // Customize the HTML
-#if 0
-    wxString verString;
-    verString.Printf("%.2f", stVERSION_NUMBER);
-    htmlText.Replace(wxT("$VERSION$"), verString);
-#endif
     htmlText.Replace(wxT("$DATE$"), _T(__DATE__));
 
     wxSize htmlSize(400, 290);