[Libreoffice-commits] core.git: 2 commits - include/svx svx/Library_svx.mk svx/source

Jan Holesovsky kendy at suse.cz
Tue Jun 11 05:04:30 PDT 2013


 include/svx/sidebar/SidebarDialControl.hxx           |    3 
 svx/Library_svx.mk                                   |    1 
 svx/source/dialog/dialcontrol.cxx                    |   42 ++++++---
 svx/source/sidebar/possize/SidebarDialControl.cxx    |   17 +--
 svx/source/sidebar/possize/SidebarDialControlBmp.cxx |   87 -------------------
 svx/source/sidebar/possize/SidebarDialControlBmp.hxx |   43 ---------
 6 files changed, 40 insertions(+), 153 deletions(-)

New commits:
commit 0aa7a033cb392dd0e8fc7f065dcfd07cc6aa4401
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Jun 11 13:59:13 2013 +0200

    sidebar: Allow smaller SidebarDialControl, to fit nicely.
    
    Change-Id: I6e0b86527a3c458be563b1fb5a71d45d05aeb5ca

diff --git a/include/svx/sidebar/SidebarDialControl.hxx b/include/svx/sidebar/SidebarDialControl.hxx
index 4f2c118..68293e6 100644
--- a/include/svx/sidebar/SidebarDialControl.hxx
+++ b/include/svx/sidebar/SidebarDialControl.hxx
@@ -31,6 +31,9 @@ public:
     SidebarDialControl (Window* pParent, const ResId& rResId);
     virtual ~SidebarDialControl (void);
 
+    virtual Size GetOptimalSize() const;
+    virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL);
+
     virtual void MouseButtonDown (const MouseEvent& rMEvt);
 
 protected:
diff --git a/svx/source/sidebar/possize/SidebarDialControl.cxx b/svx/source/sidebar/possize/SidebarDialControl.cxx
index d7c80e9..a0c1024 100644
--- a/svx/source/sidebar/possize/SidebarDialControl.cxx
+++ b/svx/source/sidebar/possize/SidebarDialControl.cxx
@@ -47,8 +47,16 @@ SidebarDialControl::~SidebarDialControl (void)
 {
 }
 
+Size SidebarDialControl::GetOptimalSize() const
+{
+    return LogicToPixel(Size(10, 10), MAP_APPFONT);
+}
 
-
+void SidebarDialControl::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)
+{
+    long nMax = std::max(nWidth, nHeight);
+    DialControl::setPosSizePixel(nX, nY, nMax, nMax, nFlags);
+}
 
 void SidebarDialControl::MouseButtonDown( const MouseEvent& rMEvt )
 {
commit 7945e4e5870c00dc41000776540030d4b8660cc8
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Jun 11 12:55:30 2013 +0200

    sidebar: Let the sidebar's dial control use the same graphics as DialControl.
    
    It is not the most pretty one under the sun, but at least any general
    improvements in the DialControl will improve the look of the sidebar too :-)
    
    Change-Id: Ib26b097b322b69516898a5dd80bed3f8a0fa89d7

diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index 385e5a3..efe2127 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -195,7 +195,6 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
     svx/source/sidebar/line/LineWidthPopup \
     svx/source/sidebar/possize/PosSizePropertyPanel \
     svx/source/sidebar/possize/SidebarDialControl \
-    svx/source/sidebar/possize/SidebarDialControlBmp \
     svx/source/sidebar/tools/ColorControl \
     svx/source/sidebar/tools/ColorPopup \
     svx/source/sidebar/tools/PopupControl \
diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx
index 40c818e..5ebb396 100644
--- a/svx/source/dialog/dialcontrol.cxx
+++ b/svx/source/dialog/dialcontrol.cxx
@@ -72,23 +72,37 @@ void DialControlBmp::DrawBackground( const Size& rSize, bool bEnabled )
 
 void DialControlBmp::DrawElements( const String& rText, sal_Int32 nAngle )
 {
-    // *** rotated text ***
-
-    Font aFont( GetFont() );
-    aFont.SetColor( GetTextColor() );
-    aFont.SetOrientation( static_cast< short >( (nAngle + 5) / 10 ) );  // Font uses 1/10 degrees
-    aFont.SetWeight( WEIGHT_BOLD );
-    SetFont( aFont );
-
     double fAngle = nAngle * F_PI180 / 100.0;
     double fSin = sin( fAngle );
     double fCos = cos( fAngle );
     double fWidth = GetTextWidth( rText ) / 2.0;
     double fHeight = GetTextHeight() / 2.0;
-    long nX = static_cast< long >( mnCenterX - fWidth * fCos - fHeight * fSin );
-    long nY = static_cast< long >( mnCenterY + fWidth * fSin - fHeight * fCos );
-    Rectangle aRect( nX, nY, 2 * mnCenterX - nX, 2 * mnCenterY - nY );
-    DrawText( aRect, rText, mbEnabled ? 0 : TEXT_DRAW_DISABLE );
+
+    if ( rText.Len() > 0 )
+    {
+        // rotated text
+        Font aFont( GetFont() );
+        aFont.SetColor( GetTextColor() );
+        aFont.SetOrientation( static_cast< short >( (nAngle + 5) / 10 ) );  // Font uses 1/10 degrees
+        aFont.SetWeight( WEIGHT_BOLD );
+        SetFont( aFont );
+
+        long nX = static_cast< long >( mnCenterX - fWidth * fCos - fHeight * fSin );
+        long nY = static_cast< long >( mnCenterY + fWidth * fSin - fHeight * fCos );
+        Rectangle aRect( nX, nY, 2 * mnCenterX - nX, 2 * mnCenterY - nY );
+        DrawText( aRect, rText, mbEnabled ? 0 : TEXT_DRAW_DISABLE );
+    }
+    else
+    {
+        // only a line
+        const sal_Int32 nDx (fCos * (maRect.GetWidth()-4) / 2);
+        const sal_Int32 nDy (-fSin * (maRect.GetHeight()-4) / 2);
+        Point pt1( maRect.Center() );
+        Point pt2( pt1.X() + nDx, pt1.Y() + nDy);
+
+        SetLineColor( GetTextColor() );
+        DrawLine( pt1, pt2 );
+    }
 
     // *** drag button ***
 
@@ -96,8 +110,8 @@ void DialControlBmp::DrawElements( const String& rText, sal_Int32 nAngle )
     SetLineColor( GetButtonLineColor() );
     SetFillColor( GetButtonFillColor( bMain ) );
 
-    nX = mnCenterX - static_cast< long >( (DIAL_OUTER_WIDTH / 2 - mnCenterX) * fCos );
-    nY = mnCenterY - static_cast< long >( (mnCenterY - DIAL_OUTER_WIDTH / 2) * fSin );
+    long nX = mnCenterX - static_cast< long >( (DIAL_OUTER_WIDTH / 2 - mnCenterX) * fCos );
+    long nY = mnCenterY - static_cast< long >( (mnCenterY - DIAL_OUTER_WIDTH / 2) * fSin );
     long nSize = bMain ? (DIAL_OUTER_WIDTH / 4) : (DIAL_OUTER_WIDTH / 2 - 1);
     DrawEllipse( Rectangle( nX - nSize, nY - nSize, nX + nSize, nY + nSize ) );
 }
diff --git a/svx/source/sidebar/possize/SidebarDialControl.cxx b/svx/source/sidebar/possize/SidebarDialControl.cxx
index a6611b7..d7c80e9 100644
--- a/svx/source/sidebar/possize/SidebarDialControl.cxx
+++ b/svx/source/sidebar/possize/SidebarDialControl.cxx
@@ -16,7 +16,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 #include <svx/sidebar/SidebarDialControl.hxx>
-#include "SidebarDialControlBmp.hxx"
 
 #include <vcl/svapp.hxx>
 
@@ -25,9 +24,6 @@ namespace svx { namespace sidebar {
 SidebarDialControl::SidebarDialControl (Window* pParent, WinBits nBits)
     : svx::DialControl(pParent, nBits)
 {
-    mpImpl->mpBmpEnabled.reset(new SidebarDialControlBmp(*this));
-    mpImpl->mpBmpDisabled.reset(new SidebarDialControlBmp(*this));
-    mpImpl->mpBmpBuffered.reset(new SidebarDialControlBmp(*this));
     Init(GetOutputSizePixel());
 }
 
@@ -41,9 +37,6 @@ SidebarDialControl::SidebarDialControl (
     const ResId& rResId)
     : svx::DialControl(pParent, rResId)
 {
-    mpImpl->mpBmpEnabled.reset(new SidebarDialControlBmp(*this));
-    mpImpl->mpBmpDisabled.reset(new SidebarDialControlBmp(*this));
-    mpImpl->mpBmpBuffered.reset(new SidebarDialControlBmp(*this));
     Init(GetOutputSizePixel());
 }
 
diff --git a/svx/source/sidebar/possize/SidebarDialControlBmp.cxx b/svx/source/sidebar/possize/SidebarDialControlBmp.cxx
deleted file mode 100644
index f702632..0000000
--- a/svx/source/sidebar/possize/SidebarDialControlBmp.cxx
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#include "SidebarDialControlBmp.hxx"
-
-#include <sfx2/sidebar/Theme.hxx>
-
-#include <vcl/svapp.hxx>
-
-#include "PosSizePropertyPanel.hrc"
-#include <svx/dialogs.hrc>
-#include <svx/dialmgr.hxx>
-#include <svx/svdstr.hrc>
-
-namespace svx { namespace sidebar {
-
-SidebarDialControlBmp::SidebarDialControlBmp (Window& rParent)
-    : DialControlBmp(rParent)
-{
-}
-
-
-
-
-SidebarDialControlBmp::~SidebarDialControlBmp (void)
-{
-}
-
-
-
-
-void SidebarDialControlBmp::DrawElements (
-    const String& /*rText*/,
-    sal_Int32 nAngle)
-{
-    if (Application::GetSettings().GetLayoutRTL())
-        nAngle = 18000 - nAngle;
-    double fAngle = nAngle * F_PI180 / 100.0;
-    double fSin = sin( fAngle );
-    double fCos = cos( fAngle );
-    DrawText( maRect, String(), mbEnabled ? 0 : TEXT_DRAW_DISABLE );
-    const sal_Int32 nDx (fCos * (maRect.GetWidth()-4) / 2);
-    const sal_Int32 nDy (-fSin * (maRect.GetHeight()-4) / 2);
-    Point pt1( maRect.Center() );
-    Point pt2( pt1.X() + nDx, pt1.Y() + nDy);
-    if ( ! sfx2::sidebar::Theme::IsHighContrastMode())
-        SetLineColor( Color( 60, 93, 138 ) );
-    else
-        SetLineColor(COL_BLACK);//Application::GetSettings().GetStyleSettings().GetFieldTextColor()
-    DrawLine( pt1, pt2 );
-}
-
-
-
-
-void SidebarDialControlBmp::DrawBackground()
-{
-    SetLineColor();
-    SetFillColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground));
-    DrawRect(maRect);
-
-    const BitmapEx aBitmapEx(SVX_RES(IMG_DIALCONTROL));
-    // Size aImageSize(aBitmapEx.GetSizePixel());
-    //    aImageSize.Width() -= 1;
-    //    aImageSize.Height() -= 1;
-    SetAntialiasing(ANTIALIASING_ENABLE_B2DDRAW |  ANTIALIASING_PIXELSNAPHAIRLINE);
-    DrawBitmapEx(maRect.TopLeft(), /*aImageSize,*/ aBitmapEx);
-}
-
-
-} } // end of namespace svx::sidebar
-
-// eof
diff --git a/svx/source/sidebar/possize/SidebarDialControlBmp.hxx b/svx/source/sidebar/possize/SidebarDialControlBmp.hxx
deleted file mode 100644
index d1cb6be..0000000
--- a/svx/source/sidebar/possize/SidebarDialControlBmp.hxx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef SVX_SIDEBAR_POSSIZE_DIAL_CONTROL_BMP_HXX
-#define SVX_SIDEBAR_POSSIZE_DIAL_CONTROL_BMP_HXX
-
-#include <svx/dialcontrol.hxx>
-
-namespace svx { namespace sidebar {
-
-
-class SidebarDialControlBmp
-    : public svx::DialControlBmp
-{
-public:
-    explicit SidebarDialControlBmp( Window& rParent);
-    virtual ~SidebarDialControlBmp (void);
-
-    virtual void DrawElements( const String& rText, sal_Int32 nAngle );
-    virtual void DrawBackground();
-
-private:
-};
-
-} } // end of namespace svx::sidebar
-
-#endif
-
-// eof


More information about the Libreoffice-commits mailing list