diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-01-13 21:43:27 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-01-14 21:31:32 +0900 |
commit | 1049511c0c5d881df4ba8042744d63d37878296f (patch) | |
tree | b300e1edd156be3f6124313e462ce9ddc6aba3e8 /sfx2 | |
parent | infobar: reuse gathering the dark/light colors from settings (diff) | |
download | core-1049511c0c5d881df4ba8042744d63d37878296f.tar.gz core-1049511c0c5d881df4ba8042744d63d37878296f.zip |
infobar: add buttons one by one with addButton
Change-Id: I5c9da630fe800df8da8ff32d7bb3e6b19fc37a8d
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 28 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 52 |
3 files changed, 39 insertions, 46 deletions
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 7cd0ebee684d..f530456b679f 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -115,7 +115,7 @@ void SfxCloseButton::Paint(const Rectangle&) } // anonymous namespace SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId, - const OUString& sMessage, vector<PushButton*> aButtons) : + const OUString& sMessage) : Window(pParent, 0), m_sId(sId), m_pMessage(new FixedText(this, 0)), @@ -133,22 +133,19 @@ SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId, m_pCloseBtn->SetClickHdl(LINK(this, SfxInfoBarWindow, CloseHandler)); m_pCloseBtn->Show(); - // Reparent the buttons and place them on the right of the bar - vector<PushButton*>::iterator it; - for (it = aButtons.begin(); it != aButtons.end(); ++it) - { - PushButton* pButton = *it; - pButton->SetParent(this); - pButton->Show(); - m_aActionBtns.push_back(pButton); - } - Resize(); } SfxInfoBarWindow::~SfxInfoBarWindow() {} +void SfxInfoBarWindow::addButton(PushButton* pButton) { + pButton->SetParent(this); + pButton->Show(); + m_aActionBtns.push_back(pButton); + Resize(); +} + void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect) { const ViewInformation2D aNewViewInfos; @@ -238,18 +235,19 @@ SfxInfoBarContainerWindow::~SfxInfoBarContainerWindow() { } -void SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage, vector<PushButton*> aButtons) +SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage) { - Size aSize = GetSizePixel( ); + Size aSize = GetSizePixel(); - SfxInfoBarWindow* pInfoBar = new SfxInfoBarWindow(this, sId, sMessage, aButtons); - pInfoBar->SetPosPixel(Point( 0, aSize.getHeight())); + SfxInfoBarWindow* pInfoBar = new SfxInfoBarWindow(this, sId, sMessage); + pInfoBar->SetPosPixel(Point(0, aSize.getHeight())); pInfoBar->Show(); m_pInfoBars.push_back(pInfoBar); long nHeight = pInfoBar->GetSizePixel().getHeight(); aSize.setHeight(aSize.getHeight() + nHeight); SetSizePixel(aSize); + return pInfoBar; } SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar(const OUString& sId) diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 943f60da08c1..5ea8ebe08565 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1448,11 +1448,10 @@ void SfxBaseController::ShowInfoBars( ) { // Get the Frame and show the InfoBar if not checked out SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); - std::vector< PushButton* > aButtons; PushButton* pBtn = new PushButton( &pViewFrame->GetWindow(), SfxResId( BT_CHECKOUT ) ); pBtn->SetClickHdl( LINK( this, SfxBaseController, CheckOutHandler ) ); - aButtons.push_back( pBtn ); - pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ), aButtons ); + SfxInfoBarWindow* pInfoBar = pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ) ); + pInfoBar->addButton(pBtn); } } } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 3c9a9df554b4..5ba7ef13a3e2 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1379,11 +1379,11 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } else { - std::vector< PushButton* > aButtons; + SfxInfoBarWindow* pInfoBar = AppendInfoBar("readonly", SfxResId(STR_READONLY_DOCUMENT)); + PushButton* pBtn = new PushButton( &GetWindow(), SfxResId(BT_READONLY_EDIT)); pBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler)); - aButtons.push_back( pBtn ); - AppendInfoBar("readonly", SfxResId(STR_READONLY_DOCUMENT), aButtons); + pInfoBar->addButton(pBtn); } break; @@ -3357,28 +3357,23 @@ void SfxViewFrame::ActivateToolPanel_Impl( const OUString& i_rPanelURL ) pPanelAccess->ActivateToolPanel( i_rPanelURL ); } -void SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage, std::vector< PushButton* > aButtons ) +SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage ) { const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); // Make sure the InfoBar container is visible - if ( !HasChildWindow( nId ) ) - ToggleChildWindow( nId ); - SfxChildWindow* pChild = GetChildWindow( nId ); - if ( pChild ) - { - SfxInfoBarContainerWindow* pInfoBars = static_cast<SfxInfoBarContainerWindow*>( pChild->GetWindow() ); - pInfoBars->appendInfoBar( sId, sMessage, aButtons ); - ShowChildWindow( nId ); - } - else + if (!HasChildWindow(nId)) + ToggleChildWindow(nId); + + SfxChildWindow* pChild = GetChildWindow(nId); + if (pChild) { - SAL_WARN( "sfx.view", "No consumer for InfoBar buttons, so deleting them instead" ); - for (std::vector< PushButton* >::iterator it = aButtons.begin(); it != aButtons.end(); ++it) - { - delete *it; - } + SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); + SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage); + ShowChildWindow(nId); + return pInfoBar; } + return NULL; } void SfxViewFrame::RemoveInfoBar( const OUString& sId ) @@ -3386,15 +3381,16 @@ void SfxViewFrame::RemoveInfoBar( const OUString& sId ) const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); // Make sure the InfoBar container is visible - if ( !HasChildWindow( nId ) ) - ToggleChildWindow( nId ); - SfxChildWindow* pChild = GetChildWindow( nId ); - if ( pChild ) - { - SfxInfoBarContainerWindow* pInfoBars = static_cast<SfxInfoBarContainerWindow*>( pChild->GetWindow() ); - SfxInfoBarWindow* pInfoBar = pInfoBars->getInfoBar( sId ); - pInfoBars->removeInfoBar( pInfoBar ); - ShowChildWindow( nId ); + if (!HasChildWindow(nId)) + ToggleChildWindow(nId); + + SfxChildWindow* pChild = GetChildWindow(nId); + if (pChild) + { + SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); + SfxInfoBarWindow* pInfoBar = pInfoBarContainer->getInfoBar(sId); + pInfoBarContainer->removeInfoBar(pInfoBar); + ShowChildWindow(nId); } } |