summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2013-04-25 10:51:17 +0000
committerMichael Meeks <michael.meeks@suse.com>2013-05-20 11:33:22 +0100
commitf14674e3f1fca1b881412f0429979a5761bfb2d6 (patch)
treed4955bba453258283c0fcc13238465284a962805
parent6c4b11e3a366b16796ce31761ce15119233c640c (diff)
Related: #i121420# apply context dependent Show Menu Commands...
according given panel configurations (cherry picked from commit c4a3b967b0ba367b219ac181fe2ed24a64e3c224) Change-Id: Ib2b3161c70112032659e712556641a46f43edcd0
-rw-r--r--sfx2/source/sidebar/Panel.cxx17
-rw-r--r--sfx2/source/sidebar/Panel.hxx7
-rw-r--r--sfx2/source/sidebar/PanelTitleBar.cxx32
-rw-r--r--sfx2/source/sidebar/PanelTitleBar.hxx7
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx16
-rw-r--r--sfx2/source/sidebar/SidebarController.hxx3
6 files changed, 51 insertions, 31 deletions
diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 5389b4ff444b..19b0588265e0 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -47,15 +47,13 @@ namespace sfx2 { namespace sidebar {
Panel::Panel (
const PanelDescriptor& rPanelDescriptor,
Window* pParentWindow,
- const ::boost::function<void(void)>& rDeckLayoutTrigger,
- const ::boost::function<void(void)>& rShowMenuFunctor)
+ const ::boost::function<void(void)>& rDeckLayoutTrigger )
: Window(pParentWindow),
msPanelId(rPanelDescriptor.msId),
mpTitleBar(new PanelTitleBar(
rPanelDescriptor.msTitle,
pParentWindow,
- this,
- rShowMenuFunctor)),
+ this)),
mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional),
mxElement(),
mxPanelComponent(),
@@ -82,6 +80,17 @@ Panel::~Panel (void)
+void Panel::SetShowMenuFunctor( const ::boost::function<void(void)>& rShowMenuFunctor )
+{
+ if ( mpTitleBar.get() )
+ {
+ mpTitleBar->SetMenuAction( rShowMenuFunctor );
+ }
+}
+
+
+
+
void Panel::Dispose (void)
{
mxPanelComponent = NULL;
diff --git a/sfx2/source/sidebar/Panel.hxx b/sfx2/source/sidebar/Panel.hxx
index ce6cb3c12eb6..5a7ca1c1ebb2 100644
--- a/sfx2/source/sidebar/Panel.hxx
+++ b/sfx2/source/sidebar/Panel.hxx
@@ -35,6 +35,7 @@ namespace sfx2 { namespace sidebar {
class PanelDescriptor;
class TitleBar;
+class PanelTitleBar;
class Panel
@@ -44,12 +45,12 @@ public:
Panel (
const PanelDescriptor& rPanelDescriptor,
Window* pParentWindow,
- const ::boost::function<void(void)>& rDeckLayoutTrigger,
- const ::boost::function<void(void)>& rShowMenuFunctor);
+ const ::boost::function<void(void)>& rDeckLayoutTrigger );
virtual ~Panel (void);
void Dispose (void);
+ void SetShowMenuFunctor( const ::boost::function<void(void)>& rShowMenuFunctor );
TitleBar* GetTitleBar (void) const;
bool IsTitleBarOptional (void) const;
void SetUIElement (const cssu::Reference<css::ui::XUIElement>& rxElement);
@@ -69,7 +70,7 @@ public:
private:
const ::rtl::OUString msPanelId;
- ::boost::scoped_ptr<TitleBar> mpTitleBar;
+ ::boost::scoped_ptr<PanelTitleBar> mpTitleBar;
const bool mbIsTitleBarOptional;
cssu::Reference<css::ui::XUIElement> mxElement;
cssu::Reference<css::ui::XSidebarPanel> mxPanelComponent;
diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx b/sfx2/source/sidebar/PanelTitleBar.cxx
index ded65fb8a458..28f819bf3954 100644
--- a/sfx2/source/sidebar/PanelTitleBar.cxx
+++ b/sfx2/source/sidebar/PanelTitleBar.cxx
@@ -41,24 +41,15 @@ static const sal_Int32 gaRightIconPadding (5);
PanelTitleBar::PanelTitleBar (
const ::rtl::OUString& rsTitle,
Window* pParentWindow,
- Panel* pPanel,
- const ::boost::function<void(void)>& rMenuAction)
+ Panel* pPanel )
: TitleBar(rsTitle, pParentWindow, GetBackgroundPaint()),
mbIsLeftButtonDown(false),
mpPanel(pPanel),
mnMenuItemIndex(1),
- maMenuAction(rMenuAction)
+ maMenuAction()
{
OSL_ASSERT(mpPanel != NULL);
- if (maMenuAction)
- {
- maToolBox.InsertItem(
- mnMenuItemIndex,
- Theme::GetImage(Theme::Image_PanelMenu));
- maToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT);
- }
-
#ifdef DEBUG
SetText(A2S("PanelTitleBar"));
#endif
@@ -74,6 +65,25 @@ PanelTitleBar::~PanelTitleBar (void)
+void PanelTitleBar::SetMenuAction ( const ::boost::function<void(void)>& rMenuAction )
+{
+ if ( !maMenuAction && rMenuAction )
+ {
+ maToolBox.InsertItem(
+ mnMenuItemIndex,
+ Theme::GetImage(Theme::Image_PanelMenu));
+ maToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT);
+ }
+ else if ( maMenuAction && !rMenuAction )
+ {
+ maToolBox.RemoveItem( maToolBox.GetItemPos( mnMenuItemIndex ) );
+ }
+ maMenuAction = rMenuAction;
+}
+
+
+
+
Rectangle PanelTitleBar::GetTitleArea (const Rectangle& rTitleBarBox)
{
if (mpPanel != NULL)
diff --git a/sfx2/source/sidebar/PanelTitleBar.hxx b/sfx2/source/sidebar/PanelTitleBar.hxx
index f76edcb4eaad..dff82a9661bb 100644
--- a/sfx2/source/sidebar/PanelTitleBar.hxx
+++ b/sfx2/source/sidebar/PanelTitleBar.hxx
@@ -34,10 +34,11 @@ public:
PanelTitleBar (
const ::rtl::OUString& rsTitle,
Window* pParentWindow,
- Panel* pPanel,
- const ::boost::function<void(void)>& rMenuAction);
+ Panel* pPanel );
virtual ~PanelTitleBar (void);
+ void SetMenuAction ( const ::boost::function<void(void)>& rMenuAction );
+
virtual void DataChanged (const DataChangedEvent& rEvent);
virtual void MouseButtonDown (const MouseEvent& rMouseEvent);
virtual void MouseButtonUp (const MouseEvent& rMouseEvent);
@@ -53,7 +54,7 @@ private:
bool mbIsLeftButtonDown;
Panel* mpPanel;
const sal_uInt16 mnMenuItemIndex;
- const ::boost::function<void(void)> maMenuAction;
+ ::boost::function<void(void)> maMenuAction;
};
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 12fc4ca9980d..c4584422856c 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -454,14 +454,18 @@ void SidebarController::SwitchToDeck (
// Panel does not yet exist. Create it.
aNewPanels[nWriteIndex] = CreatePanel(
rPanelContexDescriptor.msId,
- mpCurrentDeck->GetPanelParentWindow(),
- rPanelContexDescriptor.msMenuCommand);
+ mpCurrentDeck->GetPanelParentWindow());
bHasPanelSetChanged = true;
}
if (aNewPanels[nWriteIndex] != NULL)
{
// Depending on the context we have to collapse the panel.
aNewPanels[nWriteIndex]->SetExpanded(rPanelContexDescriptor.mbIsInitiallyVisible);
+ // Depending on the context we have to apply the show menu functor.
+ aNewPanels[nWriteIndex]->SetShowMenuFunctor(
+ rPanelContexDescriptor.msMenuCommand.getLength()>0
+ ? ::boost::bind(&SidebarController::ShowDetailMenu,this,rPanelContexDescriptor.msMenuCommand)
+ : ::boost::function<void(void)>() );
++nWriteIndex;
}
@@ -536,8 +540,7 @@ bool SidebarController::ArePanelSetsEqual (
SharedPanel SidebarController::CreatePanel (
const OUString& rsPanelId,
- ::Window* pParentWindow,
- const OUString& rsMenuCommand)
+ ::Window* pParentWindow )
{
const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId);
if (pPanelDescriptor == NULL)
@@ -547,10 +550,7 @@ SharedPanel SidebarController::CreatePanel (
SharedPanel pPanel (new Panel(
*pPanelDescriptor,
pParentWindow,
- ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()),
- rsMenuCommand.getLength()>0
- ? ::boost::bind(&SidebarController::ShowDetailMenu,this,rsMenuCommand)
- : ::boost::function<void(void)>()));
+ ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()) ) );
// Create the XUIElement.
Reference<ui::XUIElement> xUIElement (CreateUIElement(
diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx
index 9c4e2a8ff7a6..2d2773690622 100644
--- a/sfx2/source/sidebar/SidebarController.hxx
+++ b/sfx2/source/sidebar/SidebarController.hxx
@@ -132,8 +132,7 @@ private:
const bool bWantsCanvas);
SharedPanel CreatePanel (
const ::rtl::OUString& rsPanelId,
- ::Window* pParentWindow,
- const ::rtl::OUString& rsMenuCommand);
+ ::Window* pParentWindow );
void SwitchToDeck (
const DeckDescriptor& rDeckDescriptor,
const Context& rContext);