summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-03-06 10:44:34 +0000
committerKurt Zenker <kz@openoffice.org>2008-03-06 10:44:34 +0000
commitf82df298b6c8183bffb6d77e340f9e0be71495ee (patch)
treedf5ef3aecb590ddcab6760951a9e02fefc54425d /toolkit
parent3160bc4514539846192afb36041d5c274234ea31 (diff)
INTEGRATION: CWS layout_DEV300 (1.1.2); FILE ADDED
2008/02/08 18:44:43 jcn 1.1.2.1: Initial toolkit import from ee9a2fcc29d7e2f01cc80ef7c13bf7bc7d55ae7e. layout/source/awt -> toolkit/source/awt layout/source/core -> toolkit/source/layout layout/source/wrapper -> toolkit/source/vclcompat layout/inc/layout -> toolkit/inc/layout layout/source/inc -> toolkit/inc/layout layout/workben -> toolkit/workben/layout That's ooo-build trunk r11539 @ ooh680-m5/src680-m245.
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/awt/vclxsplitter.cxx319
-rw-r--r--toolkit/source/awt/vclxtabcontrol.cxx532
-rw-r--r--toolkit/source/layout/bin.cxx159
-rw-r--r--toolkit/source/layout/bin.hxx89
-rw-r--r--toolkit/source/layout/box.cxx338
-rw-r--r--toolkit/source/layout/box.hxx91
-rw-r--r--toolkit/source/layout/container.cxx141
-rw-r--r--toolkit/source/layout/container.hxx109
-rw-r--r--toolkit/source/layout/dialogbuttonhbox.cxx264
-rw-r--r--toolkit/source/layout/dialogbuttonhbox.hxx46
10 files changed, 2088 insertions, 0 deletions
diff --git a/toolkit/source/awt/vclxsplitter.cxx b/toolkit/source/awt/vclxsplitter.cxx
new file mode 100644
index 000000000000..25e740ba159d
--- /dev/null
+++ b/toolkit/source/awt/vclxsplitter.cxx
@@ -0,0 +1,319 @@
+#include "vclxsplitter.hxx"
+#ifndef _TOOLKIT_HELPER_PROPERTY_HXX_
+#include "toolkit/helper/property.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#include <vcl/split.hxx>
+
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+#include <com/sun/star/awt/PosSize.hpp>
+
+#include <assert.h>
+#include <sal/macros.h>
+
+using namespace toolkit;
+//........................................................................
+namespace layoutimpl
+{
+//........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star;
+
+class SplitterChildProps : public PropHelper
+{
+public:
+ SplitterChildProps( VCLXSplitter::ChildData *pData )
+ {
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Shrink" ),
+ ::getCppuType( static_cast< const rtl::OUString* >( NULL ) ),
+ &(pData->bShrink) );
+ }
+ PROPHELPER_SET_INFO
+};
+
+//====================================================================
+//= VCLXSplitter
+//====================================================================
+DBG_NAME( VCLXSplitter )
+//--------------------------------------------------------------------
+VCLXSplitter::VCLXSplitter( bool bHorizontal )
+: VCLXWindow()
+ , Container()
+{
+ DBG_CTOR( VCLXSplitter, NULL );
+ mnHandleRatio = 0.5;
+ mbHandlePressed = false;
+ mbHorizontal = bHorizontal;
+ mpSplitter = NULL;
+}
+
+//--------------------------------------------------------------------
+VCLXSplitter::~VCLXSplitter()
+{
+ DBG_DTOR( VCLXSplitter, NULL );
+}
+
+//--------------------------------------------------------------------
+IMPLEMENT_2_FORWARD_XINTERFACE1( VCLXSplitter, VCLXWindow, Container )
+
+//--------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXSplitter, VCLXWindow )
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXSplitter::dispose( ) throw(RuntimeException)
+{
+ {
+ ::vos::OGuard aGuard( GetMutex() );
+
+ EventObject aDisposeEvent;
+ aDisposeEvent.Source = *this;
+// maTabListeners.disposeAndClear( aDisposeEvent );
+ }
+
+ VCLXWindow::dispose();
+}
+
+//--------------------------------------------------------------------
+void VCLXSplitter::ensureSplitter()
+{
+ if ( !mpSplitter )
+ {
+ mpSplitter = new Splitter( GetWindow() , mbHorizontal ? WB_HORZ : WB_VERT );
+ mpSplitter->Show();
+ mpSplitter->SetEndSplitHdl( LINK( this, VCLXSplitter, HandleMovedHdl ) );
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXSplitter::addChild(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains > &xChild )
+ throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::awt::MaxChildrenException)
+{
+ ChildData *pData;
+ if ( ! maChildren[ 0 ].xChild.is() )
+ pData = &maChildren[ 0 ];
+ else if ( ! maChildren[ 1 ].xChild.is() )
+ pData = &maChildren[ 1 ];
+ else
+ throw css::awt::MaxChildrenException();
+
+ if ( xChild.is() )
+ {
+ pData->xChild = xChild;
+ setChildParent( xChild );
+ queueResize();
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXSplitter::removeChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains > &xChild )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ChildData *pData = 0;
+ if ( maChildren[ 0 ].xChild == xChild )
+ pData = &maChildren[ 0 ];
+ else if ( maChildren[ 1 ].xChild == xChild )
+ pData = &maChildren[ 1 ];
+
+ if ( pData )
+ {
+ pData->xChild = uno::Reference< awt::XLayoutConstrains >();
+ unsetChildParent( xChild );
+ queueResize();
+ }
+}
+
+//--------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference
+ < ::com::sun::star::awt::XLayoutConstrains > > SAL_CALL VCLXSplitter::getChildren()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ int childLen = (maChildren[ 0 ].xChild.is() ? 1: 0) +
+ (maChildren[ 1 ].xChild.is() ? 1: 0);
+ uno::Sequence< uno::Reference< awt::XLayoutConstrains > > childrenSeq( childLen );
+ int i = 0;
+ if ( maChildren[ 0 ].xChild.is() )
+ childrenSeq[ i++ ] = maChildren[ 0 ].xChild;
+ if ( maChildren[ 1 ].xChild.is() )
+ childrenSeq[ i++ ] = maChildren[ 1 ].xChild;
+ return childrenSeq;
+}
+
+//--------------------------------------------------------------------
+uno::Reference< beans::XPropertySet > SAL_CALL
+VCLXSplitter::getChildProperties( const uno::Reference< awt::XLayoutConstrains >& xChild )
+ throw (uno::RuntimeException)
+{
+ ChildData *pData = 0;
+ if ( maChildren[ 0 ].xChild == xChild )
+ pData = &maChildren[ 0 ];
+ else if ( maChildren[ 1 ].xChild == xChild )
+ pData = &maChildren[ 1 ];
+
+ if ( pData )
+ {
+ if ( !pData->xProps.is() )
+ {
+ PropHelper *pProps = new SplitterChildProps( pData );
+ pProps->setChangeListener( this );
+ pData->xProps = pProps;
+ }
+ return pData->xProps;
+ }
+ return uno::Reference< beans::XPropertySet >();
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXSplitter::allocateArea(
+ const ::com::sun::star::awt::Rectangle &rArea )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ensureSplitter(); // shouldn't be needed...
+ getMinimumSize();
+ int splitDiff;
+ if ( mbHorizontal )
+ splitDiff = rArea.Width - maAllocation.Width;
+ else
+ splitDiff = rArea.Height - maAllocation.Height;
+
+ assert(mpSplitter);
+ if ( splitDiff )
+ mpSplitter->SetSplitPosPixel( mpSplitter->GetSplitPosPixel() + splitDiff/2 );
+
+ maAllocation = rArea;
+ int width = mbHorizontal ? rArea.Width : rArea.Height;
+ int splitLen = 2;
+ int splitPos = mpSplitter->GetSplitPosPixel();
+ setPosSize( rArea.X, rArea.Y, rArea.Width, rArea.Height, PosSize::POSSIZE );
+ if ( mbHorizontal )
+ mpSplitter->SetPosSizePixel( splitPos, 0, splitLen, rArea.Height, PosSize::POSSIZE );
+ else
+ mpSplitter->SetPosSizePixel( 0, splitPos, rArea.Width, splitLen, PosSize::POSSIZE );
+ mpSplitter->SetDragRectPixel( ::Rectangle( 0, 0, rArea.Width, rArea.Height ) );
+ int leftWidth = splitPos;
+ int rightWidth = width - splitPos;
+
+ if ( maChildren[ 0 ].xChild.is() )
+ {
+ awt::Rectangle childRect( 0, 0, rArea.Width, rArea.Height );
+
+ if ( mbHorizontal )
+ childRect.Width = leftWidth - 2;
+ else
+ childRect.Height = leftWidth - 2;
+ allocateChildAt( maChildren[ 0 ].xChild, childRect );
+ }
+ if ( maChildren[ 1 ].xChild.is() )
+ {
+ awt::Rectangle childRect( 0, 0, rArea.Width, rArea.Height );
+
+ if ( mbHorizontal )
+ {
+ childRect.X += leftWidth + splitLen + 2;
+ childRect.Width = rightWidth;
+ }
+ else
+ {
+ childRect.Y += leftWidth + splitLen + 2;
+ childRect.Height = rightWidth;
+ }
+ allocateChildAt( maChildren[ 1 ].xChild, childRect );
+ }
+}
+
+//--------------------------------------------------------------------
+::com::sun::star::awt::Size SAL_CALL VCLXSplitter::getMinimumSize()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ ensureSplitter();
+
+ awt::Size size( mbHorizontal ? 2 : 0, mbHorizontal ? 0 : 2 );
+ for( unsigned int i = 0; i < 2; i++ )
+ {
+ if ( maChildren[ i ].xChild.is() )
+ {
+ awt::Size childSize = maChildren[ i ].xChild->getMinimumSize();
+ if ( mbHorizontal )
+ {
+ size.Width += childSize.Width;
+ size.Height = SAL_MAX( size.Height, childSize.Height );
+ }
+ else
+ {
+ size.Width = SAL_MAX( size.Width, childSize.Width );
+ size.Height += childSize.Height;
+ }
+ }
+ }
+
+ maRequisition = size;
+ return size;
+}
+
+//--------------------------------------------------------------------
+void VCLXSplitter::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
+{
+ ::vos::OClearableGuard aGuard( GetMutex() );
+ switch ( _rVclWindowEvent.GetId() )
+ {
+ default:
+ aGuard.clear();
+ VCLXWindow::ProcessWindowEvent( _rVclWindowEvent );
+ break;
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXSplitter::setProperty( const ::rtl::OUString& PropertyName, const Any &Value ) throw(RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ if ( GetWindow() )
+ {
+ sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
+ switch ( nPropertyId )
+ {
+ default:
+ VCLXWindow::setProperty( PropertyName, Value );
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+Any SAL_CALL VCLXSplitter::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ Any aReturn;
+ if ( GetWindow() )
+ {
+ sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
+ switch ( nPropertyId )
+ {
+ default:
+ aReturn = VCLXWindow::getProperty( PropertyName );
+ }
+ }
+ return aReturn;
+}
+
+IMPL_LINK( VCLXSplitter, HandleMovedHdl, Splitter *, pSplitter )
+{
+ (void) pSplitter;
+ forceRecalc();
+ return 0;
+}
+
+//........................................................................
+} // namespace toolkit
+//........................................................................
diff --git a/toolkit/source/awt/vclxtabcontrol.cxx b/toolkit/source/awt/vclxtabcontrol.cxx
new file mode 100644
index 000000000000..d76f2f424c24
--- /dev/null
+++ b/toolkit/source/awt/vclxtabcontrol.cxx
@@ -0,0 +1,532 @@
+#include "vclxtabcontrol.hxx"
+
+#ifndef _TOOLKIT_HELPER_PROPERTY_HXX_
+#include "toolkit/helper/property.hxx"
+#endif
+#ifndef _COM_SUN_STAR_AWT_SCROLLBARORIENTATION_HPP_
+#include <com/sun/star/awt/ScrollBarOrientation.hpp>
+#endif
+
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _SV_TABCTRL_HXX
+#include <vcl/tabctrl.hxx>
+#endif
+
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+
+#include <vcl/tabpage.hxx>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <sal/macros.h>
+
+using namespace toolkit;
+//........................................................................
+namespace layoutimpl
+{
+//........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star;
+
+class TabChildProps : public PropHelper
+{
+public:
+ TabChildProps( VCLXTabControl::ChildData *pData )
+ {
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Title" ),
+ ::getCppuType( static_cast< const rtl::OUString* >( NULL ) ),
+ &(pData->aTitle) );
+ }
+ PROPHELPER_SET_INFO
+};
+
+//====================================================================
+//= VCLXTabControl
+//====================================================================
+DBG_NAME( VCLXTabControl )
+//--------------------------------------------------------------------
+VCLXTabControl::VCLXTabControl()
+: VCLXWindow()
+ , VCLXTabControl_Base()
+ , Container()
+{
+ DBG_CTOR( VCLXTabControl, NULL );
+ mnNextTabId = 1;
+ mnChildrenNb = 0;
+}
+
+//--------------------------------------------------------------------
+VCLXTabControl::~VCLXTabControl()
+{
+ DBG_DTOR( VCLXTabControl, NULL );
+}
+
+//--------------------------------------------------------------------
+IMPLEMENT_2_FORWARD_XINTERFACE2( VCLXTabControl, VCLXWindow, Container, VCLXTabControl_Base )
+
+//--------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXTabControl, VCLXWindow, VCLXTabControl_Base )
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::dispose( ) throw(RuntimeException)
+{
+ {
+ ::vos::OGuard aGuard( GetMutex() );
+
+ EventObject aDisposeEvent;
+ aDisposeEvent.Source = *this;
+// maTabListeners.disposeAndClear( aDisposeEvent );
+ }
+
+ VCLXWindow::dispose();
+}
+/*
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::addTabListener( const Reference< XTabListener >& listener ) throw (RuntimeException)
+{
+if ( listener.is() )
+maTabListeners.addInterface( listener );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::removeTabListener( const Reference< XTabListener >& listener ) throw (RuntimeException)
+{
+if ( listener.is() )
+maTabListeners.removeInterface( listener );
+}
+*/
+
+//--------------------------------------------------------------------
+TabControl *VCLXTabControl::getTabControl() const throw (RuntimeException)
+{
+ TabControl *pTabControl = static_cast< TabControl* >( GetWindow() );
+ if ( pTabControl )
+ return pTabControl;
+ throw RuntimeException();
+}
+
+//--------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXTabControl::insertTab() throw (RuntimeException)
+{
+ TabControl *pTabControl = getTabControl();
+ int id = mnNextTabId++;
+ rtl::OUString title (RTL_CONSTASCII_USTRINGPARAM( "" ) );
+ pTabControl->InsertPage( id, title.getStr(), TAB_APPEND );
+ pTabControl->SetTabPage( id, new TabPage( pTabControl ) );
+ return id;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::removeTab( sal_Int32 ID ) throw (RuntimeException, IndexOutOfBoundsException)
+{
+ TabControl *pTabControl = getTabControl();
+ if ( pTabControl->GetTabPage( ID ) == NULL )
+ throw IndexOutOfBoundsException();
+ pTabControl->RemovePage( ID );
+}
+
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::activateTab( sal_Int32 ID ) throw (RuntimeException, IndexOutOfBoundsException)
+{
+ TabControl *pTabControl = getTabControl();
+ if ( pTabControl->GetTabPage( ID ) == NULL )
+ throw IndexOutOfBoundsException();
+ pTabControl->SelectTabPage( ID );
+}
+
+//--------------------------------------------------------------------
+sal_Int32 SAL_CALL VCLXTabControl::getActiveTabID() throw (RuntimeException)
+{
+ return getTabControl()->GetCurPageId( );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::addTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
+{
+ std::list< ::com::sun::star::uno::Reference
+ < ::com::sun::star::awt::XTabListener > >::const_iterator it;
+ for( it = mxTabListeners.begin(); it != mxTabListeners.end(); it++)
+ {
+ if ( *it == xListener )
+ // already added
+ return;
+ }
+ mxTabListeners.push_back( xListener );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::removeTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
+{
+ std::list< ::com::sun::star::uno::Reference
+ < ::com::sun::star::awt::XTabListener > >::iterator it;
+ for( it = mxTabListeners.begin(); it != mxTabListeners.end(); it++)
+ {
+ if ( *it == xListener )
+ {
+ mxTabListeners.erase( it );
+ break;
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::setTabProps( sal_Int32 ID, const Sequence< NamedValue >& Properties ) throw (RuntimeException, IndexOutOfBoundsException)
+{
+ TabControl *pTabControl = getTabControl();
+ if ( pTabControl->GetTabPage( ID ) == NULL )
+ throw IndexOutOfBoundsException();
+
+ for( int i = 0; i < Properties.getLength(); i++ )
+ {
+ const rtl::OUString &name = Properties[i].Name;
+ const Any &value = Properties[i].Value;
+
+ if ( name == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) )
+ {
+ rtl::OUString title = value.get<rtl::OUString>();
+ pTabControl->SetPageText( ID, title.getStr() );
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+Sequence< NamedValue > SAL_CALL VCLXTabControl::getTabProps( sal_Int32 ID )
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ TabControl *pTabControl = getTabControl();
+ if ( pTabControl->GetTabPage( ID ) == NULL )
+ throw IndexOutOfBoundsException();
+
+#define ADD_PROP( seq, i, name, val ) { \
+ NamedValue value; \
+ value.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( name ) ); \
+ value.Value = makeAny( val ); \
+ seq[i] = value; \
+ }
+
+ Sequence< NamedValue > props( 2 );
+ ADD_PROP( props, 0, "Title", rtl::OUString( pTabControl->GetPageText( ID ) ) );
+ ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( ID ) );
+#undef ADD_PROP
+ return props;
+}
+
+//--------------------------------------------------------------------
+
+// TODO: draw tab border here
+void SAL_CALL VCLXTabControl::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TabControl *pTabControl = getTabControl();
+ TabPage *pTabPage = pTabControl->GetTabPage( getActiveTabID() );
+ if ( pTabPage )
+ {
+ ::Point aPos( nX, nY );
+ ::Size aSize = pTabPage->GetSizePixel();
+
+ OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( GetViewGraphics() );
+ aPos = pDev->PixelToLogic( aPos );
+ aSize = pDev->PixelToLogic( aSize );
+
+ pTabPage->Draw( pDev, aPos, aSize, 0 );
+ }
+
+ VCLXWindow::draw( nX, nY );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::addChild(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains > &xChild )
+ throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::awt::MaxChildrenException)
+{
+ unsigned int id = insertTab();
+ if ( maChildren.size() < id )
+ maChildren.resize( id, 0 );
+ mnChildrenNb++;
+
+ if ( xChild.is() )
+ {
+ ChildData *pData = new ChildData();
+ pData->xChild = xChild;
+ maChildren[ id-1 ] = pData;
+
+ setChildParent( xChild );
+ queueResize();
+ }
+}
+
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::removeChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains > &xChild )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ for( unsigned i = 0; i < maChildren.size(); i++)
+ {
+ if ( maChildren[ i ] && maChildren[ i ]->xChild == xChild )
+ {
+ removeTab( i );
+ delete maChildren[ i ];
+ maChildren[ i ] = NULL;
+ mnChildrenNb--;
+
+ unsetChildParent( xChild );
+ queueResize();
+ break;
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference
+ < ::com::sun::star::awt::XLayoutConstrains > > SAL_CALL VCLXTabControl::getChildren()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Sequence< uno::Reference< awt::XLayoutConstrains > > childrenSeq( mnChildrenNb );
+ for( unsigned si = 0, ci = 0; ci < maChildren.size(); ci++)
+ {
+ if ( maChildren[ ci ] && maChildren[ ci ]->xChild.is() )
+ childrenSeq[si++] = maChildren[ ci ]->xChild;
+ }
+ return childrenSeq;
+}
+
+//--------------------------------------------------------------------
+uno::Reference< beans::XPropertySet > SAL_CALL
+VCLXTabControl::getChildProperties( const uno::Reference< awt::XLayoutConstrains >& xChild )
+ throw (uno::RuntimeException)
+{
+ std::vector< ChildData * >::iterator iter;
+ for( iter = maChildren.begin(); iter != maChildren.end(); iter++)
+ {
+ if ( (*iter)->xChild == xChild )
+ {
+ if ( !(*iter)->xProps.is() )
+ {
+ // FIXME: make me safe !
+ PropHelper *pProps = new TabChildProps( *iter );
+ pProps->setChangeListener( this );
+ (*iter)->xProps = pProps;
+ }
+ return (*iter)->xProps;
+ }
+ }
+ return uno::Reference< beans::XPropertySet >();
+}
+
+// TEMP:
+static void setChildrenVisible( uno::Reference < awt::XLayoutConstrains > xChild, bool visible )
+{
+ uno::Reference< awt::XWindow > xWin( xChild, uno::UNO_QUERY);
+ if ( xWin.is() )
+ {
+ xWin->setVisible( visible );
+//xWin->setPosSize( 0, 0, 5, 5, PosSize::POSSIZE );
+ }
+
+ uno::Reference < awt::XLayoutContainer > xCont( xChild, uno::UNO_QUERY );
+ if ( xCont.is())
+ {
+ uno::Sequence< uno::Reference < awt::XLayoutConstrains > > children = xCont->getChildren();
+ for( int i = 0; i < children.getLength(); i++ )
+ {
+ setChildrenVisible( children[i], visible );
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::allocateArea(
+ const ::com::sun::star::awt::Rectangle &rArea )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ maAllocation = rArea;
+
+ TabControl *pTabControl = getTabControl();
+
+// FIXME: this is wrong. We just want to set tab controls pos/size for the tabs menu,
+// otherwise, it gets events that should go to children (I guess we could solve this
+// by making the tabcontrol as the actual XWindow parent of its children, when importing...)
+// Not sure about TabPage drawing... That doesn't work on gtk+; just ignoring that.
+// LATER: Nah, the proper fix is to get the XWindow hierarchy straight.
+
+ setPosSize( rArea.X, rArea.Y, rArea.Width, rArea.Height, PosSize::POSSIZE );
+
+ // FIXME: we can save cycles by setting visibility more sensibly. Having
+ // it here does makes it easier when changing tabs (just needs a recalc())
+ for( unsigned int i = 0; i < maChildren.size(); i++ )
+ {
+ if ( !maChildren[ i ] )
+ continue;
+ ::com::sun::star::uno::Reference
+ < ::com::sun::star::awt::XLayoutConstrains > xChild( maChildren[ i ]->xChild );
+ if ( xChild.is() )
+ {
+ uno::Reference< awt::XWindow > xWin( xChild, uno::UNO_QUERY );
+ bool active = (i+1 == (unsigned) getActiveTabID());
+
+ // HACK: since our layout:: container don't implement XWindow, we have no easy
+ // way to set them invisible; lets just set all their children as such :P
+#if 0
+ if ( xWin.is() )
+ xWin->setVisible( active );
+#else
+ setChildrenVisible( xChild, active );
+#endif
+
+ if ( active )
+ {
+ ::Rectangle label_rect = pTabControl->GetTabBounds( i+1 );
+ ::Rectangle page_rect = pTabControl->GetTabPageBounds( i+1 );
+
+ awt::Rectangle childRect;
+ childRect.X = page_rect.Left();
+ childRect.Y = SAL_MAX( label_rect.Bottom(), page_rect.Top() );
+ childRect.Width = page_rect.Right() - page_rect.Left();
+ childRect.Height = page_rect.Bottom() - childRect.Y;
+
+ allocateChildAt( xChild, childRect );
+ }
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+::com::sun::star::awt::Size SAL_CALL VCLXTabControl::getMinimumSize()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ awt::Size size = VCLXWindow::getMinimumSize();
+ awt::Size childrenSize( 0, 0 );
+
+ TabControl* pTabControl = static_cast< TabControl* >( GetWindow() );
+ if ( !pTabControl )
+ return size;
+
+ // calculate size to accomodate all children
+ for( unsigned int i = 0; i < maChildren.size(); i++ )
+ {
+ ChildData *pChild = maChildren[ i ];
+ if ( pChild && pChild->xChild.is() )
+ {
+ // set the title prop here...
+ pTabControl->SetPageText( i+1, pChild->aTitle.getStr() );
+
+ awt::Size childSize( pChild->xChild->getMinimumSize() );
+ childrenSize.Width = SAL_MAX( childSize.Width, childrenSize.Width );
+ childrenSize.Height = SAL_MAX( childSize.Height, childrenSize.Height );
+ }
+ }
+
+ size.Width += childrenSize.Width;
+ size.Height += childrenSize.Height + 20;
+ maRequisition = size;
+ return size;
+}
+
+//--------------------------------------------------------------------
+void VCLXTabControl::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
+{
+ ::vos::OClearableGuard aGuard( GetMutex() );
+ TabControl* pTabControl = static_cast< TabControl* >( GetWindow() );
+ if ( !pTabControl )
+ return;
+
+ switch ( _rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_TABPAGE_ACTIVATE:
+ forceRecalc();
+ case VCLEVENT_TABPAGE_DEACTIVATE:
+ case VCLEVENT_TABPAGE_INSERTED:
+ case VCLEVENT_TABPAGE_REMOVED:
+ case VCLEVENT_TABPAGE_REMOVEDALL:
+ case VCLEVENT_TABPAGE_PAGETEXTCHANGED:
+ {
+ ULONG page = (ULONG) _rVclWindowEvent.GetData();
+ std::list< ::com::sun::star::uno::Reference
+ < ::com::sun::star::awt::XTabListener > >::iterator it;
+ for( it = mxTabListeners.begin(); it != mxTabListeners.end(); it++)
+ {
+ ::com::sun::star::uno::Reference
+ < ::com::sun::star::awt::XTabListener > listener = *it;
+
+ switch ( _rVclWindowEvent.GetId() )
+ {
+
+ case VCLEVENT_TABPAGE_ACTIVATE:
+ listener->activated( page );
+ break;
+ case VCLEVENT_TABPAGE_DEACTIVATE:
+ listener->deactivated( page );
+ break;
+ case VCLEVENT_TABPAGE_INSERTED:
+ listener->inserted( page );
+ break;
+ case VCLEVENT_TABPAGE_REMOVED:
+ listener->removed( page );
+ break;
+ case VCLEVENT_TABPAGE_REMOVEDALL:
+ for( int i = 1; i < mnNextTabId; i++)
+ {
+ if ( pTabControl->GetTabPage( i ) )
+ listener->removed( i );
+ }
+ break;
+ case VCLEVENT_TABPAGE_PAGETEXTCHANGED:
+ listener->changed( page, getTabProps( page ) );
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ aGuard.clear();
+ VCLXWindow::ProcessWindowEvent( _rVclWindowEvent );
+ break;
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL VCLXTabControl::setProperty( const ::rtl::OUString& PropertyName, const Any &Value ) throw(RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ if ( GetWindow() )
+ {
+ sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
+ switch ( nPropertyId )
+ {
+ default:
+ VCLXWindow::setProperty( PropertyName, Value );
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+Any SAL_CALL VCLXTabControl::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ Any aReturn;
+ if ( GetWindow() )
+ {
+ sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
+ switch ( nPropertyId )
+ {
+ default:
+ aReturn = VCLXWindow::getProperty( PropertyName );
+ }
+ }
+ return aReturn;
+}
+
+//........................................................................
+} // namespace toolkit
+//........................................................................
diff --git a/toolkit/source/layout/bin.cxx b/toolkit/source/layout/bin.cxx
new file mode 100644
index 000000000000..8f5c758d214c
--- /dev/null
+++ b/toolkit/source/layout/bin.cxx
@@ -0,0 +1,159 @@
+#include "bin.hxx"
+
+#include <sal/macros.h>
+
+namespace layoutimpl
+{
+
+using namespace css;
+
+/* Bin */
+
+Bin::Bin() : Container()
+{
+}
+
+void SAL_CALL
+Bin::addChild( const uno::Reference< awt::XLayoutConstrains >& xChild )
+ throw (uno::RuntimeException, awt::MaxChildrenException)
+{
+ if ( mxChild.is() )
+ throw awt::MaxChildrenException();
+ if ( xChild.is() )
+ {
+ mxChild = xChild;
+ setChildParent( xChild );
+ queueResize();
+ }
+}
+
+void SAL_CALL
+Bin::removeChild( const uno::Reference< awt::XLayoutConstrains >& xChild )
+ throw (uno::RuntimeException)
+{
+ if ( xChild == mxChild )
+ {
+ mxChild = uno::Reference< awt::XLayoutConstrains >();
+ unsetChildParent( xChild );
+ queueResize();
+ }
+}
+
+uno::Sequence< uno::Reference< awt::XLayoutConstrains > > SAL_CALL
+Bin::getChildren()
+ throw (uno::RuntimeException)
+{
+ return getSingleChild (mxChild);
+}
+
+void SAL_CALL
+Bin::allocateArea( const awt::Rectangle &rArea )
+ throw (uno::RuntimeException)
+{
+ maAllocation = rArea;
+ if ( mxChild.is() )
+ allocateChildAt( mxChild, rArea );
+}
+
+awt::Size SAL_CALL
+Bin::getMinimumSize()
+ throw(uno::RuntimeException)
+{
+ if ( mxChild.is() )
+ return maRequisition = maChildRequisition = mxChild->getMinimumSize();
+ return maRequisition = awt::Size( 0, 0 );
+}
+
+uno::Reference< beans::XPropertySet > SAL_CALL
+Bin::getChildProperties( const uno::Reference< awt::XLayoutConstrains >& )
+ throw (uno::RuntimeException)
+{
+ return uno::Reference< beans::XPropertySet >();
+}
+
+sal_Bool SAL_CALL
+Bin::hasHeightForWidth()
+ throw(uno::RuntimeException)
+{
+ uno::Reference< awt::XLayoutContainer > xChildCont( mxChild, uno::UNO_QUERY );
+ if ( xChildCont.is() )
+ return xChildCont->hasHeightForWidth();
+ return false;
+}
+
+sal_Int32 SAL_CALL
+Bin::getHeightForWidth( sal_Int32 nWidth )
+ throw(uno::RuntimeException)
+{
+ uno::Reference< awt::XLayoutContainer > xChildCont( mxChild, uno::UNO_QUERY );
+ if ( xChildCont.is() )
+ return xChildCont->getHeightForWidth( nWidth );
+ return maRequisition.Height;
+}
+
+/* Align */
+
+Align::Align() : Bin()
+{
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Halign" ),
+ ::getCppuType( static_cast< const float* >( NULL ) ),
+ &fHorAlign );
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Valign" ),
+ ::getCppuType( static_cast< const float* >( NULL ) ),
+ &fVerAlign );
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Hfill" ),
+ ::getCppuType( static_cast< const float* >( NULL ) ),
+ &fHorFill );
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Vfill" ),
+ ::getCppuType( static_cast< const float* >( NULL ) ),
+ &fVerFill );
+
+ fHorAlign = fVerAlign = 0.5;
+ fHorFill = fVerFill = 0;
+}
+
+void SAL_CALL
+Align::allocateArea( const awt::Rectangle &rArea )
+ throw (uno::RuntimeException)
+{
+ maAllocation = rArea;
+ if ( !mxChild.is() )
+ return;
+
+ awt::Rectangle aChildArea;
+ aChildArea.Width = SAL_MIN( rArea.Width, maChildRequisition.Width );
+ aChildArea.Width += (sal_Int32) SAL_MAX(
+ 0, (rArea.Width - maChildRequisition.Width) * fHorFill );
+ aChildArea.Height = SAL_MIN( rArea.Height, maChildRequisition.Height );
+ aChildArea.Height += (sal_Int32) SAL_MAX(
+ 0, (rArea.Height - maChildRequisition.Height) * fVerFill );
+
+ aChildArea.X = rArea.X + (sal_Int32)( (rArea.Width - aChildArea.Width) * fHorAlign );
+ aChildArea.Y = rArea.Y + (sal_Int32)( (rArea.Height - aChildArea.Height) * fVerAlign );
+
+ allocateChildAt( mxChild, aChildArea );
+}
+
+/* MinSize */
+
+MinSize::MinSize() : Bin()
+{
+ mnMinWidth = mnMinHeight = 0;
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "MinWidth" ),
+ ::getCppuType( static_cast< const long* >( NULL ) ),
+ &mnMinWidth );
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "MinHeight" ),
+ ::getCppuType( static_cast< const long* >( NULL ) ),
+ &mnMinHeight );
+}
+
+awt::Size SAL_CALL MinSize::getMinimumSize()
+ throw(uno::RuntimeException)
+{
+ Bin::getMinimumSize();
+ maRequisition.Width = SAL_MAX( maRequisition.Width, mnMinWidth );
+ maRequisition.Height = SAL_MAX( maRequisition.Height, mnMinHeight );
+ return maRequisition;
+}
+
+} // namespace layoutimpl
diff --git a/toolkit/source/layout/bin.hxx b/toolkit/source/layout/bin.hxx
new file mode 100644
index 000000000000..dbde59a95116
--- /dev/null
+++ b/toolkit/source/layout/bin.hxx
@@ -0,0 +1,89 @@
+/* A few simple binary containers */
+
+#ifndef CORE_BIN_HXX
+#define CORE_BIN_HXX
+
+#include "container.hxx"
+
+namespace layoutimpl
+{
+
+class Bin : public Container
+{
+protected:
+ // Child
+ css::awt::Size maChildRequisition;
+ css::uno::Reference< css::awt::XLayoutConstrains > mxChild;
+
+public:
+ Bin();
+ virtual ~Bin() {}
+
+ // css::awt::XLayoutContainer
+ virtual void SAL_CALL addChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException, css::awt::MaxChildrenException);
+ virtual void SAL_CALL removeChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< css::uno::Reference
+ < css::awt::XLayoutConstrains > > SAL_CALL getChildren()
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea )
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getChildProperties(
+ const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasHeightForWidth()
+ throw(css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 nWidth )
+ throw(css::uno::RuntimeException);
+
+ // css::awt::XLayoutConstrains
+ virtual css::awt::Size SAL_CALL getMinimumSize()
+ throw(css::uno::RuntimeException);
+
+ PROPHELPER_SET_INFO
+};
+
+// Align gives control over child position on the allocated space.
+class Align : public Bin
+{
+ friend class AlignChildProps;
+protected:
+ // properties
+ float fHorAlign, fVerAlign;
+ float fHorFill, fVerFill;
+
+public:
+ Align();
+
+ // css::awt::XLayoutContainer
+ virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea )
+ throw (css::uno::RuntimeException);
+
+ PROPHELPER_SET_INFO
+};
+
+// Makes child request its or a specified size, whatever is larger.
+class MinSize : public Bin
+{
+protected:
+ // properties
+ long mnMinWidth, mnMinHeight;
+
+public:
+ MinSize();
+
+ // css::awt::XLayoutContainer
+ virtual css::awt::Size SAL_CALL getMinimumSize()
+ throw(css::uno::RuntimeException);
+
+ PROPHELPER_SET_INFO
+};
+
+} // namespace layoutimpl
+
+#endif /*CORE_BIN_HXX*/
diff --git a/toolkit/source/layout/box.cxx b/toolkit/source/layout/box.cxx
new file mode 100644
index 000000000000..16519ed9d383
--- /dev/null
+++ b/toolkit/source/layout/box.cxx
@@ -0,0 +1,338 @@
+#include "box.hxx"
+
+#include <tools/debug.hxx>
+#include <sal/macros.h>
+
+// fixed point precision for distributing error
+#define FIXED_PT 16
+
+namespace layoutimpl
+{
+
+using namespace css;
+
+class BoxChildProps : public PropHelper
+{
+public:
+ BoxChildProps( Box::ChildData *pData )
+ {
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Expand" ),
+ ::getCppuType( static_cast< const sal_Bool* >( NULL ) ),
+ &(pData->bExpand) );
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Fill" ),
+ ::getCppuType( static_cast< const sal_Bool* >( NULL ) ),
+ &(pData->bFill) );
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Padding" ),
+ ::getCppuType( static_cast< const sal_Int32* >( NULL ) ),
+ &(pData->nPadding) );
+ }
+ PROPHELPER_SET_INFO
+};
+
+bool Box::ChildData::isVisible()
+{
+ // FIXME: call the 'isVisible' method on it ?
+ if ( !xChild.is() )
+ {
+ DBG_ERROR( "FIXME: invalid child !" );
+ }
+ return xChild.is();
+}
+
+Box::Box( bool horizontal )
+ : Container()
+ , mnSpacing( 0 )
+ , mbHomogeneous( false )
+ , mbHorizontal( horizontal )
+{
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Homogeneous" ),
+ ::getCppuType( static_cast< const sal_Bool* >( NULL ) ),
+ &mbHomogeneous );
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Spacing" ),
+ ::getCppuType( static_cast< const sal_Int32* >( NULL ) ),
+ &mnSpacing );
+ mbHasFlowChildren = false;
+}
+
+Box::ChildData *
+Box::createChild( uno::Reference< awt::XLayoutConstrains > const& xChild )
+{
+ ChildData *p = new ChildData();
+
+ p->nPadding = 0;
+ p->bExpand = true;
+ p->bFill = true;
+ p->xChild = xChild;
+ return p;
+}
+
+void SAL_CALL
+Box::addChild( const uno::Reference< awt::XLayoutConstrains >& xChild )
+ throw (uno::RuntimeException, awt::MaxChildrenException)
+{
+ if ( xChild.is() )
+ {
+ ChildData *pData = createChild( xChild );
+ maChildren.push_back( pData );
+ setChildParent( xChild );
+ queueResize();
+ }
+}
+
+Box::ChildData *
+Box::removeChildData( std::list< ChildData *> lst, css::uno::Reference< css::awt::XLayoutConstrains > const& xChild )
+{
+ for( std::list< ChildData * >::iterator it = lst.begin();
+ it != lst.end(); it++ )
+ {
+ if ( (*it)->xChild == xChild )
+ {
+ lst.erase( it );
+ return *it;
+ }
+ }
+ return 0;
+}
+
+void SAL_CALL
+Box::removeChild( const uno::Reference< awt::XLayoutConstrains >& xChild )
+ throw (uno::RuntimeException)
+{
+ if ( ChildData *p = removeChildData( maChildren, xChild ) )
+ {
+ // CHECK: BoxChildProps leaks?
+ delete p;
+ unsetChildParent( xChild );
+ queueResize();
+ }
+ else
+ {
+ DBG_ERROR( "Box: removeChild: no such child" );
+ }
+}
+
+uno::Sequence< uno::Reference < awt::XLayoutConstrains > > SAL_CALL
+Box::getChildren()
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< uno::Reference< awt::XLayoutConstrains > > children( maChildren.size() );
+ unsigned int i = 0;
+ for( std::list< ChildData * >::iterator it = maChildren.begin();
+ it != maChildren.end(); it++, i++ )
+ children[i] = (*it)->xChild;
+
+ return children;
+}
+
+uno::Reference< beans::XPropertySet > SAL_CALL
+Box::getChildProperties( const uno::Reference< awt::XLayoutConstrains >& xChild )
+ throw (uno::RuntimeException)
+{
+ std::list< ChildData * >::iterator iter;
+ for( iter = maChildren.begin(); iter != maChildren.end(); iter++)
+ {
+ if ( (*iter)->xChild == xChild )
+ {
+ if ( !(*iter)->xProps.is() )
+ {
+ // FIXME: make me safe !
+ PropHelper *pProps = new BoxChildProps( *iter );
+ pProps->setChangeListener( this );
+ (*iter)->xProps = pProps;
+ }
+ return (*iter)->xProps;
+ }
+ }
+ return uno::Reference< beans::XPropertySet >();
+}
+
+awt::Size
+Box::calculateSize( long nWidth )
+{
+ int nVisibleChildren = 0;
+ // primary vs secundary axis (instead of a X and Y)
+ int nPrimSize = 0, nSecSize = 0;
+ int nFlowMinWidth = 0; // in case the box only has flow children
+
+ mbHasFlowChildren = false;
+
+ std::list<ChildData *>::const_iterator it;
+ for( it = maChildren.begin(); it != maChildren.end(); it++ )
+ {
+ ChildData *child = *it;
+ if ( !child->isVisible() )
+ continue;
+
+ uno::Reference< awt::XLayoutContainer > xChildCont( child->xChild, uno::UNO_QUERY );
+ bool bFlow = xChildCont.is() && xChildCont->hasHeightForWidth();
+
+ awt::Size aChildSize = child->aRequisition = child->xChild->getMinimumSize();
+
+ if ( !mbHorizontal /*vertical*/ && bFlow )
+ {
+ if ( nFlowMinWidth == 0 || nFlowMinWidth > aChildSize.Width )
+ nFlowMinWidth = aChildSize.Width;
+ mbHasFlowChildren = true;
+ }
+ else
+ {
+ int size = primDim( aChildSize ) + child->nPadding * 2;
+ if ( mbHomogeneous )
+ nPrimSize = SAL_MAX( nPrimSize, size );
+ else
+ nPrimSize += size;
+
+ nSecSize = SAL_MAX( nSecSize, secDim( aChildSize ) );
+ }
+ nVisibleChildren++;
+ }
+
+ if ( nVisibleChildren )
+ {
+ if ( mbHomogeneous )
+ nPrimSize *= nVisibleChildren;
+ nPrimSize += (nVisibleChildren - 1) * mnSpacing;
+ }
+
+ if ( mbHasFlowChildren )
+ {
+ if ( nWidth == 0 )
+ nWidth = nSecSize ? nSecSize : nFlowMinWidth;
+ for( it = maChildren.begin(); it != maChildren.end(); it++ )
+ {
+ ChildData *child = *it;
+ if ( !child->isVisible() )
+ continue;
+
+ uno::Reference< awt::XLayoutContainer > xChildCont( child->xChild, uno::UNO_QUERY );
+ bool bFlow = xChildCont.is() && xChildCont->hasHeightForWidth();
+
+ if ( bFlow )
+ nPrimSize += xChildCont->getHeightForWidth( nWidth );
+ }
+ }
+
+ nPrimSize += mnBorderWidth * 2;
+ nSecSize += mnBorderWidth * 2;
+ return awt::Size( mbHorizontal ? nPrimSize : nSecSize,
+ mbHorizontal ? nSecSize : nPrimSize );
+}
+
+awt::Size SAL_CALL
+Box::getMinimumSize() throw(uno::RuntimeException)
+{
+ maRequisition = calculateSize();
+ return maRequisition;
+}
+
+sal_Bool SAL_CALL
+Box::hasHeightForWidth()
+ throw(uno::RuntimeException)
+{
+ return mbHasFlowChildren;
+}
+
+sal_Int32 SAL_CALL
+Box::getHeightForWidth( sal_Int32 nWidth )
+ throw(uno::RuntimeException)
+{
+ if ( hasHeightForWidth() )
+ return calculateSize( nWidth ).Height;
+ return maRequisition.Height;
+}
+
+void SAL_CALL
+Box::allocateArea( const awt::Rectangle &newArea )
+ throw (uno::RuntimeException)
+{
+ maAllocation = newArea;
+ int nVisibleChildren = 0, nExpandChildren = 0;
+
+ std::list<ChildData *>::const_iterator it;
+ for( it = maChildren.begin(); it != maChildren.end(); it++ )
+ {
+ ChildData *child = *it;
+ if ( child->isVisible() )
+ {
+ nVisibleChildren++;
+ if ( child->bExpand )
+ nExpandChildren++;
+ }
+ }
+ if ( !nVisibleChildren )
+ return;
+
+ // split rectangle for dimension helpers
+ awt::Point newPoint( newArea.X, newArea.Y );
+ awt::Size newSize( newArea.Width, newArea.Height );
+
+ int nExtraSpace;
+ if ( mbHomogeneous )
+ nExtraSpace = ( ( primDim( newSize ) - mnBorderWidth * 2 -
+ ( nVisibleChildren - 1 ) * mnSpacing )) / nVisibleChildren;
+ else if ( nExpandChildren )
+ {
+ int reqSize = primDim( maRequisition );
+ if ( !mbHorizontal && hasHeightForWidth() )
+ reqSize = getHeightForWidth( newArea.Width );
+ nExtraSpace = ( primDim( newSize ) - reqSize ) / nExpandChildren;
+ }
+ else
+ nExtraSpace = 0;
+
+ int nChildPrimPoint, nChildSecPoint, nChildPrimSize, nChildSecSize;
+
+ int nStartPoint = primDim( newPoint ) + mnBorderWidth;
+ int nBoxSecSize = SAL_MAX( 1, secDim( newSize ) - mnBorderWidth * 2 );
+
+ for( it = maChildren.begin(); it != maChildren.end(); it++ )
+ {
+ ChildData *child = *it;
+ if ( !child->isVisible() )
+ continue;
+
+ awt::Point aChildPos;
+ int nBoxPrimSize; // of the available box space
+
+ if ( mbHomogeneous )
+ nBoxPrimSize = nExtraSpace;
+ else
+ {
+ uno::Reference< awt::XLayoutContainer > xChildCont( child->xChild, uno::UNO_QUERY );
+ bool bFlow = xChildCont.is() && xChildCont->hasHeightForWidth();
+ if ( !mbHorizontal && bFlow )
+ nBoxPrimSize = xChildCont->getHeightForWidth( newArea.Width );
+ else
+ nBoxPrimSize = primDim( child->aRequisition );
+ nBoxPrimSize += child->nPadding;
+ if ( child->bExpand )
+ nBoxPrimSize += nExtraSpace;
+ }
+
+ nChildPrimPoint = nStartPoint + child->nPadding;
+ nChildSecPoint = secDim( newPoint ) + mnBorderWidth;
+
+ nChildSecSize = nBoxSecSize;
+ if ( child->bFill )
+ nChildPrimSize = SAL_MAX( 1, nBoxPrimSize - child->nPadding);
+ else
+ {
+ nChildPrimSize = primDim( child->aRequisition );
+ nChildPrimPoint += (nBoxPrimSize - nChildPrimSize) / 2;
+
+ nChildSecPoint += (nBoxSecSize - nChildSecSize) / 2;
+ }
+
+ awt::Rectangle area;
+ area.X = mbHorizontal ? nChildPrimPoint : nChildSecPoint;
+ area.Y = mbHorizontal ? nChildSecPoint : nChildPrimPoint;
+ area.Width = mbHorizontal ? nChildPrimSize : nChildSecSize;
+ area.Height = mbHorizontal ? nChildSecSize : nChildPrimSize;
+
+ allocateChildAt( child->xChild, area );
+
+ nStartPoint += nBoxPrimSize + mnSpacing + child->nPadding;
+ }
+}
+
+} // namespace layoutimpl
diff --git a/toolkit/source/layout/box.hxx b/toolkit/source/layout/box.hxx
new file mode 100644
index 000000000000..967d9824bfa9
--- /dev/null
+++ b/toolkit/source/layout/box.hxx
@@ -0,0 +1,91 @@
+#ifndef CORE_BOX_HXX
+#define CORE_BOX_HXX
+
+#include "container.hxx"
+
+#include <com/sun/star/awt/Point.hpp>
+
+#include <list>
+
+namespace layoutimpl
+{
+
+class Box : public Container
+{
+ friend class BoxChildProps;
+protected:
+ // Box properties (i.e. affect all children)
+ sal_Int32 mnSpacing;
+ sal_Bool mbHomogeneous;
+ sal_Bool mbHorizontal; // false for Vertical
+
+ // Children properties
+ struct ChildData
+ {
+ sal_Int32 nPadding;
+ sal_Bool bExpand, bFill;
+ css::awt::Size aRequisition;
+ css::uno::Reference< css::awt::XLayoutConstrains > xChild;
+ css::uno::Reference< css::beans::XPropertySet > xProps;
+ bool isVisible();
+ };
+ std::list< ChildData * > maChildren;
+ bool mbHasFlowChildren;
+
+public:
+ Box( bool horizontal );
+
+ static ChildData *createChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild );
+
+ ChildData *removeChildData( std::list< ChildData *>, css::uno::Reference< css::awt::XLayoutConstrains > const& Child );
+
+ // css::awt::XLayoutContainer
+ virtual void SAL_CALL addChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException, css::awt::MaxChildrenException);
+ virtual void SAL_CALL removeChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< css::uno::Reference
+ < css::awt::XLayoutConstrains > > SAL_CALL getChildren()
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getChildProperties(
+ const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea )
+ throw (css::uno::RuntimeException);
+
+ virtual css::awt::Size SAL_CALL getMinimumSize()
+ throw(css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasHeightForWidth()
+ throw(css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 nWidth )
+ throw(css::uno::RuntimeException);
+
+ // helper: mix of getMinimumSize() and getHeightForWidth()
+ css::awt::Size calculateSize( long nWidth = 0 );
+
+ PROPHELPER_SET_INFO
+
+private:
+ /* Helpers to deal with the joint Box directions. */
+ inline int primDim (const css::awt::Size &size)
+ { if (mbHorizontal) return size.Width; else return size.Height; }
+ inline int secDim (const css::awt::Size &size)
+ { if (mbHorizontal) return size.Height; else return size.Width; }
+ inline int primDim (const css::awt::Point &point)
+ { if (mbHorizontal) return point.X; else return point.Y; }
+ inline int secDim (const css::awt::Point &point)
+ { if (mbHorizontal) return point.Y; else return point.X; }
+};
+
+struct VBox : public Box
+{ VBox() : Box (false) {} };
+
+struct HBox : public Box
+{ HBox() : Box (true) {} };
+
+} // namespace layoutimpl
+
+#endif /*CORE_BOX_HXX*/
diff --git a/toolkit/source/layout/container.cxx b/toolkit/source/layout/container.cxx
new file mode 100644
index 000000000000..6ab4c55254b9
--- /dev/null
+++ b/toolkit/source/layout/container.cxx
@@ -0,0 +1,141 @@
+#include "container.hxx"
+
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <tools/debug.hxx>
+
+namespace layoutimpl {
+
+using namespace css;
+
+Container::Container()
+ : Container_Base()
+ , PropHelper()
+ , mnBorderWidth( 0 )
+{
+ addProp( RTL_CONSTASCII_USTRINGPARAM( "Border" ),
+ ::getCppuType( static_cast< const sal_Int32* >( NULL ) ),
+ &mnBorderWidth );
+ setChangeListener( this );
+}
+
+uno::Any
+Container::queryInterface( const uno::Type & rType ) throw (uno::RuntimeException)
+{
+ uno::Any aRet = Container_Base::queryInterface( rType );
+ return aRet.hasValue() ? aRet : PropHelper::queryInterface( rType );
+}
+
+void
+Container::allocateChildAt( const uno::Reference< awt::XLayoutConstrains > &xChild,
+ const awt::Rectangle &rArea )
+ throw( uno::RuntimeException )
+{
+ uno::Reference< awt::XLayoutContainer > xCont( xChild, uno::UNO_QUERY );
+ if ( xCont.is() )
+ xCont->allocateArea( rArea );
+ else
+ {
+ uno::Reference< awt::XWindow > xWindow( xChild, uno::UNO_QUERY );
+ if ( xWindow.is() )
+ xWindow->setPosSize( rArea.X, rArea.Y, rArea.Width, rArea.Height,
+ awt::PosSize::POSSIZE );
+ else
+ {
+ DBG_ERROR( "Error: non-sizeable child" );
+ }
+ }
+}
+
+uno::Sequence< uno::Reference< awt::XLayoutConstrains > >
+Container::getSingleChild ( uno::Reference< awt::XLayoutConstrains >const &xChildOrNil )
+{
+ uno::Sequence< uno::Reference< awt::XLayoutConstrains > > aSeq( ( xChildOrNil.is() ? 1 : 0 ) );
+ if ( xChildOrNil.is() )
+ aSeq[0] = xChildOrNil;
+ return aSeq;
+}
+
+void
+Container::queueResize()
+{
+ if ( mxLayoutUnit.is() )
+ mxLayoutUnit->queueResize( uno::Reference< awt::XLayoutContainer >( this ) );
+}
+
+void
+Container::setChildParent( const uno::Reference< awt::XLayoutConstrains >& xChild )
+{
+ uno::Reference< awt::XLayoutContainer > xContChild( xChild, uno::UNO_QUERY );
+ if ( xContChild.is() )
+ {
+ xContChild->setParent( uno::Reference< awt::XLayoutContainer >( this ) );
+#if 0
+ assert( !mxLayoutUnit.is() );
+ xContChild->setLayoutUnit( mxLayoutUnit );
+#endif
+ }
+}
+
+void
+Container::unsetChildParent( const uno::Reference< awt::XLayoutConstrains >& xChild )
+{
+ uno::Reference< awt::XLayoutContainer > xContChild( xChild, uno::UNO_QUERY );
+ if ( xContChild.is() )
+ {
+ xContChild->setParent( uno::Reference< awt::XLayoutContainer >() );
+#if 0
+ xContChild->setLayoutUnit( uno::Reference< awt::XLayoutUnit >() );
+#endif
+ }
+}
+
+#if 0
+std::string
+Container::getLabel() // debug label
+{
+ std::string depth;
+ uno::Reference< awt::XLayoutContainer > xContainer( this );
+ while ( xContainer.is() )
+ {
+ int node = 0; // child nb
+ uno::Reference< awt::XLayoutContainer > xParent = xContainer->getContainerParent();
+ if ( xParent.is() )
+ {
+
+ uno::Sequence< uno::Reference< awt::XLayoutConstrains > > aChildren;
+ aChildren = xParent->getChildren();
+ for( node = 0; node < aChildren.getLength(); node++ )
+ if ( aChildren[ node ] == xContainer )
+ break;
+ }
+
+ char str[ 8 ];
+ snprintf( str, 8, "%d", node );
+ if ( depth.empty() )
+ depth = std::string( str );
+ else
+ depth = std::string( str ) + ":" + depth;
+
+ xContainer = xParent;
+ }
+
+ return std::string( getName() ) + " (" + depth + ")";
+}
+#endif
+
+void Container::propertiesChanged()
+{
+ if ( !mxParent.is() )
+ {
+ DBG_ERROR( "Properties listener: error container doesn't have parent" );
+ }
+
+ // ask parent to be re-calculated
+// FIXME: thats wrongg actually. We just need to do a "queueResize();"
+
+ if ( mxLayoutUnit.is() && mxParent.is() )
+ mxLayoutUnit->queueResize( mxParent );
+}
+
+}
diff --git a/toolkit/source/layout/container.hxx b/toolkit/source/layout/container.hxx
new file mode 100644
index 000000000000..362050ac66cc
--- /dev/null
+++ b/toolkit/source/layout/container.hxx
@@ -0,0 +1,109 @@
+#ifndef CORE_CONTAINER_HXX
+#define CORE_CONTAINER_HXX
+
+#include "helper.hxx"
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/awt/MaxChildrenException.hpp>
+
+namespace layoutimpl
+{
+namespace css = ::com::sun::star;
+
+typedef ::cppu::WeakImplHelper2< css::awt::XLayoutContainer,
+ css::awt::XLayoutConstrains > Container_Base;
+
+class Container : public Container_Base, public PropHelper, public PropHelper::Listener
+{
+ friend class ChildProps;
+protected:
+ // Widget properties
+ css::uno::Reference< css::awt::XLayoutContainer > mxParent;
+ css::uno::Reference< css::awt::XLayoutUnit > mxLayoutUnit;
+ css::awt::Size maRequisition;
+ css::awt::Rectangle maAllocation;
+
+ // Container properties
+ sal_Int32 mnBorderWidth;
+
+ // Utilities
+ void allocateChildAt( const css::uno::Reference< css::awt::XLayoutConstrains > &xChild,
+ const css::awt::Rectangle &rArea )
+ throw (css::uno::RuntimeException);
+ static css::uno::Sequence< css::uno::Reference< css::awt::XLayoutConstrains > >
+ getSingleChild (const css::uno::Reference< css::awt::XLayoutConstrains > &xChildOrNil);
+ void setChildParent( const css::uno::Reference< css::awt::XLayoutConstrains >& xChild );
+ void unsetChildParent( const css::uno::Reference< css::awt::XLayoutConstrains >& xChild );
+
+ void queueResize();
+ void forceRecalc() { allocateArea( maAllocation ); }
+
+public:
+ Container();
+ virtual ~Container() {}
+
+ // XInterface
+ virtual void SAL_CALL acquire() throw() { PropHelper::acquire(); }
+ virtual void SAL_CALL release() throw() { PropHelper::release(); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+
+ // css::awt::XLayoutContainer
+ virtual void SAL_CALL addChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException, css::awt::MaxChildrenException) = 0;
+ virtual void SAL_CALL removeChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException) = 0;
+
+ virtual css::uno::Sequence< css::uno::Reference
+ < css::awt::XLayoutConstrains > > SAL_CALL getChildren()
+ throw (css::uno::RuntimeException) = 0;
+
+ virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getChildProperties(
+ const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
+ throw (css::uno::RuntimeException) = 0;
+
+ virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea )
+ throw (css::uno::RuntimeException) = 0;
+
+ void SAL_CALL setLayoutUnit( const css::uno::Reference< css::awt::XLayoutUnit > &xUnit )
+ throw(css::uno::RuntimeException)
+ { mxLayoutUnit = xUnit; }
+ css::uno::Reference< css::awt::XLayoutUnit > SAL_CALL getLayoutUnit()
+ throw(css::uno::RuntimeException)
+ { return mxLayoutUnit; }
+
+ css::awt::Size SAL_CALL getRequestedSize() throw(css::uno::RuntimeException)
+ { return maRequisition; }
+ com::sun::star::awt::Rectangle SAL_CALL getAllocatedArea() throw(css::uno::RuntimeException)
+ { return maAllocation; }
+
+ virtual sal_Bool SAL_CALL hasHeightForWidth()
+ throw(css::uno::RuntimeException) = 0;
+ virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 nWidth )
+ throw(css::uno::RuntimeException) = 0;
+
+ // css::awt::XLayoutContainer: css::container::XChild
+ css::uno::Reference< css::uno::XInterface > SAL_CALL getParent()
+ throw (css::uno::RuntimeException)
+ { return mxParent; }
+ void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface > &xParent )
+ throw (css::uno::RuntimeException)
+ { mxParent = css::uno::Reference< css::awt::XLayoutContainer >( xParent, css::uno::UNO_QUERY ); }
+
+ // css::awt::XLayoutConstrains
+ virtual css::awt::Size SAL_CALL getMinimumSize()
+ throw(css::uno::RuntimeException) = 0;
+ // (not properly implemented in toolkit, ignore it.)
+ css::awt::Size SAL_CALL getPreferredSize()
+ throw(css::uno::RuntimeException) { return getMinimumSize(); } // TODO: use this for flow?
+ css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize )
+ throw(css::uno::RuntimeException) { return rNewSize; }
+
+PROPHELPER_SET_INFO
+
+protected:
+ void propertiesChanged();
+};
+
+} // namespace layoutimpl
+
+#endif /*CORE_CONTAINER_HXX*/
diff --git a/toolkit/source/layout/dialogbuttonhbox.cxx b/toolkit/source/layout/dialogbuttonhbox.cxx
new file mode 100644
index 000000000000..95723c20df79
--- /dev/null
+++ b/toolkit/source/layout/dialogbuttonhbox.cxx
@@ -0,0 +1,264 @@
+#include "dialogbuttonhbox.hxx"
+
+#include <tools/debug.hxx>
+#include <toolkit/awt/vclxwindows.hxx>
+#include <vcl/button.hxx>
+
+#include "flow.hxx"
+#include "../awt/vclxbutton.hxx"
+#include "proplist.hxx"
+
+#if TEST_LAYOUT && !defined( DBG_UTIL )
+#include <stdio.h>
+#undef DBG_ERROR
+#define DBG_ERROR printf
+#undef DBG_ERROR1
+#define DBG_ERROR1 printf
+#undef DBG_ERROR2
+#define DBG_ERROR2 printf
+#endif /* TEST_LAYOUT && !DBG_UTIL */
+
+namespace layoutimpl
+{
+
+using namespace css;
+
+//FIXME: how to set platform-dependant variables?
+DialogButtonHBox::Ordering const DialogButtonHBox::DEFAULT_ORDERING =
+#if defined( MACOSX )
+ DialogButtonHBox::MacOS;
+#elif defined( SAL_W32 )
+DialogButtonHBox::WINDOWS;
+#elif defined( ENABLE_KDE )
+DialogButtonHBox::KDE;
+#else /* !MACOSX && !SAL_W32 && !ENABLE_KDE */
+DialogButtonHBox::GNOME;
+#endif /* !MACOSX && !SAL_W32 && !ENABLE_KDE */
+
+DialogButtonHBox::DialogButtonHBox()
+ : HBox()
+ , mnOrdering( DEFAULT_ORDERING )
+ , mFlow()
+ , mpAction( 0 )
+ , mpAffirmative( 0 )
+ , mpAlternate( 0 )
+ , mpApply( 0 )
+ , mpCancel( 0 )
+ , mpFlow( createChild( uno::Reference< awt::XLayoutConstrains > ( &mFlow ) ) )
+ , mpHelp( 0 )
+ , mpReset( 0 )
+{
+ mbHomogeneous = true;
+}
+
+void
+DialogButtonHBox::setOrdering( rtl::OUString const& ordering )
+{
+ if ( ordering.equalsIgnoreAsciiCaseAscii( "GNOME" ) )
+ mnOrdering = GNOME;
+ else if ( ordering.equalsIgnoreAsciiCaseAscii( "KDE" ) )
+ mnOrdering = KDE;
+ else if ( ordering.equalsIgnoreAsciiCaseAscii( "MacOS" ) )
+ mnOrdering = MACOS;
+ else if ( ordering.equalsIgnoreAsciiCaseAscii( "Windows" ) )
+ mnOrdering = WINDOWS;
+ else
+ {
+ DBG_ERROR1( "DialogButtonHBox: no such ordering: %s", OUSTRING_CSTR( ordering ) );
+ }
+}
+
+void
+DialogButtonHBox::addChild( uno::Reference< awt::XLayoutConstrains > const& xChild )
+ throw ( uno::RuntimeException, awt::MaxChildrenException )
+{
+ if ( !xChild.is() )
+ return;
+
+ ChildData *p = createChild( xChild );
+
+#define IS_BUTTON(t) dynamic_cast<VCLX##t##Button *>( xChild.get () )
+
+ /* Sort Retry as Action */
+ if ( !mpAction && IS_BUTTON( Retry ) )
+ mpAction = p;
+ else if ( !mpAffirmative && IS_BUTTON( OK ) )
+ mpAffirmative = p;
+ else if ( !mpAffirmative && IS_BUTTON( Yes ) )
+ mpAffirmative = p;
+ else if ( !mpAlternate && IS_BUTTON( No ) )
+ mpAlternate = p;
+ /* Sort Ignore as Alternate */
+ else if ( !mpAlternate && IS_BUTTON( Ignore ) )
+ mpAlternate = p;
+ else if ( !mpApply && IS_BUTTON( Apply ) )
+ mpApply = p;
+ else if ( !mpCancel && IS_BUTTON( Cancel ) )
+ mpCancel = p;
+ /* Let the user overwrite Flow */
+ else if ( /* !mpFlow && */ dynamic_cast<Flow *>( xChild.get () ) )
+ mpFlow = p;
+ else if ( !mpHelp && IS_BUTTON( Help ) )
+ mpHelp = p;
+ else if ( !mpReset && IS_BUTTON( Reset ) )
+ mpReset = p;
+ else
+ maOther.push_back( p );
+ orderChildren();
+ setChildParent( xChild );
+ queueResize();
+}
+
+void
+DialogButtonHBox::orderChildren()
+{
+ if ( mnOrdering == WINDOWS )
+ windowsOrdering();
+ else if ( mnOrdering == MACOS )
+ macosOrdering();
+ else if ( mnOrdering == KDE )
+ kdeOrdering();
+ else if ( 1 || mnOrdering == GNOME )
+ gnomeOrdering();
+}
+
+void SAL_CALL
+DialogButtonHBox::removeChild( uno::Reference< awt::XLayoutConstrains > const& xChild )
+ throw ( uno::RuntimeException)
+{
+ if ( !xChild.is ())
+ return;
+
+ ChildData *p = 0;
+
+ if ( mpAction && mpAction->xChild == xChild )
+ p = mpAction;
+ else if ( mpAffirmative && mpAffirmative->xChild == xChild )
+ p = mpAffirmative;
+ else if ( mpAlternate && mpAlternate->xChild == xChild )
+ p = mpAlternate;
+ else if ( mpApply && mpApply->xChild == xChild )
+ p = mpApply;
+ else if ( mpCancel && mpCancel->xChild == xChild )
+ p = mpCancel;
+ else if ( mpFlow && mpFlow->xChild == xChild )
+ p = mpFlow;
+ else if ( mpReset && mpReset->xChild == xChild )
+ p = mpReset;
+ else if ( mpHelp && mpHelp->xChild == xChild )
+ p = mpHelp;
+ else
+ p = removeChildData( maOther, xChild );
+
+ if ( p )
+ {
+ delete p;
+ unsetChildParent( xChild );
+ orderChildren();
+ queueResize();
+ }
+ else
+ {
+ DBG_ERROR( "DialogButtonHBox: removeChild: no such child" );
+ }
+}
+
+void
+DialogButtonHBox::gnomeOrdering()
+{
+ std::list< ChildData * > ordered;
+ if ( mpHelp )
+ ordered.push_back( mpHelp );
+ if ( mpReset )
+ ordered.push_back( mpReset );
+ if ( mpFlow && ( mpHelp || mpReset ) )
+ ordered.push_back( mpFlow );
+ ordered.insert( ordered.end(), maOther.begin(), maOther.end() );
+ if ( mpAction )
+ ordered.push_back( mpAction );
+ if ( mpApply )
+ ordered.push_back( mpApply );
+ if ( mpAlternate )
+ ordered.push_back( mpAlternate );
+ if ( mpCancel )
+ ordered.push_back( mpCancel );
+ if ( mpAffirmative )
+ ordered.push_back( mpAffirmative );
+ maChildren = ordered;
+}
+
+void
+DialogButtonHBox::kdeOrdering()
+{
+ std::list< ChildData * > ordered;
+ if ( mpHelp )
+ ordered.push_back( mpHelp );
+ if ( mpReset )
+ ordered.push_back( mpReset );
+ if ( mpFlow && ( mpHelp || mpReset ) )
+ ordered.push_back( mpFlow );
+ ordered.insert( ordered.end(), maOther.begin(), maOther.end() );
+ if ( mpAction )
+ ordered.push_back( mpAction );
+ if ( mpAffirmative )
+ ordered.push_back( mpAffirmative );
+ if ( mpApply )
+ ordered.push_back( mpApply );
+ if ( mpAlternate )
+ ordered.push_back( mpAlternate );
+ if ( mpCancel )
+ ordered.push_back( mpCancel );
+ maChildren = ordered;
+}
+
+void
+DialogButtonHBox::macosOrdering()
+{
+ std::list< ChildData * > ordered;
+ if ( mpHelp )
+ ordered.push_back( mpHelp );
+ if ( mpReset )
+ ordered.push_back( mpReset );
+ if ( mpApply )
+ ordered.push_back( mpApply );
+ if ( mpAction )
+ ordered.push_back( mpAction );
+ ordered.insert( ordered.end(), maOther.begin(), maOther.end() );
+ if ( mpFlow ) // Always flow? && ( maOther.size () || mpHelp || mpReset || mpAction ) )
+ ordered.push_back( mpFlow );
+ if ( mpAlternate )
+ ordered.push_back( mpAlternate );
+ if ( mpFlow && mpAlternate )
+ ordered.push_back( mpFlow );
+ if ( mpCancel )
+ ordered.push_back( mpCancel );
+ if ( mpAffirmative )
+ ordered.push_back( mpAffirmative );
+ maChildren = ordered;
+}
+
+void
+DialogButtonHBox::windowsOrdering()
+{
+ std::list< ChildData * > ordered;
+ if ( mpReset )
+ ordered.push_back( mpReset );
+ if ( mpReset && mpFlow )
+ ordered.push_back( mpFlow );
+ if ( mpAffirmative )
+ ordered.push_back( mpAffirmative );
+ if ( mpAlternate )
+ ordered.push_back( mpAlternate );
+ if ( mpAction )
+ ordered.push_back( mpAction );
+ if ( mpCancel )
+ ordered.push_back( mpCancel );
+ if ( mpApply )
+ ordered.push_back( mpApply );
+ ordered.insert( ordered.end(), maOther.begin(), maOther.end() );
+ if ( mpHelp )
+ ordered.push_back( mpHelp );
+ maChildren = ordered;
+}
+
+} // namespace layoutimpl
diff --git a/toolkit/source/layout/dialogbuttonhbox.hxx b/toolkit/source/layout/dialogbuttonhbox.hxx
new file mode 100644
index 000000000000..debbefab5beb
--- /dev/null
+++ b/toolkit/source/layout/dialogbuttonhbox.hxx
@@ -0,0 +1,46 @@
+#ifndef CORE_DIALOGBUTTONHBOX_HXX
+#define CORE_DIALOGBUTTONHBOX_HXX
+
+#include "box.hxx"
+#include "flow.hxx"
+
+namespace layoutimpl
+{
+
+class DialogButtonHBox : public HBox
+{
+public:
+ DialogButtonHBox();
+
+ void setOrdering( rtl::OUString const& ordering );
+ void SAL_CALL addChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ) throw ( css::uno::RuntimeException, css::awt::MaxChildrenException );
+ void SAL_CALL removeChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ) throw ( css::uno::RuntimeException );
+
+private:
+ enum Ordering { PLATFORM, GNOME, KDE, MACOS, WINDOWS };
+
+ void orderChildren();
+ void gnomeOrdering();
+ void kdeOrdering();
+ void macosOrdering();
+ void windowsOrdering();
+
+ static Ordering const DEFAULT_ORDERING;
+ Ordering mnOrdering;
+ Flow mFlow;
+
+ ChildData *mpAction; /* [..]?, [Retry?] */
+ ChildData *mpAffirmative; /* OK, Yes, Save */
+ ChildData *mpAlternate; /* NO, [Ignore?], Don't save, Quit without saving */
+ ChildData *mpApply; /* Deprecated? */
+ ChildData *mpCancel; /* Cancel, Close */
+ ChildData *mpFlow;
+ ChildData *mpHelp;
+ ChildData *mpReset;
+
+ std::list< ChildData *> maOther;
+};
+
+} // namespace layoutimpl
+
+#endif /* CORE_DIALOGBUTTONHBOX_HXX */