/src/libreoffice/include/vcl/toolkit/vclmedit.hxx
Line | Count | Source |
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 | | |
20 | | #pragma once |
21 | | |
22 | | #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) |
23 | | #error "don't use this in new code" |
24 | | #endif |
25 | | |
26 | | #include <config_options.h> |
27 | | #include <tools/lineend.hxx> |
28 | | #include <vcl/wintypes.hxx> |
29 | | #include <vcl/toolkit/edit.hxx> |
30 | | #include <vcl/dllapi.h> |
31 | | #include <vcl/timer.hxx> |
32 | | #include <memory> |
33 | | |
34 | | class ImpVclMEdit; |
35 | | class ExtTextEngine; |
36 | | class ScrollBar; |
37 | | class TextView; |
38 | | |
39 | | class TextWindow final : public vcl::Window |
40 | | { |
41 | | private: |
42 | | VclPtr<Edit> mxParent; |
43 | | std::unique_ptr<ExtTextEngine> mpExtTextEngine; |
44 | | std::unique_ptr<TextView> mpExtTextView; |
45 | | |
46 | | bool mbInMBDown; |
47 | | bool mbFocusSelectionHide; |
48 | | bool mbIgnoreTab; |
49 | | bool mbActivePopup; |
50 | | bool mbSelectOnTab; |
51 | | |
52 | | public: |
53 | | explicit TextWindow(Edit* pParent); |
54 | | virtual ~TextWindow() override; |
55 | | virtual void dispose() override; |
56 | | |
57 | 0 | ExtTextEngine* GetTextEngine() const { return mpExtTextEngine.get(); } |
58 | 0 | TextView* GetTextView() const { return mpExtTextView.get(); } |
59 | | |
60 | | virtual void MouseMove( const MouseEvent& rMEvt ) override; |
61 | | virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; |
62 | | virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; |
63 | | virtual void KeyInput( const KeyEvent& rKEvent ) override; |
64 | | |
65 | | virtual void Command( const CommandEvent& rCEvt ) override; |
66 | | |
67 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
68 | | virtual void Resize() override; |
69 | | |
70 | | virtual void GetFocus() override; |
71 | | virtual void LoseFocus() override; |
72 | | |
73 | 0 | void SetAutoFocusHide( bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; } |
74 | | |
75 | 0 | void SetIgnoreTab( bool bIgnore ) { mbIgnoreTab = bIgnore; } |
76 | | |
77 | 0 | void DisableSelectionOnFocus() { mbSelectOnTab = false; } |
78 | | }; |
79 | | |
80 | | class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) VclMultiLineEdit : public Edit |
81 | | { |
82 | | friend class VCLXAccessibleEdit; |
83 | | |
84 | | private: |
85 | | std::unique_ptr<ImpVclMEdit> pImpVclMEdit; |
86 | | |
87 | | Link<Edit&,void> aModifyHdlLink; |
88 | | |
89 | | protected: |
90 | | |
91 | | void StateChanged( StateChangedType nType ) override; |
92 | | void DataChanged( const DataChangedEvent& rDCEvt ) override; |
93 | | virtual bool PreNotify( NotifyEvent& rNEvt ) override; |
94 | | virtual bool EventNotify( NotifyEvent& rNEvt ) override; |
95 | | using Control::ImplInitSettings; |
96 | | void ImplInitSettings( bool bBackground ); |
97 | | static WinBits ImplInitStyle( WinBits nStyle ); |
98 | | |
99 | | TextView* GetTextView() const; |
100 | | ExtTextEngine* GetTextEngine() const; |
101 | | |
102 | | virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; |
103 | | public: |
104 | | VclMultiLineEdit( vcl::Window* pParent, |
105 | | WinBits nWinStyle ); |
106 | | virtual ~VclMultiLineEdit() override; |
107 | | virtual void dispose() override; |
108 | | |
109 | | void SelectionChanged(); |
110 | | void CaretChanged(); |
111 | | virtual void Modify() override; |
112 | | |
113 | | virtual void SetModifyFlag() override; |
114 | | |
115 | | virtual void SetReadOnly( bool bReadOnly = true ) override; |
116 | | virtual bool IsReadOnly() const override; |
117 | | |
118 | | void EnableFocusSelectionHide( bool bHide ); |
119 | | |
120 | | virtual void SetMaxTextLen(sal_Int32 nMaxLen) override; |
121 | | virtual sal_Int32 GetMaxTextLen() const override; |
122 | | |
123 | | void SetMaxTextWidth(tools::Long nMaxWidth); |
124 | | |
125 | | virtual void SetSelection( const Selection& rSelection ) override; |
126 | | virtual const Selection& GetSelection() const override; |
127 | | |
128 | | virtual void ReplaceSelected( const OUString& rStr ) override; |
129 | | virtual void DeleteSelected() override; |
130 | | virtual OUString GetSelected() const override; |
131 | | OUString GetSelected( LineEnd aSeparator ) const; |
132 | | |
133 | | bool CanUp() const; |
134 | | bool CanDown() const; |
135 | | |
136 | | virtual void Cut() override; |
137 | | virtual void Copy() override; |
138 | | virtual void Paste() override; |
139 | | |
140 | | virtual void SetText( const OUString& rStr ) override; |
141 | | virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override |
142 | 0 | { SetText( rStr ); SetSelection( rNewSelection ); } |
143 | | OUString GetText() const override; |
144 | | OUString GetText( LineEnd aSeparator ) const; |
145 | | OUString GetTextLines( LineEnd aSeparator ) const; |
146 | | |
147 | 0 | void SetModifyHdl( const Link<Edit&,void>& rLink ) override { aModifyHdlLink = rLink; } |
148 | 0 | const Link<Edit&,void>& GetModifyHdl() const override { return aModifyHdlLink; } |
149 | | |
150 | | virtual void Resize() override; |
151 | | virtual void GetFocus() override; |
152 | | |
153 | | virtual Size CalcMinimumSize() const override; |
154 | | Size CalcAdjustedSize( const Size& rPrefSize ) const; |
155 | | Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; |
156 | | void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; |
157 | | |
158 | | void Draw(OutputDevice& rDev, const Point& rPos, SystemTextColorFlags nFlags) override; |
159 | | |
160 | | void DisableSelectionOnFocus(); |
161 | | |
162 | | void EnableCursor( bool bEnable ); |
163 | | |
164 | | ScrollBar& GetVScrollBar() const; |
165 | | |
166 | | TextWindow* GetTextWindow(); |
167 | | |
168 | | virtual FactoryFunction GetUITestFactory() const override; |
169 | | |
170 | | virtual bool set_property(const OUString &rKey, const OUString &rValue) override; |
171 | | }; |
172 | | |
173 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |