LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vcl - ctrl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 9 66.7 %
Date: 2013-07-09 Functions: 2 5 40.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 _SV_CTRL_HXX
      21             : #define _SV_CTRL_HXX
      22             : 
      23             : #include <tools/link.hxx>
      24             : #include <tools/solar.h>
      25             : #include <vcl/dllapi.h>
      26             : #include <vcl/window.hxx>
      27             : #include <vcl/salnativewidgets.hxx>
      28             : 
      29             : // forward
      30             : namespace vcl { struct ImplControlData; struct ControlLayoutData; }
      31             : 
      32             : // -----------
      33             : // - Control -
      34             : // -----------
      35             : 
      36             : class VCL_DLLPUBLIC Control : public Window
      37             : {
      38             : protected:
      39             :     ::vcl::ImplControlData* mpControlData;
      40             : 
      41             : private:
      42             :     bool                    mbHasControlFocus;
      43             :     Link                    maGetFocusHdl;
      44             :     Link                    maLoseFocusHdl;
      45             : 
      46             :     SAL_DLLPRIVATE void     ImplInitControlData();
      47             : 
      48             :     // Copy assignment is forbidden and not implemented.
      49             :     SAL_DLLPRIVATE          Control (const Control &);
      50             :     SAL_DLLPRIVATE          Control & operator= (const Control &);
      51             : 
      52             : protected:
      53             :                     Control( WindowType nType );
      54             :     virtual void    FillLayoutData() const;
      55             : 
      56             :     // helper method for composite controls
      57             :     void            AppendLayoutData( const Control& rSubControl ) const;
      58             : 
      59             :     /// creates the mpData->mpLayoutData structure
      60             :     void            CreateLayoutData() const;
      61             :     /// determines whether we currently have layout data
      62             :     bool            HasLayoutData() const;
      63             :     /// returns the current layout data
      64             :     ::vcl::ControlLayoutData*
      65             :                     GetLayoutData() const;
      66             : 
      67             :     /** this calls both our event listeners, and a specified handler
      68             : 
      69             :         If the Control instance is destroyed during any of those calls, the
      70             :         method properly handles this (in particular, it doesn't crash :)
      71             : 
      72             :         @param nEvent
      73             :             the event to notify to our event listeners
      74             :         @param rHandler
      75             :             the handler to call
      76             :         @param pCaller
      77             :             the parameter to pass to the handler call
      78             :         @return
      79             :             if the Control instance has been destroyed in any of the call
      80             :     */
      81             :     sal_Bool        ImplCallEventListenersAndHandler(
      82             :                     sal_uLong nEvent, const Link& rHandler, void* pCaller
      83             :                 );
      84             : 
      85             :     /** draws the given text onto the given device
      86             : 
      87             :         If no reference device is set, the draw request will simply be forwarded to OutputDevice::DrawText. Otherwise,
      88             :         the text will be rendered according to the metrics at the reference device.
      89             : 
      90             :         Note that the given rectangle might be modified, it will contain the result of a GetTextRect call (either
      91             :         directly at the target device, or taking the reference device into account) when returning.
      92             :     */
      93             :     void        DrawControlText( OutputDevice& _rTargetDevice, Rectangle& _io_rRect,
      94             :                                  const OUString& _rStr, sal_uInt16 _nStyle,
      95             :                                  MetricVector* _pVector, OUString* _pDisplayText ) const;
      96             : 
      97             :     virtual const Font&
      98             :                 GetCanonicalFont( const StyleSettings& _rStyle ) const;
      99             :     virtual const Color&
     100             :                 GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
     101             : 
     102             :     void ImplInitSettings( const sal_Bool _bFont, const sal_Bool _bForeground );
     103             : 
     104             : public:
     105             :     SAL_DLLPRIVATE void ImplClearLayoutData() const;
     106             :     /** draws a frame around the give rectangle, onto the given device
     107             : 
     108             :         only to be used from within the <member>Window::Draw</member> method of your sub class.
     109             : 
     110             :         The frame is always drawn with a single line (without 3D effects). In addition, any mono
     111             :         color set at the control's settings is respected. Yet more additionally, if we're living
     112             :         in a themed desktop, this theming is ignored.
     113             : 
     114             :         Note that this makes sense, since the *only known* clients of <member>Window::Draw</member>
     115             :         are form controls, when printed or print-previewed. For form controls embedded in office documents,
     116             :         you don't want to have the theme look.
     117             : 
     118             :         @param pDev
     119             :             the device to draw onto
     120             :         @param rRect
     121             :             the rect for drawing the frame. Upon returning from the call, the rect will be inflated
     122             :             by the space occupied by the drawn pixels.
     123             :     */
     124             :     SAL_DLLPRIVATE void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect );
     125             : 
     126             : public:
     127             :     explicit        Control( Window* pParent, WinBits nWinStyle = 0 );
     128             :     explicit        Control( Window* pParent, const ResId& );
     129             :     virtual         ~Control();
     130             : 
     131             :     virtual void    GetFocus();
     132             :     virtual void    LoseFocus();
     133             :     virtual long    Notify( NotifyEvent& rNEvt );
     134             :     virtual void    StateChanged( StateChangedType nStateChange );
     135             :     virtual void    Resize();
     136             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
     137             : 
     138             :     // invalidates layout data
     139             :     virtual void    SetText( const OUString& rStr );
     140             :     // gets the displayed text
     141             :     virtual OUString GetDisplayText() const;
     142             :     // returns the bounding box for the character at index nIndex (in control coordinates)
     143             :     Rectangle GetCharacterBounds( long nIndex ) const;
     144             :     // returns the character index for corresponding to rPoint (in control coordinates)
     145             :     // -1 is returned if no character is at that point
     146             :     long GetIndexForPoint( const Point& rPoint ) const;
     147             :     // returns the interval [start,end] of line nLine
     148             :     // returns [-1,-1] for an invalid line
     149             :     Pair GetLineStartEnd( long nLine ) const;
     150             :     /** ToRelativeLineIndex changes a layout data index to a count relative to its line.
     151             : 
     152             :     <p>This is equivalent to getting the line start/end pairs with
     153             :     <member>GetLineStartEnd</member> until the index lies within [start,end] of a line
     154             :     </p>
     155             : 
     156             :     @param nIndex
     157             :     the absolute index inside the display text to be changed to a relative index
     158             : 
     159             :     @returns
     160             :     the relative index inside the displayed line or -1 if the absolute index does
     161             :     not match any line
     162             :     */
     163             :     long ToRelativeLineIndex( long nIndex ) const;
     164             : 
     165           0 :     void            SetGetFocusHdl( const Link& rLink ) { maGetFocusHdl = rLink; }
     166             :     const Link&     GetGetFocusHdl() const   { return maGetFocusHdl; }
     167           0 :     void            SetLoseFocusHdl( const Link& rLink ) { maLoseFocusHdl = rLink; }
     168           0 :     const Link&     GetLoseFocusHdl() const { return maLoseFocusHdl; }
     169             : 
     170             :     /** determines whether the control currently has the focus
     171             :     */
     172           2 :     bool            HasControlFocus() const { return mbHasControlFocus; }
     173             : 
     174             :     void            SetLayoutDataParent( const Control* pParent ) const;
     175             : 
     176             :     virtual Size    GetOptimalSize() const;
     177             : 
     178             :     /** sets a reference device used for rendering control text
     179             :         @seealso DrawControlText
     180             :     */
     181             :     void            SetReferenceDevice( OutputDevice* _referenceDevice );
     182             :     OutputDevice*   GetReferenceDevice() const;
     183             : 
     184         192 :     Font            GetUnzoomedControlPointFont() const
     185             :     {
     186         192 :         Font aFont( GetCanonicalFont( GetSettings().GetStyleSettings() ) );
     187         192 :         if ( IsControlFont() )
     188         136 :             aFont.Merge( GetControlFont() );
     189         192 :         return aFont;
     190             :     }
     191             : };
     192             : 
     193             : #endif  // _SV_CTRL_HXX
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10