X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/781bdbb410f421a1c93655217f8729160b6f4aa5..6726a6b09748c707351987da56226ac0316d1a00:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index d4ca4c4c87..c1cd5c2e0d 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -59,7 +59,7 @@ wxBEGIN_FLAGS( wxListBoxStyle ) wxFLAGS_MEMBER(wxBORDER_RAISED) wxFLAGS_MEMBER(wxBORDER_STATIC) wxFLAGS_MEMBER(wxBORDER_NONE) - + // old style border flags wxFLAGS_MEMBER(wxSIMPLE_BORDER) wxFLAGS_MEMBER(wxSUNKEN_BORDER) @@ -91,28 +91,28 @@ wxEND_FLAGS( wxListBoxStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxListBox, wxControl,"wx/listbox.h") wxBEGIN_PROPERTIES_TABLE(wxListBox) - wxEVENT_PROPERTY( Select , wxEVT_COMMAND_LISTBOX_SELECTED , wxCommandEvent ) - wxEVENT_PROPERTY( DoubleClick , wxEVT_COMMAND_LISTBOX_DOUBLECLICKED , wxCommandEvent ) + wxEVENT_PROPERTY( Select , wxEVT_COMMAND_LISTBOX_SELECTED , wxCommandEvent ) + wxEVENT_PROPERTY( DoubleClick , wxEVT_COMMAND_LISTBOX_DOUBLECLICKED , wxCommandEvent ) - wxPROPERTY( Font , wxFont , SetFont , GetFont , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxPROPERTY_COLLECTION( Choices , wxArrayString , wxString , AppendString , GetStrings, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxPROPERTY( Selection ,int, SetSelection, GetSelection,, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxPROPERTY_FLAGS( WindowStyle , wxListBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style + wxPROPERTY( Selection ,int, SetSelection, GetSelection, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + wxPROPERTY_FLAGS( WindowStyle , wxListBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style wxEND_PROPERTIES_TABLE() wxBEGIN_HANDLERS_TABLE(wxListBox) wxEND_HANDLERS_TABLE() -wxCONSTRUCTOR_4( wxListBox , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) +wxCONSTRUCTOR_4( wxListBox , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) #else IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) #endif /* TODO PROPERTIES - selection - content - item + selection + content + item */ // ============================================================================ @@ -161,7 +161,7 @@ bool wxListBox::Create(wxWindow *parent, const wxSize& size, int n, const wxString choices[], long style, - const wxValidator& wxVALIDATOR_PARAM(validator), + const wxValidator& validator, const wxString& name) { m_noItems = 0; @@ -184,6 +184,9 @@ bool wxListBox::Create(wxWindow *parent, Append(choices[i]); } + // now we can compute our best size correctly, so do it if necessary + SetBestSize(size); + return true; } @@ -284,6 +287,8 @@ void wxListBox::Delete(int N) int wxListBox::DoAppend(const wxString& item) { + InvalidateBestSize(); + int index = ListBox_AddString(GetHwnd(), item); m_noItems++; @@ -387,7 +392,7 @@ void wxListBox::Free() void wxListBox::SetSelection(int N, bool select) { - wxCHECK_RET( N == wxNOT_FOUND || + wxCHECK_RET( N == wxNOT_FOUND || (N >= 0 && N < m_noItems), wxT("invalid index in wxListBox::SetSelection") ); @@ -519,6 +524,8 @@ wxListBox::DoInsertItems(const wxArrayString& items, int pos) wxCHECK_RET( pos >= 0 && pos <= m_noItems, wxT("invalid index in wxListBox::InsertItems") ); + InvalidateBestSize(); + int nItems = items.GetCount(); for ( int i = 0; i < nItems; i++ ) { @@ -534,6 +541,8 @@ wxListBox::DoInsertItems(const wxArrayString& items, int pos) ListBox_SetItemData(GetHwnd(), idx, pNewItem); } +#else + wxUnusedVar(idx); #endif // wxUSE_OWNER_DRAWN } @@ -677,7 +686,7 @@ wxSize wxListBox::DoGetBestSize() const // the listbox should be slightly larger than the widest string int cx, cy; - wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); + wxGetCharSize(GetHWND(), &cx, &cy, GetFont()); wListbox += 3*cx; @@ -764,7 +773,7 @@ bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) wxDC dc; dc.SetHDC((WXHDC)hdc); - dc.SetFont(wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT)); + dc.SetFont(GetFont()); pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE; pStruct->itemWidth = dc.GetCharWidth();