1/*
2
3The Amazing TreeView !
4
5Author: Misza (misza@ihug.com.au)
6
7(C) 2002 OpenBeOS under MIT license
8
9*/
10#include "TreeView.h"
11#include "DUNWindow.h"
12TreeView::TreeView(BRect r) : BView(r,"miszaView",B_FOLLOW_TOP,B_WILL_DRAW)
13{
14	down = false;
15	status = false;
16}
17void TreeView::MouseUp(BPoint point)
18{	//controls what get resized and how
19	BPoint where;
20	uint32 buttons;
21	GetMouse(&where, &buttons);
22
23	if(where != point)
24	{	Invalidate();
25		down = false;
26	}
27
28	if(!status)//if view is hidden
29	{
30	Invalidate();
31
32	status = true;
33	((DUNWindow*)Window())->DoResizeMagic();
34	}
35	else if(status)
36	{
37	Invalidate();
38
39	status = false;
40	((DUNWindow*)Window())->DoResizeMagic();
41	}
42}
43
44void TreeView::MouseDown(BPoint point)
45{
46	SetMouseEventMask(B_POINTER_EVENTS,B_LOCK_WINDOW_FOCUS);
47	down = true;
48	Invalidate();
49}
50
51void TreeView::Draw(BRect updateRect)
52{	//colours for drawing the triangle
53
54	SetHighColor(0,0,0);
55	SetLowColor(150,150,150);
56	if(status && !down)//if view is showing
57	{
58		//horiz triangle
59		FillTriangle(BPoint(0,2),BPoint(8,2),BPoint(4,6),B_SOLID_LOW);
60		StrokeTriangle(BPoint(0,2),BPoint(8,2),BPoint(4,6),B_SOLID_HIGH);
61	}
62	else if (!status && !down){
63	//vert triangle
64		FillTriangle(BPoint(2,0),BPoint(2,8),BPoint(6,4),B_SOLID_LOW);
65		StrokeTriangle(BPoint(2,0),BPoint(2,8),BPoint(6,4),B_SOLID_HIGH);
66	}
67	else
68	{//midway
69		SetHighColor(0,0,0);
70		SetLowColor(100,100,0);
71		FillTriangle(BPoint(0,6),BPoint(6,0),BPoint(6,6),B_SOLID_LOW);
72		StrokeTriangle(BPoint(0,6),BPoint(6,0),BPoint(6,6),B_SOLID_HIGH);
73	}
74
75	down = false;
76	SetHighColor(0,0,0);
77	SetLowColor(150,150,150);
78
79}
80
81void TreeView::SetTreeViewStatus(bool condition)
82{
83	status = condition;
84}
85