-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.cpp
71 lines (58 loc) · 1.82 KB
/
Input.cpp
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
//#include "Input.h"
#include "Output.h"
Input::Input(window* pW)
{
pWind = pW; //point to the passed window
}
void Input::GetPointClicked(int &x, int &y)
{
pWind->WaitMouseClick(x, y); //Wait for mouse click
}
string Input::GetSrting(Output *pOut)
{
///TODO: Implement this Function
//Read a complete string from the user until the user presses "ENTER".
//If the user presses "ESCAPE". This function should return an empty string.
//"BACKSPACE" should be also supported
//User should see what he is typing at the status bar
return NULL;
}
//This function reads the position where the user clicks to determine the desired action
ActionType Input::GetUserAction() const
{
int x,y;
pWind->WaitMouseClick(x, y); //Get the coordinates of the user click
if(UI.AppMode == DESIGN ) //application is in design mode
{
//[1] If user clicks on the Toolbar
if ( y >= 0 && y < UI.ToolBarHeight)
{
//Check whick Menu item was clicked
//==> This assumes that menu items are lined up horizontally <==
int ClickedItemOrder = (x / UI.ToolItemWidth);
//Divide x coord of the point clicked by the menu item width (int division)
//if division result is 0 ==> first item is clicked, if 1 ==> 2nd item and so on
switch (ClickedItemOrder)
{
case ITM_AND2: return ADD_AND_GATE_2;
case ITM_OR2: return ADD_OR_GATE_2;
case ITM_EXIT: return EXIT;
default: return DSN_TOOL; //A click on empty place in desgin toolbar
}
}
//[2] User clicks on the drawing area
if ( y >= UI.ToolBarHeight && y < UI.height - UI.StatusBarHeight)
{
return SELECT; //user want to select/unselect a component
}
//[3] User clicks on the status bar
return STATUS_BAR;
}
else //Application is in Simulation mode
{
return SIM_MODE; //This should be changed after creating the compelete simulation bar
}
}
Input::~Input()
{
}