[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.20.1 Quick Start

In order to startup and use AWS, the following tasks must be performed.

  1. Initialize the Crystal Space facilities in the normal fashion. (see section Simple Tutorial 1). In particular, csInitializer::OpenApplication() must be invoked before any of the following tasks are performed. Initializing an AWS application also involves loading the AWS plugin. You can do this via the normal csInitializer::RequestPlugins() invocation (the common approach), or you can load it separately, if desired:
     
    csRef<iAws> aws = CS_LOAD_PLUGIN(plugin_mgr,
      "crystalspace.window.alternatemanager", iAws);
    

    If you know ahead of time that your application will be using AWS, then loading the plugin via csInitializer::OpenApplication() is more convenient and less error-prone.

  2. Setup the AWS canvas.
     
    awsCanvas = aws->SetupCanvas (0, myG2D, myG3D);
    

    Where myG2D and myG3D are your iGraphics2D and iGraphics3D cavas objects, respectively.

  3. Load definition files.
     
    aws->GetPrefMgr()->Load("/aws/awstest.def");
    

    Substitute the VFS path of your own definition file in place of the path shown in the example.

  4. Select a default skin that all windows will use.
     
    aws->GetPrefMgr()->SelectDefaultSkin("Normal Windows");
    
  5. Create and display your windows.
     
    csRef<iAwsWindow> test2 = aws->CreateWindowFrom("Another");
    csRef<iAwsWindow> test1 = aws->CreateWindowFrom("Form1");
    if (test1) test1->Show();
    if (test2) test2->Show();
    
  6. Finally, you have to make sure it actually renders to the display. So, in your program's main drawing loop you might use code similar to this:
     
    // Start drawing 2D graphics.
    if (!myG3D->BeginDraw (CSDRAW_2DGRAPHICS))
      return;
    // Make sure invalidated areas get a chance to
    // redraw themselves.
    aws->Redraw ();
    // Draw the current view of the window system to a
    // graphics context with a certain alpha value.
    aws->Print (myG3D, 64);
    

That's all there is to it. AWS is designed to be easy to use. Of course, this brief examination does not illustrate how to get user input from components in the windows, nor does it illustrate how to do anything other than display your windows. However, the windows created here are full-fledged windows with all the controls listed in the definition that you've created. For more advanced topics, read about signals (see section Signals: Responding To User Input) and custom components (see section Creating Custom AWS Components).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated using texi2html 1.76.