diff options
author | Kurt Zenker <kz@openoffice.org> | 2007-06-20 12:58:27 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2007-06-20 12:58:27 +0000 |
commit | 24a60d3744a383768f27a6fb3c29a8d4f5df2089 (patch) | |
tree | ce9d8e3e6f6f3bfec3da7ed47833610ada992f39 /svtools/source/control/fixedhyper.cxx | |
parent | INTEGRATION: CWS jl65 (1.146.38); FILE MERGED (diff) | |
download | core-24a60d3744a383768f27a6fb3c29a8d4f5df2089.tar.gz core-24a60d3744a383768f27a6fb3c29a8d4f5df2089.zip |
INTEGRATION: CWS jl65 (1.1.2); FILE ADDED
2007/06/15 13:16:49 pb 1.1.2.2: fix: #i78515# Get/LoseFocus() and KeyInput() overloaded
2007/06/14 06:34:33 pb 1.1.2.1: fix: #i78209# new class FixedHyperlink
Diffstat (limited to 'svtools/source/control/fixedhyper.cxx')
-rw-r--r-- | svtools/source/control/fixedhyper.cxx | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/svtools/source/control/fixedhyper.cxx b/svtools/source/control/fixedhyper.cxx new file mode 100644 index 000000000000..263e7e1030cc --- /dev/null +++ b/svtools/source/control/fixedhyper.cxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: fixedhyper.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: kz $ $Date: 2007-06-20 13:58:27 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "fixedhyper.hxx" + +//......................................................................... +namespace svt +{ +//......................................................................... + +// class FixedHyperlink -------------------------------------------------- + +FixedHyperlink::FixedHyperlink( Window* pParent, const ResId& rResId ) : + FixedText( pParent, rResId ), + m_nTextLen(0) +{ + Initialize(); +} + +FixedHyperlink::FixedHyperlink( Window* pParent, WinBits nWinStyle ) : + FixedText( pParent, nWinStyle ), + m_nTextLen(0) +{ + Initialize(); +} + +FixedHyperlink::~FixedHyperlink() +{ +} + +void FixedHyperlink::Initialize() +{ + // saves the old pointer + m_aOldPointer = GetPointer(); + // changes the font + Font aFont = GetControlFont( ); + // to underline + aFont.SetUnderline( UNDERLINE_SINGLE ); + SetControlFont( aFont ); + // changes the color to light blue + SetTextColor( Color( COL_LIGHTBLUE ) ); + // calculates text len + m_nTextLen = GetCtrlTextWidth( GetText() ); +} + +void FixedHyperlink::MouseMove( const MouseEvent& rMEvt ) +{ + // changes the pointer if the control is enabled and the mouse is over the text. + if ( !rMEvt.IsLeaveWindow() && IsEnabled() && GetPointerPosPixel().X() < m_nTextLen ) + SetPointer( POINTER_REFHAND ); + else + SetPointer( m_aOldPointer ); +} + +void FixedHyperlink::MouseButtonUp( const MouseEvent& ) +{ + // calls the link if the control is enabled and the mouse is over the text. + if ( IsEnabled() && GetPointerPosPixel().X() < m_nTextLen ) + m_aClickHdl.Call( this ); +} + +void FixedHyperlink::RequestHelp( const HelpEvent& rHEvt ) +{ + if ( IsEnabled() && GetPointerPosPixel().X() < m_nTextLen ) + FixedText::RequestHelp( rHEvt ); +} + +void FixedHyperlink::GetFocus() +{ + SetTextColor( Color( COL_LIGHTRED ) ); + Paint( Rectangle( Point(), GetSizePixel() ) ); + ShowFocus( Rectangle( Point( 1, 1 ), Size( m_nTextLen + 4, GetSizePixel().Height() - 2 ) ) ); +} + +void FixedHyperlink::LoseFocus() +{ + SetTextColor( Color( COL_LIGHTBLUE ) ); + Paint( Rectangle( Point(), GetSizePixel() ) ); + HideFocus(); +} + +void FixedHyperlink::KeyInput( const KeyEvent& rKEvt ) +{ + switch ( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_SPACE: + case KEY_RETURN: + m_aClickHdl.Call( this ); + break; + + default: + FixedText::KeyInput( rKEvt ); + } +} + +//......................................................................... +} // namespace svt +//......................................................................... + |