X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8300f815fa5f0e9486d14b057ce8fdda5785549b..caf6e6dee8d177844bb633786ec8c05eba6972bc:/src/msw/wince/choicece.cpp diff --git a/src/msw/wince/choicece.cpp b/src/msw/wince/choicece.cpp index 5eafda649c..fa7426f1fe 100644 --- a/src/msw/wince/choicece.cpp +++ b/src/msw/wince/choicece.cpp @@ -9,7 +9,6 @@ // License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// - // ============================================================================ // declarations // ============================================================================ @@ -18,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "choicece.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -109,6 +104,22 @@ LRESULT APIENTRY _EXPORT wxBuddyChoiceWndProc(HWND hwnd, hwnd, message, wParam, lParam); } +wxChoice *wxChoice::GetChoiceForListBox(WXHWND hwndBuddy) +{ + wxChoice *choice = (wxChoice *)wxGetWindowUserData((HWND)hwndBuddy); + + int i = ms_allChoiceSpins.Index(choice); + + if ( i == wxNOT_FOUND ) + return NULL; + + // sanity check + wxASSERT_MSG( choice->m_hwndBuddy == hwndBuddy, + _T("wxChoice has incorrect buddy HWND!") ); + + return choice; +} + // ---------------------------------------------------------------------------- // creation // ---------------------------------------------------------------------------- @@ -149,7 +160,7 @@ bool wxChoice::CreateAndInit(wxWindow *parent, WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; wxSize sizeText(size), sizeBtn(size); - sizeBtn.x = GetBestSpinerSize(IsVertical(style)).x; + sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x; if ( sizeText.x == wxDefaultCoord ) { @@ -212,7 +223,7 @@ bool wxChoice::CreateAndInit(wxWindow *parent, if ( style & wxSP_WRAP ) spiner_style |= UDS_WRAP; - if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, _T(""), 0) ) + if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, wxEmptyString, 0) ) return false; // subclass the text ctrl to be able to intercept some events @@ -284,9 +295,36 @@ WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const if ( style & wxCB_SORT ) msStyle |= LBS_SORT; + msStyle |= LBS_NOTIFY; + return msStyle; } +bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) +{ + if ( param != LBN_SELCHANGE) + { + // "selection changed" is the only event we're after + return false; + } + + int n = GetSelection(); + if (n > -1) + { + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId); + event.SetInt(n); + event.SetEventObject(this); + event.SetString(GetStringSelection()); + if ( HasClientObjectData() ) + event.SetClientObject( GetClientObject(n) ); + else if ( HasClientUntypedData() ) + event.SetClientData( GetClientData(n) ); + ProcessCommand(event); + } + + return true; +} + wxChoice::~wxChoice() { Free(); @@ -376,8 +414,12 @@ int wxChoice::GetCount() const return (int)::SendMessage(GetBuddyHwnd(), LB_GETCOUNT, 0, 0); } -int wxChoice::FindString(const wxString& s) const +int wxChoice::FindString(const wxString& s, bool bCase) const { + // back to base class search for not native search type + if (bCase) + return wxItemContainerImmutable::FindString( s, bCase ); + int pos = (int)::SendMessage(GetBuddyHwnd(), LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)s.c_str()); @@ -478,7 +520,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const wxSize wxChoice::DoGetBestSize() const { - wxSize sizeBtn = GetBestSpinerSize(IsVertical(GetWindowStyle())); + wxSize sizeBtn = GetBestSpinnerSize(IsVertical(GetWindowStyle())); sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN; int y; @@ -501,7 +543,7 @@ wxSize wxChoice::DoGetBestSize() const void wxChoice::DoMoveWindow(int x, int y, int width, int height) { - int widthBtn = GetBestSpinerSize(IsVertical(GetWindowStyle())).x; + int widthBtn = GetBestSpinnerSize(IsVertical(GetWindowStyle())).x; int widthText = width - widthBtn - MARGIN_BETWEEN; if ( widthText <= 0 ) {