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

📄 xtable.h

📁 一个简单方便的表格控件
💻 H
字号:

#pragma once

#include "XCell.h"

const int MAX_ROWS = 64;
const int MAX_COLS = 16;

// XTable
class XTable : public CWnd
{
	DECLARE_DYNAMIC(XTable)

public:
	XTable(int rows, int cols);
	virtual ~XTable();

    BOOL Create(const RECT& rect, CWnd* parent, UINT nID,
                DWORD dwStyle = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE);
public:
	XCell* cells;
	int* rowHeight;
	int* colWidth;

	int rows;
	int cols;

	int focusRow;
	int focusCol;

	XCell defaultCell;
	int defaultHeight;
	int defaultwidth;

public:
	int SetRows(int rows);
	int GetRows();
	int SetCols(int cols);
	int GetCols();

	int SetRowHeight(int row, int height);
	int GetRowHeight(int row);

	int SetColWidth(int col, int width);
	int GetColWidth(int col);

	int GetRowsHeight(int startRow, int endRow);
	int GetColsWidth(int startCol, int endCol);

	int AppendRow() {return SetRows(GetRows() + 1);}
	int AppendCol() {return SetCols(GetCols() + 1);}
	int deleteRow() {return SetRows(GetRows() - 1);}
	int deleteCol() {return SetCols(GetCols() - 1);}

	int JoinCells (int startRow, int startCol, int endRow, int endCol);
	int UnjoinCells (int row, int col);

	int SetCells(int row, int col, XCell& cell);
	XCell* GetCells(int row, int col);


	int SetText(int row, int col, CString str);
	CString GetText(int row, int col);

	int SetTextColor(int row, int col, COLORREF color);
	COLORREF GetTextColor(int row, int col);

	int SetTextFont(int row, int col, CFont& font);
	CFont* GetTextFont(int row, int col);

	int SetTextFontSize(int row, int col, int size);
	int GetTextFontSize(int row, int col);

	int SetBackColor(int row, int col, COLORREF color);
	COLORREF GetBackColor(int row, int col);

	int SetBackMode(int row, int col, int mode);
	int GetBackMode(int row, int col);

	int SetOverlap (int row, int col, bool enable);
	bool GetOverlap (int row, int col);

	int SetAlignment (int row, int col, int align);
	int GetAlignment (int row, int col);

	int SetWordbreak (int row, int col, bool enable);
	bool GetWordbreak (int row, int col);


public:

	int Draw(CDC* pDC);
	RECT GetRect(int row, int col);
	bool HitTest (CPoint point, int& row, int& col);

	int Test ();

protected:
	DECLARE_MESSAGE_MAP()

public:
	afx_msg void OnPaint();
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

	static BOOL RegisterWindowClass();
};


⌨️ 快捷键说明

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