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 | 2508692afb68a0f3422ad133c47958d3f19357f1 (patch) | |
tree | 95cee2bd1081ac5d52d404a0b9263fa8e92fe8f8 /sfx2/source | |
parent | a634d777571206e74df606041cd2cef6c978daa7 (diff) |
#98598# High contrast support for toolboxes and menus
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/imagemgr.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/appl/module.cxx | 34 | ||||
-rw-r--r-- | sfx2/source/inc/virtmenu.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/menu/mnuitem.cxx | 83 | ||||
-rw-r--r-- | sfx2/source/menu/virtmenu.cxx | 76 | ||||
-rw-r--r-- | sfx2/source/toolbox/imgmgr.cxx | 540 | ||||
-rw-r--r-- | sfx2/source/toolbox/tbxitem.cxx | 80 |
7 files changed, 605 insertions, 227 deletions
diff --git a/sfx2/source/appl/imagemgr.cxx b/sfx2/source/appl/imagemgr.cxx index e48d4c38e3..88e704e189 100644 --- a/sfx2/source/appl/imagemgr.cxx +++ b/sfx2/source/appl/imagemgr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: imagemgr.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mba $ $Date: 2001-09-18 15:45:56 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:39:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,7 +89,7 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -Image SAL_CALL GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig ) +Image SAL_CALL GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast ) { INetURLObject aObj( aURL ); INetProtocol nProtocol = aObj.GetProtocol(); @@ -142,10 +142,10 @@ Image SAL_CALL GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::fra if ( nId ) { if ( pViewFrame ) - return pViewFrame->GetImageManager()->GetImage( nId, pModule, bBig ); + return pViewFrame->GetImageManager()->GetImage( nId, pModule, bBig, bHiContrast ); else { - return SFX_APP()->GetImageManager_Impl()->GetImage( nId, NULL, bBig ); + return SFX_APP()->GetImageManager_Impl()->GetImage( nId, NULL, bBig, bHiContrast ); } } break; @@ -158,6 +158,6 @@ Image SAL_CALL GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::fra } } - return SvFileInformationManager::GetImageNoDefault( aObj, bBig ); + return SvFileInformationManager::GetImageNoDefault( aObj, bBig, bHiContrast ); } diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index e854d69f00..61f8213880 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -2,9 +2,9 @@ * * $RCSfile: module.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dv $ $Date: 2001-07-12 07:42:35 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:40:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,7 @@ #pragma hdrstop +#include <stdio.h> #include <tools/rcid.h> #include <cstdarg> @@ -95,10 +96,12 @@ public: SfxChildWinFactArr_Impl* pFactArr; ImageList* pImgListSmall; ImageList* pImgListBig; + ImageList* pImgListHiSmall; + ImageList* pImgListHiBig; SfxModule_Impl(); ~SfxModule_Impl(); - ImageList* GetImageList( ResMgr*, BOOL ); + ImageList* GetImageList( ResMgr*, BOOL, BOOL bHiContrast = FALSE ); }; SfxModule_Impl::SfxModule_Impl() @@ -115,14 +118,18 @@ SfxModule_Impl::~SfxModule_Impl() delete pFactArr; delete pImgListSmall; delete pImgListBig; + delete pImgListHiSmall; + delete pImgListHiBig; } -ImageList* SfxModule_Impl::GetImageList( ResMgr* pResMgr, BOOL bBig ) +ImageList* SfxModule_Impl::GetImageList( ResMgr* pResMgr, BOOL bBig, BOOL bHiContrast ) { - ImageList*& rpList = bBig ? pImgListBig : pImgListSmall; + ImageList*& rpList = bBig ? ( bHiContrast ? pImgListHiBig: pImgListBig ) : + ( bHiContrast ? pImgListHiSmall : pImgListSmall ); if ( !rpList ) { - ResId aResId( bBig ? RID_DEFAULTIMAGELIST_LC : RID_DEFAULTIMAGELIST_SC, pResMgr ); + ResId aResId( bBig ? ( bHiContrast ? RID_DEFAULTIMAGELIST_LCH : RID_DEFAULTIMAGELIST_LC ) : + ( bHiContrast ? RID_DEFAULTIMAGELIST_SCH : RID_DEFAULTIMAGELIST_SC ), pResMgr ); aResId.SetRT( RSC_IMAGELIST ); DBG_ASSERT( pResMgr->IsAvailable(aResId), "No default ImageList!" ); @@ -131,6 +138,12 @@ ImageList* SfxModule_Impl::GetImageList( ResMgr* pResMgr, BOOL bBig ) rpList = new ImageList( aResId ); else rpList = new ImageList(); + + // Testcode!!! + char temp[128]; + sprintf( temp, "g:\\imagelist_m%d%d.bmp", bBig ? 1 : 0, bHiContrast ? 1: 0 ); + SvFileStream aBitmapStream( String::CreateFromAscii( temp ), STREAM_STD_WRITE); + aBitmapStream << rpList->GetBitmap(); } return rpList; @@ -259,6 +272,8 @@ void SfxModule::Construct_Impl() pImpl->pFactArr=0; pImpl->pImgListSmall=0; pImpl->pImgListBig=0; + pImpl->pImgListHiSmall=0; + pImpl->pImgListHiBig=0; SetPool( &pApp->GetPool() ); } @@ -441,7 +456,12 @@ SfxChildWinFactArr_Impl* SfxModule::GetChildWinFactories_Impl() const ImageList* SfxModule::GetImageList_Impl( BOOL bBig ) { - return pImpl->GetImageList( pResMgr, bBig ); + return pImpl->GetImageList( pResMgr, bBig, FALSE ); +} + +ImageList* SfxModule::GetImageList_Impl( BOOL bBig, BOOL bHiContrast ) +{ + return pImpl->GetImageList( pResMgr, bBig, bHiContrast ); } SfxTabPage* SfxModule::CreateTabPage( USHORT nId, Window* pParent, const SfxItemSet& rSet ) diff --git a/sfx2/source/inc/virtmenu.hxx b/sfx2/source/inc/virtmenu.hxx index 9d021cdd09..904e6a8639 100644 --- a/sfx2/source/inc/virtmenu.hxx +++ b/sfx2/source/inc/virtmenu.hxx @@ -2,9 +2,9 @@ * * $RCSfile: virtmenu.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: mba $ $Date: 2001-07-02 15:35:52 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:40:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,6 +101,7 @@ private: BOOL bHelpInitialized : 1; BOOL bIsActive : 1; BOOL bControllersUnBound : 1; + BOOL bWasHighContrast : 1; private: void Construct_Impl(); @@ -155,6 +156,8 @@ public: void SetResMgr(ResMgr* pMgr) {pResMgr = pMgr; } ResMgr* GetResMgr() { return pResMgr; } void SetHelpIds( ResMgr* ); + BOOL IsHiContrastMode() const; + void UpdateImages(); DECL_LINK( Select, Menu * ); }; diff --git a/sfx2/source/menu/mnuitem.cxx b/sfx2/source/menu/mnuitem.cxx index aff6064abe..3da7c17e72 100644 --- a/sfx2/source/menu/mnuitem.cxx +++ b/sfx2/source/menu/mnuitem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: mnuitem.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mba $ $Date: 2002-03-19 17:18:36 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:41:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,12 +89,21 @@ #include <comphelper/processfactory.hxx> #endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif #ifndef _SFXENUMITEM_HXX //autogen #include <svtools/eitem.hxx> #endif #ifndef _SFXSTRITEM_HXX //autogen #include <svtools/stritem.hxx> #endif +#ifndef _SVTOOLS_IMAGEMGR_HXX +#include <svtools/imagemgr.hxx> +#endif +#ifndef INCLUDED_SVTOOLS_MENUOPTIONS_HXX +#include <svtools/menuoptions.hxx> +#endif #include <framework/menuconfiguration.hxx> #pragma hdrstop @@ -115,13 +124,14 @@ #include "module.hxx" #include "unoctitm.hxx" #include "viewfrm.hxx" +#include "imgmgr.hxx" +#include "imagemgr.hxx" using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::util; - //==================================================================== class SfxEnumMenu: public PopupMenu @@ -490,6 +500,12 @@ SfxAppMenuControl_Impl::SfxAppMenuControl_Impl( String aText = rMenu.GetItemText( nPos ); SfxApplication* pApp = SFX_APP(); SfxAppData_Impl* pImpl = pApp->Get_Impl(); + + // Determine the current background color setting for menus + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + BOOL bIsHiContrastMode = rSettings.GetMenuColor().IsDark(); + m_bWasHiContrastMode = bIsHiContrastMode; + m_bShowMenuImages = SvtMenuOptions().IsMenuIconsEnabled(); Reference<com::sun::star::lang::XMultiServiceFactory> aXMultiServiceFactory(::comphelper::getProcessServiceFactory()); ::framework::MenuConfiguration aConf( aXMultiServiceFactory ); @@ -498,6 +514,7 @@ SfxAppMenuControl_Impl::SfxAppMenuControl_Impl( if( pMenu ) { pMenu->SetSelectHdl( Link( this, Select_Impl ) ); + pMenu->SetActivateHdl( LINK(this, SfxAppMenuControl_Impl, Activate) ); rMenu.SetPopupMenu( nPos, pMenu ); } } @@ -507,6 +524,66 @@ SfxAppMenuControl_Impl::~SfxAppMenuControl_Impl() delete pMenu; } +IMPL_LINK( SfxAppMenuControl_Impl, Activate, Menu *, pMenu ) +{ + if ( pMenu ) + { + BOOL bShowMenuImages = SvtMenuOptions().IsMenuIconsEnabled(); + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + BOOL bIsHiContrastMode = rSettings.GetMenuColor().IsDark(); + + if (( bIsHiContrastMode != m_bWasHiContrastMode ) || + ( bShowMenuImages != m_bShowMenuImages ) ) + { + m_bWasHiContrastMode = bIsHiContrastMode; + m_bShowMenuImages = bShowMenuImages; + + USHORT nCount = pMenu->GetItemCount(); + for ( USHORT nSVPos = 0; nSVPos < nCount; nSVPos++ ) + { + USHORT nId = pMenu->GetItemId( nSVPos ); + if ( pMenu->GetItemType( nSVPos ) != 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 = GetImage( Reference< ::com::sun::star::frame::XFrame >(), aImageId, FALSE, bIsHiContrastMode ); + if ( !!aImage ) + { + bImageSet = sal_True; + pMenu->SetItemImage( nId, aImage ); + } + } + + String aCmd( pMenu->GetItemCommand( nId ) ); + if ( !bImageSet && aCmd.Len() ) + { + Image aImage = SvFileInformationManager::GetImage( aCmd, FALSE, bIsHiContrastMode ); + if ( !!aImage ) + pMenu->SetItemImage( nId, aImage ); + } + } + else + pMenu->SetItemImage( nId, Image() ); + } + } + } + + return TRUE; + } + + return FALSE; +} + SfxUnoMenuControl* SfxMenuControl::CreateControl( const String& rCmd, USHORT nId, Menu& rMenu, SfxBindings &rBindings, SfxVirtualMenu* pVirt ) { diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx index 4995910ba6..73340eb237 100644 --- a/sfx2/source/menu/virtmenu.cxx +++ b/sfx2/source/menu/virtmenu.cxx @@ -2,9 +2,9 @@ * * $RCSfile: virtmenu.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: mba $ $Date: 2001-09-19 07:58:19 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:41:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,9 @@ #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> #endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif #pragma hdrstop @@ -172,7 +175,8 @@ SfxVirtualMenu::SfxVirtualMenu( USHORT nOwnId, pItems(0), pBindings(&rBindings), pResMgr(0), - nLocks(0), pAutoDeactivate(0), bHelpInitialized( bWithHelp ) + nLocks(0), pAutoDeactivate(0), bHelpInitialized( bWithHelp ), + bWasHighContrast( FALSE ) { DBG_MEMTEST(); DBG_CTOR(SfxVirtualMenu, 0); @@ -198,7 +202,8 @@ SfxVirtualMenu::SfxVirtualMenu( Menu *pStarViewMenu, BOOL bWithHelp, pItems(0), pBindings(&rBindings), pResMgr(0), - nLocks(0), pAutoDeactivate(0), bHelpInitialized( bWithHelp ) + nLocks(0), pAutoDeactivate(0), bHelpInitialized( bWithHelp ), + bWasHighContrast( FALSE ) { DBG_MEMTEST(); DBG_CTOR(SfxVirtualMenu, 0); @@ -283,6 +288,17 @@ SfxVirtualMenu::~SfxVirtualMenu() } //-------------------------------------------------------------------- +BOOL SfxVirtualMenu::IsHiContrastMode() const +{ + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + Color aMenuColor = rSettings.GetMenuColor(); + if ( aMenuColor.IsDark() ) + return TRUE; + else + return FALSE; +} + +//-------------------------------------------------------------------- // internal: creates the virtual menu from the pSVMenu void SfxVirtualMenu::CreateFromSVMenu() @@ -310,6 +326,10 @@ void SfxVirtualMenu::CreateFromSVMenu() // iterate through the items pBindings->ENTERREGISTRATIONS(); ++nLocks; + + // Update high contrast state + bWasHighContrast = IsHiContrastMode(); + USHORT nSVPos = 0; for ( USHORT nPos = 0; nPos < nCount; ++nPos, ++nSVPos ) { @@ -347,7 +367,7 @@ void SfxVirtualMenu::CreateFromSVMenu() pSVMenu->GetHelpText(nId), *pBindings); if ( aOptions.IsMenuIconsEnabled() ) - pSVMenu->SetItemImage( nId, pBindings->GetImageManager()->GetImage( nId, pModule, FALSE ) ); + pSVMenu->SetItemImage( nId, pBindings->GetImageManager()->GetImage( nId, pModule, FALSE, bWasHighContrast ) ); } else { @@ -401,7 +421,7 @@ void SfxVirtualMenu::CreateFromSVMenu() if ( aCmd.Len() ) { if ( aOptions.IsMenuIconsEnabled() ) - pSVMenu->SetItemImage( nId, SvFileInformationManager::GetImage( aCmd, FALSE ) ); + pSVMenu->SetItemImage( nId, SvFileInformationManager::GetImage( aCmd, FALSE, bWasHighContrast ) ); pMnuCtrl = SfxMenuControl::CreateControl( aCmd, nId, *pSVMenu, *pBindings, this ); if ( pMnuCtrl ) @@ -440,7 +460,7 @@ void SfxVirtualMenu::CreateFromSVMenu() // if ( !pSVMenu->GetPopupMenu( nId ) && aOptions.IsMenuIconsEnabled() ) if ( aOptions.IsMenuIconsEnabled() ) - pSVMenu->SetItemImage( nId, pBindings->GetImageManager()->GetImage( nId, pModule, FALSE ) ); + pSVMenu->SetItemImage( nId, pBindings->GetImageManager()->GetImage( nId, pModule, FALSE, bWasHighContrast ) ); } if ( !IsItemHidden_Impl(nId, bOleServer, bMac) ) @@ -491,6 +511,7 @@ IMPL_LINK( SfxVirtualMenu, SettingsChanged, void*, pVoid ) SfxViewFrame *pViewFrame = pBindings->GetDispatcher()->GetFrame(); SfxModule* pModule = pViewFrame->GetObjectShell()->GetModule(); BOOL bIcons = aOptions.IsMenuIconsEnabled(); + BOOL bIsHiContrastMode = IsHiContrastMode(); for ( USHORT nSVPos=0; nSVPos<nCount; ++nSVPos ) { @@ -500,9 +521,9 @@ IMPL_LINK( SfxVirtualMenu, SettingsChanged, void*, pVoid ) { String aCmd( pSVMenu->GetItemCommand( nId ) ); if ( aCmd.Len() ) - pSVMenu->SetItemImage( nId, SvFileInformationManager::GetImage( aCmd, FALSE ) ); + pSVMenu->SetItemImage( nId, SvFileInformationManager::GetImage( aCmd, FALSE, bIsHiContrastMode ) ); else - pSVMenu->SetItemImage( nId, pBindings->GetImageManager()->GetImage( nId, pModule, FALSE ) ); + pSVMenu->SetItemImage( nId, pBindings->GetImageManager()->GetImage( nId, pModule, FALSE, bIsHiContrastMode ) ); } else if( pSVMenu->GetItemType( nSVPos ) == MENUITEM_STRINGIMAGE && !bIcons ) { @@ -515,6 +536,36 @@ IMPL_LINK( SfxVirtualMenu, SettingsChanged, void*, pVoid ) //-------------------------------------------------------------------- +void SfxVirtualMenu::UpdateImages() +{ + SvtMenuOptions aOptions; + BOOL bIcons = aOptions.IsMenuIconsEnabled(); + + if ( bIcons ) + { + BOOL bIsHiContrastMode = IsHiContrastMode(); + USHORT nCount = pSVMenu->GetItemCount(); + SfxViewFrame * pViewFrame = pBindings->GetDispatcher()->GetFrame(); + SfxModule* pModule = pViewFrame->GetObjectShell()->GetModule(); + + for ( USHORT nSVPos=0; nSVPos < nCount; ++nSVPos ) + { + USHORT nId = pSVMenu->GetItemId( nSVPos ); + PopupMenu* pPopup = pSVMenu->GetPopupMenu( nId ); + if ( pSVMenu->GetItemType( nSVPos ) == MENUITEM_STRINGIMAGE ) + { + String aCmd( pSVMenu->GetItemCommand( nId ) ); + if ( aCmd.Len() ) + pSVMenu->SetItemImage( nId, SvFileInformationManager::GetImage( aCmd, FALSE, bIsHiContrastMode ) ); + else + pSVMenu->SetItemImage( nId, pBindings->GetImageManager()->GetImage( nId, pModule, FALSE, bIsHiContrastMode ) ); + } + } + } +} + +//-------------------------------------------------------------------- + FASTBOOL SfxVirtualMenu::Bind_Impl( Menu *pMenu ) { // Selber suchen, da SV mit 'USHORT nSID = pSVMenu->GetCurItemId();' immer @@ -756,6 +807,13 @@ IMPL_LINK( SfxVirtualMenu, Activate, Menu *, pMenu ) if ( pAutoDeactivate ) // QAP-Hack pAutoDeactivate->Start(); + if ( IsHiContrastMode() != bWasHighContrast ) + { + // Refresh images as our background color changed and remember it!! + bWasHighContrast = IsHiContrastMode(); + UpdateImages(); + } + // erledigt return TRUE; } diff --git a/sfx2/source/toolbox/imgmgr.cxx b/sfx2/source/toolbox/imgmgr.cxx index f8aa196221..7f47067de3 100644 --- a/sfx2/source/toolbox/imgmgr.cxx +++ b/sfx2/source/toolbox/imgmgr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: imgmgr.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: cd $ $Date: 2002-02-22 08:09:54 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:42:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,8 @@ * ************************************************************************/ +#include <stdio.h> + #ifndef _STREAM_HXX //autogen #include <tools/stream.hxx> #endif @@ -108,16 +110,18 @@ class SfxBitmapList_Impl; class SfxImageManager_Impl : public SfxConfigItem { public: - LinkList aList; - SvtMiscOptions aOpt; - SfxBitmapList_Impl* pUserDefList; - ImageList* pUserImageList; - - void MakeDefaultImageList(); + LinkList m_aList; + SvtMiscOptions m_aOpt; + SfxBitmapList_Impl* m_pUserDefList; + ImageList* m_pUserImageList; + ImageList* m_pHCUserImageList; + int m_nUserRef; + + void MakeDefaultImageList( BOOL bHiContrast = FALSE ); void MakeUserList(); void RebuildUserList(); - Image GetImage( USHORT nId, SfxModule*, BOOL ) const; - Image SeekImage(USHORT nId, SfxModule* pModule ) const; + Image GetImage( USHORT nId, SfxModule*, BOOL bBig, BOOL bHiContrast ) const; + Image SeekImage(USHORT nId, SfxModule* pModule, BOOL bHiContrast ) const; virtual BOOL ReInitialize(); int Load( SvStream& ); @@ -137,8 +141,12 @@ public: // elements common to all ImageManager instances static ImageList* pImageListSmall=0; static ImageList* pImageListBig=0; -static ImageList* pOffImageList; +static ImageList* pImageListHiSmall=0; +static ImageList* pImageListHiBig=0; +//static ImageList* pOffImageList; +//static ImageList* pOffHiImageList; static ImageList* pImageList; +static ImageList* pHiImageList; static SfxImageManager_Impl* pGlobalConfig=NULL; static nRef=0; static nGlobalRef=0; @@ -146,13 +154,17 @@ static nGlobalRef=0; // we need a static list of all pImp instances, so all operations that should change all instances can be performed // which operations ?! -ImageList* GetImageList( BOOL bBig ) +ImageList* GetImageList( BOOL bBig, BOOL bHiContrast = FALSE ) { - ImageList*& rpList = bBig ? pImageListBig : pImageListSmall; + // Has to be changed if we know how the IDs are named!!! + ImageList*& rpList = bBig ? ( bHiContrast ? pImageListHiBig : pImageListBig ) : + ( bHiContrast ? pImageListHiSmall : pImageListSmall ); if ( !rpList ) { ResMgr *pResMgr = Resource::GetResManager(); - ResId aResId( bBig ? RID_DEFAULTIMAGELIST_LC : RID_DEFAULTIMAGELIST_SC ); + ResId aResId( bBig ? ( bHiContrast ? RID_DEFAULTIMAGELIST_LCH : RID_DEFAULTIMAGELIST_LC ) : + ( bHiContrast ? RID_DEFAULTIMAGELIST_SCH : RID_DEFAULTIMAGELIST_SC )); + aResId.SetRT( RSC_IMAGELIST ); DBG_ASSERT( pResMgr->IsAvailable(aResId), "No default ImageList!" ); @@ -161,6 +173,12 @@ ImageList* GetImageList( BOOL bBig ) rpList = new ImageList( aResId ); else rpList = new ImageList(); + + // Testcode!!! + char temp[128]; + sprintf( temp, "g:\\imagelist%d%d.bmp", bBig ? 1 : 0, bHiContrast ? 1: 0 ); + SvFileStream aBitmapStream( String::CreateFromAscii( temp ), STREAM_STD_WRITE); + aBitmapStream << rpList->GetBitmap(); } return rpList; @@ -367,8 +385,9 @@ SvStream& operator << (SvStream& rStream, const SfxBitmapList_Impl& rList) SfxImageManager_Impl::SfxImageManager_Impl( SfxConfigManager* pCfgMgr ) : SfxConfigItem( SFX_ITEMTYPE_IMAGELIST, pCfgMgr ) - , pUserImageList( 0 ) - , pUserDefList( 0 ) + , m_pUserDefList( 0 ) + , m_pUserImageList( 0 ) + , m_pHCUserImageList( 0 ) { // SetInternal( TRUE ); Initialize(); @@ -376,24 +395,26 @@ SfxImageManager_Impl::SfxImageManager_Impl( SfxConfigManager* pCfgMgr ) SfxImageManager_Impl::~SfxImageManager_Impl() { - delete pUserDefList; - delete pUserImageList; + delete m_pUserDefList; + delete m_pUserImageList; + delete m_pHCUserImageList; + if ( this == pGlobalConfig ) pGlobalConfig = NULL; } void SfxImageManager_Impl::AddLink( const Link& rLink ) { - aList.Insert( new Link( rLink ) ); + m_aList.Insert( new Link( rLink ) ); } void SfxImageManager_Impl::RemoveLink( const Link& rLink ) { - for ( USHORT n=0; n<aList.Count(); n++ ) + for ( USHORT n=0; n<m_aList.Count(); n++ ) { - if ( (*aList.GetObject(n) ) == rLink ) + if ( (*m_aList.GetObject(n) ) == rLink ) { - delete aList.Remove(n); + delete m_aList.Remove(n); break; } } @@ -458,7 +479,9 @@ int SfxImageManager_Impl::Load( SotStorage& rStorage ) return ERR_READ; Bitmap aBmp; + Bitmap aHCBmp; LoadBitmap( aBmp, rStorage, pList->aURL ); + LoadBitmap( aHCBmp, rStorage, pList->aHighContrastURL ); // get the Ids of the ImageList USHORT* pIds = new USHORT[nCount]; @@ -477,18 +500,25 @@ int SfxImageManager_Impl::Load( SotStorage& rStorage ) } } - delete pUserImageList; + delete m_pUserImageList; + delete m_pHCUserImageList; + if ( pList->nMaskMode = ::framework::ImageMaskMode_Color ) - pUserImageList = new ImageList( aBmp, pList->aMaskColor, nCount, pIds ); + { + m_pUserImageList = new ImageList( aBmp, pList->aMaskColor, nCount, pIds ); + m_pHCUserImageList = new ImageList( aHCBmp, pList->aMaskColor, nCount, pIds ); + } else { Bitmap aMask; LoadBitmap( aMask, rStorage, pList->aMaskURL ); - pUserImageList = new ImageList( aBmp, aMask, nCount, pIds ); + m_pUserImageList = new ImageList( aBmp, aMask, nCount, pIds ); + LoadBitmap( aMask, rStorage, pList->aHighContrastMaskURL ); + m_pHCUserImageList = new ImageList( aHCBmp, aMask, nCount, pIds ); } DELETEZ( pIds ); - pUserDefList = new SfxBitmapList_Impl; + m_pUserDefList = new SfxBitmapList_Impl; nCount = aDescriptor.pExternalImageList ? aDescriptor.pExternalImageList->Count() : 0; for ( USHORT n=0; n<nCount; n++ ) @@ -508,7 +538,7 @@ int SfxImageManager_Impl::Load( SotStorage& rStorage ) Bitmap aBmp; LoadBitmap( aBmp, rStorage, pItem->aURL ); - pUserDefList->AddBitmap( nId, aBmp ); + m_pUserDefList->AddBitmap( nId, aBmp ); } } @@ -536,11 +566,11 @@ BOOL SfxImageManager_Impl::Store( SotStorage& rStorage ) // bitmaps are stored in an internal bitmap directory SotStorageRef xBitmapStorage = rStorage.OpenSotStorage( String::CreateFromAscii("Bitmaps"), STREAM_STD_READWRITE ); - if ( pUserImageList->HasMaskColor() ) + if ( m_pUserImageList->HasMaskColor() ) { // mask color pList->nMaskMode = ::framework::ImageMaskMode_Color; - pList->aMaskColor = pUserImageList->GetMaskColor(); + pList->aMaskColor = m_pUserImageList->GetMaskColor(); } else { @@ -553,17 +583,25 @@ BOOL SfxImageManager_Impl::Store( SotStorage& rStorage ) // store bitmap SotStorageStreamRef xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC ); - *xBitmapStream << pUserImageList->GetMaskBitmap(); + *xBitmapStream << m_pUserImageList->GetMaskBitmap(); + + pList->aHighContrastMaskURL = String::CreateFromAscii( "Bitmaps/" ); + aStreamName = String::CreateFromAscii( "hcuserimagesmask.bmp" ); + pList->aHighContrastMaskURL += aStreamName; + + // store bitmap + xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC ); + *xBitmapStream << m_pHCUserImageList->GetMaskBitmap(); } // a modified list always contains a userlist pList->pImageItemList = new ::framework::ImageItemListDescriptor; - for ( USHORT i=0; i<pUserImageList->GetImageCount(); i++ ) + for ( USHORT i=0; i<m_pUserImageList->GetImageCount(); i++ ) { ::framework::ImageItemDescriptor* pItem = new ::framework::ImageItemDescriptor; pItem->nIndex = i; - USHORT nId = pUserImageList->GetImageId(i); + USHORT nId = m_pUserImageList->GetImageId(i); if ( SfxMacroConfig::IsMacroSlot( nId ) ) { const SfxMacroInfo* pInfo = pCfg->GetMacroInfo( nId ); @@ -585,17 +623,26 @@ BOOL SfxImageManager_Impl::Store( SotStorage& rStorage ) // store bitmap SotStorageStreamRef xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC ); - *xBitmapStream << pUserImageList->GetBitmap(); + *xBitmapStream << m_pUserImageList->GetBitmap(); + + // store high contrast URL of bitmap relative to configuration storage; name is "BitmapXXX.bmp", where XXX is an index + pList->aHighContrastURL = String::CreateFromAscii("Bitmaps/"); + aStreamName = String::CreateFromAscii("hcuserimages.bmp"); + pList->aHighContrastURL += aStreamName; + + // store high contrast bitmap + xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC ); + *xBitmapStream << m_pHCUserImageList->GetBitmap(); // collect all external bitmaps - USHORT nCount = pUserDefList->GetBitmapCount(); + USHORT nCount = m_pUserDefList->GetBitmapCount(); if ( nCount ) { aDescriptor.pExternalImageList = new ::framework::ExternalImageItemListDescriptor; for ( USHORT i=0; i<nCount; i++ ) { ::framework::ExternalImageItemDescriptor* pItem = new ::framework::ExternalImageItemDescriptor; - USHORT nId = pUserDefList->GetBitmapId(i); + USHORT nId = m_pUserDefList->GetBitmapId(i); if ( SfxMacroConfig::IsMacroSlot( nId ) ) { const SfxMacroInfo* pInfo = pCfg->GetMacroInfo( nId ); @@ -618,7 +665,7 @@ BOOL SfxImageManager_Impl::Store( SotStorage& rStorage ) // store bitmap SotStorageStreamRef xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC ); - *xBitmapStream << *pUserDefList->GetBitmap( nId ); + *xBitmapStream << *m_pUserDefList->GetBitmap( nId ); } } @@ -644,8 +691,8 @@ int SfxImageManager_Impl::Load(SvStream& rStream) MakeUserList(); // Userdef-Listen einlesen - rStream >> *pUserImageList; - rStream >> *pUserDefList; + rStream >> *m_pUserImageList; + rStream >> *m_pUserDefList; if ( nColorCount != Application::GetDefaultDevice()->GetColorCount() ) RebuildUserList(); @@ -661,8 +708,8 @@ BOOL SfxImageManager_Impl::ReInitialize() { BOOL bRet = SfxConfigItem::ReInitialize(); if ( bRet ) - for ( USHORT n=0; n<aList.Count(); n++ ) - aList.GetObject(n)->Call( this ); + for ( USHORT n=0; n<m_aList.Count(); n++ ) + m_aList.GetObject(n)->Call( this ); return bRet; } @@ -675,11 +722,11 @@ BOOL SfxImageManager_Impl::Store(SvStream& rStream) // aBitmapStream << pUserImageList->GetBitmap(); rStream << nVersion - << aOpt.GetSymbolSet() + << m_aOpt.GetSymbolSet() << Application::GetDefaultDevice()->GetColorCount(); - rStream << *pUserImageList; - rStream << *pUserDefList; + rStream << *m_pUserImageList; + rStream << *m_pUserDefList; return TRUE; } @@ -704,32 +751,42 @@ String SfxImageManager_Impl::GetStreamName() const void SfxImageManager_Impl::MakeUserList() { - if ( pUserImageList ) + if ( m_pUserImageList ) { - DELETEZ( pUserImageList ); - DELETEZ( pUserDefList ); + DELETEZ( m_pUserImageList ); + DELETEZ( m_pHCUserImageList ); + DELETEZ( m_pUserDefList ); } - pUserDefList = new SfxBitmapList_Impl; - pUserImageList = new ImageList; + m_pUserDefList = new SfxBitmapList_Impl; + m_pUserImageList = new ImageList; + m_pHCUserImageList = new ImageList; } //------------------------------------------------------------------------- -void SfxImageManager_Impl::MakeDefaultImageList() +void SfxImageManager_Impl::MakeDefaultImageList( BOOL bHiContrast ) { USHORT nType=0; - switch ( aOpt.GetSymbolSet() ) { - case SFX_SYMBOLS_SMALL: - pImageList = GetImageList( FALSE ); - break; - case SFX_SYMBOLS_LARGE: - pImageList = GetImageList( TRUE ); - break; - default: - DBG_ERROR("Unknown Symboltype!"); - break; + switch ( m_aOpt.GetSymbolSet() ) + { + case SFX_SYMBOLS_SMALL: + if ( bHiContrast ) + pHiImageList = GetImageList( FALSE, TRUE ); + else + pImageList = GetImageList( FALSE, FALSE ); + break; + case SFX_SYMBOLS_LARGE: + if ( bHiContrast ) + pHiImageList = GetImageList( TRUE, TRUE ); + else + pImageList = GetImageList( TRUE, FALSE ); + break; + default: + DBG_ERROR("Unknown Symboltype!"); + break; + } } } @@ -751,18 +808,21 @@ void SfxImageManager_Impl::RebuildUserList() VirtualDevice aDev; Size aNewSize = pImageList->GetImageSize(); aDev.SetOutputSizePixel(aNewSize); - - ImageList *pOldList = pUserImageList; - pUserImageList = new ImageList( pOldList->GetImageCount() ); + + ImageList *pOldList = m_pUserImageList; + ImageList *pOldHCList = m_pHCUserImageList; + m_pUserImageList = new ImageList( pOldList->GetImageCount() ); + m_pHCUserImageList = new ImageList( pOldHCList->GetImageCount() ); + for ( USHORT i=0; i<pOldList->GetImageCount(); i++ ) { USHORT nId = pOldList->GetImageId( i ); Image aImage; // Image benutzerdefiniert ? - if ( pUserDefList->GetBitmapPos(nId) != USHRT_MAX ) + if ( m_pUserDefList->GetBitmapPos(nId) != USHRT_MAX ) { - Bitmap *pBmp = pUserDefList->GetBitmap( nId ); + Bitmap *pBmp = m_pUserDefList->GetBitmap( nId ); if ( pBmp->GetSizePixel() != aNewSize ) { aDev.DrawBitmap( Point(), aNewSize, *pBmp ); @@ -770,51 +830,82 @@ void SfxImageManager_Impl::RebuildUserList() } else aImage = Image( *pBmp, aColor ); + + if ( aImage.GetSizePixel() == aNewSize ) + { + m_pUserImageList->AddImage( nId, aImage ); + m_pHCUserImageList->AddImage( nId, aImage ); // user images are always used as non high contrast + } } else - aImage = SeekImage( nId, NULL ); - - if ( aImage.GetSizePixel() == aNewSize ) - pUserImageList->AddImage( nId, aImage ); + { + aImage = SeekImage( nId, NULL, FALSE ); // look for non high contrast mode image + m_pUserImageList->AddImage( nId, aImage ); + aImage = SeekImage( nId, NULL, TRUE ); // look for high contrast mode image + m_pHCUserImageList->AddImage( nId, aImage ); + } } delete pOldList; + delete pOldHCList; } -Image SfxImageManager_Impl::GetImage( USHORT nId, SfxModule *pModule, BOOL bBig ) const +Image SfxImageManager_Impl::GetImage( USHORT nId, SfxModule *pModule, BOOL bBig, BOOL bHiContrast ) const { if ( !pModule ) pModule = SFX_APP()->GetActiveModule(); ImageList *pList=0; if ( pModule ) - pList = pModule->GetImageList_Impl( bBig ); + pList = pModule->GetImageList_Impl( bBig, bHiContrast ); - if ( pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) - return pUserImageList->GetImage( nId ); - else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) - return pList->GetImage( nId ); + if ( bHiContrast ) + { + if ( m_pHCUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return m_pHCUserImageList->GetImage( nId ); + else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return pList->GetImage( nId ); + else + return GetImageList( bBig, bHiContrast )->GetImage( nId ); + } else - return GetImageList( bBig )->GetImage( nId ); + { + if ( m_pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return m_pUserImageList->GetImage( nId ); + else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return pList->GetImage( nId ); + else + return GetImageList( bBig, bHiContrast )->GetImage( nId ); + } } -Image SfxImageManager_Impl::SeekImage( USHORT nId, SfxModule *pModule ) const +Image SfxImageManager_Impl::SeekImage( USHORT nId, SfxModule *pModule, BOOL bHiContrast ) const { + BOOL bBig = ( m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ); + if ( !pModule ) pModule = SFX_APP()->GetActiveModule(); ImageList *pList=0; if ( pModule ) - pList = pModule->GetImageList_Impl( aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ); - - if ( pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) - return pUserImageList->GetImage( nId ); - else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) - return pList->GetImage( nId ); - else if ( pImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) - return pImageList->GetImage( nId ); - else if ( pOffImageList ) - return pOffImageList->GetImage( nId ); + pList = pModule->GetImageList_Impl( bBig, bHiContrast ); + + if ( bHiContrast ) + { + if ( m_pHCUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return m_pHCUserImageList->GetImage( nId ); + else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return pList->GetImage( nId ); + else + return GetImageList( bBig, bHiContrast )->GetImage( nId ); + } else - return pImageList->GetImage(nId); // leeres Image zur"uckgeben + { + if ( m_pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return m_pUserImageList->GetImage( nId ); + else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return pList->GetImage( nId ); + else + return GetImageList( bBig, bHiContrast )->GetImage( nId ); + } } //------------------------------------------------------------------------- @@ -842,11 +933,11 @@ SfxImageManager::SfxImageManager( SfxObjectShell* pDoc ) } // internal cached data for comparision in callback - pData->nSet = pImp->aOpt.GetSymbolSet(); - pData->nOutStyle = pImp->aOpt.GetToolboxStyle(); + pData->nSet = pImp->m_aOpt.GetSymbolSet(); + pData->nOutStyle = pImp->m_aOpt.GetToolboxStyle(); // register callback for changes of SymbolSet or ToolboxStyle - pImp->aOpt.AddListener( LINK( this, SfxImageManager, OptionsChanged_Impl ) ); + pImp->m_aOpt.AddListener( LINK( this, SfxImageManager, OptionsChanged_Impl ) ); // SetInternal( TRUE ); nRef++; @@ -861,13 +952,14 @@ SfxImageManager::~SfxImageManager() if ( !--nRef ) { - DELETEZ( pOffImageList ); DELETEZ( pImageListSmall ); DELETEZ( pImageListBig ); + DELETEZ( pImageListHiSmall ); + DELETEZ( pImageListHiBig ); } DELETEZ( pData->pToolBoxList ); - pImp->aOpt.RemoveListener( LINK( this, SfxImageManager, OptionsChanged_Impl ) ); + pImp->m_aOpt.RemoveListener( LINK( this, SfxImageManager, OptionsChanged_Impl ) ); if ( pImp != pGlobalConfig || !--nGlobalRef ) delete pImp; delete pData; @@ -901,57 +993,67 @@ BOOL SfxImageManager::Export( SotStorage& rInStorage, SvStream& rOutStream ) void SfxImageManager::LockImage( USHORT nId, ToolBox *pBox ) { - // Neue Images kommen aus der Office-Liste - if ( !pOffImageList || pOffImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND ) - return; + LockImage( nId, pBox, FALSE ); +} +void SfxImageManager::LockImage( USHORT nId, ToolBox *pBox, BOOL bHiContrast ) +{ // Das Image mu\s die richtige Gr"o\e haben if ( pBox->GetItemImage(nId).GetSizePixel() == pImageList->GetImageSize() ) { // Ist das Image schon vorhanden ? - ImageList *pUserImageList = pImp->pUserImageList; + ImageList *pUserImageList = pImp->m_pUserImageList; + ImageList *pHCUserImageList = pImp->m_pHCUserImageList; if ( pUserImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND ) { - // Eine physikalische Kopie des Images in der User-Liste machen + // Eine physikalische Kopie des Images in der User-Listen machen pUserImageList->AddImage( nId, pBox->GetItemImage( nId ) ); + pHCUserImageList->AddImage( nId, pBox->GetItemImage( nId ) ); + if ( SfxMacroConfig::IsMacroSlot(nId) ) SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId ); pImp->SetDefault( FALSE ); } - // In der Toolbox dieses neue Image benutzen, so da\s die Referenz - // auf die Quellliste wieder entfernt wird. - pBox->SetItemImage( nId, pUserImageList->GetImage( nId ) ); + // Toolbox should use image from the user image list so that the reference to + // the source image list will be released! + if ( bHiContrast ) + pBox->SetItemImage( nId, pHCUserImageList->GetImage( nId ) ); + else + pBox->SetItemImage( nId, pUserImageList->GetImage( nId ) ); } } //------------------------------------------------------------------------- -Image SfxImageManager::MakeUserImage( USHORT nId, Image& aImage ) +Image SfxImageManager::MakeUserImage( USHORT nId, Image& aImage, BOOL bHiContrast ) { - // Neue Images kommen aus der Office-Liste - if ( !pOffImageList || pOffImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND ) - return Image(); - // Das Image mu\s die richtige Gr"o\e haben if ( aImage.GetSizePixel() == pImageList->GetImageSize() ) { // Ist das Image schon vorhanden ? - ImageList *pUserImageList = pImp->pUserImageList; + ImageList *pUserImageList = pImp->m_pUserImageList; + ImageList *pHCUserImageList = pImp->m_pHCUserImageList; + if ( pUserImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND ) { - // Eine physikalische Kopie des Images in der User-Liste machen + // Eine physikalische Kopie des Images in den User-Listen machen pUserImageList->AddImage( nId, aImage ); + pHCUserImageList->AddImage( nId, aImage ); + if ( SfxMacroConfig::IsMacroSlot(nId) ) SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId ); pImp->SetDefault( FALSE ); } - // In der Toolbox dieses neue Image benutzen, so da\s die Referenz - // auf die Quellliste wieder entfernt wird. - return pUserImageList->GetImage( nId ); + // Return image from the user image list so that the reference to + // the source image list will be released! + if ( bHiContrast ) + return pHCUserImageList->GetImage( nId ); + else + return pUserImageList->GetImage( nId ); } return Image(); @@ -971,21 +1073,9 @@ void SfxImageManager::SetSymbolSet_Impl( sal_Int16 nNewSet ) pImp->MakeDefaultImageList(); Size aNewSize = pImageList->GetImageSize(); - ImageList *pOld = pOffImageList; - if ( pOld || !pImp->IsDefault() ) - { - // Auch die Officeliste neu erzeugen bzw. neu anlegen - DELETEZ( pOffImageList ); - StartCustomize(); - } - if ( !pImp->IsDefault() ) pImp->RebuildUserList(); - // Wenn es die Officeliste vorher nicht gab, muss sie jetzt wieder entfernt werden - if ( !pOld ) - EndCustomize(); - for ( USHORT n=0; n<pData->pToolBoxList->Count(); n++ ) { ToolBoxInf_Impl *pInf = (*pData->pToolBoxList)[n]; @@ -1042,7 +1132,12 @@ void SfxImageManager::SetSymbolSet_Impl( sal_Int16 nNewSet ) Image SfxImageManager::SeekImage( USHORT nId, SfxModule *pModule ) const { - return pImp->SeekImage( nId, pModule ); + return SeekImage( nId, FALSE, pModule ); +} + +Image SfxImageManager::SeekImage( USHORT nId, BOOL bHiContrast, SfxModule *pModule ) const +{ + return pImp->SeekImage( nId, pModule, bHiContrast ); } //------------------------------------------------------------------------- @@ -1055,28 +1150,43 @@ Image SfxImageManager::SeekImage( USHORT nId, SfxModule *pModule ) const */ Image SfxImageManager::GetImage( USHORT nId, SfxModule *pModule ) const { - return pImp->GetImage( nId, pModule, ( pImp->aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ) ); + return GetImage( nId, FALSE, pModule ); +} + +Image SfxImageManager::GetImage( USHORT nId, BOOL bHiContrast, SfxModule *pModule ) const +{ + return pImp->GetImage( nId, pModule, ( pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ), bHiContrast ); +} + +Image SfxImageManager::GetImage(USHORT nId, SfxModule* pMod, BOOL bBig ) const +{ + return GetImage( nId, pMod, bBig, FALSE ); } -Image SfxImageManager::GetImage( USHORT nId, SfxModule *pModule, BOOL bBig ) const +Image SfxImageManager::GetImage( USHORT nId, SfxModule *pModule, BOOL bBig, BOOL bHiContrast ) const { - return pImp->GetImage( nId, pModule, bBig ); + return pImp->GetImage( nId, pModule, bBig, bHiContrast ); } Image SfxImageManager::GetImageFromModule_Impl( USHORT nId, SfxModule *pModule ) { + return GetImageFromModule_Impl( nId, pModule, FALSE ); +} + +Image SfxImageManager::GetImageFromModule_Impl( USHORT nId, SfxModule *pModule, BOOL bHiContrast ) +{ if ( pModule ) { - ImageList *pList = pModule->GetImageList_Impl( pImp->aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ); + ImageList *pList = pModule->GetImageList_Impl(( pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ), bHiContrast ); if ( pList ) return pList->GetImage( nId ); } else { - if ( pOffImageList ) - return pOffImageList->GetImage( nId ); - else + if ( bHiContrast ) return pImageList->GetImage( nId ); + else + return pHiImageList->GetImage( nId ); } return Image(); @@ -1084,13 +1194,29 @@ Image SfxImageManager::GetImageFromModule_Impl( USHORT nId, SfxModule *pModule ) Image SfxImageManager::GetAndLockImage_Impl( USHORT nId, SfxModule *pModule ) { - ImageList *pUserImageList = pImp->pUserImageList; + return GetAndLockImage_Impl( nId, FALSE, pModule ); +} + +Image SfxImageManager::GetAndLockImage_Impl( USHORT nId, BOOL bHiContrast, SfxModule *pModule ) +{ + BOOL bBig = ( pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ); + ImageList *pUserImageList = pImp->m_pUserImageList; + ImageList *pHCUserImageList = pImp->m_pHCUserImageList; // Zuerst in der UserImagelist suchen - if ( pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) - return pUserImageList->GetImage( nId ); - else if ( pModule ) - return GetImage( nId, pModule ); + if ( bHiContrast ) + { + if ( pHCUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return pHCUserImageList->GetImage( nId ); + } + else + { + if ( pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + return pUserImageList->GetImage( nId ); + } + + if ( pModule ) + return GetImage( nId, pModule, bBig, bHiContrast ); else { pModule = SFX_APP()->GetActiveModule(); @@ -1100,15 +1226,39 @@ Image SfxImageManager::GetAndLockImage_Impl( USHORT nId, SfxModule *pModule ) if ( pModule && pImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND ) { // Dann in der Liste des aktiven Moduls suchen - ImageList *pList = pModule->GetImageList_Impl( pImp->aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ); + ImageList *pList = pModule->GetImageList_Impl( bBig, bHiContrast ); if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) { // Das Image in die UserImageList "ubertragen - pUserImageList->AddImage( nId, pList->GetImage( nId ) ); + if ( bHiContrast ) + { + // Add it to the high contrast user image list + pHCUserImageList->AddImage( nId, pList->GetImage( nId ) ); + + // Do it for the NON high contrast user image list, too!! + ImageList *pNonList = pModule->GetImageList_Impl( bBig, FALSE ); + if ( pNonList ) + pUserImageList->AddImage( nId, pNonList->GetImage( nId ) ); + } + else + { + // Add it to the user image list + pUserImageList->AddImage( nId, pList->GetImage( nId ) ); + + // Do it for the high contrast user image list, too!! + ImageList *pHiList = pModule->GetImageList_Impl( bBig, TRUE ); + if ( pHiList ) + pHCUserImageList->AddImage( nId, pHiList->GetImage( nId ) ); + } + if ( SfxMacroConfig::IsMacroSlot(nId) ) SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId ); pImp->SetDefault( FALSE ); - return pUserImageList->GetImage( nId ); + + if ( bHiContrast ) + return pHCUserImageList->GetImage( nId ); + else + return pUserImageList->GetImage( nId ); } } @@ -1125,36 +1275,7 @@ Image SfxImageManager::GetAndLockImage_Impl( USHORT nId, SfxModule *pModule ) void SfxImageManager::StartCustomize() { - // Officeliste schon angelegt ? - if ( pOffImageList ) - return; - - USHORT nType=0; - switch ( pImp->aOpt.GetSymbolSet() ) - { - case SFX_SYMBOLS_SMALL: - nType = RID_OFFICEIMAGELIST_SC; - break; - case SFX_SYMBOLS_LARGE: - nType = RID_OFFICEIMAGELIST_LC; - break; - default: - DBG_ERROR("Unbekannter Symboltyp!"); - break; - } - - // Die Office-Imagelist wird vom default-ResMgr bereitgestellt - ResMgr *pResMgr = Resource::GetResManager(); - ResId aResId( nType ); - aResId.SetRT( RSC_IMAGELIST ); - - DBG_ASSERT( pResMgr->IsAvailable(aResId), - "Keine default ImageList vorhanden!" ); - - if ( pResMgr->IsAvailable(aResId) ) - pOffImageList = new ImageList( aResId ); - else - pOffImageList = new ImageList(); + // no more office list } //------------------------------------------------------------------------- @@ -1166,7 +1287,7 @@ void SfxImageManager::StartCustomize() void SfxImageManager::EndCustomize() { - DELETEZ( pOffImageList); + // no more office list } //------------------------------------------------------------------------- @@ -1179,13 +1300,16 @@ void SfxImageManager::EndCustomize() void SfxImageManager::ReplaceImage( USHORT nId, Bitmap* pBmp ) { - ImageList *pUserImageList = pImp->pUserImageList; - SfxBitmapList_Impl* pUserDefList = pImp->pUserDefList; + ImageList *pUserImageList = pImp->m_pUserImageList; + ImageList *pHCUserImageList = pImp->m_pHCUserImageList; + + SfxBitmapList_Impl* pUserDefList = pImp->m_pUserDefList; BOOL bReplaced = FALSE; if ( !pBmp && GetImage( nId ).GetSizePixel().Width() ) { // Auf default zuruecksetzen; zuerst das Userdef-Image entfernen pUserImageList->RemoveImage( nId ); + pHCUserImageList->RemoveImage( nId ); // Falls zu der "ubergebenen Id eine UserBitmap vorliegt, wird sie // jetzt wieder entfernt @@ -1194,19 +1318,6 @@ void SfxImageManager::ReplaceImage( USHORT nId, Bitmap* pBmp ) pUserDefList->RemoveBitmap( nId ); Image aImage = GetImage( nId ); - if ( !aImage.GetSizePixel().Width() ) - { - // Kein default-Image vorhanden, vielleicht eines in Officeliste? - ImageList *pOldOffImageList = pOffImageList; - if ( !pOldOffImageList ) - StartCustomize(); - aImage = pOffImageList->GetImage( nId ); - - // Wenn es die OfficeListe vorher nicht gab, mu\s sie jetzt wieder - // entfernt werden - if ( !pOldOffImageList ) - EndCustomize(); - } if ( aImage.GetSizePixel().Width() ) { @@ -1253,9 +1364,15 @@ void SfxImageManager::ReplaceImage( USHORT nId, Bitmap* pBmp ) // In die User-Liste aufnehmen if ( pUserImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND ) + { pUserImageList->AddImage( nId, aImage ); + pHCUserImageList->AddImage( nId, aImage ); + } else + { pUserImageList->ReplaceImage( nId, aImage ); + pHCUserImageList->ReplaceImage( nId, aImage ); + } if ( SfxMacroConfig::IsMacroSlot(nId) ) SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId ); @@ -1291,7 +1408,7 @@ void SfxImageManager::RegisterToolBox( ToolBox *pBox, USHORT nFlags ) pInf->nFlags = nFlags; pInf->pModule = NULL; pData->pToolBoxList->Append( pInf ); - pBox->SetOutStyle( pImp->aOpt.GetToolboxStyle() ); + pBox->SetOutStyle( pImp->m_aOpt.GetToolboxStyle() ); } void SfxImageManager::RegisterToolBox( ToolBox *pBox, SfxModule* pModule, USHORT nFlags ) @@ -1302,7 +1419,7 @@ void SfxImageManager::RegisterToolBox( ToolBox *pBox, SfxModule* pModule, USHORT pInf->nFlags = nFlags; pInf->pModule = pModule; pData->pToolBoxList->Append( pInf ); - pBox->SetOutStyle( pImp->aOpt.GetToolboxStyle() ); + pBox->SetOutStyle( pImp->m_aOpt.GetToolboxStyle() ); } //------------------------------------------------------------------------- @@ -1332,7 +1449,7 @@ void SfxImageManager::RegisterToolBoxManager( SfxToolBoxManager *pMgr, USHORT nF pInf->pMgr = pMgr; pInf->nFlags = nFlags; pData->pToolBoxList->Append( pInf ); - pInf->pToolBox->SetOutStyle( pImp->aOpt.GetToolboxStyle() ); + pInf->pToolBox->SetOutStyle( pImp->m_aOpt.GetToolboxStyle() ); } //------------------------------------------------------------------------- @@ -1381,13 +1498,21 @@ Color SfxImageManager::GetMaskColor() const void SfxImageManager::SetImages( ToolBox& rToolBox, SfxModule *pModule ) { + SetImages( rToolBox, pModule, FALSE ); +} + +void SfxImageManager::SetImages( ToolBox& rToolBox, SfxModule *pModule, BOOL bHiContrast ) +{ + BOOL bBig = pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE; + if ( !pModule ) pModule = SFX_APP()->GetActiveModule(); ImageList *pList=0; if ( pModule ) - pList = pModule->GetImageList_Impl( pImp->aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ); + pList = pModule->GetImageList_Impl( bBig, bHiContrast ); - ImageList *pUserImageList = pImp->pUserImageList; + ImageList *pUserImageList = bHiContrast ? pImp->m_pHCUserImageList : pImp->m_pUserImageList; + ImageList *pWorkImageList = GetImageList( bBig, bHiContrast ); USHORT nCount = rToolBox.GetItemCount(); for (USHORT n=0; n<nCount; n++) { @@ -1400,8 +1525,8 @@ void SfxImageManager::SetImages( ToolBox& rToolBox, SfxModule *pModule ) rToolBox.SetItemImage(nId, pUserImageList->GetImage(nId)); else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) rToolBox.SetItemImage(nId, pList->GetImage(nId)); - else if ( pImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) - rToolBox.SetItemImage(nId, pImageList->GetImage(nId)); + else if ( pWorkImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND ) + rToolBox.SetItemImage(nId, pWorkImageList->GetImage(nId)); } case TOOLBOXITEM_SEPARATOR: @@ -1424,7 +1549,7 @@ void SfxImageManager::SetImages( ToolBox& rToolBox, SfxModule *pModule ) BOOL SfxImageManager::IsUserDef_Impl(USHORT nId) const { - return ( pImp->pUserDefList->GetBitmapPos(nId) != USHRT_MAX ); + return ( pImp->m_pUserDefList->GetBitmapPos(nId) != USHRT_MAX ); } //------------------------------------------------------------------------- @@ -1437,7 +1562,7 @@ BOOL SfxImageManager::IsUserDef_Impl(USHORT nId) const const Bitmap& SfxImageManager::GetUserDefBitmap_Impl( USHORT nId ) const { - SfxBitmapList_Impl* pUserDefList = pImp->pUserDefList; + SfxBitmapList_Impl* pUserDefList = pImp->m_pUserDefList; USHORT nPos = pUserDefList->GetBitmapPos( nId ); DBG_ASSERT( nPos != USHRT_MAX, "Bitmap nicht vorhanden!" ); return ( *pUserDefList->GetBitmap(nId) ); @@ -1479,8 +1604,8 @@ Size SfxImageManager::GetImageSize() const IMPL_LINK( SfxImageManager, OptionsChanged_Impl, void*, pVoid ) { - SetOutStyle_Impl( pImp->aOpt.GetToolboxStyle() ); - SetSymbolSet_Impl( pImp->aOpt.GetSymbolSet() ); + SetOutStyle_Impl( pImp->m_aOpt.GetToolboxStyle() ); + SetSymbolSet_Impl( pImp->m_aOpt.GetSymbolSet() ); return 0L; } @@ -1489,15 +1614,36 @@ Image SfxImageManager::GetGlobalImage( USHORT nId, BOOL bBig ) { if ( !pGlobalConfig ) return Image(); - return pGlobalConfig->GetImage( nId, NULL, bBig ); + return pGlobalConfig->GetImage( nId, NULL, bBig, FALSE ); +} + +Image SfxImageManager::GetGlobalImage( USHORT nId, BOOL bBig, BOOL bHiContrast ) +{ + if ( !pGlobalConfig ) + return Image(); + return pGlobalConfig->GetImage( nId, NULL, bBig, bHiContrast ); } IMPL_LINK( SfxImageManager, ConfigChanged_Impl, void*, pVoid ) { + BOOL bHiContrast = FALSE; + + if ( pData->pToolBoxList->Count() > 0 ) + { + // Check whether toolbox is in high contrast mode or not! + ToolBox *pBox = (*pData->pToolBoxList)[0]->pToolBox; + Color aBackColor = pBox->GetBackground().GetColor(); + if ( aBackColor.IsDark() ) + bHiContrast = TRUE; + } + for ( USHORT i=0; i<pImageList->GetImageCount(); i++ ) { USHORT nId = pImageList->GetImageId(i); - ExchangeItemImage_Impl( nId, pImp->GetImage( nId, pData->pDoc->GetModule(), ( pData->nSet == SFX_SYMBOLS_LARGE ) ) ); + ExchangeItemImage_Impl( nId, pImp->GetImage( nId, + pData->pDoc->GetModule(), + ( pData->nSet == SFX_SYMBOLS_LARGE ), + bHiContrast ) ); } return TRUE; diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index 94a0f22b23..e1fbdd1bbb 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: tbxitem.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: mba $ $Date: 2002-04-05 12:23:06 $ + * last change: $Author: cd $ $Date: 2002-04-11 11:43:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,6 +86,10 @@ #include <framework/menuconfiguration.hxx> #include <vcl/taskpanelist.hxx> +#ifndef INCLUDED_SVTOOLS_MENUOPTIONS_HXX +#include <svtools/menuoptions.hxx> +#endif + #pragma hdrstop #include "tbxctrl.hxx" @@ -113,6 +117,7 @@ #include "app.hxx" #include "unoctitm.hxx" #include "helpid.hrc" +#include "imagemgr.hxx" #include "workwin.hxx" using namespace ::com::sun::star::uno; @@ -644,6 +649,11 @@ SfxAppToolBoxControl_Impl::SfxAppToolBoxControl_Impl rBox.SetHelpId( nId, HID_TBXCONTROL_FILENEW ); rBox.SetItemBits( nId, rBox.GetItemBits( nId ) | TIB_DROPDOWN); SetImage( String() ); + + // Determine the current background color of the menus + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + m_bWasHiContrastMode = rSettings.GetMenuColor().IsDark(); + m_bShowMenuImages = SvtMenuOptions().IsMenuIconsEnabled(); } SfxAppToolBoxControl_Impl::~SfxAppToolBoxControl_Impl() @@ -660,7 +670,7 @@ void SfxAppToolBoxControl_Impl::SetImage( const String &rURL ) aURL += String::CreateFromAscii(SfxObjectFactory::GetDefaultFactory().GetShortName()); } - GetToolBox().SetItemImage( GetId(), SvFileInformationManager::GetImage( INetURLObject( aURL ), FALSE ) ); + GetToolBox().SetItemImage( GetId(), SvFileInformationManager::GetImage( INetURLObject( aURL ), FALSE, m_bWasHiContrastMode ) ); } void SfxAppToolBoxControl_Impl::StateChanged @@ -714,6 +724,69 @@ void SfxAppToolBoxControl_Impl::Select( BOOL bMod1 ) //-------------------------------------------------------------------- long Select_Impl( void* pHdl, void* pVoid ); + +IMPL_LINK( SfxAppToolBoxControl_Impl, Activate, Menu *, pMenu ) +{ + if ( pMenu ) + { + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + BOOL bIsHiContrastMode = rSettings.GetMenuColor().IsDark(); + BOOL bShowMenuImages = SvtMenuOptions().IsMenuIconsEnabled(); + + if (( bIsHiContrastMode != m_bWasHiContrastMode ) || + ( bShowMenuImages != m_bShowMenuImages ) ) + { + m_bWasHiContrastMode = bIsHiContrastMode; + m_bShowMenuImages = bShowMenuImages; + + USHORT nCount = pMenu->GetItemCount(); + for ( USHORT nSVPos = 0; nSVPos < nCount; nSVPos++ ) + { + USHORT nId = pMenu->GetItemId( nSVPos ); + if ( pMenu->GetItemType( nSVPos ) != 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 = GetImage( Reference< ::com::sun::star::frame::XFrame >(), aImageId, FALSE, bIsHiContrastMode ); + if ( !!aImage ) + { + bImageSet = sal_True; + pMenu->SetItemImage( nId, aImage ); + } + } + + String aCmd( pMenu->GetItemCommand( nId ) ); + if ( !bImageSet && aCmd.Len() ) + { + Image aImage = SvFileInformationManager::GetImage( aCmd, FALSE, bIsHiContrastMode ); + if ( !!aImage ) + pMenu->SetItemImage( nId, aImage ); + } + } + else + pMenu->SetItemImage( nId, Image() ); + } + } + } + + return TRUE; + } + + return FALSE; +} + +//-------------------------------------------------------------------- + IMPL_LINK( SfxAppToolBoxControl_Impl, Timeout, Timer *, pTimer ) { SfxApplication* pApp = SFX_APP(); @@ -734,6 +807,7 @@ IMPL_LINK( SfxAppToolBoxControl_Impl, Timeout, Timer *, pTimer ) if( pMenu ) { pMenu->SetSelectHdl( Link( this, Select_Impl ) ); + pMenu->SetActivateHdl( LINK( this, SfxAppToolBoxControl_Impl, Activate )); rBox.SetItemDown( GetId(), TRUE ); USHORT nSelected = pMenu->Execute( &rBox, aRect, POPUPMENU_EXECUTE_UP ); if ( nSelected ) |