Exemple #1
0
void ATOM_Edit::onChar(ATOM_WidgetCharEvent *event)
{
	ATOM_STACK_TRACE(ATOM_Edit::onChar);

	// 只读情况,不允许输入
	if(EDITTYPE_READONLY & _editType)
	{
		return;
	}
	bool bSelect = false;
	unsigned short mbcc = event->mbcc;
	//if (mbcc == '\\')
	//{
	//	return;
	//}
	//ATOM_Edit不处理的键值
	if( mbcc>= 0 && mbcc < 32 && mbcc != 8)
	{
		return;
	}
	if(_cusorOldPosition != _cusorNewPosition)
	{
		size_t s = 0,t = 0;
		_selectString = getSelectString(s,t);
		if(!_selectString.empty())
		{
			deleteString(s,t);
			bSelect = true;
		}

	}
	//退格键
	if (mbcc == 8)
	{
		if(!bSelect)
			backSpace();
		return;
	}


	//处理
	char *tc = reinterpret_cast<char*>(&mbcc);
	char tc2[3];
	ZeroMemory(tc2, sizeof(tc2));
	memcpy(tc2, tc, 2);

	insertText(tc2);
}
Exemple #2
0
wxString	MPInfo::getPolygons(){
	wxString t_ret;
	getSelectString(MPbase,"SELECT count(*) FROM MP_POLY;",t_ret);
	return t_ret;
}
Exemple #3
0
wxString	MPInfo::getLines(){
	wxString t_ret;
	getSelectString(MPbase,"SELECT count(*) FROM MP_LINE;",t_ret);
	return t_ret;
}
Exemple #4
0
wxString	MPInfo::getID(){
	wxString t_ret;
	getSelectString(MPbase,"SELECT id FROM MP_ID;",t_ret);
	return t_ret;
}
Exemple #5
0
wxString	MPInfo::getName() {
	wxString t_ret;
	getSelectString(MPbase,"SELECT name FROM MP_ID;",t_ret);
	return t_ret;
}
Exemple #6
0
void ATOM_Edit::onKeyDown(ATOM_WidgetKeyDownEvent *event)
{
	ATOM_STACK_TRACE(ATOM_Edit::onKeyDown);

	// 只读情况,不允许输入
	if(EDITTYPE_READONLY & _editType)
	{
		return;
	}

	switch(event->key)
	{
	case KEY_LEFT:
		moveCursor(-1);
		break;

	case KEY_RIGHT:
		moveCursor(1);
		break;

	case KEY_DELETE:
		deleteChar();
		break;

	case KEY_HOME:
		moveCursor(-getStringLength());
		break;

	case KEY_END:
		moveCursor(getStringLength());
		break;

	case KEY_UP:
	case KEY_DOWN:
	case KEY_RETURN:
	case KEY_KP_ENTER:
	case KEY_TAB:
	case KEY_ESCAPE:
	case KEY_SPACE:
	case KEY_COLON:
		{
			ATOM_EditSysKeyEvent keyevent(getId(), event->key);
			_parent->handleEvent(&keyevent);
		}
		break;

	case KEY_v:
		if(GetAsyncKeyState(VK_LCONTROL) &0x8000 || GetAsyncKeyState(VK_RCONTROL) &0x8000)
		{
			pasteFromClipBoard();
		}
		break;
	case KEY_a:
		if(GetAsyncKeyState(VK_LCONTROL) &0x8000 || GetAsyncKeyState(VK_RCONTROL) &0x8000)
		{
			setCursor(_startPosition+_string.size());
			_cusorOldPosition.x = _offsetX;
			_cusorOldPosition.y = 0;
			_cusorNewPosition = _cursorPosition;
		}
		break;
	case KEY_c:
		if(GetAsyncKeyState(VK_LCONTROL) &0x8000|| GetAsyncKeyState(VK_RCONTROL)&0x8000)
		{	
			size_t s = 0,t = 0;
			_selectString = getSelectString(s,t);
			if(_selectString.empty())
				return;
			if(OpenClipboard(NULL))
			{

				HGLOBAL hmem=GlobalAlloc(GHND,_selectString.size()+1);
				char *pmem=(char*)GlobalLock(hmem);

				EmptyClipboard();
				memcpy(pmem,_selectString.c_str(),_selectString.size());
				SetClipboardData(CF_TEXT,hmem);
				CloseClipboard();
				GlobalFree(hmem); 
			}
		}
		break;
	case KEY_x:
		if(GetAsyncKeyState(VK_LCONTROL)&0x8000 || GetAsyncKeyState(VK_RCONTROL)&0x8000)
		{
			size_t s = 0,t = 0;
			_selectString = getSelectString(s,t);
			deleteString(s,t);
			if(_selectString.empty())
				return;
			if(OpenClipboard(NULL))
			{

				HGLOBAL hmem=GlobalAlloc(GHND,_selectString.size()+1);
				char *pmem=(char*)GlobalLock(hmem);

				EmptyClipboard();
				memcpy(pmem,_selectString.c_str(),_selectString.size());
				SetClipboardData(CF_TEXT,hmem);
				CloseClipboard();
				GlobalFree(hmem); 
			}
		}
		break;
	}
	if(_parent)
	{
		_parent->queueEvent (ATOM_NEW(ATOM_WidgetKeyDownEvent, getId(),event->key,event->keymod), ATOM_APP);
	}
}