diff options
79 files changed, 6779 insertions, 1119 deletions
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx index a3a3f63367c1..46063564193d 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -123,8 +123,7 @@ inline UniString SmartRel2Abs_Impl(INetURLObject const & rTheBaseURIRef, eStyle); if (bCheckFileExists && !bWasAbsolute - && (aAbsURIRef.GetProtocol() == INET_PROT_FILE - || aAbsURIRef.GetProtocol() == INET_PROT_VND_SUN_STAR_WFS)) + && (aAbsURIRef.GetProtocol() == INET_PROT_FILE)) { INetURLObject aNonFileURIRef; aNonFileURIRef.SetSmartURL(rTheRelURIRef, diff --git a/svtools/inc/svtools/accessiblefactory.hxx b/svtools/inc/svtools/accessiblefactory.hxx index b435d3da96a7..9606e93a2fa0 100644..100755 --- a/svtools/inc/svtools/accessiblefactory.hxx +++ b/svtools/inc/svtools/accessiblefactory.hxx @@ -61,6 +61,10 @@ namespace svt { //........................................................................ + class ToolPanelDeck; + class IToolPanelDeck; + class PanelTabBar; + /** a function which is able to create a factory for the standard Accessible/Context components needed for standard toolkit controls @@ -162,6 +166,18 @@ namespace svt sal_Int32 _nRowPos, sal_uInt16 _nColPos ) const = 0; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + createAccessibleToolPanelDeck( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rAccessibleParent, + ::svt::ToolPanelDeck& i_rPanelDeck + ) = 0; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + createAccessibleToolPanelTabBar( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rAccessibleParent, + ::svt::IToolPanelDeck& i_rPanelDeck, + ::svt::PanelTabBar& i_rTabBar + ) = 0; }; //........................................................................ diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx index b08a7f04f1da..457b63a0a488 100644..100755 --- a/svtools/inc/svtools/accessibletable.hxx +++ b/svtools/inc/svtools/accessibletable.hxx @@ -100,7 +100,7 @@ public: AccessibleTableControlObjType eObjType ) const= 0; // Window - virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) = 0; + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const = 0; virtual void GrabFocus()= 0; virtual XACC GetAccessible( BOOL bCreate = TRUE )= 0; virtual Window* GetAccessibleParentWindow() const= 0; diff --git a/svtools/inc/svtools/accessibletableprovider.hxx b/svtools/inc/svtools/accessibletableprovider.hxx index fd29c72f35be..d14aecce9f58 100644 --- a/svtools/inc/svtools/accessibletableprovider.hxx +++ b/svtools/inc/svtools/accessibletableprovider.hxx @@ -132,7 +132,7 @@ public: virtual BOOL GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ) = 0; // Window - virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) = 0; + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const = 0; virtual void GrabFocus() = 0; virtual XACC GetAccessible( BOOL bCreate = TRUE ) = 0; virtual Window* GetAccessibleParentWindow() const = 0; diff --git a/svtools/inc/svtools/brwbox.hxx b/svtools/inc/svtools/brwbox.hxx index 9adeaf7efd05..8a8e4c04ecad 100644 --- a/svtools/inc/svtools/brwbox.hxx +++ b/svtools/inc/svtools/brwbox.hxx @@ -848,7 +848,7 @@ public: virtual sal_Bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const; virtual String GetAccessibleCellText(long _nRow, USHORT _nColPos) const; virtual BOOL GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ); - virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ); + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; virtual void GrabFocus(); virtual XACC GetAccessible( BOOL bCreate = TRUE ); virtual Window* GetAccessibleParentWindow() const; diff --git a/svtools/inc/svtools/svtabbx.hxx b/svtools/inc/svtools/svtabbx.hxx index 8b8092260e33..89fd92a4fc09 100644 --- a/svtools/inc/svtools/svtabbx.hxx +++ b/svtools/inc/svtools/svtabbx.hxx @@ -251,7 +251,7 @@ public: virtual BOOL GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ); // Window - virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ); + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; virtual void GrabFocus(); virtual XACC GetAccessible( BOOL bCreate = TRUE ); virtual Window* GetAccessibleParentWindow() const; diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index c1381e3b3c0b..cbe22da4a9d5 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -180,7 +180,7 @@ namespace svt { namespace table AccessibleTableControlObjType eObjType ) const; //// Window - virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ); + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; virtual void GrabFocus(); virtual XACC GetAccessible( BOOL bCreate = TRUE ); virtual Window* GetAccessibleParentWindow() const; diff --git a/svtools/inc/svtools/toolpanel/decklayouter.hxx b/svtools/inc/svtools/toolpanel/decklayouter.hxx new file mode 100755 index 000000000000..da03d7c6c3aa --- /dev/null +++ b/svtools/inc/svtools/toolpanel/decklayouter.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_DECKLAYOUTER_HXX +#define SVT_DECKLAYOUTER_HXX + +#include <com/sun/star/uno/Reference.hxx> + +#include <rtl/ref.hxx> + +#include <boost/optional.hpp> + +namespace com { namespace sun { namespace star { namespace accessibility { + class XAccessible; +} } } } +class Rectangle; +class Point; + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= IDeckLayouter + //==================================================================== + class IDeckLayouter : public ::rtl::IReference + { + public: + /** re-arranges the elements of the tool deck, taking into account the + available space for the complete deck. + + @param i_rDeckPlayground + the playground for the complete tool panel deck + @return + the content area for a single tool panel + */ + virtual ::Rectangle Layout( const ::Rectangle& i_rDeckPlayground ) = 0; + + /** destroys the instance + + Since the layouter is ref-counted, but might keep references to non-ref-counted objects + (in particular, the ToolPanelDeck, which is a VCL-Window, and thus cannot be ref-counted), + Destroy is the definitive way to dispose the instance. Technically, it's still alive afterwards, + but non-functional. + */ + virtual void Destroy() = 0; + + /** assuming that a layouter neesds to provide some kind of panel selector control, this method + requests to set the focus to this control. + */ + virtual void SetFocusToPanelSelector() = 0; + + /** returns the number of components in the XAccessible hierarchy which are needed to represent all elements + the layouter is responsible form. + + Note that the implementation must guarantee that the count is fixed over the life time of the layouter. + */ + virtual size_t GetAccessibleChildCount() const = 0; + + /** retrieves the XAccessible implementation for the <code>i_nChildIndex</code>'th child in the XAccessible + hierarchy. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + GetAccessibleChild( + const size_t i_nChildIndex, + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible + ) = 0; + + virtual ~IDeckLayouter() + { + } + }; + + typedef ::rtl::Reference< IDeckLayouter > PDeckLayouter; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_DECKLAYOUTER_HXX diff --git a/svtools/inc/svtools/toolpanel/paneltabbar.hxx b/svtools/inc/svtools/toolpanel/paneltabbar.hxx new file mode 100644 index 000000000000..668935d8a739 --- /dev/null +++ b/svtools/inc/svtools/toolpanel/paneltabbar.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_PANELTABBAR_HXX +#define SVT_PANELTABBAR_HXX + +#include "svtools/svtdllapi.h" +#include "svtools/toolpanel/tabalignment.hxx" +#include "svtools/toolpanel/tabitemcontent.hxx" + +#include <vcl/ctrl.hxx> + +#include <memory> +#include <boost/optional.hpp> + +class PushButton; + +//........................................................................ +namespace svt +{ +//........................................................................ + + class PanelTabBar_Impl; + class IToolPanelDeck; + + //==================================================================== + //= PanelTabBar + //==================================================================== + /** a tab bar for selecting panels + + At the moment, this control aligns the tabs vertically, this might be extended to also support a horizontal + layout in the future. + */ + class SVT_DLLPUBLIC PanelTabBar : public Control + { + public: + PanelTabBar( Window& i_rParentWindow, IToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent ); + ~PanelTabBar(); + + // attribute access + TabItemContent GetTabItemContent() const; + void SetTabItemContent( const TabItemContent& i_eItemContent ); + + ::boost::optional< size_t > GetFocusedPanelItem() const; + void FocusPanelItem( const size_t i_nItemPos ); + Rectangle GetItemScreenRect( const size_t i_nItemPos ) const; + bool IsVertical() const; + IToolPanelDeck& GetPanelDeck() const; + PushButton& GetScrollButton( const bool i_bForward ); + + // Window overridables + virtual Size GetOptimalSize( WindowSizeType i_eType ) const; + + protected: + // Window overridables + virtual void Paint( const Rectangle& i_rRect ); + virtual void Resize(); + virtual void MouseMove( const MouseEvent& i_rMouseEvent ); + virtual void MouseButtonDown( const MouseEvent& i_rMouseEvent ); + virtual void MouseButtonUp( const MouseEvent& i_rMouseEvent ); + virtual void RequestHelp( const HelpEvent& i_rHelpEvent ); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void KeyInput( const KeyEvent& i_rKeyEvent ); + virtual void DataChanged( const DataChangedEvent& i_rDataChanedEvent ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > + GetComponentInterface( BOOL i_bCreate ); + + private: + ::std::auto_ptr< PanelTabBar_Impl > m_pImpl; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_PANELTABBAR_HXX + diff --git a/svtools/inc/svtools/toolpanel/refbase.hxx b/svtools/inc/svtools/toolpanel/refbase.hxx new file mode 100644 index 000000000000..991d6e619090 --- /dev/null +++ b/svtools/inc/svtools/toolpanel/refbase.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_REFBASE_HXX +#define SVT_REFBASE_HXX + +#include "svtools/svtdllapi.h" + +#include <rtl/ref.hxx> + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= RefBase + //==================================================================== + class SVT_DLLPUBLIC RefBase : public ::rtl::IReference + { + protected: + RefBase() + :m_refCount( 0 ) + { + } + + virtual ~RefBase() + { + } + + virtual oslInterlockedCount SAL_CALL acquire(); + virtual oslInterlockedCount SAL_CALL release(); + + private: + oslInterlockedCount m_refCount; + }; + +#define DECLARE_IREFERENCE() \ + virtual oslInterlockedCount SAL_CALL acquire(); \ + virtual oslInterlockedCount SAL_CALL release(); + + +#define IMPLEMENT_IREFERENCE( classname ) \ + oslInterlockedCount classname::acquire() \ + { \ + return RefBase::acquire(); \ + } \ + oslInterlockedCount classname::release() \ + { \ + return RefBase::release(); \ + } + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_REFBASE_HXX diff --git a/svtools/inc/svtools/toolpanel/tabalignment.hxx b/svtools/inc/svtools/toolpanel/tabalignment.hxx new file mode 100644 index 000000000000..cc3f17469ffe --- /dev/null +++ b/svtools/inc/svtools/toolpanel/tabalignment.hxx @@ -0,0 +1,47 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_TABALIGNMENT_HXX +#define SVT_TABALIGNMENT_HXX + +//........................................................................ +namespace svt +{ +//........................................................................ + + enum TabAlignment + { + TABS_LEFT, + TABS_RIGHT, + TABS_TOP, + TABS_BOTTOM + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_TABALIGNMENT_HXX diff --git a/svtools/inc/svtools/toolpanel/tabitemcontent.hxx b/svtools/inc/svtools/toolpanel/tabitemcontent.hxx new file mode 100644 index 000000000000..a1cf9deae9f4 --- /dev/null +++ b/svtools/inc/svtools/toolpanel/tabitemcontent.hxx @@ -0,0 +1,48 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_TABITEMCONTENT_HXX +#define SVT_TABITEMCONTENT_HXX + +//........................................................................ +namespace svt +{ +//........................................................................ + + enum TabItemContent + { + TABITEM_IMAGE_AND_TEXT, + TABITEM_IMAGE_ONLY, + TABITEM_TEXT_ONLY, + + TABITEM_AUTO + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_TABITEMCONTENT_HXX diff --git a/svtools/inc/svtools/toolpanel/tablayouter.hxx b/svtools/inc/svtools/toolpanel/tablayouter.hxx new file mode 100755 index 000000000000..92b36acf9114 --- /dev/null +++ b/svtools/inc/svtools/toolpanel/tablayouter.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_TABLAYOUTER_HXX +#define SVT_TABLAYOUTER_HXX + +#include "svtools/svtdllapi.h" +#include "svtools/toolpanel/decklayouter.hxx" +#include "svtools/toolpanel/tabalignment.hxx" +#include "svtools/toolpanel/tabitemcontent.hxx" +#include "svtools/toolpanel/refbase.hxx" + +#include <memory> + +#include <boost/noncopyable.hpp> + +class Window; + +//........................................................................ +namespace svt +{ +//........................................................................ + + class IToolPanelDeck; + + struct TabDeckLayouter_Data; + + //==================================================================== + //= TabDeckLayouter + //==================================================================== + class SVT_DLLPUBLIC TabDeckLayouter :public RefBase + ,public IDeckLayouter + ,public ::boost::noncopyable + { + public: + /** creates a new layouter + @param i_rParent + is the parent window for any VCL windows the layouter needs to create. + @param i_rPanels + is the panel deck which the layouter is responsible for. + @param i_eAlignment + specifies the alignment of the panel selector + @param TabItemContent + specifies the content to show on the tab items + */ + TabDeckLayouter( + Window& i_rParent, + IToolPanelDeck& i_rPanels, + const TabAlignment i_eAlignment, + const TabItemContent i_eItemContent + ); + ~TabDeckLayouter(); + + // attribute access + TabItemContent GetTabItemContent() const; + void SetTabItemContent( const TabItemContent& i_eItemContent ); + TabAlignment GetTabAlignment() const; + + // helpers for the A11Y implementation + ::boost::optional< size_t > + GetFocusedPanelItem() const; + void FocusPanelItem( const size_t i_nItemPos ); + bool IsPanelSelectorEnabled() const; + bool IsPanelSelectorVisible() const; + Rectangle GetItemScreenRect( const size_t i_nItemPos ) const; + + // IDeckLayouter + virtual Rectangle Layout( const Rectangle& i_rDeckPlayground ); + virtual void Destroy(); + virtual void SetFocusToPanelSelector(); + virtual size_t GetAccessibleChildCount() const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + GetAccessibleChild( + const size_t i_nChildIndex, + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible + ); + + // IReference + DECLARE_IREFERENCE() + + private: + ::std::auto_ptr< TabDeckLayouter_Data > m_pData; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_TABLAYOUTER_HXX diff --git a/svtools/inc/svtools/toolpanel/toolpanel.hxx b/svtools/inc/svtools/toolpanel/toolpanel.hxx new file mode 100644 index 000000000000..d4d009b5c169 --- /dev/null +++ b/svtools/inc/svtools/toolpanel/toolpanel.hxx @@ -0,0 +1,143 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_TOOLPANEL_HXX +#define SVT_TOOLPANEL_HXX + +#include "svtools/svtdllapi.h" +#include "svtools/toolpanel/refbase.hxx" + +#include <rtl/ustring.hxx> +#include <vcl/image.hxx> + +#include <boost/noncopyable.hpp> + +class Rectangle; +class Window; +namespace com { namespace sun { namespace star { namespace accessibility { + class XAccessible; +} } } } + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= IToolPanel + //==================================================================== + /** abstract interface for a single tool panel + */ + class SVT_DLLPUBLIC IToolPanel : public ::rtl::IReference + { + public: + /// retrieves the display name of the panel + virtual ::rtl::OUString GetDisplayName() const = 0; + + /// retrieves the image associated with the panel, if any + virtual Image GetImage() const = 0; + + /** activates the panel + + Usually, this means the panel's Window is created (if not previosly done so) and shown. + + @param i_rParentWindow + the parent window to anchor the panel window at. Subsequent calls to the Activate + method will always get the same parent window. The complete area of this window is + available, and should be used, for the panel window. + */ + virtual void Activate( Window& i_rParentWindow ) = 0; + + /** deactivates the panel + + There are different ways how an implementation could deactivate a panel. The easiest way + would be to simply hide the associated Window. Alternatively, you could completely destroy it, + or decide to cache it by re-parenting it to another (temporary, invisible) window. + */ + virtual void Deactivate() = 0; + + /** sets a new size for the panel's Window + + The panel window is always expected to be positioned at (0,0), relative to the parent window + which was passed to the Activate member. Resizing the panel window is necessary when the size of + this parent window changes. Effectively, this method is a means of convenience, to relief panel + implementations from reacting on size changes of their parent window themselves. + */ + virtual void SetSizePixel( const Size& i_rPanelWindowSize ) = 0; + + /// sets the focus to the panel window + virtual void GrabFocus() = 0; + + /** release any resources associated with the panel. + + In particular, implementations should ultimately destroy the VCL window which implements the panel + window. No subsequent calls to any other method will happen after Destroy has been called. + */ + virtual void Dispose() = 0; + + /** creates an XAccessible for the tool panel + + Implementations are allowed to create a new instance each time this method is called, the caller + is responsible for caching the XAccessible implementation, if this is desired. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + CreatePanelAccessible( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible + ) = 0; + + virtual ~IToolPanel() + { + } + }; + + typedef ::rtl::Reference< IToolPanel > PToolPanel; + + //==================================================================== + //= ToolPanelBase + //==================================================================== + /** base class for tool panel implementations, adding ref count implementation to the IToolPanel interface, + but still being abstract + */ + class SVT_DLLPUBLIC ToolPanelBase :public IToolPanel + ,public RefBase + ,public ::boost::noncopyable + { + protected: + ToolPanelBase(); + ~ToolPanelBase(); + + public: + DECLARE_IREFERENCE() + + private: + oslInterlockedCount m_refCount; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_TOOLPANEL_HXX diff --git a/svtools/inc/svtools/toolpanel/toolpaneldeck.hxx b/svtools/inc/svtools/toolpanel/toolpaneldeck.hxx new file mode 100755 index 000000000000..358464211255 --- /dev/null +++ b/svtools/inc/svtools/toolpanel/toolpaneldeck.hxx @@ -0,0 +1,192 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVT_TOOLPANELDECK_HXX +#define SVT_TOOLPANELDECK_HXX + +#include "svtools/svtdllapi.h" +#include "svtools/toolpanel/toolpanel.hxx" +#include "svtools/toolpanel/decklayouter.hxx" + +#include <vcl/ctrl.hxx> + +#include <boost/optional.hpp> +#include <memory> + +//........................................................................ +namespace svt +{ +//........................................................................ + + class ToolPanelCollection; + class ToolPanelDeck_Impl; + + //==================================================================== + //= IToolPanelDeckListener + //==================================================================== + class SAL_NO_VTABLE IToolPanelDeckListener + { + public: + /** called when a panel has been inserted into the deck + */ + virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0; + + /** called when a panel has been removed from the deck + */ + virtual void PanelRemoved( const size_t i_nPosition ) = 0; + + /** called when the active panel of the deck changed + */ + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) = 0; + + /** called when a new layouter has been set at a tool panel deck. + + The method is called after the old layouter has been disposed (i.e. its Destroy method has been + invoked), and after the complete deck has been re-layouter. + */ + virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ) = 0; + + /** called when the tool panel deck which the listener registered at is dying. The listener is required to + release all references to the deck then. + */ + virtual void Dying() = 0; + }; + + //==================================================================== + //= IToolPanelDeck + //==================================================================== + class SVT_DLLPUBLIC IToolPanelDeck + { + public: + /** returns the number of panels in the container + */ + virtual size_t GetPanelCount() const = 0; + + /** retrieves the panel with the given index. Invalid indexes will be reported via an assertion in the + non-product version, and silently ignored in the product version, with a NULL panel being returned. + */ + virtual PToolPanel GetPanel( const size_t i_nPos ) const = 0; + + /** returns the number of the currently active panel. + */ + virtual ::boost::optional< size_t > + GetActivePanel() const = 0; + + /** activates the panel with the given number. If the given number is larger or equal to the number of panels + in the deck, this will be reported via an assertion in non-product builds, and otherwise ignored. + @param i_rPanel + the number of the panel to activate. If this is not set, the currently active panel is de-activated, + and no new panel is activated at all. Whether or not this makes sense for your application is at + your own discretion. + */ + virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) = 0; + + /** inserts a new panel into the container. NULL panels are not allowed, as are positions greater than the + current panel count. Violations of this will be reported via an assertion in the non-product version, and + silently ignored in the product version. + */ + virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0; + + /** removes a panel specified by its position. + + Note: It is the responsibility of the caller to ensure that the panel is destroyed appropriately. That is, + the tool panel deck will <em>not</em> invoke <member>IToolPanel::Dispose</member> on the removed panel. + The advantage is that the panel might be re-used later, with the disadvantage that the owner of the panel + deck must know whether Dispose must be invoked after removal, or whether the panel will properly + dispose itself when its ref count drops to 0. + */ + virtual PToolPanel RemovePanel( const size_t i_nPosition ) = 0; + + /** adds a new listener to be notified when the container content changes. The caller is responsible + for life time control, i.e. removing the listener before it actually dies. + */ + virtual void AddListener( IToolPanelDeckListener& i_rListener ) = 0; + + /** removes a container listener previously added via addListener. + */ + virtual void RemoveListener( IToolPanelDeckListener& i_rListener ) = 0; + }; + + //==================================================================== + //= ToolPanelDeck + //==================================================================== + class SVT_DLLPUBLIC ToolPanelDeck :public Control + ,public IToolPanelDeck + { + public: + ToolPanelDeck( Window& i_rParent, const WinBits i_nStyle ); + ~ToolPanelDeck(); + + // attributes + PDeckLayouter GetLayouter() const; + void SetLayouter( const PDeckLayouter& i_pNewLayouter ); + + /** returns the window which acts as anchor for the panel windows. + + This is a single dedicated window, which is passed to the IToolPanel::ActivatePanel method + whenever a panel is activated, to act as parent window for the panel's VCL-Window. + */ + Window& GetPanelWindowAnchor(); + + /** sets the window which should act as parent in the A11Y object hierarchy. + + Calling this method has no effect if CreateAccessible had always been called. + */ + void SetAccessibleParentWindow( Window* i_pAccessibleParent ); + Window* GetAccessibleParentWindow() const; + + // IToolPanelDeck + virtual size_t GetPanelCount() const; + virtual PToolPanel GetPanel( const size_t i_nPos ) const; + virtual ::boost::optional< size_t > + GetActivePanel() const; + virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ); + virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual PToolPanel RemovePanel( const size_t i_nPosition ); + virtual void AddListener( IToolPanelDeckListener& i_rListener ); + virtual void RemoveListener( IToolPanelDeckListener& i_rListener ); + + protected: + // Window overridables + virtual void Resize(); + virtual long Notify( NotifyEvent& i_rNotifyEvent ); + virtual void GetFocus(); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > + GetComponentInterface( BOOL i_bCreate ); + + private: + ::std::auto_ptr< ToolPanelDeck_Impl > m_pImpl; + + private: + using Window::GetAccessibleParentWindow; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_TOOLPANELDECK_HXX diff --git a/svtools/prj/build.lst b/svtools/prj/build.lst index 4b2cd9f9b26b..1fd12bb50b6c 100644 --- a/svtools/prj/build.lst +++ b/svtools/prj/build.lst @@ -21,9 +21,11 @@ st svtools\source\plugapp nmake - all st_papp st_inc NULL st svtools\source\svhtml nmake - all st_html st_inc NULL st svtools\source\svrtf nmake - all st_rtf st_inc NULL st svtools\source\table nmake - all st_table st_inc NULL +st svtools\source\toolpanel nmake - all st_toolpanel st_inc NULL st svtools\source\uno nmake - all st_uno st_inc NULL st svtools\source\urlobj nmake - all st__url st_inc NULL -st svtools\util nmake - all st_util st_svtgraphic st__brw st__ctr st_conf st_ctl st_dial st_edit st__misc st__url st_html st_papp st_rtf st_table st_uno st_vfilt st_vigif st_vixbm st_vixpm st_vjpeg st_vwmf st_svtjava NULL +st svtools\util nmake - all st_util st_svtgraphic st__brw st__ctr st_conf st_ctl st_dial st_edit st__misc st__url st_html st_papp st_rtf st_table st_toolpanel st_uno st_vfilt st_vigif st_vixbm st_vixpm st_vjpeg st_vwmf st_svtjava NULL st svtools\source\hatchwindow nmake - all st_hatchwin st_inc NULL st svtools\source\productregistration nmake - all st_prodreg st_util st_inc NULL st svtools\workben\unodialog nmake - all st_workben_udlg st_util NULL +st svtools\workben\toolpanel nmake - all st_workben_toolpanel st_util st_toolpanel NULL diff --git a/svtools/prj/d.lst b/svtools/prj/d.lst index 0a3ccd8a9819..fa3fbb2371dd 100644 --- a/svtools/prj/d.lst +++ b/svtools/prj/d.lst @@ -1,6 +1,7 @@ mkdir: %COMMON_DEST%\bin%_EXT%\hid mkdir: %COMMON_DEST%\res%_EXT% mkdir: %_DEST%\inc%_EXT%\svtools +mkdir: %_DEST%\inc%_EXT%\svtools\toolpanel ..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid ..\%__SRC%\srs\ehdl.srs %_DEST%\res%_EXT%\svtools.srs @@ -29,6 +30,8 @@ mkdir: %_DEST%\inc%_EXT%\svtools ..\inc\*.h %_DEST%\inc%_EXT%\svtools\*.h ..\inc\*.hrc %_DEST%\inc%_EXT%\svtools\*.hrc +..\inc\svtools\toolpanel\*.* %_DEST%\inc%_EXT%\svtools\toolpanel\*.hrc + dos: sh -c "if test %OS% = MACOSX; then macosx-create-bundle %_DEST%\bin%_EXT%\bmp=%__PRJROOT%\%__SRC%\bin%_EXT%; fi" *.xml %_DEST%\xml%_EXT%\*.xml diff --git a/svtools/source/brwbox/brwbox3.cxx b/svtools/source/brwbox/brwbox3.cxx index 449d5642e034..102af1b6e1a1 100644 --- a/svtools/source/brwbox/brwbox3.cxx +++ b/svtools/source/brwbox/brwbox3.cxx @@ -542,7 +542,7 @@ BOOL BrowseBox::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, in return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, nBase, rVector ); } // ----------------------------------------------------------------------------- -Rectangle BrowseBox::GetWindowExtentsRelative( Window *pRelativeWindow ) +Rectangle BrowseBox::GetWindowExtentsRelative( Window *pRelativeWindow ) const { return Control::GetWindowExtentsRelative( pRelativeWindow ); } diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx index 9d4ad1ba15b5..9640ca7a310f 100644 --- a/svtools/source/contnr/svtabbx.cxx +++ b/svtools/source/contnr/svtabbx.cxx @@ -1232,7 +1232,7 @@ BOOL SvHeaderTabListBox::GetGlyphBoundRects( const Point& rOrigin, const String& return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, nBase, rVector ); } // ----------------------------------------------------------------------- -Rectangle SvHeaderTabListBox::GetWindowExtentsRelative( Window *pRelativeWindow ) +Rectangle SvHeaderTabListBox::GetWindowExtentsRelative( Window *pRelativeWindow ) const { return Control::GetWindowExtentsRelative( pRelativeWindow ); } diff --git a/svtools/source/misc/svtaccessiblefactory.cxx b/svtools/source/misc/svtaccessiblefactory.cxx index 1a8284642698..b20863db3208 100644..100755 --- a/svtools/source/misc/svtaccessiblefactory.cxx +++ b/svtools/source/misc/svtaccessiblefactory.cxx @@ -209,6 +209,24 @@ namespace svt { return NULL; } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + createAccessibleToolPanelDeck( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/, + ::svt::ToolPanelDeck& /*i_rPanelDeck*/ + ) + { + return NULL; + } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + createAccessibleToolPanelTabBar( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/, + ::svt::IToolPanelDeck& /*i_rPanelDeck*/, + ::svt::PanelTabBar& /*i_rTabBar*/ + ) + { + return NULL; + } }; //---------------------------------------------------------------- diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 71c753d3ea86..262c32ae8ebc 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -394,7 +394,7 @@ void TableControl::FillAccessibleStateSet( } } -Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) +Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) const { return Control::GetWindowExtentsRelative( pRelativeWindow ); } diff --git a/svtools/source/toolpanel/dummypanel.cxx b/svtools/source/toolpanel/dummypanel.cxx new file mode 100644 index 000000000000..dae50723d4f1 --- /dev/null +++ b/svtools/source/toolpanel/dummypanel.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "dummypanel.hxx" + +//........................................................................ +namespace svt +{ +//........................................................................ + + using ::com::sun::star::uno::Reference; + using ::com::sun::star::accessibility::XAccessible; + + //==================================================================== + //= DummyPanel + //==================================================================== + //-------------------------------------------------------------------- + DummyPanel::DummyPanel() + { + } + + //-------------------------------------------------------------------- + DummyPanel::~DummyPanel() + { + } + + //-------------------------------------------------------------------- + IMPLEMENT_IREFERENCE( DummyPanel ) + + //-------------------------------------------------------------------- + void DummyPanel::Activate( Window& ) + { + } + + //-------------------------------------------------------------------- + void DummyPanel::Deactivate() + { + } + + //-------------------------------------------------------------------- + void DummyPanel::SetSizePixel( const Size& ) + { + } + + //-------------------------------------------------------------------- + ::rtl::OUString DummyPanel::GetDisplayName() const + { + return ::rtl::OUString(); + } + + //-------------------------------------------------------------------- + Image DummyPanel::GetImage() const + { + return Image(); + } + + //-------------------------------------------------------------------- + void DummyPanel::GrabFocus() + { + } + + //-------------------------------------------------------------------- + void DummyPanel::Dispose() + { + } + + //-------------------------------------------------------------------- + Reference< XAccessible > DummyPanel::CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible ) + { + (void)i_rParentAccessible; + return NULL; + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/dummypanel.hxx b/svtools/source/toolpanel/dummypanel.hxx new file mode 100644 index 000000000000..b37e5cca19af --- /dev/null +++ b/svtools/source/toolpanel/dummypanel.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef DUMMYPANEL_HXX +#define DUMMYPANEL_HXX + +#include "svtools/toolpanel/toolpanel.hxx" +#include "svtools/toolpanel/refbase.hxx" + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= DummyPanel + //==================================================================== + /// is a dummy implementation of the IToolPanel interface + class DummyPanel :public RefBase + ,public IToolPanel + { + public: + DummyPanel(); + ~DummyPanel(); + + // IToolPanel + virtual ::rtl::OUString GetDisplayName() const; + virtual Image GetImage() const; + virtual void Activate( Window& i_rParentWindow ); + virtual void Deactivate(); + virtual void SetSizePixel( const Size& i_rPanelWindowSize ); + virtual void GrabFocus(); + virtual void Dispose(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + CreatePanelAccessible( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible + ); + + DECLARE_IREFERENCE() + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // DUMMYPANEL_HXX diff --git a/svtools/source/toolpanel/makefile.mk b/svtools/source/toolpanel/makefile.mk new file mode 100755 index 000000000000..9d293b56d231 --- /dev/null +++ b/svtools/source/toolpanel/makefile.mk @@ -0,0 +1,65 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.16 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=svtools +TARGET=toolpanel + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=TRUE + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/svt.pmk + +# --- Files -------------------------------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES=\ + toolpanel.src + +SLOFILES=\ + $(SLO)$/dummypanel.obj \ + $(SLO)$/paneldecklisteners.obj \ + $(SLO)$/paneltabbar.obj \ + $(SLO)$/paneltabbarpeer.obj \ + $(SLO)$/refbase.obj \ + $(SLO)$/tabbargeometry.obj \ + $(SLO)$/tablayouter.obj \ + $(SLO)$/toolpanel.obj \ + $(SLO)$/toolpanelcollection.obj \ + $(SLO)$/toolpaneldeck.obj \ + $(SLO)$/toolpaneldeckpeer.obj \ + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/svtools/source/toolpanel/paneldecklisteners.cxx b/svtools/source/toolpanel/paneldecklisteners.cxx new file mode 100755 index 000000000000..32ba9b5c6a24 --- /dev/null +++ b/svtools/source/toolpanel/paneldecklisteners.cxx @@ -0,0 +1,137 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "paneldecklisteners.hxx" +#include "svtools/toolpanel/toolpaneldeck.hxx" + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= PanelDeckListeners + //==================================================================== + //-------------------------------------------------------------------- + PanelDeckListeners::PanelDeckListeners() + { + } + + //-------------------------------------------------------------------- + PanelDeckListeners::~PanelDeckListeners() + { + } + + //-------------------------------------------------------------------- + void PanelDeckListeners::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) + { + ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); + for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->PanelInserted( i_pPanel, i_nPosition ); + } + } + + //-------------------------------------------------------------------- + void PanelDeckListeners::PanelRemoved( const size_t i_nPosition ) + { + ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); + for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->PanelRemoved( i_nPosition ); + } + } + + //-------------------------------------------------------------------- + void PanelDeckListeners::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) + { + ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); + for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->ActivePanelChanged( i_rOldActive, i_rNewActive ); + } + } + + //-------------------------------------------------------------------- + void PanelDeckListeners::LayouterChanged( const PDeckLayouter& i_rNewLayouter ) + { + ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); + for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->LayouterChanged( i_rNewLayouter ); + } + } + + //-------------------------------------------------------------------- + void PanelDeckListeners::Dying() + { + while ( !m_aListeners.empty() ) + { + IToolPanelDeckListener* pListener( *m_aListeners.begin() ); + m_aListeners.erase( m_aListeners.begin() ); + pListener->Dying(); + } + } + + //-------------------------------------------------------------------- + void PanelDeckListeners::AddListener( IToolPanelDeckListener& i_rListener ) + { + m_aListeners.push_back( &i_rListener ); + } + + //-------------------------------------------------------------------- + void PanelDeckListeners::RemoveListener( IToolPanelDeckListener& i_rListener ) + { + for ( ::std::vector< IToolPanelDeckListener* >::iterator lookup = m_aListeners.begin(); + lookup != m_aListeners.end(); + ++lookup + ) + { + if ( *lookup == &i_rListener ) + { + m_aListeners.erase( lookup ); + return; + } + } + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/paneldecklisteners.hxx b/svtools/source/toolpanel/paneldecklisteners.hxx new file mode 100755 index 000000000000..bc7e2ae7db88 --- /dev/null +++ b/svtools/source/toolpanel/paneldecklisteners.hxx @@ -0,0 +1,72 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef PANELDECKLISTENERS_HXX +#define PANELDECKLISTENERS_HXX + +#include "svtools/toolpanel/toolpaneldeck.hxx" + +#include <boost/optional.hpp> +#include <vector> + +//........................................................................ +namespace svt +{ +//........................................................................ + + class IToolPanelDeckListener; + + //==================================================================== + //= PanelDeckListeners + //==================================================================== + /** implements a container for IToolPanelDeckListeners + */ + class PanelDeckListeners + { + public: + PanelDeckListeners(); + ~PanelDeckListeners(); + + // IToolPanelDeckListener equivalents, forward the events to all registered listeners + void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ); + void PanelRemoved( const size_t i_nPosition ); + void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + void LayouterChanged( const PDeckLayouter& i_rNewLayouter ); + void Dying(); + + // listener maintainance + void AddListener( IToolPanelDeckListener& i_rListener ); + void RemoveListener( IToolPanelDeckListener& i_rListener ); + + private: + ::std::vector< IToolPanelDeckListener* > m_aListeners; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // PANELDECKLISTENERS_HXX diff --git a/svtools/source/toolpanel/paneltabbar.cxx b/svtools/source/toolpanel/paneltabbar.cxx new file mode 100755 index 000000000000..95e6caa311e4 --- /dev/null +++ b/svtools/source/toolpanel/paneltabbar.cxx @@ -0,0 +1,1356 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "svtools/toolpanel/paneltabbar.hxx" +#include "svtools/toolpanel/toolpaneldeck.hxx" +#include "svtools/svtdata.hxx" + +#include "tabitemdescriptor.hxx" +#include "paneltabbarpeer.hxx" +#include "tabbargeometry.hxx" + +#include <vcl/button.hxx> +#include <vcl/help.hxx> +#include <vcl/virdev.hxx> +#include <tools/diagnose_ex.h> +#include <svl/svtools.hrc> + +#include <boost/optional.hpp> +#include <vector> + +// space around an item +#define ITEM_OUTER_SPACE 2 * 3 +// spacing before and after an item's text +#define ITEM_TEXT_FLOW_SPACE 5 +// space between item icon and icon text +#define ITEM_ICON_TEXT_DISTANCE 4 + +//........................................................................ +namespace svt +{ +//........................................................................ + + using ::com::sun::star::uno::Reference; + using ::com::sun::star::awt::XWindowPeer; + + typedef sal_uInt16 ItemFlags; + + #define ITEM_STATE_NORMAL 0x00 + #define ITEM_STATE_ACTIVE 0x01 + #define ITEM_STATE_HOVERED 0x02 + #define ITEM_STATE_FOCUSED 0x04 + #define ITEM_POSITION_FIRST 0x08 + #define ITEM_POSITION_LAST 0x10 + + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + ControlState lcl_ItemToControlState( const ItemFlags i_nItemFlags ) + { + ControlState nState = CTRL_STATE_ENABLED; + if ( i_nItemFlags & ITEM_STATE_FOCUSED ) nState |= CTRL_STATE_FOCUSED | CTRL_STATE_PRESSED; + if ( i_nItemFlags & ITEM_STATE_HOVERED ) nState |= CTRL_STATE_ROLLOVER; + if ( i_nItemFlags & ITEM_STATE_ACTIVE ) nState |= CTRL_STATE_SELECTED; + return nState; + } + } + + //================================================================================================================== + //= ITabBarRenderer + //================================================================================================================== + class SAL_NO_VTABLE ITabBarRenderer + { + public: + /** fills the background of our target device + */ + virtual void renderBackground() const = 0; + virtual Rectangle calculateDecorations( const Rectangle& i_rContentArea, const ItemFlags i_nItemFlags ) const = 0; + virtual void preRenderItem( const Rectangle& i_rContentRect, const ItemFlags i_nItemFlags ) const = 0; + virtual void postRenderItem( Window& i_rActualWindow, const Rectangle& i_rItemRect, const ItemFlags i_nItemFlags ) const = 0; + + // TODO: postRenderItem takes the "real" window, i.e. effectively the tab bar. This is because + // DrawSelectionBackground needs to be applied after everything else is painted, and is available at the Window + // class, but not at the OutputDevice. This makes the API somewhat weird, as we're now mixing operations on the + // target device, done in a normalized geometry, with operations on the window, done in a transformed geometry. + // So, we should get rid of postRenderItem completely. + }; + typedef ::boost::shared_ptr< ITabBarRenderer > PTabBarRenderer; + + //================================================================================================================== + //= VCLItemRenderer - declaration + //================================================================================================================== + class VCLItemRenderer : public ITabBarRenderer + { + public: + VCLItemRenderer( OutputDevice& i_rTargetDevice ) + :m_rTargetDevice( i_rTargetDevice ) + { + } + + // ITabBarRenderer + virtual void renderBackground() const; + virtual Rectangle calculateDecorations( const Rectangle& i_rContentArea, const ItemFlags i_nItemFlags ) const; + virtual void preRenderItem( const Rectangle& i_rContentRect, const ItemFlags i_nItemFlags ) const; + virtual void postRenderItem( Window& i_rActualWindow, const Rectangle& i_rItemRect, const ItemFlags i_nItemFlags ) const; + + protected: + OutputDevice& getTargetDevice() const { return m_rTargetDevice; } + + private: + OutputDevice& m_rTargetDevice; + }; + + //================================================================================================================== + //= VCLItemRenderer - implementation + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + void VCLItemRenderer::renderBackground() const + { + getTargetDevice().DrawRect( Rectangle( Point(), getTargetDevice().GetOutputSizePixel() ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle VCLItemRenderer::calculateDecorations( const Rectangle& i_rContentArea, const ItemFlags i_nItemFlags ) const + { + (void)i_nItemFlags; + // no decorations at all + return i_rContentArea; + } + + //------------------------------------------------------------------------------------------------------------------ + void VCLItemRenderer::preRenderItem( const Rectangle& i_rContentRect, const ItemFlags i_nItemFlags ) const + { + (void)i_rContentRect; + (void)i_nItemFlags; + } + + //------------------------------------------------------------------------------------------------------------------ + void VCLItemRenderer::postRenderItem( Window& i_rActualWindow, const Rectangle& i_rItemRect, const ItemFlags i_nItemFlags ) const + { + const bool bActive = ( ( i_nItemFlags & ITEM_STATE_ACTIVE ) != 0 ); + const bool bHovered = ( ( i_nItemFlags & ITEM_STATE_HOVERED ) != 0 ); + const bool bFocused = ( ( i_nItemFlags & ITEM_STATE_FOCUSED ) != 0 ); + if ( bActive || bHovered || bFocused ) + { + Rectangle aSelectionRect( i_rItemRect ); + aSelectionRect.Left() += ITEM_OUTER_SPACE / 2; + aSelectionRect.Top() += ITEM_OUTER_SPACE / 2; + aSelectionRect.Right() -= ITEM_OUTER_SPACE / 2; + aSelectionRect.Bottom() -= ITEM_OUTER_SPACE / 2; + i_rActualWindow.DrawSelectionBackground( + aSelectionRect, + ( bHovered || bFocused ) ? ( bActive ? 1 : 2 ) : 0 /* hilight */, + bActive /* check */, + TRUE /* border */, + FALSE /* ext border only */, + 0 /* corner radius */, + NULL, + NULL + ); + } + } + + //================================================================================================================== + //= NWFToolboxItemRenderer - declaration + //================================================================================================================== + class NWFToolboxItemRenderer : public ITabBarRenderer + { + public: + NWFToolboxItemRenderer( OutputDevice& i_rTargetDevice ) + :m_rTargetDevice( i_rTargetDevice ) + { + } + + // ITabBarRenderer + virtual void renderBackground() const; + virtual Rectangle calculateDecorations( const Rectangle& i_rContentArea, const ItemFlags i_nItemFlags ) const; + virtual void preRenderItem( const Rectangle& i_rContentRect, const ItemFlags i_nItemFlags ) const; + virtual void postRenderItem( Window& i_rActualWindow, const Rectangle& i_rItemRect, const ItemFlags i_nItemFlags ) const; + + protected: + OutputDevice& getTargetDevice() const { return m_rTargetDevice; } + + private: + OutputDevice& m_rTargetDevice; + }; + + //================================================================================================================== + //= NWFToolboxItemRenderer - implementation + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + void NWFToolboxItemRenderer::renderBackground() const + { + getTargetDevice().DrawRect( Rectangle( Point(), getTargetDevice().GetOutputSizePixel() ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle NWFToolboxItemRenderer::calculateDecorations( const Rectangle& i_rContentArea, const ItemFlags i_nItemFlags ) const + { + // don't ask GetNativeControlRegion, this will not deliver proper results in all cases. + // Instead, simply assume that both the content and the bounding region are the same. +// const ControlState nState( lcl_ItemToControlState( i_nItemFlags ); +// const ImplControlValue aControlValue; +// bool bNativeOK = m_rTargetWindow.GetNativeControlRegion( +// CTRL_TOOLBAR, PART_BUTTON, +// i_rContentArea, nState, +// aControlValue, ::rtl::OUString(), +// aBoundingRegion, aContentRegion +// ); + (void)i_nItemFlags; + return Rectangle( + Point( i_rContentArea.Left() - 1, i_rContentArea.Top() - 1 ), + Size( i_rContentArea.GetWidth() + 2, i_rContentArea.GetHeight() + 2 ) + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void NWFToolboxItemRenderer::preRenderItem( const Rectangle& i_rContentRect, const ItemFlags i_nItemFlags ) const + { + const ControlState nState = lcl_ItemToControlState( i_nItemFlags ); + + ImplControlValue aControlValue; + aControlValue.setTristateVal( ( i_nItemFlags & ITEM_STATE_ACTIVE ) ? BUTTONVALUE_ON : BUTTONVALUE_OFF ); + + bool bNativeOK = getTargetDevice().DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON, i_rContentRect, nState, aControlValue, rtl::OUString() ); + (void)bNativeOK; + OSL_ENSURE( bNativeOK, "NWFToolboxItemRenderer::preRenderItem: inconsistent NWF implementation!" ); + // IsNativeControlSupported returned true, previously, otherwise we would not be here ... + } + + //------------------------------------------------------------------------------------------------------------------ + void NWFToolboxItemRenderer::postRenderItem( Window& i_rActualWindow, const Rectangle& i_rItemRect, const ItemFlags i_nItemFlags ) const + { + (void)i_rActualWindow; + (void)i_rItemRect; + (void)i_nItemFlags; + } + + //================================================================================================================== + //= NWFTabItemRenderer - declaration + //================================================================================================================== + class NWFTabItemRenderer : public ITabBarRenderer + { + public: + NWFTabItemRenderer( OutputDevice& i_rTargetDevice ) + :m_rTargetDevice( i_rTargetDevice ) + { + } + + // ITabBarRenderer + virtual void renderBackground() const; + virtual Rectangle calculateDecorations( const Rectangle& i_rContentArea, const ItemFlags i_nItemFlags ) const; + virtual void preRenderItem( const Rectangle& i_rContentRect, const ItemFlags i_nItemFlags ) const; + virtual void postRenderItem( Window& i_rActualWindow, const Rectangle& i_rItemRect, const ItemFlags i_nItemFlags ) const; + + protected: + OutputDevice& getTargetDevice() const { return m_rTargetDevice; } + + private: + OutputDevice& m_rTargetDevice; + }; + + //================================================================================================================== + //= NWFTabItemRenderer - implementation + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + void NWFTabItemRenderer::renderBackground() const + { + Rectangle aBackground( Point(), getTargetDevice().GetOutputSizePixel() ); + getTargetDevice().DrawRect( aBackground ); + + aBackground.Top() = aBackground.Bottom(); + getTargetDevice().DrawNativeControl( CTRL_TAB_PANE, PART_ENTIRE_CONTROL, aBackground, + CTRL_STATE_ENABLED, ImplControlValue(), ::rtl::OUString() ); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle NWFTabItemRenderer::calculateDecorations( const Rectangle& i_rContentArea, const ItemFlags i_nItemFlags ) const + { + const ControlState nState( lcl_ItemToControlState( i_nItemFlags ) ); + + TabitemValue tiValue; + ImplControlValue aControlValue( (void*)(&tiValue) ); + + Region aBoundingRegion, aContentRegion; + bool bNativeOK = getTargetDevice().GetNativeControlRegion( + CTRL_TAB_ITEM, PART_ENTIRE_CONTROL, + i_rContentArea, nState, + aControlValue, ::rtl::OUString(), + aBoundingRegion, aContentRegion + ); + (void)bNativeOK; + OSL_ENSURE( bNativeOK, "NWFTabItemRenderer::calculateDecorations: GetNativeControlRegion not implemented for CTRL_TAB_ITEM?!" ); + + return aBoundingRegion.GetBoundRect(); + } + + //------------------------------------------------------------------------------------------------------------------ + void NWFTabItemRenderer::preRenderItem( const Rectangle& i_rContentRect, const ItemFlags i_nItemFlags ) const + { + const ControlState nState = lcl_ItemToControlState( i_nItemFlags ); + + TabitemValue tiValue; + if ( i_nItemFlags & ITEM_POSITION_FIRST ) + tiValue.mnAlignment |= TABITEM_FIRST_IN_GROUP; + if ( i_nItemFlags & ITEM_POSITION_LAST ) + tiValue.mnAlignment |= TABITEM_LAST_IN_GROUP; + + ImplControlValue aControlValue( (void *)(&tiValue) ); + + bool bNativeOK = getTargetDevice().DrawNativeControl( CTRL_TAB_ITEM, PART_ENTIRE_CONTROL, i_rContentRect, nState, aControlValue, rtl::OUString() ); + (void)bNativeOK; + OSL_ENSURE( bNativeOK, "NWFTabItemRenderer::preRenderItem: inconsistent NWF implementation!" ); + // IsNativeControlSupported returned true, previously, otherwise we would not be here ... + } + + //------------------------------------------------------------------------------------------------------------------ + void NWFTabItemRenderer::postRenderItem( Window& i_rActualWindow, const Rectangle& i_rItemRect, const ItemFlags i_nItemFlags ) const + { + (void)i_rActualWindow; + (void)i_rItemRect; + (void)i_nItemFlags; + } + + //================================================================================================================== + //= PanelTabBar_Impl + //================================================================================================================== + class PanelTabBar_Impl : public IToolPanelDeckListener + { + public: + PanelTabBar_Impl( PanelTabBar& i_rTabBar, IToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent ); + + ~PanelTabBar_Impl() + { + m_rPanelDeck.RemoveListener( *this ); + } + + // IToolPanelDeckListener + virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) + { + (void)i_pPanel; + (void)i_nPosition; + m_bItemsDirty = true; + m_rTabBar.Invalidate(); + + Relayout(); + } + + virtual void PanelRemoved( const size_t i_nPosition ) + { + m_bItemsDirty = true; + m_rTabBar.Invalidate(); + + if ( i_nPosition < m_nScrollPosition ) + --m_nScrollPosition; + + Relayout(); + } + + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ); + virtual void Dying(); + + void UpdateScrollButtons() + { + m_aScrollBack.Enable( m_nScrollPosition > 0 ); + m_aScrollForward.Enable( m_nScrollPosition < m_aItems.size() - 1 ); + } + + void Relayout(); + void EnsureItemsCache(); + ::boost::optional< size_t > FindItemForPoint( const Point& i_rPoint ) const; + void DrawItem( const size_t i_nItemIndex, const Rectangle& i_rBoundaries ) const; + void InvalidateItem( const size_t i_nItemIndex, const ItemFlags i_nAdditionalItemFlags = 0 ) const; + void CopyFromRenderDevice( const Rectangle& i_rLogicalRect ) const; + Rectangle GetActualLogicalItemRect( const Rectangle& i_rLogicalItemRect ) const; + Rectangle GetItemScreenRect( const size_t i_nItemPos ) const; + + void FocusItem( const ::boost::optional< size_t >& i_rItemPos ); + + inline bool IsVertical() const + { + return ( ( m_eTabAlignment == TABS_LEFT ) + || ( m_eTabAlignment == TABS_RIGHT ) + ); + } + + protected: + DECL_LINK( OnScroll, const PushButton* ); + + void impl_calcItemRects(); + Size impl_calculateItemContentSize( const PToolPanel& i_pPanel, const TabItemContent i_eItemContent ) const; + void impl_renderItemContent( const PToolPanel& i_pPanel, const Rectangle& i_rContentArea, const TabItemContent i_eItemContent ) const; + ItemFlags impl_getItemFlags( const size_t i_nItemIndex ) const; + + public: + PanelTabBar& m_rTabBar; + TabBarGeometry m_aGeometry; + NormalizedArea m_aNormalizer; + TabAlignment m_eTabAlignment; + IToolPanelDeck& m_rPanelDeck; + + VirtualDevice m_aRenderDevice; + PTabBarRenderer m_pRenderer; + + ::boost::optional< size_t > m_aHoveredItem; + ::boost::optional< size_t > m_aFocusedItem; + bool m_bMouseButtonDown; + + ItemDescriptors m_aItems; + bool m_bItemsDirty; + + PushButton m_aScrollBack; + PushButton m_aScrollForward; + + size_t m_nScrollPosition; + }; + + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + //-------------------------------------------------------------------------------------------------------------- + #if OSL_DEBUG_LEVEL > 0 + static void lcl_checkConsistency( const PanelTabBar_Impl& i_rImpl ) + { + if ( !i_rImpl.m_bItemsDirty ) + { + if ( i_rImpl.m_rPanelDeck.GetPanelCount() != i_rImpl.m_aItems.size() ) + { + OSL_ENSURE( false, "lcl_checkConsistency: inconsistent array sizes!" ); + return; + } + for ( size_t i = 0; i < i_rImpl.m_rPanelDeck.GetPanelCount(); ++i ) + { + if ( i_rImpl.m_rPanelDeck.GetPanel( i ).get() != i_rImpl.m_aItems[i].pPanel.get() ) + { + OSL_ENSURE( false, "lcl_checkConsistency: array elements are inconsistent!" ); + return; + } + } + } + } + + #define DBG_CHECK( data ) \ + lcl_checkConsistency( data ); + #else + #define DBG_CHECK( data ) \ + (void)data; + #endif + + //-------------------------------------------------------------------------------------------------------------- + class ClipItemRegion + { + public: + ClipItemRegion( const PanelTabBar_Impl& i_rImpl ) + :m_rDevice( i_rImpl.m_rTabBar ) + { + m_rDevice.Push( PUSH_CLIPREGION ); + m_rDevice.SetClipRegion( i_rImpl.m_aNormalizer.getTransformed( i_rImpl.m_aGeometry.getItemsRect(), i_rImpl.m_eTabAlignment ) ); + } + + ~ClipItemRegion() + { + m_rDevice.Pop(); + } + + private: + OutputDevice& m_rDevice; + }; + } + + //================================================================================================================== + //= PanelTabBar_Impl - implementation + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + PanelTabBar_Impl::PanelTabBar_Impl( PanelTabBar& i_rTabBar, IToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent ) + :m_rTabBar( i_rTabBar ) + ,m_aGeometry( i_eItemContent ) + ,m_aNormalizer() + ,m_eTabAlignment( i_eAlignment ) + ,m_rPanelDeck( i_rPanelDeck ) + ,m_aRenderDevice( i_rTabBar ) + ,m_pRenderer() + ,m_aHoveredItem() + ,m_aFocusedItem() + ,m_bMouseButtonDown( false ) + ,m_aItems() + ,m_bItemsDirty( true ) + ,m_aScrollBack( &i_rTabBar, WB_BEVELBUTTON ) + ,m_aScrollForward( &i_rTabBar, WB_BEVELBUTTON ) + ,m_nScrollPosition( 0 ) + { +#ifdef WNT + if ( m_aRenderDevice.IsNativeControlSupported( CTRL_TAB_ITEM, PART_ENTIRE_CONTROL ) ) + // this mode requires the NWF framework to be able to render those items onto a virtual + // device. For some frameworks (some GTK themes, in particular), this is known to fail. + // So, be on the safe side for the moment. + m_pRenderer.reset( new NWFTabItemRenderer( m_aRenderDevice ) ); + else +#endif + if ( m_aRenderDevice.IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) + m_pRenderer.reset( new NWFToolboxItemRenderer( m_aRenderDevice ) ); + else + m_pRenderer.reset( new VCLItemRenderer( m_aRenderDevice ) ); + + m_aRenderDevice.SetLineColor(); + + m_rPanelDeck.AddListener( *this ); + + m_aScrollBack.SetSymbol( IsVertical() ? SYMBOL_ARROW_UP : SYMBOL_ARROW_LEFT ); + m_aScrollBack.Show(); + m_aScrollBack.SetClickHdl( LINK( this, PanelTabBar_Impl, OnScroll ) ); + m_aScrollBack.SetAccessibleDescription( String( SvtResId( STR_SVT_ACC_BEGIN + 0 ) ) ); + m_aScrollBack.SetAccessibleName( m_aScrollBack.GetAccessibleDescription() ); + + m_aScrollForward.SetSymbol( IsVertical() ? SYMBOL_ARROW_DOWN : SYMBOL_ARROW_RIGHT ); + m_aScrollForward.Show(); + m_aScrollForward.SetClickHdl( LINK( this, PanelTabBar_Impl, OnScroll ) ); + m_aScrollForward.SetAccessibleDescription( String( SvtResId( STR_SVT_ACC_BEGIN + 1 ) ) ); + m_aScrollForward.SetAccessibleName( m_aScrollForward.GetAccessibleDescription() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::impl_calcItemRects() + { + m_aItems.resize(0); + + Point aCompletePos( m_aGeometry.getFirstItemPosition() ); + Point aIconOnlyPos( aCompletePos ); + Point aTextOnlyPos( aCompletePos ); + + for ( size_t i = 0; + i < m_rPanelDeck.GetPanelCount(); + ++i + ) + { + PToolPanel pPanel( m_rPanelDeck.GetPanel( i ) ); + + ItemDescriptor aItem; + aItem.pPanel = pPanel; + + Rectangle aContentArea; + + const Size aCompleteSize( impl_calculateItemContentSize( pPanel, TABITEM_IMAGE_AND_TEXT ) ); + const Size aIconOnlySize( impl_calculateItemContentSize( pPanel, TABITEM_IMAGE_ONLY ) ); + const Size aTextOnlySize( impl_calculateItemContentSize( pPanel, TABITEM_TEXT_ONLY ) ); + + // TODO: have one method calculating all sizes? + + // remember the three areas + aItem.aCompleteArea = Rectangle( aCompletePos, aCompleteSize ); + aItem.aIconOnlyArea = Rectangle( aIconOnlyPos, aIconOnlySize ); + aItem.aTextOnlyArea = Rectangle( aTextOnlyPos, aTextOnlySize ); + + m_aItems.push_back( aItem ); + + aCompletePos = aItem.aCompleteArea.TopRight(); + aIconOnlyPos = aItem.aIconOnlyArea.TopRight(); + aTextOnlyPos = aItem.aTextOnlyArea.TopRight(); + } + + m_bItemsDirty = false; + } + + //------------------------------------------------------------------------------------------------------------------ + Size PanelTabBar_Impl::impl_calculateItemContentSize( const PToolPanel& i_pPanel, const TabItemContent i_eItemContent ) const + { + // calculate the size needed for the content + OSL_ENSURE( i_eItemContent != TABITEM_AUTO, "PanelTabBar_Impl::impl_calculateItemContentSize: illegal TabItemContent value!" ); + + const Image aImage( i_pPanel->GetImage() ); + const bool bUseImage = !!aImage && ( i_eItemContent != TABITEM_TEXT_ONLY ); + + const ::rtl::OUString sItemText( i_pPanel->GetDisplayName() ); + const bool bUseText = ( sItemText.getLength() != 0 ) && ( i_eItemContent != TABITEM_IMAGE_ONLY ); + + Size aItemContentSize; + if ( bUseImage ) + { + aItemContentSize = aImage.GetSizePixel(); + } + + if ( bUseText ) + { + if ( bUseImage ) + aItemContentSize.Width() += ITEM_ICON_TEXT_DISTANCE; + + // add space for text + const Size aTextSize( m_rTabBar.GetCtrlTextWidth( sItemText ), m_rTabBar.GetTextHeight() ); + aItemContentSize.Width() += aTextSize.Width(); + aItemContentSize.Height() = ::std::max( aItemContentSize.Height(), aTextSize.Height() ); + + aItemContentSize.Width() += 2 * ITEM_TEXT_FLOW_SPACE; + } + + if ( !bUseImage && !bUseText ) + { + // have a minimal size - this is pure heuristics, but if it doesn't suit your needs, then give your panels + // a name and or image! :) + aItemContentSize = Size( 16, 16 ); + } + + aItemContentSize.Width() += 2 * ITEM_OUTER_SPACE; + aItemContentSize.Height() += 2 * ITEM_OUTER_SPACE; + + return aItemContentSize; + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::impl_renderItemContent( const PToolPanel& i_pPanel, const Rectangle& i_rContentArea, const TabItemContent i_eItemContent ) const + { + OSL_ENSURE( i_eItemContent != TABITEM_AUTO, "PanelTabBar_Impl::impl_renderItemContent: illegal TabItemContent value!" ); + + Rectangle aRenderArea( i_rContentArea ); + if ( IsVertical() ) + { + aRenderArea.Top() += ITEM_OUTER_SPACE; + } + else + { + aRenderArea.Left() += ITEM_OUTER_SPACE; + } + + // draw the image + const Image aItemImage( i_pPanel->GetImage() ); + const Size aImageSize( aItemImage.GetSizePixel() ); + const bool bUseImage = !!aItemImage && ( i_eItemContent != TABITEM_TEXT_ONLY ); + + if ( bUseImage ) + { + Point aImagePos; + if ( IsVertical() ) + { + aImagePos.X() = aRenderArea.Left() + ( aRenderArea.GetWidth() - aImageSize.Width() ) / 2; + aImagePos.Y() = aRenderArea.Top(); + } + else + { + aImagePos.X() = aRenderArea.Left(); + aImagePos.Y() = aRenderArea.Top() + ( aRenderArea.GetHeight() - aImageSize.Height() ) / 2; + } + m_rTabBar.DrawImage( aImagePos, aItemImage ); + } + + const ::rtl::OUString sItemText( i_pPanel->GetDisplayName() ); + const bool bUseText = ( sItemText.getLength() != 0 ) && ( i_eItemContent != TABITEM_IMAGE_ONLY ); + + if ( bUseText ) + { + if ( IsVertical() ) + { + if ( bUseImage ) + aRenderArea.Top() += aImageSize.Height() + ITEM_ICON_TEXT_DISTANCE; + aRenderArea.Top() += ITEM_TEXT_FLOW_SPACE; + } + else + { + if ( bUseImage ) + aRenderArea.Left() += aImageSize.Width() + ITEM_ICON_TEXT_DISTANCE; + aRenderArea.Left() += ITEM_TEXT_FLOW_SPACE; + } + + // draw the text + const Size aTextSize( m_rTabBar.GetCtrlTextWidth( sItemText ), m_rTabBar.GetTextHeight() ); + Point aTextPos( aRenderArea.TopLeft() ); + if ( IsVertical() ) + { + m_rTabBar.Push( PUSH_FONT ); + + Font aFont( m_rTabBar.GetFont() ); + aFont.SetOrientation( 2700 ); + aFont.SetVertical( TRUE ); + m_rTabBar.SetFont( aFont ); + + aTextPos.X() += aTextSize.Height(); + aTextPos.X() += ( aRenderArea.GetWidth() - aTextSize.Height() ) / 2; + } + else + { + aTextPos.Y() += ( aRenderArea.GetHeight() - aTextSize.Height() ) / 2; + } + + m_rTabBar.DrawText( aTextPos, sItemText ); + + if ( IsVertical() ) + { + m_rTabBar.Pop(); + } + } + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::CopyFromRenderDevice( const Rectangle& i_rLogicalRect ) const + { + BitmapEx aBitmap( m_aRenderDevice.GetBitmapEx( + i_rLogicalRect.TopLeft(), + Size( + i_rLogicalRect.GetSize().Width(), + i_rLogicalRect.GetSize().Height() + ) + ) ); + if ( IsVertical() ) + { + aBitmap.Rotate( 2700, COL_BLACK ); + if ( m_eTabAlignment == TABS_LEFT ) + aBitmap.Mirror( BMP_MIRROR_HORZ ); + } + else if ( m_eTabAlignment == TABS_BOTTOM ) + { + aBitmap.Mirror( BMP_MIRROR_VERT ); + } + + const Rectangle aActualRect( m_aNormalizer.getTransformed( i_rLogicalRect, m_eTabAlignment ) ); + m_rTabBar.DrawBitmapEx( aActualRect.TopLeft(), aBitmap ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::InvalidateItem( const size_t i_nItemIndex, const ItemFlags i_nAdditionalItemFlags ) const + { + const ItemDescriptor& rItem( m_aItems[ i_nItemIndex ] ); + const ItemFlags nItemFlags( impl_getItemFlags( i_nItemIndex ) | i_nAdditionalItemFlags ); + + const Rectangle aNormalizedContent( GetActualLogicalItemRect( rItem.GetCurrentRect() ) ); + const Rectangle aNormalizedBounds( m_pRenderer->calculateDecorations( aNormalizedContent, nItemFlags ) ); + + const Rectangle aActualBounds = m_aNormalizer.getTransformed( aNormalizedBounds, m_eTabAlignment ); + m_rTabBar.Invalidate( aActualBounds ); + } + + //------------------------------------------------------------------------------------------------------------------ + ItemFlags PanelTabBar_Impl::impl_getItemFlags( const size_t i_nItemIndex ) const + { + ItemFlags nItemFlags( ITEM_STATE_NORMAL ); + if ( m_aHoveredItem == i_nItemIndex ) + { + nItemFlags |= ITEM_STATE_HOVERED; + if ( m_bMouseButtonDown ) + nItemFlags |= ITEM_STATE_ACTIVE; + } + + if ( m_rPanelDeck.GetActivePanel() == i_nItemIndex ) + nItemFlags |= ITEM_STATE_ACTIVE; + + if ( m_aFocusedItem == i_nItemIndex ) + nItemFlags |= ITEM_STATE_FOCUSED; + + if ( 0 == i_nItemIndex ) + nItemFlags |= ITEM_POSITION_FIRST; + + if ( m_rPanelDeck.GetPanelCount() - 1 == i_nItemIndex ) + nItemFlags |= ITEM_POSITION_LAST; + + return nItemFlags; + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::DrawItem( const size_t i_nItemIndex, const Rectangle& i_rBoundaries ) const + { + const ItemDescriptor& rItem( m_aItems[ i_nItemIndex ] ); + const ItemFlags nItemFlags( impl_getItemFlags( i_nItemIndex ) ); + + // the normalized bounding and content rect + const Rectangle aNormalizedContent( GetActualLogicalItemRect( rItem.GetCurrentRect() ) ); + const Rectangle aNormalizedBounds( m_pRenderer->calculateDecorations( aNormalizedContent, nItemFlags ) ); + + // check whether the item actually overlaps with the painting area + if ( !i_rBoundaries.IsEmpty() ) + { + const Rectangle aItemRect( GetActualLogicalItemRect( rItem.GetCurrentRect() ) ); + if ( !aItemRect.IsOver( i_rBoundaries ) ) + return; + } + + m_rTabBar.SetUpdateMode( FALSE ); + + // the aligned bounding and content rect + const Rectangle aActualBounds = m_aNormalizer.getTransformed( aNormalizedBounds, m_eTabAlignment ); + const Rectangle aActualContent = m_aNormalizer.getTransformed( aNormalizedContent, m_eTabAlignment ); + + // render item "background" layer + m_pRenderer->preRenderItem( aNormalizedContent, nItemFlags ); + + // copy from the virtual device to ourself + CopyFromRenderDevice( aNormalizedBounds ); + + // render the actual item content + impl_renderItemContent( rItem.pPanel, aActualContent, rItem.eContent ); + + // render item "foreground" layer + m_pRenderer->postRenderItem( m_rTabBar, aActualBounds, nItemFlags ); + + m_rTabBar.SetUpdateMode( TRUE ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::EnsureItemsCache() + { + if ( m_bItemsDirty == false ) + { + DBG_CHECK( *this ); + return; + } + impl_calcItemRects(); + OSL_POSTCOND( m_bItemsDirty == false, "PanelTabBar_Impl::EnsureItemsCache: cache still dirty!" ); + DBG_CHECK( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::Relayout() + { + EnsureItemsCache(); + + const Size aOutputSize( m_rTabBar.GetOutputSizePixel() ); + m_aNormalizer = NormalizedArea( Rectangle( Point(), aOutputSize ), IsVertical() ); + const Size aLogicalOutputSize( m_aNormalizer.getReferenceSize() ); + + // forward actual output size to our render device + m_aRenderDevice.SetOutputSizePixel( aLogicalOutputSize ); + + // re-calculate the size of the scroll buttons and of the items + m_aGeometry.relayout( aLogicalOutputSize, m_aItems ); + + if ( m_aGeometry.getButtonBackRect().IsEmpty() ) + { + m_aScrollBack.Hide(); + } + else + { + const Rectangle aButtonBack( m_aNormalizer.getTransformed( m_aGeometry.getButtonBackRect(), m_eTabAlignment ) ); + m_aScrollBack.SetPosSizePixel( aButtonBack.TopLeft(), aButtonBack.GetSize() ); + m_aScrollBack.Show(); + } + + if ( m_aGeometry.getButtonForwardRect().IsEmpty() ) + { + m_aScrollForward.Hide(); + } + else + { + const Rectangle aButtonForward( m_aNormalizer.getTransformed( m_aGeometry.getButtonForwardRect(), m_eTabAlignment ) ); + m_aScrollForward.SetPosSizePixel( aButtonForward.TopLeft(), aButtonForward.GetSize() ); + m_aScrollForward.Show(); + } + + UpdateScrollButtons(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::boost::optional< size_t > PanelTabBar_Impl::FindItemForPoint( const Point& i_rPoint ) const + { + Point aPoint( IsVertical() ? i_rPoint.Y() : i_rPoint.X(), IsVertical() ? i_rPoint.X() : i_rPoint.Y() ); + + if ( !m_aGeometry.getItemsRect().IsInside( aPoint ) ) + return ::boost::optional< size_t >(); + + size_t i=0; + for ( ItemDescriptors::const_iterator item = m_aItems.begin(); + item != m_aItems.end(); + ++item, ++i + ) + { + Rectangle aItemRect( GetActualLogicalItemRect( item->GetCurrentRect() ) ); + if ( aItemRect.IsInside( aPoint ) ) + { + return ::boost::optional< size_t >( i ); + } + } + return ::boost::optional< size_t >(); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle PanelTabBar_Impl::GetItemScreenRect( const size_t i_nItemPos ) const + { + ENSURE_OR_RETURN( i_nItemPos < m_aItems.size(), "PanelTabBar_Impl::GetItemScreenRect: invalid item pos!", Rectangle() ); + const ItemDescriptor& rItem( m_aItems[ i_nItemPos ] ); + const Rectangle aItemRect( m_aNormalizer.getTransformed( + GetActualLogicalItemRect( rItem.GetCurrentRect() ), + m_eTabAlignment ) ); + + const Rectangle aTabBarRect( m_rTabBar.GetWindowExtentsRelative( NULL ) ); + return Rectangle( + Point( aTabBarRect.Left() + aItemRect.Left(), aTabBarRect.Top() + aItemRect.Top() ), + aItemRect.GetSize() + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::FocusItem( const ::boost::optional< size_t >& i_rItemPos ) + { + // reset old focus item + if ( !!m_aFocusedItem ) + InvalidateItem( *m_aFocusedItem ); + m_aFocusedItem.reset(); + + // mark the active icon as focused + if ( !!i_rItemPos ) + { + m_aFocusedItem = i_rItemPos; + InvalidateItem( *m_aFocusedItem ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + IMPL_LINK( PanelTabBar_Impl, OnScroll, const PushButton*, i_pButton ) + { + if ( i_pButton == &m_aScrollBack ) + { + OSL_ENSURE( m_nScrollPosition > 0, "PanelTabBar_Impl::OnScroll: inconsistency!" ); + --m_nScrollPosition; + m_rTabBar.Invalidate(); + } + else if ( i_pButton == &m_aScrollForward ) + { + OSL_ENSURE( m_nScrollPosition < m_aItems.size() - 1, "PanelTabBar_Impl::OnScroll: inconsistency!" ); + ++m_nScrollPosition; + m_rTabBar.Invalidate(); + } + + UpdateScrollButtons(); + + return 0L; + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle PanelTabBar_Impl::GetActualLogicalItemRect( const Rectangle& i_rLogicalItemRect ) const + { + // care for the offset imposed by our geometry, i.e. whether or not we have scroll buttons + Rectangle aItemRect( i_rLogicalItemRect ); + aItemRect.Move( m_aGeometry.getItemsRect().Left() - m_aGeometry.getButtonBackRect().Left(), 0 ); + + // care for the current scroll position + OSL_ENSURE( m_nScrollPosition < m_aItems.size(), "GetActualLogicalItemRect: invalid scroll position!" ); + if ( ( m_nScrollPosition > 0 ) && ( m_nScrollPosition < m_aItems.size() ) ) + { + long nOffsetX = m_aItems[ m_nScrollPosition ].GetCurrentRect().Left() - m_aItems[ 0 ].GetCurrentRect().Left(); + long nOffsetY = m_aItems[ m_nScrollPosition ].GetCurrentRect().Top() - m_aItems[ 0 ].GetCurrentRect().Top(); + aItemRect.Move( -nOffsetX, -nOffsetY ); + } + + return aItemRect; + } + + //================================================================================================================== + //= PanelTabBar_Impl + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) + { + EnsureItemsCache(); + + if ( !!i_rOldActive ) + InvalidateItem( *i_rOldActive, ITEM_STATE_ACTIVE ); + if ( !!i_rNewActive ) + InvalidateItem( *i_rNewActive ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::LayouterChanged( const PDeckLayouter& i_rNewLayouter ) + { + // not interested in + (void)i_rNewLayouter; + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar_Impl::Dying() + { + // not interested in - the notifier is a member of this instance here, so we're dying ourself at the moment + } + + //================================================================================================================== + //= PanelTabBar + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + PanelTabBar::PanelTabBar( Window& i_rParentWindow, IToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent ) + :Control( &i_rParentWindow, 0 ) + ,m_pImpl( new PanelTabBar_Impl( *this, i_rPanelDeck, i_eAlignment, i_eItemContent ) ) + { + DBG_CHECK( *m_pImpl ); + } + + //------------------------------------------------------------------------------------------------------------------ + PanelTabBar::~PanelTabBar() + { + } + + //------------------------------------------------------------------------------------------------------------------ + TabItemContent PanelTabBar::GetTabItemContent() const + { + return m_pImpl->m_aGeometry.getItemContent(); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::SetTabItemContent( const TabItemContent& i_eItemContent ) + { + m_pImpl->m_aGeometry.setItemContent( i_eItemContent ); + m_pImpl->Relayout(); + Invalidate(); + } + + //------------------------------------------------------------------------------------------------------------------ + IToolPanelDeck& PanelTabBar::GetPanelDeck() const + { + DBG_CHECK( *m_pImpl ); + return m_pImpl->m_rPanelDeck; + } + + //------------------------------------------------------------------------------------------------------------------ + Size PanelTabBar::GetOptimalSize( WindowSizeType i_eType ) const + { + m_pImpl->EnsureItemsCache(); + Size aOptimalSize( m_pImpl->m_aGeometry.getOptimalSize( m_pImpl->m_aItems, i_eType == WINDOWSIZE_MINIMUM ) ); + if ( m_pImpl->IsVertical() ) + ::std::swap( aOptimalSize.Width(), aOptimalSize.Height() ); + return aOptimalSize; + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::Resize() + { + Control::Resize(); + m_pImpl->Relayout(); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::Paint( const Rectangle& i_rRect ) + { + m_pImpl->EnsureItemsCache(); + + // background + const Rectangle aNormalizedPaintArea( m_pImpl->m_aNormalizer.getNormalized( i_rRect, m_pImpl->m_eTabAlignment ) ); + m_pImpl->m_aRenderDevice.Push( PUSH_CLIPREGION ); + m_pImpl->m_aRenderDevice.SetClipRegion( aNormalizedPaintArea ); + m_pImpl->m_pRenderer->renderBackground(); + m_pImpl->m_aRenderDevice.Pop(); + m_pImpl->CopyFromRenderDevice( aNormalizedPaintArea ); + + // ensure the items really paint into their own playground only + ClipItemRegion aClipItems( *m_pImpl ); + + const Rectangle aLogicalPaintRect( m_pImpl->m_aNormalizer.getNormalized( i_rRect, m_pImpl->m_eTabAlignment ) ); + + const ::boost::optional< size_t > aActivePanel( m_pImpl->m_rPanelDeck.GetActivePanel() ); + const ::boost::optional< size_t > aHoveredPanel( m_pImpl->m_aHoveredItem ); + + // items: + // 1. paint all non-active, non-hovered items + size_t i=0; + for ( ItemDescriptors::const_iterator item = m_pImpl->m_aItems.begin(); + item != m_pImpl->m_aItems.end(); + ++item, ++i + ) + { + if ( i == aActivePanel ) + continue; + + if ( aHoveredPanel == i ) + continue; + + m_pImpl->DrawItem( i, aLogicalPaintRect ); + } + + // 2. paint the item which is hovered, /without/ the mouse button pressed down + if ( !!aHoveredPanel && !m_pImpl->m_bMouseButtonDown ) + m_pImpl->DrawItem( *aHoveredPanel, aLogicalPaintRect ); + + // 3. paint the active item + if ( !!aActivePanel ) + m_pImpl->DrawItem( *aActivePanel, aLogicalPaintRect ); + + // 4. paint the item which is hovered, /with/ the mouse button pressed down + if ( !!aHoveredPanel && m_pImpl->m_bMouseButtonDown ) + m_pImpl->DrawItem( *aHoveredPanel, aLogicalPaintRect ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::MouseMove( const MouseEvent& i_rMouseEvent ) + { + m_pImpl->EnsureItemsCache(); + + ::boost::optional< size_t > aOldItem( m_pImpl->m_aHoveredItem ); + ::boost::optional< size_t > aNewItem( m_pImpl->FindItemForPoint( i_rMouseEvent.GetPosPixel() ) ); + + if ( i_rMouseEvent.IsLeaveWindow() ) + aNewItem.reset(); + + if ( aOldItem != aNewItem ) + { + if ( !!aOldItem ) + m_pImpl->InvalidateItem( *aOldItem ); + + m_pImpl->m_aHoveredItem = aNewItem; + + if ( !!aNewItem ) + m_pImpl->InvalidateItem( *aNewItem ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::MouseButtonDown( const MouseEvent& i_rMouseEvent ) + { + Control::MouseButtonDown( i_rMouseEvent ); + + if ( !i_rMouseEvent.IsLeft() ) + return; + + m_pImpl->EnsureItemsCache(); + + ::boost::optional< size_t > aHitItem( m_pImpl->FindItemForPoint( i_rMouseEvent.GetPosPixel() ) ); + if ( !aHitItem ) + return; + + CaptureMouse(); + m_pImpl->m_bMouseButtonDown = true; + + m_pImpl->InvalidateItem( *aHitItem ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::MouseButtonUp( const MouseEvent& i_rMouseEvent ) + { + Control::MouseButtonUp( i_rMouseEvent ); + + if ( m_pImpl->m_bMouseButtonDown ) + { + ::boost::optional< size_t > aHitItem( m_pImpl->FindItemForPoint( i_rMouseEvent.GetPosPixel() ) ); + if ( !!aHitItem ) + { + // re-draw that item now that we're not in mouse-down mode anymore + m_pImpl->InvalidateItem( *aHitItem ); + // activate the respective panel + m_pImpl->m_rPanelDeck.ActivatePanel( *aHitItem ); + } + + OSL_ENSURE( IsMouseCaptured(), "PanelTabBar::MouseButtonUp: inconsistency!" ); + if ( IsMouseCaptured() ) + ReleaseMouse(); + m_pImpl->m_bMouseButtonDown = false; + } + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::RequestHelp( const HelpEvent& i_rHelpEvent ) + { + m_pImpl->EnsureItemsCache(); + + ::boost::optional< size_t > aHelpItem( m_pImpl->FindItemForPoint( ScreenToOutputPixel( i_rHelpEvent.GetMousePosPixel() ) ) ); + if ( !aHelpItem ) + return; + + const ItemDescriptor& rItem( m_pImpl->m_aItems[ *aHelpItem ] ); + if ( rItem.eContent != TABITEM_IMAGE_ONLY ) + // if the text is displayed for the item, we do not need to show it as tooltip + return; + + const ::rtl::OUString sItemText( rItem.pPanel->GetDisplayName() ); + if ( i_rHelpEvent.GetMode() == HELPMODE_BALLOON ) + Help::ShowBalloon( this, OutputToScreenPixel( rItem.GetCurrentRect().Center() ), rItem.GetCurrentRect(), sItemText ); + else + Help::ShowQuickHelp( this, rItem.GetCurrentRect(), sItemText ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::GetFocus() + { + Control::GetFocus(); + if ( !m_pImpl->m_aFocusedItem ) + m_pImpl->FocusItem( m_pImpl->m_rPanelDeck.GetActivePanel() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::LoseFocus() + { + Control::LoseFocus(); + + if ( !!m_pImpl->m_aFocusedItem ) + { + m_pImpl->InvalidateItem( *m_pImpl->m_aFocusedItem ); + } + + m_pImpl->m_aFocusedItem.reset(); + } + + //------------------------------------------------------------------------------------------------------------------ + class KeyInputHandler + { + public: + KeyInputHandler( Control& i_rControl, const KeyEvent& i_rKeyEvent ) + :m_rControl( i_rControl ) + ,m_rKeyEvent( i_rKeyEvent ) + ,m_bHandled( false ) + { + } + + ~KeyInputHandler() + { + if ( !m_bHandled ) + m_rControl.Control::KeyInput( m_rKeyEvent ); + } + + void setHandled() + { + m_bHandled = true; + } + + private: + Control& m_rControl; + const KeyEvent& m_rKeyEvent; + bool m_bHandled; + }; + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::KeyInput( const KeyEvent& i_rKeyEvent ) + { + KeyInputHandler aKeyInputHandler( *this, i_rKeyEvent ); + + const KeyCode& rKeyCode( i_rKeyEvent.GetKeyCode() ); + if ( rKeyCode.GetModifier() != 0 ) + // only interested in mere key presses + return; + + // if there are less than 2 panels, we cannot travel them ... + const size_t nPanelCount( m_pImpl->m_rPanelDeck.GetPanelCount() ); + if ( nPanelCount < 2 ) + return; + + OSL_PRECOND( !!m_pImpl->m_aFocusedItem, "PanelTabBar::KeyInput: we should have a focused item here!" ); + // if we get KeyInput events, we should have the focus. In this case, m_aFocusedItem should not be empty, + // except if there are no panels, but then we bail out of this method here earlier ... + + bool bFocusNext = false; + bool bFocusPrev = false; + + switch ( rKeyCode.GetCode() ) + { + case KEY_UP: bFocusPrev = true; break; + case KEY_DOWN: bFocusNext = true; break; + case KEY_LEFT: + if ( IsRTLEnabled() ) + bFocusNext = true; + else + bFocusPrev = true; + break; + case KEY_RIGHT: + if ( IsRTLEnabled() ) + bFocusPrev = true; + else + bFocusNext = true; + break; + case KEY_RETURN: + m_pImpl->m_rPanelDeck.ActivatePanel( *m_pImpl->m_aFocusedItem ); + break; + } + + if ( !bFocusNext && !bFocusPrev ) + return; + + m_pImpl->InvalidateItem( *m_pImpl->m_aFocusedItem ); + if ( bFocusNext ) + { + m_pImpl->m_aFocusedItem.reset( ( *m_pImpl->m_aFocusedItem + 1 ) % nPanelCount ); + } + else + { + m_pImpl->m_aFocusedItem.reset( ( *m_pImpl->m_aFocusedItem + nPanelCount - 1 ) % nPanelCount ); + } + m_pImpl->InvalidateItem( *m_pImpl->m_aFocusedItem ); + + // don't delegate to base class + aKeyInputHandler.setHandled(); + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::DataChanged( const DataChangedEvent& i_rDataChanedEvent ) + { + Control::DataChanged( i_rDataChanedEvent ); + + if ( ( i_rDataChanedEvent.GetType() == DATACHANGED_SETTINGS ) + && ( ( i_rDataChanedEvent.GetFlags() & SETTINGS_STYLE ) != 0 ) + ) + { + Invalidate(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + bool PanelTabBar::IsVertical() const + { + return m_pImpl->IsVertical(); + } + + //------------------------------------------------------------------------------------------------------------------ + PushButton& PanelTabBar::GetScrollButton( const bool i_bForward ) + { + return i_bForward ? m_pImpl->m_aScrollForward : m_pImpl->m_aScrollBack; + } + + //------------------------------------------------------------------------------------------------------------------ + ::boost::optional< size_t > PanelTabBar::GetFocusedPanelItem() const + { + return m_pImpl->m_aFocusedItem; + } + + //------------------------------------------------------------------------------------------------------------------ + void PanelTabBar::FocusPanelItem( const size_t i_nItemPos ) + { + ENSURE_OR_RETURN_VOID( i_nItemPos < m_pImpl->m_rPanelDeck.GetPanelCount(), "PanelTabBar::FocusPanelItem: illegal item pos!" ); + + if ( !HasChildPathFocus() ) + GrabFocus(); + + m_pImpl->FocusItem( i_nItemPos ); + OSL_POSTCOND( !!m_pImpl->m_aFocusedItem, "PanelTabBar::FocusPanelItem: have the focus, but no focused item?" ); + if ( !!m_pImpl->m_aFocusedItem ) + m_pImpl->InvalidateItem( *m_pImpl->m_aFocusedItem ); + m_pImpl->m_aFocusedItem.reset( i_nItemPos ); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle PanelTabBar::GetItemScreenRect( const size_t i_nItemPos ) const + { + return m_pImpl->GetItemScreenRect( i_nItemPos ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XWindowPeer > PanelTabBar::GetComponentInterface( BOOL i_bCreate ) + { + Reference< XWindowPeer > xWindowPeer( Control::GetComponentInterface( FALSE ) ); + if ( !xWindowPeer.is() && i_bCreate ) + { + xWindowPeer.set( new PanelTabBarPeer( *this ) ); + SetComponentInterface( xWindowPeer ); + } + return xWindowPeer; + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/paneltabbarpeer.cxx b/svtools/source/toolpanel/paneltabbarpeer.cxx new file mode 100644 index 000000000000..d8329109ffb4 --- /dev/null +++ b/svtools/source/toolpanel/paneltabbarpeer.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "paneltabbarpeer.hxx" +#include "svtools/toolpanel/paneltabbar.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/DisposedException.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace svt +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::accessibility::XAccessibleContext; + using ::com::sun::star::lang::DisposedException; + /** === end UNO using === **/ + + //================================================================================================================== + //= PanelTabBarPeer + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + PanelTabBarPeer::PanelTabBarPeer( PanelTabBar& i_rTabBar ) + :VCLXWindow() + ,m_pTabBar( &i_rTabBar ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + PanelTabBarPeer::~PanelTabBarPeer() + { + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessibleContext > PanelTabBarPeer::CreateAccessibleContext() + { + ::vos::OGuard aSolarGuard( GetMutex() ); + if ( m_pTabBar == NULL ) + throw DisposedException( ::rtl::OUString(), *this ); + + + + Window* pAccessibleParent( m_pTabBar->GetAccessibleParentWindow() ); + ENSURE_OR_RETURN( pAccessibleParent != NULL, "no accessible parent => no accessible context", NULL ); + Reference< XAccessible > xAccessibleParent( pAccessibleParent->GetAccessible(), UNO_SET_THROW ); + return m_aAccessibleFactory.getFactory().createAccessibleToolPanelTabBar( xAccessibleParent, m_pTabBar->GetPanelDeck(), *m_pTabBar ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL PanelTabBarPeer::dispose() throw(RuntimeException) + { + { + ::vos::OGuard aSolarGuard( GetMutex() ); + m_pTabBar = NULL; + } + VCLXWindow::dispose(); + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/paneltabbarpeer.hxx b/svtools/source/toolpanel/paneltabbarpeer.hxx new file mode 100644 index 000000000000..7c2e5188d994 --- /dev/null +++ b/svtools/source/toolpanel/paneltabbarpeer.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVT_PANELTABBARPEER_HXX +#define SVT_PANELTABBARPEER_HXX + +#include "svtaccessiblefactory.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <toolkit/awt/vclxwindow.hxx> + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + class PanelTabBar; + //==================================================================== + //= PanelTabBarPeer + //==================================================================== + class PanelTabBarPeer : public VCLXWindow + { + public: + PanelTabBarPeer( PanelTabBar& i_rTabBar ); + + protected: + ~PanelTabBarPeer(); + + // VCLXWindow overridables + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > CreateAccessibleContext(); + + // XComponent + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + private: + AccessibleFactoryAccess m_aAccessibleFactory; + PanelTabBar* m_pTabBar; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVT_PANELTABBARPEER_HXX diff --git a/svtools/source/toolpanel/refbase.cxx b/svtools/source/toolpanel/refbase.cxx new file mode 100644 index 000000000000..f41aa2d9bb9c --- /dev/null +++ b/svtools/source/toolpanel/refbase.cxx @@ -0,0 +1,56 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "svtools/toolpanel/refbase.hxx" + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= RefBase + //==================================================================== + //-------------------------------------------------------------------- + oslInterlockedCount SAL_CALL RefBase::acquire() + { + return osl_incrementInterlockedCount( &m_refCount ); + } + + //-------------------------------------------------------------------- + oslInterlockedCount SAL_CALL RefBase::release() + { + oslInterlockedCount newCount = osl_decrementInterlockedCount( &m_refCount ); + if ( 0 == newCount ) + delete this; + return newCount; + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/tabbargeometry.cxx b/svtools/source/toolpanel/tabbargeometry.cxx new file mode 100644 index 000000000000..45c40cee6ef2 --- /dev/null +++ b/svtools/source/toolpanel/tabbargeometry.cxx @@ -0,0 +1,328 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "tabbargeometry.hxx" + +#include <basegfx/range/b2drange.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/numeric/ftools.hxx> + +#include <vcl/window.hxx> + +#include <algorithm> + +// the width (or height, depending on alignment) of the scroll buttons +#define BUTTON_FLOW_WIDTH 20 +// the space between the scroll buttons and the items +#define BUTTON_FLOW_SPACE 2 +// outer space to apply between the tab bar borders and any content. Note that those refer to a "normalized" geometry, +// i.e. if the tab bar were aligned at the top +#define OUTER_SPACE_LEFT 2 +#define OUTER_SPACE_TOP 4 +#define OUTER_SPACE_RIGHT 4 +#define OUTER_SPACE_BOTTOM 2 + +// outer space to apply between the area for the items, and the actual items. They refer to a normalized geometry. +#define ITEMS_INSET_LEFT 4 +#define ITEMS_INSET_TOP 3 +#define ITEMS_INSET_RIGHT 4 +#define ITEMS_INSET_BOTTOM 0 + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + //-------------------------------------------------------------------------------------------------------------- + static void lcl_transform( Rectangle& io_rRect, const ::basegfx::B2DHomMatrix& i_rTransformation ) + { + ::basegfx::B2DRange aRect( io_rRect.Left(), io_rRect.Top(), io_rRect.Right(), io_rRect.Bottom() ); + aRect.transform( i_rTransformation ); + io_rRect.Left() = long( aRect.getMinX() ); + io_rRect.Top() = long( aRect.getMinY() ); + io_rRect.Right() = long( aRect.getMaxX() ); + io_rRect.Bottom() = long( aRect.getMaxY() ); + } + + //-------------------------------------------------------------------------------------------------------------- + /** transforms the given, possible rotated playground, + */ + void lcl_rotate( const Rectangle& i_rReference, Rectangle& io_rArea, const bool i_bRight ) + { + // step 1: move the to-be-upper-left corner (left/bottom) of the rectangle to (0,0) + ::basegfx::B2DHomMatrix aTransformation; + aTransformation.translate( + i_bRight ? -i_rReference.Left() : -i_rReference.Right(), + i_bRight ? -i_rReference.Bottom() : -i_rReference.Top() + ); + + // step 2: rotate by -90 degrees + aTransformation.rotate( i_bRight ? +F_PI2 : -F_PI2 ); + // note: + // on the screen, the ordinate goes top-down, while basegfx calculates in a system where the + // ordinate goes bottom-up; thus the "wrong" sign before F_PI2 here + + // step 3: move back to original coordinates + aTransformation.translate( i_rReference.Left(), i_rReference.Top() ); + + // apply transformation + lcl_transform( io_rArea, aTransformation ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void lcl_mirrorHorizontally( const Rectangle& i_rReferenceArea, Rectangle& io_rArea ) + { + io_rArea.Left() = i_rReferenceArea.Left() + i_rReferenceArea.Right() - io_rArea.Left(); + io_rArea.Right() = i_rReferenceArea.Left() + i_rReferenceArea.Right() - io_rArea.Right(); + ::std::swap( io_rArea.Left(), io_rArea.Right() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void lcl_mirrorVertically( const Rectangle& i_rReferenceArea, Rectangle& io_rArea ) + { + io_rArea.Top() = i_rReferenceArea.Top() + i_rReferenceArea.Bottom() - io_rArea.Top(); + io_rArea.Bottom() = i_rReferenceArea.Top() + i_rReferenceArea.Bottom() - io_rArea.Bottom(); + ::std::swap( io_rArea.Top(), io_rArea.Bottom() ); + } + + //================================================================================================================== + //= NormalizedArea + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + NormalizedArea::NormalizedArea() + :m_aReference() + { + } + + //------------------------------------------------------------------------------------------------------------------ + NormalizedArea::NormalizedArea( const Rectangle& i_rReference, const bool i_bIsVertical ) + :m_aReference( i_bIsVertical ? Rectangle( i_rReference.TopLeft(), Size( i_rReference.GetHeight(), i_rReference.GetWidth() ) ) : i_rReference ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle NormalizedArea::getTransformed( const Rectangle& i_rArea, const TabAlignment i_eTargetAlignment ) const + { + Rectangle aResult( i_rArea ); + + if ( ( i_eTargetAlignment == TABS_RIGHT ) + || ( i_eTargetAlignment == TABS_LEFT ) + ) + { + lcl_rotate( m_aReference, aResult, true ); + + if ( i_eTargetAlignment == TABS_LEFT ) + { + Rectangle aReference( m_aReference ); + aReference.Transpose(); + lcl_mirrorHorizontally( aReference, aResult ); + } + } + else + if ( i_eTargetAlignment == TABS_BOTTOM ) + { + lcl_mirrorVertically( m_aReference, aResult ); + } + + return aResult; + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle NormalizedArea::getNormalized( const Rectangle& i_rArea, const TabAlignment i_eTargetAlignment ) const + { + Rectangle aResult( i_rArea ); + + if ( ( i_eTargetAlignment == TABS_RIGHT ) + || ( i_eTargetAlignment == TABS_LEFT ) + ) + { + Rectangle aReference( m_aReference ); + lcl_rotate( m_aReference, aReference, true ); + + if ( i_eTargetAlignment == TABS_LEFT ) + { + lcl_mirrorHorizontally( aReference, aResult ); + } + + lcl_rotate( aReference, aResult, false ); + } + else + if ( i_eTargetAlignment == TABS_BOTTOM ) + { + lcl_mirrorVertically( m_aReference, aResult ); + } + return aResult; + } + + //================================================================================================================== + //= TabBarGeometry + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + TabBarGeometry::TabBarGeometry( const TabItemContent i_eItemContent ) + :m_eTabItemContent( i_eItemContent ) + ,m_aItemsInset() + ,m_aButtonBackRect() + ,m_aItemsRect() + ,m_aButtonForwardRect() + { + m_aItemsInset.Left() = ITEMS_INSET_LEFT; + m_aItemsInset.Top() = ITEMS_INSET_TOP; + m_aItemsInset.Right() = ITEMS_INSET_RIGHT; + m_aItemsInset.Bottom() = ITEMS_INSET_BOTTOM; + } + + //------------------------------------------------------------------------------------------------------------------ + TabBarGeometry::~TabBarGeometry() + { + } + + //------------------------------------------------------------------------------------------------------------------ + bool TabBarGeometry::impl_fitItems( ItemDescriptors& io_rItems ) const + { + if ( io_rItems.empty() ) + // nothing to do, "no items" perfectly fit into any space we have ... + return true; + + // the available size + Size aOutputSize( getItemsRect().GetSize() ); + // shrunk by the outer space + aOutputSize.Width() -= m_aItemsInset.Right(); + aOutputSize.Height() -= m_aItemsInset.Bottom(); + const Rectangle aFitInto( Point( 0, 0 ), aOutputSize ); + + TabItemContent eItemContent( getItemContent() ); + if ( eItemContent == TABITEM_AUTO ) + { + // the "content modes" to try + TabItemContent eTryThis[] = + { + TABITEM_IMAGE_ONLY, // assumed to have the smallest rects + TABITEM_TEXT_ONLY, + TABITEM_IMAGE_AND_TEXT // assumed to have the largest rects + }; + + + // determine which of the different version fits + eItemContent = eTryThis[0]; + size_t nTryIndex = 2; + while ( nTryIndex > 0 ) + { + const Point aBottomRight( io_rItems.rbegin()->GetRect( eTryThis[ nTryIndex ] ).BottomRight() ); + if ( aFitInto.IsInside( aBottomRight ) ) + { + eItemContent = eTryThis[ nTryIndex ]; + break; + } + --nTryIndex; + } + } + + // propagate to the items + for ( ItemDescriptors::iterator item = io_rItems.begin(); + item != io_rItems.end(); + ++item + ) + { + item->eContent = eItemContent; + } + + const ItemDescriptor& rLastItem( *io_rItems.rbegin() ); + const Point aLastItemBottomRight( rLastItem.GetCurrentRect().BottomRight() ); + return aFitInto.Left() <= aLastItemBottomRight.X() + && aFitInto.Right() >= aLastItemBottomRight.X(); + } + + //------------------------------------------------------------------------------------------------------------------ + Size TabBarGeometry::getOptimalSize( ItemDescriptors& io_rItems, const bool i_bMinimalSize ) const + { + if ( io_rItems.empty() ) + return Size( + m_aItemsInset.Left() + m_aItemsInset.Right(), + m_aItemsInset.Top() + m_aItemsInset.Bottom() + ); + + // the rect of the last item + const Rectangle& rLastItemRect( i_bMinimalSize ? io_rItems.rbegin()->aIconOnlyArea : io_rItems.rbegin()->aCompleteArea ); + return Size( + rLastItemRect.Left() + 1 + m_aItemsInset.Right(), + rLastItemRect.Top() + 1 + rLastItemRect.Bottom() + m_aItemsInset.Bottom() + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void TabBarGeometry::relayout( const Size& i_rActualOutputSize, ItemDescriptors& io_rItems ) + { + // assume all items fit + Point aButtonBackPos( OUTER_SPACE_LEFT, OUTER_SPACE_TOP ); + m_aButtonBackRect = Rectangle( aButtonBackPos, Size( 1, 1 ) ); + m_aButtonBackRect.SetEmpty(); + + Point aButtonForwardPos( i_rActualOutputSize.Width(), OUTER_SPACE_TOP ); + m_aButtonForwardRect = Rectangle( aButtonForwardPos, Size( 1, 1 ) ); + m_aButtonForwardRect.SetEmpty(); + + Point aItemsPos( OUTER_SPACE_LEFT, 0 ); + Size aItemsSize( i_rActualOutputSize.Width() - OUTER_SPACE_LEFT - OUTER_SPACE_RIGHT, i_rActualOutputSize.Height() ); + m_aItemsRect = Rectangle( aItemsPos, aItemsSize ); + + if ( !impl_fitItems( io_rItems ) ) + { + // assumption was wrong, the items do not fit => calculate rects for the scroll buttons + const Size aButtonSize( BUTTON_FLOW_WIDTH, i_rActualOutputSize.Height() - OUTER_SPACE_TOP - OUTER_SPACE_BOTTOM ); + + aButtonBackPos = Point( OUTER_SPACE_LEFT, OUTER_SPACE_TOP ); + m_aButtonBackRect = Rectangle( aButtonBackPos, aButtonSize ); + + aButtonForwardPos = Point( i_rActualOutputSize.Width() - BUTTON_FLOW_WIDTH - OUTER_SPACE_RIGHT, OUTER_SPACE_TOP ); + m_aButtonForwardRect = Rectangle( aButtonForwardPos, aButtonSize ); + + aItemsPos.X() = aButtonBackPos.X() + aButtonSize.Width() + BUTTON_FLOW_SPACE; + aItemsSize.Width() = aButtonForwardPos.X() - BUTTON_FLOW_SPACE - aItemsPos.X(); + m_aItemsRect = Rectangle( aItemsPos, aItemsSize ); + + // fit items, again. In the TABITEM_AUTO case, the smaller playground for the items might lead to another + // item content. + impl_fitItems( io_rItems ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + Point TabBarGeometry::getFirstItemPosition() const + { + return Point( m_aItemsInset.Left(), m_aItemsInset.Top() ); + } + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... diff --git a/svtools/source/toolpanel/tabbargeometry.hxx b/svtools/source/toolpanel/tabbargeometry.hxx new file mode 100644 index 000000000000..059d69a3e233 --- /dev/null +++ b/svtools/source/toolpanel/tabbargeometry.hxx @@ -0,0 +1,137 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef TABBARGEOMETRY_HXX +#define TABBARGEOMETRY_HXX + +#include "svtools/toolpanel/tabalignment.hxx" + +#include "tabitemdescriptor.hxx" + +#include <tools/gen.hxx> +#include <tools/svborder.hxx> + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + //================================================================================================================== + //= NormalizedArea + //================================================================================================================== + /** a rectangle which automatically translates between unrotated and rotated geometry. + + It can be operated as if it were an unrotated area, but is able to provide corrdinates of rotated objects, + relative to its playground. + */ + class NormalizedArea + { + public: + NormalizedArea(); + NormalizedArea( const Rectangle& i_rReference, const bool i_bIsVertical ); + + /** transforms a rectangle, relative to our playground, into a coordinate system defined by the given alignment + @param i_rArea + the area which is to be transformed. + */ + Rectangle getTransformed( + const Rectangle& i_rArea, + const TabAlignment i_eTargetAlignment + ) const; + + /** normalizes an already transformed rectangle + @param i_rArea + the area which is to be normalized. + */ + Rectangle getNormalized( + const Rectangle& i_rArea, + const TabAlignment i_eTargetAlignment + ) const; + + + Size getReferenceSize() const { return m_aReference.GetSize(); } + const Rectangle& + getReference() const { return m_aReference; } + + private: + // the normalized reference area + Rectangle m_aReference; + }; + + //================================================================================================================== + //= TabBarGeometry + //================================================================================================================== + class TabBarGeometry_Impl; + class TabBarGeometry + { + public: + TabBarGeometry( const TabItemContent i_eItemContent ); + ~TabBarGeometry(); + + // retrieves the rectangle to be occupied by the button for scrolling backward through the items + const Rectangle& getButtonBackRect() const { return m_aButtonBackRect; } + // retrieves the rectangle to be occupied by the items + const Rectangle& getItemsRect() const { return m_aItemsRect; } + // retrieves the rectangle to be occupied by the button for scrolling forward through the items + const Rectangle& getButtonForwardRect() const { return m_aButtonForwardRect; } + + inline TabItemContent + getItemContent() const { return m_eTabItemContent; } + inline void setItemContent( const TabItemContent i_eItemContent ) { m_eTabItemContent = i_eItemContent; } + + /** adjusts the sizes of the buttons and the item's playground, plus the sizes of the items + */ + void relayout( const Size& i_rActualOutputSize, ItemDescriptors& io_rItems ); + + /** calculates the optimal size of the tab bar, depending on the item's sizes + */ + Size getOptimalSize( ItemDescriptors& io_rItems, const bool i_bMinimalSize ) const; + + /** retrieves the position where the first item should start, relative to the item rect + */ + Point getFirstItemPosition() const; + + private: + bool impl_fitItems( ItemDescriptors& io_rItems ) const; + + private: + /// specifies the content to be displayed in the tab items + TabItemContent m_eTabItemContent; + /// specifies the inset to be used in the items area, depends on the actual alignment + SvBorder m_aItemsInset; + // the (logical) rectangle to be used for the "back" button, empty if the button is not needed + Rectangle m_aButtonBackRect; + // the (logical) rectangle to be used for the items + Rectangle m_aItemsRect; + // the (logical) rectangle to be used for the "forward" button, empty if the button is not needed + Rectangle m_aButtonForwardRect; + }; + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... + +#endif // TABBARGEOMETRY_HXX diff --git a/svtools/source/toolpanel/tabitemdescriptor.hxx b/svtools/source/toolpanel/tabitemdescriptor.hxx new file mode 100644 index 000000000000..8005816b0fe2 --- /dev/null +++ b/svtools/source/toolpanel/tabitemdescriptor.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef TABITEMDESCRIPTOR_HXX +#define TABITEMDESCRIPTOR_HXX + +#include "svtools/toolpanel/toolpanel.hxx" +#include "svtools/toolpanel/tabitemcontent.hxx" + +#include <tools/gen.hxx> +#include <osl/diagnose.h> + +#include <vector> + +//........................................................................ +namespace svt +{ +//........................................................................ + + //================================================================================================================== + //= ItemDescriptor + //================================================================================================================== + struct ItemDescriptor + { + PToolPanel pPanel; + Rectangle aCompleteArea; // bounding area if the both text and icon are to be rendererd + Rectangle aIconOnlyArea; // bounding area if the icon is to be rendererd + Rectangle aTextOnlyArea; // bounding area if the text is to be rendererd + TabItemContent eContent; + // content to be used for this particular item. Might differ from item content which has been set + // up for the complete control, in case not the complete content fits into the available space. + + ItemDescriptor() + :pPanel() + ,aCompleteArea() + ,aIconOnlyArea() + ,aTextOnlyArea() + ,eContent( TABITEM_IMAGE_AND_TEXT ) + { + } + + const Rectangle& GetRect( const TabItemContent i_eItemContent ) const + { + OSL_ENSURE( i_eItemContent != TABITEM_AUTO, "ItemDescriptor::GetRect: illegal value!" ); + + return ( i_eItemContent == TABITEM_IMAGE_AND_TEXT ) + ? aCompleteArea + : ( ( i_eItemContent == TABITEM_TEXT_ONLY ) + ? aTextOnlyArea + : aIconOnlyArea + ); + } + + const Rectangle& GetCurrentRect() const + { + return GetRect( eContent ); + } + }; + + typedef ::std::vector< ItemDescriptor > ItemDescriptors; + + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // TABITEMDESCRIPTOR_HXX diff --git a/svtools/source/toolpanel/tablayouter.cxx b/svtools/source/toolpanel/tablayouter.cxx new file mode 100755 index 000000000000..f68bbc1bbd0f --- /dev/null +++ b/svtools/source/toolpanel/tablayouter.cxx @@ -0,0 +1,262 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "svtools/toolpanel/tablayouter.hxx" +#include "svtools/toolpanel/toolpaneldeck.hxx" +#include "svtools/toolpanel/paneltabbar.hxx" +#include "svtaccessiblefactory.hxx" + +#include <tools/gen.hxx> +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace svt +{ +//........................................................................ + + using ::com::sun::star::uno::Reference; + using ::com::sun::star::accessibility::XAccessible; + + //==================================================================== + //= TabDeckLayouter_Data + //==================================================================== + struct TabDeckLayouter_Data + { + TabAlignment eAlignment; + IToolPanelDeck& rPanels; + ::std::auto_ptr< PanelTabBar > pTabBar; + AccessibleFactoryAccess aAccessibleFactory; + + TabDeckLayouter_Data( Window& i_rParent, IToolPanelDeck& i_rPanels, + const TabAlignment i_eAlignment, const TabItemContent i_eItemContent ) + :eAlignment( i_eAlignment ) + ,rPanels( i_rPanels ) + ,pTabBar( new PanelTabBar( i_rParent, i_rPanels, i_eAlignment, i_eItemContent ) ) + { + pTabBar->Show(); + } + }; + + //==================================================================== + //= helper + //==================================================================== + namespace + { + static bool lcl_isVerticalTabBar( const TabAlignment i_eAlignment ) + { + return ( i_eAlignment == TABS_RIGHT ) + || ( i_eAlignment == TABS_LEFT ); + } + + static bool lcl_checkDisposed( const TabDeckLayouter_Data& i_rData ) + { + if ( !i_rData.pTabBar.get() ) + { + OSL_ENSURE( false, "lcl_checkDisposed: already disposed!" ); + return true; + } + return false; + } + } + + //==================================================================== + //= TabDeckLayouter + //==================================================================== + //-------------------------------------------------------------------- + TabDeckLayouter::TabDeckLayouter( Window& i_rParent, IToolPanelDeck& i_rPanels, + const TabAlignment i_eAlignment, const TabItemContent i_eItemContent ) + :m_pData( new TabDeckLayouter_Data( i_rParent, i_rPanels, i_eAlignment, i_eItemContent ) ) + { + } + + //-------------------------------------------------------------------- + TabDeckLayouter::~TabDeckLayouter() + { + } + + //-------------------------------------------------------------------- + IMPLEMENT_IREFERENCE( TabDeckLayouter ) + + //-------------------------------------------------------------------- + TabItemContent TabDeckLayouter::GetTabItemContent() const + { + if ( lcl_checkDisposed( *m_pData ) ) + return TABITEM_IMAGE_AND_TEXT; + return m_pData->pTabBar->GetTabItemContent(); + } + + //-------------------------------------------------------------------- + void TabDeckLayouter::SetTabItemContent( const TabItemContent& i_eItemContent ) + { + if ( lcl_checkDisposed( *m_pData ) ) + return; + m_pData->pTabBar->SetTabItemContent( i_eItemContent ); + } + + //-------------------------------------------------------------------- + TabAlignment TabDeckLayouter::GetTabAlignment() const + { + if ( lcl_checkDisposed( *m_pData ) ) + return TABS_RIGHT; + return m_pData->eAlignment; + } + + //-------------------------------------------------------------------- + ::boost::optional< size_t > TabDeckLayouter::GetFocusedPanelItem() const + { + if ( lcl_checkDisposed( *m_pData ) ) + return ::boost::optional< size_t >(); + return m_pData->pTabBar->GetFocusedPanelItem(); + } + + //-------------------------------------------------------------------- + void TabDeckLayouter::FocusPanelItem( const size_t i_nItemPos ) + { + if ( lcl_checkDisposed( *m_pData ) ) + return; + m_pData->pTabBar->FocusPanelItem( i_nItemPos ); + } + + //-------------------------------------------------------------------- + bool TabDeckLayouter::IsPanelSelectorEnabled() const + { + if ( lcl_checkDisposed( *m_pData ) ) + return false; + return m_pData->pTabBar->IsEnabled(); + } + + //-------------------------------------------------------------------- + bool TabDeckLayouter::IsPanelSelectorVisible() const + { + if ( lcl_checkDisposed( *m_pData ) ) + return false; + return m_pData->pTabBar->IsVisible(); + } + + //-------------------------------------------------------------------- + Rectangle TabDeckLayouter::GetItemScreenRect( const size_t i_nItemPos ) const + { + if ( lcl_checkDisposed( *m_pData ) ) + return Rectangle(); + return m_pData->pTabBar->GetItemScreenRect( i_nItemPos ); + } + + //-------------------------------------------------------------------- + Rectangle TabDeckLayouter::Layout( const Rectangle& i_rDeckPlayground ) + { + if ( lcl_checkDisposed( *m_pData ) ) + return i_rDeckPlayground; + + const Size aPreferredSize( m_pData->pTabBar->GetOptimalSize( WINDOWSIZE_PREFERRED ) ); + if ( lcl_isVerticalTabBar( m_pData->eAlignment ) ) + { + Size aTabBarSize = ( aPreferredSize.Width() < i_rDeckPlayground.GetWidth() ) + ? aPreferredSize + : m_pData->pTabBar->GetOptimalSize( WINDOWSIZE_MINIMUM ); + aTabBarSize.Height() = i_rDeckPlayground.GetHeight(); + + Rectangle aPanelRect( i_rDeckPlayground ); + if ( m_pData->eAlignment == TABS_RIGHT ) + { + aPanelRect.Right() -= aTabBarSize.Width(); + Point aTabBarTopLeft( aPanelRect.TopRight() ); + aTabBarTopLeft.X() += 1; + m_pData->pTabBar->SetPosSizePixel( aTabBarTopLeft, aTabBarSize ); + } + else + { + m_pData->pTabBar->SetPosSizePixel( aPanelRect.TopLeft(), aTabBarSize ); + aPanelRect.Left() += aTabBarSize.Width(); + } + if ( aPanelRect.Left() >= aPanelRect.Right() ) + aPanelRect = Rectangle(); + + return aPanelRect; + } + + Size aTabBarSize = ( aPreferredSize.Height() < i_rDeckPlayground.GetHeight() ) + ? aPreferredSize + : m_pData->pTabBar->GetOptimalSize( WINDOWSIZE_MINIMUM ); + aTabBarSize.Width() = i_rDeckPlayground.GetWidth(); + + Rectangle aPanelRect( i_rDeckPlayground ); + if ( m_pData->eAlignment == TABS_TOP ) + { + m_pData->pTabBar->SetPosSizePixel( aPanelRect.TopLeft(), aTabBarSize ); + aPanelRect.Top() += aTabBarSize.Height(); + } + else + { + aPanelRect.Bottom() -= aTabBarSize.Height(); + Point aTabBarTopLeft( aPanelRect.BottomLeft() ); + aTabBarTopLeft.Y() -= 1; + m_pData->pTabBar->SetPosSizePixel( aTabBarTopLeft, aTabBarSize ); + } + if ( aPanelRect.Top() >= aPanelRect.Bottom() ) + aPanelRect = Rectangle(); + + return aPanelRect; + } + + //-------------------------------------------------------------------- + void TabDeckLayouter::Destroy() + { + m_pData->pTabBar.reset(); + } + + //-------------------------------------------------------------------- + void TabDeckLayouter::SetFocusToPanelSelector() + { + if ( lcl_checkDisposed( *m_pData ) ) + return; + m_pData->pTabBar->GrabFocus(); + } + + //-------------------------------------------------------------------- + size_t TabDeckLayouter::GetAccessibleChildCount() const + { + if ( lcl_checkDisposed( *m_pData ) ) + return 0; + + return 1; + } + + //-------------------------------------------------------------------- + Reference< XAccessible > TabDeckLayouter::GetAccessibleChild( const size_t i_nChildIndex, const Reference< XAccessible >& i_rParentAccessible ) + { + (void)i_nChildIndex; + (void)i_rParentAccessible; + if ( lcl_checkDisposed( *m_pData ) ) + return NULL; + + return m_pData->pTabBar->GetAccessible( TRUE ); + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/toolpanel.cxx b/svtools/source/toolpanel/toolpanel.cxx new file mode 100644 index 000000000000..35446d1ffe2b --- /dev/null +++ b/svtools/source/toolpanel/toolpanel.cxx @@ -0,0 +1,52 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "svtools/toolpanel/toolpanel.hxx" + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= ToolPanelBase + //==================================================================== + //-------------------------------------------------------------------- + ToolPanelBase::ToolPanelBase() + { + } + + //-------------------------------------------------------------------- + ToolPanelBase::~ToolPanelBase() + { + } + + //-------------------------------------------------------------------- + IMPLEMENT_IREFERENCE( ToolPanelBase ) + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/uno/unoifac2.hrc b/svtools/source/toolpanel/toolpanel.src index a31d07e0bd27..4861fbfd14ac 100644 --- a/svtools/source/uno/unoifac2.hrc +++ b/svtools/source/toolpanel/toolpanel.src @@ -1,5 +1,4 @@ /************************************************************************* - * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. @@ -25,28 +24,16 @@ * ************************************************************************/ -#ifndef _SVT_UNO_UNOIFAC_HRC_ -#define _SVT_UNO_UNOIFAC_HRC_ - - -#ifndef _SOLAR_HRC -#include <svl/solar.hrc> -#endif - -//! Um den berblick ber alle benutzten HelpID's zu behalten sind diese -//! zentral in <helpid.hrc> -#ifndef _SVT_HELPID_HRC -#include <svtools/helpid.hrc> -#endif - -// RID's fuer das Kontextmenu der Textkomponente -#define RID_CONTEXTMENU (RID_APP_START + 1024) -#define RID_OPEN_LINK (RID_APP_START + 10) -#define RID_OPEN_LINK_NEW (RID_APP_START + 11) -#define RID_DOWNLOAD (RID_APP_START + 12) -#define RID_ADD_BOOKMARK (RID_APP_START + 13) -#define RID_COPY_LINK (RID_APP_START + 14) - +#include <svl/svtools.hrc> -#endif +// the following string ID is a hack, until MBA's promised patch appears, which splits svl/svtools.hrc +// into two files, one for svl, one or svtools +String STR_SVT_ACC_BEGIN + 0 +{ + Text [ en-US ] = "Tab Panel Scroll Button, backward"; +}; +String STR_SVT_ACC_BEGIN + 1 +{ + Text [ en-US ] = "Tab Panel Scroll Button, forward"; +}; diff --git a/svtools/source/toolpanel/toolpanelcollection.cxx b/svtools/source/toolpanel/toolpanelcollection.cxx new file mode 100644 index 000000000000..baefbd92400f --- /dev/null +++ b/svtools/source/toolpanel/toolpanelcollection.cxx @@ -0,0 +1,193 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "toolpanelcollection.hxx" +#include "paneldecklisteners.hxx" + +#include <tools/diagnose_ex.h> + +#include <vector> + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= ToolPanelCollection_Data + //==================================================================== + struct ToolPanelCollection_Data + { + ::std::vector< PToolPanel > aPanels; + ::boost::optional< size_t > aActivePanel; + PanelDeckListeners aListeners; + }; + + //==================================================================== + //= ToolPanelCollection + //==================================================================== + //-------------------------------------------------------------------- + ToolPanelCollection::ToolPanelCollection() + :m_pData( new ToolPanelCollection_Data ) + { + } + + //-------------------------------------------------------------------- + ToolPanelCollection::~ToolPanelCollection() + { + m_pData->aListeners.Dying(); + } + + //-------------------------------------------------------------------- + size_t ToolPanelCollection::GetPanelCount() const + { + return m_pData->aPanels.size(); + } + + //-------------------------------------------------------------------- + ::boost::optional< size_t > ToolPanelCollection::GetActivePanel() const + { + return m_pData->aActivePanel; + } + + //-------------------------------------------------------------------- + void ToolPanelCollection::ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) + { + if ( !!i_rPanel ) + { + OSL_ENSURE( *i_rPanel < GetPanelCount(), "ToolPanelCollection::ActivatePanel: illegal panel no.!" ); + if ( *i_rPanel >= GetPanelCount() ) + return; + } + + if ( m_pData->aActivePanel == i_rPanel ) + return; + + const ::boost::optional< size_t > aOldPanel( m_pData->aActivePanel ); + m_pData->aActivePanel = i_rPanel; + + // notify listeners + m_pData->aListeners.ActivePanelChanged( aOldPanel, m_pData->aActivePanel ); + } + + //-------------------------------------------------------------------- + PToolPanel ToolPanelCollection::GetPanel( const size_t i_nPos ) const + { + OSL_ENSURE( i_nPos < m_pData->aPanels.size(), "ToolPanelCollection::GetPanel: illegal position!" ); + if ( i_nPos >= m_pData->aPanels.size() ) + return PToolPanel(); + return m_pData->aPanels[ i_nPos ]; + } + + //-------------------------------------------------------------------- + size_t ToolPanelCollection::InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) + { + OSL_ENSURE( i_pPanel.get(), "ToolPanelCollection::InsertPanel: illegal panel!" ); + if ( !i_pPanel.get() ) + return 0; + + // insert + const size_t position = i_nPosition < m_pData->aPanels.size() ? i_nPosition : m_pData->aPanels.size(); + m_pData->aPanels.insert( m_pData->aPanels.begin() + position, i_pPanel ); + + // update active panel + if ( !!m_pData->aActivePanel ) + { + if ( i_nPosition <= *m_pData->aActivePanel ) + ++*m_pData->aActivePanel; + } + + // notifications + m_pData->aListeners.PanelInserted( i_pPanel, i_nPosition ); + + return position; + } + + //-------------------------------------------------------------------- + PToolPanel ToolPanelCollection::RemovePanel( const size_t i_nPosition ) + { + OSL_ENSURE( i_nPosition < m_pData->aPanels.size(), "ToolPanelCollection::RemovePanel: illegal position!" ); + if ( i_nPosition >= m_pData->aPanels.size() ) + return NULL; + + // if the active panel is going to be removed, activate another one (before the actual removal) + if ( m_pData->aActivePanel == i_nPosition ) + { + const ::boost::optional< size_t > aOldActive( m_pData->aActivePanel ); + + if ( i_nPosition + 1 < GetPanelCount() ) + { + ++*m_pData->aActivePanel; + } + else if ( i_nPosition > 0 ) + { + --*m_pData->aActivePanel; + } + else + { + m_pData->aActivePanel.reset(); + } + + m_pData->aListeners.ActivePanelChanged( aOldActive, m_pData->aActivePanel ); + } + + // remember the removed panel for the aller + PToolPanel pRemovedPanel( m_pData->aPanels[ i_nPosition ] ); + + // actually remove + m_pData->aPanels.erase( m_pData->aPanels.begin() + i_nPosition ); + + if ( !!m_pData->aActivePanel ) + { + if ( i_nPosition < *m_pData->aActivePanel ) + { + --*m_pData->aActivePanel; + } + } + + // notify removed panel + m_pData->aListeners.PanelRemoved( i_nPosition ); + + return pRemovedPanel; + } + + //-------------------------------------------------------------------- + void ToolPanelCollection::AddListener( IToolPanelDeckListener& i_rListener ) + { + m_pData->aListeners.AddListener( i_rListener ); + } + + //-------------------------------------------------------------------- + void ToolPanelCollection::RemoveListener( IToolPanelDeckListener& i_rListener ) + { + m_pData->aListeners.RemoveListener( i_rListener ); + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/toolpanelcollection.hxx b/svtools/source/toolpanel/toolpanelcollection.hxx new file mode 100644 index 000000000000..2bdba38546c9 --- /dev/null +++ b/svtools/source/toolpanel/toolpanelcollection.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef TOOLPANELCOLLECTION_HXX +#define TOOLPANELCOLLECTION_HXX + +#include "svtools/toolpanel/toolpaneldeck.hxx" + +#include <memory> + +//........................................................................ +namespace svt +{ +//........................................................................ + + struct ToolPanelCollection_Data; + + //==================================================================== + //= ToolPanelCollection + //==================================================================== + class ToolPanelCollection : public IToolPanelDeck + { + public: + ToolPanelCollection(); + ~ToolPanelCollection(); + + // IToolPanelDeck + virtual size_t GetPanelCount() const; + virtual PToolPanel GetPanel( const size_t i_nPos ) const; + virtual ::boost::optional< size_t > + GetActivePanel() const; + virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ); + virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual PToolPanel RemovePanel( const size_t i_nPosition ); + virtual void AddListener( IToolPanelDeckListener& i_rListener ); + virtual void RemoveListener( IToolPanelDeckListener& i_rListener ); + + private: + ::std::auto_ptr< ToolPanelCollection_Data > m_pData; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // TOOLPANELCOLLECTION_HXX diff --git a/svtools/source/toolpanel/toolpaneldeck.cxx b/svtools/source/toolpanel/toolpaneldeck.cxx new file mode 100755 index 000000000000..fe4fa63ad997 --- /dev/null +++ b/svtools/source/toolpanel/toolpaneldeck.cxx @@ -0,0 +1,533 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "dummypanel.hxx" +#include "toolpanelcollection.hxx" +#include "paneldecklisteners.hxx" +#include "toolpaneldeckpeer.hxx" +#include "svtools/toolpanel/toolpaneldeck.hxx" +#include "svtools/toolpanel/tablayouter.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +#include <boost/optional.hpp> + +//........................................................................ +namespace svt +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::accessibility::XAccessible; + using ::com::sun::star::awt::XWindowPeer; + using ::com::sun::star::uno::UNO_SET_THROW; + /** === end UNO using === **/ + namespace AccessibleRole = ::com::sun::star::accessibility::AccessibleRole; + + enum DeckAction + { + /// activates the first panel + ACTION_ACTIVATE_FIRST, + // activates the panel after the currently active panel + ACTION_ACTIVATE_NEXT, + // activates the panel before the currently active panel + ACTION_ACTIVATE_PREV, + // activates the last panel + ACTION_ACTIVATE_LAST, + + // toggles the focus between the active panel and the panel selector + ACTION_TOGGLE_FOCUS, + }; + + //==================================================================== + //= ToolPanelDeck_Impl + //==================================================================== + class ToolPanelDeck_Impl : public IToolPanelDeckListener + { + public: + ToolPanelDeck_Impl( ToolPanelDeck& i_rDeck ) + :m_rDeck( i_rDeck ) + ,m_aPanelAnchor( &i_rDeck ) + ,m_aPanels() + ,m_pDummyPanel( new DummyPanel ) + ,m_pLayouter() + ,m_pAccessibleParent( NULL ) + { + m_aPanels.AddListener( *this ); + m_aPanelAnchor.Show(); + m_aPanelAnchor.SetAccessibleRole( AccessibleRole::PANEL ); + } + + ~ToolPanelDeck_Impl() + { + } + + PDeckLayouter GetLayouter() const { return m_pLayouter; } + void SetLayouter( const PDeckLayouter& i_pNewLayouter ); + + Window& GetPanelWindowAnchor() { return m_aPanelAnchor; } + + /// notifies our listeners that we're going to die. Only to be called from with our anti-impl's destructor + void NotifyDying() + { + m_aPanels.RemoveListener( *this ); + m_aListeners.Dying(); + } + + // IToolPanelDeck equivalents + size_t GetPanelCount() const; + PToolPanel GetPanel( const size_t i_nPos ) const; + ::boost::optional< size_t > + GetActivePanel() const; + void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ); + size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ); + PToolPanel RemovePanel( const size_t i_nPosition ); + void AddListener( IToolPanelDeckListener& i_rListener ); + void RemoveListener( IToolPanelDeckListener& i_rListener ); + + /// re-layouts everything + void LayoutAll() { ImplDoLayout(); } + + void DoAction( const DeckAction i_eAction ); + + void FocusActivePanel(); + + void SetAccessibleParentWindow( Window* i_pAccessibleParent ); + Window* GetAccessibleParentWindow() const { return m_pAccessibleParent ? m_pAccessibleParent : m_rDeck.GetAccessibleParentWindow(); } + + protected: + // IToolPanelDeckListener + virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual void PanelRemoved( const size_t i_nPosition ); + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ); + virtual void Dying(); + + private: + void ImplDoLayout(); + PToolPanel GetActiveOrDummyPanel_Impl(); + + private: + ToolPanelDeck& m_rDeck; + Window m_aPanelAnchor; + ToolPanelCollection m_aPanels; + PToolPanel m_pDummyPanel; + PanelDeckListeners m_aListeners; + + PDeckLayouter m_pLayouter; + + Window* m_pAccessibleParent; + }; + + //-------------------------------------------------------------------- + PToolPanel ToolPanelDeck_Impl::GetActiveOrDummyPanel_Impl() + { + ::boost::optional< size_t > aActivePanel( m_aPanels.GetActivePanel() ); + if ( !aActivePanel ) + return m_pDummyPanel; + return m_aPanels.GetPanel( *aActivePanel ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::SetLayouter( const PDeckLayouter& i_pNewLayouter ) + { + ENSURE_OR_RETURN_VOID( i_pNewLayouter.get(), "invalid layouter" ); + + if ( m_pLayouter.get() ) + m_pLayouter->Destroy(); + + m_pLayouter = i_pNewLayouter; + + ImplDoLayout(); + + m_aListeners.LayouterChanged( m_pLayouter ); + } + + //-------------------------------------------------------------------- + size_t ToolPanelDeck_Impl::GetPanelCount() const + { + return m_aPanels.GetPanelCount(); + } + + //-------------------------------------------------------------------- + PToolPanel ToolPanelDeck_Impl::GetPanel( const size_t i_nPos ) const + { + return m_aPanels.GetPanel( i_nPos ); + } + + //-------------------------------------------------------------------- + ::boost::optional< size_t > ToolPanelDeck_Impl::GetActivePanel() const + { + return m_aPanels.GetActivePanel(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) + { + m_aPanels.ActivatePanel( i_rPanel ); + } + + //-------------------------------------------------------------------- + size_t ToolPanelDeck_Impl::InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) + { + return m_aPanels.InsertPanel( i_pPanel, i_nPosition ); + } + + //-------------------------------------------------------------------- + PToolPanel ToolPanelDeck_Impl::RemovePanel( const size_t i_nPosition ) + { + return m_aPanels.RemovePanel( i_nPosition ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::ImplDoLayout() + { + const Rectangle aDeckPlayground( Point(), m_rDeck.GetOutputSizePixel() ); + + // ask the layouter what is left for our panel, and position the panel container window appropriately + Rectangle aPlaygroundArea( aDeckPlayground ); + OSL_ENSURE( m_pLayouter.get(), "ToolPanelDeck_Impl::ImplDoLayout: no layouter!" ); + if ( m_pLayouter.get() ) + { + aPlaygroundArea = m_pLayouter->Layout( aDeckPlayground ); + } + m_aPanelAnchor.SetPosSizePixel( aPlaygroundArea.TopLeft(), aPlaygroundArea.GetSize() ); + + // position the active panel + const PToolPanel pActive( GetActiveOrDummyPanel_Impl() ); + pActive->SetSizePixel( m_aPanelAnchor.GetOutputSizePixel() ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::AddListener( IToolPanelDeckListener& i_rListener ) + { + m_aListeners.AddListener( i_rListener ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::RemoveListener( IToolPanelDeckListener& i_rListener ) + { + m_aListeners.RemoveListener( i_rListener ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::DoAction( const DeckAction i_eAction ) + { + const size_t nPanelCount( m_aPanels.GetPanelCount() ); + ::boost::optional< size_t > aActivatePanel; + ::boost::optional< size_t > aCurrentPanel( GetActivePanel() ); + + switch ( i_eAction ) + { + case ACTION_ACTIVATE_FIRST: + if ( nPanelCount > 0 ) + aActivatePanel = 0; + break; + case ACTION_ACTIVATE_PREV: + if ( !aCurrentPanel && ( nPanelCount > 0 ) ) + aActivatePanel = nPanelCount - 1; + else + if ( !!aCurrentPanel && ( *aCurrentPanel > 0 ) ) + aActivatePanel = *aCurrentPanel - 1; + break; + case ACTION_ACTIVATE_NEXT: + if ( !aCurrentPanel && ( nPanelCount > 0 ) ) + aActivatePanel = 0; + else + if ( !!aCurrentPanel && ( *aCurrentPanel < nPanelCount - 1 ) ) + aActivatePanel = *aCurrentPanel + 1; + break; + case ACTION_ACTIVATE_LAST: + if ( nPanelCount > 0 ) + aActivatePanel = nPanelCount - 1; + break; + case ACTION_TOGGLE_FOCUS: + { + PToolPanel pActivePanel( GetActiveOrDummyPanel_Impl() ); + if ( !m_aPanelAnchor.HasChildPathFocus() ) + pActivePanel->GrabFocus(); + else + GetLayouter()->SetFocusToPanelSelector(); + } + break; + } + + if ( !!aActivatePanel ) + { + ActivatePanel( aActivatePanel ); + } + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::FocusActivePanel() + { + PToolPanel pActivePanel( GetActiveOrDummyPanel_Impl() ); + pActivePanel->GrabFocus(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) + { + // multiplex to our own listeners + m_aListeners.PanelInserted( i_pPanel, i_nPosition ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::PanelRemoved( const size_t i_nPosition ) + { + // multiplex to our own listeners + m_aListeners.PanelRemoved( i_nPosition ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) + { + // hide the old panel + if ( !!i_rOldActive ) + { + const PToolPanel pOldActive( m_aPanels.GetPanel( *i_rOldActive ) ); + pOldActive->Deactivate(); + } + + // position and show the new panel + const PToolPanel pNewActive( !i_rNewActive ? m_pDummyPanel : m_aPanels.GetPanel( *i_rNewActive ) ); + pNewActive->Activate( m_aPanelAnchor ); + pNewActive->GrabFocus(); + + // resize the panel (cannot guarantee it has ever been resized before + pNewActive->SetSizePixel( m_aPanelAnchor.GetOutputSizePixel() ); + + // multiplex to our own listeners + m_aListeners.ActivePanelChanged( i_rOldActive, i_rNewActive ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::LayouterChanged( const PDeckLayouter& i_rNewLayouter ) + { + // not interested in + (void)i_rNewLayouter; + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::Dying() + { + // not interested in. Since the ToolPanelCollection is our member, this just means we ourself + // are dying, and we already sent this notification in our dtor. + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::SetAccessibleParentWindow( Window* i_pAccessibleParent ) + { + m_pAccessibleParent = i_pAccessibleParent; + } + + //==================================================================== + //= ToolPanelDeck + //==================================================================== + //-------------------------------------------------------------------- + ToolPanelDeck::ToolPanelDeck( Window& i_rParent, const WinBits i_nStyle ) + :Control( &i_rParent, i_nStyle ) + ,m_pImpl( new ToolPanelDeck_Impl( *this ) ) + { + // use a default layouter + SetLayouter( PDeckLayouter( new TabDeckLayouter( *this, *this, TABS_RIGHT, TABITEM_IMAGE_AND_TEXT ) ) ); + } + + //-------------------------------------------------------------------- + ToolPanelDeck::~ToolPanelDeck() + { + m_pImpl->NotifyDying(); + GetLayouter()->Destroy(); + + Hide(); + for ( size_t i=0; i<GetPanelCount(); ++i ) + { + PToolPanel pPanel( GetPanel( i ) ); + pPanel->Dispose(); + } + } + + //-------------------------------------------------------------------- + size_t ToolPanelDeck::GetPanelCount() const + { + return m_pImpl->GetPanelCount(); + } + + //-------------------------------------------------------------------- + PToolPanel ToolPanelDeck::GetPanel( const size_t i_nPos ) const + { + return m_pImpl->GetPanel( i_nPos ); + } + + //-------------------------------------------------------------------- + ::boost::optional< size_t > ToolPanelDeck::GetActivePanel() const + { + return m_pImpl->GetActivePanel(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) + { + m_pImpl->ActivatePanel( i_rPanel ); + } + + //-------------------------------------------------------------------- + size_t ToolPanelDeck::InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) + { + return m_pImpl->InsertPanel( i_pPanel, i_nPosition ); + } + + //-------------------------------------------------------------------- + PToolPanel ToolPanelDeck::RemovePanel( const size_t i_nPosition ) + { + return m_pImpl->RemovePanel( i_nPosition ); + } + + //-------------------------------------------------------------------- + PDeckLayouter ToolPanelDeck::GetLayouter() const + { + return m_pImpl->GetLayouter(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::SetLayouter( const PDeckLayouter& i_pNewLayouter ) + { + return m_pImpl->SetLayouter( i_pNewLayouter ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::AddListener( IToolPanelDeckListener& i_rListener ) + { + m_pImpl->AddListener( i_rListener ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::RemoveListener( IToolPanelDeckListener& i_rListener ) + { + m_pImpl->RemoveListener( i_rListener ); + } + + //-------------------------------------------------------------------- + Window& ToolPanelDeck::GetPanelWindowAnchor() + { + return m_pImpl->GetPanelWindowAnchor(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::Resize() + { + Control::Resize(); + m_pImpl->LayoutAll(); + } + + //-------------------------------------------------------------------- + long ToolPanelDeck::Notify( NotifyEvent& i_rNotifyEvent ) + { + bool bHandled = false; + if ( i_rNotifyEvent.GetType() == EVENT_KEYINPUT ) + { + const KeyEvent* pEvent = i_rNotifyEvent.GetKeyEvent(); + const KeyCode& rKeyCode = pEvent->GetKeyCode(); + if ( rKeyCode.GetModifier() == KEY_MOD1 ) + { + bHandled = true; + switch ( rKeyCode.GetCode() ) + { + case KEY_HOME: + m_pImpl->DoAction( ACTION_ACTIVATE_FIRST ); + break; + case KEY_PAGEUP: + m_pImpl->DoAction( ACTION_ACTIVATE_PREV ); + break; + case KEY_PAGEDOWN: + m_pImpl->DoAction( ACTION_ACTIVATE_NEXT ); + break; + case KEY_END: + m_pImpl->DoAction( ACTION_ACTIVATE_LAST ); + break; + default: + bHandled = false; + break; + } + } + else if ( rKeyCode.GetModifier() == ( KEY_MOD1 | KEY_SHIFT ) ) + { + if ( rKeyCode.GetCode() == KEY_E ) + { + m_pImpl->DoAction( ACTION_TOGGLE_FOCUS ); + bHandled = true; + } + } + } + + if ( bHandled ) + return 1; + + return Control::Notify( i_rNotifyEvent ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::GetFocus() + { + Control::GetFocus(); + m_pImpl->FocusActivePanel(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::SetAccessibleParentWindow( Window* i_pAccessibleParent ) + { + m_pImpl->SetAccessibleParentWindow( i_pAccessibleParent ); + } + + //-------------------------------------------------------------------- + Window* ToolPanelDeck::GetAccessibleParentWindow() const + { + return m_pImpl->GetAccessibleParentWindow(); + } + + //-------------------------------------------------------------------- + Reference< XWindowPeer > ToolPanelDeck::GetComponentInterface( BOOL i_bCreate ) + { + Reference< XWindowPeer > xWindowPeer( Control::GetComponentInterface( FALSE ) ); + if ( !xWindowPeer.is() && i_bCreate ) + { + xWindowPeer.set( new ToolPanelDeckPeer( *this ) ); + SetComponentInterface( xWindowPeer ); + } + return xWindowPeer; + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/toolpaneldeckpeer.cxx b/svtools/source/toolpanel/toolpaneldeckpeer.cxx new file mode 100755 index 000000000000..0a84a90b4fb3 --- /dev/null +++ b/svtools/source/toolpanel/toolpaneldeckpeer.cxx @@ -0,0 +1,99 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "toolpaneldeckpeer.hxx" +#include "svtools/toolpanel/toolpaneldeck.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/DisposedException.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::accessibility::XAccessibleContext; + using ::com::sun::star::lang::DisposedException; + /** === end UNO using === **/ + + //================================================================================================================== + //= ToolPanelDeckPeer + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ToolPanelDeckPeer::ToolPanelDeckPeer( ToolPanelDeck& i_rDeck ) + :VCLXWindow() + ,m_pDeck( &i_rDeck ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ToolPanelDeckPeer::~ToolPanelDeckPeer() + { + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessibleContext > ToolPanelDeckPeer::CreateAccessibleContext() + { + ::vos::OGuard aSolarGuard( GetMutex() ); + if ( m_pDeck == NULL ) + throw DisposedException( ::rtl::OUString(), *this ); + + Window* pAccessibleParent( m_pDeck->GetAccessibleParentWindow() ); + ENSURE_OR_RETURN( pAccessibleParent != NULL, "no accessible parent => no accessible context", NULL ); + Reference< XAccessible > xAccessibleParent( pAccessibleParent->GetAccessible(), UNO_SET_THROW ); + return m_aAccessibleFactory.getFactory().createAccessibleToolPanelDeck( xAccessibleParent, *m_pDeck ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ToolPanelDeckPeer::dispose() throw(RuntimeException) + { + { + ::vos::OGuard aSolarGuard( GetMutex() ); + m_pDeck = NULL; + } + VCLXWindow::dispose(); + } + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... diff --git a/svtools/source/toolpanel/toolpaneldeckpeer.hxx b/svtools/source/toolpanel/toolpaneldeckpeer.hxx new file mode 100755 index 000000000000..4b6607ecbd05 --- /dev/null +++ b/svtools/source/toolpanel/toolpaneldeckpeer.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVT_TOOLPANELDECKPEER_HXX +#define SVT_TOOLPANELDECKPEER_HXX + +#include "svtaccessiblefactory.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <toolkit/awt/vclxwindow.hxx> + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + class ToolPanelDeck; + //================================================================================================================== + //= ToolPanelDeckPeer + //================================================================================================================== + class ToolPanelDeckPeer : public VCLXWindow + { + public: + ToolPanelDeckPeer( ToolPanelDeck& i_rDeck ); + + protected: + ~ToolPanelDeckPeer(); + + // VCLXWindow overridables + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > CreateAccessibleContext(); + + // XComponent + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + private: + AccessibleFactoryAccess m_aAccessibleFactory; + ToolPanelDeck* m_pDeck; + }; + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... + +#endif // SVT_TOOLPANELDECKPEER_HXX diff --git a/svtools/source/uno/makefile.mk b/svtools/source/uno/makefile.mk index 7bfe37624947..4a52960f448c 100644 --- a/svtools/source/uno/makefile.mk +++ b/svtools/source/uno/makefile.mk @@ -38,9 +38,6 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- -SRS1NAME= uno -SRC1FILES= unoifac2.src - SLOFILES= \ $(SLO)$/addrtempuno.obj \ $(SLO)$/contextmenuhelper.obj \ diff --git a/svtools/source/uno/unoifac2.src b/svtools/source/uno/unoifac2.src deleted file mode 100644 index 406701ca4fc1..000000000000 --- a/svtools/source/uno/unoifac2.src +++ /dev/null @@ -1,107 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - - -#ifndef _SVT_UNO_UNOIFAC_HRC_ -#include <unoifac2.hrc> -#endif - - -Menu RID_CONTEXTMENU -{ - ItemList = - { - MenuItem - { - Identifier = RID_OPEN_LINK ; - HelpId = HID_TEXTCPNT_OPEN_LINK ; - Text [ en-US ] = "~Open"; - }; - MenuItem - { - Identifier = RID_OPEN_LINK_NEW ; - HelpId = HID_TEXTCPNT_OPEN_LINK_NEW ; - Text [ en-US ] = "Open in New ~Window"; - }; - MenuItem - { - Identifier = RID_DOWNLOAD ; - HelpId = HID_TEXTCPNT_DOWNLOAD ; - Text [ en-US ] = "~Download..."; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = RID_ADD_BOOKMARK ; - HelpId = HID_TEXTCPNT_ADD_BOOKMARK ; - Text [ en-US ] = "Add ~Link"; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = RID_COPY_LINK ; - HelpId = HID_TEXTCPNT_COPY_LINK ; - Text [ en-US ] = "Cop~y Link" ; - }; - }; -}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/svtools/util/makefile.mk b/svtools/util/makefile.mk index ab05facdb065..0040b1d1ee65 100644 --- a/svtools/util/makefile.mk +++ b/svtools/util/makefile.mk @@ -48,30 +48,31 @@ LIB2TARGET= $(LB)$/svtool.lib LIB2FILES= $(LB)$/_svt.lib .ENDIF -LIB1TARGET= $(SLB)$/svt.lib +LIB1TARGET= $(SLB)/svt.lib LIB1FILES= \ - $(SLB)$/browse.lib \ - $(SLB)$/config.lib \ - $(SLB)$/svcontnr.lib \ - $(SLB)$/ctrl.lib \ - $(SLB)$/dialogs.lib \ - $(SLB)$/edit.lib \ - $(SLB)$/filter.lib \ - $(SLB)$/filter.uno.lib \ + $(SLB)/browse.lib \ + $(SLB)/config.lib \ + $(SLB)/svcontnr.lib \ + $(SLB)/ctrl.lib \ + $(SLB)/dialogs.lib \ + $(SLB)/edit.lib \ + $(SLB)/filter.lib \ + $(SLB)/filter.uno.lib \ $(SLB)$/graphic.lib \ - $(SLB)$/igif.lib \ - $(SLB)$/jpeg.lib \ - $(SLB)$/ixpm.lib \ - $(SLB)$/ixbm.lib \ - $(SLB)$/wmf.lib \ - $(SLB)$/java.lib \ - $(SLB)$/misc.lib \ - $(SLB)$/plugapp.lib \ - $(SLB)$/svhtml.lib \ - $(SLB)$/svrtf.lib \ - $(SLB)$/table.lib \ - $(SLB)$/unoiface.lib \ - $(SLB)$/urlobj.lib + $(SLB)/igif.lib \ + $(SLB)/jpeg.lib \ + $(SLB)/ixpm.lib \ + $(SLB)/ixbm.lib \ + $(SLB)/wmf.lib \ + $(SLB)/java.lib \ + $(SLB)/misc.lib \ + $(SLB)/plugapp.lib \ + $(SLB)/svhtml.lib \ + $(SLB)/svrtf.lib \ + $(SLB)/table.lib \ + $(SLB)/unoiface.lib \ + $(SLB)/urlobj.lib \ + $(SLB)/toolpanel.lib # generation of resourcen-lib ---------------------------------------- @@ -84,8 +85,8 @@ RESLIB1SRSFILES= \ $(SRS)$/dialogs.srs \ $(SRS)$/plugapp.srs \ $(SRS)$/svcontnr.srs \ - $(SRS)$/uno.srs \ $(SRS)$/browse.srs \ + $(SRS)$/toolpanel.srs \ $(SRS)$/javaerror.srs RESLIB3NAME= $(RESTARGETPATCH) diff --git a/svtools/workben/toolpanel/makefile.mk b/svtools/workben/toolpanel/makefile.mk new file mode 100644 index 000000000000..e64e3cd8eccd --- /dev/null +++ b/svtools/workben/toolpanel/makefile.mk @@ -0,0 +1,110 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.16 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=svtools +TARGET=toolpaneltest +TARGETTYPE=GUI +LIBTARGET=NO + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +CXXFILES= toolpaneltest.cxx + +OBJFILES= $(OBJ)$/toolpaneltest.obj + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJFILES) +APP1STDLIBS=\ + $(VCLLIB) \ + $(UCBHELPERLIB) \ + $(SALLIB) \ + $(TOOLSLIB) \ + $(COMPHELPERLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(BASEGFXLIB) \ + $(SVTOOLLIB) \ + +APP1RAPTH=BRAND + +.IF "$(GUI)"!="UNX" +APP1DEF= $(MISC)$/$(TARGET).def +.ENDIF + +.IF "$(COM)"=="GCC" +ADDOPTFILES=$(OBJ)$/toolpaneltest.obj +add_cflagscxx="-frtti -fexceptions" +.ENDIF + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + +# ------------------------------------------------------------------ +# MAC +# ------------------------------------------------------------------ + +.IF "$(GUI)" == "MAC" + +$(MISC)$/$(TARGET).def: makefile + echo Kein Def-File fuer Applikationen auf Mac +.ENDIF + + +# ------------------------------------------------------------------ +# Windows +# ------------------------------------------------------------------ + +.IF "$(GUI)" == "WIN" + +$(MISC)$/$(TARGET).def: makefile + echo NAME $(TARGET) >$@ + echo DESCRIPTION 'ToolPanel - Testprogramm' >>$@ + echo EXETYPE WINDOWS >>$@ + echo STUB 'winSTUB.EXE' >>$@ + echo PROTMODE >>$@ + echo CODE PRELOAD MOVEABLE DISCARDABLE >>$@ + echo DATA PRELOAD MOVEABLE MULTIPLE >>$@ + echo HEAPSIZE 8192 >>$@ + echo STACKSIZE 32768 >>$@ + +.ENDIF + diff --git a/svtools/workben/toolpanel/toolpaneltest.cxx b/svtools/workben/toolpanel/toolpaneltest.cxx new file mode 100755 index 000000000000..148df941a254 --- /dev/null +++ b/svtools/workben/toolpanel/toolpaneltest.cxx @@ -0,0 +1,873 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "svtools/ctrlbox.hxx" +#include "svtools/toolpanel/toolpaneldeck.hxx" +#include "svtools/toolpanel/tablayouter.hxx" + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <comphelper/processfactory.hxx> +#include <cppuhelper/bootstrap.hxx> +#include <cppuhelper/servicefactory.hxx> +#include <tools/diagnose_ex.h> +#include <ucbhelper/contentbroker.hxx> +#include <vcl/button.hxx> +#include <vcl/edit.hxx> +#include <vcl/fixed.hxx> +#include <vcl/help.hxx> +#include <vcl/lstbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/taskpanelist.hxx> +#include <vcl/wrkwin.hxx> + +namespace svt { namespace toolpanel +{ + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::XComponentContext; +using ::com::sun::star::accessibility::XAccessible; + +//============================================================================= +//= PanelDemo +//============================================================================= +class PanelDemo : public Application +{ +public: + virtual void Main(); + +private: + static Reference< XMultiServiceFactory > createApplicationServiceManager(); +}; + +//============================================================================= +//= ColoredPanelWindow +//============================================================================= +class ColoredPanelWindow : public Window +{ +public: + ColoredPanelWindow( Window& i_rParent, const Color& i_rColor, const String& i_rTitle ) + :Window( &i_rParent ) + ,m_aEdit( this, WB_BORDER ) + ,m_aTabControl( this ) + ,m_sTitle( i_rTitle ) + { + SetLineColor(); + SetFillColor( i_rColor ); + + m_aEdit.Show(); + m_aTabControl.Show(); + + const sal_Char* pTabTitles[] = + { + "This", "is a", "Tab", "Control", "intended", "for", "comparison" + }; + for ( size_t i=0; i < sizeof( pTabTitles ) / sizeof( pTabTitles[0] ); ++i ) + { + String sText( String::CreateFromAscii( pTabTitles[i] ) ); + m_aTabControl.InsertPage( i + 1, sText ); + } + } + + virtual void Paint( const Rectangle& /*i_rRect*/ ) + { + const Size aOutputSize( GetOutputSizePixel() ); + const Rectangle aTitleRect( Point( 10, 10 ), Size( aOutputSize.Width() - 20, 20 ) ); + DrawRect( aTitleRect ); + SetTextColor( GetFillColor().IsDark() ? COL_WHITE : COL_BLACK ); + DrawText( aTitleRect, m_sTitle, TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER ); + } + + virtual void GetFocus() + { + m_aEdit.GrabFocus(); + } + + virtual void Resize() + { + const Size aOutputSize( GetOutputSizePixel() ); + m_aEdit.SetPosSizePixel( + Point( 20, 40 ), + Size( aOutputSize.Width() - 40, 20 ) + ); + m_aTabControl.SetPosSizePixel( + Point( 20, 70 ), + Size( aOutputSize.Width() - 40, 150 ) + ); + } + +private: + Edit m_aEdit; + TabControl m_aTabControl; + String m_sTitle; +}; + +//============================================================================= +//= ColoredPanel +//============================================================================= +class ColoredPanel : public IToolPanel +{ +public: + ColoredPanel( Window& i_rParent, const Color& i_rColor, const sal_Char* i_pAsciiPanelName ); + ColoredPanel( Window& i_rParent, const Color& i_rColor, const String& i_rPanelName ); + ~ColoredPanel(); + + // IToolPanel + virtual ::rtl::OUString GetDisplayName() const; + virtual Image GetImage() const; + virtual void Activate( Window& i_rParentWindow ); + virtual void Deactivate(); + virtual void SetSizePixel( const Size& i_rPanelWindowSize ); + virtual void GrabFocus(); + virtual void Dispose(); + virtual Reference< XAccessible > CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible ); + + // IReference + virtual oslInterlockedCount SAL_CALL acquire(); + virtual oslInterlockedCount SAL_CALL release(); + +private: + oslInterlockedCount m_refCount; + ::std::auto_ptr< ColoredPanelWindow > + m_pWindow; + ::rtl::OUString m_aPanelName; + BitmapEx m_aPanelIcon; +}; + +//============================================================================= +//= ColoredPanel +//============================================================================= +//----------------------------------------------------------------------------- +ColoredPanel::ColoredPanel( Window& i_rParent, const Color& i_rColor, const sal_Char* i_pAsciiPanelName ) + :m_refCount(0) + ,m_pWindow( new ColoredPanelWindow( i_rParent, i_rColor, ::rtl::OUString::createFromAscii( i_pAsciiPanelName ) ) ) + ,m_aPanelName( ::rtl::OUString::createFromAscii( i_pAsciiPanelName ) ) + ,m_aPanelIcon() +{ + Bitmap aBitmap( Size( 16, 16 ), 8 ); + m_aPanelIcon = BitmapEx( aBitmap ); + m_aPanelIcon.Erase( i_rColor ); +} + +//----------------------------------------------------------------------------- +ColoredPanel::ColoredPanel( Window& i_rParent, const Color& i_rColor, const String& i_rPanelName ) + :m_refCount(0) + ,m_pWindow( new ColoredPanelWindow( i_rParent, i_rColor, i_rPanelName ) ) + ,m_aPanelName( i_rPanelName ) + ,m_aPanelIcon() +{ + Bitmap aBitmap( Size( 16, 16 ), 8 ); + m_aPanelIcon = BitmapEx( aBitmap ); + m_aPanelIcon.Erase( i_rColor ); +} + +//----------------------------------------------------------------------------- +ColoredPanel::~ColoredPanel() +{ +} + +//----------------------------------------------------------------------------- +oslInterlockedCount SAL_CALL ColoredPanel::acquire() +{ + return osl_incrementInterlockedCount( &m_refCount ); +} + +//----------------------------------------------------------------------------- +oslInterlockedCount SAL_CALL ColoredPanel::release() +{ + oslInterlockedCount newCount = osl_decrementInterlockedCount( &m_refCount ); + if ( 0 == newCount ) + delete this; + return newCount; +} + +//----------------------------------------------------------------------------- +void ColoredPanel::Activate( Window& i_rParentWindow ) +{ + ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); + OSL_ENSURE( &i_rParentWindow == m_pWindow->GetParent(), "ColoredPanel::Activate: unexpected new parent window!" ); + // the documentation of IToolPanel::Activate says it is guaranteed that the parent window is + // always the same ... + m_pWindow->SetPosSizePixel( Point(), i_rParentWindow.GetSizePixel() ); + m_pWindow->Show(); +} + +//----------------------------------------------------------------------------- +void ColoredPanel::Deactivate() +{ + ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); + m_pWindow->Hide(); +} + +//----------------------------------------------------------------------------- +void ColoredPanel::SetSizePixel( const Size& i_rPanelWindowSize ) +{ + ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); + m_pWindow->SetSizePixel( i_rPanelWindowSize ); +} + +//----------------------------------------------------------------------------- +void ColoredPanel::GrabFocus() +{ + ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); + m_pWindow->GrabFocus(); +} + +//----------------------------------------------------------------------------- +void ColoredPanel::Dispose() +{ + ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); + m_pWindow.reset(); +} + +//----------------------------------------------------------------------------- +Reference< XAccessible > ColoredPanel::CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible ) +{ + ENSURE_OR_RETURN( m_pWindow.get(), "disposed!", NULL ); + (void)i_rParentAccessible; + return m_pWindow->GetAccessible(); +} + +//----------------------------------------------------------------------------- +::rtl::OUString ColoredPanel::GetDisplayName() const +{ + return m_aPanelName; +} + +//----------------------------------------------------------------------------- +Image ColoredPanel::GetImage() const +{ + return Image( m_aPanelIcon ); +} + +//============================================================================= +//= OptionsWindow +//============================================================================= +class PanelDemoMainWindow; +class OptionsWindow :public Window + ,public ::svt::IToolPanelDeckListener +{ +public: + OptionsWindow( PanelDemoMainWindow& i_rParent ); + ~OptionsWindow(); + + // Window overridables + virtual void Resize(); + virtual void GetFocus(); + virtual void StateChanged( StateChangedType i_nStateChange ); + + // IToolPanelDeckListener + virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual void PanelRemoved( const size_t i_nPosition ); + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ); + virtual void Dying(); + +private: + DECL_LINK( OnRadioToggled, RadioButton* ); + DECL_LINK( OnListEntrySelected, ListBox* ); + DECL_LINK( OnListEntryDoubleClicked, ListBox* ); + DECL_LINK( OnButtonClicked, PushButton* ); + DECL_LINK( OnEditModified, Edit* ); + + void impl_initPanelList(); + void impl_updateRemoveButton(); + void impl_updateInsertButton(); + +private: + FixedLine m_aAlignmentHeader; + RadioButton m_aAlignLeft; + RadioButton m_aAlignRight; + RadioButton m_aAlignTop; + RadioButton m_aAlignBottom; + FixedLine m_aTabItemContent; + RadioButton m_aImagesAndText; + RadioButton m_aImagesOnly; + RadioButton m_aTextOnly; + RadioButton m_aAutomaticContent; + + FixedLine m_aPanelsHeader; + ListBox m_aPanelList; + PushButton m_aRemovePanel; + ColorListBox m_aColors; + Edit m_aNewPanelName; + PushButton m_aInsertPanel; +}; + +//============================================================================= +//= PanelDemoMainWindow +//============================================================================= +class PanelDemoMainWindow : public WorkWindow +{ +public: + PanelDemoMainWindow(); + ~PanelDemoMainWindow(); + + // window overridables + virtual void Resize(); + +public: + // operations + void AlignTabs( const ::svt::TabAlignment i_eAlignment ); + void SetTabItemContent( const TabItemContent i_eItemContent ); + + // member access + IToolPanelDeck& GetToolPanelDeck(); + PToolPanel CreateToolPanel( const Color& i_rColor, const String& i_rPanelName ); + +protected: + virtual void GetFocus(); + +private: + ToolPanelDeck m_aToolPanelDeck; + OptionsWindow m_aDemoOptions; +}; + +//============================================================================= +//= PanelDemoMainWindow - implementation +//============================================================================= +//----------------------------------------------------------------------------- +OptionsWindow::OptionsWindow( PanelDemoMainWindow& i_rParent ) + :Window( &i_rParent, WB_BORDER | WB_DIALOGCONTROL ) + ,m_aAlignmentHeader( this ) + ,m_aAlignLeft( this, WB_GROUP ) + ,m_aAlignRight( this, 0 ) + ,m_aAlignTop( this, 0 ) + ,m_aAlignBottom( this, 0 ) + ,m_aTabItemContent( this ) + ,m_aImagesAndText( this ) + ,m_aImagesOnly( this ) + ,m_aTextOnly( this ) + ,m_aAutomaticContent( this ) + ,m_aPanelsHeader( this ) + ,m_aPanelList( this ) + ,m_aRemovePanel( this ) + ,m_aColors( this, WB_DROPDOWN ) + ,m_aNewPanelName( this, WB_BORDER ) + ,m_aInsertPanel( this ) +{ + SetBorderStyle( WINDOW_BORDER_MONO ); + + m_aColors.InsertEntry( Color( COL_BLACK ), String( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) ); + m_aColors.InsertEntry( Color( COL_BLUE ), String( RTL_CONSTASCII_USTRINGPARAM( "Blue" ) ) ); + m_aColors.InsertEntry( Color( COL_GREEN ), String( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) ); + m_aColors.InsertEntry( Color( COL_CYAN ), String( RTL_CONSTASCII_USTRINGPARAM( "Cyan" ) ) ); + m_aColors.InsertEntry( Color( COL_RED ), String( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) ); + m_aColors.InsertEntry( Color( COL_MAGENTA ), String( RTL_CONSTASCII_USTRINGPARAM( "Magenta" ) ) ); + m_aColors.InsertEntry( Color( COL_BROWN ), String( RTL_CONSTASCII_USTRINGPARAM( "Brown" ) ) ); + m_aColors.InsertEntry( Color( COL_GRAY ), String( RTL_CONSTASCII_USTRINGPARAM( "Gray" ) ) ); + m_aColors.InsertEntry( Color( COL_LIGHTGRAY ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Gray" ) ) ); + m_aColors.InsertEntry( Color( COL_LIGHTBLUE ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Blue" ) ) ); + m_aColors.InsertEntry( Color( COL_LIGHTGREEN ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Green" ) ) ); + m_aColors.InsertEntry( Color( COL_LIGHTCYAN ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Cyan" ) ) ); + m_aColors.InsertEntry( Color( COL_LIGHTRED ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Red" ) ) ); + m_aColors.InsertEntry( Color( COL_LIGHTMAGENTA ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Magenta" ) ) ); + m_aColors.InsertEntry( Color( COL_YELLOW ), String( RTL_CONSTASCII_USTRINGPARAM( "Yellow" ) ) ); + m_aColors.InsertEntry( Color( COL_WHITE ), String( RTL_CONSTASCII_USTRINGPARAM( "White" ) ) ); + m_aColors.SetDropDownLineCount( 16 ); + + Window* pControls[] = + { + &m_aAlignmentHeader, &m_aAlignLeft, &m_aAlignRight, &m_aAlignTop, &m_aAlignBottom, &m_aTabItemContent, + &m_aImagesAndText, &m_aImagesOnly, &m_aTextOnly, &m_aAutomaticContent, &m_aPanelsHeader, &m_aPanelList, + &m_aRemovePanel, &m_aColors, &m_aNewPanelName, &m_aInsertPanel + }; + const sal_Char* pTexts[] = + { + "Tab Bar Alignment", "Left", "Right", "Top", "Bottom", "Tab Items", "Images and Text", "Images only", + "Text only", "Automatic", "Panels", "", "Remove Panel", "", "", "Insert Panel" + }; + for ( size_t i=0; i < sizeof( pControls ) / sizeof( pControls[0] ); ++i ) + { + const WindowType eWindowType = pControls[i]->GetType(); + + pControls[i]->SetText( String::CreateFromAscii( pTexts[i] ) ); + pControls[i]->Show(); + + if ( eWindowType == WINDOW_RADIOBUTTON ) + static_cast< RadioButton* >( pControls[i] )->SetToggleHdl( LINK( this, OptionsWindow, OnRadioToggled ) ); + + if ( eWindowType == WINDOW_LISTBOX ) + { + static_cast< ListBox* >( pControls[i] )->SetSelectHdl( LINK( this, OptionsWindow, OnListEntrySelected ) ); + static_cast< ListBox* >( pControls[i] )->SetDoubleClickHdl( LINK( this, OptionsWindow, OnListEntryDoubleClicked ) ); + } + + if ( eWindowType == WINDOW_PUSHBUTTON ) + { + static_cast< PushButton* >( pControls[i] )->SetClickHdl( LINK( this, OptionsWindow, OnButtonClicked ) ); + } + + if ( eWindowType == WINDOW_EDIT ) + { + static_cast< Edit* >( pControls[i] )->SetModifyHdl( LINK( this, OptionsWindow, OnEditModified ) ); + } + } + + m_aAlignRight.Check(); + m_aImagesAndText.Check(); + + Show(); +} + +//----------------------------------------------------------------------------- +OptionsWindow::~OptionsWindow() +{ +} + +//----------------------------------------------------------------------------- +void OptionsWindow::impl_updateInsertButton() +{ + m_aInsertPanel.Enable( ( m_aColors.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND ) && ( m_aNewPanelName.GetText().Len() > 0 ) ); +} + +//----------------------------------------------------------------------------- +void OptionsWindow::impl_updateRemoveButton() +{ + m_aRemovePanel.Enable( m_aPanelList.GetSelectEntryCount() > 0 ); +} + +//----------------------------------------------------------------------------- +void OptionsWindow::impl_initPanelList() +{ + m_aPanelList.Clear(); + + PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); + IToolPanelDeck& rPanelDeck( rController.GetToolPanelDeck() ); + + for ( size_t i=0; i<rPanelDeck.GetPanelCount(); ++i ) + { + PToolPanel pPanel = rPanelDeck.GetPanel( i ); + m_aPanelList.InsertEntry( pPanel->GetDisplayName(), pPanel->GetImage() ); + } + ActivePanelChanged( ::boost::optional< size_t >(), rPanelDeck.GetActivePanel() ); + + impl_updateRemoveButton(); + impl_updateInsertButton(); + + rPanelDeck.AddListener( *this ); +} + +//----------------------------------------------------------------------------- +void OptionsWindow::StateChanged( StateChangedType i_nStateChange ) +{ + Window::StateChanged( i_nStateChange ); + + if ( i_nStateChange == STATE_CHANGE_INITSHOW ) + { + impl_initPanelList(); + } +} + +//----------------------------------------------------------------------------- +void OptionsWindow::GetFocus() +{ + Window::GetFocus(); + RadioButton* pRadios[] = + { + &m_aAlignLeft, &m_aAlignRight, &m_aAlignTop, &m_aAlignBottom + }; + for ( size_t i=0; i < sizeof( pRadios ) / sizeof( pRadios[0] ); ++i ) + { + if ( pRadios[i]->IsChecked() ) + { + pRadios[i]->GrabFocus(); + break; + } + } +} + +//----------------------------------------------------------------------------- +void OptionsWindow::Resize() +{ + Window::Resize(); + + const Size aOutputSize( GetOutputSizePixel() ); + + const Size aSpacing( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) ); + const long nIndent( LogicToPixel( Size( 6, 9 ), MAP_APPFONT ).Width() ); + const long nFixedLineHeight( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height() ); + const long nEditLineHeight( LogicToPixel( Size( 0, 12 ), MAP_APPFONT ).Height() ); + const long nButtonLineHeight( LogicToPixel( Size( 0, 14 ), MAP_APPFONT ).Height() ); + + const long nSuperordinateWidth = aOutputSize.Width() - 2 * aSpacing.Width(); + const long nSuperordinateX = aSpacing.Width(); + + const long nSubordinateWidth = aOutputSize.Width() - 2 * aSpacing.Width() - nIndent; + const long nSubordinateX = aSpacing.Width() + nIndent; + + Point aItemPos( nSuperordinateX, aSpacing.Height() ); + + struct ControlRow + { + Window* pWindow; + bool bSubordinate; + size_t nRows; + + ControlRow( Window& i_rWindow, const bool i_bSubordinate, const size_t i_nRows = 1 ) + :pWindow( &i_rWindow ) + ,bSubordinate( i_bSubordinate ) + ,nRows( i_nRows ) + { + } + }; + ControlRow aControlRows[] = + { + ControlRow( m_aAlignmentHeader, false ), + ControlRow( m_aAlignLeft, true ), + ControlRow( m_aAlignRight, true ), + ControlRow( m_aAlignTop, true ), + ControlRow( m_aAlignBottom, true ), + ControlRow( m_aTabItemContent, false ), + ControlRow( m_aImagesAndText, true ), + ControlRow( m_aImagesOnly, true ), + ControlRow( m_aTextOnly, true ), + ControlRow( m_aAutomaticContent, true ), + ControlRow( m_aPanelsHeader, false ), + ControlRow( m_aPanelList, true, 6 ), + ControlRow( m_aRemovePanel, true ), + ControlRow( m_aColors, true ), + ControlRow( m_aNewPanelName, true ), + ControlRow( m_aInsertPanel, true ) + }; + bool bPreviousWasSubordinate = false; + for ( size_t i=0; i < sizeof( aControlRows ) / sizeof( aControlRows[0] ); ++i ) + { + aItemPos.X() = ( aControlRows[i].bSubordinate ) ? nSubordinateX : nSuperordinateX; + + if ( bPreviousWasSubordinate && !aControlRows[i].bSubordinate ) + aItemPos.Y() += aSpacing.Height(); + bPreviousWasSubordinate = aControlRows[i].bSubordinate; + + // height depends on the window type + const WindowType eWindowType = aControlRows[i].pWindow->GetType(); + long nControlHeight( nFixedLineHeight ); + if ( ( eWindowType == WINDOW_EDIT ) + || ( eWindowType == WINDOW_LISTBOX ) + ) + { + nControlHeight = nEditLineHeight; + } + else + if ( ( eWindowType == WINDOW_PUSHBUTTON ) + ) + { + nControlHeight = nButtonLineHeight; + } + + Size aControlSize( + aControlRows[i].bSubordinate ? nSubordinateWidth : nSuperordinateWidth, + nControlHeight * aControlRows[i].nRows + ); + aControlRows[i].pWindow->SetPosSizePixel( aItemPos, aControlSize ); + + aItemPos.Move( 0, aControlSize.Height() + aSpacing.Height() ); + } +} + +//----------------------------------------------------------------------------- +void OptionsWindow::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) +{ + m_aPanelList.InsertEntry( i_pPanel->GetDisplayName(), i_pPanel->GetImage(), USHORT( i_nPosition ) ); +} + +//----------------------------------------------------------------------------- +void OptionsWindow::PanelRemoved( const size_t i_nPosition ) +{ + m_aPanelList.RemoveEntry( USHORT( i_nPosition ) ); + impl_updateRemoveButton(); +} + +//----------------------------------------------------------------------------- +void OptionsWindow::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) +{ + (void)i_rOldActive; + + if ( !i_rNewActive ) + m_aPanelList.SetNoSelection(); + else + m_aPanelList.SelectEntryPos( USHORT( *i_rNewActive ) ); +} + +//----------------------------------------------------------------------------- +void OptionsWindow::LayouterChanged( const PDeckLayouter& i_rNewLayouter ) +{ + (void)i_rNewLayouter; + // not interested in +} + +//----------------------------------------------------------------------------- +void OptionsWindow::Dying() +{ + // not interested in +} + +//----------------------------------------------------------------------------- +IMPL_LINK( OptionsWindow, OnListEntrySelected, ListBox*, i_pListBox ) +{ + if ( i_pListBox == &m_aColors ) + { + m_aNewPanelName.SetText( m_aColors.GetEntry( m_aColors.GetSelectEntryPos() ) ); + impl_updateInsertButton(); + } + else if ( i_pListBox == &m_aPanelList ) + { + impl_updateRemoveButton(); + } + return 0L; +} + +//----------------------------------------------------------------------------- +IMPL_LINK( OptionsWindow, OnListEntryDoubleClicked, ListBox*, i_pListBox ) +{ + PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); + + if ( i_pListBox == &m_aPanelList ) + { + size_t nActivatePanel = size_t( m_aPanelList.GetSelectEntryPos() ); + rController.GetToolPanelDeck().ActivatePanel( nActivatePanel ); + } + + return 0L; +} + +//----------------------------------------------------------------------------- +IMPL_LINK( OptionsWindow, OnEditModified, Edit*, i_pEdit ) +{ + if ( i_pEdit && &m_aNewPanelName ) + { + impl_updateInsertButton(); + } + + return 0L; +} + +//----------------------------------------------------------------------------- +IMPL_LINK( OptionsWindow, OnButtonClicked, PushButton*, i_pPushButton ) +{ + PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); + + if ( i_pPushButton == &m_aRemovePanel ) + { + rController.GetToolPanelDeck().RemovePanel( size_t( m_aPanelList.GetSelectEntryPos() ) ); + } + else if ( i_pPushButton == &m_aInsertPanel ) + { + PToolPanel pNewPanel( rController.CreateToolPanel( m_aColors.GetEntryColor( m_aColors.GetSelectEntryPos() ), m_aNewPanelName.GetText() ) ); + + ::boost::optional< size_t > aActivePanel( rController.GetToolPanelDeck().GetActivePanel() ); + size_t nNewPanelPos = !aActivePanel ? rController.GetToolPanelDeck().GetPanelCount() : *aActivePanel + 1; + + rController.GetToolPanelDeck().InsertPanel( pNewPanel, nNewPanelPos ); + } + return 0L; +} + +//----------------------------------------------------------------------------- +IMPL_LINK( OptionsWindow, OnRadioToggled, RadioButton*, i_pRadioButton ) +{ + PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); + + if ( i_pRadioButton->IsChecked() ) + { + if ( i_pRadioButton == &m_aAlignLeft ) + { + rController.AlignTabs( TABS_LEFT ); + } + else if ( i_pRadioButton == &m_aAlignRight ) + { + rController.AlignTabs( TABS_RIGHT ); + } + else if ( i_pRadioButton == &m_aAlignTop ) + { + rController.AlignTabs( TABS_TOP ); + } + else if ( i_pRadioButton == &m_aAlignBottom ) + { + rController.AlignTabs( TABS_BOTTOM ); + } + else if ( i_pRadioButton == &m_aImagesAndText ) + { + rController.SetTabItemContent( TABITEM_IMAGE_AND_TEXT ); + } + else if ( i_pRadioButton == &m_aImagesOnly ) + { + rController.SetTabItemContent( TABITEM_IMAGE_ONLY ); + } + else if ( i_pRadioButton == &m_aTextOnly ) + { + rController.SetTabItemContent( TABITEM_TEXT_ONLY ); + } + else if ( i_pRadioButton == &m_aAutomaticContent ) + { + rController.SetTabItemContent( TABITEM_AUTO ); + } + } + return 0L; +} +//============================================================================= +//= PanelDemoMainWindow - implementation +//============================================================================= +//----------------------------------------------------------------------------- +PanelDemoMainWindow::PanelDemoMainWindow() + :WorkWindow( NULL, WB_APP | WB_STDWORK | WB_CLIPCHILDREN ) + ,m_aToolPanelDeck( *this, WB_BORDER ) + ,m_aDemoOptions( *this ) +{ + m_aToolPanelDeck.SetPosSizePixel( Point( 20, 20 ), Size( 500, 300 ) ); + m_aToolPanelDeck.SetBorderStyle( WINDOW_BORDER_MONO ); + + m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), Color( COL_RED ), "Red" ) ), m_aToolPanelDeck.GetPanelCount() ); + m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), Color( COL_GREEN ), "Some flavor of Green" ) ), m_aToolPanelDeck.GetPanelCount() ); + m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), RGB_COLORDATA( 255, 255, 0 ), "Yellow is ugly" ) ), m_aToolPanelDeck.GetPanelCount() ); + m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), RGB_COLORDATA( 0, 0, 128 ), "Blue is the Color" ) ), m_aToolPanelDeck.GetPanelCount() ); + + m_aToolPanelDeck.ActivatePanel( size_t( 0 ) ); + m_aToolPanelDeck.Show(); + + SetText( String::CreateFromAscii( "ToolPanelDeck Demo Application" ) ); + Show(); + + Help::EnableQuickHelp(); + + GetSystemWindow()->GetTaskPaneList()->AddWindow( &m_aToolPanelDeck ); + GetSystemWindow()->GetTaskPaneList()->AddWindow( &m_aDemoOptions ); +} + +//----------------------------------------------------------------------------- +PanelDemoMainWindow::~PanelDemoMainWindow() +{ + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( &m_aDemoOptions ); + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( &m_aToolPanelDeck ); +} + +//----------------------------------------------------------------------------- +void PanelDemoMainWindow::GetFocus() +{ + WorkWindow::GetFocus(); + m_aToolPanelDeck.GrabFocus(); +} + +//----------------------------------------------------------------------------- +void PanelDemoMainWindow::Resize() +{ + WorkWindow::Resize(); + Size aSize( GetOutputSizePixel() ); + aSize.Width() -= 240; + aSize.Height() -= 40; + m_aToolPanelDeck.SetPosSizePixel( Point( 20, 20 ), aSize ); + + m_aDemoOptions.SetPosSizePixel( + Point( 20 + aSize.Width(), 20 ), + Size( 200, aSize.Height() ) + ); +} + +//----------------------------------------------------------------------------- +void PanelDemoMainWindow::AlignTabs( const ::svt::TabAlignment i_eAlignment ) +{ + TabItemContent eCurrentItemContent( TABITEM_IMAGE_AND_TEXT ); + TabDeckLayouter* pLayouter = dynamic_cast< TabDeckLayouter* >( m_aToolPanelDeck.GetLayouter().get() ); + OSL_ENSURE( pLayouter, "PanelDemoMainWindow::AlignTabs: wrong layouter!" ); + if ( pLayouter ) + eCurrentItemContent = pLayouter->GetTabItemContent(); + + m_aToolPanelDeck.SetLayouter( PDeckLayouter( new TabDeckLayouter( m_aToolPanelDeck, m_aToolPanelDeck, i_eAlignment, eCurrentItemContent ) ) ); +} + +//----------------------------------------------------------------------------- +void PanelDemoMainWindow::SetTabItemContent( const TabItemContent i_eItemContent ) +{ + TabDeckLayouter* pLayouter = dynamic_cast< TabDeckLayouter* >( m_aToolPanelDeck.GetLayouter().get() ); + OSL_ENSURE( pLayouter, "PanelDemoMainWindow::SetTabItemContent: wrong layouter!" ); + // we currently use tab layouters only ... + if ( !pLayouter ) + return; + + pLayouter->SetTabItemContent( i_eItemContent ); +} + +//----------------------------------------------------------------------------- +IToolPanelDeck& PanelDemoMainWindow::GetToolPanelDeck() +{ + return m_aToolPanelDeck; +} + +//----------------------------------------------------------------------------- +PToolPanel PanelDemoMainWindow::CreateToolPanel( const Color& i_rColor, const String& i_rPanelName ) +{ + return PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), i_rColor, i_rPanelName ) ); +} + +//============================================================================= +//= PanelDemo +//============================================================================= +//----------------------------------------------------------------------------- +Reference< XMultiServiceFactory > PanelDemo::createApplicationServiceManager() +{ + Reference< XMultiServiceFactory > xMS; + try + { + Reference< XComponentContext > xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext(); + if ( xComponentContext.is() ) + xMS = xMS.query( xComponentContext->getServiceManager() ); + } + catch( const ::com::sun::star::uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return xMS; +} + +//----------------------------------------------------------------------------- +void __EXPORT PanelDemo::Main() +{ + // create service factory + Reference< XMultiServiceFactory > xSMgr = createApplicationServiceManager(); + ::comphelper::setProcessServiceFactory( xSMgr ); + + // initialize the UCB + Sequence< Any > aArgs(2); + aArgs[0] <<= rtl::OUString::createFromAscii( "Local" ); + aArgs[1] <<= rtl::OUString::createFromAscii( "Office" ); + ::ucbhelper::ContentBroker::initialize( xSMgr, aArgs ); + + // run the application + PanelDemoMainWindow aWindow; + Execute(); +} + +PanelDemo aTheApplication; + +} } // namespace ::svt::toolpanel diff --git a/tools/inc/tools/diagnose_ex.h b/tools/inc/tools/diagnose_ex.h index fac739b32583..6833fd6632ce 100644 --- a/tools/inc/tools/diagnose_ex.h +++ b/tools/inc/tools/diagnose_ex.h @@ -141,6 +141,24 @@ return; \ } +/** asserts a given condition (in debug mode), and continues the most-inner + loop if the condition is not met +*/ +#define ENSURE_OR_CONTINUE( c, m ) \ + if ( !(c) ) \ + { \ + OSL_ENSURE( false, m ); \ + continue; \ + } +/** asserts a given condition (in debug mode), and continues the most-inner + loop if the condition is not met +*/ +#define ENSURE_OR_BREAK( c, m ) \ + if ( !(c) ) \ + { \ + OSL_ENSURE( false, m ); \ + break; \ + } #endif // TOOLS_DIAGNOSE_EX_H diff --git a/tools/inc/tools/gen.hxx b/tools/inc/tools/gen.hxx index 85da22126b77..308cc02165ce 100644 --- a/tools/inc/tools/gen.hxx +++ b/tools/inc/tools/gen.hxx @@ -420,6 +420,7 @@ public: Point Center() const; void Move( long nHorzMove, long nVertMove ); + inline void Transpose(); inline void SetPos( const Point& rPoint ); void SetSize( const Size& rSize ); inline Size GetSize() const; @@ -578,6 +579,20 @@ inline void Rectangle::Move( long nHorzMove, long nVertMove ) nBottom += nVertMove; } +void Rectangle::Transpose() +{ + if ( !IsEmpty() ) + { + long swap( nLeft ); + nLeft = nTop; + nTop = swap; + + swap = nRight; + nRight = nBottom; + nBottom = swap; + } +} + inline void Rectangle::SetPos( const Point& rPoint ) { if ( nRight != RECT_EMPTY ) diff --git a/tools/inc/tools/urlobj.hxx b/tools/inc/tools/urlobj.hxx index 86a8114ab0b8..17d52432e206 100644 --- a/tools/inc/tools/urlobj.hxx +++ b/tools/inc/tools/urlobj.hxx @@ -125,22 +125,21 @@ enum INetProtocol INET_PROT_DATA = 15, INET_PROT_CID = 16, INET_PROT_OUT = 17, - INET_PROT_VND_SUN_STAR_WFS = 18, - INET_PROT_VND_SUN_STAR_HIER = 19, - INET_PROT_VIM = 20, - INET_PROT_UNO = 21, - INET_PROT_COMPONENT = 22, - INET_PROT_VND_SUN_STAR_PKG = 23, - INET_PROT_LDAP = 24, - INET_PROT_DB = 25, - INET_PROT_VND_SUN_STAR_CMD = 26, - INET_PROT_VND_SUN_STAR_ODMA = 27, - INET_PROT_TELNET = 28, - INET_PROT_VND_SUN_STAR_EXPAND = 29, - INET_PROT_VND_SUN_STAR_TDOC = 30, - INET_PROT_GENERIC = 31, - INET_PROT_SMB = 32, - INET_PROT_END = 33 + INET_PROT_VND_SUN_STAR_HIER = 18, + INET_PROT_VIM = 19, + INET_PROT_UNO = 20, + INET_PROT_COMPONENT = 21, + INET_PROT_VND_SUN_STAR_PKG = 22, + INET_PROT_LDAP = 23, + INET_PROT_DB = 24, + INET_PROT_VND_SUN_STAR_CMD = 25, + INET_PROT_VND_SUN_STAR_ODMA = 26, + INET_PROT_TELNET = 27, + INET_PROT_VND_SUN_STAR_EXPAND = 28, + INET_PROT_VND_SUN_STAR_TDOC = 29, + INET_PROT_GENERIC = 30, + INET_PROT_SMB = 31, + INET_PROT_END = 32 }; //============================================================================ diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 07c532e60dd7..a6d7bc6fd04e 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -191,11 +191,6 @@ using namespace com::sun; name = *(escaped / alphanum / "!" / "$" / "'" / "(" / ")" / "*" / "+" / "," / "-" / "." / ":" / ";" / "=" / "?" / "@" / "_" / "~" - ; prvate (see RFC 1738, RFC 2396) - vnd-sun-star-wfs-url = "VND.SUN.STAR.WFS://" [host / "LOCALHOST"] ["/" segment *("/" segment)] - segment = *pchar - - ; private vnd-sun-star-hier-url = "VND.SUN.STAR.HIER:" ["//"reg_name] *("/" *pchar) reg_name = 1*(escaped / alphanum / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / "-" / "." / ":" / ";" / "=" / "@" / "_" / "~") @@ -403,8 +398,6 @@ static INetURLObject::SchemeInfo const aSchemeInfoMap[INET_PROT_END] false, false }, { "out", "out://", 0, true, false, false, false, false, false, false, false }, - { "vnd.sun.star.wfs", "vnd.sun.star.wfs://", 0, true, false, false, - false, true, true, true, false }, { "vnd.sun.star.hier", "vnd.sun.star.hier:", 0, true, false, false, false, false, false, true, false }, { "vim", "vim://", 0, true, true, false, true, false, false, true, @@ -429,7 +422,7 @@ static INetURLObject::SchemeInfo const aSchemeInfoMap[INET_PROT_END] false, false, false, false, false }, { "vnd.sun.star.tdoc", "vnd.sun.star.tdoc:", 0, false, false, false, false, false, false, true, false }, - { "", "", 0, false, false, false, false, false, false, false, false }, + { "", "", 0, false, false, false, false, true, true, true, false }, { "smb", "smb://", 139, true, true, false, true, true, true, true, true } }; @@ -1338,7 +1331,7 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, if (pHostPortBegin) { sal_Unicode const * pPort = pHostPortEnd; - if (getSchemeInfo().m_bPort && pHostPortBegin < pHostPortEnd) + if ( getSchemeInfo().m_bPort && pHostPortBegin < pHostPortEnd ) { sal_Unicode const * p1 = pHostPortEnd - 1; while (p1 > pHostPortBegin && INetMIME::isDigit(*p1)) @@ -1350,7 +1343,6 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: // If the host equals "LOCALHOST" (unencoded and ignoring // case), turn it into an empty host: if (INetMIME::equalIgnoreCase(pHostPortBegin, pPort, @@ -1367,7 +1359,6 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, return false; } break; - default: if (pHostPortBegin == pPort) { @@ -1609,7 +1600,23 @@ bool INetURLObject::convertRelToAbs(rtl::OUString const & rTheRelURIRef, STATE_DONE }; rtl::OUStringBuffer aSynAbsURIRef; - aSynAbsURIRef.appendAscii(getSchemeInfo().m_pScheme); + // make sure that the scheme is copied for generic schemes: getSchemeInfo().m_pScheme + // is empty ("") in that case, so take the scheme from m_aAbsURIRef + if (m_eScheme != INET_PROT_GENERIC) + { + aSynAbsURIRef.appendAscii(getSchemeInfo().m_pScheme); + } + else + { + sal_Unicode const * pSchemeBegin + = m_aAbsURIRef.getStr(); + sal_Unicode const * pSchemeEnd = pSchemeBegin; + while (pSchemeEnd[0] != ':') + { + ++pSchemeEnd; + } + aSynAbsURIRef.append(pSchemeBegin, pSchemeEnd - pSchemeBegin); + } aSynAbsURIRef.append(sal_Unicode(':')); sal_Char cEscapePrefix = getEscapePrefix(); @@ -2162,11 +2169,7 @@ INetURLObject::getPrefix(sal_Unicode const *& rBegin, { "vnd.sun.star.tdoc:", 0, INET_PROT_VND_SUN_STAR_TDOC, PrefixInfo::OFFICIAL }, { "vnd.sun.star.webdav:", 0, INET_PROT_VND_SUN_STAR_WEBDAV, - PrefixInfo::OFFICIAL }, - { "vnd.sun.star.wfs:", 0, INET_PROT_VND_SUN_STAR_WFS, - PrefixInfo::OFFICIAL }, - { "wfs:", "vnd.sun.star.wfs:", INET_PROT_VND_SUN_STAR_WFS, - PrefixInfo::ALIAS } }; + PrefixInfo::OFFICIAL } }; PrefixInfo const * pFirst = aMap + 1; PrefixInfo const * pLast = aMap + sizeof aMap / sizeof (PrefixInfo) - 1; PrefixInfo const * pMatch = 0; @@ -2889,7 +2892,6 @@ bool INetURLObject::setHost(rtl::OUString const & rTheHost, bool bOctets, switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { rtl::OUString sTemp(aSynHost); if (sTemp.equalsIgnoreAsciiCaseAsciiL( @@ -2985,7 +2987,6 @@ bool INetURLObject::parsePath(INetProtocol eScheme, break; case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { if (bSkippedInitialSlash) aTheSynPath.append(sal_Unicode('/')); @@ -3398,7 +3399,6 @@ bool INetURLObject::parsePath(INetProtocol eScheme, if (aTheSynPath.getLength() == 0) return false; break; - default: OSL_ASSERT(false); break; @@ -3825,7 +3825,27 @@ INetURLObject::getAbbreviated( OSL_ENSURE(rStringWidth.is(), "specification violation"); sal_Char cEscapePrefix = getEscapePrefix(); rtl::OUStringBuffer aBuffer; - aBuffer.appendAscii(getSchemeInfo().m_pScheme); + // make sure that the scheme is copied for generic schemes: getSchemeInfo().m_pScheme + // is empty ("") in that case, so take the scheme from m_aAbsURIRef + if (m_eScheme != INET_PROT_GENERIC) + { + aBuffer.appendAscii(getSchemeInfo().m_pScheme); + } + else + { + if (m_aAbsURIRef) + { + sal_Unicode const * pSchemeBegin + = m_aAbsURIRef.getStr(); + sal_Unicode const * pSchemeEnd = pSchemeBegin; + + while (pSchemeEnd[0] != ':') + { + ++pSchemeEnd; + } + aBuffer.append(pSchemeBegin, pSchemeEnd - pSchemeBegin); + } + } aBuffer.append(static_cast< sal_Unicode >(':')); bool bAuthority = getSchemeInfo().m_bAuthority; sal_Unicode const * pCoreBegin @@ -4007,7 +4027,6 @@ bool INetURLObject::operator ==(INetURLObject const & rObject) const switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { // If the URL paths of two file URLs only differ in that one has a // final '/' and the other has not, take the two paths as @@ -4162,7 +4181,6 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme, switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { rtl::OUString sTemp(aSynHost); if (sTemp.equalsIgnoreAsciiCaseAsciiL( diff --git a/tools/workben/urltest.cxx b/tools/workben/urltest.cxx index 694698297680..0930dfcc5239 100644 --- a/tools/workben/urltest.cxx +++ b/tools/workben/urltest.cxx @@ -523,6 +523,8 @@ main() /*TODO "vnd.sun.star.wfs:///c|/xyz/",*/ /*TODO "vnd.sun.star.wfs://xxx/yyy?zzz",*/ "vnd.sun.star.wfs:///x/y/z", + "vnd.sun.star.generic:///x/y/z", + "vnd.sun.star.generic://host:34/x/y/z" /*TODO "wfs://",*/ /*TODO "wfs://LocalHost",*/ /*TODO "wfs:///c|/xyz/",*/ @@ -533,13 +535,21 @@ main() INetURLObject aUrl(aTest[i]); if (aUrl.HasError()) printf("BAD %s\n", aTest[i]); - else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). - equalsAscii(aTest[i]) != sal_True) + else { + if (aUrl.GetProtocol() != INET_PROT_GENERIC) { + printf("BAD PROTOCOL %i -> %i\n", + aUrl.GetProtocol(), + INET_PROT_GENERIC); + } + if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). + equalsAscii(aTest[i]) != sal_True) + { String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); printf("BAD %s -> %s\n", aTest[i], ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer()); + } } } } diff --git a/ucbhelper/inc/ucbhelper/propertyvalueset.hxx b/ucbhelper/inc/ucbhelper/propertyvalueset.hxx index ed02a80f571f..82d440df0c02 100644 --- a/ucbhelper/inc/ucbhelper/propertyvalueset.hxx +++ b/ucbhelper/inc/ucbhelper/propertyvalueset.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/sdbc/XColumnLocate.hpp> #include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/beans/Property.hpp> #include <cppuhelper/weak.hxx> #include "osl/mutex.hxx" @@ -43,7 +44,6 @@ namespace com { namespace sun { namespace star { namespace script { } } } } namespace com { namespace sun { namespace star { namespace beans { - struct Property; struct PropertyValue; class XPropertySet; } } } } @@ -205,175 +205,205 @@ public: */ sal_Int32 getLength() const; - /** - * This method appends a string to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendString ( const ::com::sun::star::beans::Property& rProp, - const ::rtl::OUString& rValue ); - - /** - * This method appends a boolean to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendBoolean ( const ::com::sun::star::beans::Property& rProp, - sal_Bool bValue ); - - /** - * This method appends a byte to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendByte ( const ::com::sun::star::beans::Property& rProp, - sal_Int8 nValue ); - - /** - * This method appends a short to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendShort ( const ::com::sun::star::beans::Property& rProp, - sal_Int16 nValue ); - - /** - * This method appends an int to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendInt ( const ::com::sun::star::beans::Property& rProp, - sal_Int32 nValue ); - - /** - * This method appends a long to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendLong ( const ::com::sun::star::beans::Property& rProp, - sal_Int64 nValue ); - - /** - * This method appends a float to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendFloat ( const ::com::sun::star::beans::Property& rProp, - float nValue ); - - /** - * This method appends a double to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendDouble ( const ::com::sun::star::beans::Property& rProp, - double nValue ); - - /** - * This method appends a byte sequence to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendBytes ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Sequence< - sal_Int8 >& rValue ); - - /** - * This method appends a date to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendDate ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::util::Date& rValue ); - - /** - * This method appends a time to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendTime ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::util::Time& rValue ); - - /** - * This method appends a timestamp to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendTimestamp( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::util::DateTime& rValue ); - - /** - * This method appends a binary stream to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendBinaryStream ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Reference< - ::com::sun::star::io::XInputStream >& - rValue ); - - /** - * This method appends a character stream to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendCharacterStream( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Reference< - ::com::sun::star::io::XInputStream >& - rValue ); - - /** - * This method appends an object ( any ) to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendObject ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Any& rValue ); - - /** - * This method appends a ref to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendRef ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Reference< - ::com::sun::star::sdbc::XRef >& rValue ); - - /** - * This method appends a blob to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendBlob ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Reference< - ::com::sun::star::sdbc::XBlob >& rValue ); - - /** - * This method appends a clob to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendClob ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Reference< - ::com::sun::star::sdbc::XClob >& rValue ); - - /** - * This method appends an array to the value set. - * - * @param rProp is the property the value belongs to. - */ - void appendArray ( const ::com::sun::star::beans::Property& rProp, - const ::com::sun::star::uno::Reference< - ::com::sun::star::sdbc::XArray >& rValue ); - - /** - * This method appends a void value ( a "hole" ) to the value set. This - * is useful, since void values indicate errors, like non-existing - * property (-values) etc. - * - * @param rProp is the property the value belongs to. - */ - void appendVoid ( const ::com::sun::star::beans::Property& rProp ); + void appendString( const ::rtl::OUString& rPropName, const ::rtl::OUString& rValue ); + void appendString( const sal_Char* pAsciiPropName, const ::rtl::OUString& rValue ) + { + appendString( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendString( const ::com::sun::star::beans::Property& rProp, const ::rtl::OUString& rValue ) + { + appendString( rProp.Name, rValue ); + } + + void appendBoolean( const ::rtl::OUString& rPropName, sal_Bool bValue ); + void appendBoolean( const sal_Char* pAsciiPropName, sal_Bool bValue ) + { + appendBoolean( ::rtl::OUString::createFromAscii( pAsciiPropName ), bValue ); + } + void appendBoolean( const ::com::sun::star::beans::Property& rProp, sal_Bool bValue ) + { + appendBoolean( rProp.Name, bValue ); + } + + void appendByte( const ::rtl::OUString& rPropName, sal_Int8 nValue ); + void appendByte( const sal_Char* pAsciiPropName, sal_Int8 nValue ) + { + appendByte( ::rtl::OUString::createFromAscii( pAsciiPropName ), nValue ); + } + void appendByte( const ::com::sun::star::beans::Property& rProp, sal_Int8 nValue ) + { + appendByte( rProp.Name, nValue ); + } + + void appendShort( const ::rtl::OUString& rPropName, sal_Int16 nValue ); + void appendShort( const sal_Char* pAsciiPropName, sal_Int16 nValue ) + { + appendShort( ::rtl::OUString::createFromAscii( pAsciiPropName ), nValue ); + } + void appendShort( const ::com::sun::star::beans::Property& rProp, sal_Int16 nValue ) + { + appendShort( rProp.Name, nValue ); + } + + void appendInt( const ::rtl::OUString& rPropName, sal_Int32 nValue ); + void appendInt( const sal_Char* pAsciiPropName, sal_Int32 nValue ) + { + appendInt( ::rtl::OUString::createFromAscii( pAsciiPropName ), nValue ); + } + void appendInt( const ::com::sun::star::beans::Property& rProp, sal_Int32 nValue ) + { + appendInt( rProp.Name, nValue ); + } + + void appendLong( const ::rtl::OUString& rPropName, sal_Int64 nValue ); + void appendLong( const sal_Char* pAsciiPropName, sal_Int64 nValue ) + { + appendLong( ::rtl::OUString::createFromAscii( pAsciiPropName ), nValue ); + } + void appendLong( const ::com::sun::star::beans::Property& rProp, sal_Int64 nValue ) + { + appendLong( rProp.Name, nValue ); + } + + void appendFloat( const ::rtl::OUString& rPropName, float nValue ); + void appendFloat( const sal_Char* pAsciiPropName, float nValue ) + { + appendFloat( ::rtl::OUString::createFromAscii( pAsciiPropName ), nValue ); + } + void appendFloat( const ::com::sun::star::beans::Property& rProp, float nValue ) + { + appendFloat( rProp.Name, nValue ); + } + + void appendDouble( const ::rtl::OUString& rPropName, double nValue ); + void appendDouble( const sal_Char* pAsciiPropName, double nValue ) + { + appendDouble( ::rtl::OUString::createFromAscii( pAsciiPropName ), nValue ); + } + void appendDouble( const ::com::sun::star::beans::Property& rProp, double nValue ) + { + appendDouble( rProp.Name, nValue ); + } + + void appendBytes( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Sequence< sal_Int8 >& rValue ); + void appendBytes( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Sequence< sal_Int8 >& rValue ) + { + appendBytes( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendBytes( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Sequence< sal_Int8 >& rValue ) + { + appendBytes( rProp.Name, rValue ); + } + + void appendDate( const ::rtl::OUString& rPropName, const ::com::sun::star::util::Date& rValue ); + void appendDate( const sal_Char* pAsciiPropName, const ::com::sun::star::util::Date& rValue ) + { + appendDate( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendDate( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::util::Date& rValue ) + { + appendDate( rProp.Name, rValue ); + } + + void appendTime( const ::rtl::OUString& rPropName, const ::com::sun::star::util::Time& rValue ); + void appendTime( const sal_Char* pAsciiPropName, const ::com::sun::star::util::Time& rValue ) + { + appendTime( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendTime( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::util::Time& rValue ) + { + appendTime( rProp.Name, rValue ); + } + + void appendTimestamp( const ::rtl::OUString& rPropName, const ::com::sun::star::util::DateTime& rValue ); + void appendTimestamp( const sal_Char* pAsciiPropName, const ::com::sun::star::util::DateTime& rValue ) + { + appendTimestamp( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendTimestamp( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::util::DateTime& rValue ) + { + appendTimestamp( rProp.Name, rValue ); + } + + void appendBinaryStream( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rValue ); + void appendBinaryStream( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rValue ) + { + appendBinaryStream( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendBinaryStream( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rValue ) + { + appendBinaryStream( rProp.Name, rValue ); + } + + void appendCharacterStream( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rValue ); + void appendCharacterStream( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rValue ) + { + appendCharacterStream( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendCharacterStream( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rValue ) + { + appendCharacterStream( rProp.Name, rValue ); + } + + void appendObject( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rValue ); + void appendObject( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Any& rValue ) + { + appendObject( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendObject( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Any& rValue ) + { + appendObject( rProp.Name, rValue ); + } + + void appendRef( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& rValue ); + void appendRef( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& rValue ) + { + appendRef( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendRef( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& rValue ) + { + appendRef( rProp.Name, rValue ); + } + + void appendBlob( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& rValue ); + void appendBlob( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& rValue ) + { + appendBlob( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendBlob( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& rValue ) + { + appendBlob( rProp.Name, rValue ); + } + + void appendClob( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& rValue ); + void appendClob( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& rValue ) + { + appendClob( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendClob( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& rValue ) + { + appendClob( rProp.Name, rValue ); + } + + void appendArray( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& rValue ); + void appendArray( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& rValue ) + { + appendArray( ::rtl::OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendArray( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& rValue ) + { + appendArray( rProp.Name, rValue ); + } + + void appendVoid( const ::rtl::OUString& rPropName ); + void appendVoid( const sal_Char* pAsciiPropName) + { + appendVoid( ::rtl::OUString::createFromAscii( pAsciiPropName ) ); + } + void appendVoid( const ::com::sun::star::beans::Property& rProp ) + { + appendVoid( rProp.Name ); + } /** * This method tries to append all property values contained in a diff --git a/ucbhelper/prj/build.lst b/ucbhelper/prj/build.lst index 3f49d69c987f..bbd01df9022a 100644 --- a/ucbhelper/prj/build.lst +++ b/ucbhelper/prj/build.lst @@ -1,6 +1,7 @@ -uh ucbhelper : offuh sal cppu cppuhelper salhelper NULL -uh ucbhelper usr1 - all uh_mkout NULL -uh ucbhelper\inc nmake - all uh_inc NULL -uh ucbhelper\source\client nmake - all uh_client uh_inc NULL -uh ucbhelper\source\provider nmake - all uh_provider uh_inc NULL -uh ucbhelper\util nmake - all uh_util uh_client uh_provider NULL +uh ucbhelper : offuh sal cppu cppuhelper salhelper NULL +uh ucbhelper usr1 - all uh_mkout NULL +uh ucbhelper\inc nmake - all uh_inc NULL +uh ucbhelper\source\client nmake - all uh_client uh_inc NULL +uh ucbhelper\source\provider nmake - all uh_provider uh_inc NULL +uh ucbhelper\util nmake - all uh_util uh_client uh_provider NULL +uh ucbhelper\workben\myucp nmake - all uh_wb_myucp uh_util NULL diff --git a/ucbhelper/source/provider/propertyvalueset.cxx b/ucbhelper/source/provider/propertyvalueset.cxx index 5d9cfe31cf87..1c857ca467f0 100644 --- a/ucbhelper/source/provider/propertyvalueset.cxx +++ b/ucbhelper/source/provider/propertyvalueset.cxx @@ -89,7 +89,8 @@ const sal_uInt32 OBJECT_VALUE_SET = 0x00040000; struct PropertyValue { - Property aProperty; + ::rtl::OUString + sPropertyName; sal_uInt32 nPropsSet; sal_uInt32 nOrigValue; @@ -240,12 +241,12 @@ class PropertyValues : public PropertyValuesVector {}; _member_name_, \ getCppuType( static_cast< const _type_ * >( 0 ) ) ) -#define SETVALUE_IMPL( _property_, _type_name_, _member_name_, _value_ ) \ +#define SETVALUE_IMPL( _prop_name_, _type_name_, _member_name_, _value_ ) \ \ osl::MutexGuard aGuard( m_aMutex ); \ \ ucbhelper_impl::PropertyValue aNewValue; \ - aNewValue.aProperty = _property_; \ + aNewValue.sPropertyName = _prop_name_; \ aNewValue.nPropsSet = _type_name_; \ aNewValue.nOrigValue = _type_name_; \ aNewValue._member_name_ = _value_; \ @@ -642,7 +643,7 @@ sal_Int32 SAL_CALL PropertyValueSet::findColumn( const OUString& columnName ) sal_Int32 nCount = m_pValues->size(); for ( sal_Int32 n = 0; n < nCount; ++n ) { - if ( (*m_pValues)[ n ].aProperty.Name.equals( columnName ) ) + if ( (*m_pValues)[ n ].sPropertyName.equals( columnName ) ) return sal_Int32( n + 1 ); // Index is 1-based. } } @@ -682,144 +683,144 @@ sal_Int32 PropertyValueSet::getLength() const } //========================================================================= -void PropertyValueSet::appendString( const Property& rProp, +void PropertyValueSet::appendString( const ::rtl::OUString& rPropName, const OUString& rValue ) { - SETVALUE_IMPL( rProp, STRING_VALUE_SET, aString, rValue ); + SETVALUE_IMPL( rPropName, STRING_VALUE_SET, aString, rValue ); } //========================================================================= -void PropertyValueSet::appendBoolean( const Property& rProp, +void PropertyValueSet::appendBoolean( const ::rtl::OUString& rPropName, sal_Bool bValue ) { - SETVALUE_IMPL( rProp, BOOLEAN_VALUE_SET, bBoolean, bValue ); + SETVALUE_IMPL( rPropName, BOOLEAN_VALUE_SET, bBoolean, bValue ); } //========================================================================= -void PropertyValueSet::appendByte( const Property& rProp, +void PropertyValueSet::appendByte( const ::rtl::OUString& rPropName, sal_Int8 nValue ) { - SETVALUE_IMPL( rProp, BYTE_VALUE_SET, nByte, nValue ); + SETVALUE_IMPL( rPropName, BYTE_VALUE_SET, nByte, nValue ); } //========================================================================= -void PropertyValueSet::appendShort( const Property& rProp, +void PropertyValueSet::appendShort( const ::rtl::OUString& rPropName, sal_Int16 nValue ) { - SETVALUE_IMPL( rProp, SHORT_VALUE_SET, nShort, nValue ); + SETVALUE_IMPL( rPropName, SHORT_VALUE_SET, nShort, nValue ); } //========================================================================= -void PropertyValueSet::appendInt( const Property& rProp, +void PropertyValueSet::appendInt( const ::rtl::OUString& rPropName, sal_Int32 nValue ) { - SETVALUE_IMPL( rProp, INT_VALUE_SET, nInt, nValue ); + SETVALUE_IMPL( rPropName, INT_VALUE_SET, nInt, nValue ); } //========================================================================= -void PropertyValueSet::appendLong( const Property& rProp, +void PropertyValueSet::appendLong( const ::rtl::OUString& rPropName, sal_Int64 nValue ) { - SETVALUE_IMPL( rProp, LONG_VALUE_SET, nLong, nValue ); + SETVALUE_IMPL( rPropName, LONG_VALUE_SET, nLong, nValue ); } //========================================================================= -void PropertyValueSet::appendFloat( const Property& rProp, +void PropertyValueSet::appendFloat( const ::rtl::OUString& rPropName, float nValue ) { - SETVALUE_IMPL( rProp, FLOAT_VALUE_SET, nFloat, nValue ); + SETVALUE_IMPL( rPropName, FLOAT_VALUE_SET, nFloat, nValue ); } //========================================================================= -void PropertyValueSet::appendDouble( const Property& rProp, +void PropertyValueSet::appendDouble( const ::rtl::OUString& rPropName, double nValue ) { - SETVALUE_IMPL( rProp, DOUBLE_VALUE_SET, nDouble, nValue ); + SETVALUE_IMPL( rPropName, DOUBLE_VALUE_SET, nDouble, nValue ); } //========================================================================= -void PropertyValueSet::appendBytes( const Property& rProp, +void PropertyValueSet::appendBytes( const ::rtl::OUString& rPropName, const Sequence< sal_Int8 >& rValue ) { - SETVALUE_IMPL( rProp, BYTES_VALUE_SET, aBytes, rValue ); + SETVALUE_IMPL( rPropName, BYTES_VALUE_SET, aBytes, rValue ); } //========================================================================= -void PropertyValueSet::appendDate( const Property& rProp, +void PropertyValueSet::appendDate( const ::rtl::OUString& rPropName, const Date& rValue ) { - SETVALUE_IMPL( rProp, DATE_VALUE_SET, aDate, rValue ); + SETVALUE_IMPL( rPropName, DATE_VALUE_SET, aDate, rValue ); } //========================================================================= -void PropertyValueSet::appendTime( const Property& rProp, +void PropertyValueSet::appendTime( const ::rtl::OUString& rPropName, const Time& rValue ) { - SETVALUE_IMPL( rProp, TIME_VALUE_SET, aTime, rValue ); + SETVALUE_IMPL( rPropName, TIME_VALUE_SET, aTime, rValue ); } //========================================================================= -void PropertyValueSet::appendTimestamp( const Property& rProp, +void PropertyValueSet::appendTimestamp( const ::rtl::OUString& rPropName, const DateTime& rValue ) { - SETVALUE_IMPL( rProp, TIMESTAMP_VALUE_SET, aTimestamp, rValue ); + SETVALUE_IMPL( rPropName, TIMESTAMP_VALUE_SET, aTimestamp, rValue ); } //========================================================================= void PropertyValueSet::appendBinaryStream( - const Property& rProp, + const ::rtl::OUString& rPropName, const Reference< XInputStream >& rValue ) { - SETVALUE_IMPL( rProp, BINARYSTREAM_VALUE_SET, xBinaryStream, rValue ); + SETVALUE_IMPL( rPropName, BINARYSTREAM_VALUE_SET, xBinaryStream, rValue ); } //========================================================================= void PropertyValueSet::appendCharacterStream( - const Property& rProp, + const ::rtl::OUString& rPropName, const Reference< XInputStream >& rValue ) { - SETVALUE_IMPL( rProp, CHARACTERSTREAM_VALUE_SET, xCharacterStream, rValue ); + SETVALUE_IMPL( rPropName, CHARACTERSTREAM_VALUE_SET, xCharacterStream, rValue ); } //========================================================================= -void PropertyValueSet::appendObject( const Property& rProp, +void PropertyValueSet::appendObject( const ::rtl::OUString& rPropName, const Any& rValue ) { - SETVALUE_IMPL( rProp, OBJECT_VALUE_SET, aObject, rValue ); + SETVALUE_IMPL( rPropName, OBJECT_VALUE_SET, aObject, rValue ); } //========================================================================= -void PropertyValueSet::appendRef( const Property& rProp, +void PropertyValueSet::appendRef( const ::rtl::OUString& rPropName, const Reference< XRef >& rValue ) { - SETVALUE_IMPL( rProp, REF_VALUE_SET, xRef, rValue ); + SETVALUE_IMPL( rPropName, REF_VALUE_SET, xRef, rValue ); } //========================================================================= -void PropertyValueSet::appendBlob( const Property& rProp, +void PropertyValueSet::appendBlob( const ::rtl::OUString& rPropName, const Reference< XBlob >& rValue ) { - SETVALUE_IMPL( rProp, BLOB_VALUE_SET, xBlob, rValue ); + SETVALUE_IMPL( rPropName, BLOB_VALUE_SET, xBlob, rValue ); } //========================================================================= -void PropertyValueSet::appendClob( const Property& rProp, +void PropertyValueSet::appendClob( const ::rtl::OUString& rPropName, const Reference< XClob >& rValue ) { - SETVALUE_IMPL( rProp, CLOB_VALUE_SET, xClob, rValue ); + SETVALUE_IMPL( rPropName, CLOB_VALUE_SET, xClob, rValue ); } //========================================================================= -void PropertyValueSet::appendArray( const Property& rProp, +void PropertyValueSet::appendArray( const ::rtl::OUString& rPropName, const Reference< XArray >& rValue ) { - SETVALUE_IMPL( rProp, ARRAY_VALUE_SET, xArray, rValue ); + SETVALUE_IMPL( rPropName, ARRAY_VALUE_SET, xArray, rValue ); } //========================================================================= -void PropertyValueSet::appendVoid( const Property& rProp ) +void PropertyValueSet::appendVoid( const ::rtl::OUString& rPropName ) { - SETVALUE_IMPL( rProp, NO_VALUE_SET, aObject, Any() ); + SETVALUE_IMPL( rPropName, NO_VALUE_SET, aObject, Any() ); } //========================================================================= diff --git a/unotools/inc/unotools/confignode.hxx b/unotools/inc/unotools/confignode.hxx index 8745508375a1..57c3d4070feb 100644 --- a/unotools/inc/unotools/confignode.hxx +++ b/unotools/inc/unotools/confignode.hxx @@ -35,6 +35,11 @@ #include <com/sun/star/util/XChangesBatch.hpp> #include <unotools/eventlisteneradapter.hxx> +namespace comphelper +{ + class ComponentContext; +} + //........................................................................ namespace utl { @@ -59,19 +64,23 @@ namespace utl m_xReplaceAccess; /// replacing child values ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xContainerAccess; /// modifying set nodes (optional interface of our UNO object) - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - m_xProvider; /// the configuration provider which supplied the nodes of the hierarchy we're a part of + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + m_xDummy; sal_Bool m_bEscapeNames; /// escape names before accessing children ? ::rtl::OUString m_sCompletePath; OConfigurationNode insertNode(const ::rtl::OUString& _rName,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xNode) const throw(); + protected: /// constructs a node object with an interface representing a node OConfigurationNode( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxNode, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxProvider); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxNode + ); + + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& + getUNONode() const { return m_xDirectAccess; } public: /// constructs an empty and invalid node object @@ -186,14 +195,6 @@ namespace utl */ sal_Bool getEscape() const { return m_bEscapeNames; } - /** clone the object, creating a new hierarchy where the root represents the same node as the object - where this method is called does.<p/> - The new hierarchy does not share any updates with the one the object is a part of, i.e. any changes made - in the existing hierarchy are not visible to the newly created one until committed (and vice versa). - @param _rRoot out parameter. upon return, contains the object representing the root of the new hierarchy. - */ - OConfigurationTreeRoot cloneAsRoot() const throw(); - /// invalidate the object virtual void clear() throw(); @@ -246,22 +247,23 @@ namespace utl /** ctor<p/> */ OConfigurationTreeRoot( - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesBatch >& _rxRootNode, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxProvider); + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesBatch >& _rxRootNode + ); /** ctor for a readonly node */ OConfigurationTreeRoot( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxRootNode, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxProvider); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxRootNode + ); public: - /// modes to used when creating a top-level node object + /// modes to use when creating a top-level node object enum CREATION_MODE { - CM_READONLY, /// open the node (i.e. sub tree) for read access only - CM_UPDATABLE, /// open the node (i.e. sub tree) for read and write access - CM_PREFER_UPDATABLE /// open the node (i.e. sub tree) for read and write access, if this fails, open it for read acces + /// open the node (i.e. sub tree) for read access only + CM_READONLY, + /// open the node (i.e. sub tree) for read and write access, fall back to read-only if write access is not possible + CM_UPDATABLE }; public: @@ -270,6 +272,14 @@ namespace utl */ OConfigurationTreeRoot() :OConfigurationNode() { } + /** creates a configuration tree for the given path in the given mode + */ + OConfigurationTreeRoot( + const ::comphelper::ComponentContext& i_rContext, + const sal_Char* i_pAsciiNodePath, + const bool i_bUpdatable + ); + /// copy ctor OConfigurationTreeRoot(const OConfigurationTreeRoot& _rSource) :OConfigurationNode(_rSource), m_xCommitter(_rSource.m_xCommitter) { } @@ -293,7 +303,7 @@ namespace utl const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxConfProvider, const ::rtl::OUString& _rPath, sal_Int32 _nDepth = -1, - CREATION_MODE _eMode = CM_PREFER_UPDATABLE, + CREATION_MODE _eMode = CM_UPDATABLE, sal_Bool _bLazyWrite = sal_True ); @@ -310,7 +320,7 @@ namespace utl @param _eMode specifies which privileges should be applied when retrieving the node */ static OConfigurationTreeRoot createWithServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, - const ::rtl::OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_PREFER_UPDATABLE, sal_Bool _bLazyWrite = sal_True); + const ::rtl::OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_UPDATABLE, sal_Bool _bLazyWrite = sal_True); /** tolerant version of the <member>createWithServiceFactory</member> @@ -319,7 +329,7 @@ namespace utl given node path does not exist) are still asserted.</p> */ static OConfigurationTreeRoot tryCreateWithServiceFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, - const ::rtl::OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_PREFER_UPDATABLE, sal_Bool _bLazyWrite = sal_True ); + const ::rtl::OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_UPDATABLE, sal_Bool _bLazyWrite = sal_True ); /** commit all changes made on the subtree the object is the root for<p/> All changes made on any <type>OConfigurationNode</type> object retrieved (maybe indirect) from this root diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx index 802a63782cf9..5db9f8db4313 100644 --- a/unotools/source/config/confignode.cxx +++ b/unotools/source/config/confignode.cxx @@ -40,6 +40,8 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XNamed.hpp> #include <comphelper/extract.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <rtl/string.hxx> #if OSL_DEBUG_LEVEL > 0 #include <rtl/strbuf.hxx> @@ -60,9 +62,8 @@ namespace utl //= OConfigurationNode //======================================================================== //------------------------------------------------------------------------ - OConfigurationNode::OConfigurationNode(const Reference< XInterface >& _rxNode, const Reference< XMultiServiceFactory >& _rxProvider) - :m_xProvider(_rxProvider) - ,m_bEscapeNames(sal_False) + OConfigurationNode::OConfigurationNode(const Reference< XInterface >& _rxNode ) + :m_bEscapeNames(sal_False) { OSL_ENSURE(_rxNode.is(), "OConfigurationNode::OConfigurationNode: invalid node interface!"); if (_rxNode.is()) @@ -98,7 +99,6 @@ namespace utl ,m_xDirectAccess(_rSource.m_xDirectAccess) ,m_xReplaceAccess(_rSource.m_xReplaceAccess) ,m_xContainerAccess(_rSource.m_xContainerAccess) - ,m_xProvider(_rSource.m_xProvider) ,m_bEscapeNames(_rSource.m_bEscapeNames) ,m_sCompletePath(_rSource.m_sCompletePath) { @@ -116,7 +116,6 @@ namespace utl m_xDirectAccess = _rSource.m_xDirectAccess; m_xContainerAccess = _rSource.m_xContainerAccess; m_xReplaceAccess = _rSource.m_xReplaceAccess; - m_xProvider = _rSource.m_xProvider; m_bEscapeNames = _rSource.m_bEscapeNames; m_sCompletePath = _rSource.m_sCompletePath; @@ -244,7 +243,7 @@ namespace utl ::rtl::OUString sName = normalizeName(_rName, NO_CALLER); m_xContainerAccess->insertByName(sName, makeAny(_xNode)); // if we're here, all was ok ... - return OConfigurationNode(_xNode, m_xProvider); + return OConfigurationNode( _xNode ); } catch(const Exception&) { @@ -308,7 +307,7 @@ namespace utl OSL_ENSURE(sal_False, "OConfigurationNode::openNode: could not open the node!"); } if (xNode.is()) - return OConfigurationNode(xNode, m_xProvider); + return OConfigurationNode( xNode ); } catch(NoSuchElementException& e) { @@ -470,63 +469,102 @@ namespace utl } //------------------------------------------------------------------------ - OConfigurationTreeRoot OConfigurationNode::cloneAsRoot() const throw() + void OConfigurationNode::clear() throw() + { + m_xHierarchyAccess.clear(); + m_xDirectAccess.clear(); + m_xReplaceAccess.clear(); + m_xContainerAccess.clear(); + } + + //======================================================================== + //= helper + //======================================================================== + namespace { - OSL_ENSURE(m_xHierarchyAccess.is(), "OConfigurationNode::cloneAsRoot: object is invalid!"); - if (m_xHierarchyAccess.is()) + //-------------------------------------------------------------------- + static const ::rtl::OUString& lcl_getProviderServiceName( ) { - // first get the complete path of the node we represent - ::rtl::OUString sCompletePath; - Reference< XHierarchicalName > xNodeNameAccess(m_xHierarchyAccess, UNO_QUERY); - if (xNodeNameAccess.is()) + static ::rtl::OUString s_sProviderServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); + return s_sProviderServiceName; + } + + //-------------------------------------------------------------------- + Reference< XMultiServiceFactory > lcl_getConfigProvider( const ::comphelper::ComponentContext& i_rContext ) + { + try { - try - { - sCompletePath = xNodeNameAccess->getHierarchicalName(); - OSL_ENSURE(sCompletePath.getLength(), "OConfigurationNode::cloneAsRoot: invalid path retrieved!"); - } - catch(Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } + Reference< XMultiServiceFactory > xProvider( i_rContext.createComponent( lcl_getProviderServiceName() ), UNO_QUERY_THROW ); + return xProvider; } - - // then create a new tree root object with that path and our provider - OSL_ENSURE(m_xProvider.is(), "OConfigurationNode::cloneAsRoot: have an invalid provider!"); - if (sCompletePath.getLength() && m_xProvider.is()) + catch ( const Exception& ) { - return OConfigurationTreeRoot::createWithProvider(m_xProvider, sCompletePath, -1, isReadonly() ? OConfigurationTreeRoot::CM_READONLY : OConfigurationTreeRoot::CM_PREFER_UPDATABLE); + DBG_UNHANDLED_EXCEPTION(); } + return NULL; } - return OConfigurationTreeRoot(); - } - //------------------------------------------------------------------------ - void OConfigurationNode::clear() throw() - { - m_xHierarchyAccess.clear(); - m_xDirectAccess.clear(); - m_xReplaceAccess.clear(); - m_xContainerAccess.clear(); + //-------------------------------------------------------------------- + Reference< XInterface > lcl_createConfigurationRoot( const Reference< XMultiServiceFactory >& i_rxConfigProvider, + const ::rtl::OUString& i_rNodePath, const bool i_bUpdatable, const sal_Int32 i_nDepth, const bool i_bLazyWrite ) + { + ENSURE_OR_RETURN( i_rxConfigProvider.is(), "invalid provider", NULL ); + try + { + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "nodepath", i_rNodePath ); + aArgs.put( "lazywrite", i_bLazyWrite ); + aArgs.put( "depth", i_nDepth ); + + ::rtl::OUString sAccessService = ::rtl::OUString::createFromAscii( + i_bUpdatable + ? "com.sun.star.configuration.ConfigurationUpdateAccess" + : "com.sun.star.configuration.ConfigurationAccess" ); + + Reference< XInterface > xRoot( + i_rxConfigProvider->createInstanceWithArguments( sAccessService, aArgs.getWrappedPropertyValues() ), + UNO_SET_THROW + ); + return xRoot; + } + catch ( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return NULL; + } } - //======================================================================== //= OConfigurationTreeRoot //======================================================================== //------------------------------------------------------------------------ - OConfigurationTreeRoot::OConfigurationTreeRoot(const Reference< XChangesBatch >& _rxRootNode, const Reference< XMultiServiceFactory >& _rxProvider) - :OConfigurationNode(_rxRootNode.get(), _rxProvider) + OConfigurationTreeRoot::OConfigurationTreeRoot( const Reference< XChangesBatch >& _rxRootNode ) + :OConfigurationNode( _rxRootNode.get() ) ,m_xCommitter(_rxRootNode) { } //------------------------------------------------------------------------ - OConfigurationTreeRoot::OConfigurationTreeRoot(const Reference< XInterface >& _rxRootNode, const Reference< XMultiServiceFactory >& _rxProvider) - :OConfigurationNode(_rxRootNode.get(), _rxProvider) + OConfigurationTreeRoot::OConfigurationTreeRoot( const Reference< XInterface >& _rxRootNode ) + :OConfigurationNode( _rxRootNode ) + ,m_xCommitter( _rxRootNode, UNO_QUERY ) { } //------------------------------------------------------------------------ + OConfigurationTreeRoot::OConfigurationTreeRoot( const ::comphelper::ComponentContext& i_rContext, const sal_Char* i_pAsciiNodePath, const bool i_bUpdatable ) + :OConfigurationNode( lcl_createConfigurationRoot( lcl_getConfigProvider( i_rContext.getLegacyServiceFactory() ), + ::rtl::OUString::createFromAscii( i_pAsciiNodePath ), i_bUpdatable, -1, false ).get() ) + ,m_xCommitter() + { + if ( i_bUpdatable ) + { + m_xCommitter.set( getUNONode(), UNO_QUERY ); + OSL_ENSURE( m_xCommitter.is(), "OConfigurationTreeRoot::OConfigurationTreeRoot: could not create an updatable node!" ); + } + } + + //------------------------------------------------------------------------ void OConfigurationTreeRoot::clear() throw() { OConfigurationNode::clear(); @@ -555,117 +593,20 @@ namespace utl return sal_False; } - namespace - { - static const ::rtl::OUString& lcl_getProviderServiceName( ) - { - static ::rtl::OUString s_sProviderServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); - return s_sProviderServiceName; - } - } - //------------------------------------------------------------------------ OConfigurationTreeRoot OConfigurationTreeRoot::createWithProvider(const Reference< XMultiServiceFactory >& _rxConfProvider, const ::rtl::OUString& _rPath, sal_Int32 _nDepth, CREATION_MODE _eMode, sal_Bool _bLazyWrite) { - OSL_ENSURE(_rxConfProvider.is(), "OConfigurationTreeRoot::createWithProvider: invalid provider!"); - -#ifdef DBG_UTIL - if (_rxConfProvider.is()) - { - try - { - Reference< XServiceInfo > xSI(_rxConfProvider, UNO_QUERY); - if (!xSI.is()) - { - OSL_ENSURE(sal_False, "OConfigurationTreeRoot::createWithProvider: no XServiceInfo interface on the provider!"); - } - else - { - OSL_ENSURE(xSI->supportsService( lcl_getProviderServiceName( ) ), - "OConfigurationTreeRoot::createWithProvider: sure this is a provider? Missing the ConfigurationProvider service!"); - } - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } - } -#endif - - sal_Bool bTryAgain(sal_False); - do - { - if (_rxConfProvider.is()) - { - try - { - Sequence< Any > aCreationArgs(3); - aCreationArgs[0] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), 0, makeAny(_rPath), PropertyState_DIRECT_VALUE)); - aCreationArgs[1] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), 0, makeAny((sal_Int32)_nDepth), PropertyState_DIRECT_VALUE)); - aCreationArgs[2] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), 0, ::cppu::bool2any(_bLazyWrite), PropertyState_DIRECT_VALUE)); - - ::rtl::OUString sAccessService = ::rtl::OUString::createFromAscii(CM_READONLY == _eMode - ? "com.sun.star.configuration.ConfigurationAccess" - : "com.sun.star.configuration.ConfigurationUpdateAccess"); - - Reference< XInterface > xRoot = _rxConfProvider->createInstanceWithArguments(sAccessService, aCreationArgs); - if (!xRoot.is()) - { - OSL_ENSURE(sal_False, "OConfigurationTreeRoot::createWithProvider: could not create the node access!"); - } - else if (CM_READONLY == _eMode) - { - return OConfigurationTreeRoot(xRoot, _rxConfProvider); - } - else - { // get the changes batch interface - Reference< XChangesBatch > xCommitter(xRoot, UNO_QUERY); - if (xCommitter.is()) - return OConfigurationTreeRoot(xCommitter, _rxConfProvider); - else - OSL_ENSURE(sal_False, "OConfigurationTreeRoot::createWithProvider: invalid root object (missing interface XChangesBatch)!"); - - // dispose the object if it is already created, but unusable - Reference< XComponent > xComp(xRoot, UNO_QUERY); - if (xComp.is()) - try { xComp->dispose(); } catch(Exception&) { } - } - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - bTryAgain = CM_PREFER_UPDATABLE == _eMode; - if (bTryAgain) - _eMode = CM_READONLY; - } - while (bTryAgain); - + Reference< XInterface > xRoot( lcl_createConfigurationRoot( + _rxConfProvider, _rPath, _eMode != CM_READONLY, _nDepth, _bLazyWrite ) ); + if ( xRoot.is() ) + return OConfigurationTreeRoot( xRoot ); return OConfigurationTreeRoot(); } //------------------------------------------------------------------------ - OConfigurationTreeRoot OConfigurationTreeRoot::createWithServiceFactory(const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rPath, sal_Int32 _nDepth, CREATION_MODE _eMode, sal_Bool _bLazyWrite) + OConfigurationTreeRoot OConfigurationTreeRoot::createWithServiceFactory( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rPath, sal_Int32 _nDepth, CREATION_MODE _eMode, sal_Bool _bLazyWrite ) { - OSL_ENSURE(_rxORB.is(), "OConfigurationTreeRoot::createWithServiceFactory: invalid service factory!"); - if (_rxORB.is()) - { - try - { - Reference< XInterface > xProvider = _rxORB->createInstance( lcl_getProviderServiceName( ) ); - OSL_ENSURE(xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: could not instantiate the config provider service!"); - Reference< XMultiServiceFactory > xProviderAsFac(xProvider, UNO_QUERY); - OSL_ENSURE(xProviderAsFac.is() || !xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: the provider is missing an interface!"); - if (xProviderAsFac.is()) - return createWithProvider(xProviderAsFac, _rPath, _nDepth, _eMode, _bLazyWrite); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - return OConfigurationTreeRoot(); + return createWithProvider( lcl_getConfigProvider( _rxORB ), _rPath, _nDepth, _eMode, _bLazyWrite ); } //------------------------------------------------------------------------ @@ -681,9 +622,9 @@ namespace utl if ( xConfigFactory.is() ) return createWithProvider( xConfigFactory, _rPath, _nDepth, _eMode, _bLazyWrite ); } - catch(Exception&) + catch(const Exception&) { - // silent this, 'cause the contract of this method states "no assertions" + // silence this, 'cause the contract of this method states "no assertions" } } return OConfigurationTreeRoot(); diff --git a/unotools/source/config/configvaluecontainer.cxx b/unotools/source/config/configvaluecontainer.cxx index c04f29428bf5..653305f92f74 100644 --- a/unotools/source/config/configvaluecontainer.cxx +++ b/unotools/source/config/configvaluecontainer.cxx @@ -331,7 +331,7 @@ namespace utl m_pImpl->xORB, _rConfigLocation, _nLevels, - ( _nAccessFlags & CVC_UPDATE_ACCESS ) ? OConfigurationTreeRoot::CM_PREFER_UPDATABLE : OConfigurationTreeRoot::CM_READONLY, + ( _nAccessFlags & CVC_UPDATE_ACCESS ) ? OConfigurationTreeRoot::CM_UPDATABLE : OConfigurationTreeRoot::CM_READONLY, ( _nAccessFlags & CVC_IMMEDIATE_UPDATE ) ? sal_False : sal_True ); #ifdef DBG_UTIL diff --git a/vcl/aqua/inc/salgdi.h b/vcl/aqua/inc/salgdi.h index d83067cb64b8..247de1b95dec 100644 --- a/vcl/aqua/inc/salgdi.h +++ b/vcl/aqua/inc/salgdi.h @@ -230,15 +230,15 @@ public: CGPoint* makeCGptArray(ULONG nPoints, const SalPoint* pPtAry); // native widget rendering methods that require mirroring virtual BOOL hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside ); + const Point& aPos, BOOL& rIsInside ); virtual BOOL drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, const rtl::OUString& aCaption ); virtual BOOL drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption ); + const rtl::OUString& aCaption ); virtual BOOL getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& aCaption, + const ImplControlValue& aValue, const rtl::OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ); // get device resolution diff --git a/vcl/aqua/source/gdi/salnativewidgets.cxx b/vcl/aqua/source/gdi/salnativewidgets.cxx index b4b843eaca58..5eccf88dc523 100644 --- a/vcl/aqua/source/gdi/salnativewidgets.cxx +++ b/vcl/aqua/source/gdi/salnativewidgets.cxx @@ -380,7 +380,7 @@ BOOL AquaSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart n * nType/nPart combination. */ BOOL AquaSalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - const Point& rPos, SalControlHandle& rControlHandle, BOOL& rIsInside ) + const Point& rPos, BOOL& rIsInside ) { if ( nType == CTRL_SCROLLBAR ) { @@ -468,7 +468,6 @@ UInt32 AquaSalGraphics::getTrackState( ControlState nState ) * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the AquaSalGraphics implementation. * aCaption: A caption or title string (like button text etc) */ BOOL AquaSalGraphics::drawNativeControl(ControlType nType, @@ -476,7 +475,6 @@ BOOL AquaSalGraphics::drawNativeControl(ControlType nType, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption ) { BOOL bOK = FALSE; @@ -1226,12 +1224,11 @@ BOOL AquaSalGraphics::drawNativeControl(ControlType nType, * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the AquaSalGraphics implementation. * aCaption: A caption or title string (like button text etc) */ BOOL AquaSalGraphics::drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption ) + const rtl::OUString& aCaption ) { return( FALSE ); } @@ -1248,11 +1245,10 @@ BOOL AquaSalGraphics::drawNativeControlText( ControlType nType, ControlPart nPar * * rControlRegion: The bounding region of the control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the AquaSalGraphics implementation. * aCaption: A caption or title string (like button text etc) */ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& aCaption, + const ImplControlValue& aValue, const rtl::OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ) { diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index 70c1e6aa624d..9b748f2b5937 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -39,6 +39,7 @@ #include <vcl/mapmod.hxx> #include <vcl/wall.hxx> #include <vcl/settings.hxx> +#include <vcl/salnativewidgets.hxx> #include <tools/poly.hxx> #include <basegfx/vector/b2enums.hxx> #include <com/sun/star/uno/Reference.h> @@ -1177,6 +1178,49 @@ public: BitmapEx GetDownsampledBitmapEx( const Size& rDstSz, const Point& rSrcPt, const Size& rSrcSz, const BitmapEx& rBmpEx, long nMaxBmpDPIX, long nMaxBmpDPIY ); + + //------------------------------------- + // Native Widget Rendering functions + //------------------------------------- + + // These all just call through to the private mpGraphics functions of the same name. + + // Query the platform layer for control support + BOOL IsNativeControlSupported( ControlType nType, ControlPart nPart ); + + // Query the native control to determine if it was acted upon + BOOL HitTestNativeControl( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + const Point& aPos, + BOOL& rIsInside ); + + // Request rendering of a particular control and/or part + BOOL DrawNativeControl( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption ); + + // Request rendering of a caption string for a control + BOOL DrawNativeControlText( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption ); + + // Query the native control's actual drawing region (including adornment) + BOOL GetNativeControlRegion( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption, + Region &rNativeBoundingRegion, + Region &rNativeContentRegion ); + }; #endif // _SV_OUTDEV_HXX diff --git a/vcl/inc/vcl/salgdi.hxx b/vcl/inc/vcl/salgdi.hxx index 02e9efbc0f94..510e797678b0 100644 --- a/vcl/inc/vcl/salgdi.hxx +++ b/vcl/inc/vcl/salgdi.hxx @@ -159,15 +159,15 @@ protected: // native widget rendering methods that require mirroring virtual BOOL hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside ); + const Point& aPos, BOOL& rIsInside ); virtual BOOL drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, const rtl::OUString& aCaption ); virtual BOOL drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption ); + const rtl::OUString& aCaption ); virtual BOOL getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& aCaption, + const ImplControlValue& aValue, const rtl::OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ); /** Render bitmap with alpha channel @@ -442,7 +442,6 @@ public: ControlPart nPart, const Region& rControlRegion, const Point& aPos, - SalControlHandle& rControlHandle, BOOL& rIsInside, const OutputDevice *pOutDev ); @@ -452,7 +451,6 @@ public: const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption, const OutputDevice *pOutDev ); @@ -462,7 +460,6 @@ public: const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption, const OutputDevice *pOutDev ); @@ -472,7 +469,6 @@ public: const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion, diff --git a/vcl/inc/vcl/window.h b/vcl/inc/vcl/window.h index 9d917a09b6de..691c3ed18421 100644 --- a/vcl/inc/vcl/window.h +++ b/vcl/inc/vcl/window.h @@ -56,7 +56,6 @@ class VirtualDevice; class Cursor; class ImplDevFontList; class ImplFontCache; -class SalControlHandle; class SmartId; class VCLXWindow; class SalFrame; @@ -120,7 +119,6 @@ struct ImplWinData USHORT mnTrackFlags; USHORT mnIsTopWindow; BOOL mbMouseOver; // tracks mouse over for native widget paint effect - SalControlHandle* mpSalControlHandle; // native data for NWF BOOL mbEnableNativeWidget; // toggle native widget rendering SmartId* mpSmartHelpId; SmartId* mpSmartUniqueId; diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx index 3d1cc91ee468..d8c429ef64d2 100644 --- a/vcl/inc/vcl/window.hxx +++ b/vcl/inc/vcl/window.hxx @@ -548,20 +548,18 @@ public: SAL_DLLPRIVATE ::std::vector<Window *>& ImplGetOwnerDrawList(); SAL_DLLPRIVATE Window* ImplGetTopmostFrameWindow(); - SAL_DLLPRIVATE Rectangle ImplGetWindowExtentsRelative( Window *pRelativeWindow, BOOL bClientOnly ); + SAL_DLLPRIVATE Rectangle ImplGetWindowExtentsRelative( Window *pRelativeWindow, BOOL bClientOnly ) const; SAL_DLLPRIVATE void ImplNotifyIconifiedState( BOOL bIconified ); SAL_DLLPRIVATE bool ImplStopDnd(); SAL_DLLPRIVATE void ImplStartDnd(); SAL_DLLPRIVATE static void ImplInitAppFontData( Window* pWindow ); - SAL_DLLPRIVATE void ImplInitSalControlHandle(); SAL_DLLPRIVATE void ImplPaintToDevice( OutputDevice* pTargetOutDev, const Point& rPos ); SAL_DLLPRIVATE BOOL ImplIsInTaskPaneList(); SAL_DLLPRIVATE void ImplIsInTaskPaneList( BOOL mbIsInTaskList ); SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > ImplGetCanvas( const Size& rFullscreenSize, bool bFullscreen, bool bSpriteCanvas ) const; - SAL_DLLPRIVATE void ImplMoveControlValue( ControlType, const ImplControlValue&, const Point& ) const; private: // Default construction is forbidden and not implemented. @@ -856,9 +854,9 @@ public: Point AbsoluteScreenToOutputPixel( const Point& rPos ) const; Rectangle GetDesktopRectPixel() const; // window extents including border and decoratrion - Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ); + Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; // window extents of the client window, coordinates to be used in SetPosPixel - Rectangle GetClientWindowExtentsRelative( Window *pRelativeWindow ); + Rectangle GetClientWindowExtentsRelative( Window *pRelativeWindow ) const; virtual BOOL IsScrollable() const; virtual void Scroll( long nHorzScroll, long nVertScroll, @@ -1092,44 +1090,6 @@ public: void EnableNativeWidget( BOOL bEnable = TRUE ); BOOL IsNativeWidgetEnabled() const; - // These all just call through to the private mpWindowImpl->mpFrame functions of the same name. - - // Query the platform layer for control support - BOOL IsNativeControlSupported( ControlType nType, ControlPart nPart ); - - // Query the native control to determine if it was acted upon - BOOL HitTestNativeControl( ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - const Point& aPos, - BOOL& rIsInside ); - - // Request rendering of a particular control and/or part - BOOL DrawNativeControl( ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - ControlState nState, - const ImplControlValue& aValue, - rtl::OUString aCaption ); - - // Request rendering of a caption string for a control - BOOL DrawNativeControlText( ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - ControlState nState, - const ImplControlValue& aValue, - rtl::OUString aCaption ); - - // Query the native control's actual drawing region (including adornment) - BOOL GetNativeControlRegion( ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - ControlState nState, - const ImplControlValue& aValue, - rtl::OUString aCaption, - Region &rNativeBoundingRegion, - Region &rNativeContentRegion ); - // a helper method for a Control's Draw method void PaintToDevice( OutputDevice* pDevice, const Point& rPos, const Size& rSize ); diff --git a/vcl/os2/inc/salgdi.h b/vcl/os2/inc/salgdi.h index ce486084a5b1..b8dc4eba0199 100644 --- a/vcl/os2/inc/salgdi.h +++ b/vcl/os2/inc/salgdi.h @@ -197,15 +197,15 @@ protected: #if 0 // native widget rendering methods that require mirroring virtual BOOL hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside ); + const Point& aPos, BOOL& rIsInside ); virtual BOOL drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, rtl::OUString aCaption ); virtual BOOL drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, rtl::OUString aCaption ); + rtl::OUString aCaption ); virtual BOOL getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, rtl::OUString aCaption, + const ImplControlValue& aValue, rtl::OUString aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ); #endif diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 741267044829..b97afd720785 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -408,6 +408,9 @@ Size TabControl::ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth ) if( aImageSize.Height() > aSize.Height() ) aSize.Height() = aImageSize.Height(); + aSize.Width() += TAB_TABOFFSET_X*2; + aSize.Height() += TAB_TABOFFSET_Y*2; + Region aCtrlRegion( Rectangle( (const Point&)Point( 0, 0 ), aSize ) ); Region aBoundingRgn, aContentRgn; const ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); @@ -419,8 +422,6 @@ Size TabControl::ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth ) return aCont.GetSize(); } - aSize.Width() += TAB_TABOFFSET_X*2; - aSize.Height() += TAB_TABOFFSET_Y*2; // For systems without synthetic bold support if ( mbExtraSpace ) aSize.Width() += TAB_EXTRASPACE_X; diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx index e3f63a03d081..e79308b2664e 100644 --- a/vcl/source/gdi/image.cxx +++ b/vcl/source/gdi/image.cxx @@ -50,6 +50,10 @@ #include <vcl/image.h> #include <vcl/image.hxx> +#if OSL_DEBUG_LEVEL > 0 +#include <rtl/strbuf.hxx> +#endif + DBG_NAME( Image ) DBG_NAME( ImageList ) @@ -543,11 +547,19 @@ void ImageAryData::Load(const rtl::OUString &rPrefix) rtl::OUString aFileName = rPrefix; aFileName += maName; -#ifdef DBG_UTIL - bool bSuccess = aImageTree->loadImage( aFileName, aSymbolsStyle, maBitmapEx, true ); - DBG_ASSERT (bSuccess, "ImageAryData::Failed to load image"); -#else - aImageTree->loadImage( aFileName, aSymbolsStyle, maBitmapEx, true ); +#if OSL_DEBUG_LEVEL > 0 + bool bSuccess = +#endif + aImageTree->loadImage( aFileName, aSymbolsStyle, maBitmapEx, true ); +#if OSL_DEBUG_LEVEL > 0 + if ( !bSuccess ) + { + ::rtl::OStringBuffer aMessage; + aMessage.append( "ImageAryData::Load: failed to load image '" ); + aMessage.append( ::rtl::OUStringToOString( aFileName, RTL_TEXTENCODING_UTF8 ).getStr() ); + aMessage.append( "'" ); + OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + } #endif } diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index 75f2b3fffc64..f069828f25f9 100644 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -106,6 +106,7 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/outdev4.obj \ $(SLO)$/outdev5.obj \ $(SLO)$/outdev6.obj \ + $(SLO)$/outdevnative.obj \ $(SLO)$/regband.obj \ $(SLO)$/region.obj \ $(SLO)$/wall.obj \ diff --git a/vcl/source/gdi/outdevnative.cxx b/vcl/source/gdi/outdevnative.cxx new file mode 100644 index 000000000000..fed41ec4de85 --- /dev/null +++ b/vcl/source/gdi/outdevnative.cxx @@ -0,0 +1,290 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_vcl.hxx" + +#include "vcl/outdev.hxx" +#include "vcl/window.hxx" +#include "vcl/salgdi.hxx" +#include "vcl/salnativewidgets.hxx" +#include "vcl/pdfextoutdevdata.hxx" + +// ----------------------------------------------------------------------- + +static bool lcl_enableNativeWidget( const OutputDevice& i_rDevice ) +{ + const OutDevType eType( i_rDevice.GetOutDevType() ); + switch ( eType ) + { + + case OUTDEV_WINDOW: + return dynamic_cast< const Window* >( &i_rDevice )->IsNativeWidgetEnabled(); + + case OUTDEV_VIRDEV: + { + const ::vcl::ExtOutDevData* pOutDevData( i_rDevice.GetExtOutDevData() ); + const ::vcl::PDFExtOutDevData* pPDFData( dynamic_cast< const ::vcl::PDFExtOutDevData* >( pOutDevData ) ); + if ( pPDFData != NULL ) + return false; + return true; + } + + default: + return false; + } +} + +// ----------------------------------------------------------------------- +// These functions are mainly passthrough functions that allow access to +// the SalFrame behind a Window object for native widget rendering purposes. +// ----------------------------------------------------------------------- + +// ----------------------------------------------------------------------- + +BOOL OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart nPart ) +{ + if( !lcl_enableNativeWidget( *this ) ) + return FALSE; + + if ( !mpGraphics ) + if ( !ImplGetGraphics() ) + return FALSE; + + return( mpGraphics->IsNativeControlSupported(nType, nPart) ); +} + + +// ----------------------------------------------------------------------- + +BOOL OutputDevice::HitTestNativeControl( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + const Point& aPos, + BOOL& rIsInside ) +{ + if( !lcl_enableNativeWidget( *this ) ) + return FALSE; + + if ( !mpGraphics ) + if ( !ImplGetGraphics() ) + return FALSE; + + Point aWinOffs( mnOutOffX, mnOutOffY ); + Region screenRegion( rControlRegion ); + screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); + + return( mpGraphics->HitTestNativeControl(nType, nPart, screenRegion, Point( aPos.X() + mnOutOffX, aPos.Y() + mnOutOffY ), + rIsInside, this ) ); +} + +// ----------------------------------------------------------------------- + +static void lcl_moveControlValue( ControlType nType, const ImplControlValue& aValue, const Point& rDelta ) +{ + if( aValue.getOptionalVal() ) + { + switch( nType ) + { + case CTRL_SLIDER: + { + SliderValue* pSlVal = reinterpret_cast<SliderValue*>(aValue.getOptionalVal()); + pSlVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); + } + break; + case CTRL_SCROLLBAR: + { + ScrollbarValue* pScVal = reinterpret_cast<ScrollbarValue*>(aValue.getOptionalVal()); + pScVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); + pScVal->maButton1Rect.Move( rDelta.X(), rDelta.Y() ); + pScVal->maButton2Rect.Move( rDelta.X(), rDelta.Y() ); + } + break; + case CTRL_SPINBOX: + case CTRL_SPINBUTTONS: + { + SpinbuttonValue* pSpVal = reinterpret_cast<SpinbuttonValue*>(aValue.getOptionalVal()); + pSpVal->maUpperRect.Move( rDelta.X(), rDelta.Y() ); + pSpVal->maLowerRect.Move( rDelta.X(), rDelta.Y() ); + } + break; + case CTRL_TOOLBAR: + { + ToolbarValue* pTVal = reinterpret_cast<ToolbarValue*>(aValue.getOptionalVal()); + pTVal->maGripRect.Move( rDelta.X(), rDelta.Y() ); + } + break; + } + } +} + +BOOL OutputDevice::DrawNativeControl( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption ) +{ + if( !lcl_enableNativeWidget( *this ) ) + return FALSE; + + /* + if( !IsInPaint() && IsPaintTransparent() ) + { + // only required if called directly (ie, we're not in Paint() ): + // force redraw (Paint()) for transparent controls + // to trigger a repaint of the background + Region aClipRgn( GetClipRegion() ); + if( !rControlRegion.IsEmpty() ) + aClipRgn.Intersect( rControlRegion ); + Invalidate( aClipRgn, INVALIDATE_UPDATE ); + return TRUE; + } + */ + + // make sure the current clip region is initialized correctly + if ( !mpGraphics ) + if ( !ImplGetGraphics() ) + return FALSE; + + if ( mbInitClipRegion ) + ImplInitClipRegion(); + if ( mbOutputClipped ) + return TRUE; + + if ( mbInitLineColor ) + ImplInitLineColor(); + if ( mbInitFillColor ) + ImplInitFillColor(); + + // Convert the coordinates from relative to Window-absolute, so we draw + // in the correct place in platform code + Point aWinOffs( mnOutOffX, mnOutOffY ); + Region screenRegion( rControlRegion ); + screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); + + // do so for ImplControlValue members, also + lcl_moveControlValue( nType, aValue, aWinOffs ); + + Region aTestRegion( GetActiveClipRegion() ); + aTestRegion.Intersect( rControlRegion ); + if( aTestRegion == rControlRegion ) + nState |= CTRL_CACHING_ALLOWED; // control is not clipped, caching allowed + + BOOL bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, aValue, aCaption, this ); + + // transform back ImplControlValue members + lcl_moveControlValue( nType, aValue, Point()-aWinOffs ); + + return bRet; +} + + +// ----------------------------------------------------------------------- + +BOOL OutputDevice::DrawNativeControlText(ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption ) +{ + if( !lcl_enableNativeWidget( *this ) ) + return FALSE; + + // make sure the current clip region is initialized correctly + if ( !mpGraphics ) + if ( !ImplGetGraphics() ) + return false; + + if ( mbInitClipRegion ) + ImplInitClipRegion(); + if ( mbOutputClipped ) + return true; + + if ( mbInitLineColor ) + ImplInitLineColor(); + if ( mbInitFillColor ) + ImplInitFillColor(); + + // Convert the coordinates from relative to Window-absolute, so we draw + // in the correct place in platform code + Point aWinOffs( mnOutOffX, mnOutOffY ); + Region screenRegion( rControlRegion ); + screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); + lcl_moveControlValue( nType, aValue, aWinOffs ); + + BOOL bRet = mpGraphics->DrawNativeControlText(nType, nPart, screenRegion, nState, aValue, aCaption, this ); + + // transform back ImplControlValue members + lcl_moveControlValue( nType, aValue, Point()-aWinOffs ); + + return bRet; +} + + +// ----------------------------------------------------------------------- + +BOOL OutputDevice::GetNativeControlRegion( ControlType nType, + ControlPart nPart, + const Region& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption, + Region &rNativeBoundingRegion, + Region &rNativeContentRegion ) +{ + if( !lcl_enableNativeWidget( *this ) ) + return FALSE; + + if ( !mpGraphics ) + if ( !ImplGetGraphics() ) + return FALSE; + + // Convert the coordinates from relative to Window-absolute, so we draw + // in the correct place in platform code + Point aWinOffs( mnOutOffX, mnOutOffY ); + Region screenRegion( rControlRegion ); + screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); + lcl_moveControlValue( nType, aValue, aWinOffs ); + + BOOL bRet = mpGraphics->GetNativeControlRegion(nType, nPart, screenRegion, nState, aValue, + aCaption, rNativeBoundingRegion, + rNativeContentRegion, this ); + if( bRet ) + { + // transform back native regions + rNativeBoundingRegion.Move( -aWinOffs.X(), -aWinOffs.Y() ); + rNativeContentRegion.Move( -aWinOffs.X(), -aWinOffs.Y() ); + } + // transform back ImplControlValue members + lcl_moveControlValue( nType, aValue, Point()-aWinOffs ); + + return bRet; +} + + diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 55d6f7bdd892..84e45979d679 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -669,7 +669,7 @@ BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* } BOOL SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside, const OutputDevice *pOutDev ) + const Point& aPos, BOOL& rIsInside, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) { @@ -677,10 +677,10 @@ BOOL SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, co Region rgn( rControlRegion ); mirror( pt.X(), pOutDev ); mirror( rgn, pOutDev ); - return hitTestNativeControl( nType, nPart, rgn, pt, rControlHandle, rIsInside ); + return hitTestNativeControl( nType, nPart, rgn, pt, rIsInside ); } else - return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rControlHandle, rIsInside ); + return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rIsInside ); } void SalGraphics::mirror( ControlType nType, const ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const @@ -722,7 +722,7 @@ void SalGraphics::mirror( ControlType nType, const ImplControlValue& rVal, const } BOOL SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, const OUString& aCaption, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) @@ -730,33 +730,33 @@ BOOL SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Region rgn( rControlRegion ); mirror( rgn, pOutDev ); mirror( nType, aValue, pOutDev ); - BOOL bRet = drawNativeControl( nType, nPart, rgn, nState, aValue, rControlHandle, aCaption ); + BOOL bRet = drawNativeControl( nType, nPart, rgn, nState, aValue, aCaption ); mirror( nType, aValue, pOutDev, true ); return bRet; } else - return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, rControlHandle, aCaption ); + return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, aCaption ); } BOOL SalGraphics::DrawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& aCaption, const OutputDevice *pOutDev ) + const OUString& aCaption, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) { Region rgn( rControlRegion ); mirror( rgn, pOutDev ); mirror( nType, aValue, pOutDev ); - BOOL bRet = drawNativeControlText( nType, nPart, rgn, nState, aValue, rControlHandle, aCaption ); + BOOL bRet = drawNativeControlText( nType, nPart, rgn, nState, aValue, aCaption ); mirror( nType, aValue, pOutDev, true ); return bRet; } else - return drawNativeControlText( nType, nPart, rControlRegion, nState, aValue, rControlHandle, aCaption ); + return drawNativeControlText( nType, nPart, rControlRegion, nState, aValue, aCaption ); } BOOL SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& aCaption, + const ImplControlValue& aValue, const OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion, const OutputDevice *pOutDev ) { if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) @@ -764,7 +764,7 @@ BOOL SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, Region rgn( rControlRegion ); mirror( rgn, pOutDev ); mirror( nType, aValue, pOutDev ); - if( getNativeControlRegion( nType, nPart, rgn, nState, aValue, rControlHandle, aCaption, + if( getNativeControlRegion( nType, nPart, rgn, nState, aValue, aCaption, rNativeBoundingRegion, rNativeContentRegion ) ) { mirror( rNativeBoundingRegion, pOutDev, true ); @@ -779,7 +779,7 @@ BOOL SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, } } else - return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, rControlHandle, aCaption, + return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, aCaption, rNativeBoundingRegion, rNativeContentRegion ); } diff --git a/vcl/source/gdi/salnativewidgets-none.cxx b/vcl/source/gdi/salnativewidgets-none.cxx index 8b87f142ba25..7faf12d062fe 100644 --- a/vcl/source/gdi/salnativewidgets-none.cxx +++ b/vcl/source/gdi/salnativewidgets-none.cxx @@ -60,7 +60,6 @@ BOOL SalGraphics::hitTestNativeControl( ControlType, ControlPart, const Region&, const Point&, - SalControlHandle&, BOOL& ) { return( FALSE ); @@ -74,7 +73,6 @@ BOOL SalGraphics::hitTestNativeControl( ControlType, * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the SalFrame implementation. * aCaption: A caption or title string (like button text etc) */ BOOL SalGraphics::drawNativeControl( ControlType, @@ -82,7 +80,6 @@ BOOL SalGraphics::drawNativeControl( ControlType, const Region&, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { return( FALSE ); @@ -97,7 +94,6 @@ BOOL SalGraphics::drawNativeControl( ControlType, * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the SalFrame implementation. * aCaption: A caption or title string (like button text etc) */ BOOL SalGraphics::drawNativeControlText( ControlType, @@ -105,7 +101,6 @@ BOOL SalGraphics::drawNativeControlText( ControlType, const Region&, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { return( FALSE ); @@ -123,7 +118,6 @@ BOOL SalGraphics::drawNativeControlText( ControlType, * * rControlRegion: The bounding region of the control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the SalFrame implementation. * aCaption: A caption or title string (like button text etc) */ BOOL SalGraphics::getNativeControlRegion( ControlType, @@ -131,7 +125,6 @@ BOOL SalGraphics::getNativeControlRegion( ControlType, const Region&, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString&, Region &, Region & ) diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 8906edaa5046..aadef164282b 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -98,6 +98,7 @@ #include "vcl/lazydelete.hxx" #include <set> +#include <typeinfo> using namespace rtl; using namespace ::com::sun::star::uno; @@ -1322,7 +1323,6 @@ ImplWinData* Window::ImplGetWinData() const mpWindowImpl->mpWinData->mnIsTopWindow = (USHORT) ~0; // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) mpWindowImpl->mpWinData->mbMouseOver = FALSE; mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? FALSE : TRUE; // TRUE: try to draw this control with native theme API - mpWindowImpl->mpWinData->mpSalControlHandle = NULL; mpWindowImpl->mpWinData->mpSmartHelpId = NULL; mpWindowImpl->mpWinData->mpSmartUniqueId = NULL; } @@ -4328,6 +4328,27 @@ Window::Window( Window* pParent, const ResId& rResId ) } // ----------------------------------------------------------------------- +#if OSL_DEBUG_LEVEL > 0 +namespace +{ + void lcl_appendWindowInfo( ByteString& io_rErrorString, const Window& i_rWindow ) + { + // skip border windows, they don't carry information which helps diagnosing the problem + const Window* pWindow( &i_rWindow ); + while ( pWindow && ( pWindow->GetType() == WINDOW_BORDERWINDOW ) ) + pWindow = pWindow->GetWindow( WINDOW_FIRSTCHILD ); + if ( !pWindow ) + pWindow = &i_rWindow; + + io_rErrorString += char(13); + io_rErrorString += typeid( *pWindow ).name(); + io_rErrorString += " (window text: '"; + io_rErrorString += ByteString( pWindow->GetText(), RTL_TEXTENCODING_UTF8 ); + io_rErrorString += "')"; + } +} +#endif +// ----------------------------------------------------------------------- Window::~Window() { @@ -4460,9 +4481,7 @@ Window::~Window() if ( ImplIsRealParentPath( pTempWin ) ) { bError = TRUE; - if ( aErrorStr.Len() ) - aErrorStr += "; "; - aErrorStr += ByteString( pTempWin->GetText(), RTL_TEXTENCODING_UTF8 ); + lcl_appendWindowInfo( aErrorStr, *pTempWin ); } pTempWin = pTempWin->mpWindowImpl->mpNextOverlap; } @@ -4483,9 +4502,7 @@ Window::~Window() if ( ImplIsRealParentPath( pTempWin ) ) { bError = TRUE; - if ( aErrorStr.Len() ) - aErrorStr += "; "; - aErrorStr += ByteString( pTempWin->GetText(), RTL_TEXTENCODING_UTF8 ); + lcl_appendWindowInfo( aErrorStr, *pTempWin ); } pTempWin = pTempWin->mpWindowImpl->mpFrameData->mpNextFrame; } @@ -4507,10 +4524,8 @@ Window::~Window() pTempWin = mpWindowImpl->mpFirstChild; while ( pTempWin ) { - aTempStr += ByteString( pTempWin->GetText(), RTL_TEXTENCODING_UTF8 ); + lcl_appendWindowInfo( aTempStr, *pTempWin ); pTempWin = pTempWin->mpWindowImpl->mpNext; - if ( pTempWin ) - aTempStr += "; "; } DBG_ERROR( aTempStr.GetBuffer() ); GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! @@ -4524,10 +4539,8 @@ Window::~Window() pTempWin = mpWindowImpl->mpFirstOverlap; while ( pTempWin ) { - aTempStr += ByteString( pTempWin->GetText(), RTL_TEXTENCODING_UTF8 ); + lcl_appendWindowInfo( aTempStr, *pTempWin ); pTempWin = pTempWin->mpWindowImpl->mpNext; - if ( pTempWin ) - aTempStr += "; "; } DBG_ERROR( aTempStr.GetBuffer() ); GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! @@ -4722,10 +4735,6 @@ Window::~Window() delete mpWindowImpl->mpWinData->mpFocusRect; if ( mpWindowImpl->mpWinData->mpTrackRect ) delete mpWindowImpl->mpWinData->mpTrackRect; - // Native widget support - delete mpWindowImpl->mpWinData->mpSalControlHandle; - mpWindowImpl->mpWinData->mpSalControlHandle = NULL; - if ( mpWindowImpl->mpWinData->mpSmartHelpId ) delete mpWindowImpl->mpWinData->mpSmartHelpId; if ( mpWindowImpl->mpWinData->mpSmartUniqueId ) @@ -7444,13 +7453,13 @@ Rectangle Window::ImplOutputToUnmirroredAbsoluteScreenPixel( const Rectangle &rR // ----------------------------------------------------------------------- -Rectangle Window::GetWindowExtentsRelative( Window *pRelativeWindow ) +Rectangle Window::GetWindowExtentsRelative( Window *pRelativeWindow ) const { // with decoration return ImplGetWindowExtentsRelative( pRelativeWindow, FALSE ); } -Rectangle Window::GetClientWindowExtentsRelative( Window *pRelativeWindow ) +Rectangle Window::GetClientWindowExtentsRelative( Window *pRelativeWindow ) const { // without decoration return ImplGetWindowExtentsRelative( pRelativeWindow, TRUE ); @@ -7458,12 +7467,12 @@ Rectangle Window::GetClientWindowExtentsRelative( Window *pRelativeWindow ) // ----------------------------------------------------------------------- -Rectangle Window::ImplGetWindowExtentsRelative( Window *pRelativeWindow, BOOL bClientOnly ) +Rectangle Window::ImplGetWindowExtentsRelative( Window *pRelativeWindow, BOOL bClientOnly ) const { SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry(); // make sure we use the extent of our border window, // otherwise we miss a few pixels - Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this; + const Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this; Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) ); aPos.X() += g.nX; diff --git a/vcl/source/window/window3.cxx b/vcl/source/window/window3.cxx index aecbc9c3ef0c..65019ba2a4af 100644 --- a/vcl/source/window/window3.cxx +++ b/vcl/source/window/window3.cxx @@ -28,269 +28,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#define _SV_WINDOW_CXX - -#include "svsys.h" -#include "vcl/window.h" #include "vcl/window.hxx" #include "vcl/waitobj.hxx" -#include "vcl/salgdi.hxx" -#include "vcl/salnativewidgets.hxx" -#include "vcl/salctrlhandle.hxx" -#include "rtl/ustring.hxx" #include "vcl/button.hxx" -using namespace rtl; - -// ----------------------------------------------------------------------- -// These functions are mainly passthrough functions that allow access to -// the SalFrame behind a Window object for native widget rendering purposes. -// ----------------------------------------------------------------------- - -void Window::ImplInitSalControlHandle() -{ - // create SalControlHandle on demand - // not needed for ordinary windows - // TODO: move creation to SalGraphics - //if( !ImplGetWinData()->mpSalControlHandle ) - // ImplGetWinData()->mpSalControlHandle = new SalControlHandle; -} - -// ----------------------------------------------------------------------- - -BOOL Window::IsNativeControlSupported( ControlType nType, ControlPart nPart ) -{ - if( !IsNativeWidgetEnabled() ) - return FALSE; - - if ( !mpGraphics ) - if ( !ImplGetGraphics() ) - return FALSE; - - return( mpGraphics->IsNativeControlSupported(nType, nPart) ); -} - - -// ----------------------------------------------------------------------- - -BOOL Window::HitTestNativeControl( ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - const Point& aPos, - BOOL& rIsInside ) -{ - if( !IsNativeWidgetEnabled() ) - return FALSE; - - if ( !mpGraphics ) - if ( !ImplGetGraphics() ) - return FALSE; - - ImplInitSalControlHandle(); - - Point aWinOffs; - aWinOffs = OutputToScreenPixel( aWinOffs ); - Region screenRegion( rControlRegion ); - screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); - - return( mpGraphics->HitTestNativeControl(nType, nPart, screenRegion, OutputToScreenPixel( aPos ), *ImplGetWinData()->mpSalControlHandle, rIsInside, this ) ); -} - -// ----------------------------------------------------------------------- - -void Window::ImplMoveControlValue( ControlType nType, const ImplControlValue& aValue, const Point& rDelta ) const -{ - if( aValue.getOptionalVal() ) - { - switch( nType ) - { - case CTRL_SLIDER: - { - SliderValue* pSlVal = reinterpret_cast<SliderValue*>(aValue.getOptionalVal()); - pSlVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); - } - break; - case CTRL_SCROLLBAR: - { - ScrollbarValue* pScVal = reinterpret_cast<ScrollbarValue*>(aValue.getOptionalVal()); - pScVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); - pScVal->maButton1Rect.Move( rDelta.X(), rDelta.Y() ); - pScVal->maButton2Rect.Move( rDelta.X(), rDelta.Y() ); - } - break; - case CTRL_SPINBOX: - case CTRL_SPINBUTTONS: - { - SpinbuttonValue* pSpVal = reinterpret_cast<SpinbuttonValue*>(aValue.getOptionalVal()); - pSpVal->maUpperRect.Move( rDelta.X(), rDelta.Y() ); - pSpVal->maLowerRect.Move( rDelta.X(), rDelta.Y() ); - } - break; - case CTRL_TOOLBAR: - { - ToolbarValue* pTVal = reinterpret_cast<ToolbarValue*>(aValue.getOptionalVal()); - pTVal->maGripRect.Move( rDelta.X(), rDelta.Y() ); - } - break; - } - } -} - -BOOL Window::DrawNativeControl( ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - ControlState nState, - const ImplControlValue& aValue, - OUString aCaption ) -{ - if( !IsNativeWidgetEnabled() ) - return FALSE; - - /* - if( !IsInPaint() && IsPaintTransparent() ) - { - // only required if called directly (ie, we're not in Paint() ): - // force redraw (Paint()) for transparent controls - // to trigger a repaint of the background - Region aClipRgn( GetClipRegion() ); - if( !rControlRegion.IsEmpty() ) - aClipRgn.Intersect( rControlRegion ); - Invalidate( aClipRgn, INVALIDATE_UPDATE ); - return TRUE; - } - */ - - ImplInitSalControlHandle(); - - // make sure the current clip region is initialized correctly - if ( !mpGraphics ) - if ( !ImplGetGraphics() ) - return FALSE; - - if ( mbInitClipRegion ) - ImplInitClipRegion(); - if ( mbOutputClipped ) - return TRUE; - - if ( mbInitLineColor ) - ImplInitLineColor(); - if ( mbInitFillColor ) - ImplInitFillColor(); - - // Convert the coordinates from relative to Window-absolute, so we draw - // in the correct place in platform code - Point aWinOffs; - aWinOffs = OutputToScreenPixel( aWinOffs ); - Region screenRegion( rControlRegion ); - screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); - - // do so for ImplControlValue members, also - ImplMoveControlValue( nType, aValue, aWinOffs ); - - Region aTestRegion( GetActiveClipRegion() ); - aTestRegion.Intersect( rControlRegion ); - if( aTestRegion == rControlRegion ) - nState |= CTRL_CACHING_ALLOWED; // control is not clipped, caching allowed - - BOOL bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, aValue, *ImplGetWinData()->mpSalControlHandle, aCaption, this ); - - // transform back ImplControlValue members - ImplMoveControlValue( nType, aValue, Point()-aWinOffs ); - - return bRet; -} - - -// ----------------------------------------------------------------------- - -BOOL Window::DrawNativeControlText(ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - ControlState nState, - const ImplControlValue& aValue, - OUString aCaption ) -{ - if( !IsNativeWidgetEnabled() ) - return FALSE; - - ImplInitSalControlHandle(); - - // make sure the current clip region is initialized correctly - if ( !mpGraphics ) - if ( !ImplGetGraphics() ) - return false; - - if ( mbInitClipRegion ) - ImplInitClipRegion(); - if ( mbOutputClipped ) - return true; - - if ( mbInitLineColor ) - ImplInitLineColor(); - if ( mbInitFillColor ) - ImplInitFillColor(); - - // Convert the coordinates from relative to Window-absolute, so we draw - // in the correct place in platform code - Point aWinOffs; - aWinOffs = OutputToScreenPixel( aWinOffs ); - Region screenRegion( rControlRegion ); - screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); - ImplMoveControlValue( nType, aValue, aWinOffs ); - - BOOL bRet = mpGraphics->DrawNativeControlText(nType, nPart, screenRegion, nState, aValue, *ImplGetWinData()->mpSalControlHandle, aCaption, this ); - - // transform back ImplControlValue members - ImplMoveControlValue( nType, aValue, Point()-aWinOffs ); - - return bRet; -} - - -// ----------------------------------------------------------------------- - -BOOL Window::GetNativeControlRegion( ControlType nType, - ControlPart nPart, - const Region& rControlRegion, - ControlState nState, - const ImplControlValue& aValue, - OUString aCaption, - Region &rNativeBoundingRegion, - Region &rNativeContentRegion ) -{ - if( !IsNativeWidgetEnabled() ) - return FALSE; - - if ( !mpGraphics ) - if ( !ImplGetGraphics() ) - return FALSE; - - ImplInitSalControlHandle(); - - // Convert the coordinates from relative to Window-absolute, so we draw - // in the correct place in platform code - Point aWinOffs; - aWinOffs = OutputToScreenPixel( aWinOffs ); - Region screenRegion( rControlRegion ); - screenRegion.Move( aWinOffs.X(), aWinOffs.Y()); - ImplMoveControlValue( nType, aValue, aWinOffs ); - - BOOL bRet = mpGraphics->GetNativeControlRegion(nType, nPart, screenRegion, nState, aValue, - *ImplGetWinData()->mpSalControlHandle, aCaption, rNativeBoundingRegion, - rNativeContentRegion, this ); - if( bRet ) - { - // transform back native regions - rNativeBoundingRegion.Move( -aWinOffs.X(), -aWinOffs.Y() ); - rNativeContentRegion.Move( -aWinOffs.X(), -aWinOffs.Y() ); - } - // transform back ImplControlValue members - ImplMoveControlValue( nType, aValue, Point()-aWinOffs ); - - return bRet; -} - - // ----------------------------------------------------------------------- WaitObject::~WaitObject() diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index de4d55b0230a..244c001b3aa0 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -191,34 +191,34 @@ static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow ); //--- static Rectangle NWGetButtonArea( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& rCaption ); + const ImplControlValue& aValue, const OUString& rCaption ); //--- static Rectangle NWGetEditBoxPixmapRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& rCaption ); + const ImplControlValue& aValue, const OUString& rCaption ); static void NWPaintOneEditBox( int nScreen, GdkDrawable * gdkDrawable, GdkRectangle *gdkRect, ControlType nType, ControlPart nPart, Rectangle aEditBoxRect, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); //--- static Rectangle NWGetSpinButtonRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& rCaption ); + const ImplControlValue& aValue, const OUString& rCaption ); static void NWPaintOneSpinButton( int nScreen, GdkPixmap * pixmap, ControlType nType, ControlPart nPart, Rectangle aAreaRect, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, const OUString& rCaption ); //--- static Rectangle NWGetComboBoxButtonRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& rCaption ); + const ImplControlValue& aValue, const OUString& rCaption ); //--- static Rectangle NWGetListBoxButtonRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& rCaption ); + const ImplControlValue& aValue, const OUString& rCaption ); static Rectangle NWGetListBoxIndicatorRect( int nScreen, ControlType nType, ControlPart nPart, Rectangle aAreaRect, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& rCaption ); + const ImplControlValue& aValue, const OUString& rCaption ); static Rectangle NWGetToolbarRect( int nScreen, ControlType nType, @@ -226,7 +226,6 @@ static Rectangle NWGetToolbarRect( int nScreen, Rectangle aAreaRect, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); //--- @@ -620,7 +619,6 @@ BOOL GtkSalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, const Point& aPos, - SalControlHandle&, BOOL& rIsInside ) { if ( ( nType == CTRL_SCROLLBAR ) && @@ -725,7 +723,6 @@ BOOL GtkSalGraphics::hitTestNativeControl( ControlType nType, * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the SalFrame implementation. * rCaption: A caption or title string (like button text etc) */ BOOL GtkSalGraphics::drawNativeControl( ControlType nType, @@ -733,13 +730,12 @@ BOOL GtkSalGraphics::drawNativeControl( ControlType nType, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ) { if( (nType==CTRL_CHECKBOX) && (nPart==PART_ENTIRE_CONTROL) && aValue.getTristateVal() == BUTTONVALUE_MIXED ) { - return drawNativeMixedStateCheck( nType, nPart, rControlRegion, nState, aValue, rControlHandle, rCaption ); + return drawNativeMixedStateCheck( nType, nPart, rControlRegion, nState, aValue, rCaption ); } BOOL returnVal = FALSE; @@ -802,61 +798,61 @@ BOOL GtkSalGraphics::drawNativeControl( ControlType nType, if ( (nType==CTRL_PUSHBUTTON) && (nPart==PART_ENTIRE_CONTROL) ) { - returnVal = NWPaintGTKButton( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKButton( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( (nType==CTRL_RADIOBUTTON) && (nPart==PART_ENTIRE_CONTROL) ) { - returnVal = NWPaintGTKRadio( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKRadio( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( (nType==CTRL_CHECKBOX) && (nPart==PART_ENTIRE_CONTROL) ) { - returnVal = NWPaintGTKCheck( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKCheck( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( (nType==CTRL_SCROLLBAR) && ((nPart==PART_DRAW_BACKGROUND_HORZ) || (nPart==PART_DRAW_BACKGROUND_VERT)) ) { - returnVal = NWPaintGTKScrollbar( nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKScrollbar( nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( ((nType==CTRL_EDITBOX) && ((nPart==PART_ENTIRE_CONTROL) || (nPart==HAS_BACKGROUND_TEXTURE)) ) || ((nType==CTRL_SPINBOX) && (nPart==HAS_BACKGROUND_TEXTURE)) || ((nType==CTRL_COMBOBOX) && (nPart==HAS_BACKGROUND_TEXTURE)) || ((nType==CTRL_LISTBOX) && (nPart==HAS_BACKGROUND_TEXTURE)) ) { - returnVal = NWPaintGTKEditBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKEditBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( ((nType==CTRL_MULTILINE_EDITBOX) && ((nPart==PART_ENTIRE_CONTROL) || (nPart==HAS_BACKGROUND_TEXTURE)) ) ) { - returnVal = NWPaintGTKEditBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKEditBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( ((nType==CTRL_SPINBOX) || (nType==CTRL_SPINBUTTONS)) && ((nPart==PART_ENTIRE_CONTROL) || (nPart==PART_ALL_BUTTONS)) ) { - returnVal = NWPaintGTKSpinBox( nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKSpinBox( nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( (nType == CTRL_COMBOBOX) && ( (nPart==PART_ENTIRE_CONTROL) ||(nPart==PART_BUTTON_DOWN) ) ) { - returnVal = NWPaintGTKComboBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKComboBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( (nType==CTRL_TAB_ITEM) || (nType==CTRL_TAB_PANE) || (nType==CTRL_TAB_BODY) || (nType==CTRL_FIXEDBORDER) ) { if ( nType == CTRL_TAB_BODY ) returnVal = TRUE; else - returnVal = NWPaintGTKTabItem( nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption); + returnVal = NWPaintGTKTabItem( nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption); } else if ( (nType==CTRL_LISTBOX) && ((nPart==PART_ENTIRE_CONTROL) || (nPart==PART_WINDOW)) ) { - returnVal = NWPaintGTKListBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKListBox( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( (nType== CTRL_TOOLBAR) ) { - returnVal = NWPaintGTKToolbar( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKToolbar( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if ( (nType== CTRL_MENUBAR) ) { - returnVal = NWPaintGTKMenubar( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKMenubar( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if( (nType == CTRL_MENU_POPUP) && ( (nPart == PART_ENTIRE_CONTROL) @@ -866,19 +862,19 @@ BOOL GtkSalGraphics::drawNativeControl( ControlType nType, ) ) { - returnVal = NWPaintGTKPopupMenu( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKPopupMenu( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if( (nType == CTRL_TOOLTIP) && (nPart == PART_ENTIRE_CONTROL) ) { - returnVal = NWPaintGTKTooltip( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKTooltip( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if( (nType == CTRL_PROGRESS) && (nPart == PART_ENTIRE_CONTROL) ) { - returnVal = NWPaintGTKProgress( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKProgress( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if( (nType == CTRL_LISTNODE) && (nPart == PART_ENTIRE_CONTROL) ) { - returnVal = NWPaintGTKListNode( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKListNode( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } else if( (nType == CTRL_LISTNET) && (nPart == PART_ENTIRE_CONTROL) ) { @@ -887,7 +883,7 @@ BOOL GtkSalGraphics::drawNativeControl( ControlType nType, } else if( (nType == CTRL_SLIDER) ) { - returnVal = NWPaintGTKSlider( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + returnVal = NWPaintGTKSlider( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } if( pixmap ) @@ -904,7 +900,6 @@ BOOL GtkSalGraphics::drawNativeMixedStateCheck( ControlType nType, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ) { // need to emulate something for mixed state @@ -927,7 +922,7 @@ BOOL GtkSalGraphics::drawNativeMixedStateCheck( ControlType nType, SetClipRegion( pFontGC_, aRegion ); XDestroyRegion( aRegion ); - returnVal = drawNativeControl( nType, nPart, rControlRegion, nState, aValue, rControlHandle, rCaption ); + returnVal = drawNativeControl( nType, nPart, rControlRegion, nState, aValue, rCaption ); if( returnVal ) { @@ -938,7 +933,7 @@ BOOL GtkSalGraphics::drawNativeMixedStateCheck( ControlType nType, XUnionRectWithRegion( &aXRect, aRegion, aRegion ); SetClipRegion( pFontGC_, aRegion ); XDestroyRegion( aRegion ); - returnVal = drawNativeControl( nType, nPart, rControlRegion, nState, aValue, rControlHandle, rCaption ); + returnVal = drawNativeControl( nType, nPart, rControlRegion, nState, aValue, rCaption ); } // clean up @@ -957,7 +952,6 @@ BOOL GtkSalGraphics::drawNativeMixedStateCheck( ControlType nType, * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the SalFrame implementation. * rCaption: A caption or title string (like button text etc) */ BOOL GtkSalGraphics::drawNativeControlText( ControlType, @@ -965,7 +959,6 @@ BOOL GtkSalGraphics::drawNativeControlText( ControlType, const Region&, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { return( FALSE ); @@ -983,7 +976,6 @@ BOOL GtkSalGraphics::drawNativeControlText( ControlType, * * rControlRegion: The bounding region of the control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the SalFrame implementation. * rCaption: A caption or title string (like button text etc) */ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, @@ -991,7 +983,6 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ) @@ -1003,7 +994,7 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, && (rControlRegion.GetBoundRect().GetHeight() > 16) ) { rNativeBoundingRegion = NWGetButtonArea( m_nScreen, nType, nPart, rControlRegion.GetBoundRect(), - nState, aValue, rControlHandle, rCaption ); + nState, aValue, rCaption ); rNativeContentRegion = rControlRegion; returnVal = TRUE; @@ -1011,7 +1002,7 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, if ( (nType==CTRL_COMBOBOX) && ((nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) ) { rNativeBoundingRegion = NWGetComboBoxButtonRect( m_nScreen, nType, nPart, rControlRegion.GetBoundRect(), nState, - aValue, rControlHandle, rCaption ); + aValue, rCaption ); rNativeContentRegion = rNativeBoundingRegion; returnVal = TRUE; @@ -1020,7 +1011,7 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, { rNativeBoundingRegion = NWGetSpinButtonRect( m_nScreen, nType, nPart, rControlRegion.GetBoundRect(), nState, - aValue, rControlHandle, rCaption ); + aValue, rCaption ); rNativeContentRegion = rNativeBoundingRegion; returnVal = TRUE; @@ -1028,7 +1019,7 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, if ( (nType==CTRL_LISTBOX) && ((nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) ) { rNativeBoundingRegion = NWGetListBoxButtonRect( m_nScreen, nType, nPart, rControlRegion.GetBoundRect(), nState, - aValue, rControlHandle, rCaption ); + aValue, rCaption ); rNativeContentRegion = rNativeBoundingRegion; returnVal = TRUE; @@ -1041,7 +1032,7 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, (nPart==PART_BUTTON) )) { - rNativeBoundingRegion = NWGetToolbarRect( m_nScreen, nType, nPart, rControlRegion.GetBoundRect(), nState, aValue, rControlHandle, rCaption ); + rNativeBoundingRegion = NWGetToolbarRect( m_nScreen, nType, nPart, rControlRegion.GetBoundRect(), nState, aValue, rCaption ); rNativeContentRegion = rNativeBoundingRegion; returnVal = TRUE; } @@ -1155,7 +1146,7 @@ BOOL GtkSalGraphics::NWPaintGTKButton( const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue&, - SalControlHandle&, const OUString& ) + const OUString& ) { GtkStateType stateType; GtkShadowType shadowType; @@ -1268,7 +1259,7 @@ BOOL GtkSalGraphics::NWPaintGTKButton( static Rectangle NWGetButtonArea( int nScreen, ControlType, ControlPart, Rectangle aAreaRect, ControlState nState, - const ImplControlValue&, SalControlHandle&, const OUString& ) + const ImplControlValue&, const OUString& ) { gboolean interiorFocus; gint focusWidth; @@ -1324,7 +1315,7 @@ BOOL GtkSalGraphics::NWPaintGTKRadio( GdkDrawable* gdkDrawable, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, - const ImplControlValue& aValue, SalControlHandle&, + const ImplControlValue& aValue, const OUString& ) { GtkStateType stateType; @@ -1383,7 +1374,7 @@ BOOL GtkSalGraphics::NWPaintGTKCheck( GdkDrawable* gdkDrawable, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle&, const OUString& ) + const OUString& ) { GtkStateType stateType; GtkShadowType shadowType; @@ -1438,7 +1429,7 @@ BOOL GtkSalGraphics::NWPaintGTKScrollbar( ControlType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList&, ControlState nState, - const ImplControlValue& aValue, SalControlHandle&, + const ImplControlValue& aValue, const OUString& ) { ScrollbarValue* pScrollbarVal = (ScrollbarValue *)(aValue.getOptionalVal()); @@ -1844,7 +1835,7 @@ BOOL GtkSalGraphics::NWPaintGTKEditBox( GdkDrawable* gdkDrawable, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, + const ImplControlValue& aValue, const OUString& rCaption ) { Rectangle pixmapRect; @@ -1853,7 +1844,7 @@ BOOL GtkSalGraphics::NWPaintGTKEditBox( GdkDrawable* gdkDrawable, // Find the overall bounding rect of the buttons's drawing area, // plus its actual draw rect excluding adornment pixmapRect = NWGetEditBoxPixmapRect( m_nScreen, nType, nPart, rControlRectangle, - nState, aValue, rControlHandle, rCaption ); + nState, aValue, rCaption ); for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it ) { clipRect.x = it->Left(); @@ -1861,7 +1852,7 @@ BOOL GtkSalGraphics::NWPaintGTKEditBox( GdkDrawable* gdkDrawable, clipRect.width = it->GetWidth(); clipRect.height = it->GetHeight(); - NWPaintOneEditBox( m_nScreen, gdkDrawable, &clipRect, nType, nPart, pixmapRect, nState, aValue, rControlHandle, rCaption ); + NWPaintOneEditBox( m_nScreen, gdkDrawable, &clipRect, nType, nPart, pixmapRect, nState, aValue, rCaption ); } return( TRUE ); @@ -1878,7 +1869,6 @@ static Rectangle NWGetEditBoxPixmapRect(int nScreen, Rectangle aAreaRect, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { Rectangle pixmapRect = aAreaRect; @@ -1915,7 +1905,6 @@ static void NWPaintOneEditBox( int nScreen, Rectangle aEditBoxRect, ControlState nState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { GtkStateType stateType; @@ -1984,7 +1973,7 @@ BOOL GtkSalGraphics::NWPaintGTKSpinBox( ControlType nType, ControlPart nPart, const clipList&, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ) + const OUString& rCaption ) { GdkPixmap * pixmap; Rectangle pixmapRect; @@ -2032,8 +2021,8 @@ BOOL GtkSalGraphics::NWPaintGTKSpinBox( ControlType nType, ControlPart nPart, if ( !pixmap ) return( FALSE ); - upBtnRect = NWGetSpinButtonRect( m_nScreen, nType, upBtnPart, pixmapRect, upBtnState, aValue, rControlHandle, rCaption ); - downBtnRect = NWGetSpinButtonRect( m_nScreen, nType, downBtnPart, pixmapRect, downBtnState, aValue, rControlHandle, rCaption ); + upBtnRect = NWGetSpinButtonRect( m_nScreen, nType, upBtnPart, pixmapRect, upBtnState, aValue, rCaption ); + downBtnRect = NWGetSpinButtonRect( m_nScreen, nType, downBtnPart, pixmapRect, downBtnState, aValue, rCaption ); if ( (nType==CTRL_SPINBOX) && (nPart!=PART_ALL_BUTTONS) ) { @@ -2043,7 +2032,7 @@ BOOL GtkSalGraphics::NWPaintGTKSpinBox( ControlType nType, ControlPart nPart, aEditBoxRect.setX( 0 ); aEditBoxRect.setY( 0 ); - NWPaintOneEditBox( m_nScreen, pixmap, NULL, nType, nPart, aEditBoxRect, nState, aValue, rControlHandle, rCaption ); + NWPaintOneEditBox( m_nScreen, pixmap, NULL, nType, nPart, aEditBoxRect, nState, aValue, rCaption ); } NWSetWidgetState( gWidgetData[m_nScreen].gSpinButtonWidget, nState, stateType ); @@ -2060,8 +2049,8 @@ BOOL GtkSalGraphics::NWPaintGTKSpinBox( ControlType nType, ControlPart nPart, shadowRect.GetWidth(), shadowRect.GetHeight() ); } - NWPaintOneSpinButton( m_nScreen, pixmap, nType, upBtnPart, pixmapRect, upBtnState, aValue, rControlHandle, rCaption ); - NWPaintOneSpinButton( m_nScreen, pixmap, nType, downBtnPart, pixmapRect, downBtnState, aValue, rControlHandle, rCaption ); + NWPaintOneSpinButton( m_nScreen, pixmap, nType, upBtnPart, pixmapRect, upBtnState, aValue, rCaption ); + NWPaintOneSpinButton( m_nScreen, pixmap, nType, downBtnPart, pixmapRect, downBtnState, aValue, rCaption ); if( !NWRenderPixmapToScreen(pixmap, pixmapRect) ) { @@ -2081,7 +2070,6 @@ static Rectangle NWGetSpinButtonRect( int nScreen, Rectangle aAreaRect, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { gint buttonSize; @@ -2125,7 +2113,6 @@ static void NWPaintOneSpinButton( int nScreen, Rectangle aAreaRect, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ) { Rectangle buttonRect; @@ -2137,7 +2124,7 @@ static void NWPaintOneSpinButton( int nScreen, NWEnsureGTKSpinButton( nScreen ); NWConvertVCLStateToGTKState( nState, &stateType, &shadowType ); - buttonRect = NWGetSpinButtonRect( nScreen, nType, nPart, aAreaRect, nState, aValue, rControlHandle, rCaption ); + buttonRect = NWGetSpinButtonRect( nScreen, nType, nPart, aAreaRect, nState, aValue, rCaption ); NWSetWidgetState( gWidgetData[nScreen].gSpinButtonWidget, nState, stateType ); gtk_paint_box( gWidgetData[nScreen].gSpinButtonWidget->style, pixmap, stateType, shadowType, NULL, gWidgetData[nScreen].gSpinButtonWidget, @@ -2169,7 +2156,7 @@ BOOL GtkSalGraphics::NWPaintGTKComboBox( GdkDrawable* gdkDrawable, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ) + const OUString& rCaption ) { Rectangle pixmapRect; Rectangle buttonRect; @@ -2194,7 +2181,7 @@ BOOL GtkSalGraphics::NWPaintGTKComboBox( GdkDrawable* gdkDrawable, NWSetWidgetState( gWidgetData[m_nScreen].gComboWidget, nState, stateType ); NWSetWidgetState( gWidgetData[m_nScreen].gArrowWidget, nState, stateType ); - buttonRect = NWGetComboBoxButtonRect( m_nScreen, nType, PART_BUTTON_DOWN, pixmapRect, nState, aValue, rControlHandle, rCaption ); + buttonRect = NWGetComboBoxButtonRect( m_nScreen, nType, PART_BUTTON_DOWN, pixmapRect, nState, aValue, rCaption ); if( nPart == PART_BUTTON_DOWN ) buttonRect.Left() += 1; @@ -2216,7 +2203,7 @@ BOOL GtkSalGraphics::NWPaintGTKComboBox( GdkDrawable* gdkDrawable, if( nPart == PART_ENTIRE_CONTROL ) NWPaintOneEditBox( m_nScreen, gdkDrawable, &clipRect, nType, nPart, aEditBoxRect, - nState, aValue, rControlHandle, rCaption ); + nState, aValue, rCaption ); // Buttons must paint opaque since some themes have alpha-channel enabled buttons gtk_paint_flat_box( gWidgetData[m_nScreen].gBtnWidget->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE, @@ -2247,7 +2234,6 @@ static Rectangle NWGetComboBoxButtonRect( int nScreen, Rectangle aAreaRect, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { Rectangle aButtonRect; @@ -2302,7 +2288,7 @@ BOOL GtkSalGraphics::NWPaintGTKTabItem( ControlType nType, ControlPart, const clipList&, ControlState nState, const ImplControlValue& aValue, - SalControlHandle&, const OUString& ) + const OUString& ) { GdkPixmap * pixmap; Rectangle pixmapRect; @@ -2444,7 +2430,7 @@ BOOL GtkSalGraphics::NWPaintGTKListBox( GdkDrawable* gdkDrawable, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ) + const OUString& rCaption ) { Rectangle pixmapRect; Rectangle widgetRect; @@ -2511,7 +2497,7 @@ BOOL GtkSalGraphics::NWPaintGTKListBox( GdkDrawable* gdkDrawable, y+(widgetRect.Top() - pixmapRect.Top()), widgetRect.GetWidth(), widgetRect.GetHeight() ); aIndicatorRect = NWGetListBoxIndicatorRect( m_nScreen, nType, nPart, widgetRect, nState, - aValue, rControlHandle, rCaption ); + aValue, rCaption ); gtk_paint_tab( gWidgetData[m_nScreen].gOptionMenuWidget->style, gdkDrawable, stateType, shadowType, &clipRect, gWidgetData[m_nScreen].gOptionMenuWidget, "optionmenutab", x+(aIndicatorRect.Left() - pixmapRect.Left()), @@ -2538,7 +2524,7 @@ BOOL GtkSalGraphics::NWPaintGTKToolbar( const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle&, const OUString& ) + const OUString& ) { GtkStateType stateType; GtkShadowType shadowType; @@ -2685,7 +2671,7 @@ BOOL GtkSalGraphics::NWPaintGTKMenubar( const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue&, - SalControlHandle&, const OUString& ) + const OUString& ) { GtkStateType stateType; GtkShadowType shadowType; @@ -2770,7 +2756,7 @@ BOOL GtkSalGraphics::NWPaintGTKPopupMenu( const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue&, - SalControlHandle&, const OUString& ) + const OUString& ) { // #i50745# gtk does not draw disabled menu entries (and crux theme // even crashes), draw them using vcl functionality. @@ -2900,7 +2886,7 @@ BOOL GtkSalGraphics::NWPaintGTKTooltip( const Rectangle& rControlRectangle, const clipList& rClipList, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) + const OUString& ) { NWEnsureGTKTooltip( m_nScreen ); @@ -2938,7 +2924,7 @@ BOOL GtkSalGraphics::NWPaintGTKListNode( const Rectangle& rControlRectangle, const clipList&, ControlState nState, const ImplControlValue& rValue, - SalControlHandle&, const OUString& ) + const OUString& ) { NWEnsureGTKTreeView( m_nScreen ); @@ -2992,7 +2978,7 @@ BOOL GtkSalGraphics::NWPaintGTKProgress( const Rectangle& rControlRectangle, const clipList&, ControlState, const ImplControlValue& rValue, - SalControlHandle&, const OUString& ) + const OUString& ) { NWEnsureGTKProgressBar( m_nScreen ); @@ -3056,7 +3042,7 @@ BOOL GtkSalGraphics::NWPaintGTKSlider( const Rectangle& rControlRectangle, const clipList&, ControlState nState, const ImplControlValue& rValue, - SalControlHandle&, const OUString& ) + const OUString& ) { NWEnsureGTKSlider( m_nScreen ); @@ -3185,7 +3171,6 @@ static Rectangle NWGetListBoxButtonRect( int nScreen, Rectangle aAreaRect, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { Rectangle aPartRect; @@ -3248,7 +3233,6 @@ static Rectangle NWGetListBoxIndicatorRect( int nScreen, Rectangle aAreaRect, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { Rectangle aIndicatorRect; @@ -3295,7 +3279,6 @@ static Rectangle NWGetToolbarRect( int nScreen, Rectangle aAreaRect, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { Rectangle aRet; diff --git a/vcl/unx/inc/plugins/gtk/gtkgdi.hxx b/vcl/unx/inc/plugins/gtk/gtkgdi.hxx index ed3f782c8576..065b5435eeb0 100644 --- a/vcl/unx/inc/plugins/gtk/gtkgdi.hxx +++ b/vcl/unx/inc/plugins/gtk/gtkgdi.hxx @@ -64,15 +64,15 @@ public: // native widget methods virtual BOOL IsNativeControlSupported( ControlType nType, ControlPart nPart ); virtual BOOL hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside ); + const Point& aPos, BOOL& rIsInside ); virtual BOOL drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, const rtl::OUString& rCaption ); virtual BOOL drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& rCaption ); + const rtl::OUString& rCaption ); virtual BOOL getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& rCaption, + const ImplControlValue& aValue, const rtl::OUString& rCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ); //helper methods for frame's UpdateSettings @@ -101,86 +101,86 @@ protected: const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKRadio( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKCheck( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKScrollbar( ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKEditBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKSpinBox( ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKComboBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKTabItem( ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKListBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKToolbar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKMenubar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKPopupMenu( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKTooltip( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKProgress( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKSlider( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL NWPaintGTKListNode( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& rCaption ); + const OUString& rCaption ); BOOL drawNativeMixedStateCheck( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, const rtl::OUString& rCaption ); }; diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx index ea9161235ac9..3adc9f5c679a 100644 --- a/vcl/unx/kde/salnativewidgets-kde.cxx +++ b/vcl/unx/kde/salnativewidgets-kde.cxx @@ -1177,18 +1177,18 @@ class KDESalGraphics : public X11SalGraphics virtual BOOL IsNativeControlSupported( ControlType nType, ControlPart nPart ); virtual BOOL hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, const Point& aPos, - SalControlHandle& rControlHandle, BOOL& rIsInside ); + BOOL& rIsInside ); virtual BOOL drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, + const ImplControlValue& aValue, const OUString& aCaption ); virtual BOOL drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, + const ImplControlValue& aValue, const OUString& aCaption ); virtual BOOL getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, + const ImplControlValue& aValue, const OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ); }; @@ -1242,7 +1242,7 @@ BOOL KDESalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP */ BOOL KDESalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, const Point& rPos, - SalControlHandle&, BOOL& rIsInside ) + BOOL& rIsInside ) { if ( nType == CTRL_SCROLLBAR ) { @@ -1344,15 +1344,12 @@ BOOL KDESalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, @param aValue An optional value (tristate/numerical/string). - @param rControlHandle - Carries platform dependent data and is maintained by the SalFrame implementation. - @param aCaption A caption or title string (like button text etc.) */ BOOL KDESalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle&, + const ImplControlValue& aValue, const OUString& ) { BOOL bReturn = FALSE; @@ -1489,15 +1486,12 @@ BOOL KDESalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, @param aValue An optional value (tristate/numerical/string) - @param rControlHandle - Carries platform dependent data and is maintained by the SalFrame implementation. - @param aCaption A caption or title string (like button text etc.) */ BOOL KDESalGraphics::drawNativeControlText( ControlType, ControlPart, const Region&, ControlState, - const ImplControlValue&, SalControlHandle&, + const ImplControlValue&, const OUString& ) { return FALSE; @@ -1517,15 +1511,12 @@ BOOL KDESalGraphics::drawNativeControlText( ControlType, ControlPart, @param aValue An optional value (tristate/numerical/string) - @param rControlHandle - Carries platform dependent data and is maintained by the SalFrame implementation. - @param aCaption A caption or title string (like button text etc.) */ BOOL KDESalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue&, SalControlHandle&, + const ImplControlValue&, const OUString&, Region &rNativeBoundingRegion, Region &rNativeContentRegion ) { diff --git a/vcl/unx/kde4/KDESalGraphics.cxx b/vcl/unx/kde4/KDESalGraphics.cxx index 25dd50ce3958..e8d184e6539b 100644 --- a/vcl/unx/kde4/KDESalGraphics.cxx +++ b/vcl/unx/kde4/KDESalGraphics.cxx @@ -158,7 +158,7 @@ BOOL KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart par BOOL KDESalGraphics::hitTestNativeControl( ControlType, ControlPart, const Region&, const Point&, - SalControlHandle&, BOOL& ) + BOOL& ) { return FALSE; } @@ -220,7 +220,7 @@ namespace BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, const Region& rControlRegion, ControlState nControlState, - const ImplControlValue& value, SalControlHandle&, + const ImplControlValue& value, const OUString& ) { // put not implemented types here @@ -567,7 +567,7 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, const Region& controlRegion, ControlState controlState, - const ImplControlValue& val, SalControlHandle&, + const ImplControlValue& val, const OUString&, Region &nativeBoundingRegion, Region &nativeContentRegion ) { diff --git a/vcl/unx/kde4/KDESalGraphics.hxx b/vcl/unx/kde4/KDESalGraphics.hxx index b5328f462a16..5661d743e0cd 100644 --- a/vcl/unx/kde4/KDESalGraphics.hxx +++ b/vcl/unx/kde4/KDESalGraphics.hxx @@ -59,7 +59,7 @@ class KDESalGraphics : public X11SalGraphics */ virtual BOOL hitTestNativeControl( ControlType type, ControlPart part, const Region& rControlRegion, const Point& aPos, - SalControlHandle& rControlHandle, BOOL& rIsInside ); + BOOL& rIsInside ); /** Draw the requested control described by part/nControlState. @param rControlRegion @@ -68,15 +68,12 @@ class KDESalGraphics : public X11SalGraphics @param aValue An optional value (tristate/numerical/string). - @param rControlHandle - Carries platform dependent data and is maintained by the SalFrame implementation. - @param aCaption A caption or title string (like button text etc.) */ virtual BOOL drawNativeControl( ControlType type, ControlPart part, const Region& rControlRegion, ControlState nControlState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, + const ImplControlValue& aValue, const rtl::OUString& aCaption ); /** Draw text on the widget. @@ -85,12 +82,11 @@ class KDESalGraphics : public X11SalGraphics @param rControlRegion The bounding region of the complete control in VCL frame coordinates. @param aValue An optional value (tristate/numerical/string) - @param rControlHandle Carries platform dependent data and is maintained by the SalFrame implementation. @param aCaption A caption or title string (like button text etc.) */ virtual BOOL drawNativeControlText( ControlType, ControlPart, const Region&, ControlState, - const ImplControlValue&, SalControlHandle&, + const ImplControlValue&, const rtl::OUString& ) { return false; } /** Check if the bounding regions match. @@ -106,15 +102,12 @@ class KDESalGraphics : public X11SalGraphics @param aValue An optional value (tristate/numerical/string) - @param rControlHandle - Carries platform dependent data and is maintained by the SalFrame implementation. - @param aCaption A caption or title string (like button text etc.) */ virtual BOOL getNativeControlRegion( ControlType type, ControlPart part, const Region& rControlRegion, ControlState nControlState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, + const ImplControlValue& aValue, const rtl::OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ); };
\ No newline at end of file diff --git a/vcl/win/inc/salgdi.h b/vcl/win/inc/salgdi.h index 6b58e0c5375a..4b97eeb98c0b 100644 --- a/vcl/win/inc/salgdi.h +++ b/vcl/win/inc/salgdi.h @@ -228,15 +228,15 @@ protected: // native widget rendering methods that require mirroring virtual BOOL hitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside ); + const Point& aPos, BOOL& rIsInside ); virtual BOOL drawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, + ControlState nState, const ImplControlValue& aValue, const rtl::OUString& aCaption ); virtual BOOL drawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const rtl::OUString& aCaption ); + const rtl::OUString& aCaption ); virtual BOOL getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState, - const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& aCaption, + const ImplControlValue& aValue, const rtl::OUString& aCaption, Region &rNativeBoundingRegion, Region &rNativeContentRegion ); virtual bool drawAlphaBitmap( const SalTwoRect&, diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index 1b7ed7dcfccb..47bf91a615e0 100644 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -315,7 +315,6 @@ BOOL WinSalGraphics::hitTestNativeControl( ControlType, ControlPart, const Region&, const Point&, - SalControlHandle&, BOOL& ) { return FALSE; @@ -421,7 +420,6 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, ControlPart nPart, ControlState nState, const ImplControlValue& aValue, - SalControlHandle&, OUString aCaption ) { // a listbox dropdown is actually a combobox dropdown @@ -936,7 +934,6 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the WinSalGraphics implementation. * aCaption: A caption or title string (like button text etc) */ BOOL WinSalGraphics::drawNativeControl( ControlType nType, @@ -944,7 +941,6 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, const Region& rControlRegion, ControlState nState, const ImplControlValue& aValue, - SalControlHandle& rControlHandle, const OUString& aCaption ) { BOOL bOk = false; @@ -1031,7 +1027,7 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, OUString aCaptionStr( aCaption.replace('~', '&') ); // translate mnemonics bOk = ImplDrawNativeControl(mhDC, hTheme, rc, nType, nPart, nState, aValue, - rControlHandle, aCaptionStr ); + aCaptionStr ); // restore alignment SetTextAlign( mhDC, ta ); @@ -1051,7 +1047,6 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, * * rControlRegion: The bounding region of the complete control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the WinSalGraphics implementation. * aCaption: A caption or title string (like button text etc) */ BOOL WinSalGraphics::drawNativeControlText( ControlType, @@ -1059,7 +1054,6 @@ BOOL WinSalGraphics::drawNativeControlText( ControlType, const Region&, ControlState, const ImplControlValue&, - SalControlHandle&, const OUString& ) { return( false ); @@ -1077,15 +1071,13 @@ BOOL WinSalGraphics::drawNativeControlText( ControlType, * * rControlRegion: The bounding region of the control in VCL frame coordinates. * aValue: An optional value (tristate/numerical/string) - * rControlHandle: Carries platform dependent data and is maintained by the WinSalGraphics implementation. * aCaption: A caption or title string (like button text etc) */ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, - ControlState, - const ImplControlValue&, - SalControlHandle&, + ControlState nState, + const ImplControlValue& rControlValue, const OUString&, Region &rNativeBoundingRegion, Region &rNativeContentRegion ) @@ -1201,6 +1193,7 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, } } } + if( nType == CTRL_SLIDER && ( (nPart == PART_THUMB_HORZ) || (nPart == PART_THUMB_VERT) ) ) { HTHEME hTheme = getThemeHandle( mhWnd, L"Trackbar"); @@ -1229,6 +1222,37 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, } } + if ( ( nType == CTRL_TAB_ITEM ) && ( nPart == PART_ENTIRE_CONTROL ) ) + { + Rectangle aControlRect( rControlRegion.GetBoundRect() ); + rNativeContentRegion = aControlRect; + + --aControlRect.Bottom(); + + TabitemValue *pValue = static_cast< TabitemValue* >( rControlValue.getOptionalVal() ); + if ( pValue ) + { + if ( pValue->isBothAligned() ) + --aControlRect.Right(); + } + + if ( nState & CTRL_STATE_SELECTED ) + { + aControlRect.Left() -= 2; + if ( pValue && !pValue->isBothAligned() ) + { + if ( pValue->isLeftAligned() || pValue->isNotAligned() ) + aControlRect.Right() += 2; + if ( pValue->isRightAligned() ) + aControlRect.Right() += 1; + } + aControlRect.Top() -= 2; + aControlRect.Bottom() += 2; + } + rNativeBoundingRegion = aControlRect; + bRet = TRUE; + } + ReleaseDC( mhWnd, hDC ); return( bRet ); } |