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