File: hdIFigure.cpp

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (175 lines) | stat: -rw-r--r-- 3,280 bytes parent folder | download
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// hdIFigure.cpp - Base class for all figures
//
//////////////////////////////////////////////////////////////////////////

#include "pgAdmin3.h"

// wxWindows headers
#include <wx/wx.h>
#include <wx/dcbuffer.h>

// App headers
#include "hotdraw/figures/hdIFigure.h"
#include "hotdraw/handles/hdIHandle.h"
#include "hotdraw/utilities/hdArrayCollection.h"
#include "hotdraw/tools/hdITool.h"
#include "hotdraw/connectors/hdIConnector.h"
#include "hotdraw/connectors/hdChopBoxConnector.h"

hdIFigure::hdIFigure()
{
	handles = new hdCollection(new hdArrayCollection());
	observers = new hdCollection(new hdArrayCollection());
	unsigned int i;
	for(i = 0; i < MAXPOS; i++)
	{
		selected.Add(false);
	}
	connector = NULL;
	basicDisplayBox.SetSize(wxSize(0, 0));
}

hdIFigure::~hdIFigure()
{
	if(connector)
		delete connector;
	if(handles)
		delete handles;
	if(observers)
	{
		observers->removeAll();
		delete observers;
	}
}

void hdIFigure::AddPosForNewDiagram()
{
	basicDisplayBox.addNewXYPosition();
	selected.Add(false);
}

void hdIFigure::RemovePosOfDiagram(int posIdx)
{
	basicDisplayBox.removeXYPosition(posIdx);
}

hdMultiPosRect &hdIFigure::displayBox()
{
	return getBasicDisplayBox();
}

hdMultiPosRect &hdIFigure::getBasicDisplayBox()
{
	return basicDisplayBox;
}

void hdIFigure::draw (wxBufferedDC &context, hdDrawingView *view)
{

}

void hdIFigure::drawSelected (wxBufferedDC &context, hdDrawingView *view)
{

}

hdCollection *hdIFigure::handlesEnumerator()
{
	return handles;
}

void hdIFigure::addHandle (hdIHandle *handle)
{
	if(!handles)
	{
		handles  = new hdCollection(new hdArrayCollection());
	}
	handles->addItem(handle);
}

void hdIFigure::removeHandle (hdIHandle *handle)
{
	if(handles)
	{
		handles->removeItem(handle);
	}
}

hdITool *hdIFigure::CreateFigureTool(hdDrawingView *view, hdITool *defaultTool)
{
	return defaultTool;
}

bool hdIFigure::isSelected(int posIdx)
{
	return selected[posIdx];
}

void hdIFigure::setSelected(int posIdx, bool value)
{
	selected[posIdx] = value;
}

hdIConnector *hdIFigure::connectorAt (int posIdx, int x, int y)
{
	if(!connector)
		connector = new hdChopBoxConnector(this);
	return connector;
}

bool hdIFigure::includes(hdIFigure *figure)
{
	return (this == figure);
}

void hdIFigure::onFigureChanged(int posIdx, hdIFigure *figure)
{

	hdIteratorBase *iterator = observers->createIterator();
	while(iterator->HasNext())
	{
		hdIFigure *o = (hdIFigure *) iterator->Next();
		o->onFigureChanged(posIdx, this);
	}
	delete iterator;
}

void hdIFigure::addObserver(hdIFigure *observer)
{
	if(!observers)
	{
		observers  = new hdCollection(new hdArrayCollection());
	}
	observers->addItem(observer);
}

void hdIFigure::removeObserver(hdIFigure *observer)
{
	if(observers)
	{
		observers->removeItem(observer);
	}
}

hdIteratorBase *hdIFigure::observersEnumerator()
{
	return observers->createIterator();
}

void hdIFigure::setKindId(int hiddenId)
{
	kindHiddenId = hiddenId;
}

//Hack because is kindof in not powerful as it should be
int hdIFigure::getKindId()
{
	return kindHiddenId;
}