forked from Adham-hussin/Paint-for-Kids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddSquAction.cpp
45 lines (31 loc) · 1.09 KB
/
AddSquAction.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
#include "AddSquAction.h"
AddSquAction::AddSquAction(ApplicationManager *pApp):Action(pApp)
{
}
void AddSquAction::ReadActionParameters()
{
//Get a Pointer to the Input / Output Interfaces
Output* pOut = pManager->GetOutput();
Input* pIn = pManager->GetInput();
pOut->PrintMessage("New Rectangle: Click at first corner");
//Read 1st corner and store in point P1
pIn->GetPointClicked(P1.x, P1.y);
pOut->PrintMessage("New Rectangle: Click at second corner");
//Read 2nd corner and store in point P2
pIn->GetPointClicked(P2.x, P2.y);
RectGfxInfo.isFilled = false; //default is not filled
//get drawing, filling colors and pen width from the interface
RectGfxInfo.DrawClr = pOut->getCrntDrawColor();
RectGfxInfo.FillClr = pOut->getCrntFillColor();
pOut->ClearStatusBar();
}
//Execute the action
void AddRectAction::Execute()
{
//This action needs to read some parameters first
ReadActionParameters();
//Create a rectangle with the parameters read from the user
CRectangle *R=new CRectangle(P1, P2, RectGfxInfo);
//Add the rectangle to the list of figures
pManager->AddFigure(R);
}