diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2016-10-14 19:13:05 +0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-10-25 11:27:03 +0000 |
commit | 799a3a7915e6285c8072f92c63ba7149223ac443 (patch) | |
tree | 19f57f8ef305c973270446bbf08b32e3d6b32eba /basctl | |
parent | c5498c310f6765ec9857e34169fd4a8d48953eb7 (diff) |
tdf#103209 Apply application color settings to Basic IDE
This makes the text and background colors in the editor window
follow the custom colors "Font color" and "Document background"
respectively in Options > LibreOffice > Applications Colors.
... for those who think BASIC looks cooler when written in green
text on black background.
Change-Id: I82647865f7c2915341249c2fd5ebc9bd8d617bd1
Reviewed-on: https://gerrit.libreoffice.org/29815
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: jan iversen <jani@documentfoundation.org>
Tested-by: jan iversen <jani@documentfoundation.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 49 | ||||
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 14 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 42 |
3 files changed, 42 insertions, 63 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 9d3f9cffe083..351ce03e34fd 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1444,14 +1444,6 @@ void ModulWindowLayout::Paint (vcl::RenderContext& rRenderContext, Rectangle con rRenderContext.DrawText(Point(), IDEResId(RID_STR_NOMODULE).toString()); } -// virtual -void ModulWindowLayout::DataChanged (DataChangedEvent const& rDCEvt) -{ - Layout::DataChanged(rDCEvt); - if (rDCEvt.GetType() == DataChangedEventType::SETTINGS && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) - aSyntaxColors.SettingsChanged(); -} - void ModulWindowLayout::Activating (BaseWindow& rChild) { assert(dynamic_cast<ModulWindow*>(&rChild)); @@ -1511,11 +1503,6 @@ ModulWindowLayout::SyntaxColors::SyntaxColors () : { aConfig.AddListener(this); - aColors[TokenType::Unknown] = - aColors[TokenType::Whitespace] = - aColors[TokenType::EOL] = - Application::GetSettings().GetStyleSettings().GetFieldTextColor(); - NewConfig(true); } @@ -1524,20 +1511,6 @@ ModulWindowLayout::SyntaxColors::~SyntaxColors () aConfig.RemoveListener(this); } -void ModulWindowLayout::SyntaxColors::SettingsChanged () -{ - Color const aColor = Application::GetSettings().GetStyleSettings().GetFieldTextColor(); - if (aColor != aColors[TokenType::Unknown]) - { - aColors[TokenType::Unknown] = - aColors[TokenType::Whitespace] = - aColors[TokenType::EOL] = - aColor; - if (pEditor) - pEditor->UpdateSyntaxHighlighting(); - } -} - // virtual void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32) { @@ -1554,15 +1527,37 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst) } const vIds[] = { + { TokenType::Unknown, svtools::FONTCOLOR }, { TokenType::Identifier, svtools::BASICIDENTIFIER }, + { TokenType::Whitespace, svtools::FONTCOLOR }, { TokenType::Number, svtools::BASICNUMBER }, { TokenType::String, svtools::BASICSTRING }, + { TokenType::EOL, svtools::FONTCOLOR }, { TokenType::Comment, svtools::BASICCOMMENT }, { TokenType::Error, svtools::BASICERROR }, { TokenType::Operator, svtools::BASICOPERATOR }, { TokenType::Keywords, svtools::BASICKEYWORD }, }; + Color aDocColor = aConfig.GetColorValue(svtools::DOCCOLOR).nColor; + if (bFirst || aDocColor != m_aBackgroundColor) + { + m_aBackgroundColor = aDocColor; + if (!bFirst && pEditor) + { + pEditor->SetBackground(Wallpaper(m_aBackgroundColor)); + pEditor->Invalidate(); + } + } + + Color aFontColor = aConfig.GetColorValue(svtools::FONTCOLOR).nColor; + if (bFirst || aFontColor != m_aFontColor) + { + m_aFontColor = aFontColor; + if (!bFirst && pEditor) + pEditor->ChangeFontColor(m_aFontColor); + } + bool bChanged = false; for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i) { diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 9a5156072e1e..6770ffbdf9a2 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -94,8 +94,6 @@ private: class ProgressInfo; std::unique_ptr<ProgressInfo> pProgress; - virtual void DataChanged(DataChangedEvent const & rDCEvt) override; - using Window::Notify; virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; @@ -156,6 +154,7 @@ public: bool CanModify() { return ImpCanModify(); } + void ChangeFontColor( Color aColor ); void UpdateSyntaxHighlighting (); bool GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName) const; @@ -428,6 +427,8 @@ public: public: void BasicAddWatch (OUString const&); void BasicRemoveWatch (); + Color GetBackgroundColor () const { return aSyntaxColors.GetBackgroundColor(); } + Color GetFontColor () const { return aSyntaxColors.GetFontColor(); } Color GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); } protected: @@ -443,9 +444,7 @@ private: VclPtr<WatchWindow> aWatchWindow; VclPtr<StackWindow> aStackWindow; ObjectCatalog& rObjectCatalog; -private: - virtual void DataChanged (DataChangedEvent const& rDCEvt) override; -private: + // SyntaxColors -- stores Basic syntax highlighting colors class SyntaxColors : public utl::ConfigurationListener { @@ -454,8 +453,9 @@ private: virtual ~SyntaxColors () override; public: void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; } - void SettingsChanged (); public: + Color GetBackgroundColor () const { return m_aBackgroundColor; }; + Color GetFontColor () const { return m_aFontColor; } Color GetColor (TokenType eType) const { return aColors[eType]; } private: @@ -463,6 +463,8 @@ private: void NewConfig (bool bFirst); private: + Color m_aBackgroundColor; + Color m_aFontColor; // the color values (the indexes are TokenType, see comphelper/syntaxhighlight.hxx) o3tl::enumarray<TokenType, Color> aColors; // the configuration diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 64003b6e3622..33fbf526b93d 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -227,7 +227,7 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : bDelayHighlight(true), pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this)) { - SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); + SetBackground(Wallpaper(rModulWindow.GetLayout().GetBackgroundColor())); SetPointer( Pointer( PointerStyle::Text ) ); SetHelpId( HID_BASICIDE_EDITORWINDOW ); @@ -1033,34 +1033,6 @@ void EditorWindow::CreateEditEngine() rModulWindow.SetReadOnly(true); } -// virtual -void EditorWindow::DataChanged(DataChangedEvent const & rDCEvt) -{ - Window::DataChanged(rDCEvt); - if (rDCEvt.GetType() == DataChangedEventType::SETTINGS - && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) - { - Color aColor(GetSettings().GetStyleSettings().GetFieldColor()); - const AllSettings* pOldSettings = rDCEvt.GetOldSettings(); - if (!pOldSettings || aColor != pOldSettings->GetStyleSettings().GetFieldColor()) - { - SetBackground(Wallpaper(aColor)); - Invalidate(); - } - if (pEditEngine != nullptr) - { - aColor = GetSettings().GetStyleSettings().GetFieldTextColor(); - if (!pOldSettings || aColor != - pOldSettings-> GetStyleSettings().GetFieldTextColor()) - { - vcl::Font aFont(pEditEngine->GetFont()); - aFont.SetColor(aColor); - pEditEngine->SetFont(aFont); - } - } - } -} - void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { if (TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint)) @@ -1206,6 +1178,16 @@ void EditorWindow::ImpDoHighlight( sal_uLong nLine ) } } +void EditorWindow::ChangeFontColor( Color aColor ) +{ + if (pEditEngine) + { + vcl::Font aFont(pEditEngine->GetFont()); + aFont.SetColor(aColor); + pEditEngine->SetFont(aFont); + } +} + void EditorWindow::UpdateSyntaxHighlighting () { const sal_uInt32 nCount = pEditEngine->GetParagraphCount(); @@ -1225,7 +1207,7 @@ void EditorWindow::ImplSetFont() } Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get()); vcl::Font aFont(sFontName, aFontSize); - aFont.SetColor(Application::GetSettings().GetStyleSettings().GetFieldTextColor()); + aFont.SetColor(rModulWindow.GetLayout().GetFontColor()); SetPointFont(*this, aFont); // FIXME RenderContext aFont = GetFont(); |