#if wxUSE_CHOICE && defined(__SMARTPHONE__) && defined(__WXWINCE__)
+#include "wx/choice.h"
+
#ifndef WX_PRECOMP
- #include "wx/choice.h"
- #include <commctrl.h>
- #include "wx/msw/missing.h"
- #include "wx/msw/winundef.h"
+ #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
#endif
#include "wx/spinbutt.h" // for wxSpinnerBestSize
sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
}
- SetBestSize(size);
+ SetInitialSize(size);
(void)::ShowWindow(GetBuddyHwnd(), SW_SHOW);
wxChoice::~wxChoice()
{
- Free();
+ Clear();
}
// ----------------------------------------------------------------------------
// adding/deleting items to/from the list
// ----------------------------------------------------------------------------
-int wxChoice::DoAppend(const wxString& item)
+int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items,
+ unsigned int pos,
+ void **clientData,
+ wxClientDataType type)
{
- int n = (int)::SendMessage(GetBuddyHwnd(), LB_ADDSTRING, 0, (LPARAM)item.c_str());
+ MSWAllocStorage(items, LB_INITSTORAGE);
- if ( n == LB_ERR )
- {
- wxLogLastError(wxT("SendMessage(LB_ADDSTRING)"));
- }
+ const bool append = pos == GetCount();
+ const unsigned msg = append ? LB_ADDSTRING : LB_INSERTSTRING;
+ if ( append )
+ pos = 0;
- return n;
-}
-
-int wxChoice::DoInsert(const wxString& item, int pos)
-{
- wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into choice"));
- wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
+ int n = wxNOT_FOUND;
- int n = (int)::SendMessage(GetBuddyHwnd(), LB_INSERTSTRING, pos, (LPARAM)item.c_str());
- if ( n == LB_ERR )
+ const unsigned int numItems = items.GetCount();
+ for ( unsigned int i = 0; i < numItems; ++i )
{
- wxLogLastError(wxT("SendMessage(LB_INSERTSTRING)"));
+ n = MSWInsertOrAppendItem(pos, items[i], msg);
+ if ( !append )
+ pos++;
+
+ AssignNewItemClientData(n, clientData, i, type);
}
return n;
}
-void wxChoice::Delete(int n)
+void wxChoice::DoDeleteOneItem(unsigned int n)
{
wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::Delete") );
- if ( HasClientObjectData() )
- {
- delete GetClientObject(n);
- }
-
::SendMessage(GetBuddyHwnd(), LB_DELETESTRING, n, 0);
}
-void wxChoice::Clear()
+void wxChoice::DoClear()
{
- Free();
-
::SendMessage(GetBuddyHwnd(), LB_RESETCONTENT, 0, 0);
}
-void wxChoice::Free()
-{
- if ( HasClientObjectData() )
- {
- size_t count = GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- delete GetClientObject(n);
- }
- }
-}
-
// ----------------------------------------------------------------------------
// selection
// ----------------------------------------------------------------------------
// string list functions
// ----------------------------------------------------------------------------
-size_t wxChoice::GetCount() const
+unsigned int wxChoice::GetCount() const
{
- return (size_t)::SendMessage(GetBuddyHwnd(), LB_GETCOUNT, 0, 0);
+ return (unsigned int)::SendMessage(GetBuddyHwnd(), LB_GETCOUNT, 0, 0);
}
int wxChoice::FindString(const wxString& s, bool bCase) const
return pos == LB_ERR ? wxNOT_FOUND : pos;
}
-void wxChoice::SetString(int n, const wxString& s)
+void wxChoice::SetString(unsigned int n, const wxString& s)
{
wxCHECK_RET( IsValid(n),
wxT("invalid item index in wxChoice::SetString") );
//else: it's already NULL by default
}
-wxString wxChoice::GetString(int n) const
+wxString wxChoice::GetString(unsigned int n) const
{
int len = (int)::SendMessage(GetBuddyHwnd(), LB_GETTEXTLEN, n, 0);
// client data
// ----------------------------------------------------------------------------
-void wxChoice::DoSetItemClientData( int n, void* clientData )
+void wxChoice::DoSetItemClientData(unsigned int n, void* clientData)
{
if ( ::SendMessage(GetHwnd(), LB_SETITEMDATA,
n, (LPARAM)clientData) == LB_ERR )
}
}
-void* wxChoice::DoGetItemClientData( int n ) const
+void* wxChoice::DoGetItemClientData(unsigned int n) const
{
LPARAM rc = ::SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
if ( rc == LB_ERR )
return (void *)rc;
}
-void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
-{
- DoSetItemClientData(n, clientData);
-}
-
-wxClientData* wxChoice::DoGetItemClientObject( int n ) const
-{
- return (wxClientData *)DoGetItemClientData(n);
-}
-
// ----------------------------------------------------------------------------
// size calculations
// ----------------------------------------------------------------------------