diff options
-rw-r--r-- | svtools/inc/svtools/toolpanel/decklayouter.hxx | 66 | ||||
-rw-r--r-- | svtools/inc/svtools/toolpanel/tablayouter.hxx | 66 | ||||
-rw-r--r-- | svtools/inc/svtools/toolpanel/toolpanel.hxx | 65 | ||||
-rw-r--r-- | svtools/inc/svtools/toolpanel/toolpanelcollection.hxx | 63 | ||||
-rw-r--r-- | svtools/inc/svtools/toolpanel/toolpaneldeck.hxx | 76 | ||||
-rw-r--r-- | svtools/prj/build.lst | 4 | ||||
-rw-r--r-- | svtools/source/toolpanel/dummypanel.cxx | 66 | ||||
-rw-r--r-- | svtools/source/toolpanel/dummypanel.hxx | 57 | ||||
-rw-r--r-- | svtools/source/toolpanel/makefile.mk | 57 | ||||
-rw-r--r-- | svtools/source/toolpanel/tablayouter.cxx | 70 | ||||
-rw-r--r-- | svtools/source/toolpanel/toolpanelcollection.cxx | 94 | ||||
-rw-r--r-- | svtools/source/toolpanel/toolpaneldeck.cxx | 222 | ||||
-rw-r--r-- | svtools/workben/toolpanel/makefile.mk | 107 | ||||
-rw-r--r-- | svtools/workben/toolpanel/toolpaneltest.cxx | 225 |
14 files changed, 1237 insertions, 1 deletions
diff --git a/svtools/inc/svtools/toolpanel/decklayouter.hxx b/svtools/inc/svtools/toolpanel/decklayouter.hxx new file mode 100644 index 000000000000..b6e27162a29c --- /dev/null +++ b/svtools/inc/svtools/toolpanel/decklayouter.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * 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 DECKLAYOUTER_HXX +#define DECKLAYOUTER_HXX + +#include <boost/shared_ptr.hpp> + +class Rectangle; + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= IDeckLayouter + //==================================================================== + class IDeckLayouter + { + 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 the single tool panels + */ + virtual Rectangle Layout( const Rectangle& i_rDeckPlayground ) = 0; + + virtual ~IDeckLayouter() + { + } + }; + + typedef ::boost::shared_ptr< IDeckLayouter > PDeckLayouter; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // DECKLAYOUTER_HXX diff --git a/svtools/inc/svtools/toolpanel/tablayouter.hxx b/svtools/inc/svtools/toolpanel/tablayouter.hxx new file mode 100644 index 000000000000..ff66fe367e3b --- /dev/null +++ b/svtools/inc/svtools/toolpanel/tablayouter.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * 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 TABLAYOUTER_HXX +#define TABLAYOUTER_HXX + +#include "svtools/toolpanel/decklayouter.hxx" + +#include <memory> + +//........................................................................ +namespace svt +{ +//........................................................................ + + enum TabAlignment + { + TABS_RIGHT + }; + + struct TabDeckLayouter_Data; + + //==================================================================== + //= TabDeckLayouter + //==================================================================== + class TabDeckLayouter : public IDeckLayouter + { + public: + TabDeckLayouter( const TabAlignment i_eAlignment ); + ~TabDeckLayouter(); + + // IDeckLayouter + virtual Rectangle Layout( const Rectangle& i_rDeckPlayground ); + + private: + ::std::auto_ptr< TabDeckLayouter_Data > m_pData; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // TABLAYOUTER_HXX diff --git a/svtools/inc/svtools/toolpanel/toolpanel.hxx b/svtools/inc/svtools/toolpanel/toolpanel.hxx new file mode 100644 index 000000000000..4b7227f52cbd --- /dev/null +++ b/svtools/inc/svtools/toolpanel/toolpanel.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * 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 TOOLPANEL_HXX +#define TOOLPANEL_HXX + +#include <boost/shared_ptr.hpp> + +class Rectangle; + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= IToolPanel + //==================================================================== + /** abstract interface for a single tool panel + */ + class IToolPanel + { + public: + /// shows the panel + virtual void Show() = 0; + /// hides the panel + virtual void Hide() = 0; + /// sets the position of the panel + virtual void SetPosSizePixel( const Rectangle& i_rPanelPlayground ) = 0; + + virtual ~IToolPanel() + { + } + }; + + typedef ::boost::shared_ptr< IToolPanel > PToolPanel; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // TOOLPANEL_HXX diff --git a/svtools/inc/svtools/toolpanel/toolpanelcollection.hxx b/svtools/inc/svtools/toolpanel/toolpanelcollection.hxx new file mode 100644 index 000000000000..a0257fc5c91e --- /dev/null +++ b/svtools/inc/svtools/toolpanel/toolpanelcollection.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * 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/toolpanel.hxx" + +#include <memory> + +//........................................................................ +namespace svt +{ +//........................................................................ + + struct ToolPanelCollection_Data; + + //==================================================================== + //= ToolPanelCollection + //==================================================================== + class ToolPanelCollection + { + public: + ToolPanelCollection(); + ~ToolPanelCollection(); + + // panel access + size_t GetPanelCount() const; + PToolPanel GetPanel( const size_t i_nPos ) const; + size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_pPosition ); + + private: + ::std::auto_ptr< ToolPanelCollection_Data > m_pData; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // TOOLPANELCOLLECTION_HXX diff --git a/svtools/inc/svtools/toolpanel/toolpaneldeck.hxx b/svtools/inc/svtools/toolpanel/toolpaneldeck.hxx new file mode 100644 index 000000000000..2efde1f29e8b --- /dev/null +++ b/svtools/inc/svtools/toolpanel/toolpaneldeck.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * 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 TOOLPANELDECK_HXX +#define TOOLPANELDECK_HXX + +#include "svtools/toolpanel/decklayouter.hxx" +#include "svtools/toolpanel/toolpanelcollection.hxx" + +#include <vcl/ctrl.hxx> + +#include <memory> + +//........................................................................ +namespace svt +{ +//........................................................................ + + class ToolPanelCollection; + class ToolPanelDeck_Impl; + + //==================================================================== + //= ToolPanelDeck + //==================================================================== + class ToolPanelDeck : public Control + { + public: + ToolPanelDeck( Window& i_rParent, const WinBits i_nStyle ); + ~ToolPanelDeck(); + + // attributes + PDeckLayouter GetLayouter() const; + void SetLayouter( const PDeckLayouter& i_pNewLayouter ); + + size_t GetActivePanel() const; + void ActivatePanel( const size_t i_nPanel ); + + const ToolPanelCollection& GetPanels() const; + ToolPanelCollection& GetPanels(); + + protected: + // Window overridables + virtual void Resize(); + + private: + ::std::auto_ptr< ToolPanelDeck_Impl > m_pImpl; + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // TOOLPANELDECK_HXX diff --git a/svtools/prj/build.lst b/svtools/prj/build.lst index 5a67b9414181..a71d30487bb4 100644 --- a/svtools/prj/build.lst +++ b/svtools/prj/build.lst @@ -20,9 +20,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__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__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_toolpanel NULL diff --git a/svtools/source/toolpanel/dummypanel.cxx b/svtools/source/toolpanel/dummypanel.cxx new file mode 100644 index 000000000000..52c89be24b99 --- /dev/null +++ b/svtools/source/toolpanel/dummypanel.cxx @@ -0,0 +1,66 @@ +/************************************************************************* + * 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 +{ +//........................................................................ + + //==================================================================== + //= DummyPanel + //==================================================================== + //-------------------------------------------------------------------- + DummyPanel::DummyPanel() + { + } + + //-------------------------------------------------------------------- + DummyPanel::~DummyPanel() + { + } + + //-------------------------------------------------------------------- + void DummyPanel::Show() + { + } + + //-------------------------------------------------------------------- + void DummyPanel::Hide() + { + } + + //-------------------------------------------------------------------- + void DummyPanel::SetPosSizePixel( const Rectangle& /*i_rPanelPlayground*/ ) + { + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/dummypanel.hxx b/svtools/source/toolpanel/dummypanel.hxx new file mode 100644 index 000000000000..425467641077 --- /dev/null +++ b/svtools/source/toolpanel/dummypanel.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * 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" + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= DummyPanel + //==================================================================== + /// is a dummy implementation of the IToolPanel interface + class DummyPanel : public IToolPanel + { + public: + DummyPanel(); + ~DummyPanel(); + + // IToolPanel + virtual void Show(); + virtual void Hide(); + virtual void SetPosSizePixel( const Rectangle& i_rPanelPlayground ); + }; + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // DUMMYPANEL_HXX diff --git a/svtools/source/toolpanel/makefile.mk b/svtools/source/toolpanel/makefile.mk new file mode 100644 index 000000000000..23a3186bdcef --- /dev/null +++ b/svtools/source/toolpanel/makefile.mk @@ -0,0 +1,57 @@ +#************************************************************************* +# +# 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 -------------------------------------------------------- + +SLOFILES=\ + $(SLO)$/dummypanel.obj \ + $(SLO)$/tablayouter.obj \ + $(SLO)$/toolpanelcollection.obj \ + $(SLO)$/toolpaneldeck.obj \ + +#LIB1TARGET= $(SLB)$/$(TARGET).lib +#LIB1OBJFILES= $(SLOFILES) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/svtools/source/toolpanel/tablayouter.cxx b/svtools/source/toolpanel/tablayouter.cxx new file mode 100644 index 000000000000..3f6f57453356 --- /dev/null +++ b/svtools/source/toolpanel/tablayouter.cxx @@ -0,0 +1,70 @@ +/************************************************************************* + * 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 <tools/gen.hxx> + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= TabDeckLayouter_Data + //==================================================================== + struct TabDeckLayouter_Data + { + TabAlignment eAlignment; + }; + + //==================================================================== + //= TabDeckLayouter + //==================================================================== + //-------------------------------------------------------------------- + TabDeckLayouter::TabDeckLayouter( const TabAlignment i_eAlignment ) + :m_pData( new TabDeckLayouter_Data ) + { + m_pData->eAlignment = i_eAlignment; + } + + //-------------------------------------------------------------------- + TabDeckLayouter::~TabDeckLayouter() + { + } + + //-------------------------------------------------------------------- + Rectangle TabDeckLayouter::Layout( const Rectangle& i_rDeckPlayground ) + { + // TODO + return i_rDeckPlayground; + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/toolpanelcollection.cxx b/svtools/source/toolpanel/toolpanelcollection.cxx new file mode 100644 index 000000000000..ff274075f108 --- /dev/null +++ b/svtools/source/toolpanel/toolpanelcollection.cxx @@ -0,0 +1,94 @@ +/************************************************************************* + * 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/toolpanelcollection.hxx" + +#include <tools/diagnose_ex.h> + +#include <vector> + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= ToolPanelCollection_Data + //==================================================================== + struct ToolPanelCollection_Data + { + ::std::vector< PToolPanel > aPanels; + }; + + //==================================================================== + //= ToolPanelCollection + //==================================================================== + //-------------------------------------------------------------------- + ToolPanelCollection::ToolPanelCollection() + :m_pData( new ToolPanelCollection_Data ) + { + } + + //-------------------------------------------------------------------- + ToolPanelCollection::~ToolPanelCollection() + { + } + + //-------------------------------------------------------------------- + size_t ToolPanelCollection::GetPanelCount() const + { + return m_pData->aPanels.size(); + } + + //-------------------------------------------------------------------- + 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_pPosition ) + { + OSL_ENSURE( i_pPanel.get(), "ToolPanelCollection::InsertPanel: illegal panel!" ); + if ( !i_pPanel.get() ) + return 0; + + const size_t position = i_pPosition < m_pData->aPanels.size() ? i_pPosition : m_pData->aPanels.size(); + m_pData->aPanels.insert( m_pData->aPanels.begin() + position, i_pPanel ); + + // TODO: notification. The tool panel deck which owns us is certainly interested in this event ... + + return position; + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/source/toolpanel/toolpaneldeck.cxx b/svtools/source/toolpanel/toolpaneldeck.cxx new file mode 100644 index 000000000000..12f85794576e --- /dev/null +++ b/svtools/source/toolpanel/toolpaneldeck.cxx @@ -0,0 +1,222 @@ +/************************************************************************* + * 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 "svtools/toolpanel/toolpaneldeck.hxx" +#include "svtools/toolpanel/tablayouter.hxx" + +#include <boost/optional.hpp> + +//........................................................................ +namespace svt +{ +//........................................................................ + + //==================================================================== + //= ToolPanelDeck_Impl + //==================================================================== + class ToolPanelDeck_Impl + { + public: + ToolPanelDeck_Impl( ToolPanelDeck& i_rDeck ) + :m_rDeck( i_rDeck ) + ,m_aPanels() + ,m_pDummyPanel( new DummyPanel ) + ,m_aActivePanel() + ,m_pLayouter() + ,m_aPanelPlayground() + { + // use a default layouter + m_pLayouter.reset( new TabDeckLayouter( TABS_RIGHT ) ); + + // add as listener to the panels collection - we're interested in panels + // being added and removed + // TODO + } + + const ToolPanelCollection& GetPanels() const { return m_aPanels; } + ToolPanelCollection& GetPanels() { return m_aPanels; } + + size_t GetActivePanel() const; + void ActivatePanel( const size_t i_nPanel ); + + PDeckLayouter GetLayouter() const { return m_pLayouter; } + void SetLayouter( const PDeckLayouter& i_pNewLayouter ); + + /// re-layouts everything + void LayoutAll() { ImplDoLayout(); } + + private: + void ImplDoLayout(); + + private: + PToolPanel GetActiveOrDummyPanel_Impl(); + + private: + ToolPanelDeck& m_rDeck; + + ToolPanelCollection m_aPanels; + PToolPanel m_pDummyPanel; + ::boost::optional< size_t > + m_aActivePanel; + + PDeckLayouter m_pLayouter; + Rectangle m_aPanelPlayground; + }; + + //-------------------------------------------------------------------- + PToolPanel ToolPanelDeck_Impl::GetActiveOrDummyPanel_Impl() + { + if ( !m_aActivePanel ) + return m_pDummyPanel; + return m_aPanels.GetPanel( *m_aActivePanel ); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::SetLayouter( const PDeckLayouter& i_pNewLayouter ) + { + OSL_ENSURE( i_pNewLayouter.get(), "ToolPanelDeck_Impl::SetLayouter: invalid layouter!" ); + if ( !i_pNewLayouter.get() ) + return; + m_pLayouter = i_pNewLayouter; + + ImplDoLayout(); + } + + //-------------------------------------------------------------------- + size_t ToolPanelDeck_Impl::GetActivePanel() const + { + OSL_PRECOND( !!m_aActivePanel, "ToolPanelDeck_Impl::GetActivePanel: no active panel (yet)!" ); + if ( !m_aActivePanel ) + return 0; + return *m_aActivePanel; + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::ActivatePanel( const size_t i_nPanel ) + { + OSL_ENSURE( i_nPanel < m_aPanels.GetPanelCount(), "ToolPanelDeck_Impl::ActivatePanel: illegal panel no.!" ); + if ( i_nPanel >= m_aPanels.GetPanelCount() ) + return; + + if ( !!m_aActivePanel && ( *m_aActivePanel == i_nPanel ) ) + return; + + // hide the old panel + const PToolPanel pOldActive( GetActiveOrDummyPanel_Impl() ); + pOldActive->Hide(); + + m_aActivePanel = i_nPanel; + + // position and show the new panel + const PToolPanel pNewActive( GetActiveOrDummyPanel_Impl() ); + pNewActive->SetPosSizePixel( m_aPanelPlayground ); + pNewActive->Show(); + + // tell the layouter - it might need to adjust its visuals to the new situation + // TODO + } + + //-------------------------------------------------------------------- + void ToolPanelDeck_Impl::ImplDoLayout() + { + const Rectangle aDeckPlayground( Point(), m_rDeck.GetOutputSizePixel() ); + + // let the layouter do the main work + m_aPanelPlayground = aDeckPlayground; + OSL_ENSURE( m_pLayouter.get(), "ToolPanelDeck_Impl::ImplDoLayout: no layouter!" ); + if ( m_pLayouter.get() ) + m_aPanelPlayground = m_pLayouter->Layout( aDeckPlayground ); + + // and position the active panel + const PToolPanel pActive( GetActiveOrDummyPanel_Impl() ); + pActive->SetPosSizePixel( m_aPanelPlayground ); + } + + //==================================================================== + //= ToolPanelDeck + //==================================================================== + //-------------------------------------------------------------------- + ToolPanelDeck::ToolPanelDeck( Window& i_rParent, const WinBits i_nStyle ) + :Control( &i_rParent, i_nStyle ) + ,m_pImpl( new ToolPanelDeck_Impl( *this ) ) + { + } + + //-------------------------------------------------------------------- + ToolPanelDeck::~ToolPanelDeck() + { + } + + //-------------------------------------------------------------------- + size_t ToolPanelDeck::GetActivePanel() const + { + return m_pImpl->GetActivePanel(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::ActivatePanel( const size_t i_nPanel ) + { + m_pImpl->ActivatePanel( i_nPanel ); + } + + //-------------------------------------------------------------------- + PDeckLayouter ToolPanelDeck::GetLayouter() const + { + return m_pImpl->GetLayouter(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::SetLayouter( const PDeckLayouter& i_pNewLayouter ) + { + return m_pImpl->SetLayouter( i_pNewLayouter ); + } + + //-------------------------------------------------------------------- + const ToolPanelCollection& ToolPanelDeck::GetPanels() const + { + return m_pImpl->GetPanels(); + } + + //-------------------------------------------------------------------- + ToolPanelCollection& ToolPanelDeck::GetPanels() + { + return m_pImpl->GetPanels(); + } + + //-------------------------------------------------------------------- + void ToolPanelDeck::Resize() + { + Control::Resize(); + m_pImpl->LayoutAll(); + } + +//........................................................................ +} // namespace svt +//........................................................................ diff --git a/svtools/workben/toolpanel/makefile.mk b/svtools/workben/toolpanel/makefile.mk new file mode 100644 index 000000000000..8572ccaa3607 --- /dev/null +++ b/svtools/workben/toolpanel/makefile.mk @@ -0,0 +1,107 @@ +#************************************************************************* +# +# 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) +APP1LIBS= $(SLB)/toolpanel.lib +APP1STDLIBS=\ + $(VCLLIB) \ + $(SALLIB) \ + $(TOOLSLIB) \ + $(COMPHELPERLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + + +.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 100644 index 000000000000..6b02208fbdfe --- /dev/null +++ b/svtools/workben/toolpanel/toolpaneltest.cxx @@ -0,0 +1,225 @@ +/************************************************************************* +* 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/toolpanel/toolpaneldeck.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 <vcl/svapp.hxx> +#include <vcl/wrkwin.hxx> + +namespace svt { namespace toolpanel +{ + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::XComponentContext; + +//============================================================================= +//= 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 ) + :Window( &i_rParent ) + { + SetLineColor(); + SetFillColor( i_rColor ); + } + + virtual void Paint( const Rectangle& i_rRect ) + { + DrawRect( i_rRect ); + } +}; + +//============================================================================= +//= ColoredPanel +//============================================================================= +class ColoredPanel : public IToolPanel +{ +public: + ColoredPanel( Window& i_rParent, const Color& i_rColor ); + ~ColoredPanel(); + + // IToolPanel + virtual void Show(); + virtual void Hide(); + virtual void SetPosSizePixel( const Rectangle& i_rPanelPlayground ); + +private: + ColoredPanelWindow m_aWindow; +}; + +//============================================================================= +//= ColoredPanel +//============================================================================= +//----------------------------------------------------------------------------- +ColoredPanel::ColoredPanel( Window& i_rParent, const Color& i_rColor ) + :m_aWindow( i_rParent, i_rColor ) +{ +} + +//----------------------------------------------------------------------------- +ColoredPanel::~ColoredPanel() +{ +} + +//----------------------------------------------------------------------------- +void ColoredPanel::Show() +{ + m_aWindow.Show(); +} + +//----------------------------------------------------------------------------- +void ColoredPanel::Hide() +{ + m_aWindow.Hide(); +} + +//----------------------------------------------------------------------------- +void ColoredPanel::SetPosSizePixel( const Rectangle& i_rPanelPlayground ) +{ + m_aWindow.SetPosSizePixel( i_rPanelPlayground.TopLeft(), i_rPanelPlayground.GetSize() ); +} + +//============================================================================= +//= PanelDemoMainWindow +//============================================================================= +class PanelDemoMainWindow : public WorkWindow +{ +private: + ToolPanelDeck m_aToolPanelDeck; + +protected: + virtual void GetFocus(); + +public: + PanelDemoMainWindow(); + ~PanelDemoMainWindow(); + + virtual void Resize(); +}; + +//============================================================================= +//= PanelDemoMainWindow +//============================================================================= +//----------------------------------------------------------------------------- +PanelDemoMainWindow::PanelDemoMainWindow() + :WorkWindow( NULL, WB_APP | WB_STDWORK | WB_CLIPCHILDREN ) + ,m_aToolPanelDeck( *this, WB_BORDER ) +{ + m_aToolPanelDeck.SetPosSizePixel( Point( 20, 20 ), Size( 500, 300 ) ); + m_aToolPanelDeck.SetBorderStyle( WINDOW_BORDER_MONO ); + + ToolPanelCollection& rPanels = m_aToolPanelDeck.GetPanels(); + const size_t nFirstPanelPosition = rPanels.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck, Color( COL_RED ) ) ), rPanels.GetPanelCount() ); + m_aToolPanelDeck.ActivatePanel( nFirstPanelPosition ); + + m_aToolPanelDeck.Show(); + + SetBackground( Color( COL_LIGHTGRAY ) ); + + SetText( String::CreateFromAscii( "ToolPanelDeck Demo Application" ) ); + Show(); +} + +//----------------------------------------------------------------------------- +PanelDemoMainWindow::~PanelDemoMainWindow() +{ +} + +//----------------------------------------------------------------------------- +void PanelDemoMainWindow::GetFocus() +{ + WorkWindow::GetFocus(); + m_aToolPanelDeck.GrabFocus(); +} + +//----------------------------------------------------------------------------- +void PanelDemoMainWindow::Resize() +{ + WorkWindow::Resize(); + Size aSize( GetOutputSizePixel() ); + aSize.Width() -= 40; + aSize.Height() -= 40; + m_aToolPanelDeck.SetPosSizePixel( Point( 20, 20 ), aSize ); +} + +//============================================================================= +//= 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() +{ + Reference< XMultiServiceFactory > xSMgr = createApplicationServiceManager(); + ::comphelper::setProcessServiceFactory( xSMgr ); + + PanelDemoMainWindow aWindow; + Execute(); +} + +PanelDemo aTheApplication; + +} } // namespace ::svt::toolpanel |