]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/wince/choicece.cpp
Erase toolbar background even if it doesn't contain any controls/spaces.
[wxWidgets.git] / src / msw / wince / choicece.cpp
index caef2a0388fe1e5f8209192a34b0100324ea9a5b..a1b548e125fae8b00131bcdcef10c24d2968effd 100644 (file)
 #include "wx/choice.h"
 
 #ifndef WX_PRECOMP
+    #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
 #endif
 
-// include <commctrl.h> "properly"
-#include "wx/msw/wrapcctl.h"
-
 #include "wx/spinbutt.h" // for wxSpinnerBestSize
 
 #if wxUSE_EXTENDED_RTTI
@@ -115,7 +113,7 @@ wxChoice *wxChoice::GetChoiceForListBox(WXHWND hwndBuddy)
 
     // sanity check
     wxASSERT_MSG( choice->m_hwndBuddy == hwndBuddy,
-                  _T("wxChoice has incorrect buddy HWND!") );
+                  wxT("wxChoice has incorrect buddy HWND!") );
 
     return choice;
 }
@@ -171,7 +169,7 @@ bool wxChoice::CreateAndInit(wxWindow *parent,
     sizeText.x -= sizeBtn.x + MARGIN_BETWEEN;
     if ( sizeText.x <= 0 )
     {
-        wxLogDebug(_T("not enough space for wxSpinCtrl!"));
+        wxLogDebug(wxT("not enough space for wxSpinCtrl!"));
     }
 
     wxPoint posBtn(pos);
@@ -188,7 +186,7 @@ bool wxChoice::CreateAndInit(wxWindow *parent,
     m_hwndBuddy = (WXHWND)::CreateWindowEx
                     (
                      exStyle,                // sunken border
-                     _T("LISTBOX"),          // window class
+                     wxT("LISTBOX"),         // window class
                      NULL,                   // no window title
                      msStyle,                // style (will be shown later)
                      pos.x, pos.y,           // position
@@ -246,7 +244,7 @@ bool wxChoice::CreateAndInit(wxWindow *parent,
         sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
     }
 
-    SetBestSize(size);
+    SetInitialSize(size);
 
     (void)::ShowWindow(GetBuddyHwnd(), SW_SHOW);
 
@@ -327,70 +325,52 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
 
 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, unsigned 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(unsigned 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() )
-    {
-        unsigned int count = GetCount();
-        for ( unsigned int n = 0; n < count; n++ )
-        {
-            delete GetClientObject(n);
-        }
-    }
-}
-
 // ----------------------------------------------------------------------------
 // selection
 // ----------------------------------------------------------------------------
@@ -504,16 +484,6 @@ void* wxChoice::DoGetItemClientData(unsigned int n) const
     return (void *)rc;
 }
 
-void wxChoice::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
-{
-    DoSetItemClientData(n, clientData);
-}
-
-wxClientData* wxChoice::DoGetItemClientObject(unsigned int n) const
-{
-    return (wxClientData *)DoGetItemClientData(n);
-}
-
 // ----------------------------------------------------------------------------
 // size calculations
 // ----------------------------------------------------------------------------
@@ -547,7 +517,7 @@ void wxChoice::DoMoveWindow(int x, int y, int width, int height)
     int widthText = width - widthBtn - MARGIN_BETWEEN;
     if ( widthText <= 0 )
     {
-        wxLogDebug(_T("not enough space for wxSpinCtrl!"));
+        wxLogDebug(wxT("not enough space for wxSpinCtrl!"));
     }
 
     if ( !::MoveWindow(GetBuddyHwnd(), x, y, widthText, height, TRUE) )