Hi,
Is there any way to change the direction of listbox from "left-to-right" to "right-to-left"? You know, I use a database of farsi words which I want to show them in order with a list box; the problem is that the words are shown not only left to right, but also in reverse character order.
I had the same problem for Window graphics context and I resolved it by using DrawTextExtended() method but I wonder if there is something similar for listboxes.
Thank you beforehand.
hi jp4symbian,
Thanks for your response. I have defined iListBox as CEikTextListBox (CEikTextListBox* iListBox;). This class dos not have itemDrawer method. Is your iListBox defined as CSettingsListBoxView? How can I use it?
Thanks.
Hi jp4symbian, I wonder why I can not handle listboxes I have no compilation error but my application closed when I run it on emulator, Can you mail me a simple application which uses listboxes? My yahoo ID is hojatvaheb. God Bless you.
List Boxes are pretty easy things. At present I cannot create a sample due to time constraints. I am sorry about that..
If you can wait for some time then I can give u a sample....
You can refer this link in your SDK Help: Developer Guides >> Avkon UI Resources - Listboxes >>Creating and Using Listboxes>>Creating a Numbered Selection Listbox Without a Resource File
You will surely be able to build a List box from this code.
And you can use below code for alignment :-
iListBox->ItemDrawer()->ColumnData()->SetColumnAlignmentL(1, CGraphicsContext::ERight);
Hi, I have tired of working with S60 list boxesïŒ. I can not see items I read from database with list box but I can see list box items when I define them manually, Look at my code to read from database names:
void CDBMSListboxView::SetListItemsL(CDesCArrayFlat* aNewItems) { CTextListBoxModel* model = iListBox2->Model(); model->SetItemTextArray(aNewItems); // Set ListBox model responsible for deleting the listItems array model->SetOwnershipType( ELbmOwnsItemArray ); iListBox2->HandleItemAdditionL();//iListBox2 = new(ELeave)CAknDoubleStyleListBox (); if(aNewItems->Count()>0) { // Select the first item, if there is one. iListBox2->SetCurrentItemIndexAndDraw(0); }
But this code works fine:
void CDBMSListboxView::SetListItemsL(CDesCArrayFlat* aNewItems) { /*…reading from database…*/ CDesCArrayFlat *itemList = new (ELeave) CDesCArrayFlat(10); itemList->AppendL(_L("\t \x062A\x0644\x0641\x0646\x0647\x0627\x06CC \t\t")); itemList->AppendL(_L("\tSecond item\t\t")); // set items and ownership iListBox2->Model()->SetItemTextArray(itemList); iListBox2->Model()->SetOwnershipType(ELbmOwnsItemArray); iListBox2->SetCurrentItemIndex(0); iListBox2->SetFocus(ETrue); iListBox2->HandleItemAdditionL(); }
Is there anything related to the format of data in listboxes?! You know when I use" \t Data\t\t", it works; but when I read database items, it does not.
Special Thanks to jp4symbian.
(It can be navigated from the link that i gave u earlier in this post. It lists out almost all kinds of list boxes. Make sure you see the entire tutorial of listboxes which can be reached through the above link)
How can I change the format of data which is read from database before being displayed? I have a database of farsi words, When I debug my program, I can see that the data is in Unicode form, for example this is a name read from database: L"\x0633\x0631\x0631\x0633\x06CC\x062F"
Should this name reformatted to L"\t\x0633\x0631\x0631\x0633\x06CC\x062F\t\t" ?I'm not familiar with text processing functions of s60.
Thanks.
I have never worked with Unicode characters so don't know how to manipulate them.
If you can very well display these characters on the screen then you can use the FormatL() function in descriptors (TDes16/TDes8 class) to format your database data.
Just put your data in a descriptor and format it according to the list box that you are using.
For formatting descriptors, go through the following link in your SDK help:
» Developer Library » API Reference » C++ API reference » Descriptors » Using TDes16 >> Formatting text
I suggest first you try displaying simple English strings in your List Box to understand the basics. The you can go ahead with your Unicode characters and alignment.
And don't forget to study descriptors well, it is an extremely important part of Symbian.
result1 has a justify method ehich can be used to change the alignment of data, but it has 4 parameters which I wonder how I can use them,
another thing is that I can not use any listbox except CAknDoubleStyleListBox unless I get error message, for example if I use CAknSingleStyleListBox I get this error message: Undefined symbol: 'class CTextListBoxModel * CEikColumnListBox::Model(void) const (?Model@CEikColumnListBox@@QBEPAVCTextListBoxModel@@XZ)' referenced from 'void CDBMSListboxView::SetListItemsL(class CDesC16ArrayFlat *) (?SetListItemsL@CDBMSListboxView@@QAEXPAVCDesC16ArrayFlat@@@Z)' in DBMSListboxView.cpp:119 referenced from 'void CDBMSListboxView::SetListItemsL(class CDesC16ArrayFlat *) (?SetListItemsL@CDBMSListboxView@@QAEXPAVCDesC16ArrayFlat@@@Z)' in DBMSListboxView.cpp:120 referenced from 'int CDBMSListboxView::GetSelectedItem(class TDes16 &) const (?GetSelectedItem@CDBMSListboxView@@QBEHAAVTDes16@@@Z)' in DBMSListboxView.cpp:255
I have specified line 119 , 120 in my code.
Thanks.
I think there is some misunderstanding. There is no difference in using CAknSingleStyleListBox or CAknDoubleStyleListBox as long as the following lines are concerned:
iListBox2->Model()->SetItemTextArray(itemList);
iListBox2->Model()->SetOwnershipType(ELbmOwnsItemArray);
Maybe there is some change that you have forgotten to do when you use CAknSingleStyleListBox instead of CAknDoubleStyleListBox. Make sure you have made all necessary changes in header file n all.
Also I can tell you a better way to format.
Suppose if you are using CAknSingleStyleListBox.
_LIT(KListFormat,"_LIT(KListItemFormat, "\t%S\t\t"); // Initiliaze the list format of the list you are using/b]
_LIT(KListItem,"Item1");
// Format the data
[b]insertString.Format(KListItemFormat,&item); // Use the format function
iItemArray = static_cast(iListBox->Model()->ItemTextArray());
Forum posts: 80
Hi Rostam,
Maybe this can a bit helpful:
iListBox->ItemDrawer()->ColumnData()->SetColumnAlignmentL(1, CGraphicsContext::ERight);
I have checked it, it makes the text in the second column of your list box right aligned.
You can first reverse your entire string and then display it right-aligned.
I hope this is useful.
Forum posts: 40
hi jp4symbian,
Thanks for your response. I have defined iListBox as CEikTextListBox (CEikTextListBox* iListBox;). This class dos not have itemDrawer method. Is your iListBox defined as CSettingsListBoxView? How can I use it?
Thanks.
Forum posts: 80
Hello Rostam,
I have used CAknSingleNumberStyleListBox. There are many such different types of listboxes that you can use depending on your requirement.
And the implementation can be found in the List Box example in the SDK.
For more information on ListBox, an extremely useful link is:
http://www.newlc.com/article.php3?id_article=136
Forum posts: 40
Hi jp4symbian, I wonder why I can not handle listboxes
I have no compilation error but my application closed when I run it on emulator, Can you mail me a simple application which uses listboxes? My yahoo ID is hojatvaheb. God Bless you.
Forum posts: 80
Hi Rostam,
First I need to know which SDK are you working with currently.
If you are working with S60 3rd Edition, then I won't be able to help you.
But if its 2nd Edition, i surely can!!!
Forum posts: 40
I work with 2nd Edition
Forum posts: 80
Hi Rostam,
List Boxes are pretty easy things. At present I cannot create a sample due to time constraints. I am sorry about that..
If you can wait for some time then I can give u a sample....
You can refer this link in your SDK Help:
Developer Guides >> Avkon UI Resources - Listboxes >>Creating and Using Listboxes>>Creating a Numbered Selection Listbox Without a Resource File
You will surely be able to build a List box from this code.
And you can use below code for alignment :-
iListBox->ItemDrawer()->ColumnData()->SetColumnAlignmentL(1, CGraphicsContext::ERight);
Forum posts: 40
Hi, I have tired of working with S60 list boxesïŒ. I can not see items I read from database with list box but I can see list box items when I define them manually, Look at my code to read from database names:
void CDBMSAppUi::ShowAllRecordsL(){
_LIT(KAllRecords,"");
CDesCArrayFlat* Records = iDatabase->GetAllRecordsL();
CleanupStack::PushL(Records);
CDesCArrayFlat* names = NamesArrayL(Records);
CleanupStack::PushL(names);
ChangeViewL(EListView); // construct the listbox view
iListboxView->SetCaptionL(KAllRecords);
CleanupStack::Pop(names);
iListboxView->SetListItemsL(names); // Takes ownership
CleanupStack::PopAndDestroy(Records);
}
And here is SetListItemsL:
void CDBMSListboxView::SetListItemsL(CDesCArrayFlat* aNewItems){
CTextListBoxModel* model = iListBox2->Model();
model->SetItemTextArray(aNewItems);
// Set ListBox model responsible for deleting the listItems array
model->SetOwnershipType( ELbmOwnsItemArray );
iListBox2->HandleItemAdditionL();//iListBox2 = new(ELeave)CAknDoubleStyleListBox ();
if(aNewItems->Count()>0)
{
// Select the first item, if there is one.
iListBox2->SetCurrentItemIndexAndDraw(0);
}
But this code works fine:
void CDBMSListboxView::SetListItemsL(CDesCArrayFlat* aNewItems){
/*…reading from database…*/
CDesCArrayFlat *itemList = new (ELeave) CDesCArrayFlat(10);
itemList->AppendL(_L("\t \x062A\x0644\x0641\x0646\x0647\x0627\x06CC \t\t"));
itemList->AppendL(_L("\tSecond item\t\t"));
// set items and ownership
iListBox2->Model()->SetItemTextArray(itemList);
iListBox2->Model()->SetOwnershipType(ELbmOwnsItemArray);
iListBox2->SetCurrentItemIndex(0);
iListBox2->SetFocus(ETrue);
iListBox2->HandleItemAdditionL();
}
Thanks.
Forum posts: 80
Are you not having a separate Container class for your List Box?
I have loaded my List Box from database just the way you have done except that I have separate view and container classes.
My SetListItemsL() function gets called in the DoActivateL() function of the View class; after Container object is created and constructed.
Moreover you can also add following highlighted lines after list box is loaded:
iListBox->HandleItemAdditionL();
iListBoxEntry->ActivateL();
DrawDeferred();
iListBox->SetCurrentItemIndex(0);
Forum posts: 40
Is there anything related to the format of data in listboxes?! You know when I use" \t Data\t\t", it works; but when I read database items, it does not.
Special Thanks to jp4symbian.
Forum posts: 80
Oh yes my dear, definitely the format matters!!!!!!!!! I was assuming that you know that!
The format of the data depends on the kind of listbox you are using... You need to format your data before displaying it in the list box.
For e.g. in CAknSingleStyleListBox, data format is "\t%S\t\t"
For CAknSingleNumberStyleListBox, data format is "%d\t%S\t\t" and so on...............
Did you check out following link:
http://www.newlc.com/article.php3?id_article=234
(It can be navigated from the link that i gave u earlier in this post. It lists out almost all kinds of list boxes. Make sure you see the entire tutorial of listboxes which can be reached through the above link)
All the best!
Forum posts: 40
How can I change the format of data which is read from database before being displayed? I have a database of farsi words, When I debug my program, I can see that the data is in Unicode form, for example this is a name read from database:
L"\x0633\x0631\x0631\x0633\x06CC\x062F"Should this name reformatted to L"\t\x0633\x0631\x0631\x0633\x06CC\x062F\t\t" ?I'm not familiar with text processing functions of s60.
Thanks.
Forum posts: 80
hi rostam,
I have never worked with Unicode characters so don't know how to manipulate them.
If you can very well display these characters on the screen then you can use the FormatL() function in descriptors (TDes16/TDes8 class) to format your database data.
Just put your data in a descriptor and format it according to the list box that you are using.
For formatting descriptors, go through the following link in your SDK help:
» Developer Library » API Reference » C++ API reference » Descriptors » Using TDes16 >> Formatting text
I suggest first you try displaying simple English strings in your List Box to understand the basics. The you can go ahead with your Unicode characters and alignment.
And don't forget to study descriptors well, it is an extremely important part of Symbian.
Forum posts: 40
Thanks jp4symbian, Now I feel a bit better about s60 listboxes, I use the following code to format my data:
TPtrC16 sourceRow;TBufC16<16> str(sourceRow);
TBuf<256> result1;
_LIT16(temp,"\t");
CDesCArrayFlat *itemList = new (ELeave) CDesCArrayFlat(10);
for(TInt i=0; i<aNewItems->MdcaCount(); i++)
{
sourceRow.Set(aNewItems->MdcaPoint(i));
result1=sourceRow.Mid(0);
result1.Insert(0,temp);
itemList->AppendL(result1);
}
iListBox2->Model()->SetItemTextArray(itemList);//LINE 119
iListBox2->Model()->SetOwnershipType(ELbmOwnsItemArray);// LINE 120
iListBox2->SetCurrentItemIndex(0);
iListBox2->SetFocus(ETrue);
iListBox2->HandleItemAdditionL();
iListBox2->ActivateL();
result1 has a justify method ehich can be used to change the alignment of data, but it has 4 parameters which I wonder how I can use them,
another thing is that I can not use any listbox except CAknDoubleStyleListBox unless I get error message, for example if I use CAknSingleStyleListBox I get this error message:
Undefined symbol: 'class CTextListBoxModel * CEikColumnListBox::Model(void) const (?Model@CEikColumnListBox@@QBEPAVCTextListBoxModel@@XZ)' referenced from 'void CDBMSListboxView::SetListItemsL(class CDesC16ArrayFlat *) (?SetListItemsL@CDBMSListboxView@@QAEXPAVCDesC16ArrayFlat@@@Z)' in DBMSListboxView.cpp:119 referenced from 'void CDBMSListboxView::SetListItemsL(class CDesC16ArrayFlat *) (?SetListItemsL@CDBMSListboxView@@QAEXPAVCDesC16ArrayFlat@@@Z)' in DBMSListboxView.cpp:120 referenced from 'int CDBMSListboxView::GetSelectedItem(class TDes16 &) const (?GetSelectedItem@CDBMSListboxView@@QBEHAAVTDes16@@@Z)' in DBMSListboxView.cpp:255I have specified line 119 , 120 in my code.
Thanks.
Forum posts: 80
Hi Rostam,
I think there is some misunderstanding. There is no difference in using CAknSingleStyleListBox or CAknDoubleStyleListBox as long as the following lines are concerned:
iListBox2->Model()->SetItemTextArray(itemList);
iListBox2->Model()->SetOwnershipType(ELbmOwnsItemArray);
Maybe there is some change that you have forgotten to do when you use CAknSingleStyleListBox instead of CAknDoubleStyleListBox. Make sure you have made all necessary changes in header file n all.
Also I can tell you a better way to format.
Suppose if you are using CAknSingleStyleListBox.
_LIT(KListFormat,"_LIT(KListItemFormat, "\t%S\t\t"); // Initiliaze the list format of the list you are using/b]
_LIT(KListItem,"Item1");
TBuf<256> item(KListItem);
TBuf<256> insertString;
// Format the data(iListBox->Model()->ItemTextArray());
[b]insertString.Format(KListItemFormat,&item); // Use the format function
iItemArray = static_cast
iItemArray ->AppendL(listboxItems++, insertString);
iListBox->HandleItemAdditionL();
iListBox->SetCurrentItemIndex(0);
DrawDeferred();