📄 report.cpp
字号:
/**********************************************************************************
* *
* Henry Banking System ATM Module *
* Copyright (c) 2004 by Henry. All rights reserved. *
* *
* Permission to use, copy, modify, and distribute this software for any purpose *
* is hereby granted without fee, provided that this copyright and permissions *
* notice appear in all copies and derivatives, and that no charge may be made *
* for the software and its documentation except to cover cost of distribution. *
* *
* This software is provided "as is" without express or implied warranty. *
* *
**********************************************************************************/
/*
* Description:
*
* Generate a report form in a CUI way.
*
* Notes:
*
* This code has been written to conform to standard C++ and STL. It has been
* compiled successfully using Visual C++ 7.0.
*/
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include "common.h"
#include "report.h"
#include "cui.h"
using namespace std;
using namespace cui;
namespace report
{
size_t ReportForm::size()
{
return 3 + captionSize + textSize;
}
void ReportForm::appendItem(string caption, string text)
{
ReportItem item;
item.caption = caption;
item.text = text;
body.push_back(item);
}
void ReportForm::appendItem(string caption)
{
appendItem(caption, " ");
}
void ReportForm::appendItem()
{
appendItem(" ", " ");
}
void ReportForm::show()
{
cout << endl << endl;
showHeader();
cout << endl;
showBody();
cout << endl;
showFooter();
Alert::show("", "");
cout << endl << endl;
}
void ReportForm::showLine()
{
cout << "+" << string(captionSize, '-') << "+" << string(textSize, '-') << "+" << endl;
}
void ReportForm::showHeader()
{
cout<<header << endl;
}
void ReportForm::showBody()
{
if(body.size() == 0) return;
showLine();
for(vector<ReportItem>::size_type i = 0; i <= body.size() - 1; i++)
{
showItem(body[i]);
}
showLine();
}
void ReportForm::showFooter()
{
cout<<footer << endl;
}
void ReportForm::showItem(ReportItem item)
{
if(item.caption == "-")
{
showLine();
return;
}
cout << "|" << format(item.caption, captionSize, ALIGN_LEFT, 3) << "|";
cout << format(item.text, textSize, ALIGN_LEFT, 3) << "|" << endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -