User:CBM-c-/VS-List Browsers part 1

From Vectorworks Developer
Revision as of 08:08, 31 December 2020 by CBM-c- (talk | contribs) (expand)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Introduction List_Browsers_part_1 List_Browsers_part_2


List Browsers Part 1

List Browsers dissected Part 1: creation and columns. For better understanding please use the comprehensive example at Dialog with List Browser. By --_c_ (talk) 03:08, 31 December 2020 (EST) (previously Orso B. Schmid)


Create a List Browser

List Browsers are called in a Layout Creation routine with CreateLB.

CreateLB(dialogID: LONGINT; componentID: LONGINT; 
	widthInCharacters: INTEGER; heightInCharacters: INTEGER);
widthInCharacters, heightInCharacters
is different between Mac and PC. Basically on Mac all dialog items with a scroll bar interpret the width excluding the bar. This will influence the width of dialog elements such as PullDown menus, List Browsers, Lists and such. These items won't align with Static Text, Edit fields and similar: the scroll bar will be outside alignment. You must correct the width programmatically.


List Browsers in resizable dialogs

List Browsers are special dialog items with a built-in binding to their parent container. If a dialog is resizable, they resize width and height automatically, without any Edge Binding. For this reason you'll prefer to leave List Browsers outside groups: they will fit beautifully to the dialog window without you to bother.

dlog := CreateResizableLayout('List Browsers test', TRUE, 'Close', '', TRUE, FALSE);
{ ... }
CreateLB(dlog, cLB, cLBWidth, cLBHeight);


Load a List Browser

Your List Browser after creation is just an empty container without columns, rows or any data. Before loading the List Browser it is important to understand what needs to be loaded once and if there are things that needs to be loaded repeatedly, after destroying data. Aside of images, which must be really loaded only once, all other List Browser elements can be loaded, destroyed, created or modified according to your needs. The typical script will set up a List Browser once in SetupDialogC and manipulate repeatedly only rows data. Usually you will:

  • add Icons always only once
  • add Columns most times once
  • add Column Data Items most times only once
  • add/delete/modify Cells repeatedly

Then you'll organize your loading code as follows:

  • needs loading once --> has a place in the SetupDialogC CASE item of your dialog driver routine
  • needs loading repeatedly --> resides in a subroutine with wider validity scope (including SetupDialogC for the first run).


Items and Sub-items (0-based)

At start the main difficulty in understanding List Browsers is caused by the naming of the various routine parameters. Everyone will struggle initially with "itemIndex" and "subItemIndex", sometimes also called (more clearly) "columnIndex". The official documentation uses names not consequently. Just some examples:


GetLBItemInfo(dialogID: LONGINT; componentID: LONGINT; itemIndex: INTEGER; subItemIndex: INTEGER; 
	VAR itemString: STRING; VAR imageIndex: INTEGER): BOOLEAN;

GetLBItemData(nDialogID, nComponentID :LONGINT; nItemIndex, nSubItemIndex :INTEGER; 
	VAR nUserData :LONGINT);

InsertLBColumn( dialogID:LONGINT; componentID:LONGINT; columnIndex:INTEGER;
	headerString:STRING; width:INTEGER):INTEGER;


Introduction List_Browsers_part_1 List_Browsers_part_2