From 7ef8bfc4c75374ffd4de538cdeaa0f81b69bf61f Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Tue, 10 Jul 2001 13:44:04 +0000
Subject: [PATCH] added wxBU_EXACTFIT style

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10942 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/button.tex |  1 +
 include/wx/button.h      | 17 +++++++++++++++++
 include/wx/defs.h        | 10 ----------
 src/univ/button.cpp      |  9 ++++++---
 4 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/docs/latex/wx/button.tex b/docs/latex/wx/button.tex
index 966fa06461..043d6d9d5e 100644
--- a/docs/latex/wx/button.tex
+++ b/docs/latex/wx/button.tex
@@ -24,6 +24,7 @@ almost any other window.
 \twocolitem{\windowstyle{wxBU\_TOP}}{Aligns the label to the top of the button. WIN32 only.}
 \twocolitem{\windowstyle{wxBU\_RIGHT}}{Right-justifies the bitmap label. WIN32 only.}
 \twocolitem{\windowstyle{wxBU\_BOTTOM}}{Aligns the label to the bottom of the button. WIN32 only.}
+\twocolitem{\windowstyle{wxBU\_EXACTFIT}}{Creates the button as small as possible instead of making it of the standard size (which is the default behaviour ).}
 \end{twocollist}
 
 See also \helpref{window styles overview}{windowstyles}.
diff --git a/include/wx/button.h b/include/wx/button.h
index b9b1f0388b..3018394065 100644
--- a/include/wx/button.h
+++ b/include/wx/button.h
@@ -14,6 +14,23 @@
 
 #if wxUSE_BUTTON
 
+// ----------------------------------------------------------------------------
+// wxButton flags
+// ----------------------------------------------------------------------------
+
+// all these flags are obsolete
+#define wxBU_NOAUTODRAW      0x0000
+#define wxBU_AUTODRAW        0x0004
+#define wxBU_LEFT            0x0040
+#define wxBU_TOP             0x0080
+#define wxBU_RIGHT           0x0100
+#define wxBU_BOTTOM          0x0200
+
+// by default, the buttons will be created with some (system dependent)
+// minimal size to make them look nicer, giving this style will make them as
+// small as possible
+#define wxBU_EXACTFIT        0x0001
+
 #include "wx/control.h"
 
 class WXDLLEXPORT wxBitmap;
diff --git a/include/wx/defs.h b/include/wx/defs.h
index ccb3af3dbf..f0cc3bc94d 100644
--- a/include/wx/defs.h
+++ b/include/wx/defs.h
@@ -1195,16 +1195,6 @@ enum wxBorder
 #define wxSB_HORIZONTAL      wxHORIZONTAL
 #define wxSB_VERTICAL        wxVERTICAL
 
-/*
- * wxButton flags (Win32 only)
- */
-#define wxBU_AUTODRAW        0x0004
-#define wxBU_NOAUTODRAW      0x0000
-#define wxBU_LEFT            0x0040
-#define wxBU_TOP             0x0080
-#define wxBU_RIGHT           0x0100
-#define wxBU_BOTTOM          0x0200
-
 /*
  * wxTreeCtrl flags
  */
diff --git a/src/univ/button.cpp b/src/univ/button.cpp
index 95d4ce4aee..a6438e0d51 100644
--- a/src/univ/button.cpp
+++ b/src/univ/button.cpp
@@ -136,9 +136,12 @@ wxSize wxButton::DoGetBestClientSize() const
 
     // for compatibility with other ports, the buttons default size is never
     // less than the standard one
-    wxSize szDef = GetDefaultSize();
-    if ( width < szDef.x )
-        width = szDef.x;
+    if ( !(GetWindowStyle() & wxBU_EXACTFIT) )
+    {
+        wxSize szDef = GetDefaultSize();
+        if ( width < szDef.x )
+            width = szDef.x;
+    }
 
     return wxSize(width, height);
 }
-- 
2.50.0

