Ejemplo n.º 1
0
int wxOwnerDrawnComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
                                        unsigned int pos,
                                        void **clientData,
                                        wxClientDataType type)
{
    EnsurePopupControl();

    const unsigned int count = items.GetCount();

    if ( HasFlag(wxCB_SORT) )
    {
        int n = pos;

        for ( unsigned int i = 0; i < count; ++i )
        {
            n = GetVListBoxComboPopup()->Append(items[i]);
            AssignNewItemClientData(n, clientData, i, type);
        }

        return n;
    }
    else
    {
        for ( unsigned int i = 0; i < count; ++i, ++pos )
        {
            GetVListBoxComboPopup()->Insert(items[i], pos);
            AssignNewItemClientData(pos, clientData, i, type);
        }

        return pos - 1;
    }
}
Ejemplo n.º 2
0
int wxCheckListBox::DoInsertItems(const wxArrayStringsAdapter & items,
                                  unsigned int pos,
                                  void **clientData, wxClientDataType type)
{
    const unsigned int count = items.GetCount();

    ListView_SetItemCount( GetHwnd(), GetCount() + count );

    int n = wxNOT_FOUND;

    for( unsigned int i = 0; i < count; i++ )
    {
        LVITEM newItem;
        wxZeroMemory(newItem);
        newItem.iItem = pos + i;
        n = ListView_InsertItem( (HWND)GetHWND(), & newItem );
        wxCHECK_MSG( n != -1, -1, wxT("Item not added") );
        SetString( n, items[i] );
        m_itemsClientData.Insert(NULL, n);

        AssignNewItemClientData(n, clientData, i, type);
    }

    return n;
}
Ejemplo n.º 3
0
int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
                            unsigned int pos,
                            void **clientData, wxClientDataType type)
{
    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid control") );

    wxASSERT_MSG( !IsSorted() || (pos == GetCount()),
                 wxT("In a sorted choice data could only be appended"));

    const int count = items.GetCount();

    int n = wxNOT_FOUND;

    for ( int i = 0; i < count; ++i )
    {
        n = pos + i;
        // If sorted, use this wxSortedArrayStrings to determine
        // the right insertion point
        if (m_strings)
            n = m_strings->Add(items[i]);

        GTKInsertComboBoxTextItem( n, items[i] );

        m_clientData.Insert( NULL, n );
        AssignNewItemClientData(n, clientData, i, type);
    }

    InvalidateBestSize();

    return n;
}
Ejemplo n.º 4
0
int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
                            unsigned int pos,
                            void **clientData, wxClientDataType type)
{
    const unsigned int numItems = items.GetCount();
    for( unsigned int i = 0; i < numItems; ++i, ++pos )
    {
        unsigned int idx;

#if wxUSE_STL
        if ( IsSorted() )
        {
            wxArrayString::iterator
                insertPoint = std::lower_bound( m_strings.begin(), m_strings.end(), items[i] );
            idx = insertPoint - m_strings.begin();
            m_strings.insert( insertPoint, items[i] );
        }
        else
#endif // wxUSE_STL
        {
            idx = pos;
            m_strings.Insert( items[i], idx );
        }

        m_popUpMenu->Insert( idx, i+1, items[i] );
        m_datas.Insert( NULL, idx );
        AssignNewItemClientData(idx, clientData, i, type);
    }

    m_peer->SetMaximum( GetCount() );

    return pos - 1;
}
Ejemplo n.º 5
0
int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items,
                            unsigned int pos,
                            void **clientData,
                            wxClientDataType type)
{
    MSWAllocStorage(items, LB_INITSTORAGE);

    const bool append = pos == GetCount();
    const unsigned msg = append ? LB_ADDSTRING : LB_INSERTSTRING;
    if ( append )
        pos = 0;

    int n = wxNOT_FOUND;

    const unsigned int numItems = items.GetCount();
    for ( unsigned int i = 0; i < numItems; ++i )
    {
        n = MSWInsertOrAppendItem(pos, items[i], msg);
        if ( !append )
            pos++;

        AssignNewItemClientData(n, clientData, i, type);
    }

    return n;
}
Ejemplo n.º 6
0
int wxItemContainer::DoInsertItemsInLoop(const wxArrayStringsAdapter& items,
                                         unsigned int pos,
                                         void **clientData,
                                         wxClientDataType type)
{
    int n = wxNOT_FOUND;

    const unsigned int count = items.GetCount();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( unsigned int i = 0; i < count; ++i )
    {
        n = DoInsertOneItem(items[i], pos++);
        if ( n == wxNOT_FOUND )
            break;

        AssignNewItemClientData(n, clientData, i, type);
    }

    return n;
}
Ejemplo n.º 7
0
int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
                             unsigned int pos,
                             void **clientData,
                             wxClientDataType type)
{
    int idx = wxNOT_FOUND;
    unsigned int startpos = pos;

    const unsigned int numItems = items.GetCount();
    for ( unsigned int i = 0; i < numItems; ++i )
    {
        const wxString& item = items[i];
        idx = IsSorted() ? m_strings.sorted->Add(item)
                         : (m_strings.unsorted->Insert(item, pos), pos++);

        m_itemsClientData.Insert(NULL, idx);
        AssignNewItemClientData(idx, clientData, i, type);

        GetListPeer()->ListInsert(startpos+i);

        OnItemInserted(idx);
    }

    GetListPeer()->UpdateLineToEnd(startpos);

    UpdateOldSelections();

    return idx;
}
Ejemplo n.º 8
0
int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
                            unsigned int pos,
                            void **clientData, wxClientDataType type)
{
    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") );

    const unsigned int count = items.GetCount();

    GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );

    for ( unsigned int i = 0; i < count; ++i, ++pos )
    {
        int n = GtkAddHelper(menu, pos, items[i]);
        if ( n == wxNOT_FOUND )
            return n;

        AssignNewItemClientData(n, clientData, i, type);
    }

    // if the item to insert is at or before the selection, and the selection is valid
    if (((int)pos <= m_selection_hack) && (m_selection_hack != wxNOT_FOUND))
    {
        // move the selection forward
        m_selection_hack += count;
    }

    return pos - 1;
}
Ejemplo n.º 9
0
int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,
                             unsigned int pos,
                             void **clientData,
                             wxClientDataType type)
{
    long lIndex = 0;
    LONG lIndexType = 0;
    bool incrementPos = false;

    if (IsSorted())
        lIndexType = LIT_SORTASCENDING;
    else if (pos == GetCount())
        lIndexType = LIT_END;
    else
    {
        lIndexType = (LONG)pos;
        incrementPos = true;
    }

    int n = wxNOT_FOUND;

    unsigned int count = items.GetCount();
    for (unsigned int i = 0; i < count; i++)
    {
        n = (int)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)items[i].wx_str());
        if (n < 0)
        {
            wxLogLastError(_T("WinSendMsg(LM_INSERTITEM)"));
            n = wxNOT_FOUND;
            break;
        }
        ++m_nNumItems;

#if wxUSE_OWNER_DRAWN
        if (HasFlag(wxLB_OWNERDRAW))
        {
            wxOwnerDrawn*               pNewItem = CreateItem(n); // dummy argument
            wxScreenDC                  vDc; // FIXME: is it really needed here?
    
            pNewItem->SetName(items[i]);
            m_aItems.Insert(pNewItem, n);
            pNewItem->SetFont(GetFont());
        }
#endif
        AssignNewItemClientData(n, clientData, i, type);

        if (incrementPos)
            ++lIndexType;
    }

    return n;
} // end of wxListBox::DoInsertAppendItemsWithData
Ejemplo n.º 10
0
int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,
                             unsigned int pos,
                             void **clientData,
                             wxClientDataType type)
{
    MSWAllocStorage(items, LB_INITSTORAGE);

    const bool append = pos == GetCount();

    // we must use CB_ADDSTRING when appending as only it works correctly for
    // the sorted controls
    const unsigned msg = append ? LB_ADDSTRING : LB_INSERTSTRING;

    if ( append )
        pos = 0;

    int n = wxNOT_FOUND;

    const unsigned int numItems = items.GetCount();
    for ( unsigned int i = 0; i < numItems; i++ )
    {
        n = MSWInsertOrAppendItem(pos, items[i], msg);
        if ( n == wxNOT_FOUND )
            return n;

        if ( !append )
            pos++;

        ++m_noItems;

#if wxUSE_OWNER_DRAWN
        if ( HasFlag(wxLB_OWNERDRAW) )
        {
            wxOwnerDrawn *pNewItem = CreateLboxItem(n);
            pNewItem->SetName(items[i]);
            pNewItem->SetFont(GetFont());
            m_aItems.Insert(pNewItem, n);
        }
#endif // wxUSE_OWNER_DRAWN
        AssignNewItemClientData(n, clientData, i, type);
    }

    m_updateHorizontalExtent = true;

    UpdateOldSelections();

    return n;
}
Ejemplo n.º 11
0
int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
                             unsigned int pos,
                             void **clientData,
                             wxClientDataType type)
{
    int idx = wxNOT_FOUND;
    unsigned int startpos = pos;

    const unsigned int numItems = items.GetCount();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( unsigned int i = 0; i < numItems; ++i )
    {
        const wxString& item = items[i];
        idx = IsSorted() ? m_strings.sorted->Add(item)
                         : (m_strings.unsorted->Insert(item, pos), pos++);

        m_itemsClientData.Insert(NULL, idx);
        AssignNewItemClientData(idx, clientData, i, type);

        GetListPeer()->ListInsert(startpos+i);

        OnItemInserted(idx);
    }

    GetListPeer()->UpdateLineToEnd(startpos);

    // Inserting the items may scroll the listbox down to show the last
    // selected one but we don't want to do it as it could result in e.g. the
    // first items of a listbox be hidden immediately after its creation so
    // show the first selected item instead. Ideal would probably be to
    // preserve the old selection unchanged, in fact, but I don't know how to
    // get the first visible item so for now do at least this.
    SetFirstItem(startpos);

    UpdateOldSelections();

    return idx;
}
Ejemplo n.º 12
0
int wxItemContainer::DoInsertItemsInLoop(const wxArrayStringsAdapter& items,
                                         unsigned int pos,
                                         void **clientData,
                                         wxClientDataType type)
{
    int n = wxNOT_FOUND;

    const unsigned int count = items.GetCount();
    for ( unsigned int i = 0; i < count; ++i )
    {
        n = DoInsertOneItem(items[i], pos++);
        if ( n == wxNOT_FOUND )
            break;

        AssignNewItemClientData(n, clientData, i, type);
    }

    return n;
}
Ejemplo n.º 13
0
int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
                             unsigned int pos,
                             void **clientData,
                             wxClientDataType type)
{
    wxCHECK_MSG( m_treeview != NULL, wxNOT_FOUND, wxT("invalid listbox") );

    InvalidateBestSize();

    GtkTreeIter* pIter = NULL; // append by default
    GtkTreeIter iter;
    if ( pos != GetCount() )
    {
        wxCHECK_MSG( GTKGetIteratorFor(pos, &iter), wxNOT_FOUND,
                     wxT("internal wxListBox error in insertion") );

        pIter = &iter;
    }

    const unsigned int numItems = items.GetCount();
    for ( unsigned int i = 0; i < numItems; ++i )
    {
        GtkTreeEntry* entry = gtk_tree_entry_new();
        gtk_tree_entry_set_label(entry, wxGTK_CONV(items[i]));
        gtk_tree_entry_set_destroy_func(entry,
                (GtkTreeEntryDestroy)gtk_tree_entry_destroy_cb,
                            this);

        GtkTreeIter itercur;
        gtk_list_store_insert_before(m_liststore, &itercur, pIter);

        GTKSetItem(itercur, entry);

        g_object_unref (entry);

        if (clientData)
            AssignNewItemClientData(GTKGetIndexFor(itercur), clientData, i, type);
    }

    UpdateOldSelections();

    return pos + numItems - 1;
}
Ejemplo n.º 14
0
int wxSimpleHtmlListBox::DoInsertItems(const wxArrayStringsAdapter& items,
                                       unsigned int pos,
                                       void **clientData,
                                       wxClientDataType type)
{
    const unsigned int count = items.GetCount();

    m_items.Insert(wxEmptyString, pos, count);
    m_HTMLclientData.Insert(NULL, pos, count);

    for ( unsigned int i = 0; i < count; ++i, ++pos )
    {
        m_items[pos] = items[i];
        AssignNewItemClientData(pos, clientData, i, type);
    }

    UpdateCount();

    return pos - 1;
}
Ejemplo n.º 15
0
int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
                              unsigned int pos,
                              void **clientData, wxClientDataType type)
{
    const unsigned int numItems = items.GetCount();
    for( unsigned int i = 0; i < numItems; ++i, ++pos )
    {
        unsigned int idx;

        idx = pos;
        GetComboPeer()->InsertItem( idx, items[i] );

        if (idx > m_datas.GetCount())
            m_datas.SetCount(idx);
        m_datas.Insert( NULL, idx );
        AssignNewItemClientData(idx, clientData, i, type);
    }

    GetPeer()->SetMaximum( GetCount() );

    return pos - 1;
}
Ejemplo n.º 16
0
int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items
                           , unsigned int pos
                           , void **clientData
                           , wxClientDataType type
                           )
{
    int                             nIndex = wxNOT_FOUND;
    LONG                            nIndexType = 0;
    bool                            incrementPos = false;
    if ( IsSorted() )
        nIndexType = LIT_SORTASCENDING;
    else if (pos == GetCount())
        nIndexType = LIT_END;
    else
    {
        nIndexType = pos;
        incrementPos = true;
    }

    const unsigned int count = items.GetCount();
    for( unsigned int i = 0; i < count; ++i )
    {
        nIndex = (int)::WinSendMsg( GetHwnd()
                                   ,LM_INSERTITEM
                                   ,(MPARAM)nIndexType
                                   ,(MPARAM)items[i].wx_str()
                                  );
        if (nIndex < 0)
        {
            nIndex = wxNOT_FOUND;
            break;
        }
        AssignNewItemClientData(nIndex, clientData, i, type);

        if (incrementPos)
            ++nIndexType;
    }
    return nIndex;
} // end of wxChoice::DoInsertAppendItemsWithData
Ejemplo n.º 17
0
int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
                             unsigned int pos,
                             void **clientData,
                             wxClientDataType type)
{
    wxCHECK_MSG( m_list != NULL, wxNOT_FOUND, wxT("invalid listbox") );

    const unsigned count = GetCount();
    wxCHECK_MSG( pos <= count, wxNOT_FOUND,
                    wxT("invalid index in wxListBox::InsertItems") );

    // code elsewhere supposes we have as many items in m_clientList as items
    // in the listbox
    wxASSERT_MSG( m_clientList.GetCount() == count,
                      wxT("bug in client data management") );

    InvalidateBestSize();

    const unsigned numItems = items.GetCount();

    for ( unsigned int n = 0; n < numItems; ++n, ++pos )
    {
        const wxString& item = items[n];

        const unsigned idx = m_strings ? m_strings->Add(item)
                                       : pos;

        GtkAddItem(item, idx == GetCount() ? (unsigned) -1 : idx);

        m_clientList.Insert(idx, NULL);

        AssignNewItemClientData(idx, clientData, n, type);
    }

    wxASSERT_MSG( m_clientList.GetCount() == GetCount(),
                      wxT("bug in client data management") );

    return pos - 1;
}
Ejemplo n.º 18
0
int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items,
                            unsigned int pos,
                            void **clientData, wxClientDataType type)
{
    MSWAllocStorage(items, CB_INITSTORAGE);

    const bool append = pos == GetCount();

    // use CB_ADDSTRING when appending at the end to make sure the control is
    // resorted if it has wxCB_SORT style
    const unsigned msg = append ? CB_ADDSTRING : CB_INSERTSTRING;

    if ( append )
        pos = 0;

    int n = wxNOT_FOUND;
    const unsigned numItems = items.GetCount();
    for ( unsigned i = 0; i < numItems; ++i )
    {
        n = MSWInsertOrAppendItem(pos, items[i], msg);
        if ( n == wxNOT_FOUND )
            return n;

        if ( !append )
            pos++;

        AssignNewItemClientData(n, clientData, i, type);
    }

    // we need to refresh our size in order to have enough space for the
    // newly added items
    if ( !IsFrozen() )
        MSWUpdateDropDownHeight();

    InvalidateBestSize();

    return n;
}
Ejemplo n.º 19
0
int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
                            unsigned int pos,
                            void **clientData, wxClientDataType type)
{
    const unsigned int numItems = items.GetCount();
    for( unsigned int i = 0; i < numItems; ++i, ++pos )
    {
        unsigned int idx;

#if wxUSE_STD_CONTAINERS
        if ( IsSorted() )
        {
            wxArrayString::iterator
                insertPoint = std::lower_bound( m_strings.begin(), m_strings.end(), items[i] );
            idx = insertPoint - m_strings.begin();
            m_strings.insert( insertPoint, items[i] );
        }
        else
#endif // wxUSE_STD_CONTAINERS
        {
            idx = pos;
            m_strings.Insert( items[i], idx );
        }

        wxString text = items[i];
        if (text == wxEmptyString)
            text = " ";  // menu items can't have empty labels
        m_popUpMenu->Insert( idx, i+1, text );
        m_datas.Insert( NULL, idx );
        AssignNewItemClientData(idx, clientData, i, type);
    }

    DoAfterItemCountChange();

    return pos - 1;
}
Ejemplo n.º 20
0
int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
                              unsigned int pos,
                              void **clientData,
                              wxClientDataType type)
{
    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );

    DisableEvents();

    GtkWidget *list = GTK_COMBO(m_widget)->list;

    GtkRcStyle *style = CreateWidgetStyle();

    const unsigned int count = items.GetCount();
    for( unsigned int i = 0; i < count; ++i, ++pos )
    {
        GtkWidget *
            list_item = gtk_list_item_new_with_label( wxGTK_CONV( items[i] ) );

        if ( pos == GetCount() )
        {
            gtk_container_add( GTK_CONTAINER(list), list_item );
        }
        else // insert, not append
        {
            GList *gitem_list = g_list_alloc ();
            gitem_list->data = list_item;
            gtk_list_insert_items( GTK_LIST (list), gitem_list, pos );
        }

        if (GTK_WIDGET_REALIZED(m_widget))
        {
            gtk_widget_realize( list_item );
            gtk_widget_realize( GTK_BIN(list_item)->child );

            if (style)
            {
                gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
                GtkBin *bin = GTK_BIN( list_item );
                GtkWidget *label = GTK_WIDGET( bin->child );
                gtk_widget_modify_style( label, style );
            }

        }

        gtk_widget_show( list_item );

        if ( m_clientDataList.GetCount() < GetCount() )
            m_clientDataList.Insert( pos, NULL );
        if ( m_clientObjectList.GetCount() < GetCount() )
            m_clientObjectList.Insert( pos, NULL );

        AssignNewItemClientData(pos, clientData, i, type);
    }

    if ( style )
        gtk_rc_style_unref( style );

    EnableEvents();

    InvalidateBestSize();

    return pos - 1;
}