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
/********************************************************************
*
*	File:		fsCCalendarComponent.h
*
*	Purpose:	Display a given month calendar
*
*********************************************************************/

#ifndef fsCCalendarComponenthdr
#define fsCCalendarComponenthdr

#include <vector>

#include <fsCore/fsPoint.h>
#include <fsCore/fsSColour.h>
#include <fsCore/src/fsCUniqueId.h>

#include "fsIComponent.h"

class fsCEntity;
class fsIFont;

class fsCCalendarComponent : public fsIComponent
{
	friend class fsCComponentFactory;

public:

	static const fsCUniqueId mTypeId;
	static fsStr currentDateTime();

protected:

	void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;

	static fsIComponent* create(fsCEntity* pParent);

	fsCCalendarComponent(fsCEntity* pParent);
	virtual ~fsCCalendarComponent();<--- Destructor in derived class

private:

	fsPoint dateOfMonthPosGet(fsS32 pDay) const;

	fsBool leapYearGet(fsS32 pYear) const;
	fsS32 daysInMonthGet(fsS32 pMonth, fsS32 pYear) const;
	fsS32 firstDayOfMonthGet(fsS32 pMonth, fsS32 pYear) const;

	void thisMonthPrint() const;
	void datesOfMonthPrint(const fsPoint& pPos, fsS32 pFirstDayOfMonth, fsS32 pDaysInMonth) const;
	void daysOfWeekHeadingsPrint(const fsPoint& pPos) const;
	void monthHeadingPrint(const fsPoint& pPos, fsS32 pMonth) const;
	void textEntryCreate(const fsStr& pStr, const fsPoint& pPos) const;

	std::vector<fsCEntity*> mDayHeadings;

	fsPoint mPos;
	fsPoint mStride;

	fsIFont* mFont;
	fsSColour4B mFontColour;
};

#endif