Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeApp Class Reference

base class of Cascade Applications More...

#include <cascade/app/CascadeApp.h>

Inheritance diagram for CascadeApp:

CascadeObject List of all members.

Public Types

typedef bool() EnumProc (const char *pAppName, int nAppPID, void *pClientData)

Public Member Functions

 CascadeApp ()
virtual ~CascadeApp ()
int Run (int argc, const char **argv)
void Terminate (int nExitCode)
int GetArgc () const
const char ** GetArgv () const
const char * GetAppName () const
int GetAppPID () const
const char * GetAppWormholeURL () const
void SetFocusWindow (CascadeWindow *pWindow, bool bRedraw=true)
void ClearFocusWindow (bool bRedraw=true)
CascadeWindowGetFocusWindow ()
bool IsActive ()
void Activate ()
void Activate (const char *pAppName, int nAppPID=0)
void Deactivate ()
void RegisterInactiveKeyInterest (bool bInterest)
void RegisterECPCommand (const CascadeString &command)
void UnregisterECPCommand (const CascadeString &command)
void RegisterForSignal (int nSignum)
void UnregisterForSignal (int nSignum)

Static Public Member Functions

static CascadeAppGetApp ()
static bool MakeAppWormholeURL (int nAppPID, char *pBuff, u32 nBuffLen)
static bool EnumerateApps (EnumProc *pEnumProc, void *pClientData)

Protected Member Functions

virtual void OnAppInit ()
virtual void OnAppExit ()
virtual void OnActivate ()
virtual void OnDeactivate ()
virtual void OnKeyDown (u32 nKey)
virtual void OnKeyDownInactive (u32 nKey)
virtual void OnKeyUp (u32 nKey)
virtual void OnKeyUpInactive (u32 nKey)
virtual void OnMountMessage (const CascadeMountMessage &mountMessage)
virtual void OnPowerMessage (const CascadePowerMessage &powerMessage)
virtual void OnScreenMessage (const CascadeScreenMessage &screenMessage)
virtual void OnWormholeMessage (const CascadeMessage &message)
virtual void OnWidgetParametersChanged ()
virtual void OnECPCommand (const CascadeString &command, CascadeString &resultToSet)
virtual void OnSignal (int nSignum)

Protected Attributes

CascadeWormhole m_appWormhole

Friends

class CascadeWindow
class CascadeTimer
class CascadeInput
class CascadeAppMessageSink
class CascadeMPEGPlayer

Classes

class  RepaintEntry
class  TimerEntry
class  WindowEntry

Detailed Description

base class of Cascade Applications

Skip the description

CascadeApp is the class most Cascade developers will use once in their application :)

It is a very high-level class that provides a foundation for easy collaborative participation in the Cascade Runtime.

CascadeApp provides the following features:

CascadeApp is very easy to use. Simply instantiate your own CascadeApp derived class and Run() it. The CascadeApp base class will take control of the calling thread and call your CascadeApp derived class' virtual member functions when appropriate.

Example: A Hello World CascadeApp

    // FILE: HelloWorldApp.cpp
    #include <cascade/Cascade.h>
    #include <stdio.h>

    class HelloWorldApp : public CascadeApp
    {
    protected:
        virtual void OnAppInit() { printf("Hello World.\\n"); Terminate(0); }
    };

    int main(int argc, const char ** argv)
    {
        HelloWorldApp myApp;
        return myApp.Run(argc, argv);
    }
    

In this example, we instantiate and Run() our app in function main. This is not a requirement but it is how 99% of CascadeApps will be run since it is a convenient place to do it. Once Run() is called, the process' main thread of execution is taken over by the CascadeApp base class. The CascadeApp base class waits for wormhole messages and dispatches them to virtual member functions in a tight message loop until Terminate() is called, at which point Run() relinquishes control back to the caller. All significant processing by the client is done in CascadeApp derived class virtual member functions.

See also:
Run(), Terminate()

The Cascade App Message Loop

Feel free to use CascadeApp for all your applications; it is very high-performance. Make sure you thoroughly understand how your CascadeApp will interact with other CascadeApps on the system. Read on, brave soldier.

A few words on CascadeApp Thread Safety

The CascadeApp class is not inherently thread safe. Usually you will only be using your CascadeApp class within the context of one thread - your process' main thread of execution. If you wish to access a CascadeApp object from multiple threads in your process, be sure to protect access to your CascadeApp object with a CascadeMutex or other thread protection mechanism.
See also:
CascadeMutex

The CascadeApp Message Loop

A CascadeApp starts execution when a client calls CascadeApp::Run(). CascadeApp::Run() then calls OnAppInit() and enters a tight message loop. When the message loop completes (thanks to a call to Terminate()), OnAppExit is called and CascadeApp reqlinquishes flow of control back to the client who called CascadeApp::Run().

Most app processing, then, occurs within the context of CascadeApp's tight message loop. While in this tight message loop, all CascadeApp virtual member function invocations are performed in response to the receipt of messages on the app's wormhole, m_appWormhole. The message loop looks something like this:

    while (DispatchMessage(m_appWormhole.WaitForMessage()));
Note: DispatchMessage() is a private CascadeApp function that decodes the received wormhole message and calls virtual member functions as appropriate.

Once again, all of your overridden CascadeApp virtual member functions (save OnAppInit() and OnAppExit()) will be called from CascadeApp's tight message loop. This has the following implications:

See also:
CascadeWormhole, OnWormholeMessage(), m_appWormhole

Run(), Terminate()

OnAppInit(), OnAppExit()

How CascadeApp CK_KEY Dispatch Works

One type of wormhole message bears particular explanation. This is the CK_KEY message. CK_KEY messages are private app wormhole messages that are sent to CascadeApps by class CascadeInput. These CK_KEY messages are then decoded and dispatched to your app and its materialized windows in a methodical fashion. When these CK_KEY messages reach their corresponding virtual member function, the function parameter has been reduced to a convenient CK_KEY id. These CK_KEY ids are #defined in the file CascadeKeyDefs.h.
See also:
CascadeKeyDefs.h

CK_KEY dispatch and the 1 and only 1 Active App

At any given point in time, there is one and only one active CascadeApp in the system. (Unless there are no CascadeApps running, in which case there is no active app). The active app can change over time, as other apps are executed and as apps are made the active app explicitly with a call to Activate().

When an app is the active app, it gets all of the CK_KEY messages dispatched in the system. When an app is not active, it receives no CK_KEY messages.
Note: There is a special mechanism to allow inactive apps to receive CK_KEY messages if they register interest. That mechanism is distinct from what we desribe here - more on that in a few moments.

It is therefore apparant that whether or not an app is active determines whether or not all CK_KEY messages in the system are directed to it. Stated another way, it is the active app that the user is always currently interacting with. Once more, it is the active app that the user is always currently interacting with.

CK_KEY dispatch without a focus window:
If the active app has no CascadeWindow set as its focus window, then message dispatch is simple. Key Down CK_KEY messages are routed directly to the app's OnKeyDown() virtual member function. Similarly, Key Up CK_KEY messages are routed to the app's OnKeyUp() virtual member function.

Note:
While a keypress (e.g. a remote control button) results in dispatch to both OnKeyDown() and OnKeyUp() virtual member functions, clients should typically handle keypresses in their OnKeyDown() functions.
CK_KEY dispatch with a focus window:
A CascadeApp may optionally have a focus window. You can set the focus window for your app in two ways: (1) by calling CascadeApp::SetFocusWindow() or (2) by calling CascadWindow::SetFocus(). If your app does have a focus window, then its focus window and parents get a crack at handling the CK_KEY message with their own OnKeyDown() and OnKeyUp() handlers before CascadeApp does. This allows user input to be routed to a focus window and its parents instead of or in tandem with dispatch to CascadeApp's key handlers.

Here now is the complete pseudo-code algorithm of CK_KEY dispatch:

        let currWindow = my focus window
        while (currWindow is not NULL)
        {
            call the curr window's OnKeyDown() or OnKeyUp() handler
            did it return true? if so, then stop.
            if not, then let currWindow = the parent of currWindow
        }
        // we've now given the focus window and all of its parents a crack
        // at the message - no one handled it so call my version
        call my OnKeyDown() or OnKeyUp()
    
Note:
If an app has a focus window, it will always be given a crack at handling CK_KEY messages, even if it is not visible on screen.
This concludes our discussion of CK_KEY dispatch for the active app.
See also:
OnKeyDown(), OnKeyUp()

SetFocusWindow(), CascadeWindow

CascadeWindow::OnKeyDown(), CascadeWindow::OnKeyUp()

Optional CK_KEY dispatch to Inactive Apps

As previously mentioned in fine print, inactive apps may also receive CK_KEY messages if they register interest. An app registers interest in receiving CK_KEY messages even when it is inactive with a call to RegisterInactiveKeyInterest(). Once an app has registered inactive key interest, it will receive CK_KEY messages dispatched directly to the app's OnKeyDownInactive() and OnKeyUpInactive() virtual member functions. No inactive CK_KEY dispatches are ever performed to CascadeWindows, only the app's OnKeyDownInactive() and OnKeyUpInactive() virtual member functions are called directly.
See also:
RegisterInactiveKeyInterest()

OnKeyDownInactive(), OnKeyUpInactive()


class CascadeApp


Member Typedef Documentation

typedef bool() CascadeApp::EnumProc(const char *pAppName, int nAppPID, void *pClientData)
 

Callback function for enumerating running CascadeApps in the system

Clients provide their own EnumProc to the EnumerateApps() function. Your custom EnumProc will get called back by the EnumerateApps() function, one for each CascadeApp currently running in the system.

Parameters:
pAppName the name of the CascadeApp
nAppPID the PID of the CascadeApp
pClientData the void * pClientData passed thru from EnumerateApps()
Returns:
You should return true to continue enumeration, false to abort it
Note:
The pAppName passed into your enum proc is only valid for the lifetime of the callback. So do not cache pAppName pointers. Instead copy the strings if you want to remember them.
Warning:
Heed this NOTE not and sufferage (and I don't mean Women's voting rights) will result.
See also:
EnumerateApps()


Constructor & Destructor Documentation

CascadeApp::CascadeApp  ) 
 

The 1::1 constructor - lightweight.

This base class constructor is lightweight. It simply registers itself as the one and only one CascadeApp for this process. If you try to construct more than one instance of a CascadeApp in your process, you will purposefully crash.

Warning:
Heed this warning not and you will purposefully crash.
Note:
You may use multiple app instances within your process over time, but you may only have one instantiated at a given point in time.

virtual CascadeApp::~CascadeApp  )  [virtual]
 

Destructor.

This base class destructor unregisters itself as the one and only one CascadeApp for this process, paving the way for a subsequent one and only one CascadeApp for this process to be constructed.


Member Function Documentation

void CascadeApp::Activate const char *  pAppName,
int  nAppPID = 0
 

Makes a specific app in the system active

This version of Activate() causes the app identified by pAppName with pid nAppPID to be activated. If nAppPID is zero, the first app named pAppName will be activated.

Note:
Enhancement: make this static and make it return a bool

void CascadeApp::Activate  ) 
 

Sets the app to be the active app

Activate() sets this app to be the active app. Only one CascadeApp running on the local system can be the active app at a time. When 1 particular CascadeApp is active, all other CascadeApps running on the system are inactive. When an app is active, it gets input key messages. Input key messages are sent to the active Cascade app and get dispatched by the CascadeApp base class to your app's virtual OnKeyDown() and OnKeyUp() functions. When an app it activated, it's OnActivate() member function will be called and the app will start receiving input key messages.

See also:
IsActive(), Deactivate()

OnActivate(), OnDeactivate()

OnKeyDown(), OnKeyUp()

RegisterInactiveKeyInterest()

How CK_KEY Dispatch Works

void CascadeApp::ClearFocusWindow bool  bRedraw = true  ) 
 

Clears the app's focus window

Call ClearFocusWindow() to clear the app's focus window. When anhas no focus window (as is the case after a call to ClearFocusWindow()), and is the active app then CK_KEY messages will be dispatched directly to OnKeyDown() and OnKeyUp().

Parameters:
bRedraw whether or not the resulting change in focus state should be rendered
See also:
SetFocusWindow()

OnKeyDown(), OnKeyUp()

How CK_KEY Dispatch Works

void CascadeApp::Deactivate  ) 
 

Deactivates the app if it is active

Deactivate() deactivates the app if it is the active app. The app that was most recently previously active becomes the active app. Deactivate() will cause the app's OnDeactivate() member function to be called.

See also:
IsActive(), Activate()

OnActivate(), OnDeactivate()

OnKeyDown(), OnKeyUp()

RegisterInactiveKeyInterest()

How CK_KEY Dispatch Works

static bool CascadeApp::EnumerateApps EnumProc pEnumProc,
void *  pClientData
[static]
 

Enumerates all running CascadeApps in the system.

EnumerateApps() will call *pEnumProc for each CascadeApp currently running in the system. ***NOTE*** EnumerateApps is currently not implemented!

Parameters:
pEnumProc your EnumProc to be called back for each currently running CascadeApp
pClientData a void * that will be passed straight thru to your EnumProc
Returns:
true if enumeration carried through to completion, false if enumeration was aborted
See also:
EnumProc

static CascadeApp* CascadeApp::GetApp  )  [inline, static]
 

Returns the 1 and only 1 CascadeApp for this process.

GetApp() returns the 1 and only 1 CascadeApp for this process.

Returns:
the one and only one CascadeApp for this process
Note:
CascadeApp::GetApp() will return NULL if there is currently no 1 and only 1 CascadeApp for this process constructed. Since most Cascade Appers will construct in function main(), this is not likely to happen.

const char* CascadeApp::GetAppName  )  const [inline]
 

Gets the app's name

GetAppName() gets the app's name. A CascadeApp's name is the same as the name of the executable file that started the process that ran the app. Essentially this is argv[0] stripped of all path information.

Returns:
the app name as a const char *

int CascadeApp::GetAppPID  )  const [inline]
 

Gets the app's pid

GetAppName() gets the app's pid. A CascadeApp's pid is the process id of the process that called Run(). This usually the pid of your process' main thread.

Returns:
the app's PID
Note:
CascadeApps are uniquely indentified by their pid. PIDs are useful for determining a CascadeApps URL.
See also:
MakeAppWormholeURL()

EnumerateApps()

const char* CascadeApp::GetAppWormholeURL  )  const [inline]
 

Gets the app's wormhole URL

GetAppWormholeURL() gets the app's wormhole url. This url is useful if you want to post a message to an app's wormhole. Alternatively you could call MakeAppWormholeURL() with an app's pid to have an app's wormhole URL copied into your string buffer.

Returns:
the app wormhole url as a const char *
See also:
MakeAppWormholeURL()

int CascadeApp::GetArgc  )  const [inline]
 

Gets the argument count the app was started with

GetArgc() gets the argument count that the app was started with. The argc returned is usually that which was passed in to function main.

Returns:
the int argc

const char** CascadeApp::GetArgv  )  const [inline]
 

Gets the argument variable array the app was started with.

GetArgv() gets the argument variable array that the app was started with. The argv returned is usually that which was passed in to function main.

Returns:
the const char ** argv

CascadeWindow* CascadeApp::GetFocusWindow  )  [inline]
 

Gets the app's focus window

Call GetFocusWindow() to get the current focus window of the app.

Returns:
a pointer to the focus window of the app or NULL if no focus window is set.

bool CascadeApp::IsActive  ) 
 

Tells whether or not the app is active.

Call IsActive() to determine whether or not the app is the active app.

Returns:
true if the app is the active app, false otherwise
See also:
Activate(), Deactivate()

OnKeyDown(), OnKeyUp()

RegisterInactiveKeyInterest()

How CK_KEY Dispatch Works

static bool CascadeApp::MakeAppWormholeURL int  nAppPID,
char *  pBuff,
u32  nBuffLen
[static]
 

Constructs a the url for the app wormole given the app PID.

MakeAppWormholeURL() constructs a string containing the wormhole url for the referenced app's wormhole.

Parameters:
nAppPID the process id of the app whose wormhole url is being requested
pBuff a buffer where the generated name will be stored
nBuffLen the length in bytes of pBuff
Returns:
true if successful, false otherwise (e.g. if pBuff wasn't big enough).
Note:
MakeAppWormholeURL() doesn't ensure that the CascadeApp with pid nAppPID actually exists - it simply generates a string based on the nAppPID.
See also:
GetAppWormholeURL()

virtual void CascadeApp::OnActivate  )  [protected, virtual]
 

called when app has been activated

OnActivate() is called whenever your app is activated. Override this method to provide app functionality to execute whenever your app is made active. Typical behavior is to dynamically compute the app's focus window (if required).

Warning:
This function gets called synchronously during the process of activation with an internal activation lock. Do NOT cause yourself or other apps to become activated or deactivated during your processing of OnActivate or the system will deadlock.

virtual void CascadeApp::OnAppExit  )  [protected, virtual]
 

called when app is exiting

OnAppExit() is called when the app exits (in response to a call to Terminate()). Perform final cleanup in OnAppExit().

See also:
OnAppInit()

Terminate()

virtual void CascadeApp::OnAppInit  )  [protected, virtual]
 

The first entry point of your application

OnAppInit() is called when an app starts (in response to a call to Run()). Perform your application's initialization here. The base class implementation of OnAppInit() does nothing.

Your app will continue to run indefinitely until Terminate() is called. If your application's initialization fails, you should explicitly call Terminate() from within OnAppInit(). If your application performs a simple task and then exits (like ps, for example), then the last line of OnAppInit() should be a call to Terminate().

See also:
OnAppExit()

Terminate()

virtual void CascadeApp::OnDeactivate  )  [protected, virtual]
 

called when app has been deactivate OnDeactivate() is called whenever your app is deactivated. Override this method to provide app functionality to execute whenever your app is deactivated.

Warning:
This function gets called synchronously during the process of deactivation with an internal activation lock. Do NOT cause yourself or other apps to become activated or deactivated during your processing of OnDeactivate or the system will deadlock.

virtual void CascadeApp::OnECPCommand const CascadeString command,
CascadeString resultToSet
[protected, virtual]
 

called to allow subclasses to handle ECP commands

OnECPCommand() is called by the CascadeApp base class whenever an ECP command that has been registered for by RegisterECPCommand() is received.

Parameters:
command the ECP command that was received
resultToSet the string in which to place the ECP command's result string
See also:
RegisterECPCommand(), UnregisterECPCommand()

CascadeInput::DispatchECPCommand()

virtual void CascadeApp::OnKeyDown u32  nKey  )  [protected, virtual]
 

called to handle a key down message when active

OnKeyDown() is called by the CascadeApp base class when it is the active app and has determined that no currently displayed window wants the key message.

Parameters:
nKey the key that OnKeyDown() is notifying you of
See also:
How CK_KEY Dispatch Works

CascadeKeyDefs.h

virtual void CascadeApp::OnKeyDownInactive u32  nKey  )  [protected, virtual]
 

called to notify receipt of a key down message when inactive

OnKeyDownInactive() is called by the CascadeApp base class when it is the inactive app and you have registered interest in receiving key messages when you are inactive.

Parameters:
nKey the key that OnKeyDownInactive() is notifying you of
See also:
How CK_KEY Dispatch Works

CascadeKeyDefs.h

virtual void CascadeApp::OnKeyUp u32  nKey  )  [protected, virtual]
 

called to handle a key up message when active

OnKeyUp() is called by the CascadeApp base class when it is the active app and has determined that no currently displayed window wants the key message.

Parameters:
nKey the key that OnKeyUp() is notifying you of
See also:
How CK_KEY Dispatch Works

CascadeKeyDefs.h

virtual void CascadeApp::OnKeyUpInactive u32  nKey  )  [protected, virtual]
 

called to notify receipt of a key up message when inactive

OnKeyUpInactive() is called by the CascadeApp base class when it is the inactive app and you have registered interest in receiving key messages when you are inactive.

Parameters:
nKey the key that OnKeyUpInactive() is notifying you of
See also:
How CK_KEY Dispatch Works

CascadeKeyDefs.h

virtual void CascadeApp::OnMountMessage const CascadeMountMessage mountMessage  )  [protected, virtual]
 

called to notify that a file system has been mounted or unmounted

OnMountMessage() is called by the CascadeApp base class when a file system mount point has been added or removed.

Parameters:
mountMessage the mount message
See also:
CascadeMountMessage

virtual void CascadeApp::OnPowerMessage const CascadePowerMessage powerMessage  )  [protected, virtual]
 

called to notify that a power state change has occurred

OnPowerMessage() is called by the CascadeApp base class when a power state change has occurred.

Parameters:
powerMessage the power message
See also:
CascadePowerMessage

virtual void CascadeApp::OnScreenMessage const CascadeScreenMessage screenMessage  )  [protected, virtual]
 

called to notify that the screen resolution has changed

OnScreenMessage() is called by the CascadeApp base class when the screen resolution or output resolution has been modified.

Parameters:
screenMessage the screen message
See also:
CascadeScreenMessage

virtual void CascadeApp::OnSignal int  nSignum  )  [protected, virtual]
 

called to allow subclasses to handle signals

OnSignal() is called by the CascadeApp base class whenever a previously registered signal is raised. The default implementation does nothing for all signals except when SIGINT or SIGHUP are raised in the main app thread. When the main app thread receives SIGINT or SIGHUP, the base class implementation of OnSignal() calls Terminate(0) to gracefully shut down the app.

Note:
OnSignal() will be called in a signal handling context of the thread that is to receive the signal (usually that which caused the signal to be generated). This may or may not be the same thread as the app's main thread. This means you must provide your own thread safety from within OnSignal(). A simple means of doing this is to call getpid() and compare the result to a static value to ensure the right processing is only performed from the right thread.

clients who override OnSignal() should call the base class implementation to get automatic graceful shutdown when SIGINT and SIGHUP are received.

Parameters:
nSignum the signal being notified
See also:
RegisterForSignal(), UnregisterForSignal()

virtual void CascadeApp::OnWidgetParametersChanged  )  [protected, virtual]
 

called when CascadeWidget UI parameters have changed

OnWidgetParamtersChanged() gets called whenever the ui 'theme' paramters for widgets gets changed. The default implementation is to cause all app windows to be redrawn.

See also:
CascadeWidget

virtual void CascadeApp::OnWormholeMessage const CascadeMessage message  )  [protected, virtual]
 

called to allow subclasses to process wormhole messages

OnWormholeMessage() is called whenever the CascadeApp base class receives a wormhole message that it doesn't want to process directly. Override this function to process wormhole messages in your application.

Note:
If you create a CascadeApp derived class and intend others to subclass off of it, and you override OnWormholeMessage(), your clients should be instructed to explicitly call your version when they override OnWormholeMessage().
            Example:
            class App1 : public CascadeApp { virtual void OnWormholeMessage(const CascadeMessage & message); };
            class App2 : public App1 {
                virtual void OnWormholeMessage(const CascadeMessage & message)
                {
                    if (message.ID() == s_nMessageIDiCareAbout) { } // do something
                    else App1::OnWormholeMessage(message); // make sure my base class gets a crack.
                } };
            
Note:
It is not necessary to call the CascadeApp base class version - CascadeApp::OnWormholeMessage() from your overridden OnWormholeMessage() function as the base class implementation does nothing.
See also:
CascadeMessage

m_appWormhole

The Cascade App Message Loop

void CascadeApp::RegisterECPCommand const CascadeString command  ) 
 

registers for receipt of an ECP command

ECP stands for External Control Protocol and is the mechanism by which external devices can instruct your application to do things. A CascadeApp registers for receipt of an ECP command by calling RegisterECPCommand(). Any such ECP commands that are subsequently dispatched will be handled by your app's OnECPCommand() virtual member function.

Parameters:
command the command to register for receipt of
See also:
OnECPCommand(), UnregisterECPCommand()

void CascadeApp::RegisterForSignal int  nSignum  ) 
 

registers for receipt of a signal

RegisterForSignal() registers for receipt of signal nSignum which will be notified by the invocation of the app's OnSignal member function.

By default, all CascadeApps have SIGINT and SIGHUP registered. The default base class implementation of OnSignal() calls Terminate(0) when SIGINT or SIGHUP is received by the main app thread.

Parameters:
nSignum the signal to register for
See also:
UnregisterForSignal()

OnSignal()

void CascadeApp::RegisterInactiveKeyInterest bool  bInterest  ) 
 

Allows the app to receive key messages when inactive

RegisterInactiveKeyInterest() is used to specify whether your app receives key message dispatch to its OnKeyDownInactive() and OnKeyUpInactive() handlers when it is inactive. The default behavior for CascadeApps is to not receive key message dispatch when inactive. RegisterInactiveKeyInterest() may be used to change this behavior.

Parameters:
bInterest true to register interest, false to register disinterest.
Note:
The app must be running (Run() must have been called) before interest registered with RegisterInactiveKeyInterest() will take effect. Consequently a good place to RegisterInactiveKeyInterest() is in your app's OnAppInit() function.
See also:
OnKeyUpInactive(), OnKeyDownInactive()

OnAppInit()

How CK_KEY Dispatch Works

int CascadeApp::Run int  argc,
const char **  argv
 

Starts the application.

Run() is usually called from function main() in the following fashion:

            int main(int argc, const char ** argv)
            {
                MyApp myApp;
                return myApp.Run(argc, argv);
            }
            
Parameters:
argc The argument count (usually passed in from function main())
argv The argument variable array (usually passed in from function main())
Returns:
The exit code of the App - (as passed into Terminate())
Note:
Run() runs a tight message loop in the context of the calling thread. (Usually your process' main thread). Run() first calls your OnAppInit() virtual memeber function, then deactivates the currently active app, activates your application and then waits on m_appWormhole for wormhole messages in a tight message loop until Terminate() is called.
See also:
OnAppInit(), OnActivate()

Terminate

The Cascade App Message Loop

void CascadeApp::SetFocusWindow CascadeWindow pWindow,
bool  bRedraw = true
 

Sets the app's focus window

call SetFocusWindow() to set the app's focus window to pWindow. Each app has the ability to have up to 1 focus window. The focus window (if set) is the window to which the CascadeApp will first dispatch input messages it receives while it is the active application.

Parameters:
pWindow the window to set focus to
bRedraw whether or not the resulting change in focus state should be rendered
Note:
If bRedraw is true, then SetFocusWindow() will cause paint messages to be sent to the window losing focus and the window gaining focus. If bRedraw is false, no such messages will be sent.
See also:
OnKeyDown(), OnKeyUp()

ClearFocusWindow()

Activate(), Deactivate()

void CascadeApp::Terminate int  nExitCode  ) 
 

Stops the application.

Terminate() posts a private quit message to the app effectively causing it to terminate with exit code nExitCode. Although Terminate() may be called at anytime by any thread after Run() has been called, it is usually called by the app itself from within its main thread (that which called Run()) when it wants to terminate.

Note:
Terminate() is asynchronous in the sense that it causes the app to terminate later, when the terminate message is processed by the app's message loop. Note that this behavior is different than the classic stdlib call to exit() which terminates the process immediately. All CascadeApps should cause a graceful exit by calling Terminate().
Parameters:
nExitCode The exit code that the app should terminate with
Note:
Remember that CascadeApp is not inherently thread safe. If Terminate() is called from a thread different from that which called CascadeApp::Run(), then you must provide your own thread safety (e.g. using CascadeMutex).
See also:
Run()

CascadeMutex

The Cascade App Message Loop

Cascade App Thread Safety

void CascadeApp::UnregisterECPCommand const CascadeString command  ) 
 

unregisters for receipt of an ECP command

UnregisterECPCommand() is used to unregister a previously registered ECP command.

Parameters:
command the command to unregister
See also:
RegisterECPCommand(), OnECPCommand()

void CascadeApp::UnregisterForSignal int  nSignum  ) 
 

unregisters for receipt of a signal

Call UnregisterForSignal to unregister for reciept of a signal that you previously registered for.

Parameters:
nSignum the signal to unregister
See also:
RegisterForSignal()

OnSignal()


Friends And Related Function Documentation

friend class CascadeAppMessageSink [friend]
 

friend class CascadeInput [friend]
 

friend class CascadeMPEGPlayer [friend]
 

friend class CascadeTimer [friend]
 

friend class CascadeWindow [friend]
 


Member Data Documentation

CascadeWormhole CascadeApp::m_appWormhole [protected]
 

a wormhole you can use for sending and posting in your CascadeApp derived class

m_appWormhole may be used to send and post messages from your app to other wormholes. Additionally you can post messages to yourself by calling m_appWormhole.PostMessage(GetAppWormholeURL(), ...);

Note:
Important All of your CascadeApp derived class' processing occurs in the context of a message received from m_appWormhole. This is accomplished by the CascadeApp base class running a tight message loop on m_appWormhole inside Run(). As a result, you may not wait on m_appWormhole for messages yourself because you will pull CascadeApp private messages out of m_appWormhole and you will not know how to handle them.

All virtual member function invocations are performed from CascadeApp's tight message loop. As a result, if you perform lengthy operations in your virtual member functions (e.g. OnKeyDown()), then messages will start queuing up in your app's wormhole and missed notifications could result. Further, never steal the processor (fail to return) from one of your virtual member notification functions.

Warning:
Never call m_appWormhole.WaitForMessage() directly. Instead, allow CascadeApp's tight message loop to call your overridden OnWormholeMessage() handler to process custom wormhole messages received on m_appWormhole.
See also:
CascadeWormhole

Run()

The Cascade App Message Loop


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:18 2005 for Cascade Library by  doxygen 1.4.1