LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/control - fixedhyper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 62 0.0 %
Date: 2012-12-27 Functions: 0 15 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             : #include <vcl/fixedhyper.hxx>
      21             : 
      22             : // class FixedHyperlink --------------------------------------------------
      23             : 
      24           0 : FixedHyperlink::FixedHyperlink(Window* pParent, const ResId& rResId)
      25             :     : FixedText(pParent, rResId)
      26           0 :     , m_nTextLen(0)
      27             : {
      28           0 :     Initialize();
      29           0 : }
      30             : 
      31           0 : FixedHyperlink::FixedHyperlink(Window* pParent, WinBits nWinStyle)
      32             :     : FixedText(pParent, nWinStyle)
      33           0 :     , m_nTextLen(0)
      34             : {
      35           0 :     Initialize();
      36           0 : }
      37             : 
      38           0 : FixedHyperlink::~FixedHyperlink()
      39             : {
      40           0 : }
      41             : 
      42           0 : void FixedHyperlink::Initialize()
      43             : {
      44             :     // saves the old pointer
      45           0 :     m_aOldPointer = GetPointer();
      46             :     // changes the font
      47           0 :     Font aFont = GetControlFont( );
      48             :     // to underline
      49           0 :     aFont.SetUnderline( UNDERLINE_SINGLE );
      50           0 :     SetControlFont( aFont );
      51             :     // changes the color to light blue
      52           0 :     SetControlForeground( Color( COL_LIGHTBLUE ) );
      53             :     // calculates text len
      54           0 :     m_nTextLen = GetCtrlTextWidth( GetText() );
      55           0 : }
      56             : 
      57           0 : void FixedHyperlink::MouseMove( const MouseEvent& rMEvt )
      58             : {
      59             :     // changes the pointer if the control is enabled and the mouse is over the text.
      60           0 :     if ( !rMEvt.IsLeaveWindow() && IsEnabled() && GetPointerPosPixel().X() < m_nTextLen )
      61           0 :         SetPointer( POINTER_REFHAND );
      62             :     else
      63           0 :         SetPointer( m_aOldPointer );
      64           0 : }
      65             : 
      66           0 : void FixedHyperlink::MouseButtonUp( const MouseEvent& )
      67             : {
      68             :     // calls the link if the control is enabled and the mouse is over the text.
      69           0 :     if ( IsEnabled() && GetPointerPosPixel().X() < m_nTextLen )
      70           0 :         ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, m_aClickHdl, this );
      71           0 : }
      72             : 
      73           0 : void FixedHyperlink::RequestHelp( const HelpEvent& rHEvt )
      74             : {
      75           0 :     if ( IsEnabled() && GetPointerPosPixel().X() < m_nTextLen )
      76           0 :         FixedText::RequestHelp( rHEvt );
      77           0 : }
      78             : 
      79           0 : void FixedHyperlink::GetFocus()
      80             : {
      81           0 :     SetTextColor( Color( COL_LIGHTRED ) );
      82           0 :     Paint( Rectangle( Point(), GetSizePixel() ) );
      83           0 :     ShowFocus( Rectangle( Point( 1, 1 ), Size( m_nTextLen + 4, GetSizePixel().Height() - 2 ) ) );
      84           0 : }
      85             : 
      86           0 : void FixedHyperlink::LoseFocus()
      87             : {
      88           0 :     SetTextColor( GetControlForeground() );
      89           0 :     Paint( Rectangle( Point(), GetSizePixel() ) );
      90           0 :     HideFocus();
      91           0 : }
      92             : 
      93           0 : void FixedHyperlink::KeyInput( const KeyEvent& rKEvt )
      94             : {
      95           0 :     switch ( rKEvt.GetKeyCode().GetCode() )
      96             :     {
      97             :         case KEY_SPACE:
      98             :         case KEY_RETURN:
      99           0 :             m_aClickHdl.Call( this );
     100           0 :             break;
     101             : 
     102             :         default:
     103           0 :             FixedText::KeyInput( rKEvt );
     104             :     }
     105           0 : }
     106             : 
     107           0 : void FixedHyperlink::SetURL( const OUString& rNewURL )
     108             : {
     109           0 :     m_sURL = rNewURL;
     110           0 :     SetQuickHelpText( m_sURL );
     111           0 : }
     112             : 
     113           0 : OUString FixedHyperlink::GetURL() const
     114             : {
     115           0 :     return m_sURL;
     116             : }
     117             : 
     118           0 : void FixedHyperlink::SetText(const String& rNewDescription)
     119             : {
     120           0 :     FixedText::SetText(rNewDescription);
     121           0 :     m_nTextLen = GetCtrlTextWidth(GetText());
     122           0 : }
     123             : 
     124           0 : bool FixedHyperlink::set_property(const OString &rKey, const OString &rValue)
     125             : {
     126           0 :     if (rKey == "uri")
     127           0 :         SetURL(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
     128             :     else
     129           0 :         return FixedText::set_property(rKey, rValue);
     130           0 :     return true;
     131             : }
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10