LibreOffice Module vcl (master)  1
vclmedit.hxx
Go to the documentation of this file.
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 <tools/lineend.hxx>
27 #include <tools/wintypes.hxx>
28 #include <vcl/toolkit/edit.hxx>
29 #include <vcl/dllapi.h>
30 #include <vcl/timer.hxx>
31 #include <memory>
32 
33 class ImpVclMEdit;
34 class ExtTextEngine;
35 class TextView;
36 
37 class TextWindow final : public vcl::Window
38 {
39 private:
41  std::unique_ptr<ExtTextEngine> mpExtTextEngine;
42  std::unique_ptr<TextView> mpExtTextView;
43 
44  bool mbInMBDown;
49 
50 public:
51  explicit TextWindow(Edit* pParent);
52  virtual ~TextWindow() override;
53  virtual void dispose() override;
54 
55  ExtTextEngine* GetTextEngine() const { return mpExtTextEngine.get(); }
56  TextView* GetTextView() const { return mpExtTextView.get(); }
57 
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;
62 
63  virtual void Command( const CommandEvent& rCEvt ) override;
64 
65  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
66  virtual void Resize() override;
67 
68  virtual void GetFocus() override;
69  virtual void LoseFocus() override;
70 
71  void SetAutoFocusHide( bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; }
72 
73  void SetIgnoreTab( bool bIgnore ) { mbIgnoreTab = bIgnore; }
74 
75  void DisableSelectionOnFocus() { mbSelectOnTab = false; }
76 };
77 
79 {
80  friend class VCLXAccessibleEdit;
81 
82 private:
83  std::unique_ptr<ImpVclMEdit> pImpVclMEdit;
84 
86 
87 protected:
88 
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;
94  void ImplInitSettings( bool bBackground );
95  static WinBits ImplInitStyle( WinBits nStyle );
96 
97  TextView* GetTextView() const;
98  ExtTextEngine* GetTextEngine() const;
99 
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;
106 
107  void SelectionChanged();
108  void CaretChanged();
109  virtual void Modify() override;
110 
111  virtual void SetModifyFlag() override;
112 
113  virtual void SetReadOnly( bool bReadOnly = true ) override;
114  virtual bool IsReadOnly() const override;
115 
116  void EnableFocusSelectionHide( bool bHide );
117 
118  virtual void SetMaxTextLen(sal_Int32 nMaxLen) override;
119  virtual sal_Int32 GetMaxTextLen() const override;
120 
121  void SetMaxTextWidth(tools::Long nMaxWidth);
122 
123  virtual void SetSelection( const Selection& rSelection ) override;
124  virtual const Selection& GetSelection() const override;
125 
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;
130 
131  bool CanUp() const;
132  bool CanDown() const;
133 
134  virtual void Cut() override;
135  virtual void Copy() override;
136  virtual void Paste() override;
137 
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;
144 
145  void SetModifyHdl( const Link<Edit&,void>& rLink ) override { aModifyHdlLink = rLink; }
146  const Link<Edit&,void>& GetModifyHdl() const override { return aModifyHdlLink; }
147 
148  virtual void Resize() override;
149  virtual void GetFocus() override;
150 
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;
155 
156  void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
157 
158  void DisableSelectionOnFocus();
159 
160  void EnableCursor( bool bEnable );
161 
162  ScrollBar& GetVScrollBar() const;
163 
164  TextWindow* GetTextWindow();
165 
166  virtual FactoryFunction GetUITestFactory() const override;
167 
168  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
169 
170  virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
171 };
172 
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Size CalcMinimumSize() const
Definition: edit.cxx:2657
bool mbFocusSelectionHide
Definition: vclmedit.hxx:45
std::unique_ptr< TextView > mpExtTextView
Definition: vclmedit.hxx:42
virtual void Cut()
Definition: edit.cxx:2507
virtual void GetFocus() override
Definition: vclmedit.cxx:847
virtual void Resize() override
Definition: vclmedit.cxx:744
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: edit.cxx:363
virtual OUString GetSelected() const
Definition: edit.cxx:2495
virtual FactoryFunction GetUITestFactory() const override
Definition: edit.cxx:2912
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
virtual void Paste()
Definition: edit.cxx:2525
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: edit.cxx:223
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: vclmedit.cxx:671
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: vclmedit.cxx:739
bool mbActivePopup
Definition: vclmedit.hxx:47
virtual void DumpAsPropertyTree(tools::JsonWriter &rJsonWriter) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: edit.cxx:2918
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: edit.cxx:181
void SetIgnoreTab(bool bIgnore)
Definition: vclmedit.hxx:73
StateChangedType
Definition: window.hxx:289
void DisableSelectionOnFocus()
Definition: vclmedit.hxx:75
sal_Int64 WinBits
virtual void LoseFocus() override
Definition: vclmedit.cxx:867
virtual void Command(const CommandEvent &rCEvt) override
Definition: vclmedit.cxx:748
virtual sal_Int32 GetMaxTextLen() const
Definition: edit.hxx:181
Link< Edit &, void > aModifyHdlLink
Definition: vclmedit.hxx:85
virtual void SetModifyFlag()
Definition: edit.cxx:2588
SystemTextColorFlags
virtual const Selection & GetSelection() const
Definition: edit.cxx:2468
Definition: edit.hxx:55
std::unique_ptr< ImpVclMEdit > pImpVclMEdit
Definition: vclmedit.hxx:83
virtual void DeleteSelected()
Definition: edit.cxx:2484
virtual void SetSelection(const Selection &rSelection)
Definition: edit.cxx:2394
virtual ~TextWindow() override
Definition: vclmedit.cxx:666
TextView * GetTextView() const
Definition: vclmedit.hxx:56
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:685
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:693
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
virtual void GetFocus() override
Definition: edit.cxx:1848
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2154
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2349
const Link< Edit &, void > & GetModifyHdl() const override
Definition: vclmedit.hxx:146
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: edit.cxx:343
virtual OUString GetText() const override
Definition: edit.cxx:2564
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
virtual void Modify()
Definition: edit.cxx:2314
virtual void Resize() override
Definition: edit.cxx:1728
ExtTextEngine * GetTextEngine() const
Definition: vclmedit.hxx:55
virtual void SetText(const OUString &rStr, const Selection &rNewSelection) override
Definition: vclmedit.hxx:139
bool mbInMBDown
Definition: vclmedit.hxx:44
TextWindow(Edit *pParent)
Definition: vclmedit.cxx:639
bool mbIgnoreTab
Definition: vclmedit.hxx:46
LineEnd
std::unique_ptr< ExtTextEngine > mpExtTextEngine
Definition: vclmedit.hxx:41
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: edit.cxx:2235
bool mbSelectOnTab
Definition: vclmedit.hxx:48
virtual void Copy()
Definition: edit.cxx:2516
void SetModifyHdl(const Link< Edit &, void > &rLink) override
Definition: vclmedit.hxx:145
void ImplInitSettings()
Definition: ctrl.cxx:422
virtual void KeyInput(const KeyEvent &rKEvent) override
Definition: vclmedit.cxx:698
virtual void SetMaxTextLen(sal_Int32 nMaxLen)
Definition: edit.cxx:2381
virtual bool IsReadOnly() const
Definition: edit.hxx:175
virtual void SetText(const OUString &rStr) override
Definition: edit.cxx:2545
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:679
void SetAutoFocusHide(bool bAutoHide)
Definition: vclmedit.hxx:71
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: edit.cxx:1741
VclPtr< Edit > mxParent
Definition: vclmedit.hxx:40
virtual void ReplaceSelected(const OUString &rStr)
Definition: edit.cxx:2476
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: ctrl.cxx:224