diff --git a/ctl/ctlTree.cpp b/ctl/ctlTree.cpp index 98d0714..5cfb85f 100644 --- a/ctl/ctlTree.cpp +++ b/ctl/ctlTree.cpp @@ -15,13 +15,13 @@ // App headers #include "pgAdmin3.h" #include "ctl/ctlTree.h" - #include "schema/pgObject.h" #include "schema/pgCollection.h" #include "schema/pgServer.h" BEGIN_EVENT_TABLE(ctlTree, wxTreeCtrl) EVT_CHAR(ctlTree::OnChar) + EVT_MOUSE_EVENTS(ctlTree::OnMouse) END_EVENT_TABLE() @@ -143,7 +143,101 @@ wxTreeItemId ctlTree::FindItem(const wxTreeItemId &idParent, const wxString &pre return id; } +wxTreeItemId ctlTree::GetVerticalItem(wxPoint& pt) { + int flags = 0; + wxTreeItemId item = DoTreeHitTest(pt, flags); + if ((flags & wxTREE_HITTEST_ONITEMINDENT) == wxTREE_HITTEST_ONITEMINDENT) { + if (item) { + wxRect r; + wxTreeItemId itemParent = item; + GetBoundingRect(itemParent, r, true); + r.x = r.x - 19; + wxTreeItemId prev; + bool ex = false; + while (!ex) { + ex = true; + prev = itemParent; + itemParent = GetItemParent(itemParent); + //this->ScrollTo(itemParent); + r.x = r.x - 19; + if (r.x >= pt.x) ex = false; + } + if (prev) return (prev); + } + //wxTreeEvent nevent(wxEVT_TREE_ITEM_MIDDLE_CLICK, this, item); + //nevent.m_pointDrag = CalcScrolledPosition(pt); + //event.Skip(!GetEventHandler()->ProcessEvent(nevent)); + + } + return NULL; +} +void ctlTree::OnMouse(wxMouseEvent& event) +{ + wxPoint pt = event.GetPosition(); + int flags = 0; + wxTreeItemId item = DoTreeHitTest(pt, flags); + if (event.LeftDown()) + { + if ((flags & wxTREE_HITTEST_ONITEMINDENT) == wxTREE_HITTEST_ONITEMINDENT) { + if (item) { + wxRect r; + wxTreeItemId itemParent=item; + GetBoundingRect(itemParent, r, false); + wxTreeItemId prev; + prev = GetVerticalItem(pt); + if (prev) SelectItem(prev); + return; + } + //wxTreeEvent nevent(wxEVT_TREE_ITEM_MIDDLE_CLICK, this, item); + //nevent.m_pointDrag = CalcScrolledPosition(pt); + //event.Skip(!GetEventHandler()->ProcessEvent(nevent)); + return; + } + + } + else { + if ((flags & wxTREE_HITTEST_ONITEMINDENT) == wxTREE_HITTEST_ONITEMINDENT && (item==GetSelection())) { + wxRect r; + wxClientDC dc(this); + GetBoundingRect(item, r, true); + r.width = r.x-19; + r.x = r.x - 19; + wxTreeItemId prev; + wxTreeItemId itemParent = item; + wxImageList *list=this->GetImageList(); + bool ex = false; + while (!ex) { + //ex = true; + prev = itemParent; + itemParent = GetItemParent(itemParent); + //this->ScrollTo(itemParent); + if (!itemParent.IsOk()) break; + r.x = r.x - 19; + //if (r.x >= pt.x) ex = false; + + dc.SetClippingRegion(r.x + 1-19, r.y + 1, + 16, 16); + int image = this->GetItemImage(itemParent); + list->Draw(image, dc, + r.x + 1-19, + r.y + 1, + wxIMAGELIST_DRAW_TRANSPARENT + ); + dc.DestroyClippingRegion(); + + } +// dc.SetBrush(*wxRED); +// dc.SetPen(*wxTRANSPARENT_PEN); +// dc.DrawRectangle(r); + Update(); + return; + } + + } + event.Skip(); + +} void ctlTree::OnChar(wxKeyEvent &event) { int keyCode = event.GetKeyCode(); diff --git a/frm/events.cpp b/frm/events.cpp index dfae274..159b515 100644 --- a/frm/events.cpp +++ b/frm/events.cpp @@ -74,6 +74,7 @@ BEGIN_EVENT_TABLE(frmMain, pgFrame) EVT_TREE_ITEM_COLLAPSING(CTL_BROWSER, frmMain::OnCollapse) EVT_TREE_ITEM_ACTIVATED(CTL_BROWSER, frmMain::OnSelActivated) EVT_TREE_ITEM_RIGHT_CLICK(CTL_BROWSER, frmMain::OnSelRightClick) + EVT_TREE_ITEM_GETTOOLTIP(CTL_BROWSER, frmMain::OnBrowserToolTip) EVT_STC_UPDATEUI(CTL_SQLPANE, frmMain::OnPositionStc) EVT_CLOSE( frmMain::OnClose) @@ -818,7 +819,10 @@ void frmMain::OnContextMenu(wxCommandEvent &event) } +void frmMain::OnBrowserToolTip(wxTreeEvent& event) +{ +} //////////////////////////////////////////////////////////////////////////////// // This handler will display a popup menu for the item at the mouse position //////////////////////////////////////////////////////////////////////////////// diff --git a/include/ctl/ctlTree.h b/include/ctl/ctlTree.h index 90f1dcc..cf6ba8c 100644 --- a/include/ctl/ctlTree.h +++ b/include/ctl/ctlTree.h @@ -42,10 +42,12 @@ public: wxTreeItemId FindItem(const wxTreeItemId &item, const wxString &str, bool full = false); void NavigateTree(int keyCode); virtual ~ctlTree(); - + void OnMouse(wxMouseEvent& ev); + wxTreeItemId GetVerticalItem(wxPoint& pt); DECLARE_EVENT_TABLE() private: + void OnChar(wxKeyEvent &event); wxString m_findPrefix; ctlTreeFindTimer *m_findTimer; diff --git a/include/frm/frmMain.h b/include/frm/frmMain.h index 8e3ade8..a75cf7e 100644 --- a/include/frm/frmMain.h +++ b/include/frm/frmMain.h @@ -259,6 +259,7 @@ private: void OnTreeKeyDown(wxTreeEvent &event); void OnSelActivated(wxTreeEvent &event); void OnSelRightClick(wxTreeEvent &event); + void OnBrowserToolTip(wxTreeEvent& event); void OnCollapse(wxTreeEvent &event); void OnExpand(wxTreeEvent &event); void OnClose(wxCloseEvent &event);