//================================================================================================================
void MenuEditorSystem::OnMouseDown(WPARAM btnState, int x, int y)
{
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		if (dragStartX == -1)
		{
			dragStartX = x;
			dragStartY = y;
		}

		dragPrevX = x;
		dragPrevY = y;
		
		stampPressed = true;
		
		CalculateSelectedMousePosition(x, y);
		
		// Adds a new button to the menu from the selected button image in the button cache if in button
		// place mode
		AddButton();
		
		// Selects a button so it can be moved, if it is moving then this will be skipped
		// so that the button can be placed back on the menu with a left click
		bool goingToMove = MoveButtonStart();
		// If a button is being moved place the button at the clicked position if in button move mode
		if (!goingToMove) MoveButtonEnd();
		
		// Selects a button so it can be cloned, if it is moving then this will be skipped
		// so that the button clone can be added to the menu with a left click
		bool goingToClone = CloneButtonStart();
		// If a button is being moved place the button at the clicked position if in button clone mode
		if (!goingToClone) CloneButtonEnd();
		
		// Selects a button on the menu and deletes it if in button delete mode
		DeleteButton();
		
		// Selects the button to be resized if in button resize mode
		ResizeButtonStart();
		
		// If applicable, Add a text if in text mode
		AddText();
		
		// Selects a text so it can be moved, if it is moving then this will be skipped
		// so that the text can be placed back on the menu with a left click
		goingToMove = MoveTextStart();
		// If a text is being moved place the text at the clicked position if in text move mode
		if (!goingToMove) MoveTextEnd();
		
		// Selects a text so it can be cloned, if it is moving then this will be skipped
		// so that the text clone can be added to the menu with a left click
		goingToClone = CloneTextStart();
		// If a text is being moved place the text at the clicked position if in text clone mode
		if (!goingToClone) CloneTextEnd();
		
		// Selects a text on the menu and deletes it if in text delete mode
		DeleteText();
	}
}
//================================================================================================================
void HUDEditorSystem::OnMouseDown(WPARAM btnState, int x, int y)
{
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		stampPressed = true;
		
		CalculateSelectedMousePosition(x, y);
		
		// Adds a new image to the hud from the selected image image in the image cache if in image
		// place mode
		AddImage();
		
		// Selects a image so it can be moved, if it is moving then this will be skipped
		// so that the image can be placed back on the hud with a left click
		bool goingToMove = MoveImageStart();
		// If a image is being moved place the image at the clicked position if in image move mode
		if (!goingToMove) MoveImageEnd();
		
		// Selects a image so it can be cloned, if it is moving then this will be skipped
		// so that the image clone can be added to the hud with a left click
		bool goingToClone = CloneImageStart();
		// If a image is being moved place the image at the clicked position if in image clone mode
		if (!goingToClone) CloneImageEnd();
		
		// Selects a image on the hud and deletes it if in image delete mode
		DeleteImage();
		
		// Selects the button to be resized if in button resize mode
		ResizeImageStart();
		
		// If applicable, Add a text if in text mode
		AddText();
		
		// Selects a text so it can be moved, if it is moving then this will be skipped
		// so that the text can be placed back on the hud with a left click
		goingToMove = MoveTextStart();
		// If a text is being moved place the text at the clicked position if in text move mode
		if (!goingToMove) MoveTextEnd();
		
		// Selects a text so it can be cloned, if it is moving then this will be skipped
		// so that the text clone can be added to the hud with a left click
		goingToClone = CloneTextStart();
		// If a text is being moved place the text at the clicked position if in text clone mode
		if (!goingToClone) CloneTextEnd();
		
		// Selects a text on the hud and deletes it if in text delete mode
		DeleteText();
	}
}
Example #3
0
void Console::Append(const String& s) {
	if(s.IsEmpty()) return;
	if(console) {
		String t = Filter(s, sCharFilterNoCr);
		if(*t.Last() == '\n')
			t.Trim(t.GetCount() - 1);
		Puts(t);
		return;
	}
	int l, h;
	GetSelection(l, h);
	if(GetCursor() == GetLength()) l = -1;
	EditPos p = GetEditPos();
	SetEditable();
	MoveTextEnd();
	WString t = Filter(s, sAppf).ToWString();
	int mg = sb.GetReducedViewSize().cx / GetFont().GetAveWidth();
	if(wrap_text && mg > 4) {
		int x = GetColumnLine(GetCursor()).x;
		WStringBuffer tt;
		const wchar *q = t;
		while(*q) {
			if(x > mg - 1) {
				tt.Cat('\n');
				tt.Cat("    ");
				x = 4;
			}
			x++;
			if(*q == '\n')
				x = 0;
			tt.Cat(*q++);
		}
		Paste(tt);
	}
	else
		Paste(t);
	SetReadOnly();
	if(l >= 0) {
		SetEditPos(p);
		SetSelection(l, h);
	}
}
Example #4
0
bool LineEdit::Key(dword key, int count) {
	NextUndo();
	switch(key) {
	case K_CTRL_UP:
		ScrollUp();
		return true;
	case K_CTRL_DOWN:
		ScrollDown();
		return true;
	case K_INSERT:
		OverWriteMode(!IsOverWriteMode());
		break;
	}
	bool sel = key & K_SHIFT;
	switch(key & ~K_SHIFT) {
	case K_CTRL_LEFT:
		{
			PlaceCaret(GetPrevWord(cursor), sel);
			break;
		}
	case K_CTRL_RIGHT:
		{
			PlaceCaret(GetNextWord(cursor), sel);
			break;
		}
	case K_LEFT:
		MoveLeft(sel);
		break;
	case K_RIGHT:
		MoveRight(sel);
		break;
	case K_HOME:
		MoveHome(sel);
		break;
	case K_END:
		MoveEnd(sel);
		break;
	case K_UP:
		MoveUp(sel);
		break;
	case K_DOWN:
		MoveDown(sel);
		break;
	case K_PAGEUP:
		MovePageUp(sel);
		break;
	case K_PAGEDOWN:
		MovePageDown(sel);
		break;
	case K_CTRL_PAGEUP:
	case K_CTRL_HOME:
		MoveTextBegin(sel);
		break;
	case K_CTRL_PAGEDOWN:
	case K_CTRL_END:
		MoveTextEnd(sel);
		break;
	case K_CTRL_C:
	case K_CTRL_INSERT:
		Copy();
		break;
	case K_CTRL_A:
		SelectAll();
		break;
	default:
		if(IsReadOnly())
			return MenuBar::Scan(WhenBar, key);
		switch(key) {
		case K_DELETE:
			DeleteChar();
			break;
		case K_BACKSPACE:
		case K_SHIFT|K_BACKSPACE:
			Backspace();
			break;
	   	case K_SHIFT_TAB:
			AlignChar();
			break;
		case K_CTRL_Y:
		case K_CTRL_L:
			if(cutline) {
				CutLine();
				break;
			}
		default:
			if(InsertChar(key, count, true))
				return true;
			return MenuBar::Scan(WhenBar, key);
		}
		return true;
	}
	Sync();
	return true;
}