| 1 |
#include "DAPTooltip.hpp" |
| 2 |
|
| 3 |
#include "DAPVariableListCtrl.hpp" |
| 4 |
#include "clResizableTooltip.h" // wxEVT_TOOLTIP_DESTROY |
| 5 |
#include "clSystemSettings.h" |
| 6 |
#include "drawingutils.h" |
| 7 |
#include "event_notifier.h" |
| 8 |
#include "globals.h" |
| 9 |
#include "macros.h" |
| 10 |
|
| 11 |
#include <wx/dcclient.h> |
| 12 |
#include <wx/sizer.h> |
| 13 |
|
| 14 |
DAPTooltip::DAPTooltip(dap::Client* client, const wxString& expression, const wxString& result, const wxString& type, |
| 15 |
int variableReference) |
| 16 |
: wxPopupWindow(EventNotifier::Get()->TopFrame()) |
| 17 |
, m_client(client) |
| 18 |
{ |
| 19 |
// set a reasonable size for the tooltip |
| 20 |
wxClientDC dc(this); |
| 21 |
dc.SetFont(DrawingUtils::GetDefaultGuiFont()); |
| 22 |
wxSize sz = dc.GetTextExtent("Tp"); |
| 23 |
sz.SetWidth(sz.GetWidth() * 80); // 50 chars width |
| 24 |
sz.SetHeight(sz.GetHeight() * 20); // 10 lines |
| 25 |
|
| 26 |
SetSizer(new wxBoxSizer(wxVERTICAL)); |
| 27 |
m_list = new DAPVariableListCtrl(this, client, dap::EvaluateContext::HOVER, wxID_ANY, wxDefaultPosition, sz); |
| 28 |
GetSizer()->Add(m_list, 1, wxEXPAND); |
| 29 |
m_list->AddWatch(expression, result, type, variableReference); |
| 30 |
m_list->Bind(wxEVT_KEY_DOWN, &DAPTooltip::OnKeyDown, this); |
| 31 |
GetSizer()->Fit(this); |
| 32 |
} |
| 33 |
|
| 34 |
DAPTooltip::~DAPTooltip() {} |
| 35 |
|
| 36 |
void DAPTooltip::UpdateChildren(int varId, dap::VariablesResponse* response) |
| 37 |
{ |
| 38 |
m_list->UpdateChildren(varId, response); |
| 39 |
} |
| 40 |
|
| 41 |
void DAPTooltip::OnKeyDown(wxKeyEvent& event) |
| 42 |
{ |
| 43 |
event.Skip(); |
| 44 |
if(event.GetKeyCode() == WXK_ESCAPE) { |
| 45 |
// Cancel this tip |
| 46 |
clCommandEvent destroyEvent(wxEVT_TOOLTIP_DESTROY); |
| 47 |
EventNotifier::Get()->AddPendingEvent(destroyEvent); |
| 48 |
} |
| 49 |
} |