+ m_windowId = vId;
+ lStyle = WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON;
+
+ //
+ // OS/2 PM does not have Right/Left/Top/Bottom styles.
+ // We will have to define an additional style when we implement notebooks
+ // for a notebook page button
+ //
+ if (m_windowStyle & wxCLIP_SIBLINGS )
+ lStyle |= WS_CLIPSIBLINGS;
+ //
+ // If the parent is a scrolled window the controls must
+ // have this style or they will overlap the scrollbars
+ //
+ if (pParent)
+ if (pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) ||
+ pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)))
+ lStyle |= WS_CLIPSIBLINGS;
+
+ m_hWnd = (WXHWND)::WinCreateWindow( GetHwndOf(pParent) // Parent handle
+ ,WC_BUTTON // A Button class window
+ ,(PSZ)rsLabel.c_str() // Button text
+ ,lStyle // Button style
+ ,0, 0, 0, 0 // Location and size
+ ,GetHwndOf(pParent) // Owner handle
+ ,HWND_TOP // Top of Z-Order
+ ,vId // Identifier
+ ,NULL // No control data
+ ,NULL // No Presentation parameters
+ );
+ if (m_hWnd == 0)
+ {
+ return FALSE;
+ }
+
+ //
+ // Subclass again for purposes of dialog editing mode
+ //
+ SubclassWin(m_hWnd);
+ SetFont(pParent->GetFont());
+ SetSize( rPos.x
+ ,rPos.y
+ ,rSize.x
+ ,rSize.y
+ );
+ return TRUE;
+} // end of wxButton::Create
+
+wxButton::~wxButton()
+{
+ wxPanel* pPanel = wxDynamicCast(GetParent(), wxPanel);
+
+ if (pPanel)
+ {
+ if (pPanel->GetDefaultItem() == this)
+ {
+ //
+ // Don't leave the panel with invalid default item
+ //
+ pPanel->SetDefaultItem(NULL);
+ }
+ }
+} // end of wxButton::~wxButton
+
+// ----------------------------------------------------------------------------
+// size management including autosizing
+// ----------------------------------------------------------------------------
+
+wxSize wxButton::DoGetBestSize() const
+{
+ wxString rsLabel = wxGetWindowText(GetHWND());
+ int nWidthButton;
+ int nWidthChar;
+ int nHeightChar;
+
+ GetTextExtent( rsLabel
+ ,&nWidthButton
+ ,NULL
+ );
+
+ wxGetCharSize( GetHWND()
+ ,&nWidthChar
+ ,&nHeightChar
+ ,(wxFont*)&GetFont()
+ );
+
+ //
+ // Add a margin - the button is wider than just its label
+ //
+ nWidthButton += 3 * nWidthChar;
+
+ //
+ // The button height is proportional to the height of the font used
+ //
+ int nHeightButton = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(nHeightChar);