Пример #1
0
static TextPos DecrementTextPos(TextBuffer* textbuf, TextPos pos)
{
	if ( !pos.x && !pos.y )
		return pos;
	if ( !pos.x )
		return TextPos(textbuf->Width(), pos.y-1);
	return TextPos(pos.x-1, pos.y);
}
Пример #2
0
			void GuiDocumentCommonInterface::EditTextInternal(TextPos begin, TextPos end, const Func<void(TextPos, TextPos, vint&, vint&)>& editor)
			{
				// save run before editing
				if(begin>end)
				{
					TextPos temp=begin;
					begin=end;
					end=temp;
				}
				Ptr<DocumentModel> originalModel=documentElement->GetDocument()->CopyDocument(begin, end, true);
				if(originalModel)
				{
					// edit
					vint paragraphCount=0;
					vint lastParagraphLength=0;
					editor(begin, end, paragraphCount, lastParagraphLength);

					// calculate new caret
					TextPos caret;
					if(paragraphCount==0)
					{
						caret=begin;
					}
					else if(paragraphCount==1)
					{
						caret=TextPos(begin.row, begin.column+lastParagraphLength);
					}
					else
					{
						caret=TextPos(begin.row+paragraphCount-1, lastParagraphLength);
					}
					documentElement->SetCaret(caret, caret, true);
					documentControl->TextChanged.Execute(documentControl->GetNotifyEventArguments());

					// save run after editing
					Ptr<DocumentModel> inputModel=documentElement->GetDocument()->CopyDocument(begin, caret, true);

					// submit redo-undo
					GuiDocumentUndoRedoProcessor::ReplaceModelStruct arguments;
					arguments.originalStart=begin;
					arguments.originalEnd=end;
					arguments.originalModel=originalModel;
					arguments.inputStart=begin;
					arguments.inputEnd=caret;
					arguments.inputModel=inputModel;
					undoRedoProcessor->OnReplaceModel(arguments);
				}
			}
Пример #3
0
void CreditsInit()
{

    SDL_Color textColor = { 255, 255, 255 };
    ImageLoad("../../Resource/matrix.png", &c_background);
    TextLoad(&t, "../../Resource/alien.ttf", 30);
    TextPos(&t, 20, 250);
    TextColor(&t, &textColor);

    ButtonInit(&back, "../../Resource/back.png", 700, 500);

}
Пример #4
0
int32 STimeline::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
	// Used to track the layer ID we will return.
	int32 RetLayerId = LayerId;
	const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();

	bool bEnabled = ShouldBeEnabled( bParentEnabled );
	const ESlateDrawEffect::Type DrawEffects = bEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
		
	const FLinearColor ColorAndOpacitySRGB = InWidgetStyle.GetColorAndOpacityTint();
	static const FLinearColor SelectedBarColor(FLinearColor::White);

	// Paint inside the border only. 
	const FVector2D BorderPadding = FTaskGraphStyle::Get()->GetVector("TaskGraph.ProgressBar.BorderPadding");
	const FSlateRect ForegroundClippingRect = AllottedGeometry.GetClippingRect().InsetBy(FMargin(BorderPadding.X, BorderPadding.Y)).IntersectionWith(MyClippingRect);

	const float OffsetX = DrawingOffsetX; // BorderPadding.X
	const float Width = DrawingGeometry.Size.X; // AllottedGeometry.Size.X - - 2.0f * BorderPadding.X

	FSlateFontInfo MyFont( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Regular.ttf"), 10 );

	//FSlateDrawElement::MakeBox(
	//  OutDrawElements,
	//	RetLayerId++,
	//	AllottedGeometry.ToPaintGeometry(),
	//	BackgroundImage,
	//	MyClippingRect,
	//	DrawEffects,
	//	ColorAndOpacitySRGB
	//);	
	
	// Create line points
	const float RoundedMax = FMath::CeilToInt( MaxValue );
	const float RoundedMin = FMath::FloorToInt( MinValue );
	const float TimeScale = MaxValue - MinValue;
	const int32 NumValues = FMath::FloorToInt( AllottedGeometry.Size.X * Zoom / FixedLabelSpacing );

	TArray< FVector2D > LinePoints;
	LinePoints.AddUninitialized( 2 );
	
	{
		LinePoints[0] = FVector2D( OffsetX, BorderPadding.Y + 1.0f );
		LinePoints[1] = FVector2D( OffsetX + Width, BorderPadding.Y + 1.0f );

		// Draw lines
		FSlateDrawElement::MakeLines( 
			OutDrawElements,
			RetLayerId++,
			AllottedGeometry.ToPaintGeometry(),
			LinePoints,
			MyClippingRect,
			ESlateDrawEffect::None,
			FLinearColor::White
			);
	}

	const FVector2D TextDrawSize = FontMeasureService->Measure(TEXT("0.00"), MyFont);
	const float LineHeight = AllottedGeometry.Size.Y - BorderPadding.Y - TextDrawSize.Y - 2.0f;
	
	for( int32 LineIndex = 0; LineIndex <= NumValues; LineIndex++ )
	{
		const float NormalizedX = (float)LineIndex / NumValues;
		const float LineX = Offset + NormalizedX * Zoom;
		if( LineX < 0.0f || LineX > 1.0f )
		{
			continue;
		}

		const float LineXPos =  OffsetX + Width * LineX;
		LinePoints[0] = FVector2D( LineXPos, BorderPadding.Y );
		LinePoints[1] = FVector2D( LineXPos, LineHeight );

		// Draw lines
		FSlateDrawElement::MakeLines( 
			OutDrawElements,
			RetLayerId++,
			AllottedGeometry.ToPaintGeometry(),
			LinePoints,
			MyClippingRect,
			ESlateDrawEffect::None,
			FLinearColor::White
			);

		FString ValueText( FString::Printf( TEXT("%.2f"), MinValue + NormalizedX * TimeScale ) );
		FVector2D DrawSize = FontMeasureService->Measure(ValueText, MyFont);
		FVector2D TextPos( LineXPos - DrawSize.X * 0.5f, LineHeight );

		if( TextPos.X < 0.0f )
		{
			TextPos.X = 0.0f;
		}
		else if( (TextPos.X + DrawSize.X) > AllottedGeometry.Size.X )
		{
			TextPos.X = OffsetX + Width - DrawSize.X;
		}

		FSlateDrawElement::MakeText( 
			OutDrawElements,
			RetLayerId,
			AllottedGeometry.ToOffsetPaintGeometry( TextPos ),
			ValueText,
			MyFont,
			MyClippingRect,
			ESlateDrawEffect::None,
			FLinearColor::White
			);
	}

	// Always draw lines at the start and at the end of the timeline
	{
		LinePoints[0] = FVector2D( OffsetX, BorderPadding.Y );
		LinePoints[1] = FVector2D( OffsetX, LineHeight );

		// Draw lines
		FSlateDrawElement::MakeLines( 
			OutDrawElements,
			RetLayerId++,
			AllottedGeometry.ToPaintGeometry(),
			LinePoints,
			MyClippingRect,
			ESlateDrawEffect::None,
			FLinearColor::White
			);
	}

	{
		LinePoints[0] = FVector2D( OffsetX + Width, BorderPadding.Y );
		LinePoints[1] = FVector2D( OffsetX + Width, LineHeight );

		// Draw lines
		FSlateDrawElement::MakeLines( 
			OutDrawElements,
			RetLayerId++,
			AllottedGeometry.ToPaintGeometry(),
			LinePoints,
			MyClippingRect,
			ESlateDrawEffect::None,
			FLinearColor::White
			);
	}

	return RetLayerId - 1;
}
Пример #5
0
void ConnectorGraphics::updatePosition()
{
  QPainterPath Path;

  QPointF FromPos;
  QPointF ToPos;

  if (m_FromOutNode == NODE_PROD)
    FromPos = mp_FromItem->getProducedIOPosition();
  else
    FromPos = mp_FromItem->getUpOutIOPosition();

  if (m_ToInNode == NODE_REQ)
    ToPos = mp_ToItem->getRequiredIOPosition();
  else if (m_ToInNode == NODE_US)
    ToPos = mp_ToItem->getUsedIOPosition();
  else
    ToPos = mp_ToItem->getUpInIOPosition();


  Path.moveTo(FromPos);

  // intermediate position helps for correct bezier curve shape
  // and for positionning of variable names as curve label
  QPointF InterPos;


  if (FromPos.y() < ToPos.y()) // "From" slot (source) is upper than "To" slot (destination)
  {

    InterPos = QPointF(FromPos.x()+((ToPos.x()-FromPos.x())/2.0),
                        FromPos.y()+((ToPos.y()-FromPos.y())/2.0));

    Path.quadTo(QPointF(FromPos.x(),InterPos.y()),InterPos);
    Path.quadTo(QPointF(ToPos.x(),InterPos.y()),ToPos);
  }
  else // "From" slot (source) is lower than "To" slot (destination)
  {
    InterPos = QPointF(FromPos.x()+((ToPos.x()-FromPos.x())/2.0)-200,
                       FromPos.y()+((ToPos.y()-FromPos.y())/2.0));

    Path.quadTo(QPointF(FromPos.x()-200,FromPos.y()+200),
                InterPos);
    Path.quadTo(QPointF(ToPos.x()-200,ToPos.y()-200),
                ToPos);
  }

  setPath(Path);



  // variables names
  mp_VarsText->setText(m_Variables.join("\n"));

  QPointF TextPos(InterPos.x()-mp_VarsText->boundingRect().width()/2,
                  InterPos.y()-mp_VarsText->boundingRect().height()/2);

  mp_VarsText->setPos(TextPos);



  // variables names background box
  mp_VarsTextBox->setRect(TextPos.x()-2,TextPos.y()-2,
                          mp_VarsText->boundingRect().width()+4, mp_VarsText->boundingRect().height()+4);
}
Пример #6
0
	/***************************************************************
	* Function: Parser::streamline()
	* Purpose : Streamline an XML code string
	* Initial : Maxime Chevalier-Boisvert on October 20, 2008
	****************************************************************
	Revisions and bug fixes:
	*/
	std::string Parser::streamline(const std::string& rawInput, PosVector& positions)
	{
		// Declare a string for the streamlined output
		std::string output;

		// reserve space in the string
		output.reserve(rawInput.length());

		// Declare characters for stream processing
		unsigned char lastChar = '\0';
		unsigned char thisChar = '\0';
		unsigned char nextChar = '\0';

		// Variable to tell if we are in a CDATA region
		bool inCDATA = false;

		// Variable to tell if we are in a comment
		bool inComment = false;

		// Variable to indicate the current line number
		size_t lineNumber = 1;

		// Variable to indicate the start of the current line
		size_t lineStart = 0;

		// For each character of the input
		for (size_t charIndex = 0; charIndex < rawInput.length(); ++charIndex)
		{
			// Read this character and the next
			thisChar = rawInput[charIndex];
			nextChar = rawInput[charIndex + 1];

			// Construct the text position of the current character
			TextPos charPos(lineNumber, charIndex - lineStart + 1);

			// If this character is a newline
			if (thisChar == '\n')
			{
				// Increment the line number
				++lineNumber;

				// Store the line start index
				lineStart = charIndex + 1;
			}

			// If this is the start of a comment
			if (tokenMatch(rawInput, charIndex, "<!--") && !inCDATA && !inComment)
			{
				// We are now in a comment
				inComment = true;

				// Move past the comment opening
				charIndex += 3;
				continue;
			}

			// If this is the end of a comment
			if (tokenMatch(rawInput, charIndex, "-->") && inComment)
			{
				// We are no longer in a comment
				inComment = false;

				// Move past the comment closing
				charIndex += 2;
				continue;
			}

			// If this is the start of a CDATA region
			if (tokenMatch(rawInput, charIndex, "<![CDATA[") && !inCDATA && !inComment)
			{
				// We are now in a CDATA region
				inCDATA = true;
			}

			// If this is the end of a CDATA region
			if (tokenMatch(rawInput, charIndex, "]]>") && inCDATA)
			{
				// We are no longer in a CDATA region
				inCDATA = false;
			}

			// If we are inside a comment
			if (inComment)
			{
				// Skip this character
				continue;
			}

			// If we are not in a CDATA region
			if (!inCDATA)
			{
				// If this character is whitespace
				if (isspace(thisChar))
				{
					// Consider it a space
					thisChar = ' ';
				}

				// If the next character is whitespace
				if (isspace(nextChar))
				{
					// Consider it a space
					nextChar = ' ';
				}

				// If this character is whitespace
				if (thisChar == ' ')
				{
					// If the next char is whitespace,
					// or the last was an opening delimiter or a space,
					// or the next is a closing delimiter
					if (nextChar == ' ' ||
						lastChar == '<' || lastChar == '>' || lastChar == ' ' ||
						nextChar == '<' || nextChar == '>' || nextChar == '\0')
					{
						// Ignore this space
						continue;
					}
				}
			}

			// Add this character to the stream
			output += thisChar;

			// Store the last character added
			lastChar = thisChar;

			// Store the text position of this character
			positions.push_back(charPos);
		}

		// Add a final text position for the string terminator
		positions.push_back(TextPos(lineNumber, rawInput.length() - lineStart + 1));

		// Ensure that there is a position for each character in the output
		assert (output.length() + 1 == positions.size());

		// Return the streamlined XML stream
		return output;
	}
Пример #7
0
void TextTerminal::UpdateCursor(TextBuffer* textbuf)
{
	textbuf->SetCursorPos(TextPos(column, line));
}