3. which passes them to the popup window if it is popped up
*/
+// constants
+// ----------------------------------------------------------------------------
+
+// the margin between the text control and the combo button
+static const wxCoord g_comboMargin = 2;
+
// ----------------------------------------------------------------------------
// wxComboButton is just a normal button except that it sends commands to the
// combobox and not its parent
wxSize sizeBtn = m_btn->GetBestSize(),
sizeText = m_text->GetBestSize();
- return wxSize(sizeBtn.x + sizeText.x, wxMax(sizeBtn.y, sizeText.y));
+ return wxSize(sizeText.x + g_comboMargin + sizeBtn.x, wxMax(sizeBtn.y, sizeText.y));
}
void wxComboControl::DoMoveWindow(int x, int y, int width, int height)
void wxComboBox::Clear()
{
GetLBox()->Clear();
+ GetText()->SetValue(wxEmptyString);
}
void wxComboBox::Delete(int n)
{
+ wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Delete") );
+
+ if (GetSelection() == n)
+ GetText()->SetValue(wxEmptyString);
+
GetLBox()->Delete(n);
}
wxString wxComboBox::GetString(int n) const
{
+ wxCHECK_MSG( (n >= 0) && (n < GetCount()), wxEmptyString, _T("invalid index in wxComboBox::GetString") );
+
return GetLBox()->GetString(n);
}
void wxComboBox::SetString(int n, const wxString& s)
{
+ wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::SetString") );
+
GetLBox()->SetString(n, s);
}
void wxComboBox::Select(int n)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid combobox index") );
+ wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Select") );
GetLBox()->SetSelection(n);
GetText()->SetValue(GetLBox()->GetString(n));
int wxComboBox::GetSelection() const
{
+#if 1 // FIXME:: What is the correct behavior?
// if the current value isn't one of the listbox strings, return -1
+ return GetLBox()->GetSelection();
+#else
+ // Why oh why is this done this way?
+ // It is not because the value displayed in the text can be found
+ // in the list that it is the item that is selected!
return FindString(GetText()->GetValue());
+#endif
}
int wxComboBox::DoAppend(const wxString& item)