Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSE3150_Project/FormatterInterface.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
148 lines (121 sloc)
2.76 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FormatterInterface.h" | |
using namespace std; | |
FormatterInterface :: FormatterInterface() | |
{ | |
} | |
FormatterInterface :: ~FormatterInterface() | |
{ | |
} | |
// Settings | |
void FormatterInterface :: SetImplementor(FormatterImplementation *imp) | |
{ | |
if (implementor != __null) { | |
imp->SetMaxWidth(implementor->GetMaxWidth()); | |
imp->SetMaxHeight(implementor->GetMaxHeight()); | |
int row,col; | |
implementor->GetCursorPosition(row,col); | |
imp->SetCursorPosition(row,col); | |
} | |
implementor = shared_ptr<FormatterImplementation>(imp); | |
} | |
void FormatterInterface :: SetMaxWidth(int maxWidth) | |
{ | |
CheckImplementor(); | |
implementor->SetMaxWidth(maxWidth); | |
} | |
int FormatterInterface :: GetMaxWidth() | |
{ | |
CheckImplementor(); | |
return implementor->GetMaxWidth(); | |
} | |
void FormatterInterface :: SetMaxHeight(int maxHeight) | |
{ | |
CheckImplementor(); | |
implementor->SetMaxHeight(maxHeight); | |
} | |
int FormatterInterface :: GetMaxHeight() | |
{ | |
CheckImplementor(); | |
return implementor->GetMaxHeight(); | |
} | |
// Render Methods | |
void FormatterInterface :: Build() | |
{ | |
CheckImplementor(); | |
implementor->Build(); | |
} | |
int FormatterInterface :: GetRenderableLineCount() | |
{ | |
CheckImplementor(); | |
return implementor->GetRenderableLineCount(); | |
} | |
shared_ptr<string> FormatterInterface :: GetLine(int x) | |
{ | |
CheckImplementor(); | |
return implementor->GetLine(x); | |
} | |
void FormatterInterface :: GetCursorPosition(int &row, int &col) | |
{ | |
CheckImplementor(); | |
implementor->GetCursorPosition(row,col); | |
} | |
void FormatterInterface :: GetPosition(int &row, int &col) | |
{ | |
CheckImplementor(); | |
implementor->GetCursorPosition(row,col); | |
implementor->CursorToGrid(row,col); | |
} | |
void FormatterInterface :: SetPosition(int row, int col) | |
{ | |
CheckImplementor(); | |
implementor->GridToCursor(row,col); | |
implementor->SetCursorPosition(row,col); | |
} | |
// Actions | |
void FormatterInterface :: HandleMoveLeft() | |
{ | |
CheckImplementor(); | |
implementor->HandleMoveLeft(); | |
} | |
void FormatterInterface :: HandleMoveRight() | |
{ | |
CheckImplementor(); | |
implementor->HandleMoveRight(); | |
} | |
void FormatterInterface :: HandleMoveUp() | |
{ | |
CheckImplementor(); | |
implementor->HandleMoveUp(); | |
} | |
void FormatterInterface :: HandleMoveDown() | |
{ | |
CheckImplementor(); | |
implementor->HandleMoveDown(); | |
} | |
void FormatterInterface :: HandlePageUp() | |
{ | |
CheckImplementor(); | |
implementor->HandlePageUp(); | |
} | |
void FormatterInterface :: HandlePageDown() | |
{ | |
CheckImplementor(); | |
implementor->HandlePageDown(); | |
} | |
void FormatterInterface :: HandleHome() | |
{ | |
CheckImplementor(); | |
implementor->HandleHome(); | |
} | |
void FormatterInterface :: HandleEnd() | |
{ | |
CheckImplementor(); | |
implementor->HandleEnd(); | |
} | |
// Private Methods for ViewControllerInterface | |
void FormatterInterface :: CheckImplementor() | |
{ | |
if (implementor == __null) { | |
throw string("ViewControllerInterface has no implementation!"); | |
} | |
} |