include/ax/ax_view.h

Go to the documentation of this file.
00001 
00002 // Name:        ax_view.h
00003 // Purpose:     View classes
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_VIEW_H_
00013 #define _AX_VIEW_H_
00014 
00015 /*
00016  * Includes
00017  */
00018 
00019 #include "ax/ax_property.h"
00020 #include "ax/ax_activator.h"
00021 #include "ax/ax_speech.h"
00022 
00023 #include "wx/confbase.h"
00024 
00025 /*
00026  * Forward declarations
00027  */
00028 
00029 class AxMenuItem;
00030 class AxMenu;
00031 class AxMenuItemData;
00032 class AxDocument;
00033 class AxContainerCtrl;
00034 class AxPagerCtrl;
00035 class AxViewManager;
00036 class wxShortcutManager;
00037 
00042 enum {
00043     AxVisualSettingTextSize =           0x0001,
00044     AxVisualSettingTextColour =         0x0002,
00045     AxVisualSettingWindowColour =       0x0004,
00046     AxVisualSettingPanelColour =        0x0008,
00047     AxVisualSettingAll =                0xFFFF
00048 };
00049 
00058 class AxVisualSettings: public wxObject
00059 {
00060 public:
00061     AxVisualSettings() { Init(); }
00062     AxVisualSettings(const AxVisualSettings& info) { Copy(info); }
00063 
00064     void Init();
00065     void Copy(const AxVisualSettings& info);
00066     void operator=(const AxVisualSettings& info) { Copy(info); }
00067 
00068     void SetMenuItemDisabledTextColour(const wxColour& col) { m_menuItemDisabledTextColour = col; }
00069     const wxColour& GetMenuItemDisabledTextColour() const { return m_menuItemDisabledTextColour; }
00070 
00071     void SetMenuItemSelectedTextColour(const wxColour& col) { m_menuItemSelectedTextColour = col; }
00072     const wxColour& GetMenuItemSelectedTextColour() const { return m_menuItemSelectedTextColour; }
00073 
00074     void SetMenuItemBackgroundColour(const wxColour& col) { m_menuItemBackgroundColour = col; }
00075     const wxColour& GetMenuItemBackgroundColour() const { return m_menuItemBackgroundColour; }
00076    
00077     void SetMenuItemSelectedBackgroundColour(const wxColour& col) { m_menuItemSelectedBackgroundColour = col; }
00078     const wxColour& GetMenuItemSelectedBackgroundColour() const { return m_menuItemSelectedBackgroundColour; }
00079 
00080 #if 0
00081     void SetMenuItemTextColour(const wxColour& col) { m_menuItemTextColour = col; }
00082     const wxColour& GetMenuItemTextColour() const { return m_menuItemTextColour; }
00083 
00084     void SetMenuWindowBackgroundColour(const wxColour& col) { m_menuWindowBackgroundColour = col; }
00085     const wxColour& GetMenuWindowBackgroundColour() const { return m_menuWindowBackgroundColour; }
00086     
00087     void SetMenuFont(const wxFont& font) { m_menuFont = font; }
00088     const wxFont& GetMenuFont() const { return m_menuFont; }
00089 #endif
00090 
00093     void SetTextSize(int sz) { m_textSize = sz; }
00094 
00097     int GetTextSize() const { return m_textSize; }
00098 
00100     int GetBestTextSize() const;
00101 
00103     void SetTextColour(const wxColour& col) { m_textColour = col; }
00104 
00106     const wxColour& GetTextColour() const { return m_textColour; }
00107 
00109     wxColour GetBestTextColour() const;
00110 
00112     void SetWindowColour(const wxColour& col) { m_windowColour = col; }
00113 
00115     const wxColour& GetWindowColour() const { return m_windowColour; }
00116 
00118     wxColour GetBestWindowColour() const;
00119 
00121     void SetPanelColour(const wxColour& col) { m_panelColour = col; }
00122 
00124     const wxColour& GetPanelColour() const { return m_panelColour; }
00125 
00127     wxColour GetBestPanelColour() const;
00128 
00130     bool Load(wxConfigBase& config);
00131 
00133     bool Save(wxConfigBase& config);
00134 
00135 public:    
00136     wxColour    m_menuItemSelectedTextColour;
00137     wxColour    m_menuItemDisabledTextColour;
00138     wxColour    m_menuItemBackgroundColour;
00139     wxColour    m_menuItemSelectedBackgroundColour;
00140 
00141 #if 0
00142     wxColour    m_menuItemTextColour;
00143     wxColour    m_menuWindowBackgroundColour;
00144     wxFont      m_menuFont;
00145 #endif
00146 
00147     int         m_textSize;
00148     wxColour    m_textColour;
00149     wxColour    m_windowColour;    // e.g. text, list controls
00150     wxColour    m_panelColour;
00151 };
00152 
00165 class AxView: public wxEvtHandler
00166 {
00167     DECLARE_CLASS( AxView )
00168 
00169 public:
00170 // Constructors
00171 
00172     AxView() { Init(); }
00173     ~AxView() {}
00174 
00175 // Operations
00176 
00177     void Init();
00178 
00180     virtual bool Activate(AxViewManager* viewManager, AxDocument* doc) = 0;
00181 
00183     virtual bool Deactivate(AxViewManager* viewManager) = 0;
00184 
00187     virtual bool Initialize(AxViewManager* viewManager) = 0;
00188 
00190     virtual bool Uninitialize(AxViewManager* viewManager) = 0;
00191     
00193     virtual bool AssociateDocument(AxDocument* doc);
00194 
00197     virtual bool OnChangeMenuPre(AxMenu* currentMenu, AxMenu* newMenu);
00198 
00201     virtual bool OnChangeMenuPost(AxMenu* WXUNUSED(newMenu)) { return true; }
00202 
00204     virtual bool ShowWindow(AxViewManager* viewManager);
00205 
00207     wxWindow* GetWindow() const { return m_window; }
00208 
00210     void SetWindow(wxWindow* window) { m_window = window; }
00211 
00213     AxDocument* GetDocument() const { return m_document; }
00214 
00216     void SetDocument(AxDocument* doc) { m_document = doc; }
00217 
00219     bool IsActive() const { return m_active; }
00220 
00222     void SetActive(bool active) { m_active = active; }
00223 
00227     bool IsLive() const { return m_live; }
00228     void SetLive(bool live) { m_live = live; }
00229 
00231     AxViewManager* GetViewManager() const { return m_viewManager; }
00232 
00234     void SetViewManager(AxViewManager* manager) { m_viewManager = manager; }
00235 
00237     AxSpeech* GetSpeech() const;
00238 
00240     virtual bool Say(const wxString& text, int flags = AxSpeechFlagsPurge, int verbosity = 2);
00241 
00243     virtual bool Say(AxSpeechChannel channel, const wxString& text, int flags = AxSpeechFlagsPurge, int verbosity = 2);
00244 
00246     virtual bool StopSpeech(AxSpeechChannel channel = AxSpeechDefaultChannel);
00247 
00249     virtual bool PauseOrResumeSpeech(AxSpeechChannel channel = AxSpeechDefaultChannel);
00250 
00252     virtual bool SkipForward(AxSpeechChannel channel = AxSpeechDefaultChannel);
00253 
00255     virtual bool SkipBack(AxSpeechChannel channel = AxSpeechDefaultChannel);
00256 
00258     virtual bool IsSpeaking(AxSpeechChannel channel = AxSpeechDefaultChannel) const;
00259 
00261     virtual bool CanStop(AxSpeechChannel channel = AxSpeechDefaultChannel) const;
00262 
00264     virtual bool CanPause(AxSpeechChannel channel = AxSpeechDefaultChannel) const;
00265 
00267     virtual bool CanResume(AxSpeechChannel channel = AxSpeechDefaultChannel) const;
00268 
00270     void SetChannel(int channel) { m_channel = channel; }
00271 
00273     AxSpeechChannel GetChannel(AxSpeechChannel channel = AxSpeechDefaultChannel) const;
00274 
00275 protected:
00276 
00278     bool                m_active;
00279 
00282     bool                m_live;
00283 
00284     wxWindow*           m_window;
00285     AxDocument*         m_document;
00286     AxViewManager*      m_viewManager;
00287     AxSpeechChannel     m_channel;
00288 };
00289 
00290 WX_DEFINE_ARRAY_PTR(AxView*, AxViewArray);
00291 
00303 class AxViewManager: public wxEvtHandler
00304 {
00305     DECLARE_CLASS( AxViewManager )
00306 
00307 public:
00308 // Constructors
00309 
00310     AxViewManager() { Init(); }
00311     ~AxViewManager();
00312 
00313 // Operations
00314 
00316     void Init();
00317 
00319     void AddView(AxView* view) {  m_views.Add(view); }
00320     
00322     AxViewArray& GetViews() { return m_views; }
00323 
00325     AxView* FindView(wxClassInfo* info) const;
00326 
00328     AxView* FindOrCreateView(wxClassInfo* info);
00329 
00331     virtual bool ActivateView(AxView* view, AxDocument* doc);
00332 
00334     virtual bool DeactivateView(AxView* view);
00335 
00337     virtual bool MakeModal(bool showModal);
00338 
00340     AxView* GetActiveView() const { return m_activeView; }
00341 
00343     void ClearViews();
00344 
00346     void Clear();
00347 
00349     void SetMenuCtrl(wxWindow* ctrl) { m_menuCtrl = ctrl; }
00350 
00352     wxWindow* GetMenuCtrl() const { return m_menuCtrl; }
00353 
00355     void SetContainerCtrl(AxContainerCtrl* ctrl) { m_containerCtrl = ctrl; }
00356 
00358     AxContainerCtrl* GetContainerCtrl() const { return m_containerCtrl; }
00359 
00361     void SetViewPagerCtrl(AxPagerCtrl* ctrl) { m_viewPagerCtrl = ctrl; }
00362 
00364     AxPagerCtrl* GetViewPagerCtrl() const { return m_viewPagerCtrl; }
00365 
00367     void SetTitleCtrl(wxTextCtrl* ctrl) { m_titleCtrl = ctrl; }
00368 
00370     wxTextCtrl* GetTitleCtrl() const { return m_titleCtrl; }
00371 
00373     void SetDescriptionCtrl(wxTextCtrl* ctrl) { m_descriptionCtrl = ctrl; }
00374 
00376     wxTextCtrl* GetDescriptionCtrl() const { return m_descriptionCtrl; }
00377 
00379     AxMenuController* GetMenuController() { return m_menuController; }
00380 
00382     void SetMenuController(AxMenuController* controller);
00383 
00385     void SetShortcutManager(wxShortcutManager* manager) { m_shortcutManager = manager; }
00386 
00388     wxShortcutManager* GetShortcutManager() const { return m_shortcutManager; }
00389 
00391     bool ShowInitialMenu(AxMenu* menu);
00392 
00398     bool ShowMenu(AxMenu* menu, AxMenuItem* parentItem = NULL, AxMenu* childMenu = NULL);
00399 
00401     virtual bool ShowHomeView();
00402 
00404     wxString GetHomeDescription() const { return m_homeDescription; }
00405 
00407     void SetHomeDescription(const wxString& descr) { m_homeDescription = descr; }
00408 
00410     bool IsModal() const { return (m_modalCount > 0); }
00411 
00413     void SetVisualSettings(const AxVisualSettings& settings) { m_visualSettings = settings; }
00414     AxVisualSettings& GetVisualSettings() { return m_visualSettings; }
00415     const AxVisualSettings& GetVisualSettings() const { return m_visualSettings; }
00416 
00418     AxSpeech& GetSpeech() { return m_speech; }
00419     const AxSpeech& GetSpeech() const { return m_speech; }
00420 
00422     virtual bool UpdateAppearance(wxWindow* window = NULL, int hints = AxVisualSettingAll);
00423 
00425     virtual bool StopSpeech();
00426 
00428     virtual bool CanStopSpeech();
00429 
00433     virtual bool IdleProcessing();
00434 
00436     static AxViewManager* Get() { return sm_viewManager; }
00437 
00438 protected:
00439 
00440     AxViewArray         m_views;
00441     AxView*             m_activeView;
00442     wxWindow*           m_menuCtrl;
00443     AxContainerCtrl*    m_containerCtrl;
00444     AxPagerCtrl*        m_viewPagerCtrl;
00445     wxTextCtrl*         m_titleCtrl;
00446     wxTextCtrl*         m_descriptionCtrl;
00447     AxMenuController*   m_menuController;
00448     wxString            m_homeDescription;
00449     int                 m_modalCount;
00450     AxVisualSettings    m_visualSettings;
00451     AxSpeech            m_speech;
00452     static AxViewManager* sm_viewManager;
00453     wxShortcutManager*  m_shortcutManager;
00454 };
00455 
00456 #endif
00457     // _AX_VIEW_H_

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