]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dlgcmn.cpp
Added Set/GetQuickBestSize
[wxWidgets.git] / src / common / dlgcmn.cpp
index f03af0e60134e57be6e51787cbceffe1a19ba72f..5a1693a6a9f12ad33a681168b134f9d9d235b772 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        common/dlgcmn.cpp
+// Name:        src/common/dlgcmn.cpp
 // Purpose:     common (to all ports) wxDialog functions
 // Author:      Vadim Zeitlin
 // Modified by:
 // Purpose:     common (to all ports) wxDialog functions
 // Author:      Vadim Zeitlin
 // Modified by:
     #include "wx/settings.h"
     #include "wx/stattext.h"
     #include "wx/sizer.h"
     #include "wx/settings.h"
     #include "wx/stattext.h"
     #include "wx/sizer.h"
-    #include "wx/button.h"
     #include "wx/containr.h"
 #endif
 
     #include "wx/containr.h"
 #endif
 
+#include "wx/statline.h"
+#include "wx/sysopt.h"
+
 #if wxUSE_STATTEXT
 
 // ----------------------------------------------------------------------------
 #if wxUSE_STATTEXT
 
 // ----------------------------------------------------------------------------
@@ -108,7 +110,8 @@ void wxDialogBase::Init()
 {
     m_returnCode = 0;
     m_affirmativeId = wxID_OK;
 {
     m_returnCode = 0;
     m_affirmativeId = wxID_OK;
-    
+    m_escapeId = wxID_ANY;
+
     // the dialogs have this flag on by default to prevent the events from the
     // dialog controls from reaching the parent frame which is usually
     // undesirable and can lead to unexpected and hard to find bugs
     // the dialogs have this flag on by default to prevent the events from the
     // dialog controls from reaching the parent frame which is usually
     // undesirable and can lead to unexpected and hard to find bugs
@@ -258,13 +261,15 @@ private:
     wxString m_text;
 };
 
     wxString m_text;
 };
 
+// NB: don't "factor out" the scope operator, SGI MIPSpro 7.3 (but not 7.4)
+//     gets confused if it doesn't immediately follow the class name
 void
 #if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
 void
 #if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
-wxStaticText
+wxStaticText::
 #else
 #else
-wxStaticTextBase
+wxStaticTextBase::
 #endif
 #endif
-::Wrap(int width)
+Wrap(int width)
 {
     wxLabelWrapper wrapper;
     wrapper.WrapLabel(this, width);
 {
     wxLabelWrapper wrapper;
     wrapper.WrapLabel(this, width);
@@ -272,11 +277,12 @@ wxStaticTextBase
 
 #endif // wxUSE_STATTEXT
 
 
 #endif // wxUSE_STATTEXT
 
-#if wxUSE_BUTTON
-
-wxSizer *wxDialogBase::CreateButtonSizer( long flags )
+wxSizer *wxDialogBase::CreateButtonSizer( long flags, bool separated, wxCoord distance )
 {
 #ifdef __SMARTPHONE__
 {
 #ifdef __SMARTPHONE__
+    wxUnusedVar(separated);
+    wxUnusedVar(distance);
+
     wxDialog* dialog = (wxDialog*) this;
     if (flags & wxOK){
         dialog->SetLeftMenu(wxID_OK);
     wxDialog* dialog = (wxDialog*) this;
     if (flags & wxOK){
         dialog->SetLeftMenu(wxID_OK);
@@ -295,14 +301,64 @@ wxSizer *wxDialogBase::CreateButtonSizer( long flags )
     }
     wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
     return sizer;
     }
     wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
     return sizer;
-#else
-    return CreateStdDialogButtonSizer( flags );
-#endif
+
+#else // !__SMARTPHONE__
+
+#ifdef __POCKETPC__
+    // PocketPC guidelines recommend for Ok/Cancel dialogs to use
+    // OK button located inside caption bar and implement Cancel functionality
+    // through Undo outside dialog. As native behaviour this will be default
+    // here but can be easily replaced with real wxButtons
+    // with "wince.dialog.real-ok-cancel" option set to 1
+    if ( ((flags & ~(wxCANCEL|wxNO_DEFAULT))== wxOK) &&
+         (wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"))==0)
+       )
+    {
+        wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
+        return sizer;
+    }
+#endif // __POCKETPC__
+
+#if wxUSE_BUTTON
+
+    wxSizer* buttonSizer = CreateStdDialogButtonSizer( flags );
+
+    // Mac Human Interface Guidelines recommend not to use static lines as grouping elements
+#if wxUSE_STATLINE && !defined(__WXMAC__)
+    if(!separated)
+        return buttonSizer;
+
+    wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+    topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxBOTTOM, distance );
+    topsizer->Add( buttonSizer, 0, wxEXPAND );
+    return topsizer;
+
+#else // !wxUSE_STATLINE
+
+    wxUnusedVar(separated);
+    wxUnusedVar(distance);
+    return buttonSizer;
+
+#endif // wxUSE_STATLINE/!wxUSE_STATLINE
+
+#else // !wxUSE_BUTTON
+
+    wxUnusedVar(separated);
+    wxUnusedVar(distance);
+    wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
+    return sizer;
+
+#endif // wxUSE_BUTTON/!wxUSE_BUTTON
+
+#endif // __SMARTPHONE__/!__SMARTPHONE__
 }
 
 }
 
+#if wxUSE_BUTTON
+
 wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )
 {
     wxStdDialogButtonSizer *sizer = new wxStdDialogButtonSizer();
 wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )
 {
     wxStdDialogButtonSizer *sizer = new wxStdDialogButtonSizer();
+
     wxButton *ok = NULL;
     wxButton *yes = NULL;
     wxButton *no = NULL;
     wxButton *ok = NULL;
     wxButton *yes = NULL;
     wxButton *no = NULL;
@@ -364,5 +420,4 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )
     return sizer;
 }
 
     return sizer;
 }
 
-
 #endif // wxUSE_BUTTON
 #endif // wxUSE_BUTTON