xref: /aoo41x/main/sw/source/ui/inc/srcedtw.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _SRCEDTW_HXX
28*cdf0e10cSrcweir #define _SRCEDTW_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <vcl/window.hxx>
31*cdf0e10cSrcweir #include <svl/lstner.hxx>
32*cdf0e10cSrcweir #include <unotools/options.hxx>
33*cdf0e10cSrcweir #include <vcl/timer.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _TABLE_HXX //autogen
36*cdf0e10cSrcweir #include <tools/table.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #include <svtools/xtextedt.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir class ScrollBar;
41*cdf0e10cSrcweir class SwSrcView;
42*cdf0e10cSrcweir class SwSrcEditWindow;
43*cdf0e10cSrcweir class TextEngine;
44*cdf0e10cSrcweir class ExtTextView;
45*cdf0e10cSrcweir class DataChangedEvent;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace utl
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir     class SourceViewConfig;
50*cdf0e10cSrcweir }
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class TextViewOutWin : public Window
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 	ExtTextView*	pTextView;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir protected:
57*cdf0e10cSrcweir 	virtual void	Paint( const Rectangle& );
58*cdf0e10cSrcweir 	virtual void	KeyInput( const KeyEvent& rKeyEvt );
59*cdf0e10cSrcweir 	virtual void	MouseMove( const MouseEvent& rMEvt );
60*cdf0e10cSrcweir 	virtual void	MouseButtonDown( const MouseEvent& rMEvt );
61*cdf0e10cSrcweir 	virtual void	MouseButtonUp( const MouseEvent& rMEvt );
62*cdf0e10cSrcweir 	virtual void	Command( const CommandEvent& rCEvt );
63*cdf0e10cSrcweir 	virtual void	DataChanged( const DataChangedEvent& );
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir public:
66*cdf0e10cSrcweir 		TextViewOutWin(Window* pParent, WinBits nBits) :
67*cdf0e10cSrcweir 			Window(pParent, nBits), pTextView(0){}
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 	void	SetTextView( ExtTextView* pView ) {pTextView = pView;}
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir };
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir //------------------------------------------------------------
74*cdf0e10cSrcweir namespace svt{ class SourceViewConfig;}
75*cdf0e10cSrcweir class SwSrcEditWindow : public Window, public SfxListener, public utl::ConfigurationListener
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir private:
78*cdf0e10cSrcweir 	ExtTextView*	pTextView;
79*cdf0e10cSrcweir 	ExtTextEngine*	pTextEngine;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	TextViewOutWin*	pOutWin;
82*cdf0e10cSrcweir 	ScrollBar	   	*pHScrollbar,
83*cdf0e10cSrcweir 					*pVScrollbar;
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	SwSrcView* 		pSrcView;
86*cdf0e10cSrcweir     utl::SourceViewConfig* pSourceViewConfig;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	long			nCurTextWidth;
89*cdf0e10cSrcweir 	sal_uInt16			nStartLine;
90*cdf0e10cSrcweir     rtl_TextEncoding eSourceEncoding;
91*cdf0e10cSrcweir 	sal_Bool			bReadonly;
92*cdf0e10cSrcweir 	sal_Bool			bDoSyntaxHighlight;
93*cdf0e10cSrcweir 	sal_Bool			bHighlighting;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	Timer			aSyntaxIdleTimer;
96*cdf0e10cSrcweir 	Table			aSyntaxLineTable;
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	void			ImpDoHighlight( const String& rSource, sal_uInt16 nLineOff );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	using OutputDevice::SetFont;
101*cdf0e10cSrcweir     void            SetFont();
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	DECL_LINK( SyntaxTimerHdl, Timer * );
104*cdf0e10cSrcweir 	DECL_LINK( TimeoutHdl, Timer * );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     using Window::Notify;
107*cdf0e10cSrcweir     using Window::Invalidate;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir protected:
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	virtual void	Resize();
112*cdf0e10cSrcweir 	virtual void	DataChanged( const DataChangedEvent& );
113*cdf0e10cSrcweir 	virtual void 	GetFocus();
114*cdf0e10cSrcweir //	virtual void 	LoseFocus();
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	void 			CreateTextEngine();
117*cdf0e10cSrcweir 	void			DoSyntaxHighlight( sal_uInt16 nPara );
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	virtual void	Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
120*cdf0e10cSrcweir     virtual void    ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	DECL_LINK(ScrollHdl, ScrollBar*);
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir public:
125*cdf0e10cSrcweir 					SwSrcEditWindow( Window* pParent, SwSrcView* pParentView );
126*cdf0e10cSrcweir 					~SwSrcEditWindow();
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	void			SetScrollBarRanges();
129*cdf0e10cSrcweir 	void			InitScrollBars();
130*cdf0e10cSrcweir 	sal_uLong			Read( SvStream& rInput)
131*cdf0e10cSrcweir 						{return pTextEngine->Read(rInput);}
132*cdf0e10cSrcweir 	sal_uLong			Write( SvStream& rOutput)
133*cdf0e10cSrcweir 						{return pTextEngine->Write(rOutput);}
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	ExtTextView*	GetTextView()
136*cdf0e10cSrcweir 						{return pTextView;}
137*cdf0e10cSrcweir 	TextEngine*		GetTextEngine()
138*cdf0e10cSrcweir 						{return pTextEngine;}
139*cdf0e10cSrcweir 	SwSrcView* 		GetSrcView() {return pSrcView;}
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	TextViewOutWin*	GetOutWin() {return pOutWin;}
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	virtual void    Invalidate( sal_uInt16 nFlags = 0 );
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 	void			ClearModifyFlag()
146*cdf0e10cSrcweir 						{ pTextEngine->SetModified(sal_False); }
147*cdf0e10cSrcweir 	sal_Bool			IsModified() const
148*cdf0e10cSrcweir 						{ return pTextEngine->IsModified();}
149*cdf0e10cSrcweir 	void			CreateScrollbars();
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	void			SetReadonly(sal_Bool bSet){bReadonly = bSet;}
152*cdf0e10cSrcweir 	sal_Bool			IsReadonly(){return bReadonly;}
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	void			DoDelayedSyntaxHighlight( sal_uInt16 nPara );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 	void			SetStartLine(sal_uInt16 nLine){nStartLine = nLine;}
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	virtual void	Command( const CommandEvent& rCEvt );
159*cdf0e10cSrcweir 	void 			HandleWheelCommand( const CommandEvent& rCEvt );
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     void            SetTextEncoding(rtl_TextEncoding eEncoding);
162*cdf0e10cSrcweir };
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir #endif
165