LCOV - code coverage report
Current view: top level - libreoffice/svx/inc/svx - dialcontrol.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1 0.0 %
Date: 2012-12-27 Functions: 0 2 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 SVX_DIALCONTROL_HXX
      21             : #define SVX_DIALCONTROL_HXX
      22             : 
      23             : #include <memory>
      24             : #include <vcl/ctrl.hxx>
      25             : #include <sfx2/itemconnect.hxx>
      26             : #include "svx/svxdllapi.h"
      27             : 
      28             : class NumericField;
      29             : 
      30             : namespace svx {
      31             : 
      32             : // ============================================================================
      33             : 
      34             : struct DialControl_Impl;
      35             : 
      36             : /** This control allows to input a rotation angle, visualized by a dial.
      37             : 
      38             :     Usage: A single click sets a rotation angle rounded to steps of 15 degrees.
      39             :     Dragging with the left mouse button sets an exact rotation angle. Pressing
      40             :     the ESCAPE key during mouse drag cancels the operation and restores the old
      41             :     state of the control.
      42             : 
      43             :     It is possible to link a numeric field to this control using the function
      44             :     SetLinkedField(). The DialControl will take full control of this numeric
      45             :     field:
      46             :     -   Sets the rotation angle to the numeric field in mouse operations.
      47             :     -   Shows the value entered/modified in the numeric field.
      48             :     -   Enables/disables/shows/hides the field according to own state changes.
      49             :  */
      50             : class SVX_DLLPUBLIC DialControl : public Control
      51             : {
      52             : public:
      53             :     explicit            DialControl( Window* pParent, const ResId& rResId );
      54             :     virtual             ~DialControl();
      55             : 
      56             :     virtual void        Paint( const Rectangle& rRect );
      57             : 
      58             :     virtual void        StateChanged( StateChangedType nStateChange );
      59             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
      60             : 
      61             :     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
      62             :     virtual void        MouseMove( const MouseEvent& rMEvt );
      63             :     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
      64             :     virtual void        KeyInput( const KeyEvent& rKEvt );
      65             :     virtual void        LoseFocus();
      66             : 
      67             :     /** Returns true, if the control is not in "don't care" state. */
      68             :     bool                HasRotation() const;
      69             :     /** Sets the control to "don't care" state. */
      70             :     void                SetNoRotation();
      71             : 
      72             :     /** Returns the current rotation angle in 1/100 degrees. */
      73             :     sal_Int32           GetRotation() const;
      74             :     /** Sets the rotation to the passed value (in 1/100 degrees). */
      75             :     void                SetRotation( sal_Int32 nAngle );
      76             : 
      77             :     /** Links the passed numeric edit field to the control (bi-directional). */
      78             :     void                SetLinkedField( NumericField* pField );
      79             : 
      80             :     /** Save value for later comparison */
      81             :     void                SaveValue();
      82             : 
      83             :     /** Compare value with the saved value */
      84             :     bool                IsValueModified();
      85             : 
      86             : private:
      87             :     void                Init( const Size& rWinSize, const Font& rWinFont );
      88             :     void                Init( const Size& rWinSize );
      89             :     void                InvalidateControl();
      90             : 
      91             :     void                ImplSetRotation( sal_Int32 nAngle, bool bBroadcast );
      92             :     void                ImplSetFieldLink( const Link& rLink );
      93             : 
      94             :     void                HandleMouseEvent( const Point& rPos, bool bInitial );
      95             :     void                HandleEscapeEvent();
      96             : 
      97             :     DECL_LINK( LinkedFieldModifyHdl, NumericField* );
      98             : 
      99             :     std::auto_ptr< DialControl_Impl > mpImpl;
     100             : };
     101             : 
     102             : // ============================================================================
     103             : 
     104             : /** Wrapper for usage of a DialControl in item connections. */
     105           0 : class SVX_DLLPUBLIC DialControlWrapper : public sfx::SingleControlWrapper< DialControl, sal_Int32 >
     106             : {
     107             : public:
     108             :     explicit            DialControlWrapper( DialControl& rDial );
     109             : 
     110             :     virtual bool        IsControlDontKnow() const;
     111             :     virtual void        SetControlDontKnow( bool bSet );
     112             : 
     113             :     virtual sal_Int32   GetControlValue() const;
     114             :     virtual void        SetControlValue( sal_Int32 nValue );
     115             : };
     116             : 
     117             : // ----------------------------------------------------------------------------
     118             : 
     119             : /** An item<->control connection for a DialControl. */
     120             : typedef sfx::ItemControlConnection< sfx::Int32ItemWrapper, DialControlWrapper > DialControlConnection;
     121             : 
     122             : // ============================================================================
     123             : 
     124             : } // namespace svx
     125             : 
     126             : #endif
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10