WideStudio Logo
WideStudio
Programming Guide
WideStudio Index
Table of contents


A lista



Ajustando os itens pelo método

Utilize o método addItem para adicionar itens à lista tendo uma string e posição. Se a posição é omitida, adicione-a no final da lista. Segue exemplo:

#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
#include <WSClist.h>
extern WSClist* newlist_001;
void btnep1(WSCbase* object){
//Delete all the items of the list.
newlist_001->delAll();
//Add an item to the last of the list.
newlist_001->addItem("item1");
newlist_001->addItem("item2");
newlist_001->addItem("item3");
newlist_001->addItem("item4");
//Add an item to the specified position of the list.
newlist_001->addItem("item0",0);//0 :top
newlist_001->addItem("item5",-1);//-1 :last

//Update the modified list.
newlist_001->updateList();
}
static WSCfunctionRegister op("btnep1",(void*)btnep1);



Ajustando os itens pela propriedade

A propriedade WSNdata pode ser usada para ajuste dos itens da lista, se existe comparativamente um número menor de itens.
Neste caso, ajuste a propriedade WSNdataSource para WS_DATA_SOURCE_NONE, e ajuste os itens que são denotados com vírgula para cada um da propriedade WSNdata.
#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
#include <WSClist.h>
extern WSClist* newlist_001;
void btnep1(WSCbase* object){
//Delete all the items of the list.
newlist_001->delAll();
//Set the items of the list by the property
newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_NONE);
newlist_001->setProperty(WSNdata,"item0\nitem1\nitem2\nitem3\nitem4");
}
static WSCfunctionRegister op("btnep1",(void*)btnep1);

É possível apresentar o ICON específico pelo nome do arquivo de ícone, como segue abaixo. Ajuste como verdadeira a propriedade WSNuseIcon e ajuste os itens com o formato apresentado abaixo. Se omitido, o valor de WSNiconPixmap é utilizado como ícone default.

Formato:
  ICON1filename,string1ofTheItem\n ICON2filename,string2ofTheItem\n...
void btnep1(WSCbase* object){
//Delete all the list of the list
newlist_001->delAll();
//Set the items of the list by the property
newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_NONE);
newlist_001->setProperty(WSNdata,
"$(WSDIR)/sys/pixmaps/bi16.xpm,item1\nitem2\nitem3");
}
static WSCfunctionRegister op("btnep1",(void*)btnep1);



Ajustando os itens a partir do arquivo diretamente

É possível ajustar os itens diretamente a partir do arquivo. Neste caso, primeiro ajuste WS_DATA_SOURCE_FILE da propriedade WSNdataSource, e ajuste o nome de arquivo da propriedade WSNdataSourceName como segue:

#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
#include <WSClist.h>
extern WSClist* newlist_001;
void btnep1(WSCbase* object){
//Delete all the items of the list
newlist_001->delAll();
//Set the items from file directly
newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_FILE);
newlist_001->setProperty(WSNdataSourceName,"data.txt");
}
static WSCfunctionRegister op("btnep1",(void*)btnep1);

//data.txt contains...
$(WSDIR)/sys/pixmaps/bi16.xpm,item1
item2
item3
item4
$(WSDIR)/sys/pixmaps/bi16.xpm,item5
item6
item7
item8



Ajustando os itens a partir de outra intância

Nestes casos, ajuste em WS_DATA_SOURCE_INSTANCE a propriedade WSNdataSource, e ajuste o nome de instância na propriedade WSNdataSourceName. O exemplo a seguir, uma instância WSCtextField é especificada na propriedade WSNdataSourceName e então ajusta o dado  da mesma na lista.
#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
#include <WSClist.h>
extern WSClist* newlist_001;
void btnep1(WSCbase* object){
//Delete all the items of the list
newlist_001->delAll();
//Set the items from the other instances
newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_INSTANCE);
newlist_001->setProperty(WSNdataSourceName,"newtext_000");
}
static WSCfunctionRegister op("btnep1",(void*)btnep1);

A figura a seguir mostra a lista (lado inferior) a partir de outra instância da classe WSCtextField (lado superior).



[A lista de dados a partir de outra instância]


Document Release 3.80 for WideStudio ver 3.80, Jan 2005


WideStudio documents index | Table of contents

Copyright(C) WideStudio Development Team, 1999-2005 Last modified: Jan 05, 2005