3D PLM Enterprise Architecture

User Interface - Dialogs

Getting Started with Dialog Boxes

A first sample with dialog boxes
Use Case

Abstract

This article shows a simple example of dialog box created using the Dialog framework.


What You Will Learn With This Use Case

The Dialog framework is intended to help application developers to simply design an implement their dialog windows and boxes. Its main characteristics are:

Let's have a look at this framework through two examples. The first sample program shows how to build a very simple window and how to close it. The second sample introduces a larger number of dialog window components or objects and how to manage window layouts as well as triggering actions when clicking on Dialog framework objects [1].

[Top]

The CAADlgHelloApplication Use Case

CAADlgHelloApplication is a use case of the CAADialog.edu framework that illustrates Dialog framework capabilities.

[Top]

What Does CAADlgHelloApplication Do

For this example, you will simply display a prompt box that prints "Hello, CAA V5". To do this, derive your own application class, called CAADlgHelloApplication, from the class CATInteractiveApplication [2]. This application will:

  1. create a window to display "Hello, CAA V5" by deriving the class CATDlgDocument
  2. makes the window visible.

In addition, the mechanism to close the application from the window is included. The window is as follows:

[Top]

How to Launch CAADlgHelloApplication

To launch CAADlgHelloApplication, you will need to set up the build time environment, then compile CAADlgHelloApplication along with its prerequisites, set up the run time environment, and then execute the use case [3].

[Top]

Where to Find the CAADlgHelloApplication Code

The CAADlgHelloApplication use case is made of a several classes located in the CAADlgHelloApplication.m module of the CAADialog.edu framework:

Windows InstallRootDirectory\CAADialog.edu\CAADlgHelloApplication.m\
Unix InstallRootDirectory/CAADialog.edu/CAADlgHelloApplication.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

The CAADlgHelloApplication.m module includes four files:

CAADlgHelloApplication.h The interactive application header file
CAADlgHelloApplication.cpp The interactive application source file
CAADlgHelloWindow.h The application window header file
CAADlgHelloWindow.cpp The application window source file

The resource file CAADlgHelloWindow.CATNls is located in the CNext\resources\msgcatalog directory.

[Top]

Step-by-Step

There are two logical steps in CAADlgHelloApplication:

  1. Creating the Interactive Application
  2. Creating the Application Window

[Top]

Creating the Interactive Application

Let's look at CAADlgHelloApplication.h, the application header file:

#include "CATInteractiveApplication.h"

class CAADlgHelloApplication: public CATInteractiveApplication {

  public:

    CAADlgHelloApplication(const CATString &iIdentifier);

    virtual ~CAADlgHelloApplication();
    void BeginApplication();
    int EndApplication();

};

We find here:

The CAADlgHelloApplication.cpp looks like that:

#include "CAADlgHelloApplication.h"
#include "CAADlgHelloWindow.h"

CAADlgHelloApplication::CAADlgHelloApplication(const CATString& iIdentifier):
                        CATInteractiveApplication(NULL, iIdentifier) {}
                        
CAADlgHelloApplication::~CAADlgHelloApplication() {}

void CAADlgHelloApplication::BeginApplication() 
{
 
  CAADlgHelloWindow * pMainWindow = new CAADlgHelloWindow(this);

  pMainWindow->Build();

  pMainWindow->SetVisibility(CATDlgShow);
}

int CAADlgHelloApplication::EndApplication() 
{
  return(0);
}

CAADlgHelloApplication ApplicationInstance("Hello");

The constructor is empty. It leaves the constructors of the inherited classes run, and it automatically runs the method BeginApplication which constructs the application window and makes it visible. The method EndApplication only returns 0 to state that all is Ok . The application run is just triggerred by the its instantiation in the last statement.

[Top]

Creating the Application Window

Let's look at CAADlgHelloWindow.h, the application window header file:

#include "CATDlgDocument.h"   

class CATInteractiveApplication;   

class CAADlgHelloWindow : public CATDlgDocument
{
 
  DeclareResource(CAADlgHelloWindow, CATDlgDocument)

  public:
 
    CAADlgHelloWindow(CATInteractiveApplication * iParentCommand);

    virtual ~CAADlgHelloWindow();

    void     Build();

  private:

    void Exit (CATCommand           * iSendingCommand, 
                CATNotification      * iSentNotification, 
                CATCommandClientData   iUsefulData);

  private:
    CATInteractiveApplication * _pHelloApplication;

    
};

We find here:

The file CAADlgHelloWindow.cpp looks like that:

#include "CAADlgHelloWindow.h"

#include "CATInteractiveApplication.h" 
#include "CATDlgInclude.h"

CAADlgHelloWindow::CAADlgHelloWindow(CATInteractiveApplication * iParentCommand)                              
: CATDlgDocument(iParentCommand, "CAADlgHelloWindowId"),_pHelloApplication(iParentCommand)

{
}

CAADlgHelloWindow::~CAADlgHelloWindow()
{ 
  _pHelloApplication = NULL ;
}

void CAADlgHelloWindow::Build()
{
 
  CATDlgLabel * pLabel = new CATDlgLabel(this,"MessageId");

  
  AddAnalyseNotificationCB(this,
                            GetWindCloseNotification(),
                           (CATCommandMethod)&CAADlgHelloWindow::Exit, NULL);

}

void CAADlgHelloWindow::Exit(CATCommand         * iSendingCommand, 
                           CATNotification    * iSentNotification, 
                           CATCommandClientData iUsefulData)
{
   _pHelloApplication->Destroy();
   _pHelloApplication = NULL ;
}

The constructor for CAADlgHelloWindow only values the _pHelloApplication data member. The Build method creates the message to display as a CATDlgLabel instance, sets character string to display in the message, and registers the method Exit to be called when the window is closed. This method destroys the application. This also deletes the window. Always use a Build method, and never instantiate dialog objects in the window constructor.

The message file that contains the displayed messages is as follows.

Title           = "Hello Application";
MessageId.Title = "Hello, CAA V5";

The first message is the window title and has the simple key Title. The second one is the displayed message and its key is built using the identifier passed as second argument of the label constructor, concatenated with a dot to the Title keyword.

[Top]


In Short

This use case enables you to have a first approach with the Dialog framework concepts. In the Build method of the application window you can test the Dialog objects [4]

[Top]


References

[1] The Burger Order Dialog Box
[2] Designing Your Interactive Application
[3] Building and Launching a CAA V5 Use Case
[4] Dialog Overview
[Top]

History

Version: 1 [Fev 2003] Document created
[Top]

Copyright © 2003, Dassault Systèmes. All rights reserved.