From 8ae6cfb696ca8b55a1bb96ec996c224df9238a7c Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Sun, 7 Nov 2004 05:38:02 +0000 Subject: [PATCH] Added checking of EnableEffects flag and not allowing changes to color or underlining if it is not set, consistent with MSW (GTK2 native control doesn't offer underlining or color, so flag is essentially always disabled on GTK2) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/fontdlgg.cpp | 85 +++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/src/generic/fontdlgg.cpp b/src/generic/fontdlgg.cpp index 1766bf81be..fc558e2131 100644 --- a/src/generic/fontdlgg.cpp +++ b/src/generic/fontdlgg.cpp @@ -301,14 +301,17 @@ void wxGenericFontDialog::CreateWidgets() wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL); itemGridSizer4->Add(itemBoxSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5); - wxStaticText* itemStaticText15 = new wxStaticText( this, wxID_STATIC, _("C&olour:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - wxChoice* itemChoice16 = new wxChoice( this, wxID_FONT_COLOUR, wxDefaultPosition, wxDefaultSize, NUM_COLS, wxColourDialogNames, 0 ); - itemChoice16->SetHelpText(_("The font colour.")); - if (ShowToolTips()) - itemChoice16->SetToolTip(_("The font colour.")); - itemBoxSizer14->Add(itemChoice16, 0, wxALIGN_LEFT|wxALL, 5); + if (m_fontData.GetEnableEffects()) + { + wxStaticText* itemStaticText15 = new wxStaticText( this, wxID_STATIC, _("C&olour:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + + wxChoice* itemChoice16 = new wxChoice( this, wxID_FONT_COLOUR, wxDefaultPosition, wxDefaultSize, NUM_COLS, wxColourDialogNames, 0 ); + itemChoice16->SetHelpText(_("The font colour.")); + if (ShowToolTips()) + itemChoice16->SetToolTip(_("The font colour.")); + itemBoxSizer14->Add(itemChoice16, 0, wxALIGN_LEFT|wxALL, 5); + } wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); itemGridSizer4->Add(itemBoxSizer17, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW, 5); @@ -321,14 +324,17 @@ void wxGenericFontDialog::CreateWidgets() itemChoice19->SetToolTip(_("The font point size.")); itemBoxSizer17->Add(itemChoice19, 0, wxALIGN_LEFT|wxALL, 5); - wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL); - itemGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); - wxCheckBox* itemCheckBox21 = new wxCheckBox( this, wxID_FONT_UNDERLINE, _("&Underline"), wxDefaultPosition, wxDefaultSize, 0 ); - itemCheckBox21->SetValue(FALSE); - itemCheckBox21->SetHelpText(_("Whether the font is underlined.")); - if (ShowToolTips()) - itemCheckBox21->SetToolTip(_("Whether the font is underlined.")); - itemBoxSizer20->Add(itemCheckBox21, 0, wxALIGN_LEFT|wxALL, 5); + if (m_fontData.GetEnableEffects()) + { + wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL); + itemGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); + wxCheckBox* itemCheckBox21 = new wxCheckBox( this, wxID_FONT_UNDERLINE, _("&Underline"), wxDefaultPosition, wxDefaultSize, 0 ); + itemCheckBox21->SetValue(FALSE); + itemCheckBox21->SetHelpText(_("Whether the font is underlined.")); + if (ShowToolTips()) + itemCheckBox21->SetToolTip(_("Whether the font is underlined.")); + itemBoxSizer20->Add(itemCheckBox21, 0, wxALIGN_LEFT|wxALL, 5); + } itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); @@ -382,13 +388,21 @@ void wxGenericFontDialog::CreateWidgets() familyChoice->SetStringSelection( wxFontFamilyIntToString(dialogFont.GetFamily()) ); styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle())); weightChoice->SetStringSelection(wxFontWeightIntToString(dialogFont.GetWeight())); - wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour())); - if (name.length()) - colourChoice->SetStringSelection(name); - else - colourChoice->SetStringSelection(wxT("BLACK")); + + if (colourChoice) + { + wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour())); + if (name.length()) + colourChoice->SetStringSelection(name); + else + colourChoice->SetStringSelection(wxT("BLACK")); + } - underLineCheckBox->SetValue(dialogFont.GetUnderlined()); + if (underLineCheckBox) + { + underLineCheckBox->SetValue(dialogFont.GetUnderlined()); + } + pointSizeChoice->SetSelection(dialogFont.GetPointSize()-1); GetSizer()->SetItemMinSize(m_previewer, 430, 100); @@ -439,19 +453,34 @@ void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event)) int fontWeight = wxFontWeightStringToInt(WXSTRINGCAST weightChoice->GetStringSelection()); int fontStyle = wxFontStyleStringToInt(WXSTRINGCAST styleChoice->GetStringSelection()); int fontSize = wxAtoi(pointSizeChoice->GetStringSelection()); - int fontUnderline = underLineCheckBox->GetValue(); + // Start with previous underline setting, we want to retain it even if we can't edit it + // dialogFont is always initialized because of the call to InitializeFont + int fontUnderline = dialogFont.GetUnderlined(); + + if (underLineCheckBox) + { + fontUnderline = underLineCheckBox->GetValue(); + } dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0)); m_previewer->SetFont(dialogFont); - if ( !colourChoice->GetStringSelection().empty() ) + + if ( colourChoice ) { - wxColour col = wxTheColourDatabase->Find(colourChoice->GetStringSelection()); - if (col.Ok()) + if ( !colourChoice->GetStringSelection().empty() ) { - m_fontData.m_fontColour = col; - m_previewer->SetForegroundColour(col); + wxColour col = wxTheColourDatabase->Find(colourChoice->GetStringSelection()); + if (col.Ok()) + { + m_fontData.m_fontColour = col; + } } } + // Update color here so that we can also use the color originally passed in + // (EnableEffects may be false) + if (m_fontData.m_fontColour.Ok()) + m_previewer->SetForegroundColour(m_fontData.m_fontColour); + m_previewer->Refresh(); } -- 2.45.2