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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// hdMenuTool.cpp - Allow Edition of textTool (double click) or show a menu to modifiy in someway text (right click) a figure.
//
//////////////////////////////////////////////////////////////////////////
#include "pgAdmin3.h"
// wxWindows headers
#include <wx/wx.h>
#include <wx/textctrl.h>
#include <wx/choicdlg.h>
// App headers
#include "hotdraw/tools/hdMenuTool.h"
#include "hotdraw/figures/hdIFigure.h"
class hdDrawingEditor;
hdMenuTool::hdMenuTool(hdDrawingView *view, hdIFigure *fig, hdITool *dt):
hdFigureTool(view, fig, dt)
{
menuFigure = (hdAbstractMenuFigure *) this->getFigure();
ownerView->setMenuToolFigure(NULL);
}
hdMenuTool::~hdMenuTool()
{
}
void hdMenuTool::mouseDown(hdMouseEvent &event)
{
//Linux hack for bug
int x = event.GetPosition().x, y = event.GetPosition().y;
setAnchorCoords(x, y);
if(menuFigure->menuEnabled() && event.RightDown())
{
wxMenu menu;
event.getView()->setMenuToolFigure(menuFigure);
menuFigure->createMenu(menu);
event.getView()->connectPopUpMenu(menu);
hdPoint p = event.GetPosition();
event.getView()->CalcScrolledPosition(p.x, p.y, &p.x, &p.y);
event.getView()->PopupMenu(&menu, p);
return;
}
getDefaultTool()->mouseDown(event);
}
void hdMenuTool::activate(hdDrawingView *view)
{
hdFigureTool::activate(view);
}
void hdMenuTool::deactivate(hdDrawingView *view)
{
hdFigureTool::deactivate(view);
}
void hdMenuTool::mouseDrag(hdMouseEvent &event)
{
getDefaultTool()->mouseDrag(event);
}
void hdMenuTool::OnGenericPopupClick(wxCommandEvent &event, hdDrawingView *view)
{
menuFigure->OnGenericPopupClick(event, view);
}
|