1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| class wxMyTipWindow : public wxTipWindow
{
public:
wxMyTipWindow(wxWindow* parent, const wxString& text):
wxTipWindow(parent, text){}
void OnKeyDown(wxKeyEvent& event)
{
std::cout << "YO" << std::endl;
}
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxMyTipWindow, wxTipWindow)
EVT_KEY_DOWN(wxMyTipWindow::OnKeyDown)
END_EVENT_TABLE()
/**/
class wxTipListCtrl : public wxListCtrl
{
private:
wxTimer tipTimer;
wxString text;
wxTipWindow *tw;
public:
wxTipListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt, \
const wxSize& sz,long style,const wxValidator& validator,\
const wxString& name):
wxListCtrl(parent, id, pt, sz, style, validator, name),tipTimer(this, IDD_TIP_TIMER){tw = NULL;}
void OnTimer(wxTimerEvent& event)
{
if (!text.empty())
{
tw = new wxMyTipWindow(this, text);
tw->SetBoundingRect(wxRect(1,1,50,50));
}
}
void OnMouseMotion(wxMouseEvent& event)
{
if (tipTimer.IsRunning() == true)
tipTimer.Stop();
wxPoint position = event.GetPosition();
int flag = 0;
long *ptrSubItem;
long item = HitTest(position, flag, ptrSubItem);
if (item != wxNOT_FOUND)
{
tipTimer.Start(1200, wxTIMER_ONE_SHOT);
text = GetItemText(item);
}
}
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxTipListCtrl, wxListCtrl)
EVT_MOTION(wxTipListCtrl::OnMouseMotion)
EVT_TIMER(IDD_TIP_TIMER, wxTipListCtrl::OnTimer)
END_EVENT_TABLE()
/**/ |
Partager