Kaydet (Commit) c4a3b967 authored tarafından Oliver-Rainer Wittmann's avatar Oliver-Rainer Wittmann

121420: apply context dependent Show Menu Commands according given panel configurations

üst 26e4fcdb
......@@ -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;
......
......@@ -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;
......
......@@ -46,24 +46,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
......@@ -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)
......
......@@ -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;
};
......
......@@ -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::ArePanelSetsEqual (
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::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(
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment