00001 00002 // Name: ax_help_provider.h 00003 // Purpose: Special help text provider. 00004 // Author: Julian Smart 00005 // Modified by: 00006 // Created: 2009-04-16 00007 // RCS-ID: 00008 // Copyright: (c) Julian Smart 00009 // Licence: New BSD License 00011 00012 #ifndef _AX_HELP_PROVIDER_H_ 00013 #define _AX_HELP_PROVIDER_H_ 00014 00015 #include "wx/cshelp.h" 00016 00017 #include "wx/html/htmlwin.h" 00018 #include "wx/timer.h" 00019 00020 #if wxUSE_POPUPWIN 00021 #include "wx/popupwin.h" 00022 #endif 00023 00024 class AxSpeech; 00025 00050 class AxHelpProvider : public wxSimpleHelpProvider 00051 { 00052 public: 00053 00054 AxHelpProvider(AxSpeech* speech = NULL); 00055 ~AxHelpProvider(); 00056 00057 void Init(); 00058 00059 wxString GetWindowOrAdapterHelp(const wxWindowBase *window); 00060 00061 virtual wxString GetHelp(const wxWindowBase *window); 00062 00063 virtual bool ShowHelp(wxWindowBase *window); 00064 00065 AxSpeech* GetSpeech() const { return m_speech; } 00066 void SetSpeech(AxSpeech* speech) { m_speech = speech; } 00067 00068 static void SetHelpWindow(wxWindow* helpWindow) { sm_helpWindow = helpWindow; } 00069 00071 static void CleanUp(); 00072 00073 static wxWindow* sm_helpWindow; 00074 static wxWindow* sm_invokedFrom; 00075 00076 AxSpeech* m_speech; 00077 }; 00078 00079 #if wxUSE_POPUPWIN 00080 class AxHtmlToolTip: public wxPopupWindow 00081 #else 00082 class AxHtmlToolTip: public wxFrame 00083 #endif 00084 { 00085 DECLARE_EVENT_TABLE() 00086 DECLARE_CLASS(AxHtmlToolTip) 00087 public: 00088 AxHtmlToolTip(wxWindow* window); 00089 AxHtmlToolTip() { Init(); } 00090 ~AxHtmlToolTip(); 00091 00092 void Init(); 00093 00094 bool CreateWindow(); 00095 00096 virtual wxHtmlWindow* CreateHtmlWindow(); 00097 00098 void OnCloseWindow(wxCloseEvent& event); 00099 00100 // Set the plain text or HTML 00101 void SetTip(const wxString& tip); 00102 00103 // Use this to start showing the tip 00104 void StartShowing(); 00105 00106 // Move the tip to a suitable position relative to the object whose size 00107 // is defined by rect 00108 void MoveToGoodPosition(const wxRect& rect); 00109 00110 // Set width 00111 void SetWidth(int width) { m_htmlWidth = width; } 00112 int GetWidth() const { return m_htmlWidth; } 00113 00114 // Set margin between object and tip 00115 void SetMargin(int margin) { m_margin = margin; } 00116 int GetMargin() const { return m_margin; } 00117 00118 // Set show duration in milliseconds 00119 void SetShowDuration(int duration) { m_showDuration = duration; } 00120 int GetShowDuration() const { return m_showDuration; } 00121 00122 // Set auto-destroy 00123 void SetAutoDestroy(bool autoDestroy) { m_autoDestroy = autoDestroy; } 00124 bool GetAutoDestroy() const { return m_autoDestroy; } 00125 00126 // Set/get calling window 00127 void SetCallingWindow(wxWindow* callingWindow) { m_callingWindow = callingWindow; } 00128 wxWindow* GetCallingWindow() const { return m_callingWindow; } 00129 00130 // Set/get HTML window 00131 void SetHtmlWindow(wxHtmlWindow* win) { m_htmlWindow = win; } 00132 wxHtmlWindow* GetHtmlWindow() const { return m_htmlWindow; } 00133 00134 void OnTimeout(wxTimerEvent& event); 00135 void OnChar(wxKeyEvent& event); 00136 00137 wxHtmlWindow* m_htmlWindow; 00138 wxWindow* m_callingWindow; 00139 int m_htmlWidth; 00140 int m_margin; 00141 wxTimer m_timer; 00142 int m_showDuration; 00143 bool m_autoDestroy; // destroy on timeout 00144 }; 00145 00146 #endif // _AX_HELP_PROVIDER_H_ 00147