00001
00002
00003
00004
00005
00008
00009 #ifndef _ROKU_INCLUDE_CASCADE_APP_CASCADEAPP_H
00010 #define _ROKU_INCLUDE_CASCADE_APP_CASCADEAPP_H
00011
00012 #include <cascade/CascadeObject.h>
00013 #include <cascade/app/CascadeAppMessageSink.h>
00014 #include <cascade/app/CascadeMountMessage.h>
00015 #include <cascade/app/CascadePowerMessage.h>
00016 #include <cascade/app/CascadeTimer.h>
00017 #include <cascade/app/CascadeWindow.h>
00018 #include <cascade/graphics/CascadeScreenMessage.h>
00019 #include <cascade/interprocess/CascadeWormhole.h>
00020 #include <cascade/interprocess/CascadeSharedMemZone.h>
00021 #include <cascade/util/CascadeArray.h>
00022
00225 class CascadeApp : public CascadeObject
00226 {
00227 public:
00228 CascadeApp();
00238 virtual ~CascadeApp();
00245 public:
00246 int Run(int argc, const char ** argv);
00269 void Terminate(int nExitCode);
00291 public:
00292 inline int GetArgc() const { return m_nArgc; }
00298 inline const char ** GetArgv() const { return m_ppArgv; }
00304
00305 inline const char * GetAppName() const { return m_pAppName; }
00313 inline int GetAppPID() const { return m_nPID; }
00324 inline const char * GetAppWormholeURL() const { return m_pWormholeURL; }
00333 public:
00334 inline static CascadeApp * GetApp() { return s_pTheApp; }
00343 static bool MakeAppWormholeURL(int nAppPID, char * pBuff, u32 nBuffLen);
00356 public:
00357 void SetFocusWindow(CascadeWindow * pWindow, bool bRedraw = true);
00373 void ClearFocusWindow(bool bRedraw = true);
00385 inline CascadeWindow * GetFocusWindow() { return m_pWndFocus; }
00390 public:
00391 bool IsActive();
00401 void Activate();
00418 void Activate(const char * pAppName, int nAppPID = 0);
00425 void Deactivate();
00437 void RegisterInactiveKeyInterest(bool bInterest);
00452 typedef bool (EnumProc)(const char * pAppName, int nAppPID, void * pClientData);
00468 static bool EnumerateApps(EnumProc * pEnumProc, void * pClientData);
00477 void RegisterECPCommand(const CascadeString & command);
00487 void UnregisterECPCommand(const CascadeString & command);
00493 void RegisterForSignal(int nSignum);
00506 void UnregisterForSignal(int nSignum);
00514 protected:
00515 virtual void OnAppInit();
00529 virtual void OnAppExit();
00536 virtual void OnActivate();
00546 virtual void OnDeactivate();
00554 virtual void OnKeyDown(u32 nKey);
00562 virtual void OnKeyDownInactive(u32 nKey);
00570 virtual void OnKeyUp(u32 nKey);
00578 virtual void OnKeyUpInactive(u32 nKey);
00586 virtual void OnMountMessage(const CascadeMountMessage & mountMessage);
00593 virtual void OnPowerMessage(const CascadePowerMessage & powerMessage);
00600 virtual void OnScreenMessage(const CascadeScreenMessage & screenMessage);
00607 virtual void OnWormholeMessage(const CascadeMessage & message);
00635 virtual void OnWidgetParametersChanged();
00641 virtual void OnECPCommand(const CascadeString & command, CascadeString & resultToSet);
00650 virtual void OnSignal(int nSignum);
00669 protected:
00670 CascadeWormhole m_appWormhole;
00694
00695 private:
00696 u64 GetKernelTime();
00697 void RunMessagePump();
00698 void DispatchMessage(const CascadeMessage & message);
00699 void ProcessWindowOpMessage(const CascadeMessage & message);
00700 void ProcessInputMessage(const CascadeMessage & message);
00701 void ProcessECPMessage(const CascadeMessage & message);
00702 void ProcessWidgetParmsChangedMessage(const CascadeMessage & message);
00703 bool Initialize();
00704 void Uninitialize();
00705 private:
00706 void MaterializeWindow(CascadeWindow * pWindow, CascadeWindow::Plane plane);
00707 void VanishWindow(CascadeWindow * pWindow);
00708 void RedrawWindow(CascadeWindow * pWindow);
00709 void RedrawWindow(CascadeWindow * pWindow, const CascadeRect & rect);
00710 bool IsWindowVisible(CascadeWindow * pWindow);
00711 void RedrawScreen();
00712 void RedrawAllAppWindows();
00713
00714 private:
00715 void ProcessKeyDown(u32 nKey, u32 nRepeatCount);
00716 void ProcessKeyUp(u32 nKey);
00717 bool ProcessLeftMouseButtonDown(u16 x, u16 y);
00718 bool ProcessRightMouseButtonDown(u16 x, u16 y);
00719 bool ProcessMiddleMouseButtonDown(u16 x, u16 y);
00720 bool ProcessLeftMouseButtonUp(u16 x, u16 y);
00721 bool ProcessRightMouseButtonUp(u16 x, u16 y);
00722 bool ProcessMiddleMouseButtonUp(u16 x, u16 y);
00723 bool ProcessLeftMouseButtonDoubleClick(u16 x, u16 y);
00724 bool ProcessRightMouseButtonDoubleClick(u16 x, u16 y);
00725 bool ProcessMiddleMouseButtonDoubleClick(u16 x, u16 y);
00726 bool ProcessMouseMove(u16 x, u16 y);
00727 void AddWindowToMaterializedList(CascadeWindow * pWindow);
00728 void RemoveWindowFromMaterializedList(CascadeWindow * pWindow);
00729
00730 private:
00731 u32 SetTimer(CascadeTimer * pTimer, u32 nMilliseconds);
00732 void KillTimer(CascadeTimer * pTimer, u32 nTimerID);
00733 void KillAllTimers(CascadeTimer * pTimer);
00734
00735 private:
00736 void AddRepaintReference(CascadeWindow * pWindow);
00737 void RemoveRepaintReference(CascadeWindow * pWindow);
00738 void RemoveFromRepaintList(CascadeWindow * pWindow);
00739 bool IsWindowInRepaintList(CascadeWindow * pWindow);
00740
00741 private:
00742 void AddMessageSink(CascadeAppMessageSink * pSink);
00743 void RemoveMessageSink(CascadeAppMessageSink * pSink);
00744
00745 private:
00746 static void StaticSignalHandler(int nSignum);
00747
00748 private:
00749 class WindowEntry
00750 {
00751 public:
00752 CascadeWindow * m_pWindow;
00753 WindowEntry * m_pNext;
00754 };
00755 private:
00756 int m_nArgc;
00757 const char ** m_ppArgv;
00758 const char * m_pAppName;
00759 const char * m_pWormholeURL;
00760 int m_nPID;
00761 int m_nExitCode;
00762 CascadeWindow * m_pWndFocus;
00763 CascadeSharedMemZone * m_pZoneApp;
00764 bool m_bTerminatePending;
00765 CascadeWindow * m_pMaterializationInProgressWindow;
00766 CascadeScreen m_screen;
00767
00768 u32 m_nMessageIDAppQuit;
00769 u32 m_nMessageIDActivate;
00770 u32 m_nMessageIDDeactivate;
00771 u32 m_nMessageIDCallOnActivate;
00772 u32 m_nMessageIDCallOnDeactivate;
00773 u32 m_nMessageIDInputMessage;
00774 u32 m_nMessageIDInputMessageReply;
00775 u32 m_nMessageIDWindowOp;
00776 u32 m_nMessageIDWidgetParmsChanged;
00777 u32 m_nMessageIDECPCommand;
00778
00779 u32 m_nNextTimerID;
00780 WindowEntry * m_pFirstWindowEntry;
00781 private:
00782 class TimerEntry
00783 {
00784 public:
00785 CascadeTimer * m_pTimer;
00786 u32 m_nTimerID;
00787 u32 m_nTimerDuration;
00788 u64 m_nFireTime;
00789 };
00790 private:
00791 bool ScheduleTimerEntry(TimerEntry & entry);
00792 private:
00793 class RepaintEntry
00794 {
00795 public:
00796 CascadeWindow * m_pWindow;
00797 u32 m_nRefCount;
00798 };
00799
00800 CascadeTemplateArray<TimerEntry> m_timers;
00801 CascadeTemplateArray<RepaintEntry> m_repaintList;
00802 CascadeTemplateArray<CascadeAppMessageSink *> m_messageSinks;
00803
00804 private:
00805 static CascadeApp * s_pTheApp;
00806
00807 private:
00808 #ifndef DOXY_SKIP
00809 friend class CascadeWindow;
00810 friend class CascadeTimer;
00811 friend class CascadeInput;
00812 friend class CascadeAppMessageSink;
00813 friend class CascadeMPEGPlayer;
00814 #endif
00815 };
00816
00817 #endif // #ifndef _ROKU_INCLUDE_CASCADE_APP_CASCADEAPP_H
00818
00820
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854