void CTWenUGCtrlEx::AppendRow_ButtonAdd(void)
{
	int nRow = CUGCtrl::GetNumberRows();

	if(nRow > 0)
	{
		CUGCell cell;
		GetCell(0, nRow-1, &cell);

		if(cell.GetBitmap()==GetBitmap(m_nIndexBMP_Add))//如果有增加行
		{
			return;
		}
	}

	if(AppendRow() != UG_SUCCESS) return;

	int nCol = GetNumberCols();

	JoinCells(1, nRow, nCol-1, nRow);

	if(nCol>1)
	{
		QuickSetBackColor(1, nRow, RGB(240,240,240));
		QuickSetBorder(1, nRow, UG_BDR_RAISED|UG_BDR_LTHIN|UG_BDR_RTHIN|UG_BDR_TTHIN|UG_BDR_BTHIN); 
	}

	QuickSetBitmap(0, nRow, m_nIndexBMP_Add);
}
void CDDBaseGrid::SetMultiColHeading(int col1, int row1, int col2, int row2, CString headingStr)
{
   CUGCell cell;

   int res = JoinCells(col1, row1, col2, row2);
	GetCell(col1, row1, &cell);
   cell.SetCellTypeEx(UGCT_NORMALMULTILINE);
   SetCell(col1, row1, &cell);
   QuickSetText(col1, row1, headingStr);
}
Exemple #3
0
/***************************************************
OnSetup
	This function is called just after the grid window 
	is created or attached to a dialog item.
	It can be used to initially setup the grid
****************************************************/
void MyCug::OnSetup(){
	// setup rows and columns
	int rows = 30;
	int cols = 5;
	SetNumberRows(rows);
	SetNumberCols(cols);

	// initalize masked edit control, font, and border style
	m_pen.CreatePen (PS_SOLID,1,RGB(0,0,0));
	m_font.CreateFont (16,0,0,0,500,0,0,0,0,0,0,0,0,"Arial");
	SetDefFont (&m_font);

	// setup headings layout
	SetSH_Width (0);
	SetTH_NumberRows (2);
	SetTH_Height(40);
	SetTH_RowHeight(-1,20);
	SetTH_RowHeight(-2,20);
	JoinCells (0,-2,0,-1);
	JoinCells (2,-2,3,-2);
	JoinCells (4,-2,4,-1);
	// setup headings text
	QuickSetText (0,-2,"Date");
	QuickSetText (1,-2,"Number");
	QuickSetText (1,-1,"Type");
	QuickSetText (2,-2,"Payee");
	QuickSetText (2,-1,"Account");
	QuickSetText (3,-1,"Memo");
	QuickSetText (4,-2,"Deposit");
	EnableExcelBorders (FALSE);
	EnableCellOverLap (FALSE);

	// populate the first row group with data
	QuickSetText( 0, 0, "10/10/2001" );
	QuickSetText( 1, 0, "12203" );
	QuickSetText( 1, 1, "CHK" );
	QuickSetText( 2, 0, "Bell" );
	QuickSetText( 2, 1, "Phone" );
	QuickSetText( 4, 0, "45.50" );
}
Exemple #4
0
/***************************************************
OnGetCell
	This message is sent everytime the grid needs to
	draw a cell in the grid. At this point the cell
	class has been filled with the information to be
	used to draw the cell. The information can now be
	changed before it is used for drawing
****************************************************/
void MyCug::OnGetCell(int col,long row,CUGCell *cell){
	// set border color for each cell
	cell->SetBorderColor (&m_pen);

	if (row < 0)						// top heading
		cell->SetBorder (UG_BDR_RAISED);
	else if (row > 0 && row % 2){		// lower row
		if (col == 1)
			cell->SetMask ("???");
		else if (col == 2){
			// create and fill-in dropbox menu
			cell->SetCellType (UGCT_DROPLIST);
			cell->SetCellTypeEx (UGCT_DROPLISTHIDEBUTTON);
			cell->SetLabelText ("Phone\nCar\nR&D\nOffice Supplies");
		}
		// define back color and border style, for each cell in lower row
		cell->SetBackColor (RGB(255,255,128));
		cell->SetBorder (UG_BDR_RTHIN|UG_BDR_BTHIN);
	}
	else{								// upper row
		if (col == 0)
			cell->SetMask ("99/99/99");
		else if (col == 1)
			cell->SetMask ("999999");
		else if (col == 2){
			// create and fill-in dropbox menu
			JoinCells (col,row,col+1,row);
			cell->SetCellType (UGCT_DROPLIST);
			cell->SetCellTypeEx (UGCT_DROPLISTHIDEBUTTON);
			cell->SetLabelText ("The Code Project\nBell\nZippy Print & Copy\nAce Paper Co.");
		}
		cell->SetBorder (UG_BDR_RTHIN);
	}

	if ( col == 4 && row >= 0 )
	{	// deposit column, set its allignment
		cell->SetAlignment( UG_ALIGNRIGHT );
	}
}
Exemple #5
0
/***************************************************
OnSetup
	This function is called just after the grid window 
	is created or attached to a dialog item.
	It can be used to initially setup the grid
****************************************************/
void CRealTimeGrid::OnSetup(){
	
	int y;
	int ROWS = 25;
	int COLS = 6;
	int iHeight;
	CUGCell cell;
	CString strTemp;
	CDC* pDC;

	m_pro1Index = AddCellType( &m_pro1 );
	m_pro1.SetCanAdjust( FALSE );
	m_buttonIndex = AddCellType( &m_button );

	pDC = GetDC();
	iHeight = -MulDiv( 10, GetDeviceCaps( pDC->m_hDC, LOGPIXELSY), 72 );
	m_font1.CreateFont( iHeight,0,0,0,800,0,0,0,0,0,0,0,0, _T( "Arial" ) );
	m_font2.CreateFont( iHeight,0,0,0,500,0,0,0,0,0,0,0,0, _T( "Arial" ) );
	ReleaseDC( pDC );
	
	SetDefFont(&m_font2);

	SetUniformRowHeight(TRUE);
	SetDefRowHeight(25);
	SetNumberCols(COLS);
	SetNumberRows(ROWS);
	SetDoubleBufferMode(1);
	Set3DHeight( 2 );

	SetTH_Height( 0 );
	SetSH_Width( 100 );

	for( y = 0 ; y < ROWS ; y++ )
	{
		QuickSetCellType(0,y,m_pro1Index);
		QuickSetAlignment(0,y,UG_ALIGNCENTER|UG_ALIGNVCENTER);
		QuickSetText( 0, y, _T( "20" ) );
		QuickSetTextColor(0,y,RGB(0,0,0));
		QuickSetHTextColor(0,y,RGB(0,0,0));
		JoinCells(0,y,2,y);

		QuickSetAlignment(3,y,UG_ALIGNCENTER|UG_ALIGNVCENTER);
		QuickSetText(3,y,_T( "Normal" ) );
		//QuickSetFont(3,y,&m_font2);

		strTemp.Format( _T( "Sensor %d" ), y );
		QuickSetText( -1, y, strTemp );
	}

	GetColDefault( 4, &cell );
	cell.SetCellType( m_buttonIndex );
	cell.SetText( _T( "Reset" ) );
	cell.SetAlignment( UG_ALIGNCENTER | UG_ALIGNVCENTER );
	cell.SetBackColor( GetSysColor( COLOR_BTNFACE ) );
	SetColDefault( 4, &cell );

	GetColDefault( 5, &cell );
	cell.SetCellType( UGCT_CHECKBOX );
	cell.SetLabelText( _T( "Enabled" ) );
	cell.SetBool( TRUE );
	cell.SetAlignment( UG_ALIGNVCENTER );
	SetColDefault( 5, &cell );
	SetColWidth( 5, GetColWidth( 5 ) + 20 );

	SetTimer( TIMERID, 100, NULL);
}
Exemple #6
0
/***************************************************
OnSetup
	This function is called just after the grid window 
	is created or attached to a dialog item.
	It can be used to initially setup the grid
****************************************************/
void MyCug::OnSetup(){

	// initailize local vatiables
	int rows = 24;
	int cols = 14;
	int i,j;
	CString tmpNum;
	CUGCell cell;

	// setup rows and columns
	SetNumberRows(rows);
	SetNumberCols(cols);

	// fill-in cells with numbers
	// limit number of decimal places to 0
	GetCell (0,0,&cell);
	cell.SetNumberDecimals(0);
	cell.SetAlignment (UG_ALIGNRIGHT);
	for (i = 0; i < cols; i++)
		for (j = 0; j < rows; j++) {
			cell.SetNumber(rand()%1000);
			SetCell (i,j,&cell);
		}

	GetColDefault (10,&cell);
	m_pen.CreatePen (PS_SOLID,1,RGB(255,0,0));
	cell.SetBorderColor (&m_pen);
	cell.SetBorder (UG_BDR_LTHIN);
	SetColDefault (10,&cell);
	// create 3 column side heading
	SetSH_NumberCols(2);
	// ensure that side heading is large enough to fit 3 cols
	SetSH_Width(80);			
	SetSH_ColWidth(-1,30);		// resize columns in the side heading
	SetSH_ColWidth(-2,50);

	// create 3 row top heading
	SetTH_NumberRows(3);
	// ensure that top heading is large enough to fit 3 rows
	SetTH_Height(60);			
	SetTH_RowHeight(-1,20);		// resize rows in the top heading
	SetTH_RowHeight(-2,20);
	SetTH_RowHeight(-3,20);

	// join cells and assign text values in the top headings
	JoinCells (0,-3,9,-3);
	JoinCells (10,-3,13,-3);
	QuickSetText (0,-3,"Week-days");
	QuickSetTextColor (10,-3,RGB(255,0,10));
	QuickSetText (10,-3,"Week-end");
	for (i=0;i<cols;i+=2){
		JoinCells (i,-2,i+1,-2);
		if (i >= 10){
			QuickSetTextColor (i,-1,RGB(255,0,10));
			QuickSetTextColor (i+1,-1,RGB(255,0,10));
			QuickSetTextColor (i,-2,RGB(255,0,10));
		}
		QuickSetText (i,-1,"Sched.");
		QuickSetText (i+1,-1,"To Do");
	}
	QuickSetText (0,-2,"Monday");
	QuickSetText (2,-2,"Tuesday");
	QuickSetText (4,-2,"Wednesday");
	QuickSetText (6,-2,"Thursday");
	QuickSetText (8,-2,"Friday");
	QuickSetText (10,-2,"Satruday");
	QuickSetText (12,-2,"Sunday");

	// join cells and assign text in the side headings
	j = 8;
	for (i=0;i<rows;i+=2) {
		JoinCells (-2,i,-2,i+1);
		tmpNum.Format ("%d",j++);
		if (j < 13)
			tmpNum += " AM";
		else 
			tmpNum += " PM";
		QuickSetText (-2,i,tmpNum);
		QuickSetText (-1,i,":00");
		QuickSetText (-1,i+1,":30");
	}
}