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 _VCLMEDIT_HXX
21 : #define _VCLMEDIT_HXX
22 :
23 : #include <tools/wintypes.hxx>
24 : #include <vcl/edit.hxx>
25 : #include <vcl/dllapi.h>
26 :
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( ImpUpdateDataHdl, void* );
47 : void StateChanged( StateChangedType nType );
48 : void DataChanged( const DataChangedEvent& rDCEvt );
49 : virtual long PreNotify( NotifyEvent& rNEvt );
50 : long Notify( NotifyEvent& rNEvt );
51 : using Control::ImplInitSettings;
52 : void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
53 : WinBits ImplInitStyle( WinBits nStyle );
54 :
55 : ExtTextEngine* GetTextEngine() const;
56 : ExtTextView* GetTextView() const;
57 : ScrollBar* GetVScrollBar() const;
58 :
59 : public:
60 : VclMultiLineEdit( Window* pParent, WinBits nWinStyle = WB_LEFT | WB_BORDER );
61 : VclMultiLineEdit( Window* pParent, const ResId& rResId );
62 : virtual ~VclMultiLineEdit();
63 :
64 :
65 : virtual void Modify();
66 : virtual void UpdateData();
67 :
68 : virtual void SetModifyFlag();
69 : virtual void ClearModifyFlag();
70 : virtual sal_Bool IsModified() const;
71 :
72 : virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT );
73 0 : virtual void DisableUpdateData() { delete pUpdateDataTimer; pUpdateDataTimer = NULL; }
74 : virtual sal_uLong IsUpdateDataEnabled() const;
75 :
76 : virtual void SetReadOnly( sal_Bool bReadOnly = sal_True );
77 : virtual sal_Bool IsReadOnly() const;
78 :
79 : void EnableFocusSelectionHide( sal_Bool bHide );
80 :
81 : virtual void SetMaxTextLen( xub_StrLen nMaxLen = 0 );
82 : virtual xub_StrLen GetMaxTextLen() const;
83 :
84 : void SetMaxTextWidth( sal_uLong nMaxWidth );
85 :
86 : virtual void SetSelection( const Selection& rSelection );
87 : virtual const Selection& GetSelection() const;
88 :
89 : virtual void ReplaceSelected( const OUString& rStr );
90 : virtual void DeleteSelected();
91 : virtual OUString GetSelected() const;
92 : virtual OUString GetSelected( LineEnd aSeparator ) const;
93 :
94 : virtual void Cut();
95 : virtual void Copy();
96 : virtual void Paste();
97 :
98 : virtual void SetText( const OUString& rStr );
99 0 : virtual void SetText( const OUString& rStr, const Selection& rNewSelection )
100 0 : { SetText( rStr ); SetSelection( rNewSelection ); }
101 : OUString GetText() const;
102 : OUString GetText( LineEnd aSeparator ) const;
103 : String GetTextLines( LineEnd aSeparator ) const;
104 :
105 : void SetRightToLeft( sal_Bool bRightToLeft );
106 : sal_Bool IsRightToLeft() const;
107 :
108 0 : void SaveValue() { aSaveValue = GetText(); }
109 0 : const OUString& GetSavedValue() const { return aSaveValue; }
110 :
111 17 : void SetModifyHdl( const Link& rLink ) { aModifyHdlLink = rLink; }
112 0 : const Link& GetModifyHdl() const { return aModifyHdlLink; }
113 :
114 0 : void SetUpdateDataHdl( const Link& rLink ) { aUpdateDataHdlLink = rLink; }
115 :
116 : virtual void Resize();
117 : virtual void GetFocus();
118 :
119 : virtual Size CalcMinimumSize() const;
120 : Size CalcAdjustedSize( const Size& rPrefSize ) const;
121 : using Edit::CalcSize;
122 : Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
123 : void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
124 :
125 : void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
126 :
127 : void SetLeftMargin( sal_uInt16 n );
128 :
129 : void DisableSelectionOnFocus();
130 :
131 : void SetTextSelectable( bool bTextSelectable );
132 : void EnableCursor( sal_Bool bEnable );
133 :
134 : virtual bool set_property(const OString &rKey, const OString &rValue);
135 : };
136 :
137 0 : inline sal_uLong VclMultiLineEdit::IsUpdateDataEnabled() const
138 : {
139 0 : return pUpdateDataTimer ? pUpdateDataTimer->GetTimeout() : 0;
140 : }
141 :
142 : #endif //_VCLMEDIT_HXX
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|