My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
#include "MapLevel.h"

Rect MapLevel::GetRect()
{
Point p1(INT_MAX, INT_MAX);
Point p2(INT_MIN, INT_MIN);

bool found = false;
for (int i = 0; i < _layers.GetCount(); ++i)
if (_layers[i])
{
Rect r = _layers[i]->GetRenderRect();

if (r.BottomRight().x > p2.x)
p2.x = r.BottomRight().x;

if (r.BottomRight().y > p2.y)
p2.y = r.BottomRight().y;

if (r.TopLeft().x < p1.x)
p1.x = r.TopLeft().x;

if (r.TopLeft().y < p1.y)
p1.y = r.TopLeft().y;

found = true;
}

return found ? Rect(p1, p2) : Rect(Point(0, 0), Size(0, 0));
}

Point MapLevel::GetPageOffset()
{
Size rsz = GetRenderSize();
Size psz = GetPageSize();
Point r = Point(0, 0);

if (rsz.cx < psz.cx) r.x = (psz.cx - rsz.cx) / 2;
if (rsz.cy < psz.cy) r.y = (psz.cy - rsz.cy) / 2;

return r;
}

Rect MapLevel::GetRenderRect()
{
return GetRect();
}

Rect MapLevel::GetPageRect()
{
return Rect(_pagePos, GetSize());
}

Change log

r4180 by Sc0rch on Nov 17, 2011   Diff
MapRender: First release
(FormEditorCommon, FormEditorProperties,
Map, MapBG, MapCommon, MapEditor,
MapRenderTest.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 981 bytes, 52 lines
Powered by Google Project Hosting