LCOV - code coverage report
Current view: top level - include/svx - dialcontrol.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 3 0.0 %
Date: 2014-11-03 Functions: 0 5 0.0 %
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             : 
      20             : #ifndef INCLUDED_SVX_DIALCONTROL_HXX
      21             : #define INCLUDED_SVX_DIALCONTROL_HXX
      22             : 
      23             : #include <memory>
      24             : #include <vcl/ctrl.hxx>
      25             : #include <sfx2/itemconnect.hxx>
      26             : #include <svx/svxdllapi.h>
      27             : 
      28             : #include <boost/scoped_ptr.hpp>
      29             : 
      30             : class NumericField;
      31             : 
      32             : namespace svx {
      33             : 
      34             : 
      35             : 
      36           0 : class DialControlBmp : public VirtualDevice
      37             : {
      38             : public:
      39             :     explicit            DialControlBmp( vcl::Window& rParent );
      40             : 
      41             :     void                InitBitmap(const vcl::Font& rFont);
      42             :     void                SetSize(const Size& rSize);
      43             :     void                CopyBackground( const DialControlBmp& rSrc );
      44             :     void                DrawBackground( const Size& rSize, bool bEnabled );
      45             :     virtual void        DrawBackground();
      46             :     virtual void        DrawElements( const OUString& rText, sal_Int32 nAngle );
      47             : 
      48             : protected:
      49             :     Rectangle           maRect;
      50             :     bool                mbEnabled;
      51             : 
      52             : private:
      53             :     const Color&        GetBackgroundColor() const;
      54             :     const Color&        GetTextColor() const;
      55             :     const Color&        GetScaleLineColor() const;
      56             :     const Color&        GetButtonLineColor() const;
      57             :     const Color&        GetButtonFillColor( bool bMain ) const;
      58             : 
      59             :     void                Init();
      60             : 
      61             :     vcl::Window&             mrParent;
      62             :     long                mnCenterX;
      63             :     long                mnCenterY;
      64             : };
      65             : 
      66             : /** This control allows to input a rotation angle, visualized by a dial.
      67             : 
      68             :     Usage: A single click sets a rotation angle rounded to steps of 15 degrees.
      69             :     Dragging with the left mouse button sets an exact rotation angle. Pressing
      70             :     the ESCAPE key during mouse drag cancels the operation and restores the old
      71             :     state of the control.
      72             : 
      73             :     It is possible to link a numeric field to this control using the function
      74             :     SetLinkedField(). The DialControl will take full control of this numeric
      75             :     field:
      76             :     -   Sets the rotation angle to the numeric field in mouse operations.
      77             :     -   Shows the value entered/modified in the numeric field.
      78             :     -   Enables/disables/shows/hides the field according to own state changes.
      79             :  */
      80             : class SVX_DLLPUBLIC DialControl : public Control
      81             : {
      82             : public:
      83             :     explicit            DialControl( vcl::Window* pParent, WinBits nBits );
      84             : 
      85             :     virtual             ~DialControl();
      86             : 
      87             :     virtual void        Paint( const Rectangle& rRect ) SAL_OVERRIDE;
      88             : 
      89             :     virtual void        StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
      90             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
      91             : 
      92             :     virtual void        MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      93             :     virtual void        MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      94             :     virtual void        MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      95             :     virtual void        KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
      96             :     virtual void        LoseFocus() SAL_OVERRIDE;
      97             : 
      98             :     virtual Size        GetOptimalSize() const SAL_OVERRIDE;
      99             :     virtual void        Resize() SAL_OVERRIDE;
     100             : 
     101             :     /** Returns true, if the control is not in "don't care" state. */
     102             :     bool                HasRotation() const;
     103             :     /** Sets the control to "don't care" state. */
     104             :     void                SetNoRotation();
     105             : 
     106             :     /** Returns the current rotation angle in 1/100 degrees. */
     107             :     sal_Int32           GetRotation() const;
     108             :     /** Sets the rotation to the passed value (in 1/100 degrees). */
     109             :     void                SetRotation( sal_Int32 nAngle );
     110             : 
     111             :     /** Links the passed numeric edit field to the control (bi-directional).
     112             :      *  nDecimalPlaces:
     113             :      *     field value is usign given decimal places
     114             :      *     default is 0 which means field values are in degrees,
     115             :      *     2 means 100th of degree
     116             :      */
     117             :     void                SetLinkedField( NumericField* pField, sal_Int32 nDecimalPlaces = 0);
     118             : 
     119             :     /** The passed handler is called whenever the totation value changes. */
     120             :     void                SetModifyHdl( const Link& rLink );
     121             : 
     122             :     /** Save value for later comparison */
     123             :     void                SaveValue();
     124             : 
     125             :     /** Compare value with the saved value */
     126             :     bool                IsValueModified();
     127             : 
     128             : protected:
     129           0 :     struct DialControl_Impl
     130             :     {
     131             :         ::boost::scoped_ptr<DialControlBmp>      mpBmpEnabled;
     132             :         ::boost::scoped_ptr<DialControlBmp>      mpBmpDisabled;
     133             :         ::boost::scoped_ptr<DialControlBmp>      mpBmpBuffered;
     134             :         Link                maModifyHdl;
     135             :         NumericField*       mpLinkField;
     136             :         sal_Int32           mnLinkedFieldValueMultiplyer;
     137             :         Size                maWinSize;
     138             :         vcl::Font           maWinFont;
     139             :         sal_Int32           mnAngle;
     140             :         sal_Int32           mnInitialAngle;
     141             :         sal_Int32           mnOldAngle;
     142             :         long                mnCenterX;
     143             :         long                mnCenterY;
     144             :         bool                mbNoRot;
     145             : 
     146             :         explicit            DialControl_Impl( vcl::Window& rParent );
     147             :         void                Init( const Size& rWinSize, const vcl::Font& rWinFont );
     148             :         void                SetSize( const Size& rWinSize );
     149             :     };
     150             :     std::unique_ptr< DialControl_Impl > mpImpl;
     151             : 
     152             :     virtual void        HandleMouseEvent( const Point& rPos, bool bInitial );
     153             :     virtual void        HandleEscapeEvent();
     154             : 
     155             :     void                SetRotation( sal_Int32 nAngle, bool bBroadcast );
     156             : 
     157             :     void                Init( const Size& rWinSize, const vcl::Font& rWinFont );
     158             :     void                Init( const Size& rWinSize );
     159             : 
     160             : private:
     161             :     void                InvalidateControl();
     162             : 
     163             :     void                ImplSetFieldLink( const Link& rLink );
     164             : 
     165             : 
     166             :     DECL_LINK( LinkedFieldModifyHdl, NumericField* );
     167             : };
     168             : 
     169             : 
     170             : 
     171             : /** Wrapper for usage of a DialControl in item connections. */
     172           0 : class SVX_DLLPUBLIC DialControlWrapper : public sfx::SingleControlWrapper< DialControl, sal_Int32 >
     173             : {
     174             : public:
     175             :     explicit            DialControlWrapper( DialControl& rDial );
     176             : 
     177             :     virtual bool        IsControlDontKnow() const SAL_OVERRIDE;
     178             :     virtual void        SetControlDontKnow( bool bSet ) SAL_OVERRIDE;
     179             : 
     180             :     virtual sal_Int32   GetControlValue() const SAL_OVERRIDE;
     181             :     virtual void        SetControlValue( sal_Int32 nValue ) SAL_OVERRIDE;
     182             : };
     183             : 
     184             : 
     185             : 
     186             : /** An item<->control connection for a DialControl. */
     187             : typedef sfx::ItemControlConnection< sfx::Int32ItemWrapper, DialControlWrapper > DialControlConnection;
     188             : 
     189             : 
     190             : 
     191             : } // namespace svx
     192             : 
     193             : #endif
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10