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 .
21 #include <vcl/ctrl.hxx>
22 #include "rtattributes.hxx"
23 #include "textattributelistener.hxx"
33 class RichTextControlImpl
;
36 class RichTextControl
: public Control
, public IMultiAttributeDispatcher
39 std::unique_ptr
<RichTextControlImpl
> m_pImpl
;
43 RichTextEngine
* _pEngine
,
44 vcl::Window
* _pParent
,
46 ITextAttributeListener
* _pTextAttribListener
,
47 ITextSelectionListener
* _pSelectionListener
50 virtual ~RichTextControl( ) override
;
51 virtual void dispose() override
;
53 /* enables the change notifications for a particular attribute
55 If you want to be notified of any changes in the state of an attribute, you need to call enableAttributeNotification.
57 If you provide a dedicated listener for this attribute, this listener is called for every change in the state of
60 No matter whether you provide such a dedicated listener, the "global" listener which you specified
61 in the constructor of the control is also called for all changes in the attribute state.
63 If you previously already enabled the notification for this attribute, and specified a different listener,
64 then the previous listener will be replaced with the new listener, provided the latter is not <NULL/>.
66 void enableAttributeNotification( AttributeId _nAttributeId
, ITextAttributeListener
* _pListener
);
68 /** disables the change notifications for a particular attribute
70 If there was a listener dedicated to this attribute, it will not be referenced and used anymore
71 after this method had been called
73 void disableAttributeNotification( AttributeId _nAttributeId
);
75 /** determines whether a given slot can be mapped to an aspect of an attribute of the EditEngine
77 E.g. SID_ATTR_PARA_ADJUST_LEFT can, though it's not part of the EditEngine pool, be mapped
78 to the SID_ATTR_PARA_ADJUST slot, which in fact *is* usable with the EditEngine.
80 static bool isMappableSlot( SfxSlotId _nSlotId
);
82 // IMultiAttributeDispatcher
83 virtual AttributeState
getState( AttributeId _nAttributeId
) const override
;
84 virtual void executeAttribute( AttributeId _nAttributeId
, const SfxPoolItem
* _pArgument
) override
;
86 void SetBackgroundColor( );
87 void SetBackgroundColor( const Color
& _rColor
);
89 void SetReadOnly( bool _bReadOnly
);
90 bool IsReadOnly() const;
92 void SetHideInactiveSelection( bool _bHide
);
93 bool GetHideInactiveSelection() const;
95 const EditView
& getView() const;
98 // Window overridables
99 virtual void Draw( OutputDevice
* _pDev
, const Point
& _rPos
, SystemTextColorFlags _nFlags
) override
;
102 // Window overridables
103 virtual void Resize() override
;
104 virtual void GetFocus() override
;
105 virtual void StateChanged( StateChangedType nStateChange
) override
;
106 virtual bool PreNotify( NotifyEvent
& _rNEvt
) override
;
107 virtual bool EventNotify( NotifyEvent
& _rNEvt
) override
;
110 void applyAttributes( const SfxItemSet
& _rAttributesToApply
);
111 void implInit( RichTextEngine
* _pEngine
, ITextAttributeListener
* _pTextAttribListener
, ITextSelectionListener
* _pSelectionListener
);
112 static WinBits
implInitStyle( WinBits nStyle
);
115 EditEngine
& getEngine() const;
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */