X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/39fc096d5a40b85488a43226aa49c887ae86f45f..0cf119954679a06fb9a19ae3445ba4c89c2129a0:/src/msw/wince/choicece.cpp diff --git a/src/msw/wince/choicece.cpp b/src/msw/wince/choicece.cpp index 59971875c4..397ba4ec14 100644 --- a/src/msw/wince/choicece.cpp +++ b/src/msw/wince/choicece.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Name: src/msw/wince/choicece.cpp -// Purpose: wxChoice implementation for Smartphones +// Purpose: wxChoice implementation for smart phones driven by WinCE // Author: Wlodzimierz ABX Skiba // Modified by: // Created: 29.07.2004 @@ -39,7 +39,7 @@ #include "wx/msw/missing.h" #include "wx/msw/winundef.h" -#if wxUSE_CHOICE && defined(__SMARTPHONE__) +#if wxUSE_CHOICE && defined(__SMARTPHONE__) && defined(__WXWINCE__) #if wxUSE_EXTENDED_RTTI // TODO @@ -109,6 +109,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 +165,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 ) { @@ -284,9 +300,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(); @@ -478,7 +521,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 +544,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 ) { @@ -545,4 +588,4 @@ void wxChoice::DoGetPosition(int *x, int *y) const wxConstCast(this, wxChoice)->m_hWnd = hWnd; } -#endif // wxUSE_CHOICE && __SMARTPHONE__ +#endif // wxUSE_CHOICE && __SMARTPHONE__ && __WXWINCE__