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: baside2.hxx,v $
10 * $Revision: 1.26.22.1 $
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 ************************************************************************/
34 #include <svheader.hxx>
36 #include <bastypes.hxx>
37 #include <bastype3.hxx>
38 #include <basidesh.hxx>
43 #include <svtools/svtabbx.hxx>
44 #include <svtools/headbar.hxx>
46 #ifndef _SV_BUTTON_HXX //autogen
47 #include <vcl/button.hxx>
49 #include <basic/sbmod.hxx>
50 #include <vcl/split.hxx>
51 #include "svtools/lstner.hxx"
52 #include <svtools/colorcfg.hxx>
54 #include <sfx2/progress.hxx>
55 #include <svtools/syntaxhighlight.hxx>
57 DBG_NAMEEX( ModulWindow
)
59 #define MARKER_NOMARKER 0xFFFF
62 // #108672 Helper functions to get/set text in TextEngine
63 // using the stream interface (get/setText() only supports
64 // tools Strings limited to 64K).
65 ::rtl::OUString
getTextEngineText( ExtTextEngine
* pEngine
);
66 void setTextEngineText( ExtTextEngine
* pEngine
, const ::rtl::OUString aStr
);
68 class ProgressInfo
: public SfxProgress
75 inline ProgressInfo( SfxObjectShell
* pObjSh
, const String
& rText
, ULONG nRange
);
77 // inline void StartProgress( const String& rName, ULONG nStates );
78 // inline void EndProgress();
79 inline void StepProgress();
82 inline ProgressInfo::ProgressInfo( SfxObjectShell
* pObjSh
, const String
& rText
, ULONG nRange
)
83 : SfxProgress( pObjSh
, rText
, nRange
)
88 // inline void ProgressInfo::StartProgress( const String& rName, ULONG nStates )
92 // pStbMgr->StartProgressMode( rName, nStates );
95 // inline void ProgressInfo::EndProgress()
98 // pStbMgr->EndProgressMode();
101 inline void ProgressInfo::StepProgress()
103 SetState( ++nCurState
);
108 class SourceViewConfig
;
111 class EditorWindow
: public Window
, public SfxListener
114 ExtTextView
* pEditView
;
115 ExtTextEngine
* pEditEngine
;
117 svt::SourceViewConfig
* pSourceViewConfig
;
121 SyntaxHighlighter aHighlighter
;
122 Timer aSyntaxIdleTimer
;
123 Table aSyntaxLineTable
;
124 DECL_LINK( SyntaxTimerHdl
, Timer
* );
125 ProgressInfo
* pProgress
;
126 ModulWindow
* pModulWindow
;
128 virtual void DataChanged(DataChangedEvent
const & rDCEvt
);
130 using Window::Notify
;
131 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
133 void ImpDoHighlight( ULONG nLineOff
);
137 BOOL bDoSyntaxHighlight
;
138 BOOL bDelayHighlight
;
141 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>
142 GetComponentInterface(BOOL bCreate
= TRUE
);
145 virtual void Paint( const Rectangle
& );
146 virtual void Resize();
147 virtual void KeyInput( const KeyEvent
& rKeyEvt
);
148 virtual void MouseMove( const MouseEvent
& rMEvt
);
149 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
150 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
151 virtual void Command( const CommandEvent
& rCEvt
);
152 virtual void LoseFocus();
153 virtual void RequestHelp( const HelpEvent
& rHEvt
);
155 void DoSyntaxHighlight( ULONG nPara
);
156 String
GetWordAtCursor();
160 EditorWindow( Window
* pParent
);
163 ExtTextEngine
* GetEditEngine() const { return (ExtTextEngine
*)pEditEngine
; }
164 ExtTextView
* GetEditView() const { return pEditView
; }
165 ProgressInfo
* GetProgress() const { return pProgress
; }
167 void CreateProgress( const String
& rText
, ULONG nRange
);
168 void DestroyProgress();
170 void ParagraphInsertedDeleted( ULONG nNewPara
, BOOL bInserted
);
171 void DoDelayedSyntaxHighlight( ULONG nPara
);
173 void CreateEditEngine();
174 void SetScrollBarRanges();
175 void InitScrollBars();
176 void SetModulWindow( ModulWindow
* pWin
)
177 { pModulWindow
= pWin
; }
179 void ForceSyntaxTimeout();
180 BOOL
SetSourceInBasic( BOOL bQuiet
= TRUE
);
182 BOOL
CanModify() { return ImpCanModify(); }
186 class BreakPointWindow
: public Window
191 BreakPointList aBreakPointList
;
192 ModulWindow
* pModulWindow
;
194 bool m_bHighContrastMode
;
196 virtual void DataChanged(DataChangedEvent
const & rDCEvt
);
198 void setBackgroundColor(Color aColor
);
201 virtual void Paint( const Rectangle
& );
202 virtual void Resize();
203 BreakPoint
* FindBreakPoint( const Point
& rMousePos
);
204 void ShowMarker( BOOL bShow
);
205 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
206 virtual void Command( const CommandEvent
& rCEvt
);
211 BreakPointWindow( Window
* pParent
);
214 void SetModulWindow( ModulWindow
* pWin
)
215 { pModulWindow
= pWin
; }
217 void SetMarkerPos( USHORT nLine
, BOOL bErrorMarker
= FALSE
);
219 void DoScroll( long nHorzScroll
, long nVertScroll
);
220 long& GetCurYOffset() { return nCurYOffset
; }
221 BreakPointList
& GetBreakPoints() { return aBreakPointList
; }
225 class WatchTreeListBox
: public SvHeaderTabListBox
230 virtual BOOL
EditingEntry( SvLBoxEntry
* pEntry
, Selection
& rSel
);
231 virtual BOOL
EditedEntry( SvLBoxEntry
* pEntry
, const String
& rNewText
);
233 BOOL
ImplBasicEntryEdited( SvLBoxEntry
* pEntry
, const String
& rResult
);
234 SbxBase
* ImplGetSBXForEntry( SvLBoxEntry
* pEntry
, bool& rbArrayElement
);
236 // virtual DragDropMode NotifyBeginDrag( SvLBoxEntry* );
237 // virtual BOOL NotifyQueryDrop( SvLBoxEntry* );
239 // virtual BOOL NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
240 // SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos );
241 // virtual BOOL NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
242 // SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos );
243 // BOOL NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
244 // SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos, BOOL bMove );
247 WatchTreeListBox( Window
* pParent
, WinBits nWinBits
);
250 void RequestingChilds( SvLBoxEntry
* pParent
);
251 void UpdateWatches( bool bBasicStopped
= false );
253 using SvTabListBox::SetTabs
;
254 virtual void SetTabs();
259 class WatchWindow
: public BasicDockingWindow
264 ImageButton aRemoveWatchButton
;
265 WatchTreeListBox aTreeListBox
;
266 HeaderBar aHeaderBar
;
269 virtual void Resize();
270 virtual void Paint( const Rectangle
& rRect
);
272 DECL_LINK( ButtonHdl
, ImageButton
* );
273 DECL_LINK( TreeListHdl
, SvTreeListBox
* );
274 DECL_LINK( implEndDragHdl
, HeaderBar
* );
275 DECL_LINK( EditAccHdl
, Accelerator
* );
279 WatchWindow( Window
* pParent
);
282 void AddWatch( const String
& rVName
);
283 BOOL
RemoveSelectedWatch();
284 void UpdateWatches( bool bBasicStopped
= false );
286 WatchTreeListBox
& GetWatchTreeListBox() { return aTreeListBox
; }
290 class StackWindow
: public BasicDockingWindow
293 SvTreeListBox aTreeListBox
;
294 ImageButton aGotoCallButton
;
298 virtual void Resize();
299 virtual void Paint( const Rectangle
& rRect
);
300 DECL_LINK( ButtonHdl
, ImageButton
* );
303 StackWindow( Window
* pParent
);
310 class ComplexEditorWindow
: public Window
313 BreakPointWindow aBrkWindow
;
314 EditorWindow aEdtWindow
;
315 ScrollBar aEWVScrollBar
;
317 virtual void DataChanged(DataChangedEvent
const & rDCEvt
);
320 virtual void Resize();
321 DECL_LINK( ScrollHdl
, ScrollBar
* );
324 ComplexEditorWindow( ModulWindow
* pParent
);
326 BreakPointWindow
& GetBrkWindow() { return aBrkWindow
; }
327 EditorWindow
& GetEdtWindow() { return aEdtWindow
; }
328 ScrollBar
& GetEWVScrollBar() { return aEWVScrollBar
; }
332 #define SYNTAX_COLOR_MAX 5
334 class ModulWindow
: public IDEBaseWindow
336 friend class BasicIDEShell
;
341 ComplexEditorWindow aXEditorWindow
;
344 ModulWindowLayout
* pLayout
;
346 ::rtl::OUString m_aModule
;
348 DECL_LINK( BasicErrorHdl
, StarBASIC
* );
349 long BasicBreakHdl( StarBASIC
* pBasic
);
351 void CheckCompileBasic();
355 void AssertValidEditEngine();
358 virtual void Resize();
359 virtual void GetFocus();
360 virtual void Paint( const Rectangle
& );
361 virtual void Deactivating();
362 virtual void DoInit();
363 virtual void DoScroll( ScrollBar
* pCurScrollBar
);
368 ModulWindow( ModulWindowLayout
* pParent
, const ScriptDocument
& rDocument
, String aLibName
,
369 String aName
, ::rtl::OUString
& aModule
);
373 virtual void ExecuteCommand( SfxRequest
& rReq
);
374 virtual void GetState( SfxItemSet
& );
375 virtual void StoreData();
376 virtual void UpdateData();
377 virtual BOOL
CanClose();
378 virtual void PrintData( Printer
* pPrinter
);
379 virtual String
GetTitle();
380 virtual BasicEntryDescriptor
CreateEntryDescriptor();
381 virtual BOOL
AllowUndo();
382 virtual void SetReadOnly( BOOL bReadOnly
);
383 virtual BOOL
IsReadOnly();
385 StarBASIC
* GetBasic() { return xBasic
; }
387 SbModule
* GetSbModule() { return xModule
; }
388 void SetSbModule( SbModule
* pModule
) { xModule
= pModule
; }
389 String
GetSbModuleName();
393 BOOL
BasicStepOver();
394 BOOL
BasicStepInto();
397 BOOL
BasicToggleBreakPoint();
398 void BasicToggleBreakPointEnabled();
399 void ManageBreakPoints();
400 void UpdateBreakPoint( const BreakPoint
& rBrk
);
401 void BasicAddWatch();
402 void BasicRemoveWatch();
405 BOOL
SaveBasicSource();
408 void EditMacro( const String
& rMacroName
);
410 // void InsertFromObjectCatalog( ObjectCatalog* pObjDlg );
412 BOOL
ToggleBreakPoint( ULONG nLine
);
413 BOOL
RenameModule( const String
& rNewName
);
415 BasicStatus
& GetBasicStatus() { return aStatus
; }
417 virtual BOOL
IsModified();
418 virtual BOOL
IsPasteAllowed();
420 void FrameWindowMoved();
421 void ShowCursor( BOOL bOn
);
423 virtual USHORT
GetSearchOptions();
424 USHORT
StartSearchAndReplace( const SvxSearchItem
& rSearchItem
, BOOL bFromStart
= FALSE
);
426 virtual Window
* GetLayoutWindow();
428 EditorWindow
& GetEditorWindow() { return aXEditorWindow
.GetEdtWindow(); }
429 BreakPointWindow
& GetBreakPointWindow() { return aXEditorWindow
.GetBrkWindow(); }
430 ScrollBar
& GetEditVScrollBar() { return aXEditorWindow
.GetEWVScrollBar(); }
431 ExtTextEngine
* GetEditEngine() { return GetEditorWindow().GetEditEngine(); }
432 ExtTextView
* GetEditView() { return GetEditorWindow().GetEditView(); }
433 BreakPointList
& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); }
434 ModulWindowLayout
* GetLayout() const { return pLayout
; }
436 virtual void BasicStarted();
437 virtual void BasicStopped();
439 virtual SfxUndoManager
* GetUndoManager();
441 const ::rtl::OUString
& GetModule() const { return m_aModule
; }
442 void SetModule( const ::rtl::OUString
& aModule
) { m_aModule
= aModule
; }
445 class ModulWindowLayout
: public Window
, public SfxListener
452 WatchWindow aWatchWindow
;
453 StackWindow aStackWindow
;
458 ModulWindow
* m_pModulWindow
;
460 Color m_aSyntaxColors
[TT_KEYWORDS
+ 1];
461 svtools::ColorConfig m_aColorConfig
;
463 ImageList m_aImagesNormal
;
464 ImageList m_aImagesHighContrast
;
466 virtual void DataChanged(DataChangedEvent
const & rDCEvt
);
468 using Window::Notify
;
469 virtual void Notify(SfxBroadcaster
& rBc
, SfxHint
const & rHint
);
471 void updateSyntaxHighlighting();
473 DECL_LINK( SplitHdl
, Splitter
* );
475 void ArrangeWindows();
478 virtual void Resize();
479 virtual void Paint( const Rectangle
& rRect
);
482 ModulWindowLayout( Window
* pParent
);
483 ~ModulWindowLayout();
485 void DockaWindow( DockingWindow
* pDockingWin
);
486 BOOL
IsToBeDocked( DockingWindow
* pDockingWin
, const Point
& rPos
, Rectangle
& rRect
);
488 void SetModulWindow( ModulWindow
* pModWin
);
489 ModulWindow
* GetModulWindow() const { return m_pModulWindow
; }
491 WatchWindow
& GetWatchWindow() { return aWatchWindow
; }
492 StackWindow
& GetStackWindow() { return aStackWindow
; }
494 Image
getImage(USHORT nId
, bool bHighContrastMode
) const;
496 inline Color
const & getSyntaxColor(TokenTypes eType
) const
497 { return m_aSyntaxColors
[eType
]; }
500 #endif // _BASIDE2_HXX