merge the formfield patch from ooo-build
[ooovba.git] / forms / source / richtext / richtextviewport.cxx
blob65f192c66ba4c0371b665bd365059ac5c2846875
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: richtextviewport.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_forms.hxx"
33 #include "richtextviewport.hxx"
34 #include <svx/editview.hxx>
36 //........................................................................
37 namespace frm
39 //........................................................................
41 //====================================================================
42 //= RichTextViewPort
43 //====================================================================
44 //--------------------------------------------------------------------
45 RichTextViewPort::RichTextViewPort( Window* _pParent )
46 :Control ( _pParent )
47 ,m_bHideInactiveSelection( true )
51 //--------------------------------------------------------------------
52 void RichTextViewPort::setView( EditView& _rView )
54 m_pView = &_rView;
55 SetPointer( _rView.GetPointer() );
58 //--------------------------------------------------------------------
59 void RichTextViewPort::Paint( const Rectangle& _rRect )
61 m_pView->Paint( _rRect );
64 //--------------------------------------------------------------------
65 void RichTextViewPort::GetFocus()
67 Control::GetFocus();
68 m_pView->SetSelectionMode( EE_SELMODE_STD );
69 m_pView->ShowCursor( TRUE );
72 //--------------------------------------------------------------------
73 void RichTextViewPort::LoseFocus()
75 m_pView->HideCursor();
76 m_pView->SetSelectionMode( m_bHideInactiveSelection ? EE_SELMODE_HIDDEN : EE_SELMODE_STD );
77 Control::LoseFocus();
80 //--------------------------------------------------------------------
81 void RichTextViewPort::KeyInput( const KeyEvent& _rKEvt )
83 if ( !m_pView->PostKeyEvent( _rKEvt ) )
84 Control::KeyInput( _rKEvt );
85 else
86 implInvalidateAttributes();
89 //--------------------------------------------------------------------
90 void RichTextViewPort::MouseMove( const MouseEvent& _rMEvt )
92 Control::MouseMove( _rMEvt );
93 m_pView->MouseMove( _rMEvt );
96 //--------------------------------------------------------------------
97 void RichTextViewPort::MouseButtonDown( const MouseEvent& _rMEvt )
99 Control::MouseButtonDown( _rMEvt );
100 m_pView->MouseButtonDown( _rMEvt );
101 GrabFocus();
104 //--------------------------------------------------------------------
105 void RichTextViewPort::MouseButtonUp( const MouseEvent& _rMEvt )
107 Control::MouseButtonUp( _rMEvt );
108 m_pView->MouseButtonUp( _rMEvt );
109 implInvalidateAttributes();
112 //--------------------------------------------------------------------
113 void RichTextViewPort::SetHideInactiveSelection( bool _bHide )
115 if ( m_bHideInactiveSelection == _bHide )
116 return;
117 m_bHideInactiveSelection = _bHide;
118 if ( !HasFocus() )
119 m_pView->SetSelectionMode( m_bHideInactiveSelection ? EE_SELMODE_HIDDEN : EE_SELMODE_STD );
122 //--------------------------------------------------------------------
123 bool RichTextViewPort::GetHideInactiveSelection() const
125 return m_bHideInactiveSelection;
128 //........................................................................
129 } // namespace frm
130 //........................................................................