LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/svx - dialcontrol.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2013-07-09 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 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             : #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( Window& rParent );
      40             : 
      41             :     void                InitBitmap(const 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 String& 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             :     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( Window* pParent, const ResId& rResId );
      84             :     explicit            DialControl( Window* pParent, WinBits nBits );
      85             : 
      86             :     virtual             ~DialControl();
      87             : 
      88             :     virtual void        Paint( const Rectangle& rRect );
      89             : 
      90             :     virtual void        StateChanged( StateChangedType nStateChange );
      91             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
      92             : 
      93             :     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
      94             :     virtual void        MouseMove( const MouseEvent& rMEvt );
      95             :     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
      96             :     virtual void        KeyInput( const KeyEvent& rKEvt );
      97             :     virtual void        LoseFocus();
      98             : 
      99             :     virtual Size        GetOptimalSize() const;
     100             :     virtual void        Resize();
     101             : 
     102             :     /** Returns true, if the control is not in "don't care" state. */
     103             :     bool                HasRotation() const;
     104             :     /** Sets the control to "don't care" state. */
     105             :     void                SetNoRotation();
     106             : 
     107             :     /** Returns the current rotation angle in 1/100 degrees. */
     108             :     sal_Int32           GetRotation() const;
     109             :     /** Sets the rotation to the passed value (in 1/100 degrees). */
     110             :     void                SetRotation( sal_Int32 nAngle );
     111             : 
     112             :     /** Links the passed numeric edit field to the control (bi-directional).
     113             :      *  nDecimalPlaces:
     114             :      *     field value is usign given decimal places
     115             :      *     default is 0 which means field values are in degrees,
     116             :      *     2 means 100th of degree
     117             :      */
     118             :     void                SetLinkedField( NumericField* pField, sal_Int32 nDecimalPlaces = 0);
     119             :     /** Returns the linked numeric edit field, or 0. */
     120             :     NumericField*       GetLinkedField() const;
     121             : 
     122             :     /** The passed handler is called whenever the totation value changes. */
     123             :     void                SetModifyHdl( const Link& rLink );
     124             :     /** Returns the current modify handler. */
     125             :     const Link&         GetModifyHdl() const;
     126             : 
     127             :     /** Save value for later comparison */
     128             :     void                SaveValue();
     129             : 
     130             :     /** Compare value with the saved value */
     131             :     bool                IsValueModified();
     132             : 
     133             : protected:
     134           0 :     struct DialControl_Impl
     135             :     {
     136             :         ::boost::scoped_ptr<DialControlBmp>      mpBmpEnabled;
     137             :         ::boost::scoped_ptr<DialControlBmp>      mpBmpDisabled;
     138             :         ::boost::scoped_ptr<DialControlBmp>      mpBmpBuffered;
     139             :         Link                maModifyHdl;
     140             :         NumericField*       mpLinkField;
     141             :         sal_Int32           mnLinkedFieldValueMultiplyer;
     142             :         Size                maWinSize;
     143             :         Font                maWinFont;
     144             :         sal_Int32           mnAngle;
     145             :         sal_Int32           mnInitialAngle;
     146             :         sal_Int32           mnOldAngle;
     147             :         long                mnCenterX;
     148             :         long                mnCenterY;
     149             :         bool                mbNoRot;
     150             : 
     151             :         explicit            DialControl_Impl( Window& rParent );
     152             :         void                Init( const Size& rWinSize, const Font& rWinFont );
     153             :         void                SetSize( const Size& rWinSize );
     154             :     };
     155             :     std::auto_ptr< DialControl_Impl > mpImpl;
     156             : 
     157             :     virtual void        HandleMouseEvent( const Point& rPos, bool bInitial );
     158             :     virtual void        HandleEscapeEvent();
     159             : 
     160             :     void                SetRotation( sal_Int32 nAngle, bool bBroadcast );
     161             : 
     162             :     void                Init( const Size& rWinSize, const Font& rWinFont );
     163             :     void                Init( const Size& rWinSize );
     164             : 
     165             : private:
     166             :     void                InvalidateControl();
     167             : 
     168             :     void                ImplSetFieldLink( const Link& rLink );
     169             : 
     170             : 
     171             :     DECL_LINK( LinkedFieldModifyHdl, NumericField* );
     172             : };
     173             : 
     174             : // ============================================================================
     175             : 
     176             : /** Wrapper for usage of a DialControl in item connections. */
     177           0 : class SVX_DLLPUBLIC DialControlWrapper : public sfx::SingleControlWrapper< DialControl, sal_Int32 >
     178             : {
     179             : public:
     180             :     explicit            DialControlWrapper( DialControl& rDial );
     181             : 
     182             :     virtual bool        IsControlDontKnow() const;
     183             :     virtual void        SetControlDontKnow( bool bSet );
     184             : 
     185             :     virtual sal_Int32   GetControlValue() const;
     186             :     virtual void        SetControlValue( sal_Int32 nValue );
     187             : };
     188             : 
     189             : // ----------------------------------------------------------------------------
     190             : 
     191             : /** An item<->control connection for a DialControl. */
     192             : typedef sfx::ItemControlConnection< sfx::Int32ItemWrapper, DialControlWrapper > DialControlConnection;
     193             : 
     194             : // ============================================================================
     195             : 
     196             : } // namespace svx
     197             : 
     198             : #endif
     199             : 
     200             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10