X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c140b7e7c9aabb61ab5e6e017cfb768c05373502..05b2a432c6cecd70c825a99ff357ab0cde1877f8:/src/msw/choice.cpp?ds=sidebyside diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index b1809f6c04..af029bf042 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -52,7 +52,7 @@ wxBEGIN_FLAGS( wxChoiceStyle ) wxFLAGS_MEMBER(wxBORDER_RAISED) wxFLAGS_MEMBER(wxBORDER_STATIC) wxFLAGS_MEMBER(wxBORDER_NONE) - + // old style border flags wxFLAGS_MEMBER(wxSIMPLE_BORDER) wxFLAGS_MEMBER(wxSUNKEN_BORDER) @@ -76,26 +76,26 @@ wxEND_FLAGS( wxChoiceStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl,"wx/choice.h") wxBEGIN_PROPERTIES_TABLE(wxChoice) - wxEVENT_PROPERTY( Select , wxEVT_COMMAND_CHOICE_SELECTED , wxCommandEvent ) + 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) wxEND_HANDLERS_TABLE() -wxCONSTRUCTOR_4( wxChoice , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) +wxCONSTRUCTOR_4( wxChoice , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) #else IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) #endif /* - TODO PROPERTIES - selection (long) - content (list) - item + TODO PROPERTIES + selection (long) + content (list) + item */ // ============================================================================ @@ -130,36 +130,12 @@ bool wxChoice::Create(wxWindow *parent, bool wxChoice::CreateAndInit(wxWindow *parent, wxWindowID id, const wxPoint& pos, - const wxSize& sizeOrig, + const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { - // this is a bit hackish but we want to prevent MSWCreateControl() from - // calling SetBestSize() (which it would do if any of the size components - // is not given) because it wouldn't calculate it correctly if we have any - // strings as they're not yet added to the control when it is called - // - // so: if we have any strings, we fudge the size parameter so that - // SetBestSize() is not called by MSWCreateControl() but then we do call it - // manually below - bool autoSize = false; - wxSize size = sizeOrig; - if ( n ) - { - if ( size.x < 0 ) - { - size.x = 1; - autoSize = true; - } - if ( size.y < 0 ) - { - size.y = 1; - autoSize = true; - } - } - // initialize wxControl if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return FALSE; @@ -180,10 +156,7 @@ bool wxChoice::CreateAndInit(wxWindow *parent, } // and now we may finally size the control properly (if needed) - if ( autoSize ) - { - SetBestSize(sizeOrig); - } + SetBestSize(size); return TRUE; } @@ -202,6 +175,22 @@ bool wxChoice::Create(wxWindow *parent, style, validator, name); } +bool wxChoice::MSWShouldPreProcessMessage(WXMSG *pMsg) +{ + MSG *msg = (MSG *) pMsg; + + // don't preprocess "ESC" if combobox is dropped down + if ( msg->message == WM_KEYDOWN && msg->wParam == VK_ESCAPE ) + { + if (::SendMessage(GetHwndOf(this), CB_GETDROPPEDSTATE, 0, 0)) + { + return false; + } + } + + return wxControl::MSWShouldPreProcessMessage(pMsg); +} + WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const { // we never have an external border @@ -468,7 +457,7 @@ void wxChoice::DoGetSize(int *w, int *h) const // 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); + wxControl::DoGetSize(w, h); } void wxChoice::DoSetSize(int x, int y, @@ -497,6 +486,11 @@ void wxChoice::DoSetSize(int x, int y, wxControl::DoSetSize(x, y, width, height, sizeFlags); + // I'm commenting this out since the code appears to make choices + // and comboxes too high when they have associated sizers. I'm sure this + // is not the end of the story, which is why I'm leaving it #if'ed out for + // now. JACS. +#if 0 // if the height specified for the visible part of the control is // different from the current one, we need to change it separately // as it is not affected by normal WM_SETSIZE @@ -509,6 +503,9 @@ void wxChoice::DoSetSize(int x, int y, SendMessage(GetHwnd(), CB_SETITEMHEIGHT, (WPARAM)-1, h + delta); } } +#else + wxUnusedVar(heightOrig); +#endif } wxSize wxChoice::DoGetBestSize() const @@ -532,8 +529,7 @@ wxSize wxChoice::DoGetBestSize() const // the combobox should be slightly larger than the widest string wChoice += 5*GetCharWidth(); - // +5 is magic but seems to work well - return wxSize(wChoice, GetCharHeight() + 5); + return wxSize(wChoice, EDIT_HEIGHT_FROM_CHAR_HEIGHT(GetCharHeight())); } WXLRESULT wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)