mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
Navagate jump top level tree
Добавлен быстрый переход на родительские узлы в дереве объектов. Переход выполняется по щелчку левой кнопкой мыши по отступам.
This commit is contained in:
parent
b2db84d54f
commit
055b561af0
4 changed files with 103 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue