///////////////////////////////////////////////////////////////////////////////
// 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
#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
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
// ----------------------------------------------------------------------------
WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
wxSize sizeText(size), sizeBtn(size);
- sizeBtn.x = GetBestSpinerSize(IsVertical(style)).x;
-
- sizeBtn.x;
+ sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x;
if ( sizeText.x == wxDefaultCoord )
{
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();
int wxChoice::DoAppend(const wxString& item)
{
- int n = (int)SendMessage(GetBuddyHwnd(), LB_ADDSTRING, 0, (LPARAM)item.c_str());
+ int n = (int)::SendMessage(GetBuddyHwnd(), LB_ADDSTRING, 0, (LPARAM)item.c_str());
if ( n == LB_ERR )
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into choice"));
wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
- int n = (int)SendMessage(GetBuddyHwnd(), LB_INSERTSTRING, pos, (LPARAM)item.c_str());
+ int n = (int)::SendMessage(GetBuddyHwnd(), LB_INSERTSTRING, pos, (LPARAM)item.c_str());
if ( n == LB_ERR )
{
wxLogLastError(wxT("SendMessage(LB_INSERTSTRING)"));
delete GetClientObject(n);
}
- SendMessage(GetBuddyHwnd(), LB_DELETESTRING, n, 0);
+ ::SendMessage(GetBuddyHwnd(), LB_DELETESTRING, n, 0);
}
void wxChoice::Clear()
{
Free();
- SendMessage(GetBuddyHwnd(), LB_RESETCONTENT, 0, 0);
+ ::SendMessage(GetBuddyHwnd(), LB_RESETCONTENT, 0, 0);
}
void wxChoice::Free()
int wxChoice::GetSelection() const
{
- return (int)SendMessage(GetBuddyHwnd(), LB_GETCURSEL, 0, 0);
+ return (int)::SendMessage(GetBuddyHwnd(), LB_GETCURSEL, 0, 0);
}
void wxChoice::SetSelection(int n)
{
- SendMessage(GetBuddyHwnd(), LB_SETCURSEL, n, 0);
+ ::SendMessage(GetBuddyHwnd(), LB_SETCURSEL, n, 0);
}
// ----------------------------------------------------------------------------
int wxChoice::GetCount() const
{
- return (int)SendMessage(GetBuddyHwnd(), LB_GETCOUNT, 0, 0);
+ return (int)::SendMessage(GetBuddyHwnd(), LB_GETCOUNT, 0, 0);
}
int wxChoice::FindString(const wxString& s) const
{
- int pos = (int)SendMessage(GetBuddyHwnd(), LB_FINDSTRINGEXACT,
+ int pos = (int)::SendMessage(GetBuddyHwnd(), LB_FINDSTRINGEXACT,
(WPARAM)-1, (LPARAM)s.c_str());
return pos == LB_ERR ? wxNOT_FOUND : pos;
void* wxChoice::DoGetItemClientData( int n ) const
{
- LPARAM rc = SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
+ LPARAM rc = ::SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
if ( rc == LB_ERR )
{
wxLogLastError(wxT("LB_GETITEMDATA"));
wxSize wxChoice::DoGetBestSize() const
{
- wxSize sizeBtn = GetBestSpinerSize(IsVertical(GetWindowStyle()));
+ wxSize sizeBtn = GetBestSpinnerSize(IsVertical(GetWindowStyle()));
sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
int y;
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 )
{
wxConstCast(this, wxChoice)->m_hWnd = hWnd;
}
-#endif // wxUSE_CHOICE && __SMARTPHONE__
+#endif // wxUSE_CHOICE && __SMARTPHONE__ && __WXWINCE__