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 #ifndef INCLUDED_VCL_VCLMEDIT_HXX
21 #define INCLUDED_VCL_VCLMEDIT_HXX
22 
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>
28 #include <memory>
29 
30 class ImpVclMEdit;
31 class ExtTextEngine;
32 class TextView;
33 
34 class TextWindow final : public vcl::Window
35 {
36 private:
38  std::unique_ptr<ExtTextEngine> mpExtTextEngine;
39  std::unique_ptr<TextView> mpExtTextView;
40 
41  bool mbInMBDown;
46 
47 public:
48  explicit TextWindow(Edit* pParent);
49  virtual ~TextWindow() override;
50  virtual void dispose() override;
51 
52  ExtTextEngine* GetTextEngine() const { return mpExtTextEngine.get(); }
53  TextView* GetTextView() const { return mpExtTextView.get(); }
54 
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;
59 
60  virtual void Command( const CommandEvent& rCEvt ) override;
61 
62  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
63  virtual void Resize() override;
64 
65  virtual void GetFocus() override;
66  virtual void LoseFocus() override;
67 
68  void SetAutoFocusHide( bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; }
69 
70  void SetIgnoreTab( bool bIgnore ) { mbIgnoreTab = bIgnore; }
71 
72  void DisableSelectionOnFocus() { mbSelectOnTab = false; }
73 };
74 
76 {
77  friend class VCLXAccessibleEdit;
78 
79 private:
80  std::unique_ptr<ImpVclMEdit> pImpVclMEdit;
81 
83 
84  std::unique_ptr<Timer> pUpdateDataTimer;
85 
86 protected:
87 
88  DECL_LINK( ImpUpdateDataHdl, Timer*, void );
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  virtual void ClearModifyFlag() override;
113  virtual bool IsModified() const override;
114 
115  void EnableUpdateData( sal_uLong nTimeout );
116  virtual void UpdateData();
117  void DisableUpdateData() { pUpdateDataTimer.reset(); }
118 
119  virtual void SetReadOnly( bool bReadOnly = true ) override;
120  virtual bool IsReadOnly() const override;
121 
122  void EnableFocusSelectionHide( bool bHide );
123 
124  virtual void SetMaxTextLen(sal_Int32 nMaxLen) override;
125  virtual sal_Int32 GetMaxTextLen() const override;
126 
127  void SetMaxTextWidth(long nMaxWidth);
128 
129  virtual void SetSelection( const Selection& rSelection ) override;
130  virtual const Selection& GetSelection() const override;
131 
132  virtual void ReplaceSelected( const OUString& rStr ) override;
133  virtual void DeleteSelected() override;
134  virtual OUString GetSelected() const override;
135  OUString GetSelected( LineEnd aSeparator ) const;
136 
137  virtual void Cut() override;
138  virtual void Copy() override;
139  virtual void Paste() override;
140 
141  virtual void SetText( const OUString& rStr ) override;
142  virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override
143  { SetText( rStr ); SetSelection( rNewSelection ); }
144  OUString GetText() const override;
145  OUString GetText( LineEnd aSeparator ) const;
146  OUString GetTextLines( LineEnd aSeparator ) const;
147 
148  void SetRightToLeft( bool bRightToLeft );
149 
150  void SetModifyHdl( const Link<Edit&,void>& rLink ) override { aModifyHdlLink = rLink; }
151  const Link<Edit&,void>& GetModifyHdl() const override { return aModifyHdlLink; }
152 
153  virtual void Resize() override;
154  virtual void GetFocus() override;
155 
156  virtual Size CalcMinimumSize() const override;
157  Size CalcAdjustedSize( const Size& rPrefSize ) const;
158  Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
159  void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
160 
161  void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override;
162 
163  void DisableSelectionOnFocus();
164 
165  void EnableCursor( bool bEnable );
166 
167  ScrollBar& GetVScrollBar() const;
168 
169  TextWindow* GetTextWindow();
170 
171  virtual FactoryFunction GetUITestFactory() const override;
172 
173  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
174 };
175 
176 #endif // INCLUDED_VCL_VCLMEDIT_HXX
177 
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Size CalcMinimumSize() const
Definition: edit.cxx:2664
bool mbFocusSelectionHide
Definition: vclmedit.hxx:42
std::unique_ptr< TextView > mpExtTextView
Definition: vclmedit.hxx:39
virtual void Cut()
Definition: edit.cxx:2502
virtual void GetFocus() override
Definition: vclmedit.cxx:850
virtual void Resize() override
Definition: vclmedit.cxx:747
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: edit.cxx:363
virtual OUString GetSelected() const
Definition: edit.cxx:2490
virtual FactoryFunction GetUITestFactory() const override
Definition: edit.cxx:2920
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uIntPtr sal_uLong
virtual void Paste()
Definition: edit.cxx:2520
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:214
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: vclmedit.cxx:674
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: vclmedit.cxx:742
bool mbActivePopup
Definition: vclmedit.hxx:44
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: edit.cxx:177
virtual bool IsModified() const
Definition: edit.hxx:174
void SetIgnoreTab(bool bIgnore)
Definition: vclmedit.hxx:70
virtual void ClearModifyFlag()
Definition: edit.cxx:2591
StateChangedType
Definition: window.hxx:311
void DisableSelectionOnFocus()
Definition: vclmedit.hxx:72
sal_Int64 WinBits
virtual void LoseFocus() override
Definition: vclmedit.cxx:872
virtual void Command(const CommandEvent &rCEvt) override
Definition: vclmedit.cxx:751
virtual sal_Int32 GetMaxTextLen() const
Definition: edit.hxx:188
Link< Edit &, void > aModifyHdlLink
Definition: vclmedit.hxx:82
virtual void SetModifyFlag()
Definition: edit.cxx:2583
virtual const Selection & GetSelection() const
Definition: edit.cxx:2463
Definition: edit.hxx:55
std::unique_ptr< ImpVclMEdit > pImpVclMEdit
Definition: vclmedit.hxx:80
virtual void DeleteSelected()
Definition: edit.cxx:2479
virtual void SetSelection(const Selection &rSelection)
Definition: edit.cxx:2389
virtual ~TextWindow() override
Definition: vclmedit.cxx:669
TextView * GetTextView() const
Definition: vclmedit.hxx:53
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:688
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:696
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:51
DrawFlags
Definition: window.hxx:354
virtual void GetFocus() override
Definition: edit.cxx:1825
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2140
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2335
const Link< Edit &, void > & GetModifyHdl() const override
Definition: vclmedit.hxx:151
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: edit.cxx:337
virtual OUString GetText() const override
Definition: edit.cxx:2559
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
virtual void Modify()
Definition: edit.cxx:2300
virtual void Resize() override
Definition: edit.cxx:1711
std::unique_ptr< Timer > pUpdateDataTimer
Definition: vclmedit.hxx:84
ExtTextEngine * GetTextEngine() const
Definition: vclmedit.hxx:52
virtual void SetText(const OUString &rStr, const Selection &rNewSelection) override
Definition: vclmedit.hxx:142
bool mbInMBDown
Definition: vclmedit.hxx:41
TextWindow(Edit *pParent)
Definition: vclmedit.cxx:642
bool mbIgnoreTab
Definition: vclmedit.hxx:43
LineEnd
std::unique_ptr< ExtTextEngine > mpExtTextEngine
Definition: vclmedit.hxx:38
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: edit.cxx:2221
bool mbSelectOnTab
Definition: vclmedit.hxx:45
virtual void Copy()
Definition: edit.cxx:2511
void SetModifyHdl(const Link< Edit &, void > &rLink) override
Definition: vclmedit.hxx:150
void ImplInitSettings()
Definition: ctrl.cxx:428
virtual void KeyInput(const KeyEvent &rKEvent) override
Definition: vclmedit.cxx:701
virtual void SetMaxTextLen(sal_Int32 nMaxLen)
Definition: edit.cxx:2376
Definition: timer.hxx:26
virtual bool IsReadOnly() const
Definition: edit.hxx:180
virtual void SetText(const OUString &rStr) override
Definition: edit.cxx:2540
virtual void Draw(OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags) override
Definition: edit.cxx:1724
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:682
void SetAutoFocusHide(bool bAutoHide)
Definition: vclmedit.hxx:68
VclPtr< Edit > mxParent
Definition: vclmedit.hxx:37
virtual void ReplaceSelected(const OUString &rStr)
Definition: edit.cxx:2471
void DisableUpdateData()
Definition: vclmedit.hxx:117
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: ctrl.cxx:225