1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "richtextviewport.hxx"
21 #include <editeng/editview.hxx>
25 RichTextViewPort::RichTextViewPort( vcl::Window
* _pParent
)
26 : Control ( _pParent
)
28 , m_bHideInactiveSelection( true )
32 void RichTextViewPort::setView( EditView
& _rView
)
35 SetPointer( _rView
.GetPointer() );
38 void RichTextViewPort::Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& _rRect
)
40 m_pView
->Paint(_rRect
, &rRenderContext
);
43 void RichTextViewPort::GetFocus()
48 m_pView
->SetSelectionMode( EESelectionMode::Std
);
49 m_pView
->ShowCursor();
53 void RichTextViewPort::LoseFocus()
57 m_pView
->HideCursor();
58 m_pView
->SetSelectionMode( m_bHideInactiveSelection
? EESelectionMode::Hidden
: EESelectionMode::Std
);
63 void RichTextViewPort::KeyInput( const KeyEvent
& _rKEvt
)
65 if ( !m_pView
->PostKeyEvent( _rKEvt
) )
66 Control::KeyInput( _rKEvt
);
68 implInvalidateAttributes();
71 void RichTextViewPort::MouseMove( const MouseEvent
& _rMEvt
)
73 Control::MouseMove( _rMEvt
);
74 m_pView
->MouseMove( _rMEvt
);
77 void RichTextViewPort::MouseButtonDown( const MouseEvent
& _rMEvt
)
79 Control::MouseButtonDown( _rMEvt
);
80 m_pView
->MouseButtonDown( _rMEvt
);
84 void RichTextViewPort::MouseButtonUp( const MouseEvent
& _rMEvt
)
86 Control::MouseButtonUp( _rMEvt
);
87 m_pView
->MouseButtonUp( _rMEvt
);
88 implInvalidateAttributes();
91 void RichTextViewPort::SetHideInactiveSelection( bool _bHide
)
93 if ( m_bHideInactiveSelection
== _bHide
)
95 m_bHideInactiveSelection
= _bHide
;
97 m_pView
->SetSelectionMode( m_bHideInactiveSelection
? EESelectionMode::Hidden
: EESelectionMode::Std
);
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */