X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d76fbd5a1ae1e8cab3c4a49c5e93cc9952a5aab..d2e66707deb10dea6f92e3e4092f8a43ef942a5d:/src/richtext/richtextfontpage.cpp?ds=sidebyside diff --git a/src/richtext/richtextfontpage.cpp b/src/richtext/richtextfontpage.cpp index 87a3fb7830..d8bfa690bb 100644 --- a/src/richtext/richtextfontpage.cpp +++ b/src/richtext/richtextfontpage.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/richtext/richeditfontpage.cpp +// Name: src/richtext/richtextfontpage.cpp // Purpose: Font page for wxRichTextFormattingDialog // Author: Julian Smart // Modified by: @@ -15,15 +15,16 @@ * wxRichTextFontPage type definition */ -IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxPanel ) +IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxRichTextDialogPage ) /*! * wxRichTextFontPage event table definition */ -BEGIN_EVENT_TABLE( wxRichTextFontPage, wxPanel ) +BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage ) EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX, wxRichTextFontPage::OnFaceListBoxSelected ) EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL, wxRichTextFontPage::OnColourClicked ) + EVT_BUTTON( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxRichTextFontPage::OnColourClicked ) ////@begin wxRichTextFontPage event table entries EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated ) @@ -38,6 +39,10 @@ BEGIN_EVENT_TABLE( wxRichTextFontPage, wxPanel ) EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxRichTextFontPage::OnUnderliningCtrlSelected ) + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected ) + + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, wxRichTextFontPage::OnUnderliningCtrlSelected ) + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, wxRichTextFontPage::OnStrikethroughctrlClick ) EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick ) @@ -50,6 +55,7 @@ BEGIN_EVENT_TABLE( wxRichTextFontPage, wxPanel ) END_EVENT_TABLE() +IMPLEMENT_HELP_PROVISION(wxRichTextFontPage) /*! * wxRichTextFontPage constructors */ @@ -73,6 +79,7 @@ void wxRichTextFontPage::Init() { m_dontUpdate = false; m_colourPresent = false; + m_bgColourPresent = false; ////@begin wxRichTextFontPage member initialisation m_faceTextCtrl = NULL; @@ -82,7 +89,10 @@ void wxRichTextFontPage::Init() m_styleCtrl = NULL; m_weightCtrl = NULL; m_underliningCtrl = NULL; + m_textColourLabel = NULL; m_colourCtrl = NULL; + m_bgColourLabel = NULL; + m_bgColourCtrl = NULL; m_strikethroughCtrl = NULL; m_capitalsCtrl = NULL; m_superscriptCtrl = NULL; @@ -98,7 +108,7 @@ void wxRichTextFontPage::Init() bool wxRichTextFontPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) { ////@begin wxRichTextFontPage creation - wxPanel::Create( parent, id, pos, size, style ); + wxRichTextDialogPage::Create( parent, id, pos, size, style ); CreateControls(); if (GetSizer()) @@ -117,10 +127,10 @@ bool wxRichTextFontPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& void wxRichTextFontPage::CreateControls() { ////@begin wxRichTextFontPage content construction - wxRichTextFontPage* itemPanel1 = this; + wxRichTextFontPage* itemRichTextDialogPage1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); - itemPanel1->SetSizer(itemBoxSizer2); + itemRichTextDialogPage1->SetSizer(itemBoxSizer2); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5); @@ -131,16 +141,16 @@ void wxRichTextFontPage::CreateControls() wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); itemBoxSizer4->Add(itemBoxSizer5, 1, wxGROW, 5); - wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* itemStaticText6 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - m_faceTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); + m_faceTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_faceTextCtrl->SetHelpText(_("Type a font name.")); if (wxRichTextFontPage::ShowToolTips()) m_faceTextCtrl->SetToolTip(_("Type a font name.")); itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); - m_faceListBox = new wxRichTextFontListBox( itemPanel1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 100), 0 ); + m_faceListBox = new wxRichTextFontListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 100), 0 ); m_faceListBox->SetHelpText(_("Lists the available fonts.")); if (wxRichTextFontPage::ShowToolTips()) m_faceListBox->SetToolTip(_("Lists the available fonts.")); @@ -149,17 +159,17 @@ void wxRichTextFontPage::CreateControls() wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); itemBoxSizer4->Add(itemBoxSizer9, 0, wxGROW, 5); - wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* itemStaticText10 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer9->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - m_sizeTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, _T(""), wxDefaultPosition, wxSize(50, -1), 0 ); + m_sizeTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_sizeTextCtrl->SetHelpText(_("Type a size in points.")); if (wxRichTextFontPage::ShowToolTips()) m_sizeTextCtrl->SetToolTip(_("Type a size in points.")); itemBoxSizer9->Add(m_sizeTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); wxArrayString m_sizeListBoxStrings; - m_sizeListBox = new wxListBox( itemPanel1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE ); + m_sizeListBox = new wxListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE ); m_sizeListBox->SetHelpText(_("Lists font sizes in points.")); if (wxRichTextFontPage::ShowToolTips()) m_sizeListBox->SetToolTip(_("Lists font sizes in points.")); @@ -169,90 +179,106 @@ void wxRichTextFontPage::CreateControls() itemBoxSizer3->Add(itemBoxSizer13, 0, wxGROW, 5); wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer13->Add(itemBoxSizer14, 1, wxGROW, 5); + itemBoxSizer13->Add(itemBoxSizer14, 0, wxGROW, 5); - wxStaticText* itemStaticText15 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* itemStaticText15 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); wxArrayString m_styleCtrlStrings; - m_styleCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_STYLECTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_styleCtrlStrings, wxCB_READONLY ); + m_styleCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STYLECTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_styleCtrlStrings, wxCB_READONLY ); m_styleCtrl->SetHelpText(_("Select regular or italic style.")); if (wxRichTextFontPage::ShowToolTips()) m_styleCtrl->SetToolTip(_("Select regular or italic style.")); itemBoxSizer14->Add(m_styleCtrl, 0, wxGROW|wxALL, 5); wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer13->Add(itemBoxSizer17, 1, wxGROW, 5); + itemBoxSizer13->Add(itemBoxSizer17, 0, wxGROW, 5); - wxStaticText* itemStaticText18 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* itemStaticText18 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); wxArrayString m_weightCtrlStrings; - m_weightCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_weightCtrlStrings, wxCB_READONLY ); + m_weightCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_weightCtrlStrings, wxCB_READONLY ); m_weightCtrl->SetHelpText(_("Select regular or bold.")); if (wxRichTextFontPage::ShowToolTips()) m_weightCtrl->SetToolTip(_("Select regular or bold.")); itemBoxSizer17->Add(m_weightCtrl, 0, wxGROW|wxALL, 5); wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer13->Add(itemBoxSizer20, 1, wxGROW, 5); + itemBoxSizer13->Add(itemBoxSizer20, 0, wxGROW, 5); - wxStaticText* itemStaticText21 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* itemStaticText21 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer20->Add(itemStaticText21, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); wxArrayString m_underliningCtrlStrings; - m_underliningCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_underliningCtrlStrings, wxCB_READONLY ); + m_underliningCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_underliningCtrlStrings, wxCB_READONLY ); m_underliningCtrl->SetHelpText(_("Select underlining or no underlining.")); if (wxRichTextFontPage::ShowToolTips()) m_underliningCtrl->SetToolTip(_("Select underlining or no underlining.")); itemBoxSizer20->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5); - wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer13->Add(itemBoxSizer23, 0, wxGROW, 5); + itemBoxSizer13->Add(0, 0, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5); + + wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer13->Add(itemBoxSizer24, 0, wxGROW, 5); - wxStaticText* itemStaticText24 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer23->Add(itemStaticText24, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textColourLabel->SetValue(false); + itemBoxSizer24->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); - m_colourCtrl = new wxRichTextColourSwatchCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), wxSIMPLE_BORDER ); + m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); m_colourCtrl->SetHelpText(_("Click to change the text colour.")); if (wxRichTextFontPage::ShowToolTips()) m_colourCtrl->SetToolTip(_("Click to change the text colour.")); - itemBoxSizer23->Add(m_colourCtrl, 0, wxALIGN_LEFT|wxALL, 5); + itemBoxSizer24->Add(m_colourCtrl, 0, wxGROW|wxALL, 5); - wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer3->Add(itemBoxSizer26, 0, wxGROW, 5); + wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer13->Add(itemBoxSizer27, 0, wxGROW, 5); + + m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_bgColourLabel->SetValue(false); + itemBoxSizer27->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); + + m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); + m_bgColourCtrl->SetHelpText(_("Click to change the text background colour.")); + if (wxRichTextFontPage::ShowToolTips()) + m_bgColourCtrl->SetToolTip(_("Click to change the text background colour.")); + itemBoxSizer27->Add(m_bgColourCtrl, 0, wxGROW|wxALL, 5); - m_strikethroughCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); + wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer3->Add(itemBoxSizer30, 0, wxGROW, 5); + + m_strikethroughCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); m_strikethroughCtrl->SetValue(false); m_strikethroughCtrl->SetHelpText(_("Check to show a line through the text.")); if (wxRichTextFontPage::ShowToolTips()) m_strikethroughCtrl->SetToolTip(_("Check to show a line through the text.")); - itemBoxSizer26->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemBoxSizer30->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - m_capitalsCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); + m_capitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); m_capitalsCtrl->SetValue(false); m_capitalsCtrl->SetHelpText(_("Check to show the text in capitals.")); if (wxRichTextFontPage::ShowToolTips()) m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals.")); - itemBoxSizer26->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemBoxSizer30->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - m_superscriptCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); + m_superscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); m_superscriptCtrl->SetValue(false); m_superscriptCtrl->SetHelpText(_("Check to show the text in superscript.")); if (wxRichTextFontPage::ShowToolTips()) m_superscriptCtrl->SetToolTip(_("Check to show the text in superscript.")); - itemBoxSizer26->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemBoxSizer30->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - m_subscriptCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); + m_subscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); m_subscriptCtrl->SetValue(false); m_subscriptCtrl->SetHelpText(_("Check to show the text in subscript.")); if (wxRichTextFontPage::ShowToolTips()) m_subscriptCtrl->SetToolTip(_("Check to show the text in subscript.")); - itemBoxSizer26->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemBoxSizer30->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); - m_previewCtrl = new wxRichTextFontPreviewCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 60), 0 ); + m_previewCtrl = new wxRichTextFontPreviewCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 60), 0 ); m_previewCtrl->SetHelpText(_("Shows a preview of the font settings.")); if (wxRichTextFontPage::ShowToolTips()) m_previewCtrl->SetToolTip(_("Shows a preview of the font settings.")); @@ -262,12 +288,15 @@ void wxRichTextFontPage::CreateControls() m_faceListBox->UpdateFonts(); + m_styleCtrl->Append(_("(none)")); m_styleCtrl->Append(_("Regular")); m_styleCtrl->Append(_("Italic")); + m_weightCtrl->Append(_("(none)")); m_weightCtrl->Append(_("Regular")); m_weightCtrl->Append(_("Bold")); + m_underliningCtrl->Append(_("(none)")); m_underliningCtrl->Append(_("Not underlined")); m_underliningCtrl->Append(_("Underlined")); @@ -287,15 +316,12 @@ bool wxRichTextFontPage::TransferDataFromWindow() { wxPanel::TransferDataFromWindow(); - wxTextAttr* attr = GetAttributes(); + wxRichTextAttr* attr = GetAttributes(); - if (m_faceListBox->GetSelection() != wxNOT_FOUND) + if (!m_faceTextCtrl->GetValue().IsEmpty()) { - wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection()); - if (!faceName.IsEmpty()) - { - attr->SetFontFaceName(faceName); - } + wxString faceName = m_faceTextCtrl->GetValue(); + attr->SetFontFaceName(faceName); } else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_FACE)); @@ -312,10 +338,10 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE)); - if (m_styleCtrl->GetSelection() != wxNOT_FOUND) + if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) { wxFontStyle style; - if (m_styleCtrl->GetStringSelection() == _("Italic")) + if (m_styleCtrl->GetSelection() == 2) style = wxFONTSTYLE_ITALIC; else style = wxFONTSTYLE_NORMAL; @@ -325,10 +351,10 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC)); - if (m_weightCtrl->GetSelection() != wxNOT_FOUND) + if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0) { wxFontWeight weight; - if (m_weightCtrl->GetStringSelection() == _("Bold")) + if (m_weightCtrl->GetSelection() == 2) weight = wxFONTWEIGHT_BOLD; else weight = wxFONTWEIGHT_NORMAL; @@ -338,10 +364,10 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT)); - if (m_underliningCtrl->GetSelection() != wxNOT_FOUND) + if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0) { bool underlined; - if (m_underliningCtrl->GetStringSelection() == _("Underlined")) + if (m_underliningCtrl->GetSelection() == 2) underlined = true; else underlined = false; @@ -351,13 +377,20 @@ bool wxRichTextFontPage::TransferDataFromWindow() else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE)); - if (m_colourPresent) + if (m_textColourLabel->GetValue()) { - attr->SetTextColour(m_colourCtrl->GetBackgroundColour()); + attr->SetTextColour(m_colourCtrl->GetColour()); } else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR)); + if (m_bgColourLabel->GetValue()) + { + attr->SetBackgroundColour(m_bgColourCtrl->GetColour()); + } + else + attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_BACKGROUND_COLOUR)); + if (m_strikethroughCtrl->Get3StateValue() != wxCHK_UNDETERMINED) { attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH); @@ -405,7 +438,7 @@ bool wxRichTextFontPage::TransferDataToWindow() wxPanel::TransferDataToWindow(); m_dontUpdate = true; - wxTextAttr* attr = GetAttributes(); + wxRichTextAttr* attr = GetAttributes(); if (attr->HasFontFaceName()) { @@ -434,44 +467,62 @@ bool wxRichTextFontPage::TransferDataToWindow() if (attr->HasFontWeight()) { if (attr->GetFontWeight() == wxBOLD) - m_weightCtrl->SetSelection(1); + m_weightCtrl->SetSelection(2); else - m_weightCtrl->SetSelection(0); + m_weightCtrl->SetSelection(1); } else { - m_weightCtrl->SetSelection(wxNOT_FOUND); + m_weightCtrl->SetSelection(0); } if (attr->HasFontItalic()) { if (attr->GetFontStyle() == wxITALIC) - m_styleCtrl->SetSelection(1); + m_styleCtrl->SetSelection(2); else - m_styleCtrl->SetSelection(0); + m_styleCtrl->SetSelection(1); } else { - m_styleCtrl->SetSelection(wxNOT_FOUND); + m_styleCtrl->SetSelection(0); } if (attr->HasFontUnderlined()) { if (attr->GetFontUnderlined()) - m_underliningCtrl->SetSelection(1); + m_underliningCtrl->SetSelection(2); else - m_underliningCtrl->SetSelection(0); + m_underliningCtrl->SetSelection(1); } else { - m_underliningCtrl->SetSelection(wxNOT_FOUND); + m_underliningCtrl->SetSelection(0); } if (attr->HasTextColour()) { m_colourCtrl->SetColour(attr->GetTextColour()); + m_textColourLabel->SetValue(true); m_colourPresent = true; } + else + { + m_colourCtrl->SetColour(*wxBLACK); + m_textColourLabel->SetValue(false); + } + + if (attr->HasBackgroundColour()) + { + m_bgColourCtrl->SetColour(attr->GetBackgroundColour()); + m_bgColourLabel->SetValue(true); + m_bgColourPresent = true; + } + else + { + m_bgColourCtrl->SetColour(*wxWHITE); + m_bgColourLabel->SetValue(false); + } if (attr->HasTextEffects()) { @@ -534,7 +585,7 @@ bool wxRichTextFontPage::TransferDataToWindow() return true; } -wxTextAttr* wxRichTextFontPage::GetAttributes() +wxRichTextAttr* wxRichTextFontPage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); } @@ -542,15 +593,37 @@ wxTextAttr* wxRichTextFontPage::GetAttributes() /// Updates the font preview void wxRichTextFontPage::UpdatePreview() { - wxFont font(*wxNORMAL_FONT); + wxRichTextAttr attr; + + if (m_textColourLabel->GetValue()) + m_previewCtrl->SetForegroundColour(m_colourCtrl->GetColour()); + else + { + m_previewCtrl->SetForegroundColour(*wxBLACK); + if (!(m_colourCtrl->GetColour() == *wxBLACK)) + { + m_colourCtrl->SetColour(*wxBLACK); + m_colourCtrl->Refresh(); + } + } - if (m_colourPresent) - m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour()); + if (m_bgColourLabel->GetValue()) + m_previewCtrl->SetBackgroundColour(m_bgColourCtrl->GetColour()); + else + { + m_previewCtrl->SetBackgroundColour(*wxWHITE); + + if (!(m_bgColourCtrl->GetColour() == *wxWHITE)) + { + m_bgColourCtrl->SetColour(*wxWHITE); + m_bgColourCtrl->Refresh(); + } + } if (m_faceListBox->GetSelection() != wxNOT_FOUND) { wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection()); - font.SetFaceName(faceName); + attr.SetFontFaceName(faceName); } wxString strSize = m_sizeTextCtrl->GetValue(); @@ -558,40 +631,40 @@ void wxRichTextFontPage::UpdatePreview() { int sz = wxAtoi(strSize); if (sz > 0) - font.SetPointSize(sz); + attr.SetFontSize(sz); } - if (m_styleCtrl->GetSelection() != wxNOT_FOUND) + if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) { - int style; - if (m_styleCtrl->GetStringSelection() == _("Italic")) - style = wxITALIC; + wxFontStyle style; + if (m_styleCtrl->GetSelection() == 2) + style = wxFONTSTYLE_ITALIC; else - style = wxNORMAL; + style = wxFONTSTYLE_NORMAL; - font.SetStyle(style); + attr.SetFontStyle(style); } - if (m_weightCtrl->GetSelection() != wxNOT_FOUND) + if (m_weightCtrl->GetSelection() != wxNOT_FOUND && m_weightCtrl->GetSelection() != 0) { - int weight; - if (m_weightCtrl->GetStringSelection() == _("Bold")) - weight = wxBOLD; + wxFontWeight weight; + if (m_weightCtrl->GetSelection() == 2) + weight = wxFONTWEIGHT_BOLD; else - weight = wxNORMAL; + weight = wxFONTWEIGHT_NORMAL; - font.SetWeight(weight); + attr.SetFontWeight(weight); } - if (m_underliningCtrl->GetSelection() != wxNOT_FOUND) + if (m_underliningCtrl->GetSelection() != wxNOT_FOUND && m_underliningCtrl->GetSelection() != 0) { bool underlined; - if (m_underliningCtrl->GetStringSelection() == _("Underlined")) + if (m_underliningCtrl->GetSelection() == 2) underlined = true; else underlined = false; - font.SetUnderlined(underlined); + attr.SetFontUnderlined(underlined); } int textEffects = 0; @@ -611,6 +684,7 @@ void wxRichTextFontPage::UpdatePreview() else if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) textEffects |= wxTEXT_ATTR_EFFECT_SUBSCRIPT; + wxFont font = attr.GetFont(); m_previewCtrl->SetFont(font); m_previewCtrl->SetTextEffects(textEffects); m_previewCtrl->Refresh(); @@ -708,11 +782,15 @@ void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event ) { + bool oldDontUpdate = m_dontUpdate; m_dontUpdate = true; m_sizeTextCtrl->SetValue(event.GetString()); - m_dontUpdate = false; + m_dontUpdate = oldDontUpdate; + + if (m_dontUpdate) + return; UpdatePreview(); } @@ -723,11 +801,15 @@ void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event ) void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) ) { + bool oldDontUpdate = m_dontUpdate; m_dontUpdate = true; m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection())); - m_dontUpdate = false; + m_dontUpdate = oldDontUpdate; + + if (m_dontUpdate) + return; UpdatePreview(); } @@ -738,6 +820,9 @@ void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -748,6 +833,9 @@ void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) ) void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -758,12 +846,31 @@ void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(eve void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } -void wxRichTextFontPage::OnColourClicked( wxCommandEvent& WXUNUSED(event) ) +void wxRichTextFontPage::OnColourClicked( wxCommandEvent& event ) { - m_colourPresent = true; + if (event.GetId() == m_colourCtrl->GetId()) + m_colourPresent = true; + else if (event.GetId() == m_bgColourCtrl->GetId()) + m_bgColourPresent = true; + + m_dontUpdate = true; + + if (event.GetId() == m_colourCtrl->GetId()) + { + m_textColourLabel->SetValue(true); + } + else if (event.GetId() == m_bgColourCtrl->GetId()) + { + m_bgColourLabel->SetValue(true); + } + + m_dontUpdate = false; UpdatePreview(); } @@ -773,6 +880,9 @@ void wxRichTextFontPage::OnColourClicked( wxCommandEvent& WXUNUSED(event) ) void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -782,6 +892,9 @@ void wxRichTextFontPage::OnStrikethroughctrlClick( wxCommandEvent& WXUNUSED(even void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + UpdatePreview(); } @@ -791,6 +904,9 @@ void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) ) void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); @@ -803,6 +919,9 @@ void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXU void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) ) { + if (m_dontUpdate) + return; + if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED) m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );