1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: srcedtw.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <vcl/window.hxx>
34 #include <svtools/lstner.hxx>
35 #include <vcl/timer.hxx>
37 #ifndef _TABLE_HXX //autogen
38 #include <tools/table.hxx>
40 #include <svtools/xtextedt.hxx>
44 class SwSrcEditWindow
;
47 class DataChangedEvent
;
49 class TextViewOutWin
: public Window
51 ExtTextView
* pTextView
;
54 virtual void Paint( const Rectangle
& );
55 virtual void KeyInput( const KeyEvent
& rKeyEvt
);
56 virtual void MouseMove( const MouseEvent
& rMEvt
);
57 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
58 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
59 virtual void Command( const CommandEvent
& rCEvt
);
60 virtual void DataChanged( const DataChangedEvent
& );
63 TextViewOutWin(Window
* pParent
, WinBits nBits
) :
64 Window(pParent
, nBits
), pTextView(0){}
66 void SetTextView( ExtTextView
* pView
) {pTextView
= pView
;}
70 //------------------------------------------------------------
71 namespace svt
{ class SourceViewConfig
;}
72 class SwSrcEditWindow
: public Window
, public SfxListener
75 ExtTextView
* pTextView
;
76 ExtTextEngine
* pTextEngine
;
78 TextViewOutWin
* pOutWin
;
79 ScrollBar
*pHScrollbar
,
83 svt::SourceViewConfig
* pSourceViewConfig
;
87 rtl_TextEncoding eSourceEncoding
;
89 BOOL bDoSyntaxHighlight
;
92 Timer aSyntaxIdleTimer
;
93 Table aSyntaxLineTable
;
95 void ImpDoHighlight( const String
& rSource
, USHORT nLineOff
);
97 using OutputDevice::SetFont
;
100 DECL_LINK( SyntaxTimerHdl
, Timer
* );
101 DECL_LINK( TimeoutHdl
, Timer
* );
103 using Window::Notify
;
104 using Window::Invalidate
;
108 virtual void Resize();
109 virtual void DataChanged( const DataChangedEvent
& );
110 virtual void GetFocus();
111 // virtual void LoseFocus();
113 void CreateTextEngine();
114 void DoSyntaxHighlight( USHORT nPara
);
116 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
118 DECL_LINK(ScrollHdl
, ScrollBar
*);
121 SwSrcEditWindow( Window
* pParent
, SwSrcView
* pParentView
);
124 void SetScrollBarRanges();
125 void InitScrollBars();
126 ULONG
Read( SvStream
& rInput
)
127 {return pTextEngine
->Read(rInput
);}
128 ULONG
Write( SvStream
& rOutput
)
129 {return pTextEngine
->Write(rOutput
);}
131 ExtTextView
* GetTextView()
133 TextEngine
* GetTextEngine()
134 {return pTextEngine
;}
135 SwSrcView
* GetSrcView() {return pSrcView
;}
137 TextViewOutWin
* GetOutWin() {return pOutWin
;}
139 virtual void Invalidate( USHORT nFlags
= 0 );
141 void ClearModifyFlag()
142 { pTextEngine
->SetModified(FALSE
); }
143 BOOL
IsModified() const
144 { return pTextEngine
->IsModified();}
145 void CreateScrollbars();
147 void SetReadonly(BOOL bSet
){bReadonly
= bSet
;}
148 BOOL
IsReadonly(){return bReadonly
;}
150 void DoDelayedSyntaxHighlight( USHORT nPara
);
152 void SetStartLine(USHORT nLine
){nStartLine
= nLine
;}
154 virtual void Command( const CommandEvent
& rCEvt
);
155 void HandleWheelCommand( const CommandEvent
& rCEvt
);
157 void SetTextEncoding(rtl_TextEncoding eEncoding
);