xref: /trunk/main/sw/source/ui/inc/srcedtw.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _SRCEDTW_HXX
24cdf0e10cSrcweir #define _SRCEDTW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <vcl/window.hxx>
27cdf0e10cSrcweir #include <svl/lstner.hxx>
28cdf0e10cSrcweir #include <unotools/options.hxx>
29cdf0e10cSrcweir #include <vcl/timer.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _TABLE_HXX //autogen
32cdf0e10cSrcweir #include <tools/table.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <svtools/xtextedt.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class ScrollBar;
37cdf0e10cSrcweir class SwSrcView;
38cdf0e10cSrcweir class SwSrcEditWindow;
39cdf0e10cSrcweir class TextEngine;
40cdf0e10cSrcweir class ExtTextView;
41cdf0e10cSrcweir class DataChangedEvent;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir namespace utl
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     class SourceViewConfig;
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
48cdf0e10cSrcweir class TextViewOutWin : public Window
49cdf0e10cSrcweir {
50cdf0e10cSrcweir     ExtTextView*    pTextView;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir protected:
53cdf0e10cSrcweir     virtual void    Paint( const Rectangle& );
54cdf0e10cSrcweir     virtual void    KeyInput( const KeyEvent& rKeyEvt );
55cdf0e10cSrcweir     virtual void    MouseMove( const MouseEvent& rMEvt );
56cdf0e10cSrcweir     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
57cdf0e10cSrcweir     virtual void    MouseButtonUp( const MouseEvent& rMEvt );
58cdf0e10cSrcweir     virtual void    Command( const CommandEvent& rCEvt );
59cdf0e10cSrcweir     virtual void    DataChanged( const DataChangedEvent& );
60cdf0e10cSrcweir 
61cdf0e10cSrcweir public:
TextViewOutWin(Window * pParent,WinBits nBits)62cdf0e10cSrcweir         TextViewOutWin(Window* pParent, WinBits nBits) :
63cdf0e10cSrcweir             Window(pParent, nBits), pTextView(0){}
64cdf0e10cSrcweir 
SetTextView(ExtTextView * pView)65cdf0e10cSrcweir     void    SetTextView( ExtTextView* pView ) {pTextView = pView;}
66cdf0e10cSrcweir 
67cdf0e10cSrcweir };
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //------------------------------------------------------------
70cdf0e10cSrcweir namespace svt{ class SourceViewConfig;}
71cdf0e10cSrcweir class SwSrcEditWindow : public Window, public SfxListener, public utl::ConfigurationListener
72cdf0e10cSrcweir {
73cdf0e10cSrcweir private:
74cdf0e10cSrcweir     ExtTextView*    pTextView;
75cdf0e10cSrcweir     ExtTextEngine*  pTextEngine;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     TextViewOutWin* pOutWin;
78cdf0e10cSrcweir     ScrollBar       *pHScrollbar,
79cdf0e10cSrcweir                     *pVScrollbar;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     SwSrcView*      pSrcView;
82cdf0e10cSrcweir     utl::SourceViewConfig* pSourceViewConfig;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     long            nCurTextWidth;
85*c2eaa082SDamjan Jovanovic     sal_uInt32          nStartLine;
86cdf0e10cSrcweir     rtl_TextEncoding eSourceEncoding;
87cdf0e10cSrcweir     sal_Bool            bReadonly;
88cdf0e10cSrcweir     sal_Bool            bDoSyntaxHighlight;
89cdf0e10cSrcweir     sal_Bool            bHighlighting;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     Timer           aSyntaxIdleTimer;
92cdf0e10cSrcweir     Table           aSyntaxLineTable;
93cdf0e10cSrcweir 
94*c2eaa082SDamjan Jovanovic     void            ImpDoHighlight( const String& rSource, sal_uInt32 nLineOff );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     using OutputDevice::SetFont;
97cdf0e10cSrcweir     void            SetFont();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     DECL_LINK( SyntaxTimerHdl, Timer * );
100cdf0e10cSrcweir     DECL_LINK( TimeoutHdl, Timer * );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     using Window::Notify;
103cdf0e10cSrcweir     using Window::Invalidate;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir protected:
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     virtual void    Resize();
108cdf0e10cSrcweir     virtual void    DataChanged( const DataChangedEvent& );
109cdf0e10cSrcweir     virtual void    GetFocus();
110cdf0e10cSrcweir //  virtual void    LoseFocus();
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     void            CreateTextEngine();
113*c2eaa082SDamjan Jovanovic     void            DoSyntaxHighlight( sal_uInt32 nPara );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     virtual void    Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
116cdf0e10cSrcweir     virtual void    ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     DECL_LINK(ScrollHdl, ScrollBar*);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir public:
121cdf0e10cSrcweir                     SwSrcEditWindow( Window* pParent, SwSrcView* pParentView );
122cdf0e10cSrcweir                     ~SwSrcEditWindow();
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     void            SetScrollBarRanges();
125cdf0e10cSrcweir     void            InitScrollBars();
Read(SvStream & rInput)126cdf0e10cSrcweir     sal_uLong           Read( SvStream& rInput)
127cdf0e10cSrcweir                         {return pTextEngine->Read(rInput);}
Write(SvStream & rOutput)128cdf0e10cSrcweir     sal_uLong           Write( SvStream& rOutput)
129cdf0e10cSrcweir                         {return pTextEngine->Write(rOutput);}
130cdf0e10cSrcweir 
GetTextView()131cdf0e10cSrcweir     ExtTextView*    GetTextView()
132cdf0e10cSrcweir                         {return pTextView;}
GetTextEngine()133cdf0e10cSrcweir     TextEngine*     GetTextEngine()
134cdf0e10cSrcweir                         {return pTextEngine;}
GetSrcView()135cdf0e10cSrcweir     SwSrcView*      GetSrcView() {return pSrcView;}
136cdf0e10cSrcweir 
GetOutWin()137cdf0e10cSrcweir     TextViewOutWin* GetOutWin() {return pOutWin;}
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     virtual void    Invalidate( sal_uInt16 nFlags = 0 );
140cdf0e10cSrcweir 
ClearModifyFlag()141cdf0e10cSrcweir     void            ClearModifyFlag()
142cdf0e10cSrcweir                         { pTextEngine->SetModified(sal_False); }
IsModified() const143cdf0e10cSrcweir     sal_Bool            IsModified() const
144cdf0e10cSrcweir                         { return pTextEngine->IsModified();}
145cdf0e10cSrcweir     void            CreateScrollbars();
146cdf0e10cSrcweir 
SetReadonly(sal_Bool bSet)147cdf0e10cSrcweir     void            SetReadonly(sal_Bool bSet){bReadonly = bSet;}
IsReadonly()148cdf0e10cSrcweir     sal_Bool            IsReadonly(){return bReadonly;}
149cdf0e10cSrcweir 
150*c2eaa082SDamjan Jovanovic     void            DoDelayedSyntaxHighlight( sal_uInt32 nPara );
151cdf0e10cSrcweir 
SetStartLine(sal_uInt32 nLine)152*c2eaa082SDamjan Jovanovic     void            SetStartLine(sal_uInt32 nLine){nStartLine = nLine;}
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     virtual void    Command( const CommandEvent& rCEvt );
155cdf0e10cSrcweir     void            HandleWheelCommand( const CommandEvent& rCEvt );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     void            SetTextEncoding(rtl_TextEncoding eEncoding);
158cdf0e10cSrcweir };
159cdf0e10cSrcweir 
160cdf0e10cSrcweir #endif
161