// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see .
#include "stdwx.h"
#include "BOINCBitmapComboBox.h"
// On Windows, wxBitmapComboBox loses an item's clientData when
// another item is inserted in front of it. This subclass works
// around that bug by keeping the clientData separately.
IMPLEMENT_DYNAMIC_CLASS(CBOINCBitmapComboBox, wxBitmapComboBox)
CBOINCBitmapComboBox::CBOINCBitmapComboBox() {}
CBOINCBitmapComboBox::CBOINCBitmapComboBox(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name
) :
wxBitmapComboBox(parent, id, value, pos, size, n,
choices, style, validator, name
)
{
int i;
for (i=0; i::iterator insertionPoint = m_pClientData.begin();
m_pClientData.insert(insertionPoint + pos, NULL);
int n = wxBitmapComboBox::Insert(item, bitmap, pos);
return n;
}
int CBOINCBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, unsigned int pos, void *clientData) {
std::vector::iterator insertionPoint = m_pClientData.begin();
m_pClientData.insert(insertionPoint + pos, clientData);
int n = wxBitmapComboBox::Insert(item, bitmap, pos, (void*)NULL);
return n;
}
void CBOINCBitmapComboBox::Delete(unsigned int n) {
if (n < GetCount()) {
std::vector::iterator deletionPoint = m_pClientData.begin();
m_pClientData.erase(deletionPoint + n);
}
wxBitmapComboBox::Delete(n);
// Refresh();
}
void CBOINCBitmapComboBox::Clear() {
int count = GetCount();
for(int j = count-1; j >=0; --j) {
wxASSERT(!m_pClientData[j]);
m_pClientData[j] = NULL;
}
m_pClientData.clear();
wxBitmapComboBox::Clear();
}