1/*
2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan A��mus <superstippi@gmx.de>
7 */
8
9#include "Selectable.h"
10
11#include <debugger.h>
12
13#include "Selection.h"
14
15// constructor
16Selectable::Selectable()
17	: fSelected(false),
18	  fSelection(NULL)
19{
20}
21
22// destructor
23Selectable::~Selectable()
24{
25}
26
27// SetSelected
28void
29Selectable::SetSelected(bool selected, bool exclusive)
30{
31	// NOTE: "exclusive" is only useful when selecting,
32	// it is ignored when deselecting...
33	if (selected == fSelected)
34		return;
35
36	if (fSelection) {
37		if (selected)
38			fSelection->Select(this, !exclusive);
39		else
40			fSelection->Deselect(this);
41	} else {
42		debugger("Selectable needs to know Selection\n");
43	}
44}
45
46// SetSelection
47void
48Selectable::SetSelection(Selection* selection)
49{
50	fSelection = selection;
51}
52
53// #pragma mark -
54
55// SetSelected
56void
57Selectable::_SetSelected(bool selected)
58{
59	// NOTE: for private use by the Selection object!
60	if (fSelected != selected) {
61		fSelected = selected;
62		SelectedChanged();
63	}
64}
65