diff options
author | Stephan Bergmann <sb@openoffice.org> | 2002-07-05 09:22:53 +0000 |
---|---|---|
committer | Stephan Bergmann <sb@openoffice.org> | 2002-07-05 09:22:53 +0000 |
commit | 7d1d90ae92b60b932b887c27568d66dd94f541ae (patch) | |
tree | dbacc55cc83dda67ece43988055660901521519f | |
parent | 28c2d52e0b9d65bc9aeca4252b00ccd0ca96c022 (diff) |
#99517# Added support for high contrast mode.
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 145 | ||||
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 58 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 125 |
3 files changed, 227 insertions, 101 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index d150a73785f8..13a8a3b5498c 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: sb $ $Date: 2002-07-03 15:45:47 $ + * last change: $Author: sb $ $Date: 2002-07-05 10:22:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1384,16 +1384,17 @@ BOOL ModulWindow::IsPasteAllowed() ModulWindowLayout::ModulWindowLayout( Window* pParent ) : Window( pParent, WB_CLIPCHILDREN ), - aWatchWindow( this ), - aStackWindow( this ), aVSplitter( this, WinBits( WB_VSCROLL ) ), aHSplitter( this, WinBits( WB_HSCROLL ) ), + aWatchWindow( this ), + aStackWindow( this ), + bVSplitted(FALSE), + bHSplitted(FALSE), + m_pModulWindow(0), m_aImagesNormal(IDEResId(RID_IMGLST_LAYOUT)), m_aImagesHighContrast(IDEResId(RID_IMGLST_LAYOUT_HC)) { - pModulWindow = 0; - bVSplitted = FALSE; - bHSplitted = FALSE; + SetBackground(GetSettings().GetStyleSettings().GetWindowColor()); aVSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) ); aHSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) ); @@ -1403,16 +1404,25 @@ ModulWindowLayout::ModulWindowLayout( Window* pParent ) : aWatchWindow.Show(); aStackWindow.Show(); - aSyntaxColors[0] = Color( COL_BLACK ); // TT_UNKNOWN, - aSyntaxColors[1] = Color( COL_GREEN ); // TT_IDENTIFIER, - aSyntaxColors[2] = Color( COL_BLACK ); // TT_WHITESPACE, - aSyntaxColors[3] = Color( COL_LIGHTRED ); // TT_NUMBER, - aSyntaxColors[4] = Color( COL_LIGHTRED ); // TT_STRING, - aSyntaxColors[5] = Color( COL_BLACK ); // TT_EOL, - aSyntaxColors[6] = Color( COL_GRAY ); // TT_COMMENT, - aSyntaxColors[7] = Color( COL_RED ); // TT_ERROR, - aSyntaxColors[8] = Color( COL_BLUE ); // TT_OPERATOR, - aSyntaxColors[9] = Color( COL_BLUE ); // TT_KEYWORD + Color aColor(GetSettings().GetStyleSettings().GetFieldTextColor()); + m_aSyntaxColors[TT_UNKNOWN] = aColor; + m_aSyntaxColors[TT_WHITESPACE] = aColor; + m_aSyntaxColors[TT_EOL] = aColor; + StartListening(m_aColorConfig); + m_aSyntaxColors[TT_IDENTIFIER] + = Color(m_aColorConfig.GetColorValue(svx::BASICIDENTIFIER).nColor); + m_aSyntaxColors[TT_NUMBER] + = Color(m_aColorConfig.GetColorValue(svx::BASICNUMBER).nColor); + m_aSyntaxColors[TT_STRING] + = Color(m_aColorConfig.GetColorValue(svx::BASICSTRING).nColor); + m_aSyntaxColors[TT_COMMENT] + = Color(m_aColorConfig.GetColorValue(svx::BASICCOMMENT).nColor); + m_aSyntaxColors[TT_ERROR] = Color(COL_RED); // FIXME (#99517#) +// = Color(m_aColorConfig.GetColorValue(svx::BASICERROR).nColor); + m_aSyntaxColors[TT_OPERATOR] + = Color(m_aColorConfig.GetColorValue(svx::BASICOPERATOR).nColor); + m_aSyntaxColors[TT_KEYWORD] + = Color(m_aColorConfig.GetColorValue(svx::BASICKEYWORD).nColor); Font aFont( GetFont() ); Size aSz( aFont.GetSize() ); @@ -1420,11 +1430,13 @@ ModulWindowLayout::ModulWindowLayout( Window* pParent ) : aSz.Height() /= 2; aFont.SetSize( aSz ); aFont.SetWeight( WEIGHT_BOLD ); + aFont.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor()); SetFont( aFont ); } ModulWindowLayout::~ModulWindowLayout() { + EndListening(m_aColorConfig); } void __EXPORT ModulWindowLayout::Resize() @@ -1468,10 +1480,10 @@ void ModulWindowLayout::ArrangeWindows() Size aXEWSz; aXEWSz.Width() = aSz.Width(); aXEWSz.Height() = nVSplitPos + 1; - if ( pModulWindow ) + if ( m_pModulWindow ) { - DBG_CHKOBJ( pModulWindow, ModulWindow, 0 ); - pModulWindow->SetPosSizePixel( Point( 0, 0 ), aXEWSz ); + DBG_CHKOBJ( m_pModulWindow, ModulWindow, 0 ); + m_pModulWindow->SetPosSizePixel( Point( 0, 0 ), aXEWSz ); } aVSplitter.SetDragRectPixel( Rectangle( Point( 0, 0 ), Size( aSz.Width(), aSz.Height() ) ) ); @@ -1576,7 +1588,98 @@ void ModulWindowLayout::DockaWindow( DockingWindow* pDockingWindow ) void ModulWindowLayout::SetModulWindow( ModulWindow* pModWin ) { - pModulWindow = pModWin; + m_pModulWindow = pModWin; ArrangeWindows(); } +// virtual +void ModulWindowLayout::DataChanged(DataChangedEvent const & rDCEvt) +{ + Window::DataChanged(rDCEvt); + if (rDCEvt.GetType() == DATACHANGED_SETTINGS + && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) + { + bool bInvalidate = false; + Color aColor(GetSettings().GetStyleSettings().GetWindowColor()); + if (aColor + != rDCEvt.GetOldSettings()->GetStyleSettings().GetWindowColor()) + { + SetBackground(Wallpaper(aColor)); + bInvalidate = true; + } + aColor = GetSettings().GetStyleSettings().GetWindowTextColor(); + if (aColor != rDCEvt.GetOldSettings()-> + GetStyleSettings().GetWindowTextColor()) + { + Font aFont(GetFont()); + aFont.SetColor(aColor); + SetFont(aFont); + bInvalidate = true; + } + if (bInvalidate) + Invalidate(); + aColor = GetSettings().GetStyleSettings().GetFieldTextColor(); + if (aColor != m_aSyntaxColors[TT_UNKNOWN]) + { + m_aSyntaxColors[TT_UNKNOWN] = aColor; + m_aSyntaxColors[TT_WHITESPACE] = aColor; + m_aSyntaxColors[TT_EOL] = aColor; + updateSyntaxHighlighting(); + } + } +} + +// virtual +void ModulWindowLayout::Notify(SfxBroadcaster & rBc, SfxHint const & rHint) +{ + if (rHint.ISA(SfxSimpleHint) + && (static_cast< SfxSimpleHint const & >(rHint).GetId() + == SFX_HINT_COLORS_CHANGED)) + { + Color aColor(m_aColorConfig.GetColorValue(svx::BASICIDENTIFIER). + nColor); + bool bChanged = aColor != m_aSyntaxColors[TT_IDENTIFIER]; + m_aSyntaxColors[TT_IDENTIFIER] = aColor; + aColor = Color(m_aColorConfig.GetColorValue(svx::BASICNUMBER).nColor); + bChanged = bChanged || aColor != m_aSyntaxColors[TT_NUMBER]; + m_aSyntaxColors[TT_NUMBER] = aColor; + aColor = Color(m_aColorConfig.GetColorValue(svx::BASICSTRING).nColor); + bChanged = bChanged || aColor != m_aSyntaxColors[TT_STRING]; + m_aSyntaxColors[TT_STRING] = aColor; + aColor = Color(m_aColorConfig.GetColorValue(svx::BASICCOMMENT). + nColor); + bChanged = bChanged || aColor != m_aSyntaxColors[TT_COMMENT]; + m_aSyntaxColors[TT_COMMENT] = aColor; +// FIXME (#99517#): +// aColor = Color(m_aColorConfig.GetColorValue(svx::BASICERROR).nColor); +// bChanged = bChanged || aColor != m_aSyntaxColors[TT_ERROR]; +// m_aSyntaxColors[TT_ERROR] = aColor; + aColor = Color(m_aColorConfig.GetColorValue(svx::BASICOPERATOR). + nColor); + bChanged = bChanged || aColor != m_aSyntaxColors[TT_OPERATOR]; + m_aSyntaxColors[TT_OPERATOR] = aColor; + aColor = Color(m_aColorConfig.GetColorValue(svx::BASICKEYWORD). + nColor); + bChanged = bChanged || aColor != m_aSyntaxColors[TT_KEYWORD]; + m_aSyntaxColors[TT_KEYWORD] = aColor; + if (bChanged) + updateSyntaxHighlighting(); + } +} + +void ModulWindowLayout::updateSyntaxHighlighting() +{ + if (m_pModulWindow != 0) + { + EditorWindow & rEditor = m_pModulWindow->GetEditorWindow(); + ULONG nCount = rEditor.GetEditEngine()->GetParagraphCount(); + for (ULONG i = 0; i < nCount; ++i) + rEditor.DoDelayedSyntaxHighlight(i); + } +} + +Image ModulWindowLayout::getImage(USHORT nId, bool bHighContrastMode) const +{ + return (bHighContrastMode ? m_aImagesHighContrast : m_aImagesNormal). + GetImage(nId); +} diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index ee2254abad8b..c1408d866fec 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: sb $ $Date: 2002-07-03 15:45:46 $ + * last change: $Author: sb $ $Date: 2002-07-05 10:22:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,6 +96,14 @@ class SvxSearchItem; #include <vcl/split.hxx> #endif +#ifndef _SFXLSTNER_HXX +#include "svtools/lstner.hxx" +#endif + +#ifndef _SVX_COLORCFG_HXX +#include "svx/colorcfg.hxx" +#endif + #include <sfx2/progress.hxx> @@ -161,6 +169,7 @@ private: Timer aHelpAgentTimer; DECL_LINK( HelpAgentTimerHdl, Timer * ); + virtual void DataChanged(DataChangedEvent const & rDCEvt); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); @@ -222,6 +231,11 @@ private: BreakPointList aBreakPointList; ModulWindow* pModulWindow; BOOL bErrorMarker; + bool m_bHighContrastMode; + + virtual void DataChanged(DataChangedEvent const & rDCEvt); + + void setBackgroundColor(Color aColor); protected: virtual void Paint( const Rectangle& ); @@ -242,11 +256,6 @@ public: void SetMarkerPos( USHORT nLine, BOOL bErrorMarker = FALSE ); -// virtual void MouseMove( const MouseEvent& rMEvt ); -// virtual void MouseButtonUp( const MouseEvent& rMEvt ); -// virtual BOOL Drop( const DropEvent& rEvt ); -// virtual BOOL QueryDrop( const DropEvent& rEvt ); - void Scroll( long nHorzScroll, long nVertScroll ); long& GetCurYOffset() { return nCurYOffset; } BreakPointList& GetBreakPoints() { return aBreakPointList; } @@ -337,9 +346,10 @@ private: EditorWindow aEdtWindow; ScrollBar aEWVScrollBar; + virtual void DataChanged(DataChangedEvent const & rDCEvt); + protected: virtual void Resize(); - virtual void Paint( const Rectangle& rRect ); DECL_LINK( ScrollHdl, ScrollBar * ); public: @@ -459,7 +469,7 @@ public: void SetModule( const ::rtl::OUString& aModule ) { m_aModule = aModule; } }; -class ModulWindowLayout: public Window +class ModulWindowLayout: public Window, public SfxListener { private: @@ -469,20 +479,27 @@ private: WatchWindow aWatchWindow; StackWindow aStackWindow; - DECL_LINK( SplitHdl, Splitter * ); BOOL bVSplitted; BOOL bHSplitted; - void ArrangeWindows(); - - ModulWindow* pModulWindow; + ModulWindow * m_pModulWindow; -// BOOL bDoSyntaxHighlight; - Color aSyntaxColors[10]; + Color m_aSyntaxColors[TT_KEYWORD + 1]; + svx::ColorConfig m_aColorConfig; ImageList m_aImagesNormal; ImageList m_aImagesHighContrast; + virtual void DataChanged(DataChangedEvent const & rDCEvt); + + virtual void Notify(SfxBroadcaster & rBc, SfxHint const & rHint); + + void updateSyntaxHighlighting(); + + DECL_LINK( SplitHdl, Splitter * ); + + void ArrangeWindows(); + protected: virtual void Resize(); virtual void Paint( const Rectangle& rRect ); @@ -495,18 +512,15 @@ public: BOOL IsToBeDocked( DockingWindow* pDockingWin, const Point& rPos, Rectangle& rRect ); void SetModulWindow( ModulWindow* pModWin ); - ModulWindow* GetModulWindow() const { return pModulWindow; } + ModulWindow* GetModulWindow() const { return m_pModulWindow; } WatchWindow& GetWatchWindow() { return aWatchWindow; } StackWindow& GetStackWindow() { return aStackWindow; } - Color* GetSyntaxColors() { return aSyntaxColors; } - - Image GetImage(USHORT nId) { return m_aImagesNormal.GetImage(nId); } + Image getImage(USHORT nId, bool bHighContrastMode) const; -// BOOL DoHighlight() const { return bDoSyntaxHighlight; } -// void SetHighlightMode( BOOL bHighlight ) -// { bDoSyntaxHighlight = bHighlight; } + inline Color const & getSyntaxColor(TokenTypes eType) const + { return m_aSyntaxColors[eType]; } }; #endif // _BASIDE2_HXX diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 99103fe45298..012263652970 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2b.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: sb $ $Date: 2002-07-03 15:45:47 $ + * last change: $Author: sb $ $Date: 2002-07-05 10:22:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -282,6 +282,8 @@ void lcl_FormatArrayString( String& rResult ) void lcl_DrawIDEWindowFrame( DockingWindow* pWin ) { + // The result of using explicit colors here appears to be harmless when + // switching to high contrast mode: if ( !pWin->IsFloatingMode() ) { Size aSz = pWin->GetOutputSizePixel(); @@ -341,7 +343,8 @@ EditorWindow::EditorWindow( Window* pParent ) : bHighlightning = FALSE; pProgress = 0; nCurTextWidth = 0; - SetBackground( Wallpaper( COL_WHITE ) ); + SetBackground( + Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); SetPointer( Pointer( POINTER_TEXT ) ); SetHelpId( HID_BASICIDE_EDITORWINDOW ); @@ -784,6 +787,23 @@ void EditorWindow::CreateEditEngine() pModulWindow->SetReadOnly( TRUE ); } +// virtual +void EditorWindow::DataChanged(DataChangedEvent const & rDCEvt) +{ + Window::DataChanged(rDCEvt); + if (rDCEvt.GetType() == DATACHANGED_SETTINGS + && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) + { + Color aColor(GetSettings().GetStyleSettings().GetFieldColor()); + if (aColor + != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor()) + { + SetBackground(Wallpaper(aColor)); + Invalidate(); + } + } +} + void EditorWindow::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { if ( rHint.ISA( TextHint ) ) @@ -891,8 +911,7 @@ void EditorWindow::ImpDoHighlight( ULONG nLine ) for ( USHORT i = 0; i < nCount; i++ ) { HighlightPortion& r = aPortions[i]; - USHORT nCol = r.tokenType; - const Color& rColor = ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetSyntaxColors()[nCol]; + const Color& rColor = ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->getSyntaxColor(r.tokenType); pEditEngine->SetAttrib( TextAttribFontColor( rColor ), nLine, r.nBegin, r.nEnd ); } @@ -1065,8 +1084,7 @@ BreakPointWindow::BreakPointWindow( Window* pParent ) : { pModulWindow = 0; nCurYOffset = 0; - SetLineColor( Color( COL_BLACK ) ); - SetBackground( Wallpaper( COL_WHITE ) ); + setBackgroundColor(GetSettings().GetStyleSettings().GetFieldColor()); nMarkerPos = MARKER_NOMARKER; // nCurYOffset merken und nicht von EditEngine holen. @@ -1100,8 +1118,10 @@ void __EXPORT BreakPointWindow::Paint( const Rectangle& ) Size aOutSz( GetOutputSize() ); long nLineHeight = GetTextHeight(); - Image aBrk1( ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetImage( IMGID_BRKENABLED ) ); - Image aBrk0( ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetImage( IMGID_BRKDISABLED ) ); + Image aBrk1(((ModulWindowLayout *) pModulWindow->GetLayoutWindow())-> + getImage(IMGID_BRKENABLED, m_bHighContrastMode)); + Image aBrk0(((ModulWindowLayout *) pModulWindow->GetLayoutWindow())-> + getImage(IMGID_BRKDISABLED, m_bHighContrastMode)); Size aBmpSz( aBrk1.GetSizePixel() ); aBmpSz = PixelToLogic( aBmpSz ); Point aBmpOff( 0, 0 ); @@ -1148,11 +1168,10 @@ void BreakPointWindow::ShowMarker( BOOL bShow ) Size aOutSz( GetOutputSize() ); long nLineHeight = GetTextHeight(); - Image aMarker; - if ( bErrorMarker ) - aMarker = ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetImage( IMGID_ERRORMARKER ); - else - aMarker = ((ModulWindowLayout*)pModulWindow->GetLayoutWindow())->GetImage( IMGID_STEPMARKER ); + Image aMarker(((ModulWindowLayout*)pModulWindow->GetLayoutWindow())-> + getImage(bErrorMarker + ? IMGID_ERRORMARKER : IMGID_STEPMARKER, + m_bHighContrastMode)); Size aMarkerSz( aMarker.GetSizePixel() ); aMarkerSz = PixelToLogic( aMarkerSz ); @@ -1272,35 +1291,28 @@ BOOL BreakPointWindow::SyncYOffset() return FALSE; } - -/* - - -void __EXPORT BreakPointWindow::MouseMove( const MouseEvent &rEvt ) -{ -} - - - -void __EXPORT BreakPointWindow::MouseButtonUp( const MouseEvent &rEvt ) -{ -} - - - - -BOOL __EXPORT BreakPointWindow::Drop( const DropEvent& rEvt ) +// virtual +void BreakPointWindow::DataChanged(DataChangedEvent const & rDCEvt) { + Window::DataChanged(rDCEvt); + if (rDCEvt.GetType() == DATACHANGED_SETTINGS + && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) + { + Color aColor(GetSettings().GetStyleSettings().GetFieldColor()); + if (aColor + != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor()) + { + setBackgroundColor(aColor); + Invalidate(); + } + } } - - -BOOL __EXPORT BreakPointWindow::QueryDrop( const DropEvent& rEvt ) +void BreakPointWindow::setBackgroundColor(Color aColor) { + SetBackground(Wallpaper(aColor)); + m_bHighContrastMode = aColor.IsDark(); } -*/ - - WatchWindow::WatchWindow( Window* pParent ) : BasicDockingWindow( pParent ), @@ -1618,7 +1630,7 @@ void __EXPORT StackWindow::UpdateCalls() ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) : - Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ), + Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ), aEWVScrollBar( this, WB_VSCROLL | WB_DRAG ), aBrkWindow( this ), aEdtWindow( this ) @@ -1659,24 +1671,6 @@ void __EXPORT ComplexEditorWindow::Resize() // Invalidate(); } - - -void __EXPORT ComplexEditorWindow::Paint( const Rectangle& rRect ) -{ -#ifdef WIN - Point aPos( aEWVScrollBar.GetPosPixel() ); - Size aSz( aEWVScrollBar.GetSizePixel() ); - const Color aOldLineColor( GetLineColor() ); - SetLineColor( Color( COL_GRAY ) ); - DrawLine( Point( aPos.X(), aPos.Y() - 1 ), Point( aPos.X() + aSz.Width(), aPos.Y() - 1 ) ); - SetLineColor( Color( COL_WHITE ) ); - DrawLine( Point( aPos.X() + aSz.Width(), aPos.Y() - 1 ), Point( aPos.X() + aSz.Width(), aPos.Y() + aSz.Height() ) ); - DrawLine( Point( aPos.X(), aPos.Y() + aSz.Height() ), Point( aPos.X() + aSz.Width(), aPos.Y() + aSz.Height() ) ); - SetLineColor( aOldLineColor ); -#endif -} - - IMPL_LINK( ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar ) { if ( aEdtWindow.GetEditView() ) @@ -1692,7 +1686,22 @@ IMPL_LINK( ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar ) return 0; } - +// virtual +void ComplexEditorWindow::DataChanged(DataChangedEvent const & rDCEvt) +{ + Window::DataChanged(rDCEvt); + if (rDCEvt.GetType() == DATACHANGED_SETTINGS + && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) + { + Color aColor(GetSettings().GetStyleSettings().GetFaceColor()); + if (aColor + != rDCEvt.GetOldSettings()->GetStyleSettings().GetFaceColor()) + { + SetBackground(Wallpaper(aColor)); + Invalidate(); + } + } +} WatchTreeListBox::WatchTreeListBox( Window* pParent, WinBits nWinBits ) : SvTreeListBox( pParent, nWinBits ) |