]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextformatdlg.cpp
Fix [ 1574240 ] wx.RadioButton doesn't navigate correctly
[wxWidgets.git] / src / richtext / richtextformatdlg.cpp
index 9a7d80afd85d99e4111f19a19fddcb3fd2e7578a..e262d0850abfa2c580b43f0f41362ad28d928814 100644 (file)
@@ -16,7 +16,9 @@
     #pragma hdrstop
 #endif
 
-#include "wx/defs.h"
+#if wxUSE_RICHTEXT
+
+#include "wx/richtext/richtextformatdlg.h"
 
 #ifndef WX_PRECOMP
     #include "wx/listbox.h"
     #include "wx/bitmap.h"
     #include "wx/dcclient.h"
     #include "wx/frame.h"
-    #include "wx/imaglist.h"
     #include "wx/checkbox.h"
     #include "wx/button.h"
 #endif // WX_PRECOMP
 
-#if wxUSE_RICHTEXT
-
 #include "wx/bookctrl.h"
 #include "wx/colordlg.h"
 #include "wx/fontenum.h"
 #include "wx/settings.h"
 #include "wx/module.h"
+#include "wx/imaglist.h"
 
-#include "wx/richtext/richtextformatdlg.h"
 #include "wx/richtext/richtextctrl.h"
 #include "wx/richtext/richtextstyles.h"
 
+#ifdef __WXMAC__
+#include "../../src/richtext/richtextfontpage.cpp"
+#include "../../src/richtext/richtextindentspage.cpp"
+#include "../../src/richtext/richtexttabspage.cpp"
+#include "../../src/richtext/richtextbulletspage.cpp"
+#include "../../src/richtext/richtextstylepage.cpp"
+#else
 #include "richtextfontpage.cpp"
 #include "richtextindentspage.cpp"
 #include "richtexttabspage.cpp"
 #include "richtextbulletspage.cpp"
 #include "richtextstylepage.cpp"
+#endif
 
-#ifdef __WXMAC__
+#if 0 // def __WXMAC__
 #define wxRICHTEXT_USE_TOOLBOOK true
 #else
 #define wxRICHTEXT_USE_TOOLBOOK false
@@ -62,7 +69,7 @@
 IMPLEMENT_CLASS(wxRichTextFormattingDialog, wxPropertySheetDialog)
 
 BEGIN_EVENT_TABLE(wxRichTextFormattingDialog, wxPropertySheetDialog)
-    EVT_NOTEBOOK_PAGE_CHANGED(-1, wxRichTextFormattingDialog::OnTabChanged)
+    EVT_BOOKCTRL_PAGE_CHANGED(wxID_ANY, wxRichTextFormattingDialog::OnTabChanged)
 END_EVENT_TABLE()
 
 wxRichTextFormattingDialogFactory* wxRichTextFormattingDialog::ms_FormattingDialogFactory = NULL;
@@ -90,7 +97,7 @@ bool wxRichTextFormattingDialog::Create(long flags, wxWindow* parent, const wxSt
     GetFormattingDialogFactory()->SetSheetStyle(this);
 
     wxPropertySheetDialog::Create(parent, id, title, pos, sz,
-        style | (int)wxPlatform::IfNot(wxWinCE, resizeBorder)
+        style | (int)wxPlatform::IfNot(wxOS_WINDOWS_CE, resizeBorder)
     );
 
     GetFormattingDialogFactory()->CreateButtons(this);
@@ -168,7 +175,7 @@ bool wxRichTextFormattingDialog::UpdateDisplay()
 
 /// Apply the styles when a different tab is selected, so the previews are
 /// up to date
-void wxRichTextFormattingDialog::OnTabChanged(wxNotebookEvent& event)
+void wxRichTextFormattingDialog::OnTabChanged(wxBookCtrlEvent& event)
 {
     if (GetBookCtrl() != event.GetEventObject())
     {
@@ -193,6 +200,18 @@ void wxRichTextFormattingDialog::OnTabChanged(wxNotebookEvent& event)
     }
 }
 
+/// Respond to help command
+void wxRichTextFormattingDialog::OnHelp(wxCommandEvent& event)
+{
+    int selPage = GetBookCtrl()->GetSelection();
+    if (selPage != wxNOT_FOUND)
+    {
+        int pageId = m_pageIds[selPage];
+        if (!GetFormattingDialogFactory()->ShowHelp(pageId, this))
+            event.Skip();
+    }
+}
+
 void wxRichTextFormattingDialog::SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory)
 {
     if (ms_FormattingDialogFactory)
@@ -212,6 +231,7 @@ bool wxRichTextFormattingDialogFactory::CreatePages(long pages, wxRichTextFormat
 
     int availablePageCount = GetPageIdCount();
     int i;
+    bool selected = false;
     for (i = 0; i < availablePageCount; i ++)
     {
         int pageId = GetPageId(i);
@@ -223,10 +243,14 @@ bool wxRichTextFormattingDialogFactory::CreatePages(long pages, wxRichTextFormat
             if (panel)
             {
                 int imageIndex = GetPageImage(pageId);
-                dialog->GetBookCtrl()->AddPage(panel, title, false, imageIndex);
+                dialog->GetBookCtrl()->AddPage(panel, title, !selected, imageIndex);
+                selected = true;
+                
+                dialog->AddPageId(pageId);
             }
         }
     }
+
     return true;
 }
 
@@ -439,6 +463,7 @@ void wxRichTextColourSwatchCtrl::OnMouseEvent(wxMouseEvent& event)
         wxColourData data;
         data.SetChooseFull(true);
         data.SetColour(m_colour);
+#if wxUSE_COLOURDLG
         wxColourDialog *dialog = new wxColourDialog(parent, &data);
         // Crashes on wxMac (no m_peer)
 #ifndef __WXMAC__
@@ -451,6 +476,7 @@ void wxRichTextColourSwatchCtrl::OnMouseEvent(wxMouseEvent& event)
             SetBackgroundColour(m_colour);
         }
         dialog->Destroy();
+#endif // wxUSE_COLOURDLG
         Refresh();
 
         wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
@@ -576,4 +602,3 @@ wxString wxRichTextFontListBox::CreateHTML(const wxString& facename) const
 
 #endif
     // wxUSE_RICHTEXT
-