diff options
author | Carsten Driesner <cd@openoffice.org> | 2002-04-11 10:49:39 +0000 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2002-04-11 10:49:39 +0000 |
commit | c204eed4c0cfbfc9e28797defff95c0017968cd5 (patch) | |
tree | e7e9c231c3a401dc64da578bce0bdc364c55cec7 /framework | |
parent | 7fa06005b6fd097f5903cd2143bae1b6722e82f0 (diff) |
#98598# High contrast support for toolboxes and menus
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/classes/imagesconfiguration.hxx | 16 | ||||
-rw-r--r-- | framework/inc/classes/imagesdocumenthandler.hxx | 6 | ||||
-rw-r--r-- | framework/inc/classes/menuconfiguration.hxx | 5 | ||||
-rw-r--r-- | framework/inc/classes/menumanager.hxx | 6 | ||||
-rw-r--r-- | framework/inc/helper/imageproducer.hxx | 8 | ||||
-rw-r--r-- | framework/source/classes/bmkmenu.cxx | 15 | ||||
-rw-r--r-- | framework/source/classes/menumanager.cxx | 69 | ||||
-rw-r--r-- | framework/source/helper/imageproducer.cxx | 8 |
8 files changed, 99 insertions, 34 deletions
diff --git a/framework/inc/classes/imagesconfiguration.hxx b/framework/inc/classes/imagesconfiguration.hxx index c491688a6e83..9b9f13ce45e1 100644 --- a/framework/inc/classes/imagesconfiguration.hxx +++ b/framework/inc/classes/imagesconfiguration.hxx @@ -2,9 +2,9 @@ * * $RCSfile: imagesconfiguration.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mba $ $Date: 2001-11-27 09:48:59 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:44:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,11 +110,13 @@ struct ImageListItemDescriptor , nMaskMode( ImageMaskMode_Color ) {} ~ImageListItemDescriptor() { delete pImageItemList; } - String aURL; // a URL to a bitmap with several images inside - Color aMaskColor; // a color used as transparent - String aMaskURL; // a URL to an optional bitmap used as a mask - ImageMaskMode nMaskMode; // a enum to describe the current mask mode - ImageItemListDescriptor* pImageItemList; // an array of ImageItemDescriptors that describes every image + String aURL; // an URL to a bitmap with several images inside + Color aMaskColor; // a color used as transparent + String aMaskURL; // an URL to an optional bitmap used as a mask + ImageMaskMode nMaskMode; // an enum to describe the current mask mode + ImageItemListDescriptor* pImageItemList; // an array of ImageItemDescriptors that describes every image + String aHighContrastURL; // an URL to an optional high contrast bitmap with serveral images inside + String aHighContrastMaskURL; // an URL to an optional high contrast bitmap as a mask }; typedef ImageListItemDescriptor* ImageListItemDescriptorPtr; diff --git a/framework/inc/classes/imagesdocumenthandler.hxx b/framework/inc/classes/imagesdocumenthandler.hxx index a47430e71ec6..cd50012a15b0 100644 --- a/framework/inc/classes/imagesdocumenthandler.hxx +++ b/framework/inc/classes/imagesdocumenthandler.hxx @@ -2,9 +2,9 @@ * * $RCSfile: imagesdocumenthandler.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mba $ $Date: 2001-11-27 09:48:59 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:44:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,6 +125,8 @@ class OReadImagesDocumentHandler : public ::com::sun::star::xml::sax::XDocumentH IMG_ATTRIBUTE_BITMAPINDEX, IMG_ATTRIBUTE_MASKURL, IMG_ATTRIBUTE_MASKMODE, + IMG_ATTRIBUTE_HIGHCONTRASTURL, + IMG_ATTRIBUTE_HIGHCONTRASTMASKURL, IMG_XML_ENTRY_COUNT }; diff --git a/framework/inc/classes/menuconfiguration.hxx b/framework/inc/classes/menuconfiguration.hxx index 74a577b5c512..3343b8bb2c72 100644 --- a/framework/inc/classes/menuconfiguration.hxx +++ b/framework/inc/classes/menuconfiguration.hxx @@ -2,9 +2,9 @@ * * $RCSfile: menuconfiguration.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: cd $ $Date: 2001-08-16 07:51:55 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:44:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,6 +111,7 @@ class MenuConfiguration struct Attributes { ::rtl::OUString aTargetFrame; + ::rtl::OUString aImageId; }; MenuConfiguration( diff --git a/framework/inc/classes/menumanager.hxx b/framework/inc/classes/menumanager.hxx index 97e5bb7b0fd7..1403698af6e8 100644 --- a/framework/inc/classes/menumanager.hxx +++ b/framework/inc/classes/menumanager.hxx @@ -2,9 +2,9 @@ * * $RCSfile: menumanager.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: hr $ $Date: 2001-10-09 18:28:09 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:44:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -197,6 +197,8 @@ class MenuManager : public XSTATUSLISTENER , sal_Bool m_bDeleteChildren; sal_Bool m_bActive; sal_Bool m_bIsBookmarkMenu; + sal_Bool m_bWasHiContrast; + sal_Bool m_bShowMenuImages; ::rtl::OUString m_aMenuItemCommand; Menu* m_pVCLMenu; REFERENCE< XFRAME > m_xFrame; diff --git a/framework/inc/helper/imageproducer.hxx b/framework/inc/helper/imageproducer.hxx index 1dee27a1f59a..965e33d15651 100644 --- a/framework/inc/helper/imageproducer.hxx +++ b/framework/inc/helper/imageproducer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: imageproducer.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mba $ $Date: 2001-05-03 17:03:56 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:45:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -82,11 +82,11 @@ namespace framework { -typedef Image ( *pfunc_getImage)( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig ); +typedef Image ( *pfunc_getImage)( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast ); pfunc_getImage SAL_CALL SetImageProducer( pfunc_getImage pGetImageFunc ); -Image SAL_CALL GetImageFromURL( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig ); +Image SAL_CALL GetImageFromURL( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast ); }; diff --git a/framework/source/classes/bmkmenu.cxx b/framework/source/classes/bmkmenu.cxx index dbb71f133313..129f64e13873 100644 --- a/framework/source/classes/bmkmenu.cxx +++ b/framework/source/classes/bmkmenu.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bmkmenu.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: cd $ $Date: 2001-08-16 07:54:09 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:45:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,6 +115,7 @@ //_________________________________________________________________________________________________________________ #include <vcl/config.hxx> +#include <vcl/svapp.hxx> #include <svtools/dynamicmenuoptions.hxx> //_________________________________________________________________________________________________________________ @@ -232,6 +233,9 @@ void BmkMenu::Initialize() ::rtl::OUString aTargetFrame; ::rtl::OUString aImageId; + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + BOOL bIsHiContrastMode = rSettings.GetMenuColor().IsDark(); + UINT32 i, nCount = aDynamicMenuEntries.getLength(); for ( i = 0; i < nCount; ++i ) { @@ -249,7 +253,7 @@ void BmkMenu::Initialize() if ( aImageId.getLength() > 0 ) { - Image aImage = GetImageFromURL( m_xFrame, aImageId, FALSE ); + Image aImage = GetImageFromURL( m_xFrame, aImageId, FALSE, bIsHiContrastMode ); if ( !!aImage ) { bImageSet = sal_True; @@ -259,15 +263,18 @@ void BmkMenu::Initialize() if ( !bImageSet ) { - Image aImage = GetImageFromURL( m_xFrame, aURL, FALSE ); + Image aImage = GetImageFromURL( m_xFrame, aURL, FALSE, bIsHiContrastMode ); if ( !aImage ) InsertItem( nId, aTitle ); else InsertItem( nId, aTitle, aImage ); } + // Store values from configuration to the New and Wizard menu entries to enable + // sfx2 based code to support high contrast mode correctly! MenuConfiguration::Attributes* pUserAttributes = new MenuConfiguration::Attributes; pUserAttributes->aTargetFrame = aTargetFrame; + pUserAttributes->aImageId = aImageId; SetUserValue( nId, (ULONG)pUserAttributes ); SetItemCommand( nId, aURL ); diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx index 2fe47689ec0b..01c23211833e 100644 --- a/framework/source/classes/menumanager.cxx +++ b/framework/source/classes/menumanager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: menumanager.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: cd $ $Date: 2002-04-09 12:58:04 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:45:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -231,7 +231,10 @@ MenuManager::MenuManager( REFERENCE< XFRAME >& rFrame, Menu* pMenu, sal_Bool bDe m_bIsBookmarkMenu = sal_False; SAL_STATIC_CAST( ::com::sun::star::uno::XInterface*, (OWeakObject*)this )->acquire(); - SvtMenuOptions aOptions; + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + m_bWasHiContrast = rSettings.GetMenuColor().IsDark(); + m_bShowMenuImages = SvtMenuOptions().IsMenuIconsEnabled(); + ::std::vector< USHORT > aQueryLabelItemIdVector; int nItemCount = pMenu->GetItemCount(); @@ -302,9 +305,9 @@ MenuManager::MenuManager( REFERENCE< XFRAME >& rFrame, Menu* pMenu, sal_Bool bDe } else if ( pMenu->GetItemType( i ) != MENUITEM_SEPARATOR ) { - if ( aOptions.IsMenuIconsEnabled() ) + if ( m_bShowMenuImages ) { - Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE ); + Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE, m_bWasHiContrast ); if ( !!aImage ) pMenu->SetItemImage( nItemId, aImage ); } @@ -357,6 +360,10 @@ MenuManager::MenuManager( REFERENCE< XFRAME >& rFrame, BmkMenu* pBmkMenu, sal_Bo m_xFrame = rFrame; m_bInitialized = sal_False; m_bIsBookmarkMenu = sal_True; + + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + m_bWasHiContrast = rSettings.GetMenuColor().IsDark(); + SAL_STATIC_CAST( ::com::sun::star::uno::XInterface*, (OWeakObject*)this )->acquire(); int nItemCount = pBmkMenu->GetItemCount(); @@ -397,10 +404,8 @@ MenuManager::MenuManager( REFERENCE< XFRAME >& rFrame, BmkMenu* pBmkMenu, sal_Bo if ( pBmkAttributes ) { - // read additional attributes from attributes struct and delete it afterwards + // read additional attributes from attributes struct and BmkMenu implementation will delete all attributes itself!! pMenuItemHandler->aTargetFrame = pBmkAttributes->aTargetFrame; - delete pBmkAttributes; - pBmkMenu->SetUserValue( nItemId, 0 ); } m_aMenuItemHandlerVector.push_back( pMenuItemHandler ); @@ -874,7 +879,8 @@ IMPL_LINK( MenuManager, Activate, Menu *, pMenu ) if ( pMenu == m_pVCLMenu ) { // set/unset hiding disabled menu entries - sal_Bool bDontHide = SvtMenuOptions().IsEntryHidingEnabled(); + sal_Bool bDontHide = SvtMenuOptions().IsEntryHidingEnabled(); + sal_Bool bShowMenuImages = SvtMenuOptions().IsMenuIconsEnabled(); sal_uInt16 nFlag = pMenu->GetMenuFlags(); if ( bDontHide ) @@ -895,6 +901,51 @@ IMPL_LINK( MenuManager, Activate, Menu *, pMenu ) m_aMenuItemCommand == aSlotSpecialWindowMenu ) UpdateSpecialWindowMenu( pMenu ); + // Check if some modes have changed so we have to update our menu images + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + sal_Bool bIsHiContrast = rSettings.GetMenuColor().IsDark(); + + if ( m_bWasHiContrast != bIsHiContrast || bShowMenuImages != m_bShowMenuImages ) + { + // The mode changed so we have to replace all images + m_bWasHiContrast = bIsHiContrast; + m_bShowMenuImages = bShowMenuImages; + + for ( USHORT nPos = 0; nPos < pMenu->GetItemCount(); nPos++ ) + { + USHORT nId = pMenu->GetItemId( nPos ); + if ( pMenu->GetItemType( nPos ) != MENUITEM_SEPARATOR ) + { + if ( bShowMenuImages ) + { + sal_Bool bImageSet = sal_False; + ::rtl::OUString aImageId; + + ::framework::MenuConfiguration::Attributes* pMenuAttributes = + (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( nId ); + + if ( pMenuAttributes ) + aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes + + if ( aImageId.getLength() > 0 ) + { + Image aImage = GetImageFromURL( m_xFrame, aImageId, FALSE, bIsHiContrast ); + if ( !!aImage ) + { + bImageSet = sal_True; + pMenu->SetItemImage( nId, aImage ); + } + } + + if ( !bImageSet ) + pMenu->SetItemImage( nId, GetImageFromURL( m_xFrame, pMenu->GetItemCommand( nId ), FALSE, bIsHiContrast ) ); + } + else + pMenu->SetItemImage( nId, Image() ); + } + } + } + if ( m_bInitialized ) return 0; else diff --git a/framework/source/helper/imageproducer.cxx b/framework/source/helper/imageproducer.cxx index 53e64499615d..d15f65c715e9 100644 --- a/framework/source/helper/imageproducer.cxx +++ b/framework/source/helper/imageproducer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: imageproducer.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mba $ $Date: 2001-05-03 17:04:14 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:46:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,10 +75,10 @@ pfunc_getImage SAL_CALL SetImageProducer( pfunc_getImage pNewGetImageFunc ) } -Image SAL_CALL GetImageFromURL( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig ) +Image SAL_CALL GetImageFromURL( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast ) { if ( _pGetImageFunc ) - return _pGetImageFunc( rFrame, aURL, bBig ); + return _pGetImageFunc( rFrame, aURL, bBig, bHiContrast ); else return Image(); } |