helpbase.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/helpbase.h
  3. // Purpose: Help system base classes
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 04/01/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_HELPBASEH__
  11. #define _WX_HELPBASEH__
  12. #include "wx/defs.h"
  13. #if wxUSE_HELP
  14. #include "wx/object.h"
  15. #include "wx/string.h"
  16. #include "wx/gdicmn.h"
  17. #include "wx/frame.h"
  18. // Flags for SetViewer
  19. #define wxHELP_NETSCAPE 1
  20. // Search modes:
  21. enum wxHelpSearchMode
  22. {
  23. wxHELP_SEARCH_INDEX,
  24. wxHELP_SEARCH_ALL
  25. };
  26. // Defines the API for help controllers
  27. class WXDLLIMPEXP_CORE wxHelpControllerBase: public wxObject
  28. {
  29. public:
  30. inline wxHelpControllerBase(wxWindow* parentWindow = NULL) { m_parentWindow = parentWindow; }
  31. inline ~wxHelpControllerBase() {}
  32. // Must call this to set the filename and server name.
  33. // server is only required when implementing TCP/IP-based
  34. // help controllers.
  35. virtual bool Initialize(const wxString& WXUNUSED(file), int WXUNUSED(server) ) { return false; }
  36. virtual bool Initialize(const wxString& WXUNUSED(file)) { return false; }
  37. // Set viewer: only relevant to some kinds of controller
  38. virtual void SetViewer(const wxString& WXUNUSED(viewer), long WXUNUSED(flags) = 0) {}
  39. // If file is "", reloads file given in Initialize
  40. virtual bool LoadFile(const wxString& file = wxEmptyString) = 0;
  41. // Displays the contents
  42. virtual bool DisplayContents(void) = 0;
  43. // Display the given section
  44. virtual bool DisplaySection(int sectionNo) = 0;
  45. // Display the section using a context id
  46. virtual bool DisplayContextPopup(int WXUNUSED(contextId)) { return false; }
  47. // Display the text in a popup, if possible
  48. virtual bool DisplayTextPopup(const wxString& WXUNUSED(text), const wxPoint& WXUNUSED(pos)) { return false; }
  49. // By default, uses KeywordSection to display a topic. Implementations
  50. // may override this for more specific behaviour.
  51. virtual bool DisplaySection(const wxString& section) { return KeywordSearch(section); }
  52. virtual bool DisplayBlock(long blockNo) = 0;
  53. virtual bool KeywordSearch(const wxString& k,
  54. wxHelpSearchMode mode = wxHELP_SEARCH_ALL) = 0;
  55. /// Allows one to override the default settings for the help frame.
  56. virtual void SetFrameParameters(const wxString& WXUNUSED(title),
  57. const wxSize& WXUNUSED(size),
  58. const wxPoint& WXUNUSED(pos) = wxDefaultPosition,
  59. bool WXUNUSED(newFrameEachTime) = false)
  60. {
  61. // does nothing by default
  62. }
  63. /// Obtains the latest settings used by the help frame and the help
  64. /// frame.
  65. virtual wxFrame *GetFrameParameters(wxSize *WXUNUSED(size) = NULL,
  66. wxPoint *WXUNUSED(pos) = NULL,
  67. bool *WXUNUSED(newFrameEachTime) = NULL)
  68. {
  69. return NULL; // does nothing by default
  70. }
  71. virtual bool Quit() = 0;
  72. virtual void OnQuit() {}
  73. /// Set the window that can optionally be used for the help window's parent.
  74. virtual void SetParentWindow(wxWindow* win) { m_parentWindow = win; }
  75. /// Get the window that can optionally be used for the help window's parent.
  76. virtual wxWindow* GetParentWindow() const { return m_parentWindow; }
  77. protected:
  78. wxWindow* m_parentWindow;
  79. private:
  80. DECLARE_CLASS(wxHelpControllerBase)
  81. };
  82. #endif // wxUSE_HELP
  83. #endif
  84. // _WX_HELPBASEH__