Author: orw
Date: Thu Apr 25 11:51:17 2013
New Revision: 1475717
URL: http://svn.apache.org/r1475717
Log:
121420: apply context dependent Show Menu Commands according given panel
configurations
Modified:
openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx
openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx
openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx
openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx
openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx
openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx
Modified: openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx?rev=1475717&r1=1475716&r2=1475717&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx Thu Apr 25 11:51:17 2013
@@ -52,15 +52,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(),
@@ -87,6 +85,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;
Modified: openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx?rev=1475717&r1=1475716&r2=1475717&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx Thu Apr 25 11:51:17 2013
@@ -39,6 +39,7 @@ namespace sfx2 { namespace sidebar {
class PanelDescriptor;
class TitleBar;
+class PanelTitleBar;
class Panel
@@ -48,12 +49,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);
@@ -73,7 +74,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;
Modified: openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx?rev=1475717&r1=1475716&r2=1475717&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.cxx Thu Apr 25
11:51:17 2013
@@ -46,24 +46,15 @@ static const sal_Int32 gaRightIconPaddin
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
@@ -79,6 +70,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)
Modified: openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx?rev=1475717&r1=1475716&r2=1475717&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/PanelTitleBar.hxx Thu Apr 25
11:51:17 2013
@@ -38,10 +38,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);
@@ -57,7 +58,7 @@ private:
bool mbIsLeftButtonDown;
Panel* mpPanel;
const sal_uInt16 mnMenuItemIndex;
- const ::boost::function<void(void)> maMenuAction;
+ ::boost::function<void(void)> maMenuAction;
};
Modified: openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx?rev=1475717&r1=1475716&r2=1475717&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx Thu Apr 25
11:51:17 2013
@@ -462,14 +462,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;
}
@@ -544,8 +548,7 @@ bool SidebarController::ArePanelSetsEqua
SharedPanel SidebarController::CreatePanel (
const OUString& rsPanelId,
- ::Window* pParentWindow,
- const OUString& rsMenuCommand)
+ ::Window* pParentWindow )
{
const PanelDescriptor* pPanelDescriptor =
ResourceManager::Instance().GetPanelDescriptor(rsPanelId);
if (pPanelDescriptor == NULL)
@@ -555,10 +558,7 @@ SharedPanel SidebarController::CreatePan
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(
Modified: openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx?rev=1475717&r1=1475716&r2=1475717&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx Thu Apr 25
11:51:17 2013
@@ -136,8 +136,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);