3D PLM Enterprise Architecture

User Interface - Dialogs

Creating Dialog Boxes Automatically Resizable

Arranging Dialog Objects Using Tabulations
Use Case

Abstract

This article shows how to create extendable dialog boxes. 


What You Will Learn With This Use Case

This use case is intended to show you how to create Dialog boxes with dynamic frames. The frames appear and disappear and the dimensions of the dialog box are automatically redefined. For such behavior the frame positioning must be done by a tabulation layout [1] and not by a grid layout [2].

[Top]

The CAADlgTabulation Use Case

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

[Top]

What Does CAADlgTabulation Do

CAADlgTabulation use case creates three Dialog boxes:

  1. The "More/Less Push Button Demonstrator" Dialog box

  2. Fig. 1a: Original Size
    Fig. 1b: Extended Size

    When the end user clicks the "More" button, the Dialog box is expanded and when it clicks on the "Less" button, the dialog box retrieves its original size.

  3. The "More & Radio Button Demonstrator" Dialog box

  4. Fig. 2a: Without frame

    When the end user select the "without frame" radio button, no frame is displayed. 

    Fig. 2b: With more frame A

    When the end user selects the "With more frame A" radio button, the frame entitled "Frame A" is displayed on the right side.

    Fig. 2c: With more frame B

    When the end user selects the "With more frame B" radio button, the frame entitled "Frame B" is displayed on the right side. 

  5. The "Frame Replacement Demonstrator" Dialog box
  6. According to the selected value in the combo, the frame under the "Combo Frame" frame is not the same: "Coordinates Frame", "Circle Frame" or " Between Frame". 

    Fig. 3a:Coordinates
    Fig. 3b: Circle Center
    Fig. 3c: Between

To obtain such behavior, the frames must be attached in their container by a tabulation layout. On the pictures below, the tabulations are represented by thick lines and the frame's attachments are represented by a green rectangular box.

  1. The "More/Less Push Button Demonstrator" Dialog box

  2. Fig. 4a:
    Fig. 4b:

    The "Left More Frame" frame is always visible and attached to the first (0) vertical line. The "Right More Frame" frame is 

  3. The "More & Radio Button Demonstrator" Dialog box

  4. It is similar to the previous dialog box:

    Fig. 5a
    Fig. 5b

    The "Radio Button Frame" frame is always visible and attached to the first (0) vertical line. 

  5. The "Frame Replacement Demonstrator" Dialog box

  6. In this case the attachments are horizontal.

    Fig. 6

    The "Combo Frame" frame is always visible and attached to the first (0) horizontal line. The frame attached to the second (5) horizontal line is the frame entitled either "Coordinates Frame" (Fig. 3a) or "Circle Frame" (Fig. 3b) or ''Between Frame" (Fig. 3c) . When one of these three frames is attached and visible, the two others are invisible and detached.

Inside the frames entitled  "Left More Frame", "Right More Frame", "Frame A" and so on, you can use the grid layout [2] to locate the different components. 

[Top]

How to Launch CAADlgTabulation

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

mkrun -c CAADlgDialogDemonstrator 

When the CAADlgDialogDemonstrator application is launched:

[Top]

Where to Find the CAADlgTabulation Code

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

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

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

In the LocalInterfaces and src directory, you will find the following files:

[Top]

Step-by-Step

There are three main steps to define the three Dialog boxes of the CAADlgTabulation use case:

  1. Defining the Class Constructor
  2. Defining the Build Method 
  3. Defining the Callback Method

[Top]

Defining the Class Constructor 

CAADlgMoreButtonDlg::CAADlgMoreButtonDlg(CATDialog * pParentDlg) :
  CATDlgDialog (pParentDlg,"CAADlgMoreButtonDlg", CATDlgWndBtnOKCancel |
                                                  CATDlgWndAutoResize |
                                                  CATDlgWndNoResize ),
  ...
{
   ...
}

Each Dialog box is a class deriving from the CATDlgDialog class. The arguments of the constructor are as follows:

 

[Top]

Defining the Build Method 

The contents of this section depends on the Dialog box. 

  1. The "More/Less Push Button Demonstrator" Dialog box
  2. The "More & Radio Button Demonstrator" Dialog box
  3. The "Frame Replacement Demonstrator" Dialog box

  1. The "More/Less Push Button Demonstrator" Dialog box
  2. void CAADlgMoreButtonDlg::Build()
    {
       a/ Creating Dialog Objects
       
       b/ Arranging Dialog Objects
       
       c/ Defining Callbacks
    }
    ...

    Creating Dialog Objects

    ...
       CATDlgFrame * pFrameLeftMore = new CATDlgFrame(this, "FrameLeftMore", 
                                                            CATDlgGridLayout );
                                               
          CATDlgFrame * pFrameBase = new CATDlgFrame(pFrameLeftMore, "FrameBase", 
                                                                     CATDlgGridLayout );
                                                         
             ... The FrameBase contents is not detailed
    
          CATDlgPushButton * pPushButtonMore = new CATDlgPushButton(pFrameLeftMore, 
                                                    "PushButtonMore");
          
          _MoreMsg = CATMsgCatalog::BuildMessage("CAADlgMoreButtonDlg","ButtonMore",
                                                        NULL,0,"More>>");
          _LessMsg = CATMsgCatalog::BuildMessage("CAADlgMoreButtonDlg","ButtonLess",
                                                        NULL,0,"Less>>");                                       
          pPushButtonMore->SetTitle(_MoreMsg);
    
       _pFrameRightMore = new CATDlgFrame(this, "FrameRightMore", CATDlgGridLayout );
       
          ... The FrameRightMore contents is not detailed
    ...

    Arranging Dialog Objects

    For the "More/Less" Dialog box, the layout is the following:

    Inside the "Left More Frame" there are always a frame entitled "Base Options Frame" located in (0,0) and a push button located in (1,0). In the "Base Options Frame" frame you set all the options always available whereas in the "Right More Frame" you set only the "more" options.  

    ...
       SetVerticalAttachment(0, CATDlgTopOrLeft, pFrameLeftMore,NULL);
       pFrameBase -> SetGridConstraints(0, 0, 1, 1, CATGRID_4SIDES);
       pPushButtonMore -> SetGridConstraints(1, 0, 1, 1, CATGRID_RIGHT);
       _pFrameRightMore->SetVisibility(CATDlgHide);
    ...
    

    The Callback Definition

    ...
       AddAnalyseNotificationCB  (pPushButtonMore, 
                                  pPushButtonMore->GetPushBActivateNotification(),
         (CATCommandMethod)&CAADlgMoreButtonDlg::OnPushButtonMorePushBActivateNotification,                         
                       NULL);
    ...

    To be advised that the end user has clicked on the More button you set a callback thanks to the AddAnalyseNotificationCB method:

  3. The "More & Radio Button Demonstrator" Dialog box
  4. ...
    void CAADlgMoreRadioDlg::Build()
    {
      a/ Creating Dialog Objects
    
      b/ Arranging Dialog Objects
      
      c/ Defining Callbacks 
    }
    ...

    Creating Dialog Objects

    ... 
      CATDlgFrame * pFrameMain = new CATDlgFrame(this, "FrameMain", CATDlgGridLayout );
      
         ... FrameMain contents not explained
    
      _pFrameDetailA = new CATDlgFrame(this, "FrameDetailA", CATDlgGridLayout);
      
         ... FrameDetailA contents not explained
         
      _pFrameDetailB = new CATDlgFrame(this, "FrameDetailB", CATDlgGridLayout);
     
         ... FrameDetailB contents not explained
    ...

    The three frames, pFrameMain, _pFrameDetailA and _pFrameDetailB are created in the same way:

    Arranging Dialog ObjectsFig. 5a

    ...
      SetVerticalAttachment(0, CATDlgTopOrLeft,pFrameMain,NULL);
      _pFrameDetailB->SetVisibility(CATDlgHide); 
      _pFrameDetailA->SetVisibility(CATDlgHide);
    ...

    The Callbacks Definition

    ...
       AddAnalyseNotificationCB (pRadioButtonND, 
                                   pRadioButtonND->GetRadBModifyNotification(),
         (CATCommandMethod)&CAADlgMoreRadioDlg::OnRadioButtonNDRadBModifyNotification,
                                   NULL);
       AddAnalyseNotificationCB (pRadioButtonDB, 
                                   pRadioButtonDB->GetRadBModifyNotification(),
         (CATCommandMethod)&CAADlgMoreRadioDlg::OnRadioButtonDBRadBModifyNotification,
                                   NULL);
    
       AddAnalyseNotificationCB (pRadioButtonDA, 
                                   pRadioButtonDA->GetRadBModifyNotification(),
         (CATCommandMethod)&CAADlgMoreRadioDlg::OnRadioButtonDARadBModifyNotification,
                                   NULL);
    ...

    To be advised that the end user has clicked on a radio button you set callbacks thanks to the AddAnalyseNotificationCB method:

    Same thing for the two other radio buttons.

  5. The "Frame Replacement Demonstrator" Dialog box
  6. ...
    void CAADlgFrameReplaceDlg::Build()
    {
       a/ Creating Dialog objects 
    
       b/ Arranging the Dialog Objects
       
       c/ Defining Callback 
    }

    Creating Dialog Objects

    ...
       CATDlgFrame * pFrameCombo = new CATDlgFrame(this, "FrameCombo",
                                                         CATDlgGridLayout );                                        
          ... FrameCombo contents not explained
          
       CATDlgFrame * pFrameCoord = new CATDlgFrame(this, "FrameCoord", 
                                                         CATDlgGridLayout );                                          
          ... FrameCoord contents not explained
    
       CATDlgFrame * pFrameCircleCenter = new CATDlgFrame(this, "FrameCircleCenter", 
                                                                CATDlgGridLayout );                                            
       _pListFrame[CircleCenter] = pFrameCircleCenter ;
       
          ... FrameCircleCenter contents not explained
    
       CATDlgFrame * pFrameBetween = new CATDlgFrame(this, "FrameBetween", 
                                                           CATDlgGridLayout );                                     
       _pListFrame[Between] = pFrameBetween ;
       
          ... FrameBetween contents not explained
    ...

    The four pFrameCombo, pFrameCoord, pFrameCircleCenter and pFrameBetween frames are created on the same way:

    _pListFrame is an array of CATDlgFrame instances declared as data member of the CAADlgFrameReplaceDlg class. It keeps the list of frames to switch. See its usage in the "Defining the Callback Method" section 

    Arranging Dialog Objects - Fig. 6

    ...   
       SetHorizontalAttachment(0,CATDlgTopOrLeft,pFrameCombo,NULL);
       _CurrentSelection = 0 ;
       ... 
       pFrameCoord->SetVisibility(CATDlgHide);
       pFrameCircleCenter->SetVisibility(CATDlgHide);
       pFrameBetween->SetVisibility(CATDlgHide);
       
       SetHorizontalAttachment(5,CATDlgTopOrLeft,_pListFrame[_CurrentSelection],NULL);
       _pListFrame[_CurrentSelection]->SetVisibility(CATDlgShow);
    ...

    Defining Callback

    ...
       AddAnalyseNotificationCB (_pComboPointType, 
                     _pComboPointType->GetComboSelectNotification(),
              (CATCommandMethod)&CAADlgFrameReplaceDlg::OnComboSelectNotification,
                                   NULL);
    ...

    To be advised that the end user has select a new item in the combo list, you set a callback thanks to the AddAnalyseNotificationCB method:

[Top]

Defining the Callback Method 

In this section, we describe the methods which are called when the frame layout must be changed.  

  1. The "More/Less Push Button Demonstrator" Dialog box
  2. The "More & Radio Button Demonstrator" Dialog box
  3. The "Frame Replacement Demonstrator" Dialog box

  1. The "More/Less Push Button Demonstrator" Dialog box
  2. The OnPushButtonMorePushBActivateNotification method is called when the end user clicks on the More/Less push button.

    ...
    void CAADlgMoreButtonDlg::OnPushButtonMorePushBActivateNotification(CATCommand* cmd, 
                                       CATNotification* evt, CATCommandClientData data)
    {
       CATDlgPushButton * pButton = (CATDlgPushButton *) cmd ;
       if ( (NULL != pButton ) && (NULL !=_pFrameRightMore) )
       {
          if( TRUE == _IsMoreWindowOpen)
          {
             ResetAttachment(_pFrameRightMore);         
             _pFrameRightMore->SetVisibility(CATDlgHide);         
    
             pButton->SetTitle (_MoreMsg);
    
             _IsMoreWindowOpen= FALSE;
          }else
          {
             SetVerticalAttachment(10, CATDlgTopOrLeft, _pFrameRightMore, NULL);
             _pFrameRightMore->SetVisibility(CATDlgShow);         
    
             pButton->SetTitle (_LessMsg);
    
             _IsMoreWindowOpen = TRUE;
          }
       }
    }
    ...

    _IsMoreWindowOpen is a data member of the CAADlgMoreButtonDlg class. It is a CATBoolean value set TRUE when the right frame is opened and FALSE otherwise. The value is initialized to FALSE in the class constructor.

  3. The "More & Radio Button Demonstrator" Dialog box
  4. The OnRadioButtonDARadBModifyNotification method is called when the end user selects or deselects the "With more frame A" radio button. 

    ...
    void CAADlgMoreRadioDlg::OnRadioButtonDARadBModifyNotification(CATCommand* cmd, 
                                    CATNotification* evt, CATCommandClientData data)
    {
      CATDlgRadioButton * pRadioButton = (CATDlgRadioButton *) cmd ;
      if ( (NULL != _pFrameDetailA) && ( NULL != pRadioButton) )
      {
         if (pRadioButton->GetState() == CATDlgCheck) 
         {
            SetVerticalAttachment(10, CATDlgTopOrLeft, _pFrameDetailA, NULL);
            _pFrameDetailA->SetVisibility(CATDlgShow);         
         } 
         else 
         {
            ResetAttachment(_pFrameDetailA);         
           _pFrameDetailA->SetVisibility(CATDlgHide);         
         }
      }
    }
    ...

    When the state of the button is:

    The OnRadioButtonDBRadBModifyNotification method is called when the end user selects or deselects the "With more frame B" radio button. The contents of this method is similar to the previous one. 

    The OnRadioButtonNARadBModifyNotification method is called when the end user selects or deselects the "Without frame" radio button. The contents of this method is empty once there is no frame to attach. 

  5. The "Frame Replacement Demonstrator" Dialog box
  6. The OnComboSelectNotification method is called when the end user selects a new element in the combo list. 

    ...
    void CAADlgFrameReplaceDlg::OnComboSelectNotification(CATCommand* cmd, CATNotification* evt, CATCommandClientData data)
    {
       if ( NULL != _pComboPointType )
       {
          ResetAttachment(_pListFrame[_CurrentSelection]);
          _pListFrame[_CurrentSelection]->SetVisibility(CATDlgHide);
          
          int NewCurrentSelection = _pComboPointType->GetSelect() ;
          SetHorizontalAttachment(5, CATDlgTopOrLeft
                                         , _pListFrame[NewCurrentSelection], NULL);
          _pListFrame[NewCurrentSelection]->SetVisibility(CATDlgShow);
          
          _CurrentSelection = NewCurrentSelection ;
       }
    }
    ...

    The code is the following: See Fig. 6

    1. Retrieving the frame to detach : The _CurrentSelection frame in the _pListFrame table. See the Build method
    2. Detaching the old frame (_CurrentSelection) from its tabulation and hidding it 
    3. Retrieving the frame to attach: The current value in the combo list, NewCurrentSelection 
    4. Attaching the NewCurrentSelection frame to the fit tabulation and showing it

    NewCurrentSelection becomes the new current index value kept in the _CurrentSelection data member. 

[Top]

 


In Short

This use case explains how to use the tabulation layout to create dynamic dialog boxes, such as a more and less dialog box. 

[Top]


References

[1] Arranging Dialog Objects Using Tabulations
[2] Arranging Dialog Objects Using Grid
[3] Building and Launching a CAA V5 Use Case
[4] Assigning Resources to a Dialog Box
[Top]

History

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

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