LibreOffice Module forms (master) 1
richtextvclcontrol.hxx
Go to the documentation of this file.
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#pragma once
20
21#include <vcl/ctrl.hxx>
22#include "rtattributes.hxx"
24#include <memory>
25
26class EditView;
27class EditEngine;
28class SfxItemSet;
29
30namespace frm
31{
32
33 class RichTextControlImpl;
34 class RichTextEngine;
35
37 {
38 private:
39 std::unique_ptr<RichTextControlImpl> m_pImpl;
40
41 public:
43 RichTextEngine* _pEngine,
44 vcl::Window* _pParent,
45 WinBits _nStyle,
46 ITextAttributeListener* _pTextAttribListener,
47 ITextSelectionListener* _pSelectionListener
48 );
49
50 virtual ~RichTextControl( ) override;
51 virtual void dispose() override;
52
53 /* enables the change notifications for a particular attribute
54
55 If you want to be notified of any changes in the state of an attribute, you need to call enableAttributeNotification.
56
57 If you provide a dedicated listener for this attribute, this listener is called for every change in the state of
58 the attribute.
59
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.
62
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/>.
65 */
66 void enableAttributeNotification( AttributeId _nAttributeId, ITextAttributeListener* _pListener );
67
73 void disableAttributeNotification( AttributeId _nAttributeId );
74
80 static bool isMappableSlot( SfxSlotId _nSlotId );
81
82 // IMultiAttributeDispatcher
83 virtual AttributeState getState( AttributeId _nAttributeId ) const override;
84 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) override;
85
86 void SetBackgroundColor( );
87 void SetBackgroundColor( const Color& _rColor );
88
89 void SetReadOnly( bool _bReadOnly );
90 bool IsReadOnly() const;
91
92 void SetHideInactiveSelection( bool _bHide );
93 bool GetHideInactiveSelection() const;
94
95 const EditView& getView() const;
97
98 // Window overridables
99 virtual void Draw( OutputDevice* _pDev, const Point& _rPos, SystemTextColorFlags _nFlags ) override;
100
101 protected:
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;
108
109 private:
110 void applyAttributes( const SfxItemSet& _rAttributesToApply );
111 void implInit( RichTextEngine* _pEngine, ITextAttributeListener* _pTextAttribListener, ITextSelectionListener* _pSelectionListener );
112 static WinBits implInitStyle( WinBits nStyle );
113
114 private:
115 EditEngine& getEngine() const;
116 };
117
118
119} // namespace frm
120
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SystemTextColorFlags
virtual void GetFocus() override
virtual void Draw(OutputDevice *_pDev, const Point &_rPos, SystemTextColorFlags _nFlags) override
RichTextControl(RichTextEngine *_pEngine, vcl::Window *_pParent, WinBits _nStyle, ITextAttributeListener *_pTextAttribListener, ITextSelectionListener *_pSelectionListener)
virtual ~RichTextControl() override
virtual void StateChanged(StateChangedType nStateChange) override
void enableAttributeNotification(AttributeId _nAttributeId, ITextAttributeListener *_pListener)
std::unique_ptr< RichTextControlImpl > m_pImpl
void SetHideInactiveSelection(bool _bHide)
void applyAttributes(const SfxItemSet &_rAttributesToApply)
const EditView & getView() const
virtual void executeAttribute(AttributeId _nAttributeId, const SfxPoolItem *_pArgument) override
virtual void Resize() override
EditEngine & getEngine() const
void disableAttributeNotification(AttributeId _nAttributeId)
disables the change notifications for a particular attribute
virtual bool EventNotify(NotifyEvent &_rNEvt) override
void SetReadOnly(bool _bReadOnly)
virtual bool PreNotify(NotifyEvent &_rNEvt) override
static bool isMappableSlot(SfxSlotId _nSlotId)
determines whether a given slot can be mapped to an aspect of an attribute of the EditEngine
static WinBits implInitStyle(WinBits nStyle)
bool GetHideInactiveSelection() const
void implInit(RichTextEngine *_pEngine, ITextAttributeListener *_pTextAttribListener, ITextSelectionListener *_pSelectionListener)
virtual void dispose() override
virtual AttributeState getState(AttributeId _nAttributeId) const override
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
sal_uInt16 SfxSlotId
a SFX slot id
sal_Int32 AttributeId
the id of an attribute
StateChangedType
sal_Int64 WinBits