Programming Reference:ApplicationWindowClient Class

From BCI2000 Wiki
Jump to: navigation, search

ApplicationWindowClient is a mix-in class that provides its inheritants with access to application windows, which are instances of the ApplicationWindow class. ApplicationWindow instances have names, with the default name being "Application". A window's name may be used to obtain a DisplayWindow reference to the window, e.g.

DisplayWindow& applicationWindow = Window( "Application" );
applicationWindow.SetTop( 15 );

Const access to the underlying list of windows is provided via the ApplicationWindowClient::Windows pointer. This allows to write

if( Windows->Exists( "Application" ) )
{
  DisplayWindow& applicationWindow = Window( "Application" );
  TextStimulus* pStimulus = new TextStimulus( applicationWindow );
  ..
}

It also allows to iterate over existing windows:

for( int i = 0; i < Windows->Size(); ++i )
{
  bciout << ( *Windows )[i].Name() << endl;
}

ApplicationWindow instances are created by using the ApplicationWindowClient::Window( name ) function during a module's construction phase, typically from a GenericFilter descendant's constructor (for an example, see the ApplicationWindow class page. If an application window with that name already exists, it will be shared amongst filters which access it.

If you don't want to create an application window, but only access an existing one, you need to declare access to that window during the preflight phase. In your Preflight() member function, write:

Window( "Application" );

When no such window exists, a preflight error will be reported. Unless the window has been accessed during the construction phase, not declaring access to the window during the preflight phase will result in an error message when calling ApplicationWindowClient::Window() from elsewhere.

See Also

Programming Reference:ApplicationWindow Class, Programming Reference:Environment Class