⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.h

📁 Cool语言编译器
💻 H
字号:
#ifndef __WINDOW_H__
#define __WINDOW_H__

#include "State.h"
#include "Key.h"
#include "Type.h"

class Window
{

private:
	enum
	{
		// 窗口中最大文本行数
		MaxLine = 60,

		// 文本行的最大长度
		MaxLenOfLine = 60,

		// 窗口标题的最大长度
		MaxLenOfTitle = 70
	};

	// 窗口左上角坐标
	int x0;
	int y0;

	// 窗口右下角坐标
	int x1;
	int y1;

	// 是否有垂直滚动条标志
	bool VerticalSign;

	// 是否有阴影标志
	bool Black;

	// 垂直滚动条游标位置
	int VerticalPos;

	// 窗口文本高度,在计算游标位置时使用
	int TotHigh;

	// 当前文本行数量
	int TotLine;

	// 存储文本行内容
	char Line[MaxLine][MaxLenOfLine];

	// 存储标题内容
	char Title[MaxLenOfTitle];

	// 边框前景色
	int FrameForeground;

	// 边框背景色
	int FrameBackground;

	// 文本前景色
	int TextForeground;

	// 文本背景色
	int TextBackground;

public:
	Window(const int, const int, const int, const int, const int = true, const int = true);
	~Window();

	// 设置颜色
	void SetColor(const int, const int, const int, const int);

	// 设置标题
	void SetTitle(const char []);


	void SetTotHigh(const int);

	// 显示窗口
	void Show();

	// 滚动垂直滚动条
	void ScrollVertical(const int);

	// 滚动文本
	void ScrollText(const int);

	// 重置垂直滚动条
	void ResetVertical();

	// 等待用户上下翻屏
	void Work();

	// 等待用户输入信息
	void GetInput(char *, const int, const int, const int);

	// 等待用户按任意键
	void Wait();

	// 添加文本行
	void Add(const char []);

	// 隐藏窗口
	void Hide();

	// 清除文本行
	void ClearText();

	// 重新打印标题
	void RefreshTitle();

	void Clear();

	// 返回窗口的顶部行号
	inline int Top() const {return x0;}

	// 返回窗口的底部行号
	inline int Bottom() const {return x1;}

	// 返回窗口的左部列号
	inline int Left() const {return y0;}

	// 返回窗口的右部列号
	inline int Right() const {return y1;}

	// 返回窗口文本区的高度
	inline int High() const {return x1 - x0 - 1;}

	// 返回窗口的标题
	inline char* Caption() {return Title;}
};

// Window类中调用的外部函数
extern void Receive(int &);
extern void SetColor(const int,const int);
extern void PrintChar(const int,const int,const char);
extern void PrintLine(const int);
extern void ClearHeadBlank(char *);
extern void ClearTailBlank(char *);
extern void ShowError(const ErrorType, const int = -1, const char [] = "");

// Window类中引用的外部变量
extern int x0;

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -