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 .
20 #ifndef INCLUDED_VCL_VCLMEDIT_HXX
21 #define INCLUDED_VCL_VCLMEDIT_HXX
23 #include <tools/lineend.hxx>
24 #include <tools/wintypes.hxx>
25 #include <vcl/edit.hxx>
26 #include <vcl/dllapi.h>
27 #include <vcl/timer.hxx>
34 class TextWindow
: public vcl::Window
37 VclPtr
<Edit
> mxParent
;
38 std::unique_ptr
<ExtTextEngine
> mpExtTextEngine
;
39 std::unique_ptr
<TextView
> mpExtTextView
;
42 bool mbFocusSelectionHide
;
48 explicit TextWindow(Edit
* pParent
);
49 virtual ~TextWindow() override
;
50 virtual void dispose() override
;
52 ExtTextEngine
* GetTextEngine() const { return mpExtTextEngine
.get(); }
53 TextView
* GetTextView() const { return mpExtTextView
.get(); }
55 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
56 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
57 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
58 virtual void KeyInput( const KeyEvent
& rKEvent
) override
;
60 virtual void Command( const CommandEvent
& rCEvt
) override
;
62 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
63 virtual void Resize() override
;
65 virtual void GetFocus() override
;
66 virtual void LoseFocus() override
;
68 void SetAutoFocusHide( bool bAutoHide
) { mbFocusSelectionHide
= bAutoHide
; }
70 void SetIgnoreTab( bool bIgnore
) { mbIgnoreTab
= bIgnore
; }
72 void DisableSelectionOnFocus() { mbSelectOnTab
= false; }
75 class VCL_DLLPUBLIC VclMultiLineEdit
: public Edit
77 friend class VCLXAccessibleEdit
;
80 std::unique_ptr
<ImpVclMEdit
> pImpVclMEdit
;
82 Link
<Edit
&,void> aModifyHdlLink
;
84 std::unique_ptr
<Timer
> pUpdateDataTimer
;
85 Link
<Edit
&,void> aUpdateDataHdlLink
;
89 DECL_LINK( ImpUpdateDataHdl
, Timer
*, void );
90 void StateChanged( StateChangedType nType
) override
;
91 void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
92 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
93 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
94 using Control::ImplInitSettings
;
95 void ImplInitSettings( bool bBackground
);
96 static WinBits
ImplInitStyle( WinBits nStyle
);
98 TextView
* GetTextView() const;
99 ExtTextEngine
* GetTextEngine() const;
101 void ApplySettings(vcl::RenderContext
&) override
;
102 void ApplyBackgroundSettings(vcl::RenderContext
&, const StyleSettings
&);
103 void ApplyFontSettings(vcl::RenderContext
&, const StyleSettings
&);
106 VclMultiLineEdit( vcl::Window
* pParent
,
108 virtual ~VclMultiLineEdit() override
;
109 virtual void dispose() override
;
111 void SelectionChanged();
113 virtual void Modify() override
;
114 virtual void UpdateData() override
;
116 virtual void SetModifyFlag() override
;
117 virtual void ClearModifyFlag() override
;
118 virtual bool IsModified() const override
;
120 virtual void EnableUpdateData( sal_uLong nTimeout
= EDIT_UPDATEDATA_TIMEOUT
) override
;
121 virtual void DisableUpdateData() override
{ pUpdateDataTimer
.reset(); }
123 virtual void SetReadOnly( bool bReadOnly
= true ) override
;
124 virtual bool IsReadOnly() const override
;
126 void EnableFocusSelectionHide( bool bHide
);
128 virtual void SetMaxTextLen(sal_Int32 nMaxLen
) override
;
129 virtual sal_Int32
GetMaxTextLen() const override
;
131 void SetMaxTextWidth(long nMaxWidth
);
133 virtual void SetSelection( const Selection
& rSelection
) override
;
134 virtual const Selection
& GetSelection() const override
;
136 virtual void ReplaceSelected( const OUString
& rStr
) override
;
137 virtual void DeleteSelected() override
;
138 virtual OUString
GetSelected() const override
;
139 OUString
GetSelected( LineEnd aSeparator
) const;
141 virtual void Cut() override
;
142 virtual void Copy() override
;
143 virtual void Paste() override
;
145 virtual void SetText( const OUString
& rStr
) override
;
146 virtual void SetText( const OUString
& rStr
, const Selection
& rNewSelection
) override
147 { SetText( rStr
); SetSelection( rNewSelection
); }
148 OUString
GetText() const override
;
149 OUString
GetText( LineEnd aSeparator
) const;
150 OUString
GetTextLines( LineEnd aSeparator
) const;
152 void SetRightToLeft( bool bRightToLeft
);
154 void SetModifyHdl( const Link
<Edit
&,void>& rLink
) override
{ aModifyHdlLink
= rLink
; }
155 const Link
<Edit
&,void>& GetModifyHdl() const override
{ return aModifyHdlLink
; }
157 void SetUpdateDataHdl( const Link
<Edit
&,void>& rLink
) override
{ aUpdateDataHdlLink
= rLink
; }
159 virtual void Resize() override
;
160 virtual void GetFocus() override
;
162 virtual Size
CalcMinimumSize() const override
;
163 Size
CalcAdjustedSize( const Size
& rPrefSize
) const;
164 Size
CalcBlockSize( sal_uInt16 nColumns
, sal_uInt16 nLines
) const;
165 void GetMaxVisColumnsAndLines( sal_uInt16
& rnCols
, sal_uInt16
& rnLines
) const;
167 void Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, DrawFlags nFlags
) override
;
169 void DisableSelectionOnFocus();
171 void EnableCursor( bool bEnable
);
173 ScrollBar
& GetVScrollBar() const;
175 TextWindow
* GetTextWindow();
177 virtual FactoryFunction
GetUITestFactory() const override
;
179 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
182 #endif // INCLUDED_VCL_VCLMEDIT_HXX
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */