void GUIEditMultiString::CalcCursorXY()
{
	InvalidateCursor();

	if(!GUIInputText::textBuffer)				return;

	if(!strCount)	
	{
		SetStartCursorPos();
		return;
	}

	if(isResizeable)
		ResizeRect();

	int32 symbolPos			=	currentPos;

	ParsedString *ps		=	(ParsedString *)(*parsedStrings.Begin());
	VList::Iterator iStr	=	parsedStrings.Begin();
	for(int32 yPos = 0; yPos < strCount; ++iStr, ++yPos)
	{
		ps				=	(ParsedString *)(*iStr);
		if(symbolPos	<	ps->count)
		{
			break;
		}
		else if(symbolPos == ps->count)
		{
			VList::Iterator usedStr	=	iStr;
			++usedStr, ++yPos;

			if(		yPos < strCount 
				&&	usedStr != parsedStrings.End() 
				&& isKeyDown )
			{
				ps				=	(ParsedString *)(*usedStr);
				symbolPos	=	0;
			}

			break;
		}
		symbolPos		-=	ps->count;
	}

	int32 strWidth		=	pFont->GetStringWidth(ps->pStr, ps->count);
	int32 width			=	pFont->GetStringWidth(ps->pStr, symbolPos);
	
	if(align & Font::EAP_RIGHT)
	{
		cursorX		=	ps->x - strWidth + width;
	}
	else if(align & Font::EAP_HCENTER)
	{
		cursorX		=	ps->x - (strWidth >> 1) + width;
	}
Beispiel #2
0
void emMainPanel::SliderPanel::Input(
	emInputEvent & event, const emInputState & state, double mx, double my
)
{
	double dy;
	bool mo;

	mo = (mx>0.05 && my>0.0 && mx<1.0 && my<GetHeight()-0.05);
	if (MouseOver!=mo) {
		MouseOver=mo;
		InvalidateCursor();
		InvalidatePainting();
	}

	if (MouseOver && event.IsMouseEvent()) {
		if (event.IsKey(EM_KEY_LEFT_BUTTON)) {
			if (event.GetRepeat()==0 && !Pressed) {
				Pressed=true;
				PressMY=my;
				PressSliderY=MainPanel.SliderY;
				InvalidatePainting();
			}
			else if (event.GetRepeat()==1) {
				if (Pressed) {
					Pressed=false;
					MainPanel.UpdateCoordinates();
					InvalidatePainting();
				}
				MainPanel.DoubleClickSlider();
			}
		}
		event.Eat();
	}

	if (Pressed) {
		dy=(my-PressMY)*GetLayoutWidth();
		if (state.Get(EM_KEY_SHIFT)) {
			dy=(dy+MainPanel.SliderY-PressSliderY)*0.25+PressSliderY-MainPanel.SliderY;
		}
		MainPanel.DragSlider(dy);
	}

	if (Pressed && !state.Get(EM_KEY_LEFT_BUTTON)) {
		Pressed=false;
		MainPanel.UpdateCoordinates();
		InvalidatePainting();
	}
}
void GUIEditMultiString::Update()
{
	if (isResizeable)
	{
		Rect rc = GUIMultiString::GetRect();
		bool changed = false;
		if (rc.dx != realRect.dx)
		{
			int32 spd = (realRect.dx - rc.dx) / 3;
			changed = true;
			if (rc.dx < realRect.dx)
			{
				spd++;
				rc.dx += spd;
				if (rc.dx > realRect.dx)
				{
					rc.dx = realRect.dx;
				}
			}
			else
			{
				spd--;
				rc.dx += spd;
				if (rc.dx < realRect.dx)
				{
					rc.dx = realRect.dx;
				}
			}
		}
		if (rc.dy != realRect.dy)
		{
			int32 spd = (realRect.dy - rc.dy) / 3;
			changed = true;
			if (rc.dy < realRect.dy)
			{
				spd++;
				rc.dy += spd;
				if (rc.dy > realRect.dy)
				{
					rc.dy = realRect.dy;
				}
			}
			else
			{
				spd--;
				rc.dy += spd;
				if (rc.dy < realRect.dy)
				{
					rc.dy = realRect.dy;
				}
			}
		}
		if (changed)
		{
			GUIMultiString::SetRect(rc);
		}
	}

	if(GUISystem::Instance()->GetFocus() != this)
		return;

	GUIInputText::Update();

	InvalidateCursor();
}