Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / 13-Practice-31.05.2022 / Form.h
blob: 7818d58d627a872fbb428f492ddb67de142662b0 (plain) (blame)
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
#include "String.h"
#include "List.hpp"
#include "Control.h"
#include "Size.h"

class Form {
	Size size;
	String name;
	List<Control*> controls;

public:
	void addControl(Control& newControl) {
		controls.add(&newControl);
	}
	void changeSize(Size newSize);
	Control& operator[](unsigned index) {
		return *controls[index];
	}
	bool changeControlLocation(unsigned index, Location newLoc) {
		if (newLoc.x >= 0 && newLoc.x <= size.width && newLoc.y >= 0 && newLoc.y <= size.height) {
			controls[index]->get_loc() = newLoc;
			return true;
		}
		return false;
	}
	void change(unsigned index) {
		controls[index]->setDataDialog();
	}
};