LCOV - code coverage report
Current view: top level - svx/source/sidebar/possize - SidebarDialControl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 33 3.0 %
Date: 2014-11-03 Functions: 2 9 22.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #include <svx/sidebar/SidebarDialControl.hxx>
      20             : 
      21             : #include <vcl/builder.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <vcl/settings.hxx>
      24             : 
      25             : namespace svx { namespace sidebar {
      26             : 
      27           0 : SidebarDialControl::SidebarDialControl (vcl::Window* pParent, WinBits nBits)
      28           0 :     : svx::DialControl(pParent, nBits)
      29             : {
      30           0 :     Init(GetOutputSizePixel());
      31           0 : }
      32             : 
      33           0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSidebarDialControl(vcl::Window *pParent, VclBuilder::stringmap &)
      34             : {
      35           0 :     return new SidebarDialControl(pParent, WB_TABSTOP);
      36             : }
      37             : 
      38           0 : SidebarDialControl::~SidebarDialControl (void)
      39             : {
      40           0 : }
      41             : 
      42           0 : Size SidebarDialControl::GetOptimalSize() const
      43             : {
      44           0 :     return LogicToPixel(Size(10, 10), MAP_APPFONT);
      45             : }
      46             : 
      47           0 : void SidebarDialControl::MouseButtonDown( const MouseEvent& rMEvt )
      48             : {
      49           0 :     if( rMEvt.IsLeft() )
      50             :     {
      51           0 :         GrabFocus();
      52           0 :         CaptureMouse();
      53           0 :         mpImpl->mnOldAngle = mpImpl->mnAngle;
      54           0 :         HandleMouseEvent( rMEvt.GetPosPixel(), true );
      55             :     }
      56           0 : }
      57             : 
      58           0 : void SidebarDialControl::HandleMouseEvent( const Point& rPos, bool bInitial )
      59             : {
      60           0 :     long nX = rPos.X() - mpImpl->mnCenterX;
      61           0 :     long nY = mpImpl->mnCenterY - rPos.Y();
      62           0 :     double fH = sqrt( static_cast< double >( nX ) * nX + static_cast< double >( nY ) * nY );
      63           0 :     if( fH != 0.0 )
      64             :     {
      65           0 :         double fAngle = acos( nX / fH );
      66           0 :         sal_Int32 nAngle = static_cast< sal_Int32 >( fAngle / F_PI180 * 100.0 );
      67           0 :         if( nY < 0 )
      68           0 :             nAngle = 36000 - nAngle;
      69           0 :         if( bInitial )  // round to entire 15 degrees
      70           0 :             nAngle = ((nAngle + 750) / 1500) * 1500;
      71             : 
      72           0 :         if (Application::GetSettings().GetLayoutRTL())
      73           0 :             nAngle = 18000 - nAngle;
      74           0 :         SetRotation( nAngle, true );
      75             :     }
      76           0 : }
      77             : 
      78         594 : } } // end of namespace svx::sidebar
      79             : 
      80             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10