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 : XubString 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 : virtual void SetSelection( const Selection& rSelection );
85 : virtual const Selection& GetSelection() const;
86 :
87 : virtual void ReplaceSelected( const XubString& rStr );
88 : virtual void DeleteSelected();
89 : virtual XubString GetSelected() const;
90 : virtual XubString GetSelected( LineEnd aSeparator ) const;
91 :
92 : virtual void Cut();
93 : virtual void Copy();
94 : virtual void Paste();
95 :
96 : virtual void SetText( const XubString& rStr );
97 0 : virtual void SetText( const XubString& rStr, const Selection& rNewSelection )
98 0 : { SetText( rStr ); SetSelection( rNewSelection ); }
99 : String GetText() const;
100 : String GetText( LineEnd aSeparator ) const;
101 : String GetTextLines( LineEnd aSeparator ) const;
102 :
103 : void SetRightToLeft( sal_Bool bRightToLeft );
104 : sal_Bool IsRightToLeft() const;
105 :
106 0 : void SaveValue() { aSaveValue = GetText(); }
107 0 : const XubString& GetSavedValue() const { return aSaveValue; }
108 :
109 0 : void SetModifyHdl( const Link& rLink ) { aModifyHdlLink = rLink; }
110 0 : const Link& GetModifyHdl() const { return aModifyHdlLink; }
111 :
112 0 : void SetUpdateDataHdl( const Link& rLink ) { aUpdateDataHdlLink = rLink; }
113 0 : const Link& GetUpdateDataHdl() const { return aUpdateDataHdlLink; }
114 :
115 : virtual void Resize();
116 : virtual void GetFocus();
117 :
118 : Size CalcMinimumSize() const;
119 : Size CalcAdjustedSize( const Size& rPrefSize ) const;
120 : using Edit::CalcSize;
121 : Size CalcSize( 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 );
125 :
126 : void SetLeftMargin( sal_uInt16 n );
127 :
128 : void DisableSelectionOnFocus();
129 :
130 : void SetTextSelectable( sal_Bool bTextSelectable );
131 : void EnableCursor( sal_Bool bEnable );
132 :
133 : virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
134 : };
135 :
136 0 : inline sal_uLong VclMultiLineEdit::IsUpdateDataEnabled() const
137 : {
138 0 : return pUpdateDataTimer ? pUpdateDataTimer->GetTimeout() : 0;
139 : }
140 :
141 : #endif //_VCLMEDIT_HXX
142 :
143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|