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  void ApplySettings(vcl::RenderContext&) override;
101  void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&);
102  void ApplyFontSettings(vcl::RenderContext&, const StyleSettings&);
103 
104 public:
105  VclMultiLineEdit( vcl::Window* pParent,
106  WinBits nWinStyle );
107  virtual ~VclMultiLineEdit() override;
108  virtual void dispose() override;
109 
110  void SelectionChanged();
111  void CaretChanged();
112  virtual void Modify() override;
113 
114  virtual void SetModifyFlag() override;
115  virtual void ClearModifyFlag() override;
116  virtual bool IsModified() const override;
117 
118  void EnableUpdateData( sal_uLong nTimeout );
119  virtual void UpdateData();
120  void DisableUpdateData() { pUpdateDataTimer.reset(); }
121 
122  virtual void SetReadOnly( bool bReadOnly = true ) override;
123  virtual bool IsReadOnly() const override;
124 
125  void EnableFocusSelectionHide( bool bHide );
126 
127  virtual void SetMaxTextLen(sal_Int32 nMaxLen) override;
128  virtual sal_Int32 GetMaxTextLen() const override;
129 
130  void SetMaxTextWidth(long nMaxWidth);
131 
132  virtual void SetSelection( const Selection& rSelection ) override;
133  virtual const Selection& GetSelection() const override;
134 
135  virtual void ReplaceSelected( const OUString& rStr ) override;
136  virtual void DeleteSelected() override;
137  virtual OUString GetSelected() const override;
138  OUString GetSelected( LineEnd aSeparator ) const;
139 
140  virtual void Cut() override;
141  virtual void Copy() override;
142  virtual void Paste() override;
143 
144  virtual void SetText( const OUString& rStr ) override;
145  virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override
146  { SetText( rStr ); SetSelection( rNewSelection ); }
147  OUString GetText() const override;
148  OUString GetText( LineEnd aSeparator ) const;
149  OUString GetTextLines( LineEnd aSeparator ) const;
150 
151  void SetRightToLeft( bool bRightToLeft );
152 
153  void SetModifyHdl( const Link<Edit&,void>& rLink ) override { aModifyHdlLink = rLink; }
154  const Link<Edit&,void>& GetModifyHdl() const override { return aModifyHdlLink; }
155 
156  virtual void Resize() override;
157  virtual void GetFocus() override;
158 
159  virtual Size CalcMinimumSize() const override;
160  Size CalcAdjustedSize( const Size& rPrefSize ) const;
161  Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
162  void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
163 
164  void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override;
165 
166  void DisableSelectionOnFocus();
167 
168  void EnableCursor( bool bEnable );
169 
170  ScrollBar& GetVScrollBar() const;
171 
172  TextWindow* GetTextWindow();
173 
174  virtual FactoryFunction GetUITestFactory() const override;
175 
176  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
177 };
178 
179 #endif // INCLUDED_VCL_VCLMEDIT_HXX
180 
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Size CalcMinimumSize() const
Definition: edit.cxx:2669
bool mbFocusSelectionHide
Definition: vclmedit.hxx:42
std::unique_ptr< TextView > mpExtTextView
Definition: vclmedit.hxx:39
virtual void Cut()
Definition: edit.cxx:2507
virtual void GetFocus() override
Definition: vclmedit.cxx:849
virtual void Resize() override
Definition: vclmedit.cxx:746
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: edit.cxx:362
virtual OUString GetSelected() const
Definition: edit.cxx:2495
virtual FactoryFunction GetUITestFactory() const override
Definition: edit.cxx:2927
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uIntPtr sal_uLong
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:213
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: vclmedit.cxx:673
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: vclmedit.cxx:741
bool mbActivePopup
Definition: vclmedit.hxx:44
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: edit.cxx:176
virtual bool IsModified() const
Definition: edit.hxx:175
void SetIgnoreTab(bool bIgnore)
Definition: vclmedit.hxx:70
virtual void ClearModifyFlag()
Definition: edit.cxx:2596
StateChangedType
Definition: window.hxx:311
void DisableSelectionOnFocus()
Definition: vclmedit.hxx:72
sal_Int64 WinBits
virtual void LoseFocus() override
Definition: vclmedit.cxx:871
virtual void Command(const CommandEvent &rCEvt) override
Definition: vclmedit.cxx:750
virtual sal_Int32 GetMaxTextLen() const
Definition: edit.hxx:189
Link< Edit &, void > aModifyHdlLink
Definition: vclmedit.hxx:82
virtual void SetModifyFlag()
Definition: edit.cxx:2588
virtual const Selection & GetSelection() const
Definition: edit.cxx:2468
Definition: edit.hxx:57
std::unique_ptr< ImpVclMEdit > pImpVclMEdit
Definition: vclmedit.hxx:80
virtual void DeleteSelected()
Definition: edit.cxx:2484
virtual void SetSelection(const Selection &rSelection)
Definition: edit.cxx:2394
virtual ~TextWindow() override
Definition: vclmedit.cxx:668
TextView * GetTextView() const
Definition: vclmedit.hxx:53
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:687
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:695
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:51
DrawFlags
Definition: window.hxx:354
virtual void GetFocus() override
Definition: edit.cxx:1830
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2145
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2340
const Link< Edit &, void > & GetModifyHdl() const override
Definition: vclmedit.hxx:154
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: edit.cxx:336
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:304
virtual void Modify()
Definition: edit.cxx:2305
virtual void Resize() override
Definition: edit.cxx:1715
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:145
bool mbInMBDown
Definition: vclmedit.hxx:41
TextWindow(Edit *pParent)
Definition: vclmedit.cxx:641
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:2226
bool mbSelectOnTab
Definition: vclmedit.hxx:45
virtual void Copy()
Definition: edit.cxx:2516
void SetModifyHdl(const Link< Edit &, void > &rLink) override
Definition: vclmedit.hxx:153
void ImplInitSettings()
Definition: ctrl.cxx:428
virtual void KeyInput(const KeyEvent &rKEvent) override
Definition: vclmedit.cxx:700
virtual void SetMaxTextLen(sal_Int32 nMaxLen)
Definition: edit.cxx:2381
Definition: timer.hxx:26
virtual bool IsReadOnly() const
Definition: edit.hxx:181
virtual void SetText(const OUString &rStr) override
Definition: edit.cxx:2545
virtual void Draw(OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags) override
Definition: edit.cxx:1728
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:681
void SetAutoFocusHide(bool bAutoHide)
Definition: vclmedit.hxx:68
VclPtr< Edit > mxParent
Definition: vclmedit.hxx:37
virtual void ReplaceSelected(const OUString &rStr)
Definition: edit.cxx:2476
void DisableUpdateData()
Definition: vclmedit.hxx:120
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: ctrl.cxx:225