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
85
86
87
88
89
/********************************************************************
*
*	Created:	15/7/2014   09:06
*
*	File:		fsCRollOverGui.h
*
*	Author:		Martin P King
*	
*	Purpose:	Roll over that renders when the mouse is over any
*				of the registered entities
*
*********************************************************************/

#ifndef fsCRollOverGuihdr
#define fsCRollOverGuihdr

#include <fsCore/src/fsCUniqueId.h>

#include <fsAppCore/src/components/gui/fsIMessageListenerGuiComponent.h>
#include <fsCore/fsPoint.h>

class fsITransformationComponent;

class fsCRollOverGui : public fsIMessageListenerGuiComponent
{
	friend class fsCComponentFactory;

public:

	static const fsCUniqueId mTypeId;

	struct fsSRollOver
	{
		fsSRollOver(const fsStr& pTxt, fsCEntity* const pEnt) :
			mTxt(pTxt),
			mEnt(pEnt)
		{
		}

		fsStr mTxt;
		fsCEntity* mEnt;
	};

	static const fsCUniqueId mDeactivateMsg;

	void candidatesDeregister();
	void candidatesRegister(std::vector<fsSRollOver>& pCandidates);
	void candidateRegister(const fsSRollOver& pCandidate);
	void candidateDeRegister(fsCEntity* pEnt);


	void listenersRegisterDo() override;
	void listenersDeregisterDo() override;
	fsBool messageProcessDo(const fsCUniqueId& pMessageType,
	                        const fsIMessageDispatcher::sMessageParameters& pParam) override;

protected:

	void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;

	static fsIComponent* create(fsCEntity* pParent);

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


	void posSet(const fsPoint& pMousePos, fsCEntity* pEnt);
	void textSet(const fsSRollOver& pRollOver);
	fsBool newTarget(const fsSRollOver& pRollOver) const;

	virtual void rollOverCandidatesCheck(const fsPoint& pPos);

	std::vector<fsSRollOver> mRollOvers;

private:

	fsITransformationComponent* transformationChildComponentGet() const;
	void close();


	void positionCorrectForScreenBoundry(fsPoint& pPos, fsS32 pTargetH, fsPoint pRollOverGuiSize);

	void maxStrWidthCalculate(const fsCVariableTable& pVars);

	fsS32 mStrWidthInPixels;
	fsPoint mFixedPos;
};

#endif