LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/vcl - ctrl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 8 62.5 %
Date: 2012-08-25 Functions: 1 4 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 10 60.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SV_CTRL_HXX
      30                 :            : #define _SV_CTRL_HXX
      31                 :            : 
      32                 :            : #include <tools/link.hxx>
      33                 :            : #include <tools/solar.h>
      34                 :            : #include <vcl/dllapi.h>
      35                 :            : #include <vcl/window.hxx>
      36                 :            : #include <vcl/salnativewidgets.hxx>
      37                 :            : 
      38                 :            : // forward
      39                 :            : namespace vcl { struct ImplControlData; struct ControlLayoutData; }
      40                 :            : 
      41                 :            : // -----------
      42                 :            : // - Control -
      43                 :            : // -----------
      44                 :            : 
      45                 :            : class VCL_DLLPUBLIC Control : public Window
      46                 :            : {
      47                 :            : protected:
      48                 :            :     ::vcl::ImplControlData* mpControlData;
      49                 :            : 
      50                 :            : private:
      51                 :            :     sal_Bool                mbHasFocus;
      52                 :            :     Link                    maGetFocusHdl;
      53                 :            :     Link                    maLoseFocusHdl;
      54                 :            : 
      55                 :            :     SAL_DLLPRIVATE void     ImplInitControlData();
      56                 :            : 
      57                 :            :     // Copy assignment is forbidden and not implemented.
      58                 :            :     SAL_DLLPRIVATE          Control (const Control &);
      59                 :            :     SAL_DLLPRIVATE          Control & operator= (const Control &);
      60                 :            : 
      61                 :            : protected:
      62                 :            :                     Control( WindowType nType );
      63                 :            :     virtual void    FillLayoutData() const;
      64                 :            : 
      65                 :            :     // helper method for composite controls
      66                 :            :     void            AppendLayoutData( const Control& rSubControl ) const;
      67                 :            : 
      68                 :            :     /// creates the mpData->mpLayoutData structure
      69                 :            :     void            CreateLayoutData() const;
      70                 :            :     /// determines whether we currently have layout data
      71                 :            :     bool            HasLayoutData() const;
      72                 :            :     /// returns the current layout data
      73                 :            :     ::vcl::ControlLayoutData*
      74                 :            :                     GetLayoutData() const;
      75                 :            : 
      76                 :            :     /** this calls both our event listeners, and a specified handler
      77                 :            : 
      78                 :            :         If the Control instance is destroyed during any of those calls, the
      79                 :            :         method properly handles this (in particular, it doesn't crash :)
      80                 :            : 
      81                 :            :         @param nEvent
      82                 :            :             the event to notify to our event listeners
      83                 :            :         @param rHandler
      84                 :            :             the handler to call
      85                 :            :         @param pCaller
      86                 :            :             the parameter to pass to the handler call
      87                 :            :         @return
      88                 :            :             if the Control instance has been destroyed in any of the call
      89                 :            :     */
      90                 :            :     sal_Bool        ImplCallEventListenersAndHandler(
      91                 :            :                     sal_uLong nEvent, const Link& rHandler, void* pCaller
      92                 :            :                 );
      93                 :            : 
      94                 :            :     /** draws the given text onto the given device
      95                 :            : 
      96                 :            :         If no reference device is set, the draw request will simply be forwarded to OutputDevice::DrawText. Otherwise,
      97                 :            :         the text will be rendered according to the metrics at the reference device.
      98                 :            : 
      99                 :            :         Note that the given rectangle might be modified, it will contain the result of a GetTextRect call (either
     100                 :            :         directly at the target device, or taking the reference device into account) when returning.
     101                 :            :     */
     102                 :            :     void        DrawControlText( OutputDevice& _rTargetDevice, Rectangle& _io_rRect,
     103                 :            :                                  const XubString& _rStr, sal_uInt16 _nStyle,
     104                 :            :                                  MetricVector* _pVector, String* _pDisplayText ) const;
     105                 :            : 
     106                 :            :     virtual const Font&
     107                 :            :                 GetCanonicalFont( const StyleSettings& _rStyle ) const;
     108                 :            :     virtual const Color&
     109                 :            :                 GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
     110                 :            : 
     111                 :            :     void ImplInitSettings( const sal_Bool _bFont, const sal_Bool _bForeground );
     112                 :            : 
     113                 :            : public:
     114                 :            :     SAL_DLLPRIVATE void ImplClearLayoutData() const;
     115                 :            :     /** draws a frame around the give rectangle, onto the given device
     116                 :            : 
     117                 :            :         only to be used from within the <member>Window::Draw</member> method of your sub class.
     118                 :            : 
     119                 :            :         The frame is always drawn with a single line (without 3D effects). In addition, any mono
     120                 :            :         color set at the control's settings is respected. Yet more additionally, if we're living
     121                 :            :         in a themed desktop, this theming is ignored.
     122                 :            : 
     123                 :            :         Note that this makes sense, since the *only known* clients of <member>Window::Draw</member>
     124                 :            :         are form controls, when printed or print-previewed. For form controls embedded in office documents,
     125                 :            :         you don't want to have the theme look.
     126                 :            : 
     127                 :            :         @param pDev
     128                 :            :             the device to draw onto
     129                 :            :         @param rRect
     130                 :            :             the rect for drawing the frame. Upon returning from the call, the rect will be inflated
     131                 :            :             by the space occupied by the drawn pixels.
     132                 :            :     */
     133                 :            :     SAL_DLLPRIVATE void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect );
     134                 :            : 
     135                 :            : public:
     136                 :            :                     Control( Window* pParent, WinBits nWinStyle = 0 );
     137                 :            :                     Control( Window* pParent, const ResId& rResId );
     138                 :            :                     ~Control();
     139                 :            : 
     140                 :            :     virtual void    GetFocus();
     141                 :            :     virtual void    LoseFocus();
     142                 :            :     virtual long    Notify( NotifyEvent& rNEvt );
     143                 :            :     virtual void    StateChanged( StateChangedType nStateChange );
     144                 :            :     virtual void    Resize();
     145                 :            :     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
     146                 :            : 
     147                 :            :     // invalidates layout data
     148                 :            :     virtual void    SetText( const String& rStr );
     149                 :            :     // gets the displayed text
     150                 :            :     virtual String GetDisplayText() const;
     151                 :            :     // returns the bounding box for the character at index nIndex (in control coordinates)
     152                 :            :     Rectangle GetCharacterBounds( long nIndex ) const;
     153                 :            :     // returns the character index for corresponding to rPoint (in control coordinates)
     154                 :            :     // -1 is returned if no character is at that point
     155                 :            :     long GetIndexForPoint( const Point& rPoint ) const;
     156                 :            :     // returns the interval [start,end] of line nLine
     157                 :            :     // returns [-1,-1] for an invalid line
     158                 :            :     Pair GetLineStartEnd( long nLine ) const;
     159                 :            :     /** ToRelativeLineIndex changes a layout data index to a count relative to its line.
     160                 :            : 
     161                 :            :     <p>This is equivalent to getting the line start/end pairs with
     162                 :            :     <member>GetLineStartEnd</member> until the index lies within [start,end] of a line
     163                 :            :     </p>
     164                 :            : 
     165                 :            :     @param nIndex
     166                 :            :     the absolute index inside the display text to be changed to a relative index
     167                 :            : 
     168                 :            :     @returns
     169                 :            :     the relative index inside the displayed line or -1 if the absolute index does
     170                 :            :     not match any line
     171                 :            :     */
     172                 :            :     long ToRelativeLineIndex( long nIndex ) const;
     173                 :            : 
     174                 :          0 :     void            SetGetFocusHdl( const Link& rLink ) { maGetFocusHdl = rLink; }
     175                 :            :     const Link&     GetGetFocusHdl() const   { return maGetFocusHdl; }
     176                 :          0 :     void            SetLoseFocusHdl( const Link& rLink ) { maLoseFocusHdl = rLink; }
     177                 :          0 :     const Link&     GetLoseFocusHdl() const { return maLoseFocusHdl; }
     178                 :            : 
     179                 :            :     void            SetLayoutDataParent( const Control* pParent ) const;
     180                 :            : 
     181                 :            :     virtual Size    GetOptimalSize(WindowSizeType eType) const;
     182                 :            : 
     183                 :            :     /** sets a reference device used for rendering control text
     184                 :            :         @seealso DrawControlText
     185                 :            :     */
     186                 :            :     void            SetReferenceDevice( OutputDevice* _referenceDevice );
     187                 :            :     OutputDevice*   GetReferenceDevice() const;
     188                 :            : 
     189                 :        408 :     Font            GetUnzoomedControlPointFont() const
     190                 :            :     {
     191                 :        408 :         Font aFont( GetCanonicalFont( GetSettings().GetStyleSettings() ) );
     192 [ +  + ][ +  - ]:        408 :         if ( IsControlFont() )
     193 [ +  - ][ +  - ]:        282 :             aFont.Merge( GetControlFont() );
                 [ +  - ]
     194                 :        408 :         return aFont;
     195                 :            :     }
     196                 :            : };
     197                 :            : 
     198                 :            : #endif  // _SV_CTRL_HXX
     199                 :            : 
     200                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10