Kaydet (Commit) 799a3a79 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Caolán McNamara

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/29815Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarjan iversen <jani@documentfoundation.org>
Tested-by: 's avatarjan iversen <jani@documentfoundation.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c5498c31
...@@ -1444,14 +1444,6 @@ void ModulWindowLayout::Paint (vcl::RenderContext& rRenderContext, Rectangle con ...@@ -1444,14 +1444,6 @@ void ModulWindowLayout::Paint (vcl::RenderContext& rRenderContext, Rectangle con
rRenderContext.DrawText(Point(), IDEResId(RID_STR_NOMODULE).toString()); 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) void ModulWindowLayout::Activating (BaseWindow& rChild)
{ {
assert(dynamic_cast<ModulWindow*>(&rChild)); assert(dynamic_cast<ModulWindow*>(&rChild));
...@@ -1511,11 +1503,6 @@ ModulWindowLayout::SyntaxColors::SyntaxColors () : ...@@ -1511,11 +1503,6 @@ ModulWindowLayout::SyntaxColors::SyntaxColors () :
{ {
aConfig.AddListener(this); aConfig.AddListener(this);
aColors[TokenType::Unknown] =
aColors[TokenType::Whitespace] =
aColors[TokenType::EOL] =
Application::GetSettings().GetStyleSettings().GetFieldTextColor();
NewConfig(true); NewConfig(true);
} }
...@@ -1524,20 +1511,6 @@ ModulWindowLayout::SyntaxColors::~SyntaxColors () ...@@ -1524,20 +1511,6 @@ ModulWindowLayout::SyntaxColors::~SyntaxColors ()
aConfig.RemoveListener(this); 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 // virtual
void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32) void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32)
{ {
...@@ -1554,15 +1527,37 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst) ...@@ -1554,15 +1527,37 @@ void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst)
} }
const vIds[] = const vIds[] =
{ {
{ TokenType::Unknown, svtools::FONTCOLOR },
{ TokenType::Identifier, svtools::BASICIDENTIFIER }, { TokenType::Identifier, svtools::BASICIDENTIFIER },
{ TokenType::Whitespace, svtools::FONTCOLOR },
{ TokenType::Number, svtools::BASICNUMBER }, { TokenType::Number, svtools::BASICNUMBER },
{ TokenType::String, svtools::BASICSTRING }, { TokenType::String, svtools::BASICSTRING },
{ TokenType::EOL, svtools::FONTCOLOR },
{ TokenType::Comment, svtools::BASICCOMMENT }, { TokenType::Comment, svtools::BASICCOMMENT },
{ TokenType::Error, svtools::BASICERROR }, { TokenType::Error, svtools::BASICERROR },
{ TokenType::Operator, svtools::BASICOPERATOR }, { TokenType::Operator, svtools::BASICOPERATOR },
{ TokenType::Keywords, svtools::BASICKEYWORD }, { 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; bool bChanged = false;
for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i) for (unsigned i = 0; i != SAL_N_ELEMENTS(vIds); ++i)
{ {
......
...@@ -94,8 +94,6 @@ private: ...@@ -94,8 +94,6 @@ private:
class ProgressInfo; class ProgressInfo;
std::unique_ptr<ProgressInfo> pProgress; std::unique_ptr<ProgressInfo> pProgress;
virtual void DataChanged(DataChangedEvent const & rDCEvt) override;
using Window::Notify; using Window::Notify;
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
...@@ -156,6 +154,7 @@ public: ...@@ -156,6 +154,7 @@ public:
bool CanModify() { return ImpCanModify(); } bool CanModify() { return ImpCanModify(); }
void ChangeFontColor( Color aColor );
void UpdateSyntaxHighlighting (); void UpdateSyntaxHighlighting ();
bool GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName) const; bool GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName) const;
...@@ -428,6 +427,8 @@ public: ...@@ -428,6 +427,8 @@ public:
public: public:
void BasicAddWatch (OUString const&); void BasicAddWatch (OUString const&);
void BasicRemoveWatch (); void BasicRemoveWatch ();
Color GetBackgroundColor () const { return aSyntaxColors.GetBackgroundColor(); }
Color GetFontColor () const { return aSyntaxColors.GetFontColor(); }
Color GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); } Color GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); }
protected: protected:
...@@ -443,9 +444,7 @@ private: ...@@ -443,9 +444,7 @@ private:
VclPtr<WatchWindow> aWatchWindow; VclPtr<WatchWindow> aWatchWindow;
VclPtr<StackWindow> aStackWindow; VclPtr<StackWindow> aStackWindow;
ObjectCatalog& rObjectCatalog; ObjectCatalog& rObjectCatalog;
private:
virtual void DataChanged (DataChangedEvent const& rDCEvt) override;
private:
// SyntaxColors -- stores Basic syntax highlighting colors // SyntaxColors -- stores Basic syntax highlighting colors
class SyntaxColors : public utl::ConfigurationListener class SyntaxColors : public utl::ConfigurationListener
{ {
...@@ -454,8 +453,9 @@ private: ...@@ -454,8 +453,9 @@ private:
virtual ~SyntaxColors () override; virtual ~SyntaxColors () override;
public: public:
void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; } void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; }
void SettingsChanged ();
public: public:
Color GetBackgroundColor () const { return m_aBackgroundColor; };
Color GetFontColor () const { return m_aFontColor; }
Color GetColor (TokenType eType) const { return aColors[eType]; } Color GetColor (TokenType eType) const { return aColors[eType]; }
private: private:
...@@ -463,6 +463,8 @@ private: ...@@ -463,6 +463,8 @@ private:
void NewConfig (bool bFirst); void NewConfig (bool bFirst);
private: private:
Color m_aBackgroundColor;
Color m_aFontColor;
// the color values (the indexes are TokenType, see comphelper/syntaxhighlight.hxx) // the color values (the indexes are TokenType, see comphelper/syntaxhighlight.hxx)
o3tl::enumarray<TokenType, Color> aColors; o3tl::enumarray<TokenType, Color> aColors;
// the configuration // the configuration
......
...@@ -227,7 +227,7 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : ...@@ -227,7 +227,7 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
bDelayHighlight(true), bDelayHighlight(true),
pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this)) pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this))
{ {
SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); SetBackground(Wallpaper(rModulWindow.GetLayout().GetBackgroundColor()));
SetPointer( Pointer( PointerStyle::Text ) ); SetPointer( Pointer( PointerStyle::Text ) );
SetHelpId( HID_BASICIDE_EDITORWINDOW ); SetHelpId( HID_BASICIDE_EDITORWINDOW );
...@@ -1033,34 +1033,6 @@ void EditorWindow::CreateEditEngine() ...@@ -1033,34 +1033,6 @@ void EditorWindow::CreateEditEngine()
rModulWindow.SetReadOnly(true); 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 ) void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{ {
if (TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint)) if (TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint))
...@@ -1206,6 +1178,16 @@ void EditorWindow::ImpDoHighlight( sal_uLong nLine ) ...@@ -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 () void EditorWindow::UpdateSyntaxHighlighting ()
{ {
const sal_uInt32 nCount = pEditEngine->GetParagraphCount(); const sal_uInt32 nCount = pEditEngine->GetParagraphCount();
...@@ -1225,7 +1207,7 @@ void EditorWindow::ImplSetFont() ...@@ -1225,7 +1207,7 @@ void EditorWindow::ImplSetFont()
} }
Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get()); Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get());
vcl::Font aFont(sFontName, aFontSize); vcl::Font aFont(sFontName, aFontSize);
aFont.SetColor(Application::GetSettings().GetStyleSettings().GetFieldTextColor()); aFont.SetColor(rModulWindow.GetLayout().GetFontColor());
SetPointFont(*this, aFont); // FIXME RenderContext SetPointFont(*this, aFont); // FIXME RenderContext
aFont = GetFont(); aFont = GetFont();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment