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

📄 zsysgriddefine.cpp

📁 此次上传的使linux下的文件传输协议
💻 CPP
字号:
// zSysGridDefine.cpp : implementation file
//

#include "stdafx.h"
#include "Prog.h"
#include "zSysGridDefine.h"
#include "zSysGridDefineFrame.h"
#include "zSysGridDefineType.h"
#include "zSysGridDefineAlign.h"
#include "zSysGridDefineDataType.h"
#include "zSysGridDefineText.h"
#include "zDlgS002.h"
#include "zDlgEnable.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// zSysGridDefine dialog


zSysGridDefine::zSysGridDefine(CWnd* pParent /*=NULL*/)
	: CDialog(zSysGridDefine::IDD, pParent)
{
	//{{AFX_DATA_INIT(zSysGridDefine)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void zSysGridDefine::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(zSysGridDefine)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
	DDX_GridControl(pDX,IDC_GRID1,G);
}


BEGIN_MESSAGE_MAP(zSysGridDefine, CDialog)
	//{{AFX_MSG_MAP(zSysGridDefine)
	ON_WM_SIZE()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON_HB, OnButtonHb)
	ON_BN_CLICKED(IDC_BUTTON_CS, OnButtonCs)
	ON_BN_CLICKED(IDC_BUTTON_TYPE, OnButtonType)
	ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
	ON_BN_CLICKED(IDC_BUTTON_FONTCOLOR, OnButtonFontcolor)
	ON_BN_CLICKED(IDC_BUTTON_BAKCOLOR, OnButtonBakcolor)
	ON_BN_CLICKED(IDC_BUTTON_ALIGN, OnButtonAlign)
	ON_BN_CLICKED(IDC_BUTTON_DATATYPE, OnButtonDatatype)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
	ON_BN_CLICKED(IDC_BUTTON_LOAD, OnButtonLoad)
	ON_BN_CLICKED(IDC_BUTTON_TEXT, OnButtonText)
	ON_BN_CLICKED(IDC_BUTTON_ADDROW, OnButtonAddrow)
	ON_BN_CLICKED(IDC_BUTTON_ADDCOLUMN, OnButtonAddcolumn)
	ON_BN_CLICKED(IDC_BUTTON_INSROW, OnButtonInsrow)
	ON_BN_CLICKED(IDC_BUTTON_INSCOL, OnButtonInscol)
	ON_BN_CLICKED(IDC_BUTTON_DELROW, OnButtonDelrow)
	ON_BN_CLICKED(IDC_BUTTON_DELCOL, OnButtonDelcol)
	ON_BN_CLICKED(IDC_BUTTON_AUTOSIZE, OnButtonAutosize)
	ON_BN_CLICKED(IDC_BUTTON_COLWIDTH, OnButtonColwidth)
	ON_BN_CLICKED(IDC_BUTTON_ROWHEIGHT, OnButtonRowheight)
	ON_BN_CLICKED(IDC_BUTTON_MARGIN, OnButtonMargin)
	ON_BN_CLICKED(IDC_BUTTON_FIXROW, OnButtonFixrow)
	ON_BN_CLICKED(IDC_BUTTON_FIXCOL, OnButtonFixcol)
	ON_BN_CLICKED(IDC_BUTTON_ENABLE, OnButtonEnable)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// zSysGridDefine message handlers

BOOL zSysGridDefine::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_ImageList.Create(MAKEINTRESOURCE(IDB_GRID_IMAGELIST), 16, 1, RGB(255,0,0));
	G.SetRadioCheckImage(&m_ImageList);
	G.m_bLineType=TRUE;

//	DefineB001();

	ShowWindow(3);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void zSysGridDefine::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	if(this->IsWindowVisible())
	{
		CRect rect;
		GetClientRect(rect);
		rect.top=rect.top+65;
		G.MoveWindow(rect);
	}
}

void zSysGridDefine::OnButton1() 
{
 	zSysGridDefineFrame dlg;
 	if(dlg.DoModal()==IDOK)
 	{
		CCellRange range=G.GetSelectedCellRange();
		//先将选中范围内的所有边框线清空
		int i,j;
		for(i=range.GetMinRow();i<=range.GetMaxRow();i++)
		{
			for(j=range.GetMinCol();j<=range.GetMaxCol();j++)
			{
				G.SetItemLine(i,j,FALSE);
			}
		}
		if(dlg.m_bLeft)    //绘制左边的边框线
		{
			for(i=range.GetMinRow();i<=range.GetMaxRow();i++)
			{
				G.SetItemLeftLine(i,range.GetMinCol(),TRUE);
			}
		}
		if(dlg.m_bTop)     //绘制上边的线
		{
			for(i=range.GetMinCol();i<=range.GetMaxCol();i++)
			{
				G.SetItemTopLine(range.GetMinRow(),i,TRUE);
			}
		}
		if(dlg.m_bRight)
		{
			for(i=range.GetMinRow();i<=range.GetMaxRow();i++)
			{
				G.SetItemRightLine(i,range.GetMaxCol(),TRUE);
			}
		}
		if(dlg.m_bBottom)
		{
			for(i=range.GetMinCol();i<=range.GetMaxCol();i++)
			{
				G.SetItemBottomLine(range.GetMaxRow(),i,TRUE);
			}
		}

		if(dlg.m_bMhert)    //水平位置上的中间线
		{
			for(i=range.GetMinCol();i<=range.GetMaxCol();i++)
			{
				G.SetItemBottomLine(range.GetMinRow(),i,TRUE);
				G.SetItemTopLine(range.GetMaxRow(),i,TRUE);
			}
			for(i=range.GetMinCol();i<=range.GetMaxCol();i++)
			{
				for(j=range.GetMinRow()+1;j<range.GetMaxRow();j++)
				{
					G.SetItemTopLine(j,i,TRUE);
					G.SetItemBottomLine(j,i,TRUE);
				}
			}
		}

		if(dlg.m_bMvert)
		{
			for(i=range.GetMinRow();i<=range.GetMaxRow();i++)
			{
				G.SetItemRightLine(i,range.GetMinCol(),TRUE);
				G.SetItemLeftLine(i,range.GetMaxCol(),TRUE);
			}
			for(i=range.GetMinRow();i<=range.GetMaxRow();i++)
			{
				for(j=range.GetMinCol()+1;j<range.GetMaxCol();j++)
				{
					G.SetItemLeftLine(i,j,TRUE);
					G.SetItemRightLine(i,j,TRUE);
				}
			}
		}

		G.Invalidate();

 	}	
}

void zSysGridDefine::OnButtonHb() 
{
	CCellRange range=G.GetSelectedCellRange();	
	G.SetCellCombine(range.GetMinRow(),range.GetMinCol(),range.GetColSpan()-1,range.GetRowSpan()-1);
	G.Invalidate();
}

void zSysGridDefine::OnButtonCs() 
{
	CCellRange range=G.GetSelectedCellRange();	
	G.UndoCellCombine(range.GetMinRow(),range.GetMinCol());
	G.Invalidate();
}


void zSysGridDefine::OnButtonType() 
{
	zSysGridDefineType dlg;
	if(dlg.DoModal()==IDOK)
	{
		CCellID cell=G.GetFocusCell();
		switch(dlg.m_nType)
		{
		case JnCtrlText:
			{
				G.SetItemCtrlText(cell.row,cell.col);
			}
			break;
		case JnCtrlImage:
			{
			}
			break;
		case JnCtrlButton:
			break;
		case JnCtrlXpButton:
			{
				G.SetItemCtrlXpButton(cell.row,cell.col);
			}
			break;
		case JnCtrlDrawBias:
			break;
		case JnCtrlLink:
			break;
		case JnCtrlRadio:
			{
				G.SetItemCtrlRadio(cell.row,cell.col,theApp.jns.StrToInt1(dlg.m_s1));
			}
			break;
		case JnCtrlCheckBox:
			{
				G.SetItemCtrlCheckBox(cell.row,cell.col);
			}
			break;
		case JnCtrlEdit:
			{
				G.SetItemCtrlEdit(cell.row,cell.col);
			}
			break;
		case JnCtrlComboBox:
			{
				G.SetItemCtrlComboBox(cell.row,cell.col,&aryComboData,NULL,FALSE);
			}
			break;
		case JnCtrlDateCtrl:
			{
				G.SetItemCtrlDate(cell.row,cell.col);
			}
			break;
		case JnCtrlTimeCtrl:
			{
				G.SetItemCtrlTime(cell.row,cell.col);
			}
			break;
		case JnCtrlDateTimeCtrl:
			{
				G.SetItemCtrlDateTime(cell.row,cell.col);
			}
			break;
		case JnCtrlSpinEdit:
			break;
		}
	}
	G.Invalidate();
}


void zSysGridDefine::OnOK() 
{
	NextDlgCtrl();
}

void zSysGridDefine::OnButtonFont() 
{
	LOGFONT m_lf;
	CFontDialog dlg(&m_lf);
	if (dlg.DoModal() == IDOK) 
	{
		CCellRange range=G.GetSelectedCellRange();
		dlg.GetCurrentFont(&m_lf);
		for(int i=range.GetMinRow();i<=range.GetMaxRow();i++)
		{
			for(int j=range.GetMinCol();j<=range.GetMaxCol();j++)
			{
				G.SetItemFont(i,j,&m_lf);
			}
		}
		G.Invalidate();
	}
}

void zSysGridDefine::OnButtonFontcolor() 
{
	CColorDialog clrdlg;
	if(clrdlg.DoModal()==IDOK)
	{
		CCellRange range=G.GetSelectedCellRange();
		for(int i=range.GetMinRow();i<=range.GetMaxRow();i++)
		{
			for(int j=range.GetMinCol();j<=range.GetMaxCol();j++)
			{
				G.SetItemFgColour(i,j,clrdlg.GetColor());
			}
		}
		G.Invalidate();
	}
}


void zSysGridDefine::OnButtonBakcolor() 
{
	CColorDialog clrdlg;
	if(clrdlg.DoModal()==IDOK)
	{
		CCellRange range=G.GetSelectedCellRange();
		for(int i=range.GetMinRow();i<=range.GetMaxRow();i++)
		{
			for(int j=range.GetMinCol();j<=range.GetMaxCol();j++)
			{
				G.SetItemBkColour(i,j,clrdlg.GetColor());
			}
		}
		G.Invalidate();
	}
}

void zSysGridDefine::OnButtonAlign() 
{
	zSysGridDefineAlign dlg;
	if(dlg.DoModal()==IDOK)
	{
		GridDrawTextTypeEnum nFormat=JnDrawTextTopLeft;
		switch(dlg.m_nH)
		{
		case 0:
			nFormat=JnDrawTextTopLeft;
			break;
		case 1:
			nFormat=JnDrawTextTopCen;
			break;
		case 2:
			nFormat=JnDrawTextTopRight;
			break;
		case 3:
			nFormat=JnDrawTextVCenLeft;
			break;
		case 4:
			nFormat=JnDrawTextVCenCen;
			break;
		case 5:
			nFormat=JnDrawTextVCenRight;
			break;
		case 6:
			nFormat=JnDrawTextBtmLeft;
			break;
		case 7:
			nFormat=JnDrawTextBtmCen;
			break;
		case 8:
			nFormat=JnDrawTextBtmRight;
			break;
		case 9:
			nFormat=JnDrawTextAutoMuti;
			break;
		}
		CCellRange range=G.GetSelectedCellRange();
		for(int i=range.GetMinRow();i<=range.GetMaxRow();i++)
		{
			for(int j=range.GetMinCol();j<=range.GetMaxCol();j++)
			{
				G.SetItemFormat(i,j,nFormat);
			}
		}
		G.Invalidate();
	}
}

void zSysGridDefine::OnButtonDatatype() 
{
	zSysGridDefineDataType dlg;
	if(dlg.DoModal()==IDOK)
	{
		GridDataTypeEnum m_nType;
		if(dlg.m_sType=="字符串")
		{
			m_nType=JnGridChar;
		}
		else if(dlg.m_sType=="整数")
		{
			m_nType=JnGridInt;
		}
		else if(dlg.m_sType=="浮点数")
		{
			m_nType=JnGridFloat;
		}
		else if(dlg.m_sType=="日期类型")
		{
			m_nType=JnGridDate;
		}
		//然后根据这个类型再确定如何进行设定

		CCellRange range=G.GetSelectedCellRange();
		for(int i=range.GetMinRow();i<=range.GetMaxRow();i++)
		{
			for(int j=range.GetMinCol();j<=range.GetMaxCol();j++)
			{
				if(m_nType==JnGridFloat)
				{
					G.SetItemDataType(i,j,m_nType,theApp.jns.StrToInt1(dlg.m_sNumber));
				}
				else
				{
					G.SetItemDataType(i,j,m_nType,-1);
				}
			}
		}
	}
}

void zSysGridDefine::OnButtonSave() 
{
	if(sPath=="")
	{
		CFileDialog	dlg(TRUE);
		dlg.m_ofn.lpstrFilter ="所有文件(*.*)\0*.*\0";
		dlg.m_ofn.nFilterIndex = 0;
		if (dlg.DoModal() == IDOK)
		{
			sPath=dlg.m_ofn.lpstrFile;
			G.Save(sPath);
		}	
	}
	else
	{
		G.Save(sPath);
	}
}

void zSysGridDefine::OnButtonLoad() 
{
	G.DeleteAllRow();
	if(sPath=="")
	{
		CFileDialog	dlg(TRUE);
		dlg.m_ofn.lpstrFilter ="所有文件(*.*)\0*.*\0";
		dlg.m_ofn.nFilterIndex = 0;
		if (dlg.DoModal() == IDOK)
		{
			sPath=dlg.m_ofn.lpstrFile;
			G.Load(sPath);
		}	
	}
	else
	{
		G.Load(sPath);
	}
}

void zSysGridDefine::OnButtonText() 
{
	zSysGridDefineText dlg;
	int nRow=G.GetFocusCell().row;
	int nCol=G.GetFocusCell().col;
	dlg.m_s1=G.GetItemText(nRow,nCol);
	if(dlg.DoModal()==IDOK)
	{
		G.SetItemText(nRow,nCol,dlg.m_s1);
		G.Invalidate();
	}
}

void zSysGridDefine::OnButtonAddrow() 
{
	G.SetRowCount(G.GetRowCount()+1);
	for(int i=0;i<G.GetRowCount();i++)
	{
		G.SetItemText(i,0,theApp.jns.IntToStr1(i));
	}
	G.Invalidate();
}

void zSysGridDefine::OnButtonAddcolumn() 
{
	int nRow=G.GetFocusCell().row;
	G.InsertRow("",nRow);
	for(int i=0;i<G.GetRowCount();i++)
	{
		G.SetItemText(i,0,theApp.jns.IntToStr1(i));
	}
}


void zSysGridDefine::OnButtonInsrow() 
{
	G.SetColumnCount(G.GetColumnCount()+1);
	G.SetItemText(0,G.GetColumnCount()-1,"          ");
}

void zSysGridDefine::OnButtonInscol() 
{
	int nCol=G.GetFocusCell().col;
	G.InsertColumn("          ",JnDrawTextVCenLeft,nCol);
}


void zSysGridDefine::OnButtonDelrow() 
{
	int nRow=G.GetFocusCell().row;
	G.DeleteRow(nRow);
	G.Invalidate();
}

void zSysGridDefine::OnButtonDelcol() 
{
	int nCol=G.GetFocusCell().col;
	G.DeleteColumn(nCol);
	G.Invalidate();
}


void zSysGridDefine::OnButtonAutosize() 
{
	G.AutoSize();
}


void zSysGridDefine::DefineB001()
{
	G.m_bLineType=TRUE;
	G.SetRowCount(50);
	G.SetColumnCount(16);
	G.SetMargin(8);
	G.SetScrollGrid(TRUE);
	G.EnableSelection(FALSE);
	G.SetFixedRowCount(1);
	G.SetFixedColumnCount(1);

	for(int i=0;i<G.GetRowCount();i++)
	{
		G.SetItemText(i,0,theApp.jns.IntToStr1(i));
	}

	for(i=1;i<G.GetColumnCount();i++)
	{
		G.SetItemText(0,i,"  "+theApp.jns.IntToStr1(i)+"  ");
	}

	G.SetCellCombine(1,1,0,7);
	G.SetItemText(1,1,"商家基本情况");
	G.SetItemFormat(1,1,JnDrawTextAutoMuti);

	G.SetItemLeftLine(1,1,TRUE);
	G.SetItemTopLine(1,1,TRUE);
	G.SetItemRightLine(1,1,TRUE);
	G.SetItemBottomLine(1,1,TRUE);

	G.Invalidate();
}

void zSysGridDefine::OnButtonColwidth() 
{
	//设置指定范围内列的宽度
	zDlgS002 dlg;
	dlg.m_sCaption="列宽度";
	dlg.sTitle="设置单元格的列宽度";
	if(dlg.DoModal()==IDOK)
	{
		int nWidth=theApp.jns.StrToInt1(dlg.m_s1);
		CCellRange range=G.GetSelectedCellRange();
		for(int i=range.GetMinCol();i<=range.GetMaxCol();i++)
		{
			G.SetColumnWidth(i,nWidth);
		}
		G.Invalidate();
		G.ResetScrollBars();
	}
}


void zSysGridDefine::OnButtonRowheight() 
{
	//设置指定范围内列的宽度
	zDlgS002 dlg;
	dlg.m_sCaption="行高度";
	dlg.sTitle="设置单元格的行高度";
	if(dlg.DoModal()==IDOK)
	{
		int nHeight=theApp.jns.StrToInt1(dlg.m_s1);
		CCellRange range=G.GetSelectedCellRange();
		for(int i=range.GetMinRow();i<=range.GetMaxRow();i++)
		{
			G.SetRowHeight(i,nHeight);
		}
		G.Invalidate();
		G.ResetScrollBars();
	}	
}


void zSysGridDefine::OnButtonMargin() 
{
	//设置指定范围内列的宽度
	zDlgS002 dlg;
	dlg.m_sCaption="间距";
	dlg.sTitle="设置间距";
	if(dlg.DoModal()==IDOK)
	{
		G.SetMargin(theApp.jns.StrToInt1(dlg.m_s1));
	}	
}

void zSysGridDefine::OnButtonFixrow() 
{
	//设置指定范围内列的宽度
	zDlgS002 dlg;
	dlg.m_sCaption="固定行数";
	dlg.sTitle="设置固定行数";
	if(dlg.DoModal()==IDOK)
	{
		G.SetFixedRowCount(theApp.jns.StrToInt1(dlg.m_s1));
	}	
}


void zSysGridDefine::OnButtonFixcol() 
{
	//设置指定范围内列的宽度
	zDlgS002 dlg;
	dlg.m_sCaption="固定列数";
	dlg.sTitle="设置固定列数";
	if(dlg.DoModal()==IDOK)
	{
		G.SetFixedColumnCount(theApp.jns.StrToInt1(dlg.m_s1));
	}	
}

void zSysGridDefine::OnButtonEnable() 
{
	zDlgEnable dlg;
	int nRow=G.GetFocusCell().row;
	int nCol=G.GetFocusCell().col;
	dlg.m_b1=G.GetItemEnable(nRow,nCol);
	if(dlg.DoModal()==IDOK)
	{
		G.SetItemEnable(nRow,nCol,dlg.m_b1);
		G.Invalidate();
	}	
}

⌨️ 快捷键说明

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