1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX 28 #define FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX 29 30 #include <vcl/dialog.hxx> 31 #include <vcl/fixed.hxx> 32 #ifndef _SV_BUTTON_HXX 33 #include <vcl/button.hxx> 34 #endif 35 #include <vcl/toolbox.hxx> 36 #include <com/sun/star/awt/FontDescriptor.hpp> 37 #include "rtattributes.hxx" 38 #include "textattributelistener.hxx" 39 40 /** === begin UNO includes === **/ 41 /** === end UNO includes === **/ 42 43 class EditView; 44 class EditEngine; 45 class SfxItemSet; 46 //........................................................................ 47 namespace frm 48 { 49 //........................................................................ 50 51 class RichTextControlImpl; 52 class RichTextEngine; 53 //==================================================================== 54 //= RichTextControl 55 //==================================================================== 56 class RichTextControl : public Control, public IMultiAttributeDispatcher 57 { 58 private: 59 RichTextControlImpl* m_pImpl; 60 61 public: 62 RichTextControl( 63 RichTextEngine* _pEngine, 64 Window* _pParent, 65 WinBits _nStyle, 66 ITextAttributeListener* _pTextAttribListener, 67 ITextSelectionListener* _pSelectionListener 68 ); 69 70 ~RichTextControl( ); 71 72 /* enables the change notifications for a particular attribute 73 74 If you want to be notified of any changes in the state of an attribute, you need to call enableAttributeNotification. 75 76 If you provide a dedicated listener for this attribute, this listener is called for every change in the state of 77 the attribute. 78 79 No matter whether you provide such a dedicated listener, the "global" listener which you specified 80 in the constructor of the control is also called for all changes in the attribute state. 81 82 If you previously already enabled the notification for this attribute, and specified a different listener, 83 then the previous listener will be replaced with the new listener, provided the latter is not <NULL/>. 84 */ 85 void enableAttributeNotification( AttributeId _nAttributeId, ITextAttributeListener* _pListener = NULL ); 86 87 /** disables the change notifications for a particular attribute 88 89 If there was a listener dedicated to this attribute, it will not be referenced and used anymore 90 after this method had been called 91 */ 92 void disableAttributeNotification( AttributeId _nAttributeId ); 93 94 /** determines whether a given slot can be mapped to an aspect of an attribute of the EditEngine 95 96 E.g. SID_ATTR_PARA_ADJUST_LEFT can, though it's not part of the EditEngine pool, be mapped 97 to the SID_ATTR_PARA_ADJUST slot, which in fact *is* usable with the EditEngine. 98 */ 99 static bool isMappableSlot( SfxSlotId _nSlotId ); 100 101 // IMultiAttributeDispatcher 102 virtual AttributeState getState( AttributeId _nAttributeId ) const; 103 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ); 104 105 void SetBackgroundColor( ); 106 void SetBackgroundColor( const Color& _rColor ); 107 108 void SetReadOnly( bool _bReadOnly ); 109 bool IsReadOnly() const; 110 111 void SetHideInactiveSelection( bool _bHide ); 112 bool GetHideInactiveSelection() const; 113 114 const EditView& getView() const; 115 EditView& getView(); 116 117 // Window overridables 118 virtual void Draw( OutputDevice* _pDev, const Point& _rPos, const Size& _rSize, sal_uLong _nFlags ); 119 120 protected: 121 // Window overridables 122 virtual void Resize(); 123 virtual void GetFocus(); 124 virtual void StateChanged( StateChangedType nStateChange ); 125 virtual long PreNotify( NotifyEvent& _rNEvt ); 126 virtual long Notify( NotifyEvent& _rNEvt ); 127 128 private: 129 void applyAttributes( const SfxItemSet& _rAttributesToApply ); 130 void implInit( RichTextEngine* _pEngine, ITextAttributeListener* _pTextAttribListener, ITextSelectionListener* _pSelectionListener ); 131 static WinBits implInitStyle( WinBits nStyle ); 132 133 private: 134 EditEngine& getEngine() const; 135 Window& getViewport() const; 136 }; 137 138 //........................................................................ 139 } // namespace frm 140 //........................................................................ 141 142 #endif // FORMS_SOURCE_RICHTEXT_RICHTEXTVCLCONTROL_HXX 143 144