AMIO编辑器开发(九):键盘的左右键交互

与之前的键盘上下键一样的封装逻辑,这里就不复重了。

改变是:绘制缓冲区字符串时,要加上列的偏移量:

void EditView::drawText(HDC hdc){
	int OFFSET = 0;
	HFONT hFont = CreateFontIndirect(&logFont);
	SelectObject(hdc, hFont);
	//-----------------------
	int firstRowIndex = lpEditViewAdapter->firstVisibleRowIndex;
	int rowCount = lpEditViewAdapter->visibleRowCount;
	int columnIndex = lpEditViewAdapter->firstVisibleColumnIndex;
	TCHAR * textBuffer = NULL;
	RECT textRect;
	int incHeight = getCharHeight();
	int i = 0;
	int j = 0;
	VIEW_RECT viewRect = getArea();
	// initial RECT of draw text in editor area.
	textRect.left = viewRect.left;
	textRect.right = viewRect.right - 1;
	textRect.top = viewRect.top;
	textRect.bottom = textRect.top + incHeight;

	OFFSET = lpEditViewAdapter->firstVisibleColumnIndex;
	for (i = firstRowIndex, j = 0; i <= firstRowIndex + rowCount; i++, j++){
		// move to row
		textBuffer = lpEditViewAdapter->editTextBuffer[0] + j * GOLBAL_MEM_COLUMN_MAX + OFFSET;
		// move to first visible column
		textBuffer += columnIndex;
		// draw text on screen
		DrawText(hdc, textBuffer, lstrlen(textBuffer), &textRect, DT_LEFT);
		// refresh vertical parameter of RECT.
		textRect.top = incHeight * (j+1);
		textRect.bottom = textRect.top + incHeight;
		}// end for
	//-----------------------
	DeleteObject(hFont);

	}

最右的边界检测没有做,等以后再作为BUG微调:

下一步,就是绑定滚动条以及滚动条的UI。

转载于:https://www.cnblogs.com/aimo/archive/2012/05/05/2484424.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值