SDK:Working with Dynamic Data Exchange (DDX)

From Vectorworks Developer
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

Dynamic Data Exchange (DDX) is meant to simplify the way the data for the controls is keeping up to date. The idea is that you have variable for each control. Automatically when the control's data changes, the value of this variable is updated. There is also VWDialog::UpdateData function that you can call to update in both directions -- from the controls to the variables and vise versa.

Here are the steps which you have to do in order to attach a variable to a control.

Add a variable definition

In your dialog definition, the type of the variable depends on the type of the control. Look at the end of the document about the tables of types for each control variable.

// variable for DDX
long     fIntControlValue;

Attach the variable to the control

The control is identified by it's integer ID. It's good idea to define your control identifiers as constants. The attaching you do in VWDialog::OnDDXInitialize function after doing everything else, initializing and attaching controls if you are doing dynamic dialog. For the adding see the DDX related functions in VWDialog since for each control type there is different function that attaches DDX variable. The value of the variable is put in the control when the variable is attached to the control. Look at the end of the document about the tables of types for each control variable.

// add DDX variables to the control
this->AddDDX_EditInteger( kEditIntegerControlID, & fIntControlValue );

Now the dialogs makes sure that the DDX variables are updated with the control's data.

So, in an event functions (either virtual or event handler functions) you always have proper data in the variables for all the controls. If you want to update the variables and put the new value in the controls explicitly, you can use VWDialog::UpdateData function by passing true witch will cause the function to update the controls with their DDX variables. The variables are automatically updated before a function is called, and after it finishes.

fIntControlValue   = 11;
this->UpdateData( true );

Here is a table that describes all supported types for the DDX mechanism. It shows also the classes from VectorWorks::VWUI namespace that provides interface for working with specific controls. It also shows what type is expected to be the DDX variable for each type control.

Control Type DDX Function
VWCheckButtonCtrl bool VWDialog::AddDDX_CheckButton
VWCheckGroupBoxCtrl bool VWDialog::AddDDX_CheckGroupBox
VWColorButtonCtrl RGBColor VWDialog::AddDDX_ColorButton
VWEditIntegerCtrl long VWDialog::AddDDX_EditInteger
VWEditRealCtrl double VWDialog::AddDDX_EditReal
VWEditTextCtrl TXString VWDialog::AddDDX_EditText
VWRadioButtonCtrl bool VWDialog::AddDDX_RadioButton
VWRadioGroupBoxCtrl bool VWDialog::AddDDX_RadioGroupBox
VWPullDownMenuCtrl short VWDialog::AddDDX_PulldownMenu
VWListBoxCtrl short VWDialog::AddDDX_ListBox

See Also

SDK:Creating handler class for VectorScript layout dialog | SDK:Creating handler class for manual layout dialog | Using Saved Settings