lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] help implementation


From: Vaclav Slavik
Subject: Re: [lmi] help implementation
Date: Wed, 27 Feb 2008 22:38:36 +0100
User-agent: KMail/1.9.9

Greg Chicares wrote:
>  - If the focused window contains controls governed by XRC,
>    then we use <help> and possibly helptext="...". The user
>    interface by which the wx help provider serves up the
>    help text is just great; I wouldn't change it at all.
>
>  - Otherwise, we show the main page of the help book.

Below is a patch to add F1 support. Pressing F1 on controls with
<help> in policy editor doesn't uses popup and help viewer is shown
instead under wxMSW, I'll have to look into it further.

diff -ruN lmi.orig/lmihelp.hhc lmi/lmihelp.hhc
--- lmi.orig/lmihelp.hhc        1970-01-01 01:00:00.000000000 +0100
+++ lmi/lmihelp.hhc     2008-02-27 22:10:08.000000000 +0100
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<HTML>
+<HEAD>
+<!-- Sitemap 1.0 -->
+</HEAD><BODY>
+<OBJECT type="text/site properties">
+ <param name="ImageType" value="Folder">
+</OBJECT>
+<UL>
+<LI> <OBJECT type="text/sitemap">
+<param name="Local" value="index.html">
+<param name="Name" value="Contents">
+</OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+  <param name="Local" value="doc1.htm#intro">
+  <param name="Name" value="Introduction">
+  </OBJECT>
+<UL> <LI> <OBJECT type="text/sitemap">
+  <param name="Local" value="doc2.htm#classes">
+  <param name="Name" value="Classes">
+  </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+  <param name="Local" value="doc3.htm#functions">
+  <param name="Name" value="Functions">
+  </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+  <param name="Local" value="doc4.htm#about">
+  <param name="Name" value="About">
+  </OBJECT>
+</UL> <LI> <OBJECT type="text/sitemap">
+  <param name="Local" value="doc5.htm#chapter2">
+  <param name="Name" value="Chapter 2">
+  </OBJECT>
+</UL>
diff -ruN lmi.orig/lmihelp.hhp lmi/lmihelp.hhp
--- lmi.orig/lmihelp.hhp        1970-01-01 01:00:00.000000000 +0100
+++ lmi/lmihelp.hhp     2008-02-27 22:11:02.000000000 +0100
@@ -0,0 +1,19 @@
+[OPTIONS]
+Compatibility=1.1 or later
+Compiled file=lmihelp.chm
+Contents file=lmihelp.hhc
+Default Window=default
+Default topic=index.html
+Display compile progress=Yes
+Full-text search=Yes
+Language=0x809 English (United Kingdom)
+Title=LMI Help
+
+[WINDOWS]
+default="LMI Help","lmihelp.hhc",,"index.html",,,,,,0x2420,,0x380e,,,,,0,,,0
+
+
+[FILES]
+index.html
+
+[INFOTYPES]
diff -ruN lmi.orig/main_wx.cpp lmi/main_wx.cpp
--- lmi.orig/main_wx.cpp        2008-02-27 22:29:05.000000000 +0100
+++ lmi/main_wx.cpp     2008-02-27 22:14:51.000000000 +0100
@@ -84,6 +84,7 @@
 
 #include <wx/config.h>
 #include <wx/docmdi.h>
+#include <wx/html/helpctrl.h>
 #include <wx/image.h>
 #include <wx/log.h>                 // wxSafeShowMessage()
 #include <wx/menu.h>
@@ -119,6 +120,7 @@
 BEGIN_EVENT_TABLE(Skeleton, wxApp)
     EVT_DROP_FILES(                                    
Skeleton::UponDropFiles                    )
     
EVT_MENU(wxID_ABOUT                               ,Skeleton::UponAbout          
              )
+    
EVT_MENU(wxID_HELP                                ,Skeleton::UponHelp           
              )
     
EVT_MENU(XRCID("edit_default_cell"               
),Skeleton::UponEditDefaultCell              )
     
EVT_MENU(XRCID("preferences"                     ),Skeleton::UponPreferences    
              )
     
EVT_MENU(XRCID("test_app_status_alert"           ),Skeleton::UponTestAppStatus  
              )
@@ -251,9 +253,10 @@
 // similar manner for other lmi user interfaces.
 
 Skeleton::Skeleton()
-    :doc_manager_ (0)
-    ,frame_       (0)
-    ,timer_       (this)
+    :doc_manager_     (0)
+    ,frame_           (0)
+    ,help_controller_ (0)
+    ,timer_           (this)
 {
     SetAppName("lmi_wx");
     SetVendorName("lmi");
@@ -433,6 +436,20 @@
         );
 }
 
+void Skeleton::InitHelp()
+{
+    help_controller_ = new(wx) wxHtmlHelpController
+        (wxHF_DEFAULT_STYLE
+        ,frame_);
+
+    fs::path 
path(global_settings::instance().data_directory() / "lmihelp.hhp");
+
+    if(!help_controller_->AddBook(path.string()))
+        {
+        fatal_error() << "Unable to load help files." << LMI_FLUSH;
+        }
+}
+
 void Skeleton::InitIcon()
 {
 #ifdef LMI_MSW
@@ -483,6 +500,11 @@
     AboutDialog(frame_).ShowModal();
 }
 
+void Skeleton::UponHelp(wxCommandEvent&)
+{
+    help_controller_->DisplayContents();
+}
+
 void Skeleton::UponDropFiles(wxDropFilesEvent& event)
 {
     wxString const* filenames = event.GetFiles();
@@ -538,6 +560,7 @@
     doc_manager_->FileHistorySave(*config_);
     delete doc_manager_;
     delete config_;
+    delete help_controller_;
     return 0;
 }
 
@@ -621,6 +644,7 @@
             ,wxClipboardTextEventHandler(Skeleton::UponPaste)
             );
 
+        InitHelp();
         InitIcon();
         InitMenuBar();
         InitToolBar();
diff -ruN lmi.orig/main_wx.hpp lmi/main_wx.hpp
--- lmi.orig/main_wx.hpp        2008-02-27 22:29:06.000000000 +0100
+++ lmi/main_wx.hpp     2008-02-27 21:58:24.000000000 +0100
@@ -52,6 +52,7 @@
 class WXDLLEXPORT wxDocument;
 class WXDLLEXPORT wxMDIChildFrame;
 class WXDLLEXPORT wxMenuBar;
+class WXDLLIMPEXP_HTML wxHtmlHelpController;
 
 class Skeleton
     :public wxApp
@@ -69,11 +70,13 @@
     wxMenuBar* AdjustMenus(wxMenuBar*);
 
     void InitDocManager ();
+    void InitHelp       ();
     void InitIcon       ();
     void InitMenuBar    ();
     void InitToolBar    ();
 
     void UponAbout                        (wxCommandEvent&);
+    void UponHelp                         (wxCommandEvent&);
     void UponDropFiles                    (wxDropFilesEvent&);
     void UponEditDefaultCell              (wxCommandEvent&);
     void UponMenuOpen                     (wxMenuEvent&);
@@ -124,6 +127,8 @@
     wxConfigBase* config_;
     DocManagerEx* doc_manager_;
     wxDocMDIParentFrame* frame_;
+    wxHtmlHelpController* help_controller_;
+
     wxTimer timer_;
 
     DECLARE_EVENT_TABLE()
diff -ruN lmi.orig/menus.xrc lmi/menus.xrc
--- lmi.orig/menus.xrc  2008-02-27 22:29:06.000000000 +0100
+++ lmi/menus.xrc       2008-02-27 22:30:29.000000000 +0100
@@ -229,6 +229,11 @@
 <object class="wxMenu" name="help_menu_ref">
     <label>_Help</label>
     <help>Help</help>
+    <object class="wxMenuItem" name="wxID_HELP">
+        <label>_Contents\tF1</label>
+        <help>Open documentation</help>
+    </object>
+    <object class="separator"/>
     <object class="wxMenuItem" name="wxID_ABOUT">
         <label>_About...</label>
         <bitmap>about.xpm</bitmap>


The lmihelp.hh? files wxHtmlHelpController uses are uncompressed
MS HTML Help files ("source code" for compiled CHM files), so
any future switch to CHM would be trivial. I included larger .hhc
file to show you how hierarchies are constructed. And I didn't
include keywords/index file (.hhk) under the assumption that you
won't use it. Look at wx's samples/help for larger examples of
MS HTML Help .hh{p,c,k} files -- if the attached files aren't
self-explanatory enough, samples/help's should be (I'm not aware
of any documentation of the format of these files, it seems to
be defined as "whatever HTML Help Workshop produces").


Vaclav

-- 
PGP key: 0x465264C9, available from http://pgp.mit.edu/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]