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 : 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;
86 
87 protected:
88 
89  DECL_LINK( ImpUpdateDataHdl, Timer*, void );
90  void StateChanged( StateChangedType nType ) override;
91  void DataChanged( const DataChangedEvent& rDCEvt ) override;
92  virtual bool PreNotify( NotifyEvent& rNEvt ) override;
93  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
95  void ImplInitSettings( bool bBackground );
96  static WinBits ImplInitStyle( WinBits nStyle );
97 
98  TextView* GetTextView() const;
99  ExtTextEngine* GetTextEngine() const;
100 
101  void ApplySettings(vcl::RenderContext&) override;
102  void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&);
103  void ApplyFontSettings(vcl::RenderContext&, const StyleSettings&);
104 
105 public:
106  VclMultiLineEdit( vcl::Window* pParent,
107  WinBits nWinStyle );
108  virtual ~VclMultiLineEdit() override;
109  virtual void dispose() override;
110 
111  void SelectionChanged();
112  void CaretChanged();
113  virtual void Modify() override;
114  virtual void UpdateData() override;
115 
116  virtual void SetModifyFlag() override;
117  virtual void ClearModifyFlag() override;
118  virtual bool IsModified() const override;
119 
120  virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT ) override;
121  virtual void DisableUpdateData() override { pUpdateDataTimer.reset(); }
122 
123  virtual void SetReadOnly( bool bReadOnly = true ) override;
124  virtual bool IsReadOnly() const override;
125 
126  void EnableFocusSelectionHide( bool bHide );
127 
128  virtual void SetMaxTextLen(sal_Int32 nMaxLen) override;
129  virtual sal_Int32 GetMaxTextLen() const override;
130 
131  void SetMaxTextWidth(long nMaxWidth);
132 
133  virtual void SetSelection( const Selection& rSelection ) override;
134  virtual const Selection& GetSelection() const override;
135 
136  virtual void ReplaceSelected( const OUString& rStr ) override;
137  virtual void DeleteSelected() override;
138  virtual OUString GetSelected() const override;
139  OUString GetSelected( LineEnd aSeparator ) const;
140 
141  virtual void Cut() override;
142  virtual void Copy() override;
143  virtual void Paste() override;
144 
145  virtual void SetText( const OUString& rStr ) override;
146  virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override
147  { SetText( rStr ); SetSelection( rNewSelection ); }
148  OUString GetText() const override;
149  OUString GetText( LineEnd aSeparator ) const;
150  OUString GetTextLines( LineEnd aSeparator ) const;
151 
152  void SetRightToLeft( bool bRightToLeft );
153 
154  void SetModifyHdl( const Link<Edit&,void>& rLink ) override { aModifyHdlLink = rLink; }
155  const Link<Edit&,void>& GetModifyHdl() const override { return aModifyHdlLink; }
156 
157  void SetUpdateDataHdl( const Link<Edit&,void>& rLink ) override { aUpdateDataHdlLink = rLink; }
158 
159  virtual void Resize() override;
160  virtual void GetFocus() override;
161 
162  virtual Size CalcMinimumSize() const override;
163  Size CalcAdjustedSize( const Size& rPrefSize ) const;
164  Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
165  void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
166 
167  void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) override;
168 
169  void DisableSelectionOnFocus();
170 
171  void EnableCursor( bool bEnable );
172 
173  ScrollBar& GetVScrollBar() const;
174 
175  TextWindow* GetTextWindow();
176 
177  virtual FactoryFunction GetUITestFactory() const override;
178 
179  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
180 };
181 
182 #endif // INCLUDED_VCL_VCLMEDIT_HXX
183 
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Size CalcMinimumSize() const
Definition: edit.cxx:2727
bool mbFocusSelectionHide
Definition: vclmedit.hxx:42
#define EDIT_UPDATEDATA_TIMEOUT
Definition: edit.hxx:52
std::unique_ptr< TextView > mpExtTextView
Definition: vclmedit.hxx:39
virtual void Cut()
Definition: edit.cxx:2557
virtual void GetFocus() override
Definition: vclmedit.cxx:848
virtual void Resize() override
Definition: vclmedit.cxx:745
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: edit.cxx:364
virtual OUString GetSelected() const
Definition: edit.cxx:2545
virtual FactoryFunction GetUITestFactory() const override
Definition: edit.cxx:2985
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uIntPtr sal_uLong
virtual void DisableUpdateData() override
Definition: vclmedit.hxx:121
virtual void Paste()
Definition: edit.cxx:2575
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:672
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: vclmedit.cxx:740
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:181
void SetIgnoreTab(bool bIgnore)
Definition: vclmedit.hxx:70
virtual void ClearModifyFlag()
Definition: edit.cxx:2654
StateChangedType
Definition: window.hxx:309
void DisableSelectionOnFocus()
Definition: vclmedit.hxx:72
sal_Int64 WinBits
virtual void LoseFocus() override
Definition: vclmedit.cxx:870
virtual void Command(const CommandEvent &rCEvt) override
Definition: vclmedit.cxx:749
virtual sal_Int32 GetMaxTextLen() const
Definition: edit.hxx:199
Link< Edit &, void > aModifyHdlLink
Definition: vclmedit.hxx:82
virtual void SetModifyFlag()
Definition: edit.cxx:2646
virtual const Selection & GetSelection() const
Definition: edit.cxx:2518
Definition: edit.hxx:58
std::unique_ptr< ImpVclMEdit > pImpVclMEdit
Definition: vclmedit.hxx:80
virtual void DeleteSelected()
Definition: edit.cxx:2534
virtual void SetSelection(const Selection &rSelection)
Definition: edit.cxx:2444
virtual ~TextWindow() override
Definition: vclmedit.cxx:667
TextView * GetTextView() const
Definition: vclmedit.hxx:53
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:686
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:694
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:51
DrawFlags
Definition: window.hxx:352
virtual void GetFocus() override
Definition: edit.cxx:1838
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2160
Link< Edit &, void > aUpdateDataHdlLink
Definition: vclmedit.hxx:85
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2390
virtual void UpdateData()
Definition: edit.cxx:2351
const Link< Edit &, void > & GetModifyHdl() const override
Definition: vclmedit.hxx:155
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: edit.cxx:338
virtual OUString GetText() const override
Definition: edit.cxx:2614
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:2320
virtual void Resize() override
Definition: edit.cxx:1723
std::unique_ptr< Timer > pUpdateDataTimer
Definition: vclmedit.hxx:84
virtual void EnableUpdateData(sal_uLong nTimeout=EDIT_UPDATEDATA_TIMEOUT)
Definition: edit.cxx:2361
ExtTextEngine * GetTextEngine() const
Definition: vclmedit.hxx:52
virtual void SetText(const OUString &rStr, const Selection &rNewSelection) override
Definition: vclmedit.hxx:146
bool mbInMBDown
Definition: vclmedit.hxx:41
TextWindow(Edit *pParent)
Definition: vclmedit.cxx:640
bool mbIgnoreTab
Definition: vclmedit.hxx:43
LineEnd
std::unique_ptr< ExtTextEngine > mpExtTextEngine
Definition: vclmedit.hxx:38
void SetUpdateDataHdl(const Link< Edit &, void > &rLink) override
Definition: vclmedit.hxx:157
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: edit.cxx:2241
bool mbSelectOnTab
Definition: vclmedit.hxx:45
virtual void Copy()
Definition: edit.cxx:2566
void SetModifyHdl(const Link< Edit &, void > &rLink) override
Definition: vclmedit.hxx:154
void ImplInitSettings()
Definition: ctrl.cxx:428
virtual void KeyInput(const KeyEvent &rKEvent) override
Definition: vclmedit.cxx:699
virtual void SetMaxTextLen(sal_Int32 nMaxLen)
Definition: edit.cxx:2431
Definition: timer.hxx:26
virtual bool IsReadOnly() const
Definition: edit.hxx:190
virtual void SetText(const OUString &rStr) override
Definition: edit.cxx:2595
virtual void Draw(OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags) override
Definition: edit.cxx:1736
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: vclmedit.cxx:680
void SetAutoFocusHide(bool bAutoHide)
Definition: vclmedit.hxx:68
VclPtr< Edit > mxParent
Definition: vclmedit.hxx:37
virtual void ReplaceSelected(const OUString &rStr)
Definition: edit.cxx:2526
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: ctrl.cxx:225