SDK:Add TabPane handler class

From Vectorworks Developer
Revision as of 15:39, 12 August 2013 by Root (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

.SDK|SDK ..SDK:Types|SDK Types ..SDK:Using the SDK|Using the SDK ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

Here are the steps describing how to create a class which will handle events for a tab pane of a tab control. You have to create one class for each tab pane in your tab control.

Create class for the tab pane:

Create class

Inherit VWTabPaneCtrl class. Note that the class defines a event dispatch map. The parent dialog will pass the messages and this class will have the opportunity to handle the events in a proper way. Also you may also use the DDX mechanism (Dynamic Data Exchange (DDX) )

//////////////////////////////////////////////////////////////////////////
// MyTabPane1.h
class CMyTabPane1 : public VWFC::VWUI::VWTabPaneCtrl
{
public:
                            CMyTabPane1();
    virtual                 ~CMyTabPane1();

// events
protected:
    virtual void            OnSetUpEvent();
    virtual void            OnUpdateUI();
    virtual void            OnDDXInitialize();

// events dispatcher map
protected:
   DEFINE_EVENT_DISPATH_MAP;

// DDX variables
protected:

// local data
private:

};
//////////////////////////////////////////////////////////////////////////
// MyTabPane1.cpp

#include "MyTabPane1.h"

EVENT_DISPATCH_MAP_BEGIN( CMyTabPane1 );
EVENT_DISPATCH_MAP_END;

CMyTabPane1::CMyTabPane1()
{
    // TODO: init DDX variables
}

CMyTabPane1::~CMyTabPane1()
{
}

void CMyTabPane1::OnDDXInitialize()
{
     // TODO: attach DDX variables to the controls
}

void CMyTabPane1::OnSetUpEvent()
{
}

void CMyTabPane1::OnUpdateUI()
{
     // TODO: update dialog UI state
}

Add variables

Add variables for each of the tab pane classes in your dialog class definition.

These variables are actually instances of the tab panes. Note that in the following example there are two tab pane classes CMyTabPane1 and CMyTabPane2.

//////////////////////////////////////////////////////////////////////////
class CMyDialog : public VWFC::VWUI::VWDialog
{
public:
                            CMyDialog();
    virtual                 ~CMyDialog();

public:
    virtual bool            CreateDialogLayout();

// events
protected:
    virtual void            OnSetUpEvent();
    virtual void            OnDDXInitialize();

// dispatch map
protected:
    DEFINE_EVENT_DISPATH_MAP;

private:
    CMyTabPane1            fTheTabPane1;
    CMyTabPane2            fTheTabPane2;
};

Tell the dialog

Tell the dialog that there are two tab panes to carry about.

In the constructor of the dialog you have to attach the instances of the tab panes in the dialog. That way the dialog will send the messages to the tab pane classes for processing.

Note As you can see there is no place which each tab pane is attaches to it's parent tab control. That's because the messages from the tab panes are send by VectorWorks directly to the dialog and have nothing to do with the tab pane. Here is why the tab pane classes will receive all the message from the dialog. It is tab pane class' responsibility to handle appropriate events from the controls which are within the tab pane.

//////////////////////////////////////////////////////////////////////////
// The constructor of 'CMyDialog'
CMyDialog::CMyDialog()
{
    this->AddTabPaneControl( & fTheTabPane1 );
    this->AddTabPaneControl( & fTheTabPane2 );
}


See Also

SDK:Creating handler class for VectorScript layout dialog | SDK:Creating handler class for manual layout dialog | SDK:Working with Dynamic Data Exchange (DDX)