1/*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef CLICK_TARGET_H
6#define CLICK_TARGET_H
7
8
9#include <TokenSpace.h>
10
11
12/*!	\brief Identifies a mouse click target in the app server.
13
14	Used to discriminate between different targets in order to filter
15	multi-clicks. A click on a different target resets the click count.
16*/
17class ClickTarget {
18public:
19	enum Type {
20		TYPE_INVALID,
21		TYPE_WINDOW_CONTENTS,
22		TYPE_WINDOW_DECORATOR
23	};
24
25public:
26	ClickTarget()
27		:
28		fType(TYPE_INVALID),
29		fWindow(B_NULL_TOKEN),
30		fWindowElement(0)
31	{
32	}
33
34	ClickTarget(Type type, int32 window, int32 windowElement)
35		:
36		fType(type),
37		fWindow(window),
38		fWindowElement(windowElement)
39	{
40	}
41
42	bool IsValid() const
43	{
44		return fType != TYPE_INVALID;
45	}
46
47	Type GetType() const
48	{
49		return fType;
50	}
51
52	int32 WindowToken() const
53	{
54		return fWindow;
55	}
56
57	int32 WindowElement() const
58	{
59		return fWindowElement;
60	}
61
62	bool operator==(const ClickTarget& other) const
63	{
64		return fType == other.fType && fWindow == other.fWindow
65			&& fWindowElement == other.fWindowElement;
66	}
67
68	bool operator!=(const ClickTarget& other) const
69	{
70		return !(*this == other);
71	}
72
73private:
74	Type	fType;
75	int32	fWindow;
76	int32	fWindowElement;
77};
78
79
80#endif	// CLICK_TARGET_H
81