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 .
19 #ifndef INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX
20 #define INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX
22 #include <vcl/dialog.hxx>
23 #include <vcl/fixed.hxx>
24 #include <vcl/button.hxx>
25 #include <vcl/toolbox.hxx>
26 #include <com/sun/star/awt/FontDescriptor.hpp>
27 #include "rtattributes.hxx"
28 #include "textattributelistener.hxx"
37 class RichTextControlImpl
;
40 class RichTextControl
: public Control
, public IMultiAttributeDispatcher
43 RichTextControlImpl
* m_pImpl
;
47 RichTextEngine
* _pEngine
,
48 vcl::Window
* _pParent
,
50 ITextAttributeListener
* _pTextAttribListener
,
51 ITextSelectionListener
* _pSelectionListener
54 virtual ~RichTextControl( );
55 virtual void dispose() override
;
57 /* enables the change notifications for a particular attribute
59 If you want to be notified of any changes in the state of an attribute, you need to call enableAttributeNotification.
61 If you provide a dedicated listener for this attribute, this listener is called for every change in the state of
64 No matter whether you provide such a dedicated listener, the "global" listener which you specified
65 in the constructor of the control is also called for all changes in the attribute state.
67 If you previously already enabled the notification for this attribute, and specified a different listener,
68 then the previous listener will be replaced with the new listener, provided the latter is not <NULL/>.
70 void enableAttributeNotification( AttributeId _nAttributeId
, ITextAttributeListener
* _pListener
= nullptr );
72 /** disables the change notifications for a particular attribute
74 If there was a listener dedicated to this attribute, it will not be referenced and used anymore
75 after this method had been called
77 void disableAttributeNotification( AttributeId _nAttributeId
);
79 /** determines whether a given slot can be mapped to an aspect of an attribute of the EditEngine
81 E.g. SID_ATTR_PARA_ADJUST_LEFT can, though it's not part of the EditEngine pool, be mapped
82 to the SID_ATTR_PARA_ADJUST slot, which in fact *is* usable with the EditEngine.
84 static bool isMappableSlot( SfxSlotId _nSlotId
);
86 // IMultiAttributeDispatcher
87 virtual AttributeState
getState( AttributeId _nAttributeId
) const override
;
88 virtual void executeAttribute( AttributeId _nAttributeId
, const SfxPoolItem
* _pArgument
) override
;
90 void SetBackgroundColor( );
91 void SetBackgroundColor( const Color
& _rColor
);
93 void SetReadOnly( bool _bReadOnly
);
94 bool IsReadOnly() const;
96 void SetHideInactiveSelection( bool _bHide
);
97 bool GetHideInactiveSelection() const;
99 const EditView
& getView() const;
102 // Window overridables
103 virtual void Draw( OutputDevice
* _pDev
, const Point
& _rPos
, const Size
& _rSize
, DrawFlags _nFlags
) override
;
106 // Window overridables
107 virtual void Resize() override
;
108 virtual void GetFocus() override
;
109 virtual void StateChanged( StateChangedType nStateChange
) override
;
110 virtual bool PreNotify( NotifyEvent
& _rNEvt
) override
;
111 virtual bool Notify( NotifyEvent
& _rNEvt
) override
;
114 void applyAttributes( const SfxItemSet
& _rAttributesToApply
);
115 void implInit( RichTextEngine
* _pEngine
, ITextAttributeListener
* _pTextAttribListener
, ITextSelectionListener
* _pSelectionListener
);
116 static WinBits
implInitStyle( WinBits nStyle
);
119 EditEngine
& getEngine() const;
120 vcl::Window
& getViewport() const;
127 #endif // INCLUDED_FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */