VS:CreateStaticText: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
Line 49: Line 49:
<remark>
<remark>
To do multi-line static text, a fixed width for the control must be provided to control wrapping. The Layout Manager will determine the height of the control which will contain the entire string. If Chr(13)’s are included in the string, the string will be wrapped at the right edge of the control and broken at the Chr(13)’s as well.
To do multi-line static text, a fixed width for the control must be provided to control wrapping. The Layout Manager will determine the height of the control which will contain the entire string. If Chr(13)’s are included in the string, the string will be wrapped at the right edge of the control and broken at the Chr(13)’s as well.
</remark>


<remark>
If you are overlaying a StaticText control over an image e.g in an About My Great Plugin... dialog you'l find that on Windows your text background s filled in gray behind the text instead of being transparent so your image shows thru. There is a low-level fix for this in Vectorworks. Just set the color of the text to 1,1,1 instead of 0,0,0 using SetStaticTextColor(dialogID, componentID, red, green, blue); Conrad.
If you are overlaying a StaticText control over an image e.g in an About My Great Plugin... dialog you'l find that on Windows your text background s filled in gray behind the text instead of being transparent so your image shows thru. There is a low-level fix for this in Vectorworks. Just set the color of the text to 1,1,1 instead of 0,0,0 using SetStaticTextColor(dialogID, componentID, red, green, blue); Conrad.
</remark>
</remark>

Latest revision as of 15:25, 15 February 2019

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

Description

Creates a new static text field control in a dialog layout.

To allow the control to size automatically to the text width, pass -1 as the width parameter of the control.

PROCEDURE CreateStaticText(
dialogID :LONGINT;
itemID :LONGINT;
text :STRING;
widthInCharacters :LONGINT);
def vs.CreateStaticText(dialogID, itemID, text, widthInCharacters):
    return None

Parameters

dialogID LONGINT The index of the dialog layout containing the control.
itemID LONGINT The index that will identify the control item.
text STRING The display text for the control.
widthInCharacters LONGINT The width of the control in characters.

Remarks

To do multi-line static text, a fixed width for the control must be provided to control wrapping. The Layout Manager will determine the height of the control which will contain the entire string. If Chr(13)’s are included in the string, the string will be wrapped at the right edge of the control and broken at the Chr(13)’s as well.

If you are overlaying a StaticText control over an image e.g in an About My Great Plugin... dialog you'l find that on Windows your text background s filled in gray behind the text instead of being transparent so your image shows thru. There is a low-level fix for this in Vectorworks. Just set the color of the text to 1,1,1 instead of 0,0,0 using SetStaticTextColor(dialogID, componentID, red, green, blue); Conrad.

Example

VectorScript

PROCEDURE SampleDlg2;
CONST
    {Alignment constants}
    kRight                = 1;
    kBottom               = 2;
    kLeft                 = 3;
    kColumn               = 4;
    kResize               = 0;
    kShift                = 1;

    { default and cancel button IDs}
    kOK                   = 1;
    kCancel               = 2;

    { control IDs}
    kListBoxText          = 4;
    kListBox1             = 5;
    kListBrowserText      = 6;
    kListBrowser          = 7;
    kListBox2             = 8;

VAR
    dialog            :INTEGER;
    cnt               :INTEGER;

FUNCTION GetPlugInString(ndx :INTEGER) :STRING;
BEGIN
    {Static Text}
    IF ndx = 1001 THEN			GetPlugInString := 'OK'
    ELSE IF ndx = 1002 THEN		GetPlugInString := 'Cancel'
    ELSE IF ndx = 1003 THEN		GetPlugInString := 'Sample Dialog 2'
    ELSE IF ndx = 1004 THEN		GetPlugInString := 'List Box'
    ELSE IF ndx = 1005 THEN		GetPlugInString := ''
    ELSE IF ndx = 1006 THEN		GetPlugInString := 'List Browser'
    ELSE IF ndx = 1007 THEN		GetPlugInString := ''
    ELSE IF ndx = 1008 THEN		GetPlugInString := ''
    ; {Help Text}
    IF ndx = 2001 THEN			GetPlugInString := 'Accepts the dialog data.'
    ELSE IF ndx = 2002 THEN		GetPlugInString := 'Cancels the dialog data.'
    ELSE IF ndx = 2004 THEN		GetPlugInString := ''
    ELSE IF ndx = 2005 THEN		GetPlugInString := 'This is list box control.'
    ELSE IF ndx = 2006 THEN		GetPlugInString := ''
    ELSE IF ndx = 2007 THEN		GetPlugInString := 'This is list browser control.'
    ELSE IF ndx = 2008 THEN		GetPlugInString := 'Tabbed content list box. This list box contains rows with two strings with tab delimiter. This causes the list to have two columns.'
;END;
FUNCTION GetStr(ndx :INTEGER) :STRING;
BEGIN
    GetStr := GetPluginString( ndx + 1000 )
END;

FUNCTION GetHelpStr(ndx :INTEGER) :STRING;
BEGIN
    GetHelpStr := GetPluginString( ndx + 2000 )
END;

BEGIN
    dialog := CreateResizableLayout(GetStr(3), TRUE, GetStr(kOK), GetStr(kCancel), TRUE, TRUE );

    {create controls}
    CreateStaticText( dialog, kListBoxText, GetStr(kListBoxText), -1 );
    CreateListBox( dialog, kListBox1, 25, 10 );
    CreateListBox( dialog, kListBox2, 25, 10 );
    CreateStaticText( dialog, kListBrowserText, GetStr(kListBrowserText), -1 );
    CreateLB( dialog, kListBrowser, 50, 10 );

    {set relations}
    SetFirstLayoutItem( dialog, kListBoxText );
    SetBelowItem( dialog, kListBoxText, kListBox1, 0, 0 );
    SetRightItem( dialog, kListBox1, kListBox2, 0, 0 );
    SetBelowItem( dialog, kListBox1, kListBrowserText, 0, 0 );
    SetBelowItem( dialog, kListBrowserText, kListBrowser, 0, 0 );

    {set alignments}
    AlignItemEdge( dialog, kListBrowser, kRight, 1, kResize );
    AlignItemEdge( dialog, kListBox2, kRight, 1, kResize );

    {set bindings}
    SetEdgeBinding        ( dialog, kListBox1, TRUE, TRUE, FALSE, FALSE );
    SetProportionalBinding( dialog, kListBox1, FALSE, TRUE, FALSE, FALSE );
    SetEdgeBinding        ( dialog, kListBox2, TRUE, TRUE, FALSE, FALSE );
    SetProportionalBinding( dialog, kListBox2, TRUE, FALSE, FALSE, FALSE );

    {set help strings}
    FOR cnt := 1 TO 8 DO SetHelpText(dialog, cnt, GetHelpStr(cnt));
    

    
    IF RunLayoutDialog( dialog, NIL ) = 1 then BEGIN
    END;

END;
RUN( SampleDlg2 );

Python

def MyGetPlugInString(ndx):
#{Static Text}
	GetPlugInString = ''
	if   ndx == 1001:
		GetPlugInString = 'OK'
	elif ndx == 1002:		
		GetPlugInString = 'Cancel'
	elif ndx == 1003:
		GetPlugInString = 'Sample Dialog 2'
	elif ndx == 1004:
		GetPlugInString = 'List Box'
	elif ndx == 1005: 
		GetPlugInString = ''
	elif ndx == 1006:
		GetPlugInString = 'List Browser'
	elif ndx == 1007:
		GetPlugInString = ''
	elif ndx == 1008:
		GetPlugInString = ''
	#{Help Text}
	if   ndx == 2001:
		GetPlugInString = 'Accepts the dialog data.'
	elif ndx == 2002: 
		GetPlugInString = 'Cancels the dialog data.'
	elif ndx == 2004: 
		GetPlugInString = ''
	elif ndx == 2005:
		GetPlugInString = 'This is list box control.'
	elif ndx == 2006: 
		GetPlugInString = ''
	elif ndx == 2007:
		GetPlugInString = 'This is list browser control.'
	elif ndx == 2008:
		GetPlugInString = 'Tabbed content list box. This list box contains rows with two strings with tab delimiter. This causes the list to have two columns.'
	return GetPlugInString
	
def GetStr(ndx):
    return MyGetPlugInString( ndx + 1000 )


def GetHelpStr(ndx):
    return MyGetPlugInString( ndx + 2000 )

def SampleDlg2():
	#{Alignment constants}
	kRight                = 1;
	kBottom               = 2;
	kLeft                 = 3;
	kColumn               = 4;
	kResize               = 0;
	kShift                = 1;

	#{ default and cancel button IDs}
	kOK                   = 1;
	kCancel               = 2;

	#{ control IDs}
	kListBoxText          = 4;
	kListBox1             = 5;
	kListBrowserText      = 6;
	kListBrowser          = 7;
	kListBox2             = 8;

	dialog = vs.CreateResizableLayout(GetStr(3), True, GetStr(kOK), GetStr(kCancel), True, True );

	#{create controls}
	vs.CreateStaticText( dialog, kListBoxText, GetStr(kListBoxText), -1 );
	vs.CreateListBox( dialog, kListBox1, 25, 10 );
	vs.CreateListBox( dialog, kListBox2, 25, 10 );
	vs.CreateStaticText( dialog, kListBrowserText, GetStr(kListBrowserText), -1 );
	vs.CreateLB( dialog, kListBrowser, 50, 10 );

	#{set relations}
	vs.SetFirstLayoutItem( dialog, kListBoxText );
	vs.SetBelowItem( dialog, kListBoxText, kListBox1, 0, 0 );
	vs.SetRightItem( dialog, kListBox1, kListBox2, 0, 0 );
	vs.SetBelowItem( dialog, kListBox1, kListBrowserText, 0, 0 );
	vs.SetBelowItem( dialog, kListBrowserText, kListBrowser, 0, 0 );

	#{set alignments}
	vs.AlignItemEdge( dialog, kListBrowser, kRight, 1, kResize );
	vs.AlignItemEdge( dialog, kListBox2, kRight, 1, kResize );

	#{set bindings}
	vs.SetEdgeBinding        ( dialog, kListBox1, True, True, False, False );
	vs.SetProportionalBinding( dialog, kListBox1, False, True, False, False );
	vs.SetEdgeBinding        ( dialog, kListBox2, True, True, False, False );
	vs.SetProportionalBinding( dialog, kListBox2, True, False, False, False );

	#{set help strings}
	for cnt in range(1,8):
		vs.SetHelpText(dialog, cnt, GetHelpStr(cnt))



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

SampleDlg2()

VectorScript

Procedure TestNewControls;
VAR
dlogID, result	: LONGINT;

Procedure DialogProc(VAR item: LONGINT; data: LONGINT);
BEGIN
CASE item OF
SetupDialogC:
BEGIN
result := 0;
END;

END;
END;

BEGIN
{ ********** CHECK BOX GROUP BOX ********** }

dlogID := CreateLayout('Test New Controls', false, 'OK', 'Cancel');

CreateStaticText(dlogID, 4, 'Check Box Group Box', 20);
SetFirstLayoutItem(dlogID, 4);


{ Check box group box 1 }
CreateCheckBoxGroupBox(dlogID, 5, 'Check Box Group Box 1', TRUE);
SetBelowItem(dlogID, 4, 5, 0, 0);

CreatePushButton(dlogID, 6, 'Alpha');
SetFirstGroupItem(dlogID, 5, 6);

CreatePushButton(dlogID, 7, 'Beta');
SetBelowItem(dlogID, 6, 7, 0, 0);

CreatePushButton(dlogID, 8, 'Gamma');
SetBelowItem(dlogID, 7, 8, 0, 0);


{ Check box group box 2 }
CreateCheckBoxGroupBox(dlogID, 10, 'Check Box Group Box 2', TRUE);
SetRightItem(dlogID, 5, 10, 0, 0);

CreatePushButton(dlogID, 11, 'Ford');
SetFirstGroupItem(dlogID, 10, 11);

CreatePushButton(dlogID, 12, 'Crysler');
SetBelowItem(dlogID, 11, 12, 0, 0);

CreatePushButton(dlogID, 13, 'Honda');
SetBelowItem(dlogID, 12, 13, 0, 0);



{ **********  RADIO BUTTON GROUP BOX ********** }

CreateStaticText(dlogID, 14, 'Radio Button Group Boxes', 25);
SetBelowItem(dlogID, 5, 14, 0, 0);

{ Radio Button Group Box 1 }
CreateRadioButtonGroupBox(dlogID, 15, 'Radio Button Group Box 1', TRUE);
SetBelowItem(dlogID, 14, 15, 0, 0);

CreatePushButton(dlogID, 16, 'Rock');
SetFirstGroupItem(dlogID, 15, 16);

CreatePushButton(dlogID, 17, 'Scissors');
SetBelowItem(dlogID, 16, 17, 0, 0);

CreatePushButton(dlogID, 18, 'Paper');
SetBelowItem(dlogID, 17, 18, 0, 0);


{ Radio Button Group Box 2 }
CreateRadioButtonGroupBox(dlogID, 20, 'Radio Button Group Box 2', TRUE);
SetRightItem(dlogID, 15, 20, 0, 0);

CreatePushButton(dlogID, 21, 'Ebony');
SetFirstGroupItem(dlogID, 20, 21);

CreatePushButton(dlogID, 22, 'Ivory');
SetBelowItem(dlogID, 21, 22, 0, 0);


{ Radio Button Group Box 3 }
CreateRadioButtonGroupBox(dlogID, 25, 'Radio Button Group Box 3', TRUE);
SetRightItem(dlogID, 20, 25, 0, 0);

CreatePushButton(dlogID, 26, 'Engage system');
SetFirstGroupItem(dlogID, 25, 26);

CreateRadioButton(dlogID, 27, 'Warp Engines');
SetBelowItem(dlogID, 26, 27, 0, 0);

CreateRadioButton(dlogID, 28, 'Transporter');	
SetBelowItem(dlogID, 27, 28, 0, 0);

CreateRadioButton(dlogID, 29, 'Photon Torpedos');
SetBelowItem(dlogID, 28, 29, 0, 0);

CreateRadioButton(dlogID, 30, 'Phasers');
SetBelowItem(dlogID, 29, 30, 0, 0);


{ **********  TAB CONTROL ********** }

CreateStaticText(dlogID, 35, 'Tab Control', 15);
SetBelowItem(dlogID, 15, 35, 0, 0);

{ Tab Group 1 }
CreateGroupBox(dlogID, 50, 'Winkin', FALSE);

CreatePushButton(dlogID, 51, 'Button 1');
SetFirstGroupItem(dlogID, 50, 51);

CreatePushButton(dlogID, 52, 'Button 2');
SetBelowItem(dlogID, 51, 52, 0, 0);

CreatePushButton(dlogID, 53, 'Button 3');
SetBelowItem(dlogID, 52, 53, 0, 0);


{ Tab Group 2 }
CreateGroupBox(dlogID, 60, 'Blinkin', FALSE);

CreatePushButton(dlogID, 61, 'Button 1');
SetFirstGroupItem(dlogID, 60, 61);

CreatePushButton(dlogID, 62, 'Button 2');
SetRightItem(dlogID, 61, 62, 0, 0);

CreatePushButton(dlogID, 63, 'Button 3');
SetRightItem(dlogID, 62, 63, 0, 0);


{ Tab Group 3 }
CreateGroupBox(dlogID, 70, 'Nod', FALSE);

CreatePushButton(dlogID, 71, 'Button 1');
SetFirstGroupItem(dlogID, 70, 71);

CreatePushButton(dlogID, 72, 'Button 2');
SetRightItem(dlogID, 71, 72, 0, 0);

CreatePushButton(dlogID, 73, 'Button 3');
SetBelowItem(dlogID, 72, 73, 0, 0);


{ Create tab control }
CreateTabControl(dlogID, 40);
SetBelowItem(dlogID, 35, 40, 0, 0);

{ Add the tab panes }
CreateTabPane(dlogID, 40, 50);
CreateTabPane(dlogID, 40, 60);
CreateTabPane(dlogID, 40, 70);

result := RunLayoutDialog(dlogID, DialogProc);
END;
Run (TestNewControls);

Python

def DialogProc(item, data):
	global SetupDialogC
	SetupDialogC = 12255
	if item == SetupDialogC:
		return 0

def TestNewControls():
	#{ ********** CHECK BOX GROUP BOX ********** }
	dlogID = vs.CreateLayout('Test New Controls', False, 'OK', 'Cancel');

	vs.CreateStaticText(dlogID, 4, 'Check Box Group Box', 20)
	vs.SetFirstLayoutItem(dlogID, 4)


	#{ Check box group box 1 }
	vs.CreateCheckBoxGroupBox(dlogID, 5, 'Check Box Group Box 1', True)
	vs.SetBelowItem(dlogID, 4, 5, 0, 0)

	vs.CreatePushButton(dlogID, 6, 'Alpha')
	vs.SetFirstGroupItem(dlogID, 5, 6)

	vs.CreatePushButton(dlogID, 7, 'Beta')
	vs.SetBelowItem(dlogID, 6, 7, 0, 0)

	vs.CreatePushButton(dlogID, 8, 'Gamma')
	vs.SetBelowItem(dlogID, 7, 8, 0, 0)


	#{ Check box group box 2 }
	vs.CreateCheckBoxGroupBox(dlogID, 10, 'Check Box Group Box 2', True)
	vs.SetRightItem(dlogID, 5, 10, 0, 0)

	vs.CreatePushButton(dlogID, 11, 'Ford')
	vs.SetFirstGroupItem(dlogID, 10, 11)

	vs.CreatePushButton(dlogID, 12, 'Crysler')
	vs.SetBelowItem(dlogID, 11, 12, 0, 0)

	vs.CreatePushButton(dlogID, 13, 'Honda')
	vs.SetBelowItem(dlogID, 12, 13, 0, 0)



	#{ **********  RADIO BUTTON GROUP BOX ********** }

	vs.CreateStaticText(dlogID, 14, 'Radio Button Group Boxes', 25)
	vs.SetBelowItem(dlogID, 5, 14, 0, 0)

	#{ Radio Button Group Box 1 }
	vs.CreateRadioButtonGroupBox(dlogID, 15, 'Radio Button Group Box 1', True)
	vs.SetBelowItem(dlogID, 14, 15, 0, 0)

	vs.CreatePushButton(dlogID, 16, 'Rock')
	vs.SetFirstGroupItem(dlogID, 15, 16)

	vs.CreatePushButton(dlogID, 17, 'Scissors')
	vs.SetBelowItem(dlogID, 16, 17, 0, 0)

	vs.CreatePushButton(dlogID, 18, 'Paper')
	vs.SetBelowItem(dlogID, 17, 18, 0, 0)


	#{ Radio Button Group Box 2 }
	vs.CreateRadioButtonGroupBox(dlogID, 20, 'Radio Button Group Box 2', True)
	vs.SetRightItem(dlogID, 15, 20, 0, 0)

	vs.CreatePushButton(dlogID, 21, 'Ebony')
	vs.SetFirstGroupItem(dlogID, 20, 21)

	vs.CreatePushButton(dlogID, 22, 'Ivory')
	vs.SetBelowItem(dlogID, 21, 22, 0, 0)


	#{ Radio Button Group Box 3 }
	vs.CreateRadioButtonGroupBox(dlogID, 25, 'Radio Button Group Box 3', True)
	vs.SetRightItem(dlogID, 20, 25, 0, 0)

	vs.CreatePushButton(dlogID, 26, 'Engage system')
	vs.SetFirstGroupItem(dlogID, 25, 26)

	vs.CreateRadioButton(dlogID, 27, 'Warp Engines')
	vs.SetBelowItem(dlogID, 26, 27, 0, 0)

	vs.CreateRadioButton(dlogID, 28, 'Transporter')
	vs.SetBelowItem(dlogID, 27, 28, 0, 0)

	vs.CreateRadioButton(dlogID, 29, 'Photon Torpedos')
	vs.SetBelowItem(dlogID, 28, 29, 0, 0)

	vs.CreateRadioButton(dlogID, 30, 'Phasers')
	vs.SetBelowItem(dlogID, 29, 30, 0, 0)


	#{ **********  TAB CONTROL ********** }

	vs.CreateStaticText(dlogID, 35, 'Tab Control', 15)
	vs.SetBelowItem(dlogID, 15, 35, 0, 0)

	#{ Tab Group 1 }
	vs.CreateGroupBox(dlogID, 50, 'Winkin', False)

	vs.CreatePushButton(dlogID, 51, 'Button 1')
	vs.SetFirstGroupItem(dlogID, 50, 51)

	vs.CreatePushButton(dlogID, 52, 'Button 2')
	vs.SetBelowItem(dlogID, 51, 52, 0, 0)

	vs.CreatePushButton(dlogID, 53, 'Button 3')
	vs.SetBelowItem(dlogID, 52, 53, 0, 0)


	#{ Tab Group 2 }
	vs.CreateGroupBox(dlogID, 60, 'Blinkin', False)

	vs.CreatePushButton(dlogID, 61, 'Button 1')
	vs.SetFirstGroupItem(dlogID, 60, 61)

	vs.CreatePushButton(dlogID, 62, 'Button 2')
	vs.SetRightItem(dlogID, 61, 62, 0, 0)

	vs.CreatePushButton(dlogID, 63, 'Button 3')
	vs.SetRightItem(dlogID, 62, 63, 0, 0)


	#{ Tab Group 3 }
	vs.CreateGroupBox(dlogID, 70, 'Nod', False)

	vs.CreatePushButton(dlogID, 71, 'Button 1')
	vs.SetFirstGroupItem(dlogID, 70, 71)

	vs.CreatePushButton(dlogID, 72, 'Button 2')
	vs.SetRightItem(dlogID, 71, 72, 0, 0)

	vs.CreatePushButton(dlogID, 73, 'Button 3')
	vs.SetBelowItem(dlogID, 72, 73, 0, 0)


	#{ Create tab control }
	vs.CreateTabControl(dlogID, 40)
	vs.SetBelowItem(dlogID, 35, 40, 0, 0)

	#{ Add the tab panes }
	vs.CreateTabPane(dlogID, 40, 50)
	vs.CreateTabPane(dlogID, 40, 60)
	vs.CreateTabPane(dlogID, 40, 70)

	return vs.RunLayoutDialog(dlogID, DialogProc)

TestNewControls()

Version

Availability: from VectorWorks9.0