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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// hdAbstractFigure.cpp - Base class for all figures
//
//////////////////////////////////////////////////////////////////////////
#include "pgAdmin3.h"
// wxWindows headers
#include <wx/wx.h>
#include <wx/dcbuffer.h>
#include <wx/pen.h>
// App headers
#include "hotdraw/figures/hdAbstractFigure.h"
#include "hotdraw/figures/hdIFigure.h"
#include "hotdraw/utilities/hdArrayCollection.h"
#include "hotdraw/main/hdDrawingView.h"
hdAbstractFigure::hdAbstractFigure()
{
spaceForMovement.SetHeight(0);
spaceForMovement.SetWidth(0);
}
hdAbstractFigure::~hdAbstractFigure()
{
}
bool hdAbstractFigure::canConnect ()
{
return true;
}
bool hdAbstractFigure::includes(hdIFigure *figure)
{
return (this == figure);
}
void hdAbstractFigure::draw(wxBufferedDC &context, hdDrawingView *view)
{
//Hack to Allow creations of limits for figures movements, but what to do should be defined at derivated classes
spaceForMovement = view->canvasSize;
hdIFigure::draw(context, view);
basicDraw(context, view);
}
void hdAbstractFigure::basicDraw(wxBufferedDC &context, hdDrawingView *view)
{
hdRect copy = displayBox().gethdRect(view->getIdx());
view->CalcScrolledPosition(copy.x, copy.y, ©.x, ©.y);
context.SetPen(*wxGREEN_PEN);
context.SetBrush(wxBrush (wxColour(208, 208, 208), wxSOLID));
context.DrawRectangle(copy);
}
void hdAbstractFigure::drawSelected(wxBufferedDC &context, hdDrawingView *view)
{
hdIFigure::drawSelected(context, view);
basicDrawSelected(context, view);
}
void hdAbstractFigure::basicDrawSelected(wxBufferedDC &context, hdDrawingView *view)
{
hdRect copy = displayBox().gethdRect(view->getIdx());
view->CalcScrolledPosition(copy.x, copy.y, ©.x, ©.y);
context.SetPen(*wxRED_PEN);
context.SetBrush(wxBrush (wxColour(133, 133, 133), wxSOLID));
context.DrawRectangle(copy);
}
hdITool *hdAbstractFigure::CreateFigureTool(hdDrawingView *view, hdITool *defaultTool)
{
return defaultTool;
}
void hdAbstractFigure::moveBy(int posIdx, int x, int y)
{
willChange();
basicMoveBy(posIdx, x, y);
changed(posIdx);
}
void hdAbstractFigure::basicMoveBy(int posIdx, int x, int y)
{
basicDisplayBox.x[posIdx] += x;
basicDisplayBox.y[posIdx] += y;
}
void hdAbstractFigure::moveTo(int posIdx, int x, int y)
{
basicDisplayBox.x[posIdx] = x;
basicDisplayBox.y[posIdx] = y;
}
void hdAbstractFigure::willChange()
{
invalidate();
}
void hdAbstractFigure::changed(int posIdx)
{
invalidate();
onFigureChanged(posIdx, this);
}
void hdAbstractFigure::invalidate()
{
}
bool hdAbstractFigure::containsPoint(int posIdx, int x, int y)
{
return basicDisplayBox.Contains(posIdx, x, y);
}
void hdAbstractFigure::onFigureChanged(int posIdx, hdIFigure *figure)
{
//go to figure procedure to alert observers of changes on this figure
hdIFigure::onFigureChanged(posIdx, figure);
}
|