TreeCtrl:
[wxWidgets.git] / src / generic / helphtml.cpp
index cabeb9a82543d98ba224e0350712f6c2539cd7a7..1eb1519c8fe2679b834e69793aa1a3304b835c30 100644 (file)
     #pragma hdrstop
 #endif
 
+#if wxUSE_HELP
+
 #ifndef WX_PRECOMP
     #include "wx/setup.h"
     #include "wx/string.h"
     #include "wx/utils.h"
     #include "wx/list.h"
     #include "wx/intl.h"
+    #include "wx/msgdlg.h"
+    #include "wx/choicdlg.h"
 #endif
 
 #include "wx/helpbase.h"
@@ -38,6 +42,8 @@
     #include   <unistd.h>
 #endif
 
+#define CONTENTS_ID   0
+
 class wxExtHelpMapEntry : public wxObject
 {
 public:
@@ -198,11 +204,30 @@ wxHTMLHelpControllerBase::DisplayContents()
    if(! m_NumOfEntries)
       return FALSE;
 
-   // use ID 0 for contents
-   if(! DisplaySection(0))
-      return KeywordSearch("");
-   else
-      return TRUE;
+   wxString contents;
+   wxNode *node = m_MapList->First();
+   wxExtHelpMapEntry *entry;
+   while(node)
+   {
+      entry = (wxExtHelpMapEntry *)node->Data();
+      if(entry->id == CONTENTS_ID)
+      {
+         contents = entry->url;
+         break;
+      }
+      node = node->Next();
+   }
+
+   bool rc = FALSE;
+   wxString file;
+   file << m_MapFile << WXEXTHELP_SEPARATOR << contents;
+   if(file.Contains(_T('#')))
+      file = file.BeforeLast(_T('#'));
+   if(contents.Length() && wxFileExists(file))
+      rc = DisplaySection(CONTENTS_ID);
+   
+   // if not found, open homemade toc:
+   return rc ? TRUE : KeywordSearch(_T(""));
 }
 
 bool
@@ -303,3 +328,4 @@ wxHTMLHelpControllerBase::OnQuit()
 {
 }
 
+#endif // wxUSE_HELP