LCOV - code coverage report
Current view: top level - include/vcl - ctrl.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 4 50.0 %
Date: 2015-06-13 12:38:46 Functions: 2 4 50.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_VCL_CTRL_HXX
      21             : #define INCLUDED_VCL_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             : class StyleSettings;
      32             : 
      33             : 
      34             : // - Control -
      35             : 
      36             : 
      37             : class VCL_DLLPUBLIC Control : public vcl::Window
      38             : {
      39             : protected:
      40             :     vcl::ImplControlData* mpControlData;
      41             : 
      42             : private:
      43             :     bool                    mbHasControlFocus;
      44             :     Link<>                  maGetFocusHdl;
      45             :     Link<>                  maLoseFocusHdl;
      46             : 
      47             :     SAL_DLLPRIVATE void     ImplInitControlData();
      48             : 
      49             :                             Control (const Control &) SAL_DELETED_FUNCTION;
      50             :                             Control & operator= (const Control &) SAL_DELETED_FUNCTION;
      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             : 
      64             :     /** this calls both our event listeners, and a specified handler
      65             : 
      66             :         If the Control instance is destroyed during any of those calls, the
      67             :         method properly handles this (in particular, it doesn't crash :)
      68             : 
      69             :         @param nEvent
      70             :             the event to notify to our event listeners
      71             :         @param rHandler
      72             :             the handler to call
      73             :         @param pCaller
      74             :             the parameter to pass to the handler call
      75             :         @return
      76             :             if the Control instance has been destroyed in any of the call
      77             :     */
      78             :     bool        ImplCallEventListenersAndHandler(
      79             :                     sal_uLong nEvent, const Link<>& rHandler, void* pCaller
      80             :                 );
      81             : 
      82             :     /** draws the given text onto the given device
      83             : 
      84             :         If no reference device is set, the draw request will simply be forwarded to OutputDevice::DrawText. Otherwise,
      85             :         the text will be rendered according to the metrics at the reference device.
      86             : 
      87             :         Note that the given rectangle might be modified, it will contain the result of a GetTextRect call (either
      88             :         directly at the target device, or taking the reference device into account) when returning.
      89             :     */
      90             :     void        DrawControlText( OutputDevice& _rTargetDevice, Rectangle& _io_rRect,
      91             :                                  const OUString& _rStr, DrawTextFlags _nStyle,
      92             :                                  MetricVector* _pVector, OUString* _pDisplayText ) const;
      93             : 
      94             :     virtual const vcl::Font&
      95             :                 GetCanonicalFont( const StyleSettings& _rStyle ) const;
      96             :     virtual const Color&
      97             :                 GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
      98             : 
      99             :     void ImplInitSettings( const bool _bFont, const bool _bForeground );
     100             : 
     101             :     virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
     102             : 
     103             : public:
     104             :     SAL_DLLPRIVATE void ImplClearLayoutData() const;
     105             :     /** draws a frame around the give rectangle, onto the given device
     106             : 
     107             :         only to be used from within the Window::Draw method of your sub class.
     108             : 
     109             :         The frame is always drawn with a single line (without 3D effects). In addition, any mono
     110             :         color set at the control's settings is respected. Yet more additionally, if we're living
     111             :         in a themed desktop, this theming is ignored.
     112             : 
     113             :         Note that this makes sense, since the *only known* clients of Window::Draw
     114             :         are form controls, when printed or print-previewed. For form controls embedded in office documents,
     115             :         you don't want to have the theme look.
     116             : 
     117             :         @param pDev
     118             :             the device to draw onto
     119             :         @param rRect
     120             :             the rect for drawing the frame. Upon returning from the call, the rect will be inflated
     121             :             by the space occupied by the drawn pixels.
     122             :     */
     123             :     SAL_DLLPRIVATE void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect );
     124             : 
     125             : public:
     126             :     explicit        Control( vcl::Window* pParent, WinBits nWinStyle = 0 );
     127             :     explicit        Control( vcl::Window* pParent, const ResId& );
     128             :     virtual         ~Control();
     129             :     virtual void    dispose() SAL_OVERRIDE;
     130             : 
     131             :     virtual void    EnableRTL ( bool bEnable = true ) SAL_OVERRIDE;
     132             : 
     133             :     virtual void    GetFocus() SAL_OVERRIDE;
     134             :     virtual void    LoseFocus() SAL_OVERRIDE;
     135             :     virtual bool    Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     136             :     virtual void    StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
     137             :     virtual void    Resize() SAL_OVERRIDE;
     138             : 
     139             :     // invalidates layout data
     140             :     virtual void    SetText( const OUString& rStr ) SAL_OVERRIDE;
     141             :     // gets the displayed text
     142             :     virtual OUString GetDisplayText() const SAL_OVERRIDE;
     143             :     // returns the bounding box for the character at index nIndex (in control coordinates)
     144             :     Rectangle GetCharacterBounds( long nIndex ) const;
     145             :     // returns the character index for corresponding to rPoint (in control coordinates)
     146             :     // -1 is returned if no character is at that point
     147             :     long GetIndexForPoint( const Point& rPoint ) const;
     148             :     // returns the interval [start,end] of line nLine
     149             :     // returns [-1,-1] for an invalid line
     150             :     Pair GetLineStartEnd( long nLine ) const;
     151             :     /** ToRelativeLineIndex changes a layout data index to a count relative to its line.
     152             : 
     153             :     This is equivalent to getting the line start/end pairs with
     154             :     GetLineStartEnd() until the index lies within [start,end] of a line
     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           8 :     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           5 :     bool            HasControlFocus() const { return mbHasControlFocus; }
     173             : 
     174             :     void            SetLayoutDataParent( const Control* pParent ) const;
     175             : 
     176             :     virtual Size    GetOptimalSize() const SAL_OVERRIDE;
     177             : 
     178             :     /** sets a reference device used for rendering control text
     179             :         @see DrawControlText
     180             :     */
     181             :     void            SetReferenceDevice( OutputDevice* _referenceDevice );
     182             :     OutputDevice*   GetReferenceDevice() const;
     183             : 
     184             :     vcl::Font       GetUnzoomedControlPointFont() const;
     185             : };
     186             : 
     187             : #endif // INCLUDED_VCL_CTRL_HXX
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11