1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX
24 #define FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX
25 
26 #include <vcl/dialog.hxx>
27 #include <vcl/fixed.hxx>
28 #ifndef _SV_BUTTON_HXX
29 #include <vcl/button.hxx>
30 #endif
31 #include <vcl/toolbox.hxx>
32 #include <com/sun/star/awt/FontDescriptor.hpp>
33 #include "rtattributes.hxx"
34 #include "textattributelistener.hxx"
35 
36 /** === begin UNO includes === **/
37 /** === end UNO includes === **/
38 
39 class EditView;
40 class EditEngine;
41 class SfxItemSet;
42 //........................................................................
43 namespace frm
44 {
45 //........................................................................
46 
47     class RichTextControlImpl;
48     class RichTextEngine;
49 	//====================================================================
50 	//= RichTextControl
51 	//====================================================================
52     class RichTextControl : public Control, public IMultiAttributeDispatcher
53     {
54     private:
55         RichTextControlImpl*    m_pImpl;
56 
57     public:
58         RichTextControl(
59             RichTextEngine* _pEngine,
60             Window* _pParent,
61             WinBits _nStyle,
62             ITextAttributeListener* _pTextAttribListener,
63             ITextSelectionListener* _pSelectionListener
64         );
65 
66         ~RichTextControl( );
67 
68         /* enables the change notifications for a particular attribute
69 
70            If you want to be notified of any changes in the state of an attribute, you need to call enableAttributeNotification.
71 
72            If you provide a dedicated listener for this attribute, this listener is called for every change in the state of
73            the attribute.
74 
75            No matter whether you provide such a dedicated listener, the "global" listener which you specified
76            in the constructor of the control is also called for all changes in the attribute state.
77 
78            If you previously already enabled the notification for this attribute, and specified a different listener,
79            then the previous listener will be replaced with the new listener, provided the latter is not <NULL/>.
80         */
81         void        enableAttributeNotification( AttributeId _nAttributeId, ITextAttributeListener* _pListener = NULL );
82 
83         /** disables the change notifications for a particular attribute
84 
85             If there was a listener dedicated to this attribute, it will not be referenced and used anymore
86             after this method had been called
87         */
88         void        disableAttributeNotification( AttributeId _nAttributeId );
89 
90         /** determines whether a given slot can be mapped to an aspect of an attribute of the EditEngine
91 
92             E.g. SID_ATTR_PARA_ADJUST_LEFT can, though it's not part of the EditEngine pool, be mapped
93             to the SID_ATTR_PARA_ADJUST slot, which in fact *is* usable with the EditEngine.
94         */
95         static bool isMappableSlot( SfxSlotId _nSlotId );
96 
97         // IMultiAttributeDispatcher
98         virtual AttributeState  getState( AttributeId _nAttributeId ) const;
99         virtual void            executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument );
100 
101         void    SetBackgroundColor( );
102         void    SetBackgroundColor( const Color& _rColor );
103 
104         void    SetReadOnly( bool _bReadOnly );
105         bool    IsReadOnly() const;
106 
107         void    SetHideInactiveSelection( bool _bHide );
108         bool    GetHideInactiveSelection() const;
109 
110         const EditView& getView() const;
111               EditView& getView();
112 
113         // Window overridables
114         virtual void        Draw( OutputDevice* _pDev, const Point& _rPos, const Size& _rSize, sal_uLong _nFlags );
115 
116     protected:
117         // Window overridables
118         virtual void        Resize();
119         virtual void        GetFocus();
120         virtual void        StateChanged( StateChangedType nStateChange );
121         virtual long        PreNotify( NotifyEvent& _rNEvt );
122         virtual long        Notify( NotifyEvent& _rNEvt );
123 
124     private:
125                 void    applyAttributes( const SfxItemSet& _rAttributesToApply );
126                 void    implInit( RichTextEngine* _pEngine, ITextAttributeListener* _pTextAttribListener, ITextSelectionListener* _pSelectionListener );
127         static  WinBits implInitStyle( WinBits nStyle );
128 
129     private:
130         EditEngine&  getEngine() const;
131         Window&      getViewport() const;
132     };
133 
134 //........................................................................
135 } // namespace frm
136 //........................................................................
137 
138 #endif // FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX
139 
140