]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/choice.cpp
don't inherit back- and foreground colour
[wxWidgets.git] / src / msw / choice.cpp
index 0afb34b36d0b53cd76b301571bd883a55e146e12..1d1cd38aac66068d66f3727886577eb47f2c6eb8 100644 (file)
@@ -78,10 +78,10 @@ IMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl,"wx/choice.h")
 wxBEGIN_PROPERTIES_TABLE(wxChoice)
        wxEVENT_PROPERTY( Select , wxEVT_COMMAND_CHOICE_SELECTED , wxCommandEvent )
 
-    wxPROPERTY( Font , wxFont , SetFont , GetFont  , , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
+    wxPROPERTY( Font , wxFont , SetFont , GetFont  , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
     wxPROPERTY_COLLECTION( Choices , wxArrayString , wxString , AppendString , GetStrings , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
-       wxPROPERTY( Selection ,int, SetSelection, GetSelection, , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
-    wxPROPERTY_FLAGS( WindowStyle , wxChoiceStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+       wxPROPERTY( Selection ,int, SetSelection, GetSelection, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
+    wxPROPERTY_FLAGS( WindowStyle , wxChoiceStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
 wxEND_PROPERTIES_TABLE()
 
 wxBEGIN_HANDLERS_TABLE(wxChoice)
@@ -233,7 +233,7 @@ wxChoice::~wxChoice()
 
 int wxChoice::DoAppend(const wxString& item)
 {
-    int n = (int)SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LONG)item.c_str());
+    int n = (int)SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LPARAM)item.c_str());
     if ( n == CB_ERR )
     {
         wxLogLastError(wxT("SendMessage(CB_ADDSTRING)"));
@@ -253,7 +253,7 @@ int wxChoice::DoInsert(const wxString& item, int pos)
     wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
     wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
 
-    int n = (int)SendMessage(GetHwnd(), CB_INSERTSTRING, pos, (LONG)item.c_str());
+    int n = (int)SendMessage(GetHwnd(), CB_INSERTSTRING, pos, (LPARAM)item.c_str());
     if ( n == CB_ERR )
     {
         wxLogLastError(wxT("SendMessage(CB_INSERTSTRING)"));
@@ -438,15 +438,10 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const
 // wxMSW specific helpers
 // ----------------------------------------------------------------------------
 
-int wxChoice::GetVisibleHeight() const
-{
-    return ::SendMessage(GetHwnd(), CB_GETITEMHEIGHT, (WPARAM)-1, 0);
-}
-
 void wxChoice::UpdateVisibleHeight()
 {
     // be careful to not change the width here
-    DoSetSize(-1, -1, -1, GetVisibleHeight(), wxSIZE_USE_EXISTING);
+    DoSetSize(-1, -1, -1, GetSize().y, wxSIZE_USE_EXISTING);
 }
 
 void wxChoice::DoMoveWindow(int x, int y, int width, int height)
@@ -469,13 +464,11 @@ void wxChoice::DoMoveWindow(int x, int y, int width, int height)
 
 void wxChoice::DoGetSize(int *w, int *h) const
 {
+    // this is weird: sometimes, the height returned by Windows is clearly the
+    // total height of the control including the drop down list -- but only
+    // sometimes, and normally it isn't... I have no idea about what to do with
+    // this
     wxControl::DoGetSize(w, h);
-
-    // we need to return only the height of the visible part, not the entire
-    // height in the Windows sense which includes the height of the drop down
-    // list as well
-    if ( h )
-        *h = GetVisibleHeight();
 }
 
 void wxChoice::DoSetSize(int x, int y,
@@ -509,10 +502,11 @@ void wxChoice::DoSetSize(int x, int y,
     // as it is not affected by normal WM_SETSIZE
     if ( height != -1 )
     {
-        const int hVisibleCurrent = GetVisibleHeight();
-        if ( hVisibleCurrent != heightOrig )
+        const int delta = heightOrig - GetSize().y;
+        if ( delta )
         {
-            SendMessage(GetHwnd(), CB_SETITEMHEIGHT, (WPARAM)-1, heightOrig);
+            int h = ::SendMessage(GetHwnd(), CB_GETITEMHEIGHT, (WPARAM)-1, 0);
+            SendMessage(GetHwnd(), CB_SETITEMHEIGHT, (WPARAM)-1, h + delta);
         }
     }
 }
@@ -538,10 +532,10 @@ wxSize wxChoice::DoGetBestSize() const
     // the combobox should be slightly larger than the widest string
     wChoice += 5*GetCharWidth();
 
-    return wxSize(wChoice, GetVisibleHeight());
+    return wxSize(wChoice, EDIT_HEIGHT_FROM_CHAR_HEIGHT(GetCharHeight()));
 }
 
-long wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+WXLRESULT wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 {
     if ( nMsg == WM_LBUTTONUP )
     {