X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..a2b0fa12c9cb341acce346c0e7794e099363cd01:/src/msw/button.cpp diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 13f671d53b..80e8318503 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -22,6 +22,7 @@ #ifndef WX_PRECOMP #include "wx/button.h" +#include "wx/brush.h" #endif #include "wx/msw/private.h" @@ -30,13 +31,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl) #endif -#define BUTTON_HEIGHT_FACTOR (EDIT_CONTROL_FACTOR * 1.1) +#define BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cy) (11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)/10) // Buttons bool wxButton::MSWCommand(WXUINT param, WXWORD id) { - if (param == BN_CLICKED) + if (param == BN_CLICKED || (param == 1)) // 1 for accelerator { wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, id); event.SetEventObject(this); @@ -56,8 +57,8 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, SetValidator(validator); parent->AddChild((wxButton *)this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; m_windowStyle = (long&)style; @@ -71,31 +72,30 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, else m_windowId = id; - DWORD exStyle = MakeExtendedStyle(m_windowStyle); - HWND wx_button = - CreateWindowEx(exStyle, "BUTTON", label, BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, - 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, - wxGetInstance(), NULL); - -#if CTL3D -// if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS)) -// Ctl3dSubclassCtl(wx_button); -#endif - - m_hWnd = (WXHWND)wx_button; + m_hWnd = (WXHWND)CreateWindowEx + ( + MakeExtendedStyle(m_windowStyle), + "BUTTON", + label, + WS_VISIBLE | WS_TABSTOP | WS_CHILD, + 0, 0, 0, 0, + GetWinHwnd(parent), + (HMENU)m_windowId, + wxGetInstance(), + NULL + ); // Subclass again for purposes of dialog editing mode - SubclassWin((WXHWND)wx_button); + SubclassWin(m_hWnd); - SetFont(* parent->GetFont()); + SetFont(parent->GetFont()); SetSize(x, y, width, height); - ShowWindow(wx_button, SW_SHOW); return TRUE; } -void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags) +void wxButton::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int currentX, currentY; GetPosition(¤tX, ¤tY); @@ -106,6 +106,8 @@ void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags) if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) y1 = currentY; + AdjustForParentClientOrigin(x1, y1, sizeFlags); + int actualWidth = width; int actualHeight = height; int ww, hh; @@ -115,7 +117,8 @@ void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags) int cyf; char buf[300]; GetWindowText((HWND) GetHWND(), buf, 300); - GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL,GetFont()); + GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL, + & this->GetFont()); // If we're prepared to use the existing width, then... if (width == -1 && ((sizeFlags & wxSIZE_AUTO_WIDTH) != wxSIZE_AUTO_WIDTH)) @@ -124,7 +127,7 @@ void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags) { int cx; int cy; - wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); + wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont()); actualWidth = (int)(current_width + 3*cx) ; } @@ -133,7 +136,7 @@ void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags) actualHeight = hh; else if (height == -1) { - actualHeight = (int)(cyf*BUTTON_HEIGHT_FACTOR) ; + actualHeight = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cyf); } MoveWindow((HWND) GetHWND(), x1, y1, actualWidth, actualHeight, TRUE); @@ -147,8 +150,10 @@ void wxButton::SetDefault(void) if (parent) { - SendMessage((HWND) parent->GetHWND(), DM_SETDEFID, m_windowId, 0L); + SendMessage((HWND)parent->GetHWND(), DM_SETDEFID, m_windowId, 0L); } + + SendMessage((HWND)GetHWND(), BM_SETSTYLE, BS_DEFPUSHBUTTON, 1L); } wxString wxButton::GetLabel(void) const