The wxRTC formatting dialog now retains custom colours set within the colour dialog, and they can be accessed by the application.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2014-08-28 08:28:08 +00:00
parent 1cef1d91e5
commit f65b2f589f
3 changed files with 47 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#include "wx/propdlg.h"
#include "wx/bookctrl.h"
#include "wx/withimages.h"
#include "wx/colourdata.h"
#if wxUSE_HTML
#include "wx/htmllbox.h"
@ -241,14 +242,20 @@ public:
/// Find a page by class
wxWindow* FindPage(wxClassInfo* info) const;
/// Whether to restore the last-selected page
static bool GetRestoreLastPage() { return sm_restoreLastPage; }
/// Whether to restore the last-selected page.
static bool GetRestoreLastPage() { return sm_restoreLastPage; }
static void SetRestoreLastPage(bool b) { sm_restoreLastPage = b; }
/// The page identifier of the last page selected (not the control id)
static int GetLastPage() { return sm_lastPage; }
static void SetLastPage(int lastPage) { sm_lastPage = lastPage; }
/// Sets the custom colour data for use by the colour dialog.
static void SetColourData(const wxColourData& colourData) { sm_colourData = colourData; }
/// Returns the custom colour data for use by the colour dialog.
static wxColourData GetColourData() { return sm_colourData; }
protected:
wxRichTextAttr m_attributes;
@ -258,6 +265,7 @@ protected:
wxArrayInt m_pageIds; // mapping of book control indexes to page ids
int m_options; // UI options
bool m_ignoreUpdates;
static wxColourData sm_colourData;
static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory;
static bool sm_showToolTips;

View File

@ -275,5 +275,35 @@ public:
Updates the display.
*/
virtual bool UpdateDisplay();
/**
Returns @true if the dialog will restore the last-selected page.
*/
static bool GetRestoreLastPage();
/**
Pass @true if the dialog should restore the last-selected page.
*/
static void SetRestoreLastPage(bool b);
/**
Returns the page identifier of the last page selected (not the control id).
*/
static int GetLastPage();
/**
Sets the page identifier of the last page selected (not the control id).
*/
static void SetLastPage(int lastPage);
/**
Sets the custom colour data for use by the colour dialog.
*/
static void SetColourData(const wxColourData& colourData);
/**
Returns the custom colour data for use by the colour dialog.
*/
static wxColourData GetColourData();
};

View File

@ -92,6 +92,7 @@ END_EVENT_TABLE()
IMPLEMENT_HELP_PROVISION(wxRichTextFormattingDialog)
wxRichTextFormattingDialogFactory* wxRichTextFormattingDialog::ms_FormattingDialogFactory = NULL;
wxColourData wxRichTextFormattingDialog::sm_colourData;
void wxRichTextFormattingDialog::Init()
{
@ -762,7 +763,11 @@ void wxRichTextColourSwatchCtrl::OnMouseEvent(wxMouseEvent& event)
while (parent != NULL && !wxDynamicCast(parent, wxDialog) && !wxDynamicCast(parent, wxFrame))
parent = parent->GetParent();
wxRichTextFormattingDialog* dlg = wxDynamicCast(parent, wxRichTextFormattingDialog);
wxColourData data;
if (dlg)
data = dlg->GetColourData();
data.SetChooseFull(true);
data.SetColour(m_colour);
#if wxUSE_COLOURDLG
@ -774,6 +779,8 @@ void wxRichTextColourSwatchCtrl::OnMouseEvent(wxMouseEvent& event)
if (dialog->ShowModal() == wxID_OK)
{
wxColourData retData = dialog->GetColourData();
if (dlg)
dlg->SetColourData(retData);
m_colour = retData.GetColour();
SetBackgroundColour(m_colour);
}