[Libreoffice-commits] core.git: 10 commits - cui/source include/sfx2 sfx2/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Wed Jan 14 04:38:11 PST 2015
cui/source/dialogs/zoom.cxx | 293 ++++++++++++-----------
cui/source/inc/zoom.hxx | 56 ++--
include/sfx2/infobar.hxx | 36 +-
include/sfx2/viewfrm.hxx | 5
sfx2/source/dialog/infobar.cxx | 409 +++++++++++++++------------------
sfx2/source/view/sfxbasecontroller.cxx | 5
sfx2/source/view/viewfrm.cxx | 52 +---
7 files changed, 432 insertions(+), 424 deletions(-)
New commits:
commit 1049511c0c5d881df4ba8042744d63d37878296f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 21:43:27 2015 +0900
infobar: add buttons one by one with addButton
Change-Id: I5c9da630fe800df8da8ff32d7bb3e6b19fc37a8d
diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index ee92d39..14c680f 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -51,15 +51,19 @@ class SfxInfoBarWindow : public vcl::Window
boost::ptr_vector<PushButton> m_aActionBtns;
public:
- SfxInfoBarWindow( vcl::Window* parent, const OUString& sId,
- const OUString& sMessage,
- std::vector< PushButton* > aButtons );
+ SfxInfoBarWindow(vcl::Window* parent, const OUString& sId, const OUString& sMessage);
virtual ~SfxInfoBarWindow( );
virtual const OUString& getId() const { return m_sId; }
virtual void Paint( const Rectangle& ) SAL_OVERRIDE;
virtual void Resize( ) SAL_OVERRIDE;
+ /** Add button to Infobar.
+ * Infobar takes ownership of the button so the button is
+ * destroyed when the infobar gets destroyed.
+ */
+ void addButton(PushButton* pButton);
+
private:
DECL_LINK( CloseHandler, void* );
};
@@ -71,14 +75,14 @@ class SfxInfoBarContainerWindow : public vcl::Window
boost::ptr_vector<SfxInfoBarWindow> m_pInfoBars;
public:
- SfxInfoBarContainerWindow( SfxInfoBarContainerChild* pChildWin );
+ SfxInfoBarContainerWindow(SfxInfoBarContainerChild* pChildWin);
virtual ~SfxInfoBarContainerWindow( );
- void appendInfoBar( const OUString& sId, const OUString& sMessage, std::vector< PushButton* > aButtons );
- SfxInfoBarWindow* getInfoBar( const OUString& sId );
- void removeInfoBar( SfxInfoBarWindow* pInfoBar );
+ SfxInfoBarWindow* appendInfoBar(const OUString& sId, const OUString& sMessage);
+ SfxInfoBarWindow* getInfoBar(const OUString& sId);
+ void removeInfoBar(SfxInfoBarWindow* pInfoBar);
- virtual void Resize( ) SAL_OVERRIDE;
+ virtual void Resize() SAL_OVERRIDE;
};
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index 1d043fc..ec5ef13 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -47,6 +47,7 @@ class Fraction;
class Point;
class Size;
class SfxChildWindow;
+class SfxInfoBarWindow;
namespace sfx2
{
@@ -191,8 +192,8 @@ public:
The buttons will be added from Right to Left at the right of the info bar. The parent, size
and position of each button will be changed: only the width will remain unchanged.
*/
- void AppendInfoBar( const OUString& sId, const OUString& sMessage, std::vector< PushButton* > aButtons = std::vector< PushButton* >() );
- void RemoveInfoBar( const OUString& sId );
+ SfxInfoBarWindow* AppendInfoBar(const OUString& sId, const OUString& sMessage);
+ void RemoveInfoBar(const OUString& sId);
SAL_DLLPRIVATE void SetDowning_Impl();
SAL_DLLPRIVATE void GetDocNumber_Impl();
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index 7cd0ebe..f530456 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 943f60d..5ea8ebe 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 3c9a9df..5ba7ef1 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);
}
}
commit 1149232c70d3f0383984091df597f3419045ba19
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 14:11:09 2015 +0900
infobar: reuse gathering the dark/light colors from settings
Change-Id: I923221f502c4efd200f77d5c73f03d124490ee39
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index 70e75e5..7cd0ebe 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -37,6 +37,21 @@ const long INFO_BAR_BASE_HEIGHT = 40;
const BColor constLightColor(1.0, 1.0, 191.0 / 255.0);
const BColor constDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
+void lclDetermineLightDarkColor(BColor& rLightColor, BColor& rDarkColor)
+{
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ if (rSettings.GetHighContrastMode())
+ {
+ rLightColor = rSettings.GetLightColor().getBColor();
+ rDarkColor = rSettings.GetDialogTextColor().getBColor();
+ }
+ else
+ {
+ rLightColor = constLightColor;
+ rDarkColor = constDarkColor;
+ }
+}
+
class SfxCloseButton : public PushButton
{
public:
@@ -58,15 +73,9 @@ void SfxCloseButton::Paint(const Rectangle&)
Primitive2DSequence aSeq(2);
- BColor aLightColor(constLightColor);
- BColor aDarkColor(constDarkColor);
-
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- if (rSettings.GetHighContrastMode())
- {
- aLightColor = rSettings.GetLightColor().getBColor();
- aDarkColor = rSettings.GetDialogTextColor().getBColor();
- }
+ BColor aLightColor;
+ BColor aDarkColor;
+ lclDetermineLightDarkColor(aLightColor, aDarkColor);
// Light background
B2DPolygon aPolygon;
@@ -150,15 +159,9 @@ void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect)
Primitive2DSequence aSeq(2);
- BColor aLightColor(constLightColor);
- BColor aDarkColor(constDarkColor);
-
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- if (rSettings.GetHighContrastMode())
- {
- aLightColor = rSettings.GetLightColor().getBColor();
- aDarkColor = rSettings.GetDialogTextColor().getBColor();
- }
+ BColor aLightColor;
+ BColor aDarkColor;
+ lclDetermineLightDarkColor(aLightColor, aDarkColor);
// Update the label background color
m_pMessage->SetBackground(Wallpaper(Color(aLightColor)));
commit dc265e3b104de6a3882d25b7b808daf99425d9ee
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 14:04:29 2015 +0900
infobar: combine anon. namespace, light/dark color to constant
Change-Id: Ie22c9b2997031146ee3a25ad55b2198ed50ee028
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index 1455559..70e75e5 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -31,78 +31,77 @@ using namespace basegfx;
namespace
{
- class SfxCloseButton : public PushButton
- {
- public:
- SfxCloseButton(vcl::Window* pParent) : PushButton(pParent, 0)
- {
- }
- virtual ~SfxCloseButton() {}
+const long INFO_BAR_BASE_HEIGHT = 40;
- virtual void Paint(const Rectangle& rRect) SAL_OVERRIDE;
- };
+const BColor constLightColor(1.0, 1.0, 191.0 / 255.0);
+const BColor constDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
- void SfxCloseButton::Paint(const Rectangle&)
- {
- const ViewInformation2D aNewViewInfos;
- const unique_ptr<BaseProcessor2D> pProcessor(
- createBaseProcessor2DFromOutputDevice(*this, aNewViewInfos));
+class SfxCloseButton : public PushButton
+{
+public:
+ SfxCloseButton(vcl::Window* pParent) : PushButton(pParent, 0)
+ {}
- const Rectangle aRect(Point(0, 0), PixelToLogic(GetSizePixel()));
+ virtual ~SfxCloseButton() {}
- Primitive2DSequence aSeq(2);
+ virtual void Paint(const Rectangle& rRect) SAL_OVERRIDE;
+};
- BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
- BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
+void SfxCloseButton::Paint(const Rectangle&)
+{
+ const ViewInformation2D aNewViewInfos;
+ const unique_ptr<BaseProcessor2D> pProcessor(
+ createBaseProcessor2DFromOutputDevice(*this, aNewViewInfos));
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- if (rSettings.GetHighContrastMode())
- {
- aLightColor = rSettings.GetLightColor().getBColor();
- aDarkColor = rSettings.GetDialogTextColor().getBColor();
- }
+ const Rectangle aRect(Point(0, 0), PixelToLogic(GetSizePixel()));
- // Light background
- B2DPolygon aPolygon;
- aPolygon.append(B2DPoint(aRect.Left(), aRect.Top()));
- aPolygon.append(B2DPoint(aRect.Right(), aRect.Top()));
- aPolygon.append(B2DPoint(aRect.Right(), aRect.Bottom()));
- aPolygon.append(B2DPoint(aRect.Left(), aRect.Bottom()));
- aPolygon.setClosed(true);
+ Primitive2DSequence aSeq(2);
- PolyPolygonColorPrimitive2D* pBack =
- new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor);
- aSeq[0] = pBack;
+ BColor aLightColor(constLightColor);
+ BColor aDarkColor(constDarkColor);
+
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ if (rSettings.GetHighContrastMode())
+ {
+ aLightColor = rSettings.GetLightColor().getBColor();
+ aDarkColor = rSettings.GetDialogTextColor().getBColor();
+ }
- LineAttribute aLineAttribute(aDarkColor, 2.0);
+ // Light background
+ B2DPolygon aPolygon;
+ aPolygon.append(B2DPoint(aRect.Left(), aRect.Top()));
+ aPolygon.append(B2DPoint(aRect.Right(), aRect.Top()));
+ aPolygon.append(B2DPoint(aRect.Right(), aRect.Bottom()));
+ aPolygon.append(B2DPoint(aRect.Left(), aRect.Bottom()));
+ aPolygon.setClosed(true);
- // Cross
- B2DPolyPolygon aCross;
+ PolyPolygonColorPrimitive2D* pBack =
+ new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor);
+ aSeq[0] = pBack;
- B2DPolygon aLine1;
- aLine1.append(B2DPoint(aRect.Left(), aRect.Top()));
- aLine1.append(B2DPoint(aRect.Right(), aRect.Bottom()));
- aCross.append(aLine1);
+ LineAttribute aLineAttribute(aDarkColor, 2.0);
- B2DPolygon aLine2;
- aLine2.append(B2DPoint(aRect.Right(), aRect.Top()));
- aLine2.append(B2DPoint(aRect.Left(), aRect.Bottom()));
- aCross.append(aLine2);
+ // Cross
+ B2DPolyPolygon aCross;
- PolyPolygonStrokePrimitive2D* pCross =
- new PolyPolygonStrokePrimitive2D(aCross, aLineAttribute, StrokeAttribute());
+ B2DPolygon aLine1;
+ aLine1.append(B2DPoint(aRect.Left(), aRect.Top()));
+ aLine1.append(B2DPoint(aRect.Right(), aRect.Bottom()));
+ aCross.append(aLine1);
- aSeq[1] = pCross;
+ B2DPolygon aLine2;
+ aLine2.append(B2DPoint(aRect.Right(), aRect.Top()));
+ aLine2.append(B2DPoint(aRect.Left(), aRect.Bottom()));
+ aCross.append(aLine2);
- pProcessor->process(aSeq);
- }
-}
+ PolyPolygonStrokePrimitive2D* pCross =
+ new PolyPolygonStrokePrimitive2D(aCross, aLineAttribute, StrokeAttribute());
-namespace
-{
+ aSeq[1] = pCross;
-const long INFO_BAR_BASE_HEIGHT = 40;
+ pProcessor->process(aSeq);
+}
} // anonymous namespace
@@ -119,7 +118,7 @@ SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * nScaleFactor));
m_pMessage->SetText(sMessage);
- m_pMessage->SetBackground(Wallpaper(Color(255, 255, 191)));
+ m_pMessage->SetBackground(Wallpaper(Color(constLightColor)));
m_pMessage->Show();
m_pCloseBtn->SetClickHdl(LINK(this, SfxInfoBarWindow, CloseHandler));
@@ -151,8 +150,8 @@ void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect)
Primitive2DSequence aSeq(2);
- BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
- BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
+ BColor aLightColor(constLightColor);
+ BColor aDarkColor(constDarkColor);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if (rSettings.GetHighContrastMode())
commit 8cd86d5e27b2ba0b4621474007eea1dea9957e8b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 13:57:55 2015 +0900
Scale the infobar controls correctly with DPI scale factor
Change-Id: I7d5b3daf4ae4da05bb7f09e80e790edae24e0eaf
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index cf8e6df..1455559 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -99,6 +99,13 @@ namespace
}
}
+namespace
+{
+
+const long INFO_BAR_BASE_HEIGHT = 40;
+
+} // anonymous namespace
+
SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
const OUString& sMessage, vector<PushButton*> aButtons) :
Window(pParent, 0),
@@ -107,8 +114,9 @@ SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
m_pCloseBtn(new SfxCloseButton(this)),
m_aActionBtns()
{
+ sal_Int32 nScaleFactor = GetDPIScaleFactor();
long nWidth = pParent->GetSizePixel().getWidth();
- SetPosSizePixel(Point(0, 0), Size(nWidth, 40));
+ SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * nScaleFactor));
m_pMessage->SetText(sMessage);
m_pMessage->SetBackground(Wallpaper(Color(255, 255, 191)));
@@ -187,22 +195,28 @@ void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect)
void SfxInfoBarWindow::Resize()
{
+ sal_Int32 nScaleFactor = GetDPIScaleFactor();
+
long nWidth = GetSizePixel().getWidth();
- m_pCloseBtn->SetPosSizePixel(Point(nWidth - 25, 15), Size(10, 10));
+ m_pCloseBtn->SetPosSizePixel(Point(nWidth - 25 * nScaleFactor, 15 * nScaleFactor), Size(10 * nScaleFactor, 10 * nScaleFactor));
// Reparent the buttons and place them on the right of the bar
- long nX = m_pCloseBtn->GetPosPixel().getX() - 15;
- long nBtnGap = 5;
+ long nX = m_pCloseBtn->GetPosPixel().getX() - 15 * nScaleFactor;
+ long nButtonGap = 5 * nScaleFactor;
+
boost::ptr_vector<PushButton>::iterator it;
for (it = m_aActionBtns.begin(); it != m_aActionBtns.end(); ++it)
{
- long nBtnWidth = it->GetSizePixel().getWidth();
- nX -= nBtnWidth;
- it->SetPosSizePixel(Point(nX, 5), Size(nBtnWidth, 30));
- nX -= nBtnGap;
+ long nButtonWidth = it->GetSizePixel().getWidth();
+ nX -= nButtonWidth;
+ it->SetPosSizePixel(Point(nX, 5 * nScaleFactor), Size(nButtonWidth, 30 * nScaleFactor));
+ nX -= nButtonGap;
}
- m_pMessage->SetPosSizePixel(Point(10, 10), Size(nX - 20, 20));
+ Point aMessagePosition(10 * nScaleFactor, 10 * nScaleFactor);
+ Size aMessageSize(nX - 20 * nScaleFactor, 20 * nScaleFactor);
+
+ m_pMessage->SetPosSizePixel(aMessagePosition, aMessageSize);
}
IMPL_LINK_NOARG(SfxInfoBarWindow, CloseHandler)
commit f78d0b2e7c9a5ef3afdc4057938b1992a2a6da95
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 13:25:42 2015 +0900
Further cleanup style in infobar, remove basegfx namespace in code
Change-Id: I0201d87d631413fc75230535e25c8eac189ede10
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index a2b2cd7..cf8e6df 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -27,22 +27,23 @@ using namespace drawinglayer::processor2d;
using namespace drawinglayer::primitive2d;
using namespace drawinglayer::attribute;
using namespace drawinglayer::geometry;
+using namespace basegfx;
namespace
{
class SfxCloseButton : public PushButton
{
public:
- SfxCloseButton( vcl::Window* pParent ) : PushButton( pParent, 0 )
+ SfxCloseButton(vcl::Window* pParent) : PushButton(pParent, 0)
{
}
- virtual ~SfxCloseButton( ) { }
+ virtual ~SfxCloseButton() {}
- virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
+ virtual void Paint(const Rectangle& rRect) SAL_OVERRIDE;
};
- void SfxCloseButton::Paint( const Rectangle& )
+ void SfxCloseButton::Paint(const Rectangle&)
{
const ViewInformation2D aNewViewInfos;
const unique_ptr<BaseProcessor2D> pProcessor(
@@ -52,42 +53,44 @@ namespace
Primitive2DSequence aSeq(2);
- basegfx::BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
- basegfx::BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
+ BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
+ BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- if ( rSettings.GetHighContrastMode() )
+ if (rSettings.GetHighContrastMode())
{
- aLightColor = rSettings.GetLightColor( ).getBColor( );
- aDarkColor = rSettings.GetDialogTextColor( ).getBColor( );
-
+ aLightColor = rSettings.GetLightColor().getBColor();
+ aDarkColor = rSettings.GetDialogTextColor().getBColor();
}
// Light background
- basegfx::B2DPolygon aPolygon;
- aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Top( ) ) );
- aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Top( ) ) );
- aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Bottom( ) ) );
- aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Bottom( ) ) );
- aPolygon.setClosed( true );
- PolyPolygonColorPrimitive2D* pBack = new PolyPolygonColorPrimitive2D(
- basegfx::B2DPolyPolygon( aPolygon ), aLightColor );
+ B2DPolygon aPolygon;
+ aPolygon.append(B2DPoint(aRect.Left(), aRect.Top()));
+ aPolygon.append(B2DPoint(aRect.Right(), aRect.Top()));
+ aPolygon.append(B2DPoint(aRect.Right(), aRect.Bottom()));
+ aPolygon.append(B2DPoint(aRect.Left(), aRect.Bottom()));
+ aPolygon.setClosed(true);
+
+ PolyPolygonColorPrimitive2D* pBack =
+ new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor);
aSeq[0] = pBack;
LineAttribute aLineAttribute(aDarkColor, 2.0);
// Cross
- basegfx::B2DPolyPolygon aCross;
- basegfx::B2DPolygon aLine1;
- aLine1.append( basegfx::B2DPoint( aRect.Left(), aRect.Top( ) ) );
- aLine1.append( basegfx::B2DPoint( aRect.Right(), aRect.Bottom( ) ) );
- aCross.append( aLine1 );
- basegfx::B2DPolygon aLine2;
- aLine2.append( basegfx::B2DPoint( aRect.Right(), aRect.Top( ) ) );
- aLine2.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom( ) ) );
- aCross.append( aLine2 );
-
- PolyPolygonStrokePrimitive2D * pCross =
+ B2DPolyPolygon aCross;
+
+ B2DPolygon aLine1;
+ aLine1.append(B2DPoint(aRect.Left(), aRect.Top()));
+ aLine1.append(B2DPoint(aRect.Right(), aRect.Bottom()));
+ aCross.append(aLine1);
+
+ B2DPolygon aLine2;
+ aLine2.append(B2DPoint(aRect.Right(), aRect.Top()));
+ aLine2.append(B2DPoint(aRect.Left(), aRect.Bottom()));
+ aCross.append(aLine2);
+
+ PolyPolygonStrokePrimitive2D* pCross =
new PolyPolygonStrokePrimitive2D(aCross, aLineAttribute, StrokeAttribute());
aSeq[1] = pCross;
@@ -96,8 +99,8 @@ namespace
}
}
-SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
- const OUString& sMessage, vector<PushButton*> aButtons ) :
+SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
+ const OUString& sMessage, vector<PushButton*> aButtons) :
Window(pParent, 0),
m_sId(sId),
m_pMessage(new FixedText(this, 0)),
@@ -140,8 +143,8 @@ void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect)
Primitive2DSequence aSeq(2);
- basegfx::BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
- basegfx::BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
+ BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
+ BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if (rSettings.GetHighContrastMode())
@@ -154,25 +157,25 @@ void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect)
m_pMessage->SetBackground(Wallpaper(Color(aLightColor)));
// Light background
- basegfx::B2DPolygon aPolygon;
- aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Top( ) ) );
- aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Top( ) ) );
- aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Bottom( ) ) );
- aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Bottom( ) ) );
+ B2DPolygon aPolygon;
+ aPolygon.append(B2DPoint(aRect.Left(), aRect.Top()));
+ aPolygon.append(B2DPoint(aRect.Right(), aRect.Top()));
+ aPolygon.append(B2DPoint(aRect.Right(), aRect.Bottom()));
+ aPolygon.append(B2DPoint(aRect.Left(), aRect.Bottom()));
aPolygon.setClosed(true);
PolyPolygonColorPrimitive2D* pBack =
- new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), aLightColor);
+ new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor);
aSeq[0] = pBack;
LineAttribute aLineAttribute(aDarkColor, 1.0);
// Bottom dark line
- basegfx::B2DPolygon aPolygonBottom;
- aPolygonBottom.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom( ) ) );
- aPolygonBottom.append( basegfx::B2DPoint( aRect.Right(), aRect.Bottom( ) ) );
+ B2DPolygon aPolygonBottom;
+ aPolygonBottom.append(B2DPoint(aRect.Left(), aRect.Bottom()));
+ aPolygonBottom.append(B2DPoint(aRect.Right(), aRect.Bottom()));
- PolygonStrokePrimitive2D * pLineBottom =
+ PolygonStrokePrimitive2D* pLineBottom =
new PolygonStrokePrimitive2D (aPolygonBottom, aLineAttribute);
aSeq[1] = pLineBottom;
@@ -185,7 +188,7 @@ void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect)
void SfxInfoBarWindow::Resize()
{
long nWidth = GetSizePixel().getWidth();
- m_pCloseBtn->SetPosSizePixel(Point( nWidth - 25, 15), Size(10, 10));
+ m_pCloseBtn->SetPosSizePixel(Point(nWidth - 25, 15), Size(10, 10));
// Reparent the buttons and place them on the right of the bar
long nX = m_pCloseBtn->GetPosPixel().getX() - 15;
@@ -259,11 +262,11 @@ void SfxInfoBarContainerWindow::removeInfoBar(SfxInfoBarWindow* pInfoBar)
long nY = 0;
for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
- it->SetPosPixel( Point( 0, nY ) );
- nY += it->GetSizePixel( ).getHeight( );
+ it->SetPosPixel(Point(0, nY));
+ nY += it->GetSizePixel().getHeight();
}
- Size aSize = GetSizePixel( );
+ Size aSize = GetSizePixel();
aSize.setHeight(nY);
SetSizePixel(aSize);
commit 274f497b2502db146f23eb72426ad38a70934540
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 13:20:20 2015 +0900
Cleanup infobar
Change-Id: I2479b8df69da3c05021a82d269925a6374709c72
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index dc8a51b..a2b2cd7 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -48,12 +48,12 @@ namespace
const unique_ptr<BaseProcessor2D> pProcessor(
createBaseProcessor2DFromOutputDevice(*this, aNewViewInfos));
- const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+ const Rectangle aRect(Point(0, 0), PixelToLogic(GetSizePixel()));
- Primitive2DSequence aSeq( 2 );
+ Primitive2DSequence aSeq(2);
- basegfx::BColor aLightColor( 1.0, 1.0, 191.0 / 255.0 );
- basegfx::BColor aDarkColor( 217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0 );
+ basegfx::BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
+ basegfx::BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
if ( rSettings.GetHighContrastMode() )
@@ -98,22 +98,21 @@ namespace
SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
const OUString& sMessage, vector<PushButton*> aButtons ) :
- Window( pParent, 0 ),
- m_sId( sId ),
+ Window(pParent, 0),
+ m_sId(sId),
m_pMessage(new FixedText(this, 0)),
m_pCloseBtn(new SfxCloseButton(this)),
m_aActionBtns()
{
long nWidth = pParent->GetSizePixel().getWidth();
- SetPosSizePixel( Point( 0, 0 ), Size( nWidth, 40 ) );
+ SetPosSizePixel(Point(0, 0), Size(nWidth, 40));
- m_pMessage->SetText( sMessage );
- m_pMessage->SetBackground( Wallpaper( Color( 255, 255, 191 ) ) );
- m_pMessage->Show( );
+ m_pMessage->SetText(sMessage);
+ m_pMessage->SetBackground(Wallpaper(Color(255, 255, 191)));
+ m_pMessage->Show();
- m_pCloseBtn->SetPosSizePixel( Point( nWidth - 25, 15 ), Size( 10, 10 ) );
- m_pCloseBtn->SetClickHdl( LINK( this, SfxInfoBarWindow, CloseHandler ) );
- m_pCloseBtn->Show( );
+ 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;
@@ -128,31 +127,31 @@ SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
Resize();
}
-SfxInfoBarWindow::~SfxInfoBarWindow( )
+SfxInfoBarWindow::~SfxInfoBarWindow()
{}
-void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
+void SfxInfoBarWindow::Paint(const Rectangle& rPaintRect)
{
const ViewInformation2D aNewViewInfos;
const unique_ptr<BaseProcessor2D> pProcessor(
createBaseProcessor2DFromOutputDevice(*this, aNewViewInfos));
- const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+ const Rectangle aRect(Point(0, 0), PixelToLogic(GetSizePixel()));
- Primitive2DSequence aSeq( 2 );
+ Primitive2DSequence aSeq(2);
- basegfx::BColor aLightColor( 1.0, 1.0, 191.0 / 255.0 );
- basegfx::BColor aDarkColor( 217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0 );
+ basegfx::BColor aLightColor(1.0, 1.0, 191.0 / 255.0);
+ basegfx::BColor aDarkColor(217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0);
const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- if ( rSettings.GetHighContrastMode() )
+ if (rSettings.GetHighContrastMode())
{
- aLightColor = rSettings.GetLightColor( ).getBColor( );
- aDarkColor = rSettings.GetDialogTextColor( ).getBColor( );
+ aLightColor = rSettings.GetLightColor().getBColor();
+ aDarkColor = rSettings.GetDialogTextColor().getBColor();
}
// Update the label background color
- m_pMessage->SetBackground( Wallpaper( Color( aLightColor ) ) );
+ m_pMessage->SetBackground(Wallpaper(Color(aLightColor)));
// Light background
basegfx::B2DPolygon aPolygon;
@@ -160,7 +159,7 @@ void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Top( ) ) );
aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Bottom( ) ) );
aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Bottom( ) ) );
- aPolygon.setClosed( true );
+ aPolygon.setClosed(true);
PolyPolygonColorPrimitive2D* pBack =
new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), aLightColor);
@@ -178,63 +177,63 @@ void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
aSeq[1] = pLineBottom;
- pProcessor->process( aSeq );
+ pProcessor->process(aSeq);
- Window::Paint( rPaintRect );
+ Window::Paint(rPaintRect);
}
void SfxInfoBarWindow::Resize()
{
long nWidth = GetSizePixel().getWidth();
- m_pCloseBtn->SetPosSizePixel( Point( nWidth - 25, 15 ), Size( 10, 10 ) );
+ m_pCloseBtn->SetPosSizePixel(Point( nWidth - 25, 15), Size(10, 10));
// Reparent the buttons and place them on the right of the bar
- long nX = m_pCloseBtn->GetPosPixel( ).getX( ) - 15;
+ long nX = m_pCloseBtn->GetPosPixel().getX() - 15;
long nBtnGap = 5;
boost::ptr_vector<PushButton>::iterator it;
for (it = m_aActionBtns.begin(); it != m_aActionBtns.end(); ++it)
{
- long nBtnWidth = it->GetSizePixel( ).getWidth();
+ long nBtnWidth = it->GetSizePixel().getWidth();
nX -= nBtnWidth;
- it->SetPosSizePixel( Point( nX, 5 ), Size( nBtnWidth, 30 ) );
+ it->SetPosSizePixel(Point(nX, 5), Size(nBtnWidth, 30));
nX -= nBtnGap;
}
- m_pMessage->SetPosSizePixel( Point( 10, 10 ), Size( nX - 20, 20 ) );
+ m_pMessage->SetPosSizePixel(Point(10, 10), Size(nX - 20, 20));
}
-IMPL_LINK_NOARG( SfxInfoBarWindow, CloseHandler )
+IMPL_LINK_NOARG(SfxInfoBarWindow, CloseHandler)
{
- static_cast<SfxInfoBarContainerWindow*>(GetParent())->removeInfoBar( this );
+ static_cast<SfxInfoBarContainerWindow*>(GetParent())->removeInfoBar(this);
return 0;
}
-SfxInfoBarContainerWindow::SfxInfoBarContainerWindow( SfxInfoBarContainerChild* pChildWin ) :
- Window( pChildWin->GetParent( ), 0 ),
- m_pChildWin( pChildWin ),
+SfxInfoBarContainerWindow::SfxInfoBarContainerWindow(SfxInfoBarContainerChild* pChildWin ) :
+ Window(pChildWin->GetParent(), 0),
+ m_pChildWin(pChildWin),
m_pInfoBars()
{
}
-SfxInfoBarContainerWindow::~SfxInfoBarContainerWindow( )
+SfxInfoBarContainerWindow::~SfxInfoBarContainerWindow()
{
}
-void SfxInfoBarContainerWindow::appendInfoBar( const OUString& sId, const OUString& sMessage, vector< PushButton* > aButtons )
+void SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage, vector<PushButton*> aButtons)
{
Size aSize = GetSizePixel( );
- SfxInfoBarWindow* pInfoBar = new SfxInfoBarWindow( this, sId, sMessage, aButtons );
- pInfoBar->SetPosPixel( Point( 0, aSize.getHeight( ) ) );
- pInfoBar->Show( );
- m_pInfoBars.push_back( pInfoBar );
+ SfxInfoBarWindow* pInfoBar = new SfxInfoBarWindow(this, sId, sMessage, aButtons);
+ 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 );
+ long nHeight = pInfoBar->GetSizePixel().getHeight();
+ aSize.setHeight(aSize.getHeight() + nHeight);
+ SetSizePixel(aSize);
}
-SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar( const OUString& sId )
+SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar(const OUString& sId)
{
boost::ptr_vector<SfxInfoBarWindow>::iterator it;
for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
@@ -245,7 +244,7 @@ SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar( const OUString& sId )
return NULL;
}
-void SfxInfoBarContainerWindow::removeInfoBar( SfxInfoBarWindow* pInfoBar )
+void SfxInfoBarContainerWindow::removeInfoBar(SfxInfoBarWindow* pInfoBar)
{
boost::ptr_vector<SfxInfoBarWindow>::iterator it;
for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
@@ -265,56 +264,56 @@ void SfxInfoBarContainerWindow::removeInfoBar( SfxInfoBarWindow* pInfoBar )
}
Size aSize = GetSizePixel( );
- aSize.setHeight( nY );
- SetSizePixel( aSize );
+ aSize.setHeight(nY);
+ SetSizePixel(aSize);
- m_pChildWin->Update( );
+ m_pChildWin->Update();
}
-void SfxInfoBarContainerWindow::Resize( )
+void SfxInfoBarContainerWindow::Resize()
{
// Only need to change the width of the infobars
- long nWidth = GetSizePixel( ).getWidth( );
+ long nWidth = GetSizePixel().getWidth();
boost::ptr_vector<SfxInfoBarWindow>::iterator it;
for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
- Size aSize = it->GetSizePixel( );
- aSize.setWidth( nWidth );
- it->SetSizePixel( aSize );
- it->Resize( );
+ Size aSize = it->GetSizePixel();
+ aSize.setWidth(nWidth);
+ it->SetSizePixel(aSize);
+ it->Resize();
}
}
-SFX_IMPL_POS_CHILDWINDOW_WITHID( SfxInfoBarContainerChild, SID_INFOBAR, SFX_OBJECTBAR_OBJECT );
+SFX_IMPL_POS_CHILDWINDOW_WITHID(SfxInfoBarContainerChild, SID_INFOBAR, SFX_OBJECTBAR_OBJECT);
SfxInfoBarContainerChild::SfxInfoBarContainerChild( vcl::Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* ) :
- SfxChildWindow( _pParent, nId ),
- m_pBindings( pBindings )
+ SfxChildWindow(_pParent, nId),
+ m_pBindings(pBindings)
{
- pWindow = new SfxInfoBarContainerWindow( this );
- pWindow->SetPosSizePixel( Point( 0, 0 ), Size( _pParent->GetSizePixel( ).getWidth(), 0 ) );
- pWindow->Show( );
+ pWindow = new SfxInfoBarContainerWindow(this);
+ pWindow->SetPosSizePixel(Point(0, 0), Size(_pParent->GetSizePixel().getWidth(), 0));
+ pWindow->Show();
eChildAlignment = SFX_ALIGN_LOWESTTOP;
}
-SfxInfoBarContainerChild::~SfxInfoBarContainerChild( )
+SfxInfoBarContainerChild::~SfxInfoBarContainerChild()
{
}
-SfxChildWinInfo SfxInfoBarContainerChild::GetInfo( ) const
+SfxChildWinInfo SfxInfoBarContainerChild::GetInfo() const
{
SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
return aInfo;
}
-void SfxInfoBarContainerChild::Update( )
+void SfxInfoBarContainerChild::Update()
{
// Refresh the frame to take the infobars container height change into account
const sal_uInt16 nId = GetChildWindowId();
- SfxViewFrame* pVFrame = m_pBindings->GetDispatcher( )->GetFrame( );
- pVFrame->ShowChildWindow( nId );
+ SfxViewFrame* pVFrame = m_pBindings->GetDispatcher()->GetFrame();
+ pVFrame->ShowChildWindow(nId);
// Give the focus to the document view
pVFrame->GetWindow().GrabFocusToDocument();
commit efd013f6fc9ff5e1cb13c23c60a7e4644c2d99de
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 13:13:20 2015 +0900
reuse Resize to set control size and placement in infobar
Change-Id: I4e11cd8f02c41f73b2dda05effbcc17db036f3fc
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index fbc095f..dc8a51b 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -106,6 +106,7 @@ SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
{
long nWidth = pParent->GetSizePixel().getWidth();
SetPosSizePixel( Point( 0, 0 ), Size( nWidth, 40 ) );
+
m_pMessage->SetText( sMessage );
m_pMessage->SetBackground( Wallpaper( Color( 255, 255, 191 ) ) );
m_pMessage->Show( );
@@ -115,22 +116,16 @@ SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
m_pCloseBtn->Show( );
// Reparent the buttons and place them on the right of the bar
- long nX = m_pCloseBtn->GetPosPixel( ).getX( ) - 15;
- long nBtnGap = 5;
vector<PushButton*>::iterator it;
for (it = aButtons.begin(); it != aButtons.end(); ++it)
{
- PushButton* pBtn = *it;
- pBtn->SetParent( this );
- long nBtnWidth = pBtn->GetSizePixel( ).getWidth();
- nX -= nBtnWidth;
- pBtn->SetPosSizePixel( Point( nX, 5 ), Size( nBtnWidth, 30 ) );
- nX -= nBtnGap;
- pBtn->Show( );
- m_aActionBtns.push_back(pBtn);
+ PushButton* pButton = *it;
+ pButton->SetParent(this);
+ pButton->Show();
+ m_aActionBtns.push_back(pButton);
}
- m_pMessage->SetPosSizePixel( Point( 10, 10 ), Size( nX - 20, 20 ) );
+ Resize();
}
SfxInfoBarWindow::~SfxInfoBarWindow( )
@@ -166,6 +161,7 @@ void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Bottom( ) ) );
aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Bottom( ) ) );
aPolygon.setClosed( true );
+
PolyPolygonColorPrimitive2D* pBack =
new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), aLightColor);
aSeq[0] = pBack;
@@ -187,7 +183,7 @@ void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
Window::Paint( rPaintRect );
}
-void SfxInfoBarWindow::Resize( )
+void SfxInfoBarWindow::Resize()
{
long nWidth = GetSizePixel().getWidth();
m_pCloseBtn->SetPosSizePixel( Point( nWidth - 25, 15 ), Size( 10, 10 ) );
commit 767ec4666f5edea8aa8e5c6aa299c1312973e5e7
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Jan 13 12:42:43 2015 +0900
Cleanup SfxZoomDialog, convert plain pointer to unique_ptr
Change-Id: I50f16a6c2ec3dcbb12881ab42d0a2f9556cf7ec8
diff --git a/cui/source/dialogs/zoom.cxx b/cui/source/dialogs/zoom.cxx
index 6fee5a5..5107c6e 100644
--- a/cui/source/dialogs/zoom.cxx
+++ b/cui/source/dialogs/zoom.cxx
@@ -31,27 +31,29 @@
#include <dialmgr.hxx>
#include <svx/zoom_def.hxx>
-// static ----------------------------------------------------------------
+namespace
+{
-#define SPECIAL_FACTOR ((sal_uInt16)0xFFFF)
+const sal_uInt16 SPECIAL_FACTOR = 0xFFFF;
-// class SvxZoomDialog ---------------------------------------------------
+} // anonymous namespace
sal_uInt16 SvxZoomDialog::GetFactor() const
{
- if ( m_p100Btn->IsChecked() )
+ if (m_p100Btn->IsChecked())
return 100;
- if ( m_pUserBtn->IsChecked() )
- return (sal_uInt16)m_pUserEdit->GetValue();
+
+ if (m_pUserBtn->IsChecked())
+ return static_cast<sal_uInt16>(m_pUserEdit->GetValue());
else
return SPECIAL_FACTOR;
}
-void SvxZoomDialog::SetFactor( sal_uInt16 nNewFactor, sal_uInt16 nBtnId )
+void SvxZoomDialog::SetFactor(sal_uInt16 nNewFactor, sal_uInt16 nButtonId)
{
m_pUserEdit->Disable();
- if ( !nBtnId )
+ if (!nButtonId)
{
if ( nNewFactor == 100 )
{
@@ -62,35 +64,37 @@ void SvxZoomDialog::SetFactor( sal_uInt16 nNewFactor, sal_uInt16 nBtnId )
{
m_pUserBtn->Check();
m_pUserEdit->Enable();
- m_pUserEdit->SetValue( (long)nNewFactor );
+ m_pUserEdit->SetValue(static_cast<long>(nNewFactor));
m_pUserEdit->GrabFocus();
}
}
else
{
- m_pUserEdit->SetValue( (long)nNewFactor );
-
- if ( ZOOMBTN_OPTIMAL == nBtnId )
- {
- m_pOptimalBtn->Check();
- m_pOptimalBtn->GrabFocus();
- }
- else if ( ZOOMBTN_PAGEWIDTH == nBtnId )
- {
- m_pPageWidthBtn->Check();
- m_pPageWidthBtn->GrabFocus();
- }
- else if ( ZOOMBTN_WHOLEPAGE == nBtnId )
+ m_pUserEdit->SetValue(static_cast<long>(nNewFactor));
+ switch(nButtonId)
{
- m_pWholePageBtn->Check();
- m_pWholePageBtn->GrabFocus();
+ case ZOOMBTN_OPTIMAL:
+ {
+ m_pOptimalBtn->Check();
+ m_pOptimalBtn->GrabFocus();
+ }
+ case ZOOMBTN_PAGEWIDTH:
+ {
+ m_pPageWidthBtn->Check();
+ m_pPageWidthBtn->GrabFocus();
+ }
+ case ZOOMBTN_WHOLEPAGE:
+ {
+ m_pWholePageBtn->Check();
+ m_pWholePageBtn->GrabFocus();
+ }
}
}
}
-void SvxZoomDialog::HideButton( sal_uInt16 nBtnId )
+void SvxZoomDialog::HideButton(sal_uInt16 nButtonId)
{
- switch ( nBtnId )
+ switch (nButtonId)
{
case ZOOMBTN_OPTIMAL:
m_pOptimalBtn->Hide();
@@ -109,20 +113,25 @@ void SvxZoomDialog::HideButton( sal_uInt16 nBtnId )
}
}
-void SvxZoomDialog::SetLimits( sal_uInt16 nMin, sal_uInt16 nMax )
+void SvxZoomDialog::SetLimits(sal_uInt16 nMin, sal_uInt16 nMax)
+{
+ DBG_ASSERT(nMin < nMax, "invalid limits");
+ m_pUserEdit->SetMin(nMin);
+ m_pUserEdit->SetFirst(nMin);
+ m_pUserEdit->SetMax(nMax);
+ m_pUserEdit->SetLast(nMax);
+}
+
+const SfxItemSet* SvxZoomDialog::GetOutputItemSet() const
{
- DBG_ASSERT( nMin < nMax, "invalid limits" );
- m_pUserEdit->SetMin( nMin );
- m_pUserEdit->SetFirst( nMin );
- m_pUserEdit->SetMax( nMax );
- m_pUserEdit->SetLast( nMax );
+ return mpOutSet.get();
}
SvxZoomDialog::SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet )
: SfxModalDialog(pParent, "ZoomDialog", "cui/ui/zoomdialog.ui")
- , rSet(rCoreSet)
- , pOutSet(NULL)
- , bModified(false)
+ , mrSet(rCoreSet)
+ , mpOutSet()
+ , mbModified(false)
{
get(m_pOptimalBtn, "optimal");
@@ -138,26 +147,26 @@ SvxZoomDialog::SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet )
get(m_pColumnsEdit, "columnssb");
get(m_pBookModeChk, "bookmode");
get(m_pOKBtn, "ok");
- Link aLink = LINK( this, SvxZoomDialog, UserHdl );
- m_p100Btn->SetClickHdl( aLink );
- m_pOptimalBtn->SetClickHdl( aLink );
- m_pPageWidthBtn->SetClickHdl( aLink );
- m_pWholePageBtn->SetClickHdl( aLink );
- m_pUserBtn->SetClickHdl( aLink );
+ Link aLink = LINK(this, SvxZoomDialog, UserHdl);
+ m_p100Btn->SetClickHdl(aLink);
+ m_pOptimalBtn->SetClickHdl(aLink);
+ m_pPageWidthBtn->SetClickHdl(aLink);
+ m_pWholePageBtn->SetClickHdl(aLink);
+ m_pUserBtn->SetClickHdl(aLink);
- Link aViewLayoutLink = LINK( this, SvxZoomDialog, ViewLayoutUserHdl );
- m_pAutomaticBtn->SetClickHdl( aViewLayoutLink );
- m_pSingleBtn->SetClickHdl( aViewLayoutLink );
- m_pColumnsBtn->SetClickHdl( aViewLayoutLink );
+ Link aViewLayoutLink = LINK(this, SvxZoomDialog, ViewLayoutUserHdl);
+ m_pAutomaticBtn->SetClickHdl(aViewLayoutLink);
+ m_pSingleBtn->SetClickHdl(aViewLayoutLink);
+ m_pColumnsBtn->SetClickHdl(aViewLayoutLink);
- Link aViewLayoutSpinLink = LINK( this, SvxZoomDialog, ViewLayoutSpinHdl );
- m_pColumnsEdit->SetModifyHdl( aViewLayoutSpinLink );
+ Link aViewLayoutSpinLink = LINK(this, SvxZoomDialog, ViewLayoutSpinHdl);
+ m_pColumnsEdit->SetModifyHdl(aViewLayoutSpinLink);
- Link aViewLayoutCheckLink = LINK( this, SvxZoomDialog, ViewLayoutCheckHdl );
- m_pBookModeChk->SetClickHdl( aViewLayoutCheckLink );
+ Link aViewLayoutCheckLink = LINK(this, SvxZoomDialog, ViewLayoutCheckHdl);
+ m_pBookModeChk->SetClickHdl(aViewLayoutCheckLink);
- m_pOKBtn->SetClickHdl( LINK( this, SvxZoomDialog, OKHdl ) );
- m_pUserEdit->SetModifyHdl( LINK( this, SvxZoomDialog, SpinHdl ) );
+ m_pOKBtn->SetClickHdl(LINK(this, SvxZoomDialog, OKHdl));
+ m_pUserEdit->SetModifyHdl(LINK(this, SvxZoomDialog, SpinHdl));
// default values
sal_uInt16 nValue = 100;
@@ -166,50 +175,48 @@ SvxZoomDialog::SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet )
// maybe get the old value first
const SfxUInt16Item* pOldUserItem = 0;
- SfxObjectShell* pSh = SfxObjectShell::Current();
+ SfxObjectShell* pShell = SfxObjectShell::Current();
- if ( pSh )
- pOldUserItem = static_cast<const SfxUInt16Item*>(pSh->GetItem( SID_ATTR_ZOOM_USER ));
+ if (pShell)
+ pOldUserItem = static_cast<const SfxUInt16Item*>(pShell->GetItem(SID_ATTR_ZOOM_USER));
- if ( pOldUserItem )
+ if (pOldUserItem)
nValue = pOldUserItem->GetValue();
// initialize UserEdit
- if ( nMin > nValue )
+ if (nMin > nValue)
nMin = nValue;
- if ( nMax < nValue )
+ if (nMax < nValue)
nMax = nValue;
- m_pUserEdit->SetMin( nMin );
- m_pUserEdit->SetFirst( nMin );
- m_pUserEdit->SetMax( nMax );
- m_pUserEdit->SetLast( nMax );
- m_pUserEdit->SetValue( nValue );
+
+ SetLimits(nMin, nMax);
+ m_pUserEdit->SetValue(nValue);
m_pUserEdit->SetAccessibleName(m_pUserBtn->GetText());
m_pColumnsEdit->SetAccessibleName(m_pColumnsBtn->GetText());
m_pColumnsEdit->SetAccessibleRelationMemberOf(m_pColumnsBtn);
m_pBookModeChk->SetAccessibleRelationMemberOf(m_pColumnsBtn);
- const SfxPoolItem& rItem = rSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_ZOOM ) );
+ const SfxPoolItem& rItem = mrSet.Get(mrSet.GetPool()->GetWhich(SID_ATTR_ZOOM));
- if ( rItem.ISA(SvxZoomItem) )
+ if (rItem.ISA(SvxZoomItem))
{
const SvxZoomItem& rZoomItem = static_cast<const SvxZoomItem&>(rItem);
const sal_uInt16 nZoom = rZoomItem.GetValue();
const SvxZoomType eType = rZoomItem.GetType();
const sal_uInt16 nValSet = rZoomItem.GetValueSet();
- sal_uInt16 nBtnId = 0;
+ sal_uInt16 nButtonId = 0;
- switch ( eType )
+ switch (eType)
{
case SVX_ZOOM_OPTIMAL:
- nBtnId = ZOOMBTN_OPTIMAL;
+ nButtonId = ZOOMBTN_OPTIMAL;
break;
case SVX_ZOOM_PAGEWIDTH:
- nBtnId = ZOOMBTN_PAGEWIDTH;
+ nButtonId = ZOOMBTN_PAGEWIDTH;
break;
case SVX_ZOOM_WHOLEPAGE:
- nBtnId = ZOOMBTN_WHOLEPAGE;
+ nButtonId = ZOOMBTN_WHOLEPAGE;
break;
case SVX_ZOOM_PERCENT:
break;
@@ -217,54 +224,56 @@ SvxZoomDialog::SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet )
break;
}
- if ( !(SVX_ZOOM_ENABLE_100 & nValSet) )
+ if (!(SVX_ZOOM_ENABLE_100 & nValSet))
m_p100Btn->Disable();
- if ( !(SVX_ZOOM_ENABLE_OPTIMAL & nValSet) )
+ if (!(SVX_ZOOM_ENABLE_OPTIMAL & nValSet))
m_pOptimalBtn->Disable();
- if ( !(SVX_ZOOM_ENABLE_PAGEWIDTH & nValSet) )
+ if (!(SVX_ZOOM_ENABLE_PAGEWIDTH & nValSet))
m_pPageWidthBtn->Disable();
- if ( !(SVX_ZOOM_ENABLE_WHOLEPAGE & nValSet) )
+ if (!(SVX_ZOOM_ENABLE_WHOLEPAGE & nValSet))
m_pWholePageBtn->Disable();
- SetFactor( nZoom, nBtnId );
+
+ SetFactor(nZoom, nButtonId);
}
else
{
const sal_uInt16 nZoom = static_cast<const SfxUInt16Item&>(rItem).GetValue();
- SetFactor( nZoom );
+ SetFactor(nZoom);
}
- const SfxPoolItem* pViewLayoutItem = 0;
- if ( SfxItemState::SET == rSet.GetItemState( SID_ATTR_VIEWLAYOUT, false, &pViewLayoutItem ) )
+ const SfxPoolItem* pPoolViewLayoutItem = NULL;
+ if (SfxItemState::SET == mrSet.GetItemState(SID_ATTR_VIEWLAYOUT, false, &pPoolViewLayoutItem))
{
- const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem*>(pViewLayoutItem)->GetValue();
- const bool bBookMode = static_cast<const SvxViewLayoutItem*>(pViewLayoutItem)->IsBookMode();
+ const SvxViewLayoutItem* pViewLayoutItem = static_cast<const SvxViewLayoutItem*>(pPoolViewLayoutItem);
+ const sal_uInt16 nColumns = pViewLayoutItem->GetValue();
+ const bool bBookMode = pViewLayoutItem->IsBookMode();
- if ( 0 == nColumns )
+ if (0 == nColumns)
{
m_pAutomaticBtn->Check();
- m_pColumnsEdit->SetValue( 2 );
+ m_pColumnsEdit->SetValue(2);
m_pColumnsEdit->Disable();
m_pBookModeChk->Disable();
}
- else if ( 1 == nColumns)
+ else if (1 == nColumns)
{
m_pSingleBtn->Check();
- m_pColumnsEdit->SetValue( 2 );
+ m_pColumnsEdit->SetValue(2);
m_pColumnsEdit->Disable();
m_pBookModeChk->Disable();
}
else
{
m_pColumnsBtn->Check();
- if ( !bBookMode )
+ if (!bBookMode)
{
- m_pColumnsEdit->SetValue( nColumns );
- if ( 0 != nColumns % 2 )
+ m_pColumnsEdit->SetValue(nColumns);
+ if (nColumns % 2 != 0)
m_pBookModeChk->Disable();
}
else
{
- m_pColumnsEdit->SetValue( nColumns );
+ m_pColumnsEdit->SetValue(nColumns);
m_pBookModeChk->Check();
}
}
@@ -277,52 +286,52 @@ SvxZoomDialog::SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet )
}
SvxZoomDialog::~SvxZoomDialog()
-{
- delete pOutSet;
- pOutSet = 0;
-}
+{}
-IMPL_LINK( SvxZoomDialog, UserHdl, RadioButton *, pBtn )
+IMPL_LINK(SvxZoomDialog, UserHdl, RadioButton *, pButton)
{
- bModified = true;
+ mbModified = true;
- if (pBtn == m_pUserBtn)
+ if (pButton == m_pUserBtn)
{
m_pUserEdit->Enable();
m_pUserEdit->GrabFocus();
}
else
+ {
m_pUserEdit->Disable();
+ }
return 0;
}
IMPL_LINK_NOARG(SvxZoomDialog, SpinHdl)
{
- if ( !m_pUserBtn->IsChecked() )
+ if (!m_pUserBtn->IsChecked())
return 0;
- bModified = true;
+
+ mbModified = true;
return 0;
}
-IMPL_LINK( SvxZoomDialog, ViewLayoutUserHdl, RadioButton *, pBtn )
+IMPL_LINK(SvxZoomDialog, ViewLayoutUserHdl, RadioButton*, pButton)
{
- bModified = true;
+ mbModified = true;
- if (pBtn == m_pAutomaticBtn)
+ if (pButton == m_pAutomaticBtn)
{
m_pColumnsEdit->Disable();
m_pBookModeChk->Disable();
}
- else if (pBtn == m_pSingleBtn)
+ else if (pButton == m_pSingleBtn)
{
m_pColumnsEdit->Disable();
m_pBookModeChk->Disable();
}
- else if (pBtn == m_pColumnsBtn)
+ else if (pButton == m_pColumnsBtn)
{
m_pColumnsEdit->Enable();
m_pColumnsEdit->GrabFocus();
- if ( 0 == m_pColumnsEdit->GetValue() % 2 )
+ if (m_pColumnsEdit->GetValue() % 2 == 0)
m_pBookModeChk->Enable();
}
else
@@ -334,71 +343,75 @@ IMPL_LINK( SvxZoomDialog, ViewLayoutUserHdl, RadioButton *, pBtn )
return 0;
}
-IMPL_LINK( SvxZoomDialog, ViewLayoutSpinHdl, NumericField *, pEdt )
+IMPL_LINK(SvxZoomDialog, ViewLayoutSpinHdl, NumericField*, pEdit)
{
- if ( pEdt == m_pColumnsEdit && !m_pColumnsBtn->IsChecked() )
+ if (pEdit == m_pColumnsEdit && !m_pColumnsBtn->IsChecked())
return 0;
- if ( 0 == m_pColumnsEdit->GetValue() % 2 )
+ if (m_pColumnsEdit->GetValue() % 2 == 0)
+ {
m_pBookModeChk->Enable();
+ }
else
{
- m_pBookModeChk->Check( false );
+ m_pBookModeChk->Check(false);
m_pBookModeChk->Disable();
}
- bModified = true;
+ mbModified = true;
return 0;
}
-IMPL_LINK( SvxZoomDialog, ViewLayoutCheckHdl, CheckBox *, pChk )
+IMPL_LINK(SvxZoomDialog, ViewLayoutCheckHdl, CheckBox*, pCheckBox)
{
- if (pChk == m_pBookModeChk && !m_pColumnsBtn->IsChecked())
+ if (pCheckBox == m_pBookModeChk && !m_pColumnsBtn->IsChecked())
return 0;
- bModified = true;
+ mbModified = true;
return 0;
}
-IMPL_LINK( SvxZoomDialog, OKHdl, Button *, pBtn )
+IMPL_LINK(SvxZoomDialog, OKHdl, Button*, pButton)
{
- if ( bModified || m_pOKBtn != pBtn )
+ if (mbModified || m_pOKBtn != pButton)
{
- SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, 0, rSet.GetPool()->GetWhich( SID_ATTR_ZOOM ) );
- SvxViewLayoutItem aViewLayoutItem( 0, false, rSet.GetPool()->GetWhich( SID_ATTR_VIEWLAYOUT ) );
+ SvxZoomItem aZoomItem(SVX_ZOOM_PERCENT, 0, mrSet.GetPool()->GetWhich(SID_ATTR_ZOOM));
+ SvxViewLayoutItem aViewLayoutItem(0, false, mrSet.GetPool()->GetWhich(SID_ATTR_VIEWLAYOUT));
- if ( m_pOKBtn == pBtn )
+ if (m_pOKBtn == pButton)
{
sal_uInt16 nFactor = GetFactor();
- if ( SPECIAL_FACTOR == nFactor )
+ if (SPECIAL_FACTOR == nFactor)
{
- if ( m_pOptimalBtn->IsChecked() )
- aZoomItem.SetType( SVX_ZOOM_OPTIMAL );
- else if ( m_pPageWidthBtn->IsChecked() )
- aZoomItem.SetType( SVX_ZOOM_PAGEWIDTH );
- else if ( m_pWholePageBtn->IsChecked() )
- aZoomItem.SetType( SVX_ZOOM_WHOLEPAGE );
+ if (m_pOptimalBtn->IsChecked())
+ aZoomItem.SetType(SVX_ZOOM_OPTIMAL);
+ else if (m_pPageWidthBtn->IsChecked())
+ aZoomItem.SetType(SVX_ZOOM_PAGEWIDTH);
+ else if (m_pWholePageBtn->IsChecked())
+ aZoomItem.SetType(SVX_ZOOM_WHOLEPAGE);
}
else
- aZoomItem.SetValue( nFactor );
+ {
+ aZoomItem.SetValue(nFactor);
+ }
- if ( m_pAutomaticBtn->IsChecked() )
+ if (m_pAutomaticBtn->IsChecked())
{
- aViewLayoutItem.SetValue( 0 );
- aViewLayoutItem.SetBookMode( false );
+ aViewLayoutItem.SetValue(0);
+ aViewLayoutItem.SetBookMode(false);
}
- if ( m_pSingleBtn->IsChecked() )
+ if (m_pSingleBtn->IsChecked())
{
- aViewLayoutItem.SetValue( 1 );
- aViewLayoutItem.SetBookMode( false );
+ aViewLayoutItem.SetValue(1);
+ aViewLayoutItem.SetBookMode(false);
}
- else if ( m_pColumnsBtn->IsChecked() )
+ else if (m_pColumnsBtn->IsChecked())
{
- aViewLayoutItem.SetValue( static_cast<sal_uInt16>(m_pColumnsEdit->GetValue()) );
- aViewLayoutItem.SetBookMode( m_pBookModeChk->IsChecked() );
+ aViewLayoutItem.SetValue(static_cast<sal_uInt16>(m_pColumnsEdit->GetValue()));
+ aViewLayoutItem.SetBookMode(m_pBookModeChk->IsChecked());
}
}
else
@@ -406,23 +419,27 @@ IMPL_LINK( SvxZoomDialog, OKHdl, Button *, pBtn )
OSL_FAIL("Wrong Button");
return 0;
}
- pOutSet = new SfxItemSet( rSet );
- pOutSet->Put( aZoomItem );
+ mpOutSet.reset(new SfxItemSet(mrSet));
+ mpOutSet->Put(aZoomItem);
// don't set attribute in case the whole viewlayout stuff is disabled:
if (m_pViewFrame->IsEnabled())
- pOutSet->Put(aViewLayoutItem);
+ mpOutSet->Put(aViewLayoutItem);
// memorize value from the UserEdit beyond the dialog
SfxObjectShell* pShell = SfxObjectShell::Current();
- if ( pShell )
- pShell->PutItem( SfxUInt16Item( SID_ATTR_ZOOM_USER,
- (sal_uInt16)m_pUserEdit->GetValue() ) );
+ if (pShell)
+ {
+ sal_uInt16 nZoomValue = static_cast<sal_uInt16>(m_pUserEdit->GetValue());
+ pShell->PutItem(SfxUInt16Item(SID_ATTR_ZOOM_USER, nZoomValue));
+ }
EndDialog( RET_OK );
}
else
+ {
EndDialog( RET_CANCEL );
+ }
return 0;
}
diff --git a/cui/source/inc/zoom.hxx b/cui/source/inc/zoom.hxx
index a8b3176..3cccace 100644
--- a/cui/source/inc/zoom.hxx
+++ b/cui/source/inc/zoom.hxx
@@ -27,44 +27,44 @@
class SvxZoomDialog : public SfxModalDialog
{
private:
- RadioButton* m_pOptimalBtn;
- RadioButton* m_pWholePageBtn;
- RadioButton* m_pPageWidthBtn;
- RadioButton* m_p100Btn;
- RadioButton* m_pUserBtn;
- MetricField* m_pUserEdit;
+ RadioButton* m_pOptimalBtn;
+ RadioButton* m_pWholePageBtn;
+ RadioButton* m_pPageWidthBtn;
+ RadioButton* m_p100Btn;
+ RadioButton* m_pUserBtn;
+ MetricField* m_pUserEdit;
- VclContainer* m_pViewFrame;
- RadioButton* m_pAutomaticBtn;
- RadioButton* m_pSingleBtn;
- RadioButton* m_pColumnsBtn;
- NumericField* m_pColumnsEdit;
- CheckBox* m_pBookModeChk;
+ VclContainer* m_pViewFrame;
+ RadioButton* m_pAutomaticBtn;
+ RadioButton* m_pSingleBtn;
+ RadioButton* m_pColumnsBtn;
+ NumericField* m_pColumnsEdit;
+ CheckBox* m_pBookModeChk;
- OKButton* m_pOKBtn;
+ OKButton* m_pOKBtn;
- const SfxItemSet& rSet;
- SfxItemSet* pOutSet;
- bool bModified;
+ const SfxItemSet& mrSet;
+ std::unique_ptr<SfxItemSet> mpOutSet;
+ bool mbModified;
- DECL_LINK( UserHdl, RadioButton* );
- DECL_LINK(SpinHdl, void *);
- DECL_LINK( ViewLayoutUserHdl, RadioButton* );
- DECL_LINK( ViewLayoutSpinHdl, NumericField* );
- DECL_LINK( ViewLayoutCheckHdl, CheckBox* );
- DECL_LINK( OKHdl, Button* );
+ DECL_LINK(UserHdl, RadioButton*);
+ DECL_LINK(SpinHdl, void*);
+ DECL_LINK(ViewLayoutUserHdl, RadioButton*);
+ DECL_LINK(ViewLayoutSpinHdl, NumericField*);
+ DECL_LINK(ViewLayoutCheckHdl, CheckBox*);
+ DECL_LINK(OKHdl, Button*);
public:
- SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet );
+ SvxZoomDialog(vcl::Window* pParent, const SfxItemSet& rCoreSet);
virtual ~SvxZoomDialog();
- const SfxItemSet* GetOutputItemSet() const { return pOutSet; }
+ const SfxItemSet* GetOutputItemSet() const;
- sal_uInt16 GetFactor() const;
- void SetFactor( sal_uInt16 nNewFactor, sal_uInt16 nBtnId = 0 );
+ sal_uInt16 GetFactor() const;
+ void SetFactor(sal_uInt16 nNewFactor, sal_uInt16 nButtonId = 0);
- void HideButton( sal_uInt16 nBtnId );
- void SetLimits( sal_uInt16 nMin, sal_uInt16 nMax );
+ void HideButton(sal_uInt16 nButtonId);
+ void SetLimits(sal_uInt16 nMin, sal_uInt16 nMax);
};
#endif
commit 3b3eeff3fdf19833b8793e15c9a57ff3044d9118
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Fri Jan 9 23:53:16 2015 +0900
infobar: unique_ptr and make more readable
Change-Id: Iadaba3d9c16bdde3715d4836fa0d5661b90ccab4
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index d49b5e2..fbc095f 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -22,6 +22,11 @@
#include <vcl/settings.hxx>
using namespace std;
+using namespace drawinglayer::geometry;
+using namespace drawinglayer::processor2d;
+using namespace drawinglayer::primitive2d;
+using namespace drawinglayer::attribute;
+using namespace drawinglayer::geometry;
namespace
{
@@ -39,14 +44,13 @@ namespace
void SfxCloseButton::Paint( const Rectangle& )
{
- const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
- drawinglayer::processor2d::BaseProcessor2D * pProcessor =
- drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
- *this, aNewViewInfos );
+ const ViewInformation2D aNewViewInfos;
+ const unique_ptr<BaseProcessor2D> pProcessor(
+ createBaseProcessor2DFromOutputDevice(*this, aNewViewInfos));
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
- drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
+ Primitive2DSequence aSeq( 2 );
basegfx::BColor aLightColor( 1.0, 1.0, 191.0 / 255.0 );
basegfx::BColor aDarkColor( 217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0 );
@@ -66,12 +70,11 @@ namespace
aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Bottom( ) ) );
aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Bottom( ) ) );
aPolygon.setClosed( true );
- drawinglayer::primitive2d::PolyPolygonColorPrimitive2D* pBack =
- new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ PolyPolygonColorPrimitive2D* pBack = new PolyPolygonColorPrimitive2D(
basegfx::B2DPolyPolygon( aPolygon ), aLightColor );
aSeq[0] = pBack;
- drawinglayer::attribute::LineAttribute aLineAttribute( aDarkColor, 2.0 );
+ LineAttribute aLineAttribute(aDarkColor, 2.0);
// Cross
basegfx::B2DPolyPolygon aCross;
@@ -84,14 +87,12 @@ namespace
aLine2.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom( ) ) );
aCross.append( aLine2 );
- drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pCross =
- new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
- aCross, aLineAttribute, drawinglayer::attribute::StrokeAttribute( ) );
+ PolyPolygonStrokePrimitive2D * pCross =
+ new PolyPolygonStrokePrimitive2D(aCross, aLineAttribute, StrokeAttribute());
aSeq[1] = pCross;
- pProcessor->process( aSeq );
- delete pProcessor;
+ pProcessor->process(aSeq);
}
}
@@ -137,14 +138,13 @@ SfxInfoBarWindow::~SfxInfoBarWindow( )
void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
{
- const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
- drawinglayer::processor2d::BaseProcessor2D * pProcessor =
- drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
- *this, aNewViewInfos );
+ const ViewInformation2D aNewViewInfos;
+ const unique_ptr<BaseProcessor2D> pProcessor(
+ createBaseProcessor2DFromOutputDevice(*this, aNewViewInfos));
const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
- drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
+ Primitive2DSequence aSeq( 2 );
basegfx::BColor aLightColor( 1.0, 1.0, 191.0 / 255.0 );
basegfx::BColor aDarkColor( 217.0 / 255.0, 217.0 / 255.0, 78.0 / 255.0 );
@@ -166,26 +166,23 @@ void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
aPolygon.append( basegfx::B2DPoint( aRect.Right( ), aRect.Bottom( ) ) );
aPolygon.append( basegfx::B2DPoint( aRect.Left( ), aRect.Bottom( ) ) );
aPolygon.setClosed( true );
- drawinglayer::primitive2d::PolyPolygonColorPrimitive2D* pBack =
- new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
- basegfx::B2DPolyPolygon( aPolygon ), aLightColor );
+ PolyPolygonColorPrimitive2D* pBack =
+ new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), aLightColor);
aSeq[0] = pBack;
- drawinglayer::attribute::LineAttribute aLineAttribute( aDarkColor, 1.0 );
+ LineAttribute aLineAttribute(aDarkColor, 1.0);
// Bottom dark line
basegfx::B2DPolygon aPolygonBottom;
aPolygonBottom.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom( ) ) );
aPolygonBottom.append( basegfx::B2DPoint( aRect.Right(), aRect.Bottom( ) ) );
- drawinglayer::primitive2d::PolygonStrokePrimitive2D * pLineBottom =
- new drawinglayer::primitive2d::PolygonStrokePrimitive2D (
- aPolygonBottom, aLineAttribute );
+ PolygonStrokePrimitive2D * pLineBottom =
+ new PolygonStrokePrimitive2D (aPolygonBottom, aLineAttribute);
aSeq[1] = pLineBottom;
pProcessor->process( aSeq );
- delete pProcessor;
Window::Paint( rPaintRect );
}
commit 283170e7a37855b6902d3828e42f3265057d9c77
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Fri Jan 9 23:43:31 2015 +0900
ptr_vector & unique_ptr for infobar
Change-Id: Id0d9be65aff504ff6092fa64e8207ddb1b7aeea5
diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 386e415..ee92d39 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -17,6 +17,8 @@
#include <sfx2/dllapi.h>
#include <sfx2/childwin.hxx>
+#include <boost/ptr_container/ptr_vector.hpp>
+
/** SfxChildWindow for positioning the InfoBar in the view.
*/
class SFX2_DLLPUBLIC SfxInfoBarContainerChild : public SfxChildWindow
@@ -41,10 +43,12 @@ class SFX2_DLLPUBLIC SfxInfoBarContainerChild : public SfxChildWindow
class SfxInfoBarWindow : public vcl::Window
{
private:
- OUString m_sId;
- FixedText* m_pMessage;
- Button* m_pCloseBtn;
- std::vector< PushButton* > m_aActionBtns;
+ OUString m_sId;
+
+ std::unique_ptr<FixedText> m_pMessage;
+ std::unique_ptr<Button> m_pCloseBtn;
+
+ boost::ptr_vector<PushButton> m_aActionBtns;
public:
SfxInfoBarWindow( vcl::Window* parent, const OUString& sId,
@@ -63,8 +67,8 @@ class SfxInfoBarWindow : public vcl::Window
class SfxInfoBarContainerWindow : public vcl::Window
{
private:
- SfxInfoBarContainerChild* m_pChildWin;
- std::vector< SfxInfoBarWindow* > m_pInfoBars;
+ SfxInfoBarContainerChild* m_pChildWin;
+ boost::ptr_vector<SfxInfoBarWindow> m_pInfoBars;
public:
SfxInfoBarContainerWindow( SfxInfoBarContainerChild* pChildWin );
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index fdb37eb..d49b5e2 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -96,21 +96,19 @@ namespace
}
SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
- const OUString& sMessage, vector< PushButton* > aButtons ) :
+ const OUString& sMessage, vector<PushButton*> aButtons ) :
Window( pParent, 0 ),
m_sId( sId ),
- m_pMessage( NULL ),
- m_pCloseBtn( NULL ),
- m_aActionBtns( aButtons )
+ m_pMessage(new FixedText(this, 0)),
+ m_pCloseBtn(new SfxCloseButton(this)),
+ m_aActionBtns()
{
long nWidth = pParent->GetSizePixel().getWidth();
SetPosSizePixel( Point( 0, 0 ), Size( nWidth, 40 ) );
- m_pMessage = new FixedText( this, 0 );
m_pMessage->SetText( sMessage );
m_pMessage->SetBackground( Wallpaper( Color( 255, 255, 191 ) ) );
m_pMessage->Show( );
- m_pCloseBtn = new SfxCloseButton( this );
m_pCloseBtn->SetPosSizePixel( Point( nWidth - 25, 15 ), Size( 10, 10 ) );
m_pCloseBtn->SetClickHdl( LINK( this, SfxInfoBarWindow, CloseHandler ) );
m_pCloseBtn->Show( );
@@ -118,8 +116,8 @@ SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
// Reparent the buttons and place them on the right of the bar
long nX = m_pCloseBtn->GetPosPixel( ).getX( ) - 15;
long nBtnGap = 5;
- for ( vector< PushButton* >::iterator it = m_aActionBtns.begin( );
- it != m_aActionBtns.end( ); ++it )
+ vector<PushButton*>::iterator it;
+ for (it = aButtons.begin(); it != aButtons.end(); ++it)
{
PushButton* pBtn = *it;
pBtn->SetParent( this );
@@ -128,23 +126,14 @@ SfxInfoBarWindow::SfxInfoBarWindow( vcl::Window* pParent, const OUString& sId,
pBtn->SetPosSizePixel( Point( nX, 5 ), Size( nBtnWidth, 30 ) );
nX -= nBtnGap;
pBtn->Show( );
+ m_aActionBtns.push_back(pBtn);
}
m_pMessage->SetPosSizePixel( Point( 10, 10 ), Size( nX - 20, 20 ) );
}
SfxInfoBarWindow::~SfxInfoBarWindow( )
-{
- delete m_pMessage;
- delete m_pCloseBtn;
-
- for ( vector< PushButton* >::iterator it = m_aActionBtns.begin( );
- it != m_aActionBtns.end( ); ++it )
- {
- delete *it;
- }
- m_aActionBtns.clear( );
-}
+{}
void SfxInfoBarWindow::Paint( const Rectangle& rPaintRect )
{
@@ -209,13 +198,12 @@ void SfxInfoBarWindow::Resize( )
// Reparent the buttons and place them on the right of the bar
long nX = m_pCloseBtn->GetPosPixel( ).getX( ) - 15;
long nBtnGap = 5;
- for ( vector< PushButton* >::iterator it = m_aActionBtns.begin( );
- it != m_aActionBtns.end( ); ++it )
+ boost::ptr_vector<PushButton>::iterator it;
+ for (it = m_aActionBtns.begin(); it != m_aActionBtns.end(); ++it)
{
- PushButton* pBtn = *it;
- long nBtnWidth = pBtn->GetSizePixel( ).getWidth();
+ long nBtnWidth = it->GetSizePixel( ).getWidth();
nX -= nBtnWidth;
- pBtn->SetPosSizePixel( Point( nX, 5 ), Size( nBtnWidth, 30 ) );
+ it->SetPosSizePixel( Point( nX, 5 ), Size( nBtnWidth, 30 ) );
nX -= nBtnGap;
}
@@ -231,18 +219,12 @@ IMPL_LINK_NOARG( SfxInfoBarWindow, CloseHandler )
SfxInfoBarContainerWindow::SfxInfoBarContainerWindow( SfxInfoBarContainerChild* pChildWin ) :
Window( pChildWin->GetParent( ), 0 ),
m_pChildWin( pChildWin ),
- m_pInfoBars( )
+ m_pInfoBars()
{
}
SfxInfoBarContainerWindow::~SfxInfoBarContainerWindow( )
{
- for ( vector< SfxInfoBarWindow* >::iterator it = m_pInfoBars.begin( );
- it != m_pInfoBars.end( ); ++it )
- {
- delete *it;
- }
- m_pInfoBars.clear( );
}
void SfxInfoBarContainerWindow::appendInfoBar( const OUString& sId, const OUString& sMessage, vector< PushButton* > aButtons )
@@ -261,36 +243,32 @@ void SfxInfoBarContainerWindow::appendInfoBar( const OUString& sId, const OUStri
SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar( const OUString& sId )
{
- SfxInfoBarWindow* pRet = NULL;
- for ( vector< SfxInfoBarWindow* >::iterator it = m_pInfoBars.begin( );
- it != m_pInfoBars.end( ) && pRet == NULL; ++it )
+ boost::ptr_vector<SfxInfoBarWindow>::iterator it;
+ for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
- SfxInfoBarWindow* pBar = *it;
- if ( pBar->getId( ) == sId )
- pRet = pBar;
+ if (it->getId() == sId)
+ return &(*it);
}
- return pRet;
+ return NULL;
}
void SfxInfoBarContainerWindow::removeInfoBar( SfxInfoBarWindow* pInfoBar )
{
- for ( vector< SfxInfoBarWindow* >::iterator it = m_pInfoBars.begin( );
- it != m_pInfoBars.end( ); ++it )
+ boost::ptr_vector<SfxInfoBarWindow>::iterator it;
+ for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
- if ( pInfoBar == *it )
+ if (pInfoBar == &(*it))
{
- m_pInfoBars.erase( it );
+ m_pInfoBars.erase(it);
break;
}
}
- delete pInfoBar;
long nY = 0;
- for ( vector< SfxInfoBarWindow* >::iterator it = m_pInfoBars.begin( ); it != m_pInfoBars.end( ); ++it )
+ for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
- SfxInfoBarWindow* pBar = *it;
- pBar->SetPosPixel( Point( 0, nY ) );
- nY += pBar->GetSizePixel( ).getHeight( );
+ it->SetPosPixel( Point( 0, nY ) );
+ nY += it->GetSizePixel( ).getHeight( );
}
Size aSize = GetSizePixel( );
@@ -304,14 +282,14 @@ void SfxInfoBarContainerWindow::Resize( )
{
// Only need to change the width of the infobars
long nWidth = GetSizePixel( ).getWidth( );
- for ( vector< SfxInfoBarWindow * >::iterator it = m_pInfoBars.begin( );
- it != m_pInfoBars.end( ); ++it )
+
+ boost::ptr_vector<SfxInfoBarWindow>::iterator it;
+ for (it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
{
- SfxInfoBarWindow* pInfoBar = *it;
- Size aSize = pInfoBar->GetSizePixel( );
+ Size aSize = it->GetSizePixel( );
aSize.setWidth( nWidth );
- pInfoBar->SetSizePixel( aSize );
- pInfoBar->Resize( );
+ it->SetSizePixel( aSize );
+ it->Resize( );
}
}
More information about the Libreoffice-commits
mailing list