From 57d7f9888e18d350fb023fdccd39e0ab7a3bb8dd Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sat, 14 Apr 2007 13:17:06 +0000
Subject: [PATCH] added wxAPPLY and wxCLOSE flags to
 CreateStdDialogButtonSizer() (Marcin Wojdyr)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45457 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/dialog.tex   |  6 ++++--
 docs/latex/wx/stdbtnsz.tex |  1 +
 include/wx/defs.h          |  2 ++
 include/wx/sizer.h         |  6 +++---
 src/common/dlgcmn.cpp      | 12 ++++++++++++
 src/common/sizer.cpp       |  9 ++++++---
 6 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/docs/latex/wx/dialog.tex b/docs/latex/wx/dialog.tex
index e8edbf6e08..78ac30db30 100644
--- a/docs/latex/wx/dialog.tex
+++ b/docs/latex/wx/dialog.tex
@@ -203,7 +203,8 @@ for details.
 \func{wxSizer*}{CreateButtonSizer}{\param{long}{ flags}}
 
 Creates a sizer with standard buttons. {\it flags} is a bit list
-of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxHELP, wxNO\_DEFAULT.
+of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, wxCLOSE, 
+wxHELP, wxNO\_DEFAULT.
 
 The sizer lays out the buttons in a manner appropriate to the platform.
 
@@ -231,7 +232,8 @@ if no buttons were created.
 \func{wxStdDialogButtonSizer*}{CreateStdDialogButtonSizer}{\param{long}{ flags}}
 
 Creates a \helpref{wxStdDialogButtonSizer}{wxstddialogbuttonsizer} with standard buttons. {\it flags} is a bit list
-of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxHELP, wxNO\_DEFAULT.
+of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, wxCLOSE,
+wxHELP, wxNO\_DEFAULT.
 
 The sizer lays out the buttons in a manner appropriate to the platform.
 
diff --git a/docs/latex/wx/stdbtnsz.tex b/docs/latex/wx/stdbtnsz.tex
index 065acd3485..be6fcd54e8 100644
--- a/docs/latex/wx/stdbtnsz.tex
+++ b/docs/latex/wx/stdbtnsz.tex
@@ -46,6 +46,7 @@ Adds a button to the wxStdDialogButtonSizer. The button must have one of the fol
 \item wxID\_YES
 \item wxID\_SAVE
 \item wxID\_APPLY
+\item wxID\_CLOSE
 \item wxID\_NO
 \item wxID\_CANCEL
 \item wxID\_HELP
diff --git a/include/wx/defs.h b/include/wx/defs.h
index 5920407601..849e74390e 100644
--- a/include/wx/defs.h
+++ b/include/wx/defs.h
@@ -1653,6 +1653,8 @@ enum wxBorder
 #define wxNO                    0x00000008
 #define wxYES_NO                (wxYES | wxNO)
 #define wxCANCEL                0x00000010
+#define wxAPPLY                 0x00000020
+#define wxCLOSE                 0x00000040
 
 #define wxYES_DEFAULT           0x00000000  /*  has no effect (default) */
 #define wxNO_DEFAULT            0x00000080
diff --git a/include/wx/sizer.h b/include/wx/sizer.h
index 8aa759e376..ce2341c36f 100644
--- a/include/wx/sizer.h
+++ b/include/wx/sizer.h
@@ -862,10 +862,10 @@ public:
 
 protected:
     wxButton *m_buttonAffirmative;  // wxID_OK, wxID_YES, wxID_SAVE go here
-    wxButton *m_buttonApply;
+    wxButton *m_buttonApply;        // wxID_APPLY
     wxButton *m_buttonNegative;     // wxID_NO
-    wxButton *m_buttonCancel;
-    wxButton *m_buttonHelp;
+    wxButton *m_buttonCancel;       // wxID_CANCEL, wxID_CLOSE
+    wxButton *m_buttonHelp;         // wxID_HELP, wxID_CONTEXT_HELP
 
 private:
     DECLARE_CLASS(wxStdDialogButtonSizer)
diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp
index 67b0c89f10..be6afab98e 100644
--- a/src/common/dlgcmn.cpp
+++ b/src/common/dlgcmn.cpp
@@ -227,6 +227,18 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )
         sizer->AddButton(no);
     }
 
+    if (flags & wxAPPLY)
+    {
+        wxButton *apply = new wxButton(this, wxID_APPLY);
+        sizer->AddButton(apply);
+    }
+
+    if (flags & wxCLOSE)
+    {
+        wxButton *close = new wxButton(this, wxID_CLOSE);
+        sizer->AddButton(close);
+    }
+
     if (flags & wxHELP)
     {
         wxButton *help = new wxButton(this, wxID_HELP);
diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp
index b4ae33b5a7..5f3c324720 100644
--- a/src/common/sizer.cpp
+++ b/src/common/sizer.cpp
@@ -1962,6 +1962,7 @@ void wxStdDialogButtonSizer::AddButton(wxButton *mybutton)
             m_buttonNegative = mybutton;
             break;
         case wxID_CANCEL:
+        case wxID_CLOSE:
             m_buttonCancel = mybutton;
             break;
         case wxID_HELP:
@@ -2040,15 +2041,17 @@ void wxStdDialogButtonSizer::Realize()
             Add((wxWindow*)m_buttonNegative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3);
         }
 
+        // according to HIG, in explicit apply windows the order is: 
+        // [ Help                     Apply   Cancel   OK ]
+        if (m_buttonApply)
+            Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3);
+
         if (m_buttonCancel){
             Add((wxWindow*)m_buttonCancel, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3);
             // Cancel or help should be default
             // m_buttonCancel->SetDefaultButton();
         }
 
-        if (m_buttonApply)
-            Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3);
-
         if (m_buttonAffirmative)
             Add((wxWindow*)m_buttonAffirmative, 0, wxALIGN_CENTRE | wxLEFT, 6);
 #elif defined(__WXMSW__)
-- 
2.47.2