1427788e0SIngo Weinhold/*
2427788e0SIngo Weinhold * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3427788e0SIngo Weinhold * Distributed under the terms of the MIT License.
4427788e0SIngo Weinhold */
5427788e0SIngo Weinhold#ifndef CLICK_TARGET_H
6427788e0SIngo Weinhold#define CLICK_TARGET_H
7427788e0SIngo Weinhold
8427788e0SIngo Weinhold
9427788e0SIngo Weinhold#include <TokenSpace.h>
10427788e0SIngo Weinhold
11427788e0SIngo Weinhold
12427788e0SIngo Weinhold/*!	\brief Identifies a mouse click target in the app server.
13427788e0SIngo Weinhold
14427788e0SIngo Weinhold	Used to discriminate between different targets in order to filter
15427788e0SIngo Weinhold	multi-clicks. A click on a different target resets the click count.
16427788e0SIngo Weinhold*/
179216fc01SAugustin Cavalierclass ClickTarget {
18427788e0SIngo Weinholdpublic:
19427788e0SIngo Weinhold	enum Type {
20427788e0SIngo Weinhold		TYPE_INVALID,
21427788e0SIngo Weinhold		TYPE_WINDOW_CONTENTS,
22427788e0SIngo Weinhold		TYPE_WINDOW_DECORATOR
23427788e0SIngo Weinhold	};
24427788e0SIngo Weinhold
25427788e0SIngo Weinholdpublic:
26427788e0SIngo Weinhold	ClickTarget()
27427788e0SIngo Weinhold		:
28427788e0SIngo Weinhold		fType(TYPE_INVALID),
29427788e0SIngo Weinhold		fWindow(B_NULL_TOKEN),
30427788e0SIngo Weinhold		fWindowElement(0)
31427788e0SIngo Weinhold	{
32427788e0SIngo Weinhold	}
33427788e0SIngo Weinhold
34427788e0SIngo Weinhold	ClickTarget(Type type, int32 window, int32 windowElement)
35427788e0SIngo Weinhold		:
36427788e0SIngo Weinhold		fType(type),
37427788e0SIngo Weinhold		fWindow(window),
38427788e0SIngo Weinhold		fWindowElement(windowElement)
39427788e0SIngo Weinhold	{
40427788e0SIngo Weinhold	}
41427788e0SIngo Weinhold
42427788e0SIngo Weinhold	bool IsValid() const
43427788e0SIngo Weinhold	{
44427788e0SIngo Weinhold		return fType != TYPE_INVALID;
45427788e0SIngo Weinhold	}
46427788e0SIngo Weinhold
47427788e0SIngo Weinhold	Type GetType() const
48427788e0SIngo Weinhold	{
49427788e0SIngo Weinhold		return fType;
50427788e0SIngo Weinhold	}
51427788e0SIngo Weinhold
52427788e0SIngo Weinhold	int32 WindowToken() const
53427788e0SIngo Weinhold	{
54427788e0SIngo Weinhold		return fWindow;
55427788e0SIngo Weinhold	}
56427788e0SIngo Weinhold
57427788e0SIngo Weinhold	int32 WindowElement() const
58427788e0SIngo Weinhold	{
59427788e0SIngo Weinhold		return fWindowElement;
60427788e0SIngo Weinhold	}
61427788e0SIngo Weinhold
62427788e0SIngo Weinhold	bool operator==(const ClickTarget& other) const
63427788e0SIngo Weinhold	{
64427788e0SIngo Weinhold		return fType == other.fType && fWindow == other.fWindow
65427788e0SIngo Weinhold			&& fWindowElement == other.fWindowElement;
66427788e0SIngo Weinhold	}
67427788e0SIngo Weinhold
68427788e0SIngo Weinhold	bool operator!=(const ClickTarget& other) const
69427788e0SIngo Weinhold	{
70427788e0SIngo Weinhold		return !(*this == other);
71427788e0SIngo Weinhold	}
72427788e0SIngo Weinhold
73427788e0SIngo Weinholdprivate:
74427788e0SIngo Weinhold	Type	fType;
75427788e0SIngo Weinhold	int32	fWindow;
76427788e0SIngo Weinhold	int32	fWindowElement;
77427788e0SIngo Weinhold};
78427788e0SIngo Weinhold
79427788e0SIngo Weinhold
80427788e0SIngo Weinhold#endif	// CLICK_TARGET_H
81