include/ax/ax_textctrl.h

Go to the documentation of this file.
00001 
00002 // Name:        ax_textctrl.h
00003 // Purpose:     Accessibility classes: AxTextCtrl (speaking text control)
00004 // Author:      Julian Smart
00005 // Modified by:
00006 // Created:     2009-03-20
00007 // RCS-ID:
00008 // Copyright:   (c) Julian Smart
00009 // Licence:     New BSD License
00011 
00012 #ifndef _AX_TEXTCTRL_H_
00013 #define _AX_TEXTCTRL_H_
00014 
00015 #include "wx/textctrl.h"
00016 #include "ax/ax_speech.h"
00017 #include "ax/ax_ui_adaptation.h"
00018 
00019 class AxTextCtrlAdapter;
00020 class AxSpeech;
00021 class wxShortcutManager;
00022 
00023 enum { AxTextCtrlNext = 0x01,
00024        AxTextCtrlPrevious = 0x02
00025 };
00026 
00035 class AxTextCtrl: public wxTextCtrl
00036 {
00037     DECLARE_DYNAMIC_CLASS( AxTextCtrl )
00038 
00039 public:
00040 // Constructors
00041 
00042     AxTextCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString,
00043         const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
00044         int style = 0)
00045     {
00046         Init();
00047         Create(parent, id, value, pos, size, style);
00048     }
00049 
00050     AxTextCtrl() { Init(); }
00051     ~AxTextCtrl();
00052 
00053     bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString,
00054         const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
00055         int style = 0);
00056 
00057 // Operations
00058 
00059     void Init();
00060 
00061     AxTextCtrlAdapter* GetTextEventHandler() const { return m_textEventHandler; }
00062     void SetTextEventHandler(AxTextCtrlAdapter* handler) { m_textEventHandler = handler; }
00063 
00064     void SetShortcutManager(wxShortcutManager* shortcutManager);
00065     wxShortcutManager* GetShortcutManager() const;
00066 
00067     void SetSpeech(AxSpeech* speech);
00068     AxSpeech* GetSpeech() const;
00069 
00070 protected:
00071 
00072     AxTextCtrlAdapter* m_textEventHandler;
00073 };
00074 
00084 class AxTextCtrlAdapter: public AxAdapter
00085 {
00086     DECLARE_DYNAMIC_CLASS( AxTextCtrlAdapter )
00087     DECLARE_EVENT_TABLE()
00088 
00089 public:
00090 // Constructors
00091 
00092     AxTextCtrlAdapter(wxTextCtrlBase* ctrl = NULL, AxSpeech* speech = NULL)
00093     {
00094         Init();
00095 
00096         m_textCtrl = ctrl;
00097         if (speech)
00098             SetSpeech(speech);
00099     }
00100 
00101     ~AxTextCtrlAdapter();
00102 
00103 // Operations
00104 
00105     void Init();
00106 
00107 // Overrides
00108 
00110     virtual wxString GetName();
00111 
00114     virtual wxString GetStateText(AxContentLevel level);
00115 
00117     virtual wxString GetContent(AxContentLevel level);
00118 
00120     virtual wxString GetLabel() { return GetStaticLabel(); }
00121 
00123     virtual bool UpdateAppearance(int hints);
00124 
00125 // New functions
00126 
00128     virtual bool ReadCurrentSentence();
00129 
00131     virtual bool ReadNextSentence();
00132 
00134     virtual bool ReadPreviousSentence();
00135 
00137     virtual bool ReadCurrentParagraph();
00138 
00140     virtual bool ReadPreviousParagraph();
00141 
00143     virtual bool ReadNextParagraph();
00144 
00146     virtual bool ReadCurrentWord();
00147 
00149     virtual bool ReadPreviousWord();
00150 
00152     virtual bool ReadNextWord();
00153 
00155     virtual bool SpellWord();
00156 
00158     virtual bool ReadFromCurrentPosition();
00159 
00161     virtual bool ReadFromStart();
00162 
00164     virtual bool DescribeContext();
00165 
00166     void SetTextCtrl(wxTextCtrlBase* ctrl) { m_textCtrl = ctrl; }
00167     wxTextCtrlBase* GetTextCtrl() const { return m_textCtrl; }
00168 
00169     bool GetWord(long currentPos, long& from, long& to, wxString& value);
00170     bool GetSentence(long currentPos, long& from, long& to, wxString& value);
00171     bool GetParagraph(long currentPos, long& from, long& to, wxString& value);
00172 
00173     long FindNextWordPosition(long currentPos, int direction);
00174     long FindNextSentencePosition(long currentPos, int direction);
00175     long FindNextParagraphPosition(long currentPos, int direction);
00176 
00177     bool EatWhitespace(long& pos);
00178 
00179     wxChar GetChar(long pos);
00180 
00181     void OnReadCurrentWord(wxCommandEvent& event);
00182     void OnReadNextWord(wxCommandEvent& event);
00183     void OnReadPreviousWord(wxCommandEvent& event);
00184     void OnReadCurrentSentence(wxCommandEvent& event);
00185     void OnReadNextSentence(wxCommandEvent& event);
00186     void OnReadPreviousSentence(wxCommandEvent& event);
00187     void OnReadCurrentParagraph(wxCommandEvent& event);
00188     void OnReadNextParagraph(wxCommandEvent& event);
00189     void OnReadPreviousParagraph(wxCommandEvent& event);
00190     void OnReadFromHere(wxCommandEvent& event);
00191     void OnReadAll(wxCommandEvent& event);
00192 
00193     void OnDescribeContext(wxCommandEvent& event);
00194 
00195 protected:
00196 
00197     wxTextCtrlBase*     m_textCtrl;
00198 };
00199 
00209 class wxSearchCtrl;
00210 
00211 class AxSearchCtrlAdapter: public AxTextCtrlAdapter
00212 {
00213     DECLARE_DYNAMIC_CLASS( AxSearchCtrlAdapter )
00214     DECLARE_EVENT_TABLE()
00215 
00216 public:
00217 // Constructors
00218 
00219     AxSearchCtrlAdapter() {}
00220 
00221 // Overrides
00222 
00224     virtual wxString GetName();
00225 
00228     virtual wxString GetStateText(AxContentLevel level);
00229 
00231     virtual wxString GetContent(AxContentLevel level);
00232 
00235     virtual wxWindow* GetMainControl() const;
00236 
00237 // New functions
00238 
00239     void OnCommand(wxCommandEvent& event);
00240 
00241     wxSearchCtrl* GetSearchCtrl() const;
00242 
00243 protected:
00244 };
00245 
00254 class AxTextCtrlVoiceAdaptationHandler: public AxVoiceAdaptationHandler
00255 {
00256     DECLARE_DYNAMIC_CLASS( AxTextCtrlVoiceAdaptationHandler )
00257 
00258 public:
00259     AxTextCtrlVoiceAdaptationHandler() {}
00260 
00262     virtual bool CanHandleWindow(wxWindow* win);
00263 
00265     virtual AxAdapter* CreateEventHandler(wxWindow* win);
00266 
00269     virtual bool Adapt(wxWindow* window, AxSpeech* speech, wxShortcutManager* shortcuts, wxArrayInt& ids);
00270 
00272     virtual bool Unadapt(wxWindow* window, wxArrayInt& ids);
00273 
00275     virtual bool CanRecursivelyAdapt(wxWindow* window) const;
00276 };
00277 
00278 
00279 #endif
00280     // _AX_TEXTCTRL_H_

Generated on Wed May 6 19:20:18 2009 for AxTk by  doxygen 1.5.1