X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/81d66cf39f810503baed79213bc3122fda0ccc7b..520e470fdd0daef09c77938db642e4583933c90d:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 8eac8338fa..273b9a61be 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -38,7 +38,7 @@ #undef GetCharWidth #endif -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN #include "wx/ownerdrw.h" #endif @@ -53,7 +53,7 @@ // list box item declaration and implementation // ============================================================================ -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN class wxListBoxItem : public wxOwnerDrawn { @@ -67,7 +67,7 @@ wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE) SetMarginWidth(0); } -wxOwnerDrawn *wxListBox::CreateItem(uint n) +wxOwnerDrawn *wxListBox::CreateItem(size_t n) { return new wxListBoxItem(); } @@ -160,7 +160,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, wxSystemSettings settings; SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetForegroundColour(parent->GetForegroundColour()); m_windowId = ( id == -1 ) ? (int)NewControlId() : id; @@ -183,7 +183,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, if (m_windowStyle & wxLB_SORT) wstyle |= LBS_SORT; -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { // we don't support LBS_OWNERDRAWVARIABLE yet wstyle |= LBS_OWNERDRAWFIXED; @@ -198,65 +198,63 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, // Even with extended styles, need to combine with WS_BORDER // for them to look right. - if ( want3D || (m_windowStyle & wxSIMPLE_BORDER) - || (m_windowStyle & wxRAISED_BORDER) - || (m_windowStyle & wxSUNKEN_BORDER) - || (m_windowStyle & wxDOUBLE_BORDER) ) { + if ( want3D || wxStyleHasBorder(m_windowStyle) ) + { wstyle |= WS_BORDER; } - HWND wx_list = CreateWindowEx(exStyle, "LISTBOX", NULL, + m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "LISTBOX", NULL, wstyle | WS_CHILD, 0, 0, 0, 0, (HWND)parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); - m_hWnd = (WXHWND)wx_list; + wxCHECK_MSG( m_hWnd, FALSE, "Failed to create listbox" ); #if CTL3D if (want3D) { - Ctl3dSubclassCtl(wx_list); + Ctl3dSubclassCtl(hwnd); m_useCtl3D = TRUE; } #endif // Subclass again to catch messages - SubclassWin((WXHWND)wx_list); + SubclassWin(m_hWnd); - uint ui; - for (ui = 0; ui < (uint)n; ui++) { - SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]); + size_t ui; + for (ui = 0; ui < (size_t)n; ui++) { + Append(choices[ui]); } -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { - for (ui = 0; ui < (uint)n; ui++) { + for (ui = 0; ui < (size_t)n; ui++) { // create new item which will process WM_{DRAW|MEASURE}ITEM messages wxOwnerDrawn *pNewItem = CreateItem(ui); pNewItem->SetName(choices[ui]); m_aItems.Add(pNewItem); - ListBox_SetItemData(wx_list, ui, pNewItem); + ListBox_SetItemData(hwnd, ui, pNewItem); } } #endif - if ((m_windowStyle & wxLB_MULTIPLE) == 0) - SendMessage(wx_list, LB_SETCURSEL, 0, 0); + if ( (m_windowStyle & wxLB_MULTIPLE) == 0 ) + SendMessage(hwnd, LB_SETCURSEL, 0, 0); SetFont(* parent->GetFont()); SetSize(x, y, width, height); - ShowWindow(wx_list, SW_SHOW); + Show(TRUE); return TRUE; } wxListBox::~wxListBox(void) { -#if USE_OWNER_DRAWN - uint uiCount = m_aItems.Count(); +#if wxUSE_OWNER_DRAWN + size_t uiCount = m_aItems.Count(); while ( uiCount-- != 0 ) { delete m_aItems[uiCount]; } @@ -266,7 +264,7 @@ wxListBox::~wxListBox(void) void wxListBox::SetupColours(void) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); - SetForegroundColour(GetParent()->GetDefaultForegroundColour()); + SetForegroundColour(GetParent()->GetForegroundColour()); } void wxListBox::SetFirstItem(int N) @@ -294,9 +292,9 @@ void wxListBox::Append(const wxString& item) int index = ListBox_AddString(hwnd, item); m_noItems ++; -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { - wxOwnerDrawn *pNewItem = CreateItem(-1); // dummy argument + wxOwnerDrawn *pNewItem = CreateItem(index); // dummy argument pNewItem->SetName(item); m_aItems.Add(pNewItem); ListBox_SetItemData(hwnd, index, pNewItem); @@ -311,7 +309,7 @@ void wxListBox::Append(const wxString& item, char *Client_data) int index = ListBox_AddString(hwnd, item); m_noItems ++; -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { // client data must be pointer to wxOwnerDrawn, otherwise we would crash // in OnMeasure/OnDraw. @@ -337,17 +335,17 @@ void wxListBox::Set(int n, const wxString *choices, char** clientData) } m_noItems = n; -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { // first delete old items - uint ui = m_aItems.Count(); + size_t ui = m_aItems.Count(); while ( ui-- != 0 ) { delete m_aItems[ui]; } m_aItems.Empty(); // then create new ones - for (ui = 0; ui < (uint)n; ui++) { + for (ui = 0; ui < (size_t)n; ui++) { wxOwnerDrawn *pNewItem = CreateItem(ui); pNewItem->SetName(choices[ui]); m_aItems.Add(pNewItem); @@ -592,12 +590,12 @@ wxListBox::InsertItems(int nItems, const wxString items[], int pos) ListBox_InsertString(hwnd, i + pos, items[i]); m_noItems += nItems; - #if USE_OWNER_DRAWN + #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { for ( i = 0; i < nItems; i++ ) { - wxOwnerDrawn *pNewItem = CreateItem((uint)(pos + i)); + wxOwnerDrawn *pNewItem = CreateItem((size_t)(pos + i)); pNewItem->SetName(items[i]); - m_aItems.Insert(pNewItem, (uint)(pos + i)); + m_aItems.Insert(pNewItem, (size_t)(pos + i)); ListBox_SetItemData(hwnd, i, pNewItem); } } @@ -628,7 +626,7 @@ void wxListBox::SetString(int N, const wxString& s) if (sel >= 0) SetSelection(sel); -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) // update item's text m_aItems[N]->SetName(s); @@ -764,7 +762,7 @@ long wxListBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) return wxControl::MSWWindowProc(nMsg, wParam, lParam); } -#if USE_OWNER_DRAWN +#if wxUSE_OWNER_DRAWN // drawing // ------- @@ -818,4 +816,4 @@ bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) } #endif - // USE_OWNER_DRAWN + // wxUSE_OWNER_DRAWN