×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    33

    How to get listbox and search control sized, positioned?

    I have read everything I can find on the use of adaptive search for a listbox, and nothing I have tried yields a correct sizing/positioning of both the listbox and the search control. What I end up with is a list that takes up all the available display, but the search control is invisible or perhaps underneath the listbox. Tapping on any entry in the list brings up the adaptive search controls, and they work, i.e., the list gets properly filtered.

    The listbox and search control are in a CAknDialog derived dialog, and that dialog's resource specified flags = EAknListBoxSelectionList plus an array that contains about fifty entries.

    I do no explicit sizing/positioning in PreLayoutDynInitL(), but I see in the debugger that the dialog's SizeChanged() function is called before the dialog is displayed. That function looks like this:

    void CDialog::SizeChanged()
    {
    if (iListBox)
    {
    if (iSearchField)
    {
    TPoint coordListBox;
    AknLayoutUtils::LayoutMetricsPosition(AknLayoutUtils::EMainPane, coordListBox);
    iListBox->SetExtent(coordListBox, iListBox->MinimumSize());
    AknFind::HandleFixedFindSizeChanged(this, iListBox, iSearchField);
    }
    else
    {
    iListBox->SetRect(Rect()); // Sets rectangle of lstbox.
    }
    }
    }

    The search control ends up with a (0, -52) origin, which makes sense only if that is relative to the bottom left of the list - but when I create that control, I specify its parent as the dialog, not the listbox.

    Does anybody have an idea what is going wrong here?

    I've spent a lot of time trying to find a working example project, but all I've found is sample code in the 5th Edition SDK docs, which isn't complete. If anybody knows of a working example, please direct me to it.

    Thanks,

    Mark

  2. #2
    Registered User
    Join Date
    Mar 2008
    Posts
    12

    Re: How to get listbox and search control sized, positioned?

    Hi,
    you probably find some solution, but for the next generation of hopless symbian developers - here is short example of positioning listbox + searchfield.

    Yes, you are right method SizeChanged() is invoked whenever you call SetRect(aRect) on your container/dialog class - this should be sufficient to correctly layout listbox + searchfield.

    Code:
    void CsearchListContainer::SizeChanged()
    {	
      if (iListBox)
      {
        if (iFindBox)
        {
          CAknColumnListBox* aknListBox = STATIC_CAST(CAknColumnListBox*, iListBox);
          AknFind::HandleFixedFindSizeChanged(this, aknListBox, iFindBox);
        }
        else
        {
          iListBox->SetRect(Rect()); // Sets rectangle of lstbox.
        }
      }
    }
    There is problem with magnifier icon. If you use nonstandart Rect for your dialog, the icon is moved to the left out of screen. Only solution I found is to get rid of the icon:


    Code:
    CAknSearchField* CsearchListContainer::CreateFindBoxL(CEikListBox* aListBox, CTextListBoxModel* aModel,
        CAknSearchField::TSearchFieldStyle aStyle)
    {
      CAknSearchField* findbox = NULL;
    
      if(aListBox && aModel)
      {
        CAknFilteredTextListBoxModel* model = STATIC_CAST( CAknFilteredTextListBoxModel*, aModel );
        
        CFbsBitmap *nullBmp = new (ELeave) CFbsBitmap();
        CleanupStack::PushL(nullBmp);
        nullBmp->Create(TSize(0, 0), EColor4K);
        CGulIcon *nullIcon = CGulIcon::NewL(nullBmp, NULL);
        CleanupStack::Pop(); //nullBmp
        
        findbox = CAknSearchField::NewL(*this, aStyle, nullIcon, KAknListFindBoxTextLength);
        CleanupStack::PushL(findbox);
        
        model->CreateFilterL(aListBox, findbox);
        CleanupStack::Pop(findbox); // findbox
      }
    
      return findbox;
    }

Similar Threads

  1. EEventKey + listbox + search field
    By egeri in forum Symbian User Interface
    Replies: 16
    Last Post: 2009-06-09, 10:26
  2. Search Field in selection listbox
    By palak_shah_23 in forum Symbian User Interface
    Replies: 8
    Last Post: 2009-04-22, 11:05
  3. Listbox Search
    By patil_ruturaj in forum Symbian
    Replies: 1
    Last Post: 2008-08-25, 07:02
  4. Issue with Search Field in Listbox
    By s_mehdi76 in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-04-04, 08:16
  5. Issues implementing a ListBox control
    By gan_kim_heng in forum Symbian
    Replies: 6
    Last Post: 2007-03-04, 05:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×