summaryrefslogtreecommitdiff
path: root/inputmethods/dasher/DasherView.inl
blob: fbb0c163306439e8c0c9e02e25870428633a935b (plain)
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
// DasherView.inl
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2001-2002 David Ward
//
/////////////////////////////////////////////////////////////////////////////


inline void Dasher::CDasherView::Render()
{
	m_Screen->Blank();
	
	// Render nodes to screen object (should use off screen buffer)
	RecursiveRender(m_DasherModel.Root(), m_DasherModel.Rootmin(), m_DasherModel.Rootmax(), 2, false);
	RecursiveRender(m_DasherModel.Root(), m_DasherModel.Rootmin(), m_DasherModel.Rootmax(), 2, true);
	Crosshair(m_DasherModel.DasherOX()); // add crosshair
//	m_Screen->Display();                 // copy from buffer to screen
}

inline void Dasher::CDasherView::MapScreen(int* DrawX, int* DrawY)
{
	using namespace Dasher::Opts;
	
	switch (ScreenOrientation) {
		case (LeftToRight):
			break;
		case (RightToLeft):
			*DrawX = m_Screen->GetWidth() - *DrawX;
			break;
		case (TopToBottom): {
			int Swapper = ( *DrawX * m_Screen->GetHeight()) / m_Screen->GetWidth();
			*DrawX = (*DrawY  * m_Screen->GetWidth()) / m_Screen->GetHeight();
			*DrawY = Swapper;
			break;
			}
		case (BottomToTop): {
			// Note rotation by 90 degrees not reversible like others
			int Swapper = m_Screen->GetHeight() - ( *DrawX * m_Screen->GetHeight()) / m_Screen->GetWidth();
			*DrawX = (*DrawY  * m_Screen->GetWidth()) / m_Screen->GetHeight();
			*DrawY = Swapper;
			break;
			}
		default:
			break;
	}
}


inline void Dasher::CDasherView::UnMapScreen(int* MouseX, int* MouseY)
{
	using namespace Dasher::Opts;
	
	switch (ScreenOrientation) {
		case (LeftToRight):
			break;
		case (RightToLeft):
			*MouseX = m_Screen->GetWidth() - *MouseX;
			break;
		case (TopToBottom): {
			int Swapper = (*MouseX * m_Screen->GetHeight()) / m_Screen->GetWidth();
			*MouseX = (*MouseY *m_Screen->GetWidth()) / m_Screen->GetHeight();;
			*MouseY = Swapper;
			break;
			}
		case (BottomToTop): {
			int Swapper = (*MouseX * m_Screen->GetHeight()) / m_Screen->GetWidth();
			*MouseX = ((m_Screen->GetHeight() - *MouseY) * m_Screen->GetWidth()) / m_Screen->GetHeight();
			*MouseY = Swapper;
			break;
			}
		default:
			break;
	}
}