diff --git a/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp b/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp index 24a515044c..9fb5c0f0b9 100644 --- a/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2009, Rene Gollent, rene@gollent.com. + * Copyright 2009-2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,13 @@ static const int32 kSpacesPerTab = 4; // TODO: Should be settable! static const bigtime_t kScrollTimer = 10000LL; +static const char* kClearBreakpointMessage = "Click to clear breakpoint at " + "line %" B_PRId32 "."; +static const char* kDisableBreakpointMessage = "Click to disable breakpoint at " + "line %" B_PRId32 "."; +static const char* kEnableBreakpointMessage = "Click to enable breakpoint at " + "line %" B_PRId32 "."; + class SourceView::BaseView : public BView { public: @@ -157,6 +165,8 @@ public: virtual void MouseDown(BPoint where); +protected: + virtual bool GetToolTipAt(BPoint point, BToolTip** _tip); private: Team* fTeam; @@ -944,6 +954,59 @@ SourceView::MarkerView::MouseDown(BPoint where) } +bool +SourceView::MarkerView::GetToolTipAt(BPoint point, BToolTip** _tip) +{ + if (fSourceCode == NULL) + return false; + + int32 line = LineAtOffset(point.y); + if (line < 0) + return false; + + AutoLocker locker(fTeam); + Statement* statement; + if (fTeam->GetStatementAtSourceLocation(fSourceCode, + SourceLocation(line), statement) != B_OK) { + return false; + } + BReference statementReference(statement, true); + if (statement->StartSourceLocation().Line() != line) + return false; + + SourceView::MarkerManager::BreakpointMarker* marker = + fMarkerManager->BreakpointMarkerAtLine(line); + + BString text; + if (marker == NULL) { + text.SetToFormat(kEnableBreakpointMessage, line); + } else if ((modifiers() & B_SHIFT_KEY) != 0) { + if (!marker->IsEnabled()) { + text.SetToFormat(kClearBreakpointMessage, line); + } else { + text.SetToFormat(kDisableBreakpointMessage, line); + } + } else { + if (marker->IsEnabled()) { + text.SetToFormat(kClearBreakpointMessage, line); + } else { + text.SetToFormat(kEnableBreakpointMessage, line); + } + } + + if (text.Length() > 0) { + BTextToolTip* tip = new(std::nothrow) BTextToolTip(text); + if (tip == NULL) + return false; + + *_tip = tip; + return true; + } + + return false; +} + + // #pragma mark - TextView