1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _SVEDIT_HXX
25 #define _SVEDIT_HXX
26
27 #include <tools/wintypes.hxx>
28 #include <vcl/edit.hxx>
29
30 #include <svtools/syntaxhighlight.hxx>
31 #include <svtools/svtdllapi.h>
32 #include <svtools/colorcfg.hxx>
33
34 class ImpSvMEdit;
35 class Timer;
36 class ExtTextEngine;
37 class ExtTextView;
38
39 class SVT_DLLPUBLIC MultiLineEdit : public Edit
40 {
41 private:
42 ImpSvMEdit* pImpSvMEdit;
43
44 XubString aSaveValue;
45 Link aModifyHdlLink;
46
47 Timer* pUpdateDataTimer;
48 Link aUpdateDataHdlLink;
49
50 protected:
51
52 DECL_LINK( ImpUpdateDataHdl, Timer* );
53 void StateChanged( StateChangedType nType );
54 void DataChanged( const DataChangedEvent& rDCEvt );
55 virtual long PreNotify( NotifyEvent& rNEvt );
56 long Notify( NotifyEvent& rNEvt );
57 using Control::ImplInitSettings;
58 void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
59 WinBits ImplInitStyle( WinBits nStyle );
60
61 ExtTextEngine* GetTextEngine() const;
62 ExtTextView* GetTextView() const;
63 ScrollBar* GetHScrollBar() const;
64 ScrollBar* GetVScrollBar() const;
65
66 public:
67 MultiLineEdit( Window* pParent, WinBits nWinStyle = WB_LEFT | WB_BORDER );
68 MultiLineEdit( Window* pParent, const ResId& rResId );
69 ~MultiLineEdit();
70
71
72 virtual void Modify();
73 virtual void UpdateData();
74
75 virtual void SetModifyFlag();
76 virtual void ClearModifyFlag();
77 virtual sal_Bool IsModified() const;
78
79 virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT );
DisableUpdateData()80 virtual void DisableUpdateData() { delete pUpdateDataTimer; pUpdateDataTimer = NULL; }
81 virtual sal_uLong IsUpdateDataEnabled() const;
82
83 virtual void SetReadOnly( sal_Bool bReadOnly = sal_True );
84 virtual sal_Bool IsReadOnly() const;
85
86 void EnableFocusSelectionHide( sal_Bool bHide );
87 sal_Bool IsFocusSelectionHideEnabled() const;
88
89 virtual void SetMaxTextLen( xub_StrLen nMaxLen = 0 );
90 virtual xub_StrLen GetMaxTextLen() const;
91
92 virtual void SetSelection( const Selection& rSelection );
93 virtual const Selection& GetSelection() const;
94
95 virtual void ReplaceSelected( const XubString& rStr );
96 virtual void DeleteSelected();
97 virtual XubString GetSelected() const;
98 virtual XubString GetSelected( LineEnd aSeparator ) const;
99
100 virtual void Cut();
101 virtual void Copy();
102 virtual void Paste();
103
104 virtual void SetText( const XubString& rStr );
SetText(const XubString & rStr,const Selection & rNewSelection)105 virtual void SetText( const XubString& rStr, const Selection& rNewSelection )
106 { SetText( rStr ); SetSelection( rNewSelection ); }
107 String GetText() const;
108 String GetText( LineEnd aSeparator ) const;
109 String GetTextLines() const;
110 String GetTextLines( LineEnd aSeparator ) const;
111
112 void SetRightToLeft( sal_Bool bRightToLeft );
113 sal_Bool IsRightToLeft() const;
114
SaveValue()115 void SaveValue() { aSaveValue = GetText(); }
GetSavedValue() const116 const XubString& GetSavedValue() const { return aSaveValue; }
117
SetModifyHdl(const Link & rLink)118 void SetModifyHdl( const Link& rLink ) { aModifyHdlLink = rLink; }
GetModifyHdl() const119 const Link& GetModifyHdl() const { return aModifyHdlLink; }
120
SetUpdateDataHdl(const Link & rLink)121 void SetUpdateDataHdl( const Link& rLink ) { aUpdateDataHdlLink = rLink; }
GetUpdateDataHdl() const122 const Link& GetUpdateDataHdl() const { return aUpdateDataHdlLink; }
123
124 virtual void Resize();
125 virtual void GetFocus();
126
127 Size CalcMinimumSize() const;
128 Size CalcAdjustedSize( const Size& rPrefSize ) const;
129 using Edit::CalcSize;
130 Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
131 void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
132
133 void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
134
135 void SetLeftMargin( sal_uInt16 n );
136 sal_uInt16 GetLeftMargin() const;
137
138 virtual
139 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
140 GetComponentInterface(sal_Bool bCreate = sal_True);
141
142 void DisableSelectionOnFocus();
143 };
144
IsUpdateDataEnabled() const145 inline sal_uLong MultiLineEdit::IsUpdateDataEnabled() const
146 {
147 return pUpdateDataTimer ? pUpdateDataTimer->GetTimeout() : 0;
148 }
149
150 #endif
151