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