X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/456bc6d9b83882a3b0e919fc733898d9d331ecd6..4b2424bcadbc87babd3367d243b957e49333eeae:/src/msw/button.cpp?ds=sidebyside diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 24d5340b6e..5cb83273d7 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -68,66 +68,47 @@ bool wxButton::Create(wxWindow *parent, const wxValidator& validator, const wxString& name) { - if ( !CreateBase(parent, id, pos, size, style, validator, name) ) + if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return FALSE; - parent->AddChild((wxButton *)this); + return MSWCreateControl(_T("BUTTON"), label, pos, size, style); +} - m_backgroundColour = parent->GetBackgroundColour(); - m_foregroundColour = parent->GetForegroundColour(); +wxButton::~wxButton() +{ +} - long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD /* | WS_CLIPSIBLINGS */ ; +// ---------------------------------------------------------------------------- +// flags +// ---------------------------------------------------------------------------- - if ( m_windowStyle & wxCLIP_SIBLINGS ) - msStyle |= WS_CLIPSIBLINGS; +WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const +{ + // buttons never have an external border, they draw their own one + WXDWORD msStyle = wxControl::MSWGetStyle + ( + (style & ~wxBORDER_MASK) | wxBORDER_NONE, exstyle + ); + + // we must use WS_CLIPSIBLINGS with the buttons or they would draw over + // each other in any resizeable dialog which has more than one button in + // the bottom + msStyle |= WS_CLIPSIBLINGS; #ifdef __WIN32__ - if(m_windowStyle & wxBU_LEFT) + // don't use "else if" here: weird as it is, but you may combine wxBU_LEFT + // and wxBU_RIGHT to get BS_CENTER! + if ( style & wxBU_LEFT ) msStyle |= BS_LEFT; - if(m_windowStyle & wxBU_RIGHT) + if ( style & wxBU_RIGHT ) msStyle |= BS_RIGHT; - if(m_windowStyle & wxBU_TOP) + if ( style & wxBU_TOP ) msStyle |= BS_TOP; - if(m_windowStyle & wxBU_BOTTOM) + if ( style & wxBU_BOTTOM ) msStyle |= BS_BOTTOM; -#endif - - m_hWnd = (WXHWND)CreateWindowEx - ( - MakeExtendedStyle(m_windowStyle), - wxT("BUTTON"), - label, - msStyle, - 0, 0, 0, 0, - GetWinHwnd(parent), - (HMENU)m_windowId, - wxGetInstance(), - NULL - ); - - if (m_hWnd == 0) - { - wxString msg; -#ifdef __WIN16__ - msg.Printf(wxT("CreateWindowEx failed")); -#else - msg.Printf(wxT("CreateWindowEx failed with error number %ld"), (long) GetLastError()); -#endif - wxFAIL_MSG(msg); - } - - // Subclass again for purposes of dialog editing mode - SubclassWin(m_hWnd); - - SetFont(parent->GetFont()); - - SetSize(pos.x, pos.y, size.x, size.y); - - return TRUE; -} +#endif // __WIN32__ -wxButton::~wxButton() -{ + return msStyle; } // ---------------------------------------------------------------------------- @@ -164,7 +145,7 @@ wxSize wxButtonBase::GetDefaultSize() if ( s_sizeBtn.x == 0 ) { wxScreenDC dc; - dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); // the size of a standard button in the dialog units is 50x14, // translate this to pixels