update dev300-m58
[ooovba.git] / sw / source / ui / inc / srcedtw.hxx
blob25adc176fa4b0cba5964a96c8ca1da4c0e30b822
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: srcedtw.hxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
30 #ifndef _SRCEDTW_HXX
31 #define _SRCEDTW_HXX
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>
39 #endif
40 #include <svtools/xtextedt.hxx>
42 class ScrollBar;
43 class SwSrcView;
44 class SwSrcEditWindow;
45 class TextEngine;
46 class ExtTextView;
47 class DataChangedEvent;
49 class TextViewOutWin : public Window
51 ExtTextView* pTextView;
53 protected:
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& );
62 public:
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
74 private:
75 ExtTextView* pTextView;
76 ExtTextEngine* pTextEngine;
78 TextViewOutWin* pOutWin;
79 ScrollBar *pHScrollbar,
80 *pVScrollbar;
82 SwSrcView* pSrcView;
83 svt::SourceViewConfig* pSourceViewConfig;
85 long nCurTextWidth;
86 USHORT nStartLine;
87 rtl_TextEncoding eSourceEncoding;
88 BOOL bReadonly;
89 BOOL bDoSyntaxHighlight;
90 BOOL bHighlighting;
92 Timer aSyntaxIdleTimer;
93 Table aSyntaxLineTable;
95 void ImpDoHighlight( const String& rSource, USHORT nLineOff );
97 using OutputDevice::SetFont;
98 void SetFont();
100 DECL_LINK( SyntaxTimerHdl, Timer * );
101 DECL_LINK( TimeoutHdl, Timer * );
103 using Window::Notify;
104 using Window::Invalidate;
106 protected:
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*);
120 public:
121 SwSrcEditWindow( Window* pParent, SwSrcView* pParentView );
122 ~SwSrcEditWindow();
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()
132 {return pTextView;}
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);
160 #endif