-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChildFam.h
63 lines (44 loc) · 1.43 KB
/
ChildFam.h
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
#pragma once
#include <FL/Fl_Multiline_Output.H>
#include <FL/Fl_Box.H>
#include "Person.h"
#include "Marriage.h"
// TODO more than 3 children
class ChildFam : public Fl_Box
{
private:
Fl_Color _clr;
int childCount;
Marriage *_parents;
Marriage *children[3];
int _realW;
int _realH;
public:
ChildFam (Person *husb, Person *wife, Fl_Color clr, int x, int y)
: Fl_Box(x, y, 140, 325) // NOTE: first approximation
{
box(FL_BORDER_BOX);
_clr = clr;
_parents = new Marriage(husb, wife, clr, x+3, y+3);
childCount = 0;
_realW = _parents->realW()+4;
_realH = _parents->realH()+6;
// Adjust our size for the required display dimensions
resize(x,y, _realW, _realH);
}
void AddChild(Person *child, Person *spouse)
{
int marriageHigh = _parents->realH();
int deltaY = marriageHigh + 2;
for (int i=0; i < childCount; i++)
deltaY += children[i]->realH();
Marriage *childM = new Marriage(child, spouse, _clr, x()+24, y()+deltaY);
children[childCount] = childM;
_realW = Marriage::max(_realW, children[childCount]->realW()+25);
_realH = deltaY + children[childCount]->realH() + 4;
resize(x(),y(),_realW, _realH);
childCount++;
}
int realW() { return _realW; }
int realH() { return _realH; }
};