Exemplo n.º 1
0
int
SFont_AlignedHeight (SFont_Font * Font, int w, int gap, char *text)
{
  char buf[512] = "";
  int width = 0;
  int ww = 0;
  int len = strlen (text);
  int i = 0;
  int y = 0;
  int nextWord = 0;

  if (text == NULL)
    return 0;

  for (i = 0; i < len; i++)
    {
      ww = wordWidth (Font, text, i, nextWord + 1);
      if ((width + ww) >= w)
	{
	  width = 0;
	  buf[0] = '\0';
	  y += Font->Surface->h + gap;
	}
      width += ww;
      copyWord (Font, text, buf, i, nextWord);
      i = nextWord;
      nextWord = findWord (Font, text, i + 1);
    }
  return y += Font->Surface->h;
}
Exemplo n.º 2
0
void
SFont_WriteAligned (SFont_Font * Font, int x, int y, int w,
		    int gap, int align, char *text)
{
  char buf[512] = "";
  int width = 0;
  int ww = 0;
  int len = strlen (text);
  int i = 0;
  int nextWord = 0;

  if (text == NULL)
    return;

  for (i = 0; i < len; i++)
    {
      ww = wordWidth (Font, text, i, nextWord + 1);
      if ((width + ww) >= w)
	{
	  switch (align)
	    {
	    case ALEFT:
	      SFont_Write (Font, x, y, buf);
	      break;
	    case ARIGHT:
	      SFont_Write (Font, x + w - width, y, buf);
	      break;
	    case ACENTER:
	      SFont_Write (Font, x + (w - width) / 2, y, buf);
	      break;
	    default:
	      break;
	    }
	  width = 0;
	  buf[0] = '\0';
	  y += Font->Surface->h + gap;
	}
      width += ww;
      copyWord (Font, text, buf, i, nextWord);
      i = nextWord;
      nextWord = findWord (Font, text, i + 1);
    }

  switch (align)
    {
    case ALEFT:
      SFont_Write (Font, x, y, buf);
      break;
    case ARIGHT:
      SFont_Write (Font, x + w - width, y, buf);
      break;
    case ACENTER:
      SFont_Write (Font, x + (w - width) / 2, y, buf);
      break;
    default:
      break;
    }
}
Exemplo n.º 3
0
bool Abi::isCompatibleWith(const Abi &other) const
{
    bool isCompat = (architecture() == other.architecture() || other.architecture() == Abi::UnknownArchitecture)
                     && (os() == other.os() || other.os() == Abi::UnknownOS)
                     && (osFlavor() == other.osFlavor() || other.osFlavor() == Abi::UnknownFlavor)
                     && (binaryFormat() == other.binaryFormat() || other.binaryFormat() == Abi::UnknownFormat)
                     && ((wordWidth() == other.wordWidth() && wordWidth() != 0) || other.wordWidth() == 0);
    // *-linux-generic-* is compatible with *-linux-* (both ways): This is for the benefit of
    // people building Qt themselves using e.g. a meego toolchain.
    //
    // We leave it to the specific targets to catch filter out the tool chains that do not
    // work for them.
    if (!isCompat && (architecture() == other.architecture() || other.architecture() == Abi::UnknownArchitecture)
                  && ((os() == other.os()) && (os() == LinuxOS))
                  && (osFlavor() == GenericLinuxFlavor || other.osFlavor() == GenericLinuxFlavor)
                  && (binaryFormat() == other.binaryFormat() || other.binaryFormat() == Abi::UnknownFormat)
                  && ((wordWidth() == other.wordWidth() && wordWidth() != 0) || other.wordWidth() == 0))
        isCompat = true;
    return isCompat;
}
Exemplo n.º 4
0
int ZLTextView::ViewStyle::elementWidth(const ZLTextElement &element, unsigned int charNumber) const {
	switch (element.kind()) {
		case ZLTextElement::WORD_ELEMENT:
			return wordWidth((const ZLTextWord&)element, charNumber, -1, false);
		case ZLTextElement::IMAGE_ELEMENT:
			return context().imageWidth(((const ZLTextImageElement&)element).image());
		case ZLTextElement::INDENT_ELEMENT:
			return textStyle()->firstLineIndentDelta();
		case ZLTextElement::HSPACE_ELEMENT:
		case ZLTextElement::NB_HSPACE_ELEMENT:
			return 0;
		case ZLTextElement::BEFORE_PARAGRAPH_ELEMENT:
		case ZLTextElement::AFTER_PARAGRAPH_ELEMENT:
		case ZLTextElement::EMPTY_LINE_ELEMENT:
			return context().width() + abs(textStyle()->leftIndent()) + abs(textStyle()->rightIndent()) + abs(textStyle()->firstLineIndentDelta()) + 1;
		case ZLTextElement::FORCED_CONTROL_ELEMENT:
		case ZLTextElement::CONTROL_ELEMENT:
			return 0;
		case ZLTextElement::FIXED_HSPACE_ELEMENT:
			return context().spaceWidth() * ((const ZLTextFixedHSpaceElement&)element).length();
	}
	return 0;
}