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
/********************************************************************
*
*	Created:	1/4/2014   9:48
*
*	File:		fsCCheckBoxComponent.h
*
*	Author:		Mick Waites
*	
*	Purpose:	A single toggle switch, or part of a group.
*
*********************************************************************/

#ifndef fsCCheckBoxComponenthdr
#define fsCCheckBoxComponenthdr

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

#include "../../fsIGestureHandlingComponent.h"

struct fsPoint;
class fsCCheckBoxGroupComponent;
class fsCBrush;


class fsCCheckBoxComponent : public fsIGestureHandlingComponent
{
	friend class fsCComponentFactory;
	friend class fsCCheckBoxGroupComponent;

public:

	struct sCheckBoxMsgParam : public fsIMessageDispatcher::sMessageParameters
	{
		sCheckBoxMsgParam(const fsStr& pParentName) : mParentName(pParentName), mValue(false)
		{
		}

		const fsStr& mParentName;
		fsBool mValue;
	};

	static const fsCUniqueId mTypeId;

	static const fsCUniqueId mEventCheckBoxToggledMsg;

	void initManually(std::vector<fsStr> pButtonFilenames);
	void tint(fsSColour const& pTint);

	void valueSet(fsBool pValue);
	fsBool valueGet() const;

	void groupInitialise();

protected:

	fsBool acceptingInputGet() const override;
	fsBool highlightSetDo() override;

	void onTap(const fsPoint& pTapPos) override;

	static fsIComponent* create(fsCEntity* pParent);

	void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;

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

	sCheckBoxMsgParam mMessageParams;

	fsCCheckBoxGroupComponent* mGroup;

	std::shared_ptr<fsCBrush> mBrushes[4];

private:

	void spriteInitialise(const fsCVariableTable& pVars);
	void brushLoad(const fsCVariableTable& pVars, const fsStr& pVarKey, fsS32 pBrushIndex);
	void spriteBrushSet() const;

	fsSColour mTint;
};

#endif