本文整理汇总了C++中QValueList::pop_front方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueList::pop_front方法的具体用法?C++ QValueList::pop_front怎么用?C++ QValueList::pop_front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueList
的用法示例。
在下文中一共展示了QValueList::pop_front方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCharacter
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
}
}
}