From e1f36ff823aa21414b756cbe451853d1f1338fd9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Jul 1999 21:51:58 +0000 Subject: [PATCH 1/1] wxButton::GetDefaultSize() added for MSW and documented git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2980 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/button.tex | 8 ++++++++ include/wx/msw/button.h | 2 ++ src/msw/button.cpp | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/docs/latex/wx/button.tex b/docs/latex/wx/button.tex index be87dacb31..7bac1a1118 100644 --- a/docs/latex/wx/button.tex +++ b/docs/latex/wx/button.tex @@ -99,6 +99,14 @@ The button's label. \helpref{wxButton::SetLabel}{wxbuttonsetlabel} +\membersection{wxButton::GetDefaultSize}\label{wxbuttongetdefaultsize} + +\func{wxSize}{GetDefaultSize}{\void} + +Returns the default size for the buttons. It is advised to make all the dialog +buttons of the same size and this function allows to retrieve the (platform and +current font dependent size) which should be the best suited for this. + \membersection{wxButton::SetDefault}\label{wxbuttonsetdefault} \func{void}{SetDefault}{\void} diff --git a/include/wx/msw/button.h b/include/wx/msw/button.h index 4d78ab2d40..6888ee443a 100644 --- a/include/wx/msw/button.h +++ b/include/wx/msw/button.h @@ -49,6 +49,8 @@ public: virtual void SetDefault(); + static wxSize GetDefaultSize(); + // implementation from now on virtual void Command(wxCommandEvent& event); virtual bool MSWCommand(WXUINT param, WXWORD id); diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 1a34a34d0e..5138afaf6d 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -131,6 +131,20 @@ wxSize wxButton::DoGetBestSize() return wxSize(wBtn, hBtn); } +/* static */ +wxSize wxButton::GetDefaultSize() +{ + // the base unit is the height of the system GUI font + int wChar, hChar; + wxGetCharSize(0, &wChar, &hChar, NULL); + + // the button height is proportional to the height of the font used + int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar); + + // and the width/height ration is 75/23 + return wxSize((75 * hBtn) / 23, hBtn); +} + // ---------------------------------------------------------------------------- // set this button as the default one in its panel // ---------------------------------------------------------------------------- -- 2.47.2