Exemple #1
0
void KstEditViewObjectDialogI::fillPenStyleWidget(QComboBox* widget) {
  QRect rect = widget->style().querySubControlMetrics(QStyle::CC_ComboBox, 
                                                      widget, 
                                                      QStyle::SC_ComboBoxEditField);
  rect.setLeft(rect.left() + 2);
  rect.setRight(rect.right() - 2);
  rect.setTop(rect.top() + 2);
  rect.setBottom(rect.bottom() - 2);

  // fill the combo with pen styles
  QPixmap ppix(rect.width(), rect.height());
  QPainter pp(&ppix);
  QPen pen(Qt::black, 0);

  widget->clear(); 
  
  QValueList<Qt::PenStyle> styles;
  styles.append(Qt::SolidLine);
  styles.append(Qt::DashLine);
  styles.append(Qt::DotLine);
  styles.append(Qt::DashDotLine);
  styles.append(Qt::DashDotDotLine);
  
  while (!styles.isEmpty()) {
    pen.setStyle(styles.front());
    pp.setPen(pen);
    pp.fillRect( pp.window(), QColor("white"));
    pp.drawLine(1,ppix.height()/2,ppix.width()-1, ppix.height()/2);
    widget->insertItem(ppix);
    styles.pop_front();
  }
}
Exemple #2
0
QStringList Rad::kanjiByRad(const QStringList &list)
{
	//kdDebug() << "kanjiByRad (list version)\n";

	QStringList ret;
	QValueList<QStringList> lists;

	for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
	{
		//kdDebug() << "loading radical " << *it << endl;
		lists.append(kanjiByRad(*it));
	}

	QStringList first = lists.first();
	lists.pop_front();

	for (QStringList::Iterator kit = first.begin(); kit != first.end(); ++kit)
	{
		//kdDebug() << "kit is " << *kit << endl;
		QValueList<bool> outcomes;
		for (QValueList<QStringList>::Iterator it = lists.begin(); it != lists.end(); ++it)
		{
			//kdDebug() << "looping through lists\n";
			outcomes.append((*it).contains(*kit) > 0);
		}

		const bool containsBool = false;
		if ((outcomes.contains(containsBool) < 1))
		{
			//kdDebug() << "appending " << *kit << endl;
			ret.append(*kit);
		}
		else
		{
			//kdDebug() << "not appending " << *kit << endl;
		}
	}

	return ret;
}
cTexture *cAsciiFonts::buildText(unsigned char font, const QCString &text, unsigned short hueid, bool shaded, enTextAlign align, bool hueAll) {
	if (font > 9) {
		font = 3; // Default back to font 3 if the font is invalid
	}

	unsigned int width = 0; // Total width of the text	
	unsigned int height = this->height[font]; // Total height of the text
	unsigned int lineWidth = 0; // Length of the current line
	unsigned int lines = 1; // Number of lines
	QValueList<unsigned int> lineWidths; // Vector with the lengths of lines
	
	// Iterate over the string once to get the width of the string
	QCString::ConstIterator it;
	for (it = text.begin(); it != text.end(); ++it) {
		if (*it == '\n') {
			lines += 1;
			if (lineWidth > width) {
				width = lineWidth;
			}
			lineWidths.append(lineWidth);
			lineWidth = 0;
		} else {
			cSurface *ch = getCharacter(font, *it);
	
			if (ch) {
				lineWidth += ch->width(); // Increase the width of the text
			}
		}
	}

	if (lineWidth > 0) {
		lineWidths.append(lineWidth);

		if (lineWidth > width) {
			width = lineWidth;
		}
	}

	unsigned int baseline = height; // Store the baseline
	height = lines * height; // Increase the height of the text	

	cSurface *surface = 0; // The resulting text line

	if (width > 0) {
		surface = new cSurface(width, height);
		surface->clear(); // Clear the background of the surface

		// Start copying the characters over
		int destx = 0;
		int desty = 0;
		switch (align) {
			case ALIGN_LEFT:
				destx = 0; // Start on the left border
				break;
			case ALIGN_CENTER:
				destx = (width - lineWidths.front()) >> 1; // Take whats left of the total width and divide it into two
				break;
			case ALIGN_RIGHT:
				destx = (width - lineWidths.front()); // Take the right part and use it as an offset
				break;
		}
		lineWidths.pop_front();

		for (it = text.begin(); it != text.end(); ++it) {
			if (*it == '\n') {
				if (!lineWidths.isEmpty()) {
					switch (align) {
						case ALIGN_LEFT:
							destx = 0; // Start on the left border
							break;
						case ALIGN_CENTER:
							destx = (width - lineWidths.front()) >> 1; // Take whats left of the total width and divide it into two
							break;
						case ALIGN_RIGHT:
							destx = (width - lineWidths.front()); // Take the right part and use it as an offset
							break;
					}
					lineWidths.pop_front();
				}
				baseline += this->height[font];
			} else {
				cSurface *ch = getCharacter(font, *it);
				if (ch) {
					desty = baseline - ch->height();
					// MemCpy Line by Line
					for (int yl = 0; yl < ch->height(); ++yl) {
						unsigned char *src = ch->scanline(yl);
						unsigned char *dest = surface->scanline(yl + desty) + destx * 4;
						memcpy(dest, src, ch->width() * 4);
					}
					destx += ch->width(); // Increase for the next draw
				}
			}
		}