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 "richtextviewport.hxx"
21 : #include <editeng/editview.hxx>
22 :
23 :
24 : namespace frm
25 : {
26 :
27 40 : RichTextViewPort::RichTextViewPort( vcl::Window* _pParent )
28 : :Control ( _pParent )
29 : ,m_pView(NULL)
30 40 : ,m_bHideInactiveSelection( true )
31 : {
32 40 : }
33 :
34 :
35 40 : void RichTextViewPort::setView( EditView& _rView )
36 : {
37 40 : m_pView = &_rView;
38 40 : SetPointer( _rView.GetPointer() );
39 40 : }
40 :
41 :
42 0 : void RichTextViewPort::Paint( const Rectangle& _rRect )
43 : {
44 0 : m_pView->Paint( _rRect );
45 0 : }
46 :
47 :
48 0 : void RichTextViewPort::GetFocus()
49 : {
50 0 : Control::GetFocus();
51 0 : m_pView->SetSelectionMode( EE_SELMODE_STD );
52 0 : m_pView->ShowCursor( true );
53 0 : }
54 :
55 :
56 0 : void RichTextViewPort::LoseFocus()
57 : {
58 0 : m_pView->HideCursor();
59 0 : m_pView->SetSelectionMode( m_bHideInactiveSelection ? EE_SELMODE_HIDDEN : EE_SELMODE_STD );
60 0 : Control::LoseFocus();
61 0 : }
62 :
63 :
64 0 : void RichTextViewPort::KeyInput( const KeyEvent& _rKEvt )
65 : {
66 0 : if ( !m_pView->PostKeyEvent( _rKEvt ) )
67 0 : Control::KeyInput( _rKEvt );
68 : else
69 0 : implInvalidateAttributes();
70 0 : }
71 :
72 :
73 0 : void RichTextViewPort::MouseMove( const MouseEvent& _rMEvt )
74 : {
75 0 : Control::MouseMove( _rMEvt );
76 0 : m_pView->MouseMove( _rMEvt );
77 0 : }
78 :
79 :
80 0 : void RichTextViewPort::MouseButtonDown( const MouseEvent& _rMEvt )
81 : {
82 0 : Control::MouseButtonDown( _rMEvt );
83 0 : m_pView->MouseButtonDown( _rMEvt );
84 0 : GrabFocus();
85 0 : }
86 :
87 :
88 0 : void RichTextViewPort::MouseButtonUp( const MouseEvent& _rMEvt )
89 : {
90 0 : Control::MouseButtonUp( _rMEvt );
91 0 : m_pView->MouseButtonUp( _rMEvt );
92 0 : implInvalidateAttributes();
93 0 : }
94 :
95 :
96 48 : void RichTextViewPort::SetHideInactiveSelection( bool _bHide )
97 : {
98 48 : if ( m_bHideInactiveSelection == _bHide )
99 70 : return;
100 26 : m_bHideInactiveSelection = _bHide;
101 26 : if ( !HasFocus() )
102 26 : m_pView->SetSelectionMode( m_bHideInactiveSelection ? EE_SELMODE_HIDDEN : EE_SELMODE_STD );
103 : }
104 :
105 :
106 :
107 :
108 192 : } // namespace frm
109 :
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|