![]() | Programming Guide | WideStudio Index Table of contents |
子目录结构一览
通过函数实现一览的数据显示控制
在子目录结构一览(WSCtreeList),或者WSClist 的一览类别为[子目录结构一览]的一览中,要追加项目显示数据时,同前面介绍的一览情况完全一样,使用addItem 函数。根据addItem ,指定追加的字符串,追加的位置。省略追加位置的话,将被追加到一览的末尾。同时,一览项目的结构阶层,能用setItemValue 函数设定。在引数中,将设定项目的位置,值别等指定于WS_INDENT_LEVEL,及阶层中。完全不设定的情况下,将成为第0阶层,成为最初阶层。mpfc::WSClist_setItemValue($obj,$pos,$mpfc::WS_INDENT_LEVEL,$level); $pos = 0,1,2,...,-1(最末尾) $level = 0(top),1,2,3...下图是子目录结构一览中追加项目的范例。
[子目录结构一览]#---------------------------------------------------------- #Function for the event procedure #---------------------------------------------------------- use mpfc; sub btnep1 { my ($object) = @_; #Delete all the items of the list. mpfc::WSClist_delAll($newlist_001); #Add an item to the last of the list. mpfc::WSClist_addItem($newlist_001,"item1"); mpfc::WSClist_setItemValue($newlist_001,-1,$mpfc::WS_INDENT_LEVEL,0); mpfc::WSClist_addItem($newlist_001,"item2"); mpfc::WSClist_setItemValue($newlist_001,-1,$mpfc::WS_INDENT_LEVEL,1); mpfc::WSClist_addItem($newlist_001,"item3"); mpfc::WSClist_setItemValue($newlist_001,-1,$mpfc::WS_INDENT_LEVEL,2); mpfc::WSClist_addItem($newlist_001,"item4"); mpfc::WSClist_setItemValue($newlist_001,-1,$mpfc::WS_INDENT_LEVEL,3); mpfc::WSClist_addItem($newlist_001,"item5"); mpfc::WSClist_setItemValue($newlist_001,-1,$mpfc::WS_INDENT_LEVEL,0); mpfc::WSClist_addItem($newlist_001,"item6"); mpfc::WSClist_setItemValue($newlist_001,-1,$mpfc::WS_INDENT_LEVEL,1); #Add an item to the specified position of the list. mpfc::WSClist_updateList($newlist_001); return; } 1;在子目录结构一览中,应该注意的是,在项目间完全没有任何关系,只是单纯的一览显示,即各项目按指定状态进行显示。因此,删掉最上层的项目,不会使其以下阶层的项目丢失。同时,跟前项之间的差为+1为止。如果有+1以上差,将被自动订正为+1。通过属性设定详细一览的数据
项目数少的比较情况,能通过属性进行项目的总括设定。这个情况时,首先,将dataSource 属性设定为WS_DATA_SOURCE_NONE。然后,用以下格式在data 属性中设定数据。
数据格式:(属性 useIcon为True的情况)icon_filename,indent_level,1=open/0=close,项目字符串\n...数据格式:(属性 useIcon为 False 的情况)indent_level,1=open/0=close,项目字符串\n...如果省略图标,属性 iconPixmap 中指定的图标将被作为图标使用。#---------------------------------------------------------- #Function for the event procedure #---------------------------------------------------------- use mpfc; sub btnep1 { my ($object) = @_; #Delete all the items of the list. mpfc::WSClist_delAll($newlist_001); #Set the items of the list by the property mpfc::WSCbase_setProperty($newlist_001,"dataSource",$mpfc::WS_DATA_SOURCE_NONE); mpfc::WSCbase_setProperty($newlist_001,"data",",0,1,item1\n,1,1,item2\n,2,1,item3"); return; } 1;通过文件设定子项目结构一览数据
可以通过指定文件名,从文件进行项目的总括设定。这种情况时,首先,将dataSource 属性指定为 WS_DATA_SOURCE_FILE。然后,在dataSourceName 属性中指定文件名。通过builder的属性设定,和程序的设定实现动作。下列是在程序中的设定的例子。#---------------------------------------------------------- #Function for the event procedure #---------------------------------------------------------- use mpfc; sub btnep1 { my ($object) = @_; #Delete all the items of the list mpfc::WSClist_delAll($newlist_001); #Set the items from file directly mpfc::WSCbase_setProperty($newlist_001,"dataSource",$mpfc::WS_DATA_SOURCE_FILE); mpfc::WSCbase_setProperty($newlist_001,"dataSourceName","data.txt"); return; } 1; #data.txt contains... $(WSDIR)/sys/pixmaps/bi16.xpm,0,1,item1 1,1,item2 2,1,item3 3,1,item4 $(WSDIR)/sys/pixmaps/bi16.xpm,0,1,item5 1,1,item6 2,1,item7 3,1,item8通过Instance显示一览的数据
通过指定Instance名,从该Instance的数据源对象属性对项目进行总括设定。这个情况时,首先,将dataSource 属性设定为WS_DATA_SOURCE_INSTANCE。然后,在dataSourceName 属性中指定Instance名。下列的例子中,指定了WSCtextField 的Instance(newtext_000)。数据的形式,与文件指定的情况一样。被输入到newtext_000中的字符串在一览里将被显示。通过builder的属性设定,程序的设定可以动作。下列是在程序设定的例子。这个情况,被输入区域的Instance newtext_000中所输入的字符串将作为详细一览的项目被显示。下列是在程序的设定的例子。这个情况,被输入Instance newtext_000的字符串将作为子目录结构一览的项目被显示。#---------------------------------------------------------- #Function for the event procedure #---------------------------------------------------------- use mpfc; sub btnep1 { my ($object) = @_; #Delete all the items of the list mpfc::WSClist_delAll($newlist_001); #Set the items from the other instances mpfc::WSCbase_setProperty($newlist_001,"dataSource",$mpfc::WS_DATA_SOURCE_INSTANCE); mpfc::WSCbase_setProperty($newlist_001,"dataSourceName","newtext_000"); return; } 1;
Copyright(C) T. Hirabayashi, 2000-2004 | Last modified: Feb 25, 2004 |