Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / vcl / toolkit / vclmedit.hxx
blob2ca010451907f921803b148b66f8ccee17ea4d6a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
26 #include <tools/lineend.hxx>
27 #include <vcl/wintypes.hxx>
28 #include <vcl/toolkit/edit.hxx>
29 #include <vcl/dllapi.h>
30 #include <vcl/timer.hxx>
31 #include <memory>
33 class ImpVclMEdit;
34 class ExtTextEngine;
35 class TextView;
37 class TextWindow final : public vcl::Window
39 private:
40 VclPtr<Edit> mxParent;
41 std::unique_ptr<ExtTextEngine> mpExtTextEngine;
42 std::unique_ptr<TextView> mpExtTextView;
44 bool mbInMBDown;
45 bool mbFocusSelectionHide;
46 bool mbIgnoreTab;
47 bool mbActivePopup;
48 bool mbSelectOnTab;
50 public:
51 explicit TextWindow(Edit* pParent);
52 virtual ~TextWindow() override;
53 virtual void dispose() override;
55 ExtTextEngine* GetTextEngine() const { return mpExtTextEngine.get(); }
56 TextView* GetTextView() const { return mpExtTextView.get(); }
58 virtual void MouseMove( const MouseEvent& rMEvt ) override;
59 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
60 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
61 virtual void KeyInput( const KeyEvent& rKEvent ) override;
63 virtual void Command( const CommandEvent& rCEvt ) override;
65 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
66 virtual void Resize() override;
68 virtual void GetFocus() override;
69 virtual void LoseFocus() override;
71 void SetAutoFocusHide( bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; }
73 void SetIgnoreTab( bool bIgnore ) { mbIgnoreTab = bIgnore; }
75 void DisableSelectionOnFocus() { mbSelectOnTab = false; }
78 class VCL_DLLPUBLIC VclMultiLineEdit : public Edit
80 friend class VCLXAccessibleEdit;
82 private:
83 std::unique_ptr<ImpVclMEdit> pImpVclMEdit;
85 Link<Edit&,void> aModifyHdlLink;
87 protected:
89 void StateChanged( StateChangedType nType ) override;
90 void DataChanged( const DataChangedEvent& rDCEvt ) override;
91 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
92 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
93 using Control::ImplInitSettings;
94 void ImplInitSettings( bool bBackground );
95 static WinBits ImplInitStyle( WinBits nStyle );
97 TextView* GetTextView() const;
98 ExtTextEngine* GetTextEngine() const;
100 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
101 public:
102 VclMultiLineEdit( vcl::Window* pParent,
103 WinBits nWinStyle );
104 virtual ~VclMultiLineEdit() override;
105 virtual void dispose() override;
107 void SelectionChanged();
108 void CaretChanged();
109 virtual void Modify() override;
111 virtual void SetModifyFlag() override;
113 virtual void SetReadOnly( bool bReadOnly = true ) override;
114 virtual bool IsReadOnly() const override;
116 void EnableFocusSelectionHide( bool bHide );
118 virtual void SetMaxTextLen(sal_Int32 nMaxLen) override;
119 virtual sal_Int32 GetMaxTextLen() const override;
121 void SetMaxTextWidth(tools::Long nMaxWidth);
123 virtual void SetSelection( const Selection& rSelection ) override;
124 virtual const Selection& GetSelection() const override;
126 virtual void ReplaceSelected( const OUString& rStr ) override;
127 virtual void DeleteSelected() override;
128 virtual OUString GetSelected() const override;
129 OUString GetSelected( LineEnd aSeparator ) const;
131 bool CanUp() const;
132 bool CanDown() const;
134 virtual void Cut() override;
135 virtual void Copy() override;
136 virtual void Paste() override;
138 virtual void SetText( const OUString& rStr ) override;
139 virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override
140 { SetText( rStr ); SetSelection( rNewSelection ); }
141 OUString GetText() const override;
142 OUString GetText( LineEnd aSeparator ) const;
143 OUString GetTextLines( LineEnd aSeparator ) const;
145 void SetModifyHdl( const Link<Edit&,void>& rLink ) override { aModifyHdlLink = rLink; }
146 const Link<Edit&,void>& GetModifyHdl() const override { return aModifyHdlLink; }
148 virtual void Resize() override;
149 virtual void GetFocus() override;
151 virtual Size CalcMinimumSize() const override;
152 Size CalcAdjustedSize( const Size& rPrefSize ) const;
153 Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
154 void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
156 void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
158 void DisableSelectionOnFocus();
160 void EnableCursor( bool bEnable );
162 ScrollBar& GetVScrollBar() const;
164 TextWindow* GetTextWindow();
166 virtual FactoryFunction GetUITestFactory() const override;
168 virtual bool set_property(const OUString &rKey, const OUString &rValue) override;
170 virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */