Exemplo n.º 1
0
bool LineEdit::OnDragDropFinish(UIElement* source)
{
    if (source && editable_)
    {
        // If the UI element in question has a drag-and-drop content string defined, use it instead of element text
        if (source->GetVars().Contains(VAR_DRAGDROPCONTENT))
        {
            SetText(source->GetVar(VAR_DRAGDROPCONTENT).GetString());
            return true;
        }

        StringHash sourceType = source->GetType();
        if (sourceType == LineEdit::GetTypeStatic())
        {
            LineEdit* sourceLineEdit = static_cast<LineEdit*>(source);
            SetText(sourceLineEdit->GetText());
            return true;
        }
        else if (sourceType == Text::GetTypeStatic())
        {
            Text* sourceText = static_cast<Text*>(source);
            SetText(sourceText->GetText());
            return true;
        }
    }

    return false;
}
Exemplo n.º 2
0
const String& FileSelector::GetFilter() const
{
    Text* selectedFilter = static_cast<Text*>(filterList_->GetSelectedItem());
    if (selectedFilter)
        return selectedFilter->GetText();
    else
        return String::EMPTY;
}
Exemplo n.º 3
0
 void ProcessTextChange(EditorRange& Modification,
              Text& input) {
   size_t start = Modification.fEdit.fStart;
   if (start > 6) start -= 5; // not -= 6: we require at least one changed char
   else start = 0;
   size_t P = input.GetText().find("return", start, 6);
   if (P != std::string::npos) {
     for (size_t i = P; i < P + 6; ++i) {
       input.SetColor(i, 1);
     }
     Modification.fDisplay.Extend(Range(P, 6));
   }
 }
Exemplo n.º 4
0
void ListView::CopySelectedItemsToClipboard() const
{
    String selectedText;

    for (PODVector<unsigned>::ConstIterator i = selections_.Begin(); i != selections_.End(); ++i)
    {
        // Only handle Text UI element
        Text* text = dynamic_cast<Text*>(GetItem(*i));
        if (text)
            selectedText.Append(text->GetText()).Append("\n");
    }

    GetSubsystem<UI>()->SetClipboardText(selectedText);
}
Exemplo n.º 5
0
bool LineEdit::OnDragDropFinish(UIElement* source)
{
    if (source)
    {
        ShortStringHash sourceType = source->GetType();
        if (sourceType == LineEdit::GetTypeStatic())
        {
            LineEdit* sourceLineEdit = static_cast<LineEdit*>(source);
            SetText(sourceLineEdit->GetText());
            return true;
        }
        else if (sourceType == Text::GetTypeStatic())
        {
            Text* sourceText = static_cast<Text*>(source);
            SetText(sourceText->GetText());
            return true;
        }
    }
    
    return false;
}
Exemplo n.º 6
0
void ModalWindow::InitComponents(const String &title, const String &message,
	bool show_close_button)
{
	assert(!m_ok_button); // ok button should not have been inited

	m_title_text = dynamic_cast<Text *>(GetChild("TitleText", true));
	assert(m_title_text);
	m_title_text->SetText(m_l10n->Get(title));

	m_message_text = dynamic_cast<Text *>(GetChild("MessageText", true));
	m_message_text->SetText(m_l10n->Get(message));

	m_ok_button = dynamic_cast<Button *>(GetChild("OkButton", true));
	assert(m_ok_button);

	Button *cancel_button = dynamic_cast<Button *>(GetChild("CancelButton", true));
	Text *cancelButtonText = dynamic_cast<Text *>(GetChild("CancelButtonText", true));
	assert(cancel_button && cancelButtonText);

	cancelButtonText->SetText(m_l10n->Get(cancelButtonText->GetText()));

	Button *close_button = dynamic_cast<Button *>(GetChild("CloseButton", true));
	assert(close_button);

	if (show_close_button) {
		SubscribeToEvent(close_button, E_RELEASED, URHO3D_HANDLER(ModalWindow, HandleMessageAcknowledged));
	}
	else {
		close_button->Remove();
	}

	SetModal(true);
	SubscribeToEvent(this, E_MODALCHANGED, URHO3D_HANDLER(ModalWindow, HandleMessageAcknowledged));

	SubscribeToEvent(m_ok_button, E_RELEASED, URHO3D_HANDLER(ModalWindow, HandleMessageAcknowledged));
	SubscribeToEvent(cancel_button, E_RELEASED, URHO3D_HANDLER(ModalWindow, HandleMessageAcknowledged));

	SubscribeToEvent(E_KEYDOWN, URHO3D_HANDLER(ModalWindow, HandleKeyDown));

}
Exemplo n.º 7
0
void DxManager::RenderText()
{
	/*
	this->Dx_DeviceContext->OMSetRenderTargets(1, &this->Dx_RenderTargetView, this->Dx_DepthStencilView);
	this->Dx_DeviceContext->RSSetViewports(1, &this->Dx_Viewport);
	this->Dx_DeviceContext->ClearDepthStencilView(this->Dx_DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	*/
	this->Dx_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	for(int i = 0; i < this->texts.size(); i++)
	{
		Text* txt = this->texts[i];
		// if Convert from screen space is needed, which it is
		this->Shader_Text->SetFloat("posx", (txt->GetPosition().x / this->params.windowWidth) * 2 - 1);
		this->Shader_Text->SetFloat("posy", 2 - (txt->GetPosition().y / this->params.windowHeight) * 2 - 1);

		this->Shader_Text->SetFloat("size", txt->GetSize());
		this->Shader_Text->SetFloat("windowWidth", (float)this->params.windowWidth);
		this->Shader_Text->SetFloat("windowHeight", (float)this->params.windowHeight);
		
		// Im only using ASCI 30 - 100, to reduce data sent I only send those 70 as 0-70. Therefor the t = 30 and t - 30
		static bool once = true;
		if(once)
		{
			for(int t = 30; t < 100; t++)
			{
				this->Shader_Text->SetFloatAtIndex(t - 30, "charTex", (float)(int)txt->GetFont()->charTexCoords[t]);
				this->Shader_Text->SetFloatAtIndex(t - 30, "charWidth", (float)(int)txt->GetFont()->charWidth[t]);
			}
			once = false;
		}


		this->Shader_Text->SetResource("tex2D", txt->GetFont()->textureResource->GetSRVPointer());


		string drawText = txt->GetText();

		//
		if(drawText.size() > 40)
			drawText = drawText.substr(0, 40);

		this->Shader_Text->SetFloat("NrOfChars", (float)drawText.size());
		for(int t = 0; t < (int)drawText.size(); t++)
		{
			// Im only using ASCI 30 - 100, to reduce data sent I only send those 70 as 0-70. Therefor the -30
			this->Shader_Text->SetFloatAtIndex(t, "text", (float)(int)drawText[t] - 30);
		}

		//

		/*
		bool go = true;
		do
		{
			int chars = 40;
			if(drawText.size() <= chars)
			{
				go = false;
				this->Shader_Text->SetFloat("NrOfChars", (float)drawText.size());

				for(int t = 0; t < drawText.size(); t++)
				{
					this->Shader_Text->SetFloatAtIndex(t, "text", (float)(int)drawText[t]);
				}
			}
			else
			{
				string temp = drawText.substr(0, 40);
				drawText = drawText.substr(41);


				this->Shader_Text->SetFloat("NrOfChars", (float)temp.size());

				for(int t = 0; t < temp.size(); t++)
				{
					this->Shader_Text->SetFloatAtIndex(t, "text", (float)(int)temp[t]);
				}
			}
		}
		while(go);

		*/


		this->Shader_Text->Apply(0);

		this->Dx_DeviceContext->Draw(1, 0);
	}
	this->Shader_Text->SetResource("tex2D", NULL);
	this->Shader_Text->Apply(0);
}
Exemplo n.º 8
0
  size_t
  TerminalDisplay::WriteWrappedElement(const Text& Element, size_t TextOffset,
                                       size_t WriteOffset, size_t Requested) {
    size_t Start = TextOffset;
    size_t Remaining = Requested;

    size_t Available = Element.length() - Start;
    if (Requested == (size_t) -1) {
      Requested = Available;
    }

    if (Available > 0) {
      if (Available < Remaining) {
        Remaining = Available;
      }

      while (Remaining > 0) {
        size_t numThisLine = Remaining;

        // How much can this line hold?
        size_t numToEOL = GetWidth() - ((Start + WriteOffset) % GetWidth());
        if (!numToEOL) {
          MoveDown();
          ++fWritePos.fLine;
          MoveFront();
          fWritePos.fCol = 0;
          numToEOL = GetWidth();
        }
        if (numThisLine > numToEOL) {
          numThisLine = numToEOL;
        }

        if (GetContext()->GetColorizer()) {
          // We only write same-color chunks; how long is it?
          const std::vector<char>& Colors = Element.GetColors();
          char ThisColor = Colors[Start];
          size_t numSameColor = 1;
          while (numSameColor < numThisLine
                 && ThisColor == Colors[Start + numSameColor])
            ++numSameColor;
          numThisLine = numSameColor;

          if (ThisColor != fPrevColor) {
            Color C;
            GetContext()->GetColorizer()->GetColor(ThisColor, C);
            SetColor(ThisColor, C);
            fPrevColor = ThisColor;
          }
        }

        WriteRawString(Element.GetText().c_str() + Start, numThisLine);
        fWritePos = IndexToPos(PosToIndex(fWritePos) + numThisLine);
        if (numThisLine == numToEOL) {
          ActOnEOL();
        }

        Start += numThisLine;
        Remaining -= numThisLine;
      }
    }

    if (Requested == Available) {
      size_t VisL = fWriteLen / GetWidth();
      size_t Wrote = WriteOffset + TextOffset + Requested;
      size_t WroteL = Wrote / GetWidth();
      size_t NumToEOL = GetWidth() - (Wrote % GetWidth());
      if (fWriteLen > Wrote && NumToEOL > 0) {
        // Wrote less and not at EOL
        EraseToRight();
      }
      if (WroteL < VisL) {
        Pos prevWC = GetCursor();
        MoveFront();
        fWritePos.fCol = 0;
        for (size_t l = WroteL + 1; l <= VisL; ++l) {
          MoveDown();
          ++fWritePos.fLine;
          EraseToRight();
        }
        Move(prevWC);
      }
    }
    return Remaining;
  }