VS:CreateLayout

From Vectorworks Developer
Jump to: navigation, search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Creates a new custom dialog layout. After the layout is created, control items for the dialog can be added to the layout.
FUNCTION CreateLayout(
dialogTitle  :STRING;
hasHelp  :BOOLEAN;
defaultButtonName  :STRING;
cancelButtonName  :STRING) : LONGINT;
def vs.CreateLayout(dialogTitle, hasHelp, defaultButtonName, cancelButtonName):
    return LONGINT

Parameters

dialogTitle STRING Title of the dialog.
hasHelp BOOLEAN Enables help text for the dialog.
defaultButtonName STRING Text displayed in the default button of the dialog.
cancelButtonName STRING Text displayed in the cancel button of the dialog.

Return Value

Returns an index number identifying the new dialog layout.

Remarks

Creates a dialog with a default button, cancel button, and a help box. If you do not want a button created then pass an empty string.

Note that when you start creating controls, you should stick to IDs that are less than 500. Using IDs >= 500 will sometimes work, but sometimes they will not. (Layout Manager writes its own information into whatever structure it's using, in the 500+ range, and this "might" over-write control indexes.)

It is possible to place a control next to the OK and Cancel button. To do this, give that control id 12605. It is not neccesary to add this control to the layout, this is done automatically (see Example 2 below).

Example

VectorScript

PROCEDURE AddChoiceSample;
CONST

    { control IDs}
    kCreatePullDownMenu                  = 33;

    kCreatePullDownMenuGroupBox          = 34;

    kCreateListBox                       = 29;
    kCreateListBoxN                      = 30;

    kCreatePushButton                    = 100;

VAR
    dialog            :INTEGER;

PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
BEGIN
    CASE item OF
        SetupDialogC: BEGIN
        
            AddChoice( dialog, kCreatePullDownMenu, 'kCreatePullDownMenu choice', 0 );

            AddChoice( dialog, kCreatePullDownMenuGroupBox, 'kCreatePullDownMenuGroupBox choice', 0 );

            AddChoice( dialog, kCreateListBox, 'kCreateListBox choice', 0 );
            AddChoice( dialog, kCreateListBoxN, 'kCreateListBoxN choice', 0 );

        END;
    END;
END;


BEGIN
    dialog := CreateLayout( 'Add Choice Sample', TRUE, 'OK', 'Cancel' );

    {create controls}

    CreatePullDownMenu( dialog, kCreatePullDownMenu, 24 );

    CreatePullDownMenuGroupBox( dialog, kCreatePullDownMenuGroupBox, 24, 'pull down menu', TRUE );

    CreatePushButton( dialog, kCreatePushButton, 'push button' );
    SetFirstGroupItem( dialog, kCreatePullDownMenuGroupBox, kCreatePushButton );

    CreateListBox( dialog, kCreateListBox, 24, 4 );
    CreateListBoxN( dialog, kCreateListBoxN, 24, 4, TRUE );


    {set relations}
    SetFirstLayoutItem( dialog, kCreatePullDownMenu );
 
    SetBelowItem( dialog, kCreatePullDownMenu, kCreatePullDownMenuGroupBox, 0, 0 );

    SetBelowItem( dialog, kCreatePullDownMenuGroupBox, kCreateListBox, 0, 0 );
    SetBelowItem( dialog, kCreateListBox, kCreateListBoxN, 0, 0 );



    IF RunLayoutDialog( dialog, Dialog_Handler ) = 1 THEN BEGIN
    END;

END;
RUN( AddChoiceSample );

Python

def AddChoiceSample():
	# control IDs
	global kCreatePullDownMenu                
	global kCreatePullDownMenuGroupBox 
	global kCreateListBox                          
	global kCreateListBoxN                        
	global kCreatePushButton   
	global SetupDialogC
	kCreatePullDownMenu                = 33
	kCreatePullDownMenuGroupBox = 34
	kCreateListBox                          = 29
	kCreateListBoxN                        = 30
	kCreatePushButton                    = 100
	SetupDialogC = 12255


def Dialog_Handler(item, data):
	if (item == SetupDialogC):
		vs.AddChoice( dialog, kCreatePullDownMenu, 'kCreatePullDownMenu choice', 0 )
		vs.AddChoice( dialog, kCreatePullDownMenuGroupBox, 'kCreatePullDownMenuGroupBox choice', 0 )
		vs.AddChoice( dialog, kCreateListBox, 'kCreateListBox choice', 0 )
		vs.AddChoice( dialog, kCreateListBoxN, 'kCreateListBoxN choice', 0 )

def CreateMyDialog():
	global dialog
	dialog = vs.CreateLayout( 'Add Choice Sample', 1, 'OK', 'Cancel' )

	#{create controls}

	vs.CreatePullDownMenu( dialog, kCreatePullDownMenu, 24 )

	vs.CreatePullDownMenuGroupBox( dialog, kCreatePullDownMenuGroupBox, 24, 'pull down menu', 1 )

	vs.CreatePushButton( dialog, kCreatePushButton, 'push button' )
	vs.SetFirstGroupItem( dialog, kCreatePullDownMenuGroupBox, kCreatePushButton )

	vs.CreateListBox( dialog, kCreateListBox, 24, 4 )
	vs.CreateListBoxN( dialog, kCreateListBoxN, 24, 4, 1 )


	#{set relations}
	vs.SetFirstLayoutItem( dialog, kCreatePullDownMenu )
 
	vs.SetBelowItem( dialog, kCreatePullDownMenu, kCreatePullDownMenuGroupBox, 0, 0 )

	vs.SetBelowItem( dialog, kCreatePullDownMenuGroupBox, kCreateListBox, 0, 0 )
	vs.SetBelowItem( dialog, kCreateListBox, kCreateListBoxN, 0, 0 )

	if vs.RunLayoutDialog( dialog, Dialog_Handler ) == 1:
		pass

kCreatePullDownMenu = 0               
kCreatePullDownMenuGroupBox  = 0 
kCreateListBox     = 0                       
kCreateListBoxN    = 0                      
kCreatePushButton    = 0 
SetupDialogC = 0 
dialog = 0
AddChoiceSample()
CreateMyDialog()

Version

Availability: from VectorWorks9.0
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox