1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2013, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef SOURCE_VIEW_H 7 #define SOURCE_VIEW_H 8 9 10 #include <Font.h> 11 #include <View.h> 12 13 #include "Types.h" 14 15 16 class Breakpoint; 17 class FunctionInstance; 18 class SourceCode; 19 class StackFrame; 20 class StackTrace; 21 class Statement; 22 class SyntaxHighlightInfo; 23 class Team; 24 class Thread; 25 class UserBreakpoint; 26 27 28 class SourceView : public BView { 29 public: 30 class Listener; 31 32 public: 33 SourceView(Team* team, Listener* listener); 34 ~SourceView(); 35 36 static SourceView* Create(Team* team, Listener* listener); 37 // throws 38 39 virtual void MessageReceived(BMessage* message); 40 41 void UnsetListener(); 42 43 void SetStackTrace(StackTrace* stackTrace, 44 Thread* thread); 45 void SetStackFrame(StackFrame* stackFrame); 46 void SetSourceCode(SourceCode* sourceCode); 47 48 void UserBreakpointChanged( 49 UserBreakpoint* breakpoint); 50 51 bool ScrollToAddress(target_addr_t address); 52 bool ScrollToLine(uint32 line); 53 54 void HighlightBorder(bool state); 55 virtual void TargetedByScrollView(BScrollView* scrollView); 56 57 virtual BSize MinSize(); 58 virtual BSize MaxSize(); 59 virtual BSize PreferredSize(); 60 61 virtual void DoLayout(); 62 63 private: 64 class BaseView; 65 class MarkerManager; 66 class MarkerView; 67 class TextView; 68 69 // for gcc2 70 friend class TextView; 71 friend class MarkerView; 72 73 struct FontInfo { 74 BFont font; 75 font_height fontHeight; 76 float lineHeight; 77 }; 78 79 protected: 80 bool GetStatementForLine(int32 line, 81 Statement*& _statement); 82 83 private: 84 void _Init(); 85 void _UpdateScrollBars(); 86 BSize _DataRectSize() const; 87 88 private: 89 Team* fTeam; 90 Thread* fActiveThread; 91 StackTrace* fStackTrace; 92 StackFrame* fStackFrame; 93 SourceCode* fSourceCode; 94 MarkerManager* fMarkerManager; 95 MarkerView* fMarkerView; 96 TextView* fTextView; 97 FontInfo fFontInfo; 98 Listener* fListener; 99 SyntaxHighlightInfo* fCurrentSyntaxInfo; 100 }; 101 102 103 class SourceView::Listener { 104 public: 105 virtual ~Listener(); 106 107 virtual void SetBreakpointRequested( 108 target_addr_t address, bool enabled) = 0; 109 virtual void ClearBreakpointRequested( 110 target_addr_t address) = 0; 111 virtual void ThreadActionRequested(Thread* thread, 112 uint32 action, target_addr_t address) = 0; 113 virtual void FunctionSourceCodeRequested( 114 FunctionInstance* function, 115 bool forceDisassembly) = 0; 116 }; 117 118 119 #endif // SOURCE_VIEW_H 120