Line data Source code
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 :
28 : class ImpVclMEdit;
29 : class Timer;
30 : class ExtTextEngine;
31 : class ExtTextView;
32 :
33 : class VCL_DLLPUBLIC VclMultiLineEdit : public Edit
34 : {
35 : private:
36 : ImpVclMEdit* pImpVclMEdit;
37 :
38 : OUString aSaveValue;
39 : Link<> aModifyHdlLink;
40 :
41 : Timer* pUpdateDataTimer;
42 : Link<> aUpdateDataHdlLink;
43 :
44 : protected:
45 :
46 : DECL_LINK_TYPED( ImpUpdateDataHdl, Timer*, void );
47 : void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
48 : void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
49 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
50 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
51 : using Control::ImplInitSettings;
52 : void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
53 : static WinBits ImplInitStyle( WinBits nStyle );
54 :
55 : ExtTextEngine* GetTextEngine() const;
56 : ExtTextView* GetTextView() const;
57 : ScrollBar* GetVScrollBar() const;
58 :
59 : virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
60 : public:
61 : VclMultiLineEdit( vcl::Window* pParent,
62 : WinBits nWinStyle = WB_LEFT | WB_BORDER );
63 : virtual ~VclMultiLineEdit();
64 : virtual void dispose() SAL_OVERRIDE;
65 :
66 : void SelectionChanged();
67 : void CaretChanged();
68 : virtual void Modify() SAL_OVERRIDE;
69 : virtual void UpdateData() SAL_OVERRIDE;
70 :
71 : virtual void SetModifyFlag() SAL_OVERRIDE;
72 : virtual void ClearModifyFlag() SAL_OVERRIDE;
73 : virtual bool IsModified() const SAL_OVERRIDE;
74 :
75 : virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT ) SAL_OVERRIDE;
76 0 : virtual void DisableUpdateData() SAL_OVERRIDE { delete pUpdateDataTimer; pUpdateDataTimer = NULL; }
77 :
78 : virtual void SetReadOnly( bool bReadOnly = true ) SAL_OVERRIDE;
79 : virtual bool IsReadOnly() const SAL_OVERRIDE;
80 :
81 : void EnableFocusSelectionHide( bool bHide );
82 :
83 : virtual void SetMaxTextLen(sal_Int32 nMaxLen = 0) SAL_OVERRIDE;
84 : virtual sal_Int32 GetMaxTextLen() const SAL_OVERRIDE;
85 :
86 : void SetMaxTextWidth( sal_uLong nMaxWidth );
87 :
88 : virtual void SetSelection( const Selection& rSelection ) SAL_OVERRIDE;
89 : virtual const Selection& GetSelection() const SAL_OVERRIDE;
90 :
91 : virtual void ReplaceSelected( const OUString& rStr ) SAL_OVERRIDE;
92 : virtual void DeleteSelected() SAL_OVERRIDE;
93 : virtual OUString GetSelected() const SAL_OVERRIDE;
94 : OUString GetSelected( LineEnd aSeparator ) const;
95 :
96 : virtual void Cut() SAL_OVERRIDE;
97 : virtual void Copy() SAL_OVERRIDE;
98 : virtual void Paste() SAL_OVERRIDE;
99 :
100 : virtual void SetText( const OUString& rStr ) SAL_OVERRIDE;
101 0 : virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) SAL_OVERRIDE
102 0 : { SetText( rStr ); SetSelection( rNewSelection ); }
103 : OUString GetText() const SAL_OVERRIDE;
104 : OUString GetText( LineEnd aSeparator ) const;
105 : OUString GetTextLines( LineEnd aSeparator ) const;
106 :
107 : void SetRightToLeft( bool bRightToLeft );
108 :
109 0 : void SaveValue() { aSaveValue = GetText(); }
110 0 : const OUString& GetSavedValue() const { return aSaveValue; }
111 : bool IsValueChangedFromSaved() const { return aSaveValue != GetText(); }
112 :
113 17 : void SetModifyHdl( const Link<>& rLink ) SAL_OVERRIDE { aModifyHdlLink = rLink; }
114 0 : const Link<>& GetModifyHdl() const SAL_OVERRIDE { return aModifyHdlLink; }
115 :
116 0 : void SetUpdateDataHdl( const Link<>& rLink ) SAL_OVERRIDE { aUpdateDataHdlLink = rLink; }
117 :
118 : virtual void Resize() SAL_OVERRIDE;
119 : virtual void GetFocus() SAL_OVERRIDE;
120 :
121 : virtual Size CalcMinimumSize() const SAL_OVERRIDE;
122 : Size CalcAdjustedSize( const Size& rPrefSize ) const;
123 : Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
124 : void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
125 :
126 : void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
127 :
128 : void SetLeftMargin( sal_uInt16 n );
129 :
130 : void DisableSelectionOnFocus();
131 :
132 : void EnableCursor( bool bEnable );
133 :
134 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
135 : };
136 :
137 : #endif // INCLUDED_VCL_VCLMEDIT_HXX
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|