Exemple #1
0
// Draws a char* to a context at textposX and textposY with word wrapping capabilities
void DrawText (const char *Attribute, char *Data, CGContextRef myContext,
			   int rowLength, int colLength, int wraplength, int * textposX, int * textposY){
	
	
	if (Data[0] != 0) {
		char sizeArray[rowLength][colLength];
		bzero(sizeArray, rowLength*colLength);
		
		strcpy(sizeArray[0], Attribute);
		wordWrap(Data, *sizeArray, colLength, wraplength);
        
        for (int i = 0; i < rowLength; i++) {
			if (sizeArray[i][0] != 0) {
				*textposY = *textposY + 20;
			}
        }
        
		
		for (int i = 0; i < rowLength; i++) {
			if (sizeArray[i][0] != 0) {
				CGContextShowTextAtPoint (myContext, *textposX, *textposY, sizeArray[i], strlen(sizeArray[i]));
				*textposY = *textposY - 20;
			}
		}
		*textposY = *textposY - 5;
	}
	
}
Exemple #2
0
void calcRectangle (const char *Attribute, char *Data,
                    int rowLength, int colLength, int wraplength, int * textposX, int * textposY){
	
	
	if (Data[0] != 0) {
		char sizeArray[rowLength][colLength];
		bzero(sizeArray, rowLength*colLength);
        
        char *datatmp;
        datatmp = (char*) malloc(strlen(Data)*sizeof(Data));
        strcpy(datatmp, Data);
        
		strcpy(sizeArray[0], Attribute);
		wordWrap(datatmp, *sizeArray, colLength, wraplength);
		
		for (int i = 0; i < rowLength; i++) {
			if (sizeArray[i][0] != 0) {
				*textposY = *textposY + 20;
			}
		}
		*textposY = *textposY - 5;
        
        free(datatmp);
	}
}
void KFileIVIDesktop::paintItem( TQPainter *p, const TQColorGroup &cg)
{
  TQColorGroup colors = updateColors(cg);

  TQIconView* view = iconView();
  Q_ASSERT( view );

  if ( !view )
    return;

  if ( !wordWrap() )
    return;

  p->save();

  // draw the pixmap as in TDEIconViewItem::paintItem(...)
  paintPixmap(p, colors);

  //
  // Paint the text as shadowed if the shadow is available
  //
  if (m_shadow != 0L && (static_cast<KDesktopShadowSettings *> (m_shadow->shadowSettings()))->isEnabled())
    drawShadowedText(p, colors);
  else {
    paintFontUpdate(p);
    paintText(p, colors);
  }

  p->restore();

  paintOverlay(p);
  paintOverlayProgressBar(p);
}
int QLabel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 12)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 12;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< Qt::TextFormat*>(_v) = textFormat(); break;
        case 2: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(pixmap())); break;
        case 3: *reinterpret_cast< bool*>(_v) = hasScaledContents(); break;
        case 4: *reinterpret_cast< Qt::Alignment*>(_v) = alignment(); break;
        case 5: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 6: *reinterpret_cast< int*>(_v) = margin(); break;
        case 7: *reinterpret_cast< int*>(_v) = indent(); break;
        case 8: *reinterpret_cast< bool*>(_v) = openExternalLinks(); break;
        case 9: *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags(); break;
        case 10: *reinterpret_cast< bool*>(_v) = hasSelectedText(); break;
        case 11: *reinterpret_cast< QString*>(_v) = selectedText(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setTextFormat(*reinterpret_cast< Qt::TextFormat*>(_v)); break;
        case 2: setPixmap(*reinterpret_cast< QPixmap*>(_v)); break;
        case 3: setScaledContents(*reinterpret_cast< bool*>(_v)); break;
        case 4: setAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break;
        case 5: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 6: setMargin(*reinterpret_cast< int*>(_v)); break;
        case 7: setIndent(*reinterpret_cast< int*>(_v)); break;
        case 8: setOpenExternalLinks(*reinterpret_cast< bool*>(_v)); break;
        case 9: setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemple #5
0
void HiRes1Engine::printString(const Common::String &str) {
	Common::String wrap = str;
	wordWrap(wrap);
	_display->printString(wrap);

	if (_messageDelay)
		delay(14 * 166018 / 1000);
}
Exemple #6
0
double
scaleText(const char* text, char* buf)
{
  int length = strlen(text);
  if(length < 10) {
    strcpy(buf, text);
    return 1.0;
  } else if(length < 24) {
    wordWrap(text, 10, buf);
    return 0.70;
  } else if(length < 48) {
    wordWrap(text, 15, buf);
    return 0.5;
  } else {
    wordWrap(text, 20, buf);
    return 0.40;
  }
}
Exemple #7
0
QString CustomLabel::elidedText() const
{
    QString elided = text();
    QStringList srcLines;
    QStringList dstLines;
    QRectF lr = contentsRect();
    int textWidth = lr.width();
    // eliding text
    // TODO: move to text change / resize event handler, make elided a member
    if (elideMode() != Qt::ElideNone)
    {
        QFontMetrics fm = fontMetrics();
        if (!wordWrap())
        {
            // single line elide
            elided = fm.elidedText(text(), elideMode(), textWidth);
        }
        else if (elideMode() == Qt::ElideRight)
        {
            // multiline elide
            srcLines = elided.split("\n");
            int pxPerLine = fm.lineSpacing();
            int lines = lr.height() / pxPerLine + 1;

            foreach (QString srcLine, srcLines)
            {
                int w = fm.width(srcLine);
                if (w >= textWidth)
                {
                    QStringList tmpList = srcLine.split(' ');
                    QString s;
                    int i = 0;
                    while (i < tmpList.count())
                    {
                        if (fm.width(s + " " + tmpList.at(i)) >= textWidth)
                        {
                            if (!s.isEmpty())
                            {
                                dstLines += s;
                                s = QString::null;
                            }
                        }
                        if (!s.isEmpty())
                        {
                            s += " ";
                        }
                        s += tmpList.at(i);
                        i++;
                    }
                    dstLines += s;
                }
                else
                {
                    dstLines += srcLine;
                }
            }
QSize SMSItemDelegate::sizeHint ( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    Q_UNUSED ( option );
    Q_UNUSED ( index );

    QFont font = KGlobalSettings::generalFont();
    const QFontMetrics fontMetrics ( font );

    QString body = index.data ( SMSList::Body ).toString();
    QStringList list = wordWrap ( body );

    return QSize ( 0,fontMetrics.height() *list.size() +SPACING*9 );
}
Exemple #9
0
Surface *Surface::newDialog(uint16 width, const char *line, int color) {
	char **lines;
	Common::String lineCopy(line);
	uint8 numLines;
	wordWrap(lineCopy.begin(), width - (Surface::textX() * 2), lines, numLines);

	// Create the dialog
	Surface *result = newDialog(width, numLines, const_cast<const char **>(lines), true, color);

	// Deallocate used resources
	free(lines);

	return result;
}
int QgsDetailedItemDelegate::height( const QStyleOptionViewItem & theOption,
                                     const QgsDetailedItemData theData ) const
{
  QFontMetrics myTitleMetrics( titleFont( theOption ) );
  QFontMetrics myDetailMetrics( detailFont( theOption ) );
  //we don't word wrap the title so its easy to measure
  int myHeight = myTitleMetrics.height() + verticalSpacing();
  //the detail needs to be measured though
  QStringList myList = wordWrap( theData.detail(),
                                 myDetailMetrics,
                                 theOption.rect.width() - ( mpCheckBox->width() + horizontalSpacing() ) );
  myHeight += ( myList.count() + 1 ) * ( myDetailMetrics.height() - verticalSpacing() );
  return myHeight;
}
QString openGlContext()
{
    QString result;
    QTextStream str(&result);

    QOpenGLContext context;
    if (context.create()) {
#  ifdef QT_OPENGL_DYNAMIC
        str << "Dynamic GL ";
#  endif
        switch (context.openGLModuleType()) {
        case QOpenGLContext::LibGL:
            str << "LibGL";
            break;
        case QOpenGLContext::LibGLES:
            str << "LibGLES";
            break;
        }

        QWindow window;
        if (QGuiApplication::platformName() == QLatin1String("greenisland"))
            window.setFlags(Qt::Desktop);
        window.setSurfaceType(QSurface::OpenGLSurface);
        //window.setScreen(QGuiApplication::primaryScreen());
        window.create();
        if (context.makeCurrent(&window)) {
            QOpenGLFunctions functions(&context);

            str << " Vendor: " << reinterpret_cast<const char *>(functions.glGetString(GL_VENDOR))
                << "\nRenderer: " << reinterpret_cast<const char *>(functions.glGetString(GL_RENDERER))
                << "\nVersion: " << reinterpret_cast<const char *>(functions.glGetString(GL_VERSION))
                << "\nGLSL version: " << reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION))
                << "\nFormat: " << context.format();

            QList<QByteArray> extensionList = context.extensions().toList();
            std::sort(extensionList.begin(), extensionList.end());
            QByteArray extensions = extensionList.join(' ');
            str << " \nFound " << extensionList.size() << " extensions:\n";
            str << wordWrap(extensions, 78);

            context.doneCurrent();
        }
        window.destroy();
    } else {
        str << "Unable to create an Open GL context.\n";
    }

    return result;
}
int QgsDetailedItemDelegate::height( const QStyleOptionViewItem &option,
                                     const QgsDetailedItemData &data ) const
{
  QFontMetrics myTitleMetrics( titleFont( option ) );
  QFontMetrics myDetailMetrics( detailFont( option ) );
  QFontMetrics myCategoryMetrics( categoryFont( option ) );
  //we don't word wrap the title so its easy to measure
  int myHeight = myTitleMetrics.height() + verticalSpacing();
  //the detail needs to be measured though
  QStringList myList = wordWrap( data.detail(),
                                 myDetailMetrics,
                                 option.rect.width() - ( mpCheckBox->width() + horizontalSpacing() ) );
  myHeight += ( myList.count() + 1 ) * ( myDetailMetrics.height() - verticalSpacing() );
  //we don't word wrap the category so its easy to measure
  myHeight += myCategoryMetrics.height() + verticalSpacing();
#if 0
  // if category should be wrapped use this code
  myList = wordWrap( data.category(),
                     myCategoryMetrics,
                     option.rect.width() - ( mpCheckBox->width() + horizontalSpacing() ) );
  myHeight += ( myList.count() + 1 ) * ( myCategoryMetrics.height() - verticalSpacing() );
#endif
  return myHeight;
}
int CorpusViewDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: showMarkedUpText((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: moveRightView((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 2: moveLeftView((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 3: wordWrap((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}
Exemple #14
0
bool KFileIVIDesktop::shouldUpdateShadow(bool selected)
{
  unsigned long uid = (static_cast<KDesktopShadowSettings *> (m_shadow->shadowSettings()))->UID();
  TQString wrapped = wordWrap()->wrappedString();

  if (wrapped != oldText){
    oldText = wrapped;
    _selectedUID = _normalUID = 0;
  }

  if (selected == true)
    return (uid != _selectedUID);
  else
    return (uid != _normalUID);

  return false;
}
Exemple #15
0
TQImage *KFileIVIDesktop::buildShadow( TQPainter *p, const int align,
                                      TQColor &shadowColor )
{
  TQPainter pixPainter;
  int spread = shadowThickness();

  TQPixmap textPixmap(textRect( FALSE ).width() + spread * 2 + 2,
    textRect( FALSE ).height() + spread * 2 + 2);

  textPixmap.fill(TQColor(0,0,0));
  textPixmap.setMask( textPixmap.createHeuristicMask(TRUE) );

  pixPainter.begin(&textPixmap);
  pixPainter.setPen(white);    // get the pen from the root painter
  pixPainter.setFont(p->font()); // get the font from the root painter
  wordWrap()->drawText( &pixPainter, spread, spread, align | KWordWrap::Truncate );
  pixPainter.end();

  return new TQImage(m_shadow->makeShadow(textPixmap, shadowColor));
}
Exemple #16
0
void KFileIVIDesktop::calcRect( const TQString& _text )
{
    TDEIconViewItem::calcRect( _text );

    if ( !iconView() || !m_shadow ||
         !wordWrap() || !( static_cast<KDesktopShadowSettings *>
             ( m_shadow->shadowSettings() ) )->isEnabled() )
        return;

    int spread = shadowThickness();
    TQRect itemTextRect = textRect();
    TQRect itemRect = rect();

    itemTextRect.setBottom( itemTextRect.bottom() + spread );
    itemTextRect.setRight( itemTextRect.right() + spread );
    itemRect.setBottom( itemRect.bottom() + spread );
    itemRect.setRight( itemRect.right() + spread );

    setTextRect( itemTextRect );
    setItemRect( itemRect );
}
void QgsDetailedItemDelegate::paintManually( QPainter *thepPainter,
    const QStyleOptionViewItem &theOption,
    const QgsDetailedItemData &theData ) const
{
  //
  // Get the strings and check box properties
  //
  //bool myCheckState = theIndex.model()->data(theIndex, Qt::CheckStateRole).toBool();
  mpCheckBox->setChecked( theData.isChecked() );
  mpCheckBox->setEnabled( theData.isEnabled() );
  QPixmap myCbxPixmap( mpCheckBox->size() );
  mpCheckBox->render( &myCbxPixmap ); //we will draw this onto the widget further down

  //
  // Calculate the widget height and other metrics
  //

  QFontMetrics myTitleMetrics( titleFont( theOption ) );
  QFontMetrics myDetailMetrics( detailFont( theOption ) );
  int myTextStartX = theOption.rect.x() + horizontalSpacing();
  int myTextStartY = theOption.rect.y() + verticalSpacing();
  int myHeight = myTitleMetrics.height() + verticalSpacing();

  //
  // Draw the item background with a gradient if its highlighted
  //
  if ( theOption.state & QStyle::State_Selected )
  {
    drawHighlight( theOption, thepPainter, height( theOption, theData ) );
    thepPainter->setPen( theOption.palette.highlightedText().color() );
  }
  else
  {
    thepPainter->setPen( theOption.palette.text().color() );
  }


  //
  // Draw the checkbox
  //
  if ( theData.isCheckable() )
  {
    thepPainter->drawPixmap( theOption.rect.x(),
                             theOption.rect.y() + mpCheckBox->height(),
                             myCbxPixmap );
    myTextStartX = theOption.rect.x() + myCbxPixmap.width() + horizontalSpacing();
  }
  //
  // Draw the decoration (pixmap)
  //
  bool myIconFlag = false;
  QPixmap myDecoPixmap = theData.icon();
  if ( !myDecoPixmap.isNull() )
  {
    myIconFlag = true;
    int iconWidth = 32, iconHeight = 32;

    if ( myDecoPixmap.width() <= iconWidth && myDecoPixmap.height() <= iconHeight )
    {
      // the pixmap has reasonable size
      int offsetX = 0, offsetY = 0;
      if ( myDecoPixmap.width() < iconWidth )
        offsetX = ( iconWidth - myDecoPixmap.width() ) / 2;
      if ( myDecoPixmap.height() < iconHeight )
        offsetY = ( iconHeight - myDecoPixmap.height() ) / 2;

      thepPainter->drawPixmap( myTextStartX + offsetX,
                               myTextStartY + offsetY,
                               myDecoPixmap );
    }
    else
    {
      // shrink the pixmap, it's too big
      thepPainter->drawPixmap( myTextStartX, myTextStartY, iconWidth, iconHeight, myDecoPixmap );
    }

    myTextStartX += iconWidth + horizontalSpacing();
  }
  //
  // Draw the title
  //
  myTextStartY += myHeight / 2;
  thepPainter->setFont( titleFont( theOption ) );
  thepPainter->drawText( myTextStartX,
                         myTextStartY,
                         theData.title() );
  //
  // Draw the description with word wrapping if needed
  //
  thepPainter->setFont( detailFont( theOption ) ); //return to original font set by client
  if ( myIconFlag )
  {
    myTextStartY += verticalSpacing();
  }
  else
  {
    myTextStartY +=  myDetailMetrics.height() + verticalSpacing();
  }
  QStringList myList =
    wordWrap( theData.detail(), myDetailMetrics, theOption.rect.width() - myTextStartX );
  QStringListIterator myLineWrapIterator( myList );
  while ( myLineWrapIterator.hasNext() )
  {
    QString myLine = myLineWrapIterator.next();
    thepPainter->drawText( myTextStartX,
                           myTextStartY,
                           myLine );
    myTextStartY += myDetailMetrics.height() - verticalSpacing();
  }

  //
  // Draw the category. Not sure if we need word wrapping for it.
  //
  thepPainter->setFont( categoryFont( theOption ) ); //return to original font set by client
  thepPainter->drawText( myTextStartX,
                         myTextStartY,
                         theData.category() );

  //
  // Draw the category with word wrapping if needed
  //
  /*
  myTextStartY += verticalSpacing();
  if ( myIconFlag )
  {
    myTextStartY += verticalSpacing();
  }
  else
  {
    myTextStartY +=  myCategoryMetrics.height() + verticalSpacing();
  }
  myList =
    wordWrap( theData.category(), myCategoryMetrics, theOption.rect.width() - myTextStartX );
  QStringListIterator myLineWrapIter( myList );
  while ( myLineWrapIter.hasNext() )
  {
    QString myLine = myLineWrapIter.next();
    thepPainter->drawText( myTextStartX,
                           myTextStartY,
                           myLine );
    myTextStartY += myCategoryMetrics.height() - verticalSpacing();
  }
  */
} //render by manual painting
int QListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractItemView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 1)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 1;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Movement*>(_v) = movement(); break;
        case 1: *reinterpret_cast< Flow*>(_v) = flow(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isWrapping(); break;
        case 3: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break;
        case 4: *reinterpret_cast< LayoutMode*>(_v) = layoutMode(); break;
        case 5: *reinterpret_cast< int*>(_v) = spacing(); break;
        case 6: *reinterpret_cast< QSize*>(_v) = gridSize(); break;
        case 7: *reinterpret_cast< ViewMode*>(_v) = viewMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = modelColumn(); break;
        case 9: *reinterpret_cast< bool*>(_v) = uniformItemSizes(); break;
        case 10: *reinterpret_cast< int*>(_v) = batchSize(); break;
        case 11: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 12: *reinterpret_cast< bool*>(_v) = isSelectionRectVisible(); break;
        }
        _id -= 13;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setMovement(*reinterpret_cast< Movement*>(_v)); break;
        case 1: setFlow(*reinterpret_cast< Flow*>(_v)); break;
        case 2: setWrapping(*reinterpret_cast< bool*>(_v)); break;
        case 3: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break;
        case 4: setLayoutMode(*reinterpret_cast< LayoutMode*>(_v)); break;
        case 5: setSpacing(*reinterpret_cast< int*>(_v)); break;
        case 6: setGridSize(*reinterpret_cast< QSize*>(_v)); break;
        case 7: setViewMode(*reinterpret_cast< ViewMode*>(_v)); break;
        case 8: setModelColumn(*reinterpret_cast< int*>(_v)); break;
        case 9: setUniformItemSizes(*reinterpret_cast< bool*>(_v)); break;
        case 10: setBatchSize(*reinterpret_cast< int*>(_v)); break;
        case 11: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 12: setSelectionRectVisible(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 13;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 13;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
int QTreeView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractItemView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: expanded((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 1: collapsed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 2: hideColumn((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: showColumn((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: expand((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 5: collapse((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 6: resizeColumnToContents((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: sortByColumn((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: expandAll(); break;
        case 9: collapseAll(); break;
        case 10: expandToDepth((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 11: columnResized((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 12: columnCountChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 13: columnMoved(); break;
        case 14: reexpand(); break;
        case 15: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 16: d_func()->_q_endAnimatedOperation(); break;
        case 17: d_func()->_q_modelAboutToBeReset(); break;
        case 18: d_func()->_q_sortIndicatorChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Qt::SortOrder(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 19;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = autoExpandDelay(); break;
        case 1: *reinterpret_cast< int*>(_v) = indentation(); break;
        case 2: *reinterpret_cast< bool*>(_v) = rootIsDecorated(); break;
        case 3: *reinterpret_cast< bool*>(_v) = uniformRowHeights(); break;
        case 4: *reinterpret_cast< bool*>(_v) = itemsExpandable(); break;
        case 5: *reinterpret_cast< bool*>(_v) = isSortingEnabled(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isAnimated(); break;
        case 7: *reinterpret_cast< bool*>(_v) = allColumnsShowFocus(); break;
        case 8: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 9: *reinterpret_cast< bool*>(_v) = isHeaderHidden(); break;
        case 10: *reinterpret_cast< bool*>(_v) = expandsOnDoubleClick(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAutoExpandDelay(*reinterpret_cast< int*>(_v)); break;
        case 1: setIndentation(*reinterpret_cast< int*>(_v)); break;
        case 2: setRootIsDecorated(*reinterpret_cast< bool*>(_v)); break;
        case 3: setUniformRowHeights(*reinterpret_cast< bool*>(_v)); break;
        case 4: setItemsExpandable(*reinterpret_cast< bool*>(_v)); break;
        case 5: setSortingEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 6: setAnimated(*reinterpret_cast< bool*>(_v)); break;
        case 7: setAllColumnsShowFocus(*reinterpret_cast< bool*>(_v)); break;
        case 8: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 9: setHeaderHidden(*reinterpret_cast< bool*>(_v)); break;
        case 10: setExpandsOnDoubleClick(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemple #20
0
void CustomLabel::paintEvent(QPaintEvent *pe)
{
    if ((!text().isEmpty()) &&
            (textFormat() == Qt::PlainText ||
             (textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
    {
        QPainter painter(this);
#ifndef DEBUG_CUSTOMLABEL
        QRectF lr = contentsRect();
        lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
        QStyleOption opt;
        opt.initFrom(this);

        int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
        int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
        if (wordWrap())
            flags |= Qt::TextWordWrap;
        switch (shadowType)
        {
        case NoShadow:
            flags |= TF_NOSHADOW;
            break;
        case DarkShadow:
            flags |= TF_DARKSHADOW;
            break;
        case LightShadow:
            flags |= TF_LIGHTSHADOW;
            break;
        default:
            break;
        }
        QString textToDraw = elidedText();
        style()->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), textToDraw, QPalette::WindowText);
#else // DEBUG_CUSTOMLABEL
        QTextDocument *doc = textDocument();
        QAbstractTextDocumentLayout::PaintContext ctx = textDocumentPaintContext(doc);
        QString shadowKey;
        switch (shadowType)
        {
        case DarkShadow:
            shadowKey = GFX_TEXTSHADOWS;
            break;
        case LightShadow:
            shadowKey = GFX_NOTICEWIDGET;
            break;
        case NoShadow:
        default:
            break;
        }

        // magic numbers
        int dx = -2;
        int dy = -2;
        // adding margins
        dx += contentsMargins().left();
        dy += contentsMargins().top();

# if 1 // for debug set 0
        QGraphicsDropShadowEffect *shadow = qobject_cast<QGraphicsDropShadowEffect *>(GraphicsEffectsStorage::staticStorage(RSR_STORAGE_GRAPHICSEFFECTS)->getFirstEffect(shadowKey));
# else // debug shadow
        QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
        shadow->setColor(Qt::red);
        shadow->setOffset(1, 1);
# endif
        if (shadow)
        {
# if 0 // for "image method" set 1
            QImage shadowedText(size(), QImage::Format_ARGB32_Premultiplied);
#  if defined(Q_WS_MAC) && !defined(__MAC_OS_X_NATIVE_FULLSCREEN)
            // TODO: fix that
            shadowedText.fill(Qt::red); // DUNNO WHY!!!
#  else
            shadowedText.fill(Qt::transparent);
#  endif
            QPainter tmpPainter(&shadowedText);
            tmpPainter.setRenderHint(QPainter::Antialiasing);
            tmpPainter.setRenderHint(QPainter::HighQualityAntialiasing);
            tmpPainter.setRenderHint(QPainter::TextAntialiasing);
            tmpPainter.setRenderHint(QPainter::SmoothPixmapTransform);
            tmpPainter.translate(dx, dy);
            doc->documentLayout()->draw(&tmpPainter, ctx);
            painter.drawImage(0, 0, shadowedText);
# else // text method
            QPalette origPal = ctx.palette;
            ctx.palette.setColor(QPalette::Text, shadow->color());

            // draw shadow
            painter.save();
            painter.translate(dx + shadow->xOffset(), dy + shadow->yOffset());
            doc->documentLayout()->draw(&painter, ctx);
            painter.restore();

            ctx.palette = origPal;

            // draw text
            painter.save();
            painter.translate(dx, dy);
            doc->documentLayout()->draw(&painter, ctx);
            painter.restore();
# endif // shadow method
        }
        else
        {
            painter.save();
            painter.translate(dx, dy);
            doc->documentLayout()->draw(&painter, ctx);
            painter.restore();
        }
        doc->deleteLater();
#endif // DEBUG_CUSTOMLABEL
    }
    else
        QLabel::paintEvent(pe);
}
Exemple #21
0
//intitalize window and window options, calls main loop
void Game::Start(void)
{
  if(gameState != Uninitialized)
    return;

  //set window icon
  icon.loadFromFile("images/Player.png");
  //make the window
  mainWindow.create(sf::VideoMode(1024,768,32),"Ace SPACE Pilot"); //playing field is 576 by 768
  mainWindow.setView(View);
  mainWindow.setIcon(40,40,icon.getPixelsPtr());
  mainWindow.setKeyRepeatEnabled(false);
  mainWindow.setFramerateLimit(60);
  mainWindow.setMouseCursorVisible(false);
  rightBound.setSize(sf::Vector2f(400,768));
  rightBound.setFillColor(sf::Color::Black);
  rightBound.setPosition(576,0);
  leftBound.setSize(sf::Vector2f(400,768));
  leftBound.setFillColor(sf::Color::Black);
  leftBound.setPosition(-400,0);
  bottomBound.setSize(sf::Vector2f(576,400));
  bottomBound.setFillColor(sf::Color::Black);
  bottomBound.setPosition(0,768);
  spawnArea.setSize(sf::Vector2f(676,400));
  spawnArea.setPosition(-50,-400);
  spawnArea.setFillColor(sf::Color::Black);
  wholeArea.setSize(sf::Vector2f(1024,768));
  wholeArea.setFillColor(sf::Color::Black);
  mainWindow.setVerticalSyncEnabled(true);
  gameState = Uninitialized;

  //load our main fonts
  uni05.loadFromFile("fonts/uni05_53.ttf");
  datagoth.loadFromFile("fonts/datagoth.otf");

  //load projectile textures
  textures[0].loadFromFile("images/proj.png");
  textures[1].loadFromFile("images/EnemyProj.png");
  textures[2].loadFromFile("images/EnemyProjSmall.png");

  //load sounds
  sf::SoundBuffer projSound;
  projSound.loadFromFile("sounds/se_plst00.wav");
  sounds[0].setBuffer(projSound);
  sounds[0].setVolume(20);

  sf::SoundBuffer okSound;
  okSound.loadFromFile("sounds/se_ok00.wav");
  sounds[1].setBuffer(okSound);
  sounds[1].setVolume(50);

  sf::SoundBuffer pauseSound;
  pauseSound.loadFromFile("sounds/se_select00.wav");
  sounds[2].setBuffer(pauseSound);

  sf::SoundBuffer hitSound;
  hitSound.loadFromFile("sounds/se_damage00.wav");
  sounds[3].setBuffer(hitSound);
  sounds[3].setVolume(20);

  sf::SoundBuffer endSound;
  endSound.loadFromFile("sounds/se_playerdead.wav");
  sounds[4].setBuffer(endSound);

  sf::SoundBuffer killSound;
  killSound.loadFromFile("sounds/destroy.ogg");
  sounds[5].setBuffer(killSound);

	//loads in story
    std::ifstream storyFile("storytime.txt");
    std::string storyString((std::istreambuf_iterator<char>(storyFile)), std::istreambuf_iterator<char>());
    story = wordWrap(storyString,48);


  if(mainWindow.setActive(true))
{
  while(gameState != Exiting)
  {
    GameLoop();
  }
}
  
  mainWindow.setActive(false);
  if(mainWindow.isOpen())
    mainWindow.close();
}
Exemple #22
0
void KFileIVIDesktop::drawShadowedText( TQPainter *p, const TQColorGroup &cg )
{
  bool drawRoundedRect = TDEGlobalSettings::iconUseRoundedRect();

  int textX;
  if (drawRoundedRect == true)
    textX = textRect( FALSE ).x() + 4;
  else
    textX = textRect( FALSE ).x() + 2;
  int textY = textRect( FALSE ).y();
  int align = ((TDEIconView *) iconView())->itemTextPos() == TQIconView::Bottom
    ? AlignHCenter : AlignAuto;
  // FIXME
  // Work around incorrect shadow position detailed in Bug 1807
  bool rebuild = true; // shouldUpdateShadow(isSelected());

  KDesktopShadowSettings *settings = (KDesktopShadowSettings *) (m_shadow->shadowSettings());

  unsigned long uid = settings->UID();

  p->setFont(iconView()->font());
  paintFontUpdate(p);
  TQColor shadow;
  TQColor text;
  int spread = shadowThickness();

  if ( isSelected() && settings->selectionType() != KShadowSettings::InverseVideoOnSelection ) {
    text = cg.highlightedText();
    TQRect rect = textRect( false );
    rect.setRight( rect.right() - spread );
    rect.setBottom( rect.bottom() - spread + 1 );
    if (drawRoundedRect == true) {
      p->setBrush( TQBrush( cg.highlight() ) );
      p->setPen( TQPen( cg.highlight() ) );
      p->drawRoundRect( rect,
		      1000 / rect.width(),
		      1000 / rect.height() );
    }
    else {
      p->fillRect( textRect( false ), cg.highlight() );
    }
  }
  else {
    // use shadow
    if ( isSelected() ) {
      // inverse text and shadow colors
      shadow = settings->textColor();
      text = settings->bgColor();
      if ( rebuild ) {
        setSelectedImage( buildShadow( p, align, shadow ) );
        _selectedUID = uid;
      }
    }
    else {
      text = settings->textColor();
      shadow = ( settings->bgColor().isValid() ) ? settings->bgColor() :
               ( tqGray( text.rgb() ) > 127 ) ? black : white;
      if (rebuild) {
        setNormalImage(buildShadow(p, align, shadow));
        _normalUID = uid;
      }
    }

    // draw the shadow
    int shadowX = textX - spread + settings->offsetX();
    int shadowY = textY - spread + settings->offsetY();

    p->drawImage(shadowX, shadowY,
      (isSelected()) ? *selectedImage() : *normalImage(),
      0, 0, -1, -1, DITHER_FLAGS);
  }

  // draw the text
  p->setPen(text);
  wordWrap()->drawText( p, textX, textY, align | KWordWrap::Truncate );
}
Exemple #23
0
void CustomLabel::paintEvent(QPaintEvent * pe)
{
	if ((!text().isEmpty()) &&
			(textFormat() == Qt::PlainText ||
			 (textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
	{
		QPainter painter(this);
		QRectF lr = contentsRect();
		lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
		QStyleOption opt;
		opt.initFrom(this);
		int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
		int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
		if (wordWrap())
			flags |= Qt::TextWordWrap;
		switch (shadowType)
		{
		case NoShadow:
			flags |= TF_NOSHADOW;
			break;
		case DarkShadow:
			flags |= TF_DARKSHADOW;
			break;
		case LightShadow:
			flags |= TF_LIGHTSHADOW;
			break;
		default:
			break;
		}
		QString textToDraw = text();
		int textWidth = lr.width();
		// eliding text
		// TODO: move to text change / resize event handler, make textToDraw a member
		if (elideMode() != Qt::ElideNone)
		{
			QFontMetrics fm = fontMetrics();
			if (!wordWrap())
			{
				textToDraw = fm.elidedText(text(), elideMode(), textWidth);
			}
			else if (elideMode() == Qt::ElideRight)
			{
				// multiline elide
				int pxPerLine = fontMetrics().lineSpacing();
				int lines = lr.height() / pxPerLine + 1;
#ifdef DEBUG_ENABLED
//				if (lines > 1)
//				{
//					qDebug() << pxPerLine << lines << lr << fm.height() << font().toString();
//				}
#endif
#ifdef Q_WS_MAC // mac hack, dunno why
				//lines--;
				// TODO: debug this!!!
#endif
				QStringList srcLines = text().split("\n");
				QStringList dstLines;
				foreach (QString srcLine, srcLines)
				{
					int w = fm.width(srcLine);
					if (w >= textWidth)
					{
						QStringList tmpList = srcLine.split(' ');
						QString s;
						int i = 0;
						while (i < tmpList.count())
						{
							if (fm.width(s + " " + tmpList.at(i)) >= textWidth)
							{
								if (!s.isEmpty())
								{
									dstLines += s;
									s = QString::null;
								}
							}
							if (!s.isEmpty())
							{
								s += " ";
							}
							s += tmpList.at(i);
							i++;
						}
						dstLines += s;
					}
					else
					{
						dstLines += srcLine;
					}
				}
Exemple #24
0
int
main (int argc, char *argv[])
{
	char *r, *str = (char *)
		"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer metus\n"
		"pede, pretium vitae, rhoncus et, auctor sit amet, ligula. Integer volutpat\n"
		"orci et elit. Nunc tempus, urna at sollicitudin rutrum, arcu libero rhoncus\n"
		"lectus, vitae feugiat purus orci ultricies turpis. Pellentesque habitant\n"
		"morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam\n"
		"in pede. Etiam eu sem id urna ultricies congue. Vestibulum porttitor\n"
		"ultrices neque. Mauris semper, mauris ut feugiat ultricies, augue purus\n"
		"tincidunt  elit, eu interdum ante nisl ac ante. Pellentesque dui. Vestibulum\n"
		"pretium, augue non cursus pretium, nibh dolor laoreet leo, sed pharetra pede\n"
		"libero non diam.\n"
		"\n"
		"Proin est nisi,                     gravida ac, vulputate id, fringilla sit\n"
		"amet, magna. Nam congue cursus magna. In malesuada, velit a gravida sodales,\n"
		"dolor nisl vestibulum orci, sit amet sagittis mauris tellus nec purus. Nulla\n"
		"eget risus. Quisque nec sapien blandit odio convallis ullamcorper. Lorem\n"
		"ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque cursus.\n"
		"Aliquam tempus neque vitae libero molestie ut auctor.\n"
		"\n"
		"\n"
		"\n"
		"In nec massa eu tortor vulputate suscipit. Nam tristique magna nec pede. Sed\n"
		"a nisi. Nulla sed augue ut risus placerat porttitor. Ut aliquam. Nulla\n"
		"facilisi. Nulla vehicula nibh ac sapien. Nunc facilisis dapibus ipsum. Donec\n"
		"sed mauris. Nulla quam nisi, laoreet non, dignissim posuere, lacinia nec,\n"
		"turpis. Mauris malesuada nisi sed enim. In hac habitasse platea dictumst.\n"
		"Fusce    faucibus, turpis nec auctor posuere, nulla tellus scelerisque metus,\n"
		"quis molestie mi dui id quam. Mauris vestibulum. Nam ullamcorper.\n"
		"";

	r = wordWrap (str, 10);
	if (r != NULL)
		puts ("-- Not NULL");

	r = wordWrap (str, 40);
	test (r,
		"Lorem ipsum dolor sit amet, consectetuer\n"
		"adipiscing elit. Integer metus pede,\n"
		"pretium vitae, rhoncus et, auctor sit\n"
		"amet, ligula. Integer volutpat orci et\n"
		"elit. Nunc tempus, urna at sollicitudin\n"
		"rutrum, arcu libero rhoncus lectus,\n"
		"vitae feugiat purus orci ultricies\n"
		"turpis. Pellentesque habitant morbi\n"
		"tristique senectus et netus et malesuada\n"
		"fames ac turpis egestas. Nam in pede.\n"
		"Etiam eu sem id urna ultricies congue.\n"
		"Vestibulum porttitor ultrices neque.\n"
		"Mauris semper, mauris ut feugiat\n"
		"ultricies, augue purus tincidunt elit,\n"
		"eu interdum ante nisl ac ante.\n"
		"Pellentesque dui. Vestibulum pretium,\n"
		"augue non cursus pretium, nibh dolor\n"
		"laoreet leo, sed pharetra pede libero\n"
		"non diam.\n"
		"\n"
		"Proin est nisi, gravida ac, vulputate\n"
		"id, fringilla sit amet, magna. Nam\n"
		"congue cursus magna. In malesuada, velit\n"
		"a gravida sodales, dolor nisl vestibulum\n"
		"orci, sit amet sagittis mauris tellus\n"
		"nec purus. Nulla eget risus. Quisque nec\n"
		"sapien blandit odio convallis\n"
		"ullamcorper. Lorem ipsum dolor sit amet,\n"
		"consectetuer adipiscing elit.\n"
		"Pellentesque cursus. Aliquam tempus\n"
		"neque vitae libero molestie ut auctor.\n"
		"\n"
		"In nec massa eu tortor vulputate\n"
		"suscipit. Nam tristique magna nec pede.\n"
		"Sed a nisi. Nulla sed augue ut risus\n"
		"placerat porttitor. Ut aliquam. Nulla\n"
		"facilisi. Nulla vehicula nibh ac sapien.\n"
		"Nunc facilisis dapibus ipsum. Donec sed\n"
		"mauris. Nulla quam nisi, laoreet non,\n"
		"dignissim posuere, lacinia nec, turpis.\n"
		"Mauris malesuada nisi sed enim. In hac\n"
		"habitasse platea dictumst. Fusce\n"
		"faucibus, turpis nec auctor posuere,\n"
		"nulla tellus scelerisque metus, quis\n"
		"molestie mi dui id quam. Mauris\n"
		"vestibulum. Nam ullamcorper.\n");
	free (r);

	r = wordWrap (str, 80);
	test (r,
		"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer metus pede,\n"
		"pretium vitae, rhoncus et, auctor sit amet, ligula. Integer volutpat orci et\n"
		"elit. Nunc tempus, urna at sollicitudin rutrum, arcu libero rhoncus lectus,\n"
		"vitae feugiat purus orci ultricies turpis. Pellentesque habitant morbi tristique\n"
		"senectus et netus et malesuada fames ac turpis egestas. Nam in pede. Etiam eu\n"
		"sem id urna ultricies congue. Vestibulum porttitor ultrices neque. Mauris\n"
		"semper, mauris ut feugiat ultricies, augue purus tincidunt elit, eu interdum\n"
		"ante nisl ac ante. Pellentesque dui. Vestibulum pretium, augue non cursus\n"
		"pretium, nibh dolor laoreet leo, sed pharetra pede libero non diam.\n"
		"\n"
		"Proin est nisi, gravida ac, vulputate id, fringilla sit amet, magna. Nam congue\n"
		"cursus magna. In malesuada, velit a gravida sodales, dolor nisl vestibulum orci,\n"
		"sit amet sagittis mauris tellus nec purus. Nulla eget risus. Quisque nec sapien\n"
		"blandit odio convallis ullamcorper. Lorem ipsum dolor sit amet, consectetuer\n"
		"adipiscing elit. Pellentesque cursus. Aliquam tempus neque vitae libero molestie\n"
		"ut auctor.\n"
		"\n"
		"In nec massa eu tortor vulputate suscipit. Nam tristique magna nec pede. Sed a\n"
		"nisi. Nulla sed augue ut risus placerat porttitor. Ut aliquam. Nulla facilisi.\n"
		"Nulla vehicula nibh ac sapien. Nunc facilisis dapibus ipsum. Donec sed mauris.\n"
		"Nulla quam nisi, laoreet non, dignissim posuere, lacinia nec, turpis. Mauris\n"
		"malesuada nisi sed enim. In hac habitasse platea dictumst. Fusce faucibus,\n"
		"turpis nec auctor posuere, nulla tellus scelerisque metus, quis molestie mi dui\n"
		"id quam. Mauris vestibulum. Nam ullamcorper.\n");
	free (r);

	return 0;
}
Exemple #25
0
void DeckMenu::Render()
{
    JRenderer * renderer = JRenderer::GetInstance();
    float height = mHeight;

    if (!menuInitialized)
    {
        initMenuItems();
        stars->Fire();
        timeOpen = 0;
        menuInitialized = true;
    }
    
    if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
    
    for (int i = startId; i < startId + maxItems; i++)
    {
        if (i > mCount - 1) break;        
        DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
        if (currentMenuItem->getY() - DeckMenuConst::kLineHeight * startId < mY + height - DeckMenuConst::kLineHeight + 7)
        {
            // only load stats for visible items in the list
			DeckMetaData* metaData = currentMenuItem->getMetaData();
            if (metaData && !metaData->mStatsLoaded)
            {
                metaData->LoadStats();
			}

            if (currentMenuItem->hasFocus())
            {
                mSelectedDeck = metaData;
                WFont *descriptionFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);

                // display the "more info" button if special condition is met
                if (showDetailsScreen())
                {                    
                    dismissButton->setIsSelectionValid(true);
                    dismissButton->Render();
                }
                else
                {
                    dismissButton->setIsSelectionValid(false);
                }
                // display the avatar image
                string currentAvatarImageName = currentMenuItem->getImageFilename();
                if (currentAvatarImageName.size() > 0)
                {
                    JQuadPtr quad = WResourceManager::Instance()->RetrieveTempQuad(currentAvatarImageName, TEXTURE_SUB_AVATAR);
                    if(quad.get())
                    {
                        quad->mWidth = 35.f;
                        quad->mHeight = 50.f;
                        if (currentMenuItem->getText() == "Evil Twin")
                        {
                            JQuad * evil = quad.get();
                            evil->SetHFlip(true);
                            renderer->RenderQuad(quad.get(), avatarX, avatarY);
                            evil = NULL;
                        }
                        else
                            renderer->RenderQuad(quad.get(), avatarX, avatarY);
                    }
                }
                
                // fill in the description part of the screen
				string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID );
                descriptionFont->SetColor(ARGB(255,255,255,255));
                descriptionFont->DrawString(text.c_str(), descX, descY);
                
                // fill in the statistical portion
                if (currentMenuItem->hasMetaData())
                {
                    ostringstream oss;
                    oss << _("Deck: ") << currentMenuItem->getDeckName() << endl;
                    oss << currentMenuItem->getDeckStatsSummary();
                    descriptionFont->SetColor(ARGB(255,255,255,255));
                    descriptionFont->DrawString(oss.str(), statsX, statsY);
                }
                
                // change the font color of the current menu item
                mFont->SetColor(ARGB(255,255,255,255));
            }
            else // reset the font color to be slightly muted
                mFont->SetColor(ARGB(150,255,255,255));
            currentMenuItem->RenderWithOffset(-DeckMenuConst::kLineHeight * startId);
        }
    }
    
	if (!title.empty())
    {
        mFont->SetColor(ARGB(255,255,255,255));
        mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
    }

    mScroller->Render();
	RenderBackground();
    RenderDeckManaColors();
    
    renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
	stars->Render();
	renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);

}
void SMSItemDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    QStyleOptionViewItemV4 optV4 = option;
    initStyleOption ( &optV4, index );

    painter->save();

    painter->setRenderHints ( QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing );
    painter->setClipRect ( optV4.rect );

    QStyle *style = QApplication::style();
    style->drawPrimitive ( QStyle::PE_PanelItemViewItem, &option, painter );

    QFont font = KGlobalSettings::generalFont();

    const QFontMetrics fontMetrics ( font );

    painter->setFont ( font );


    //TODO: Make word wrapping dynamic
    QString body = index.data ( SMSList::Body ).toString();
    QStringList list = wordWrap ( body );
    QPen bodyPen = painter->pen();
    bodyPen.setColor ( m_palette->color ( QPalette::Normal, QPalette::Text ) );
    painter->setPen ( bodyPen );
    QRect bodyRect = optV4.rect;
    bodyRect.setX ( SPACING * 2 );
    bodyRect.setWidth ( fontMetrics.width ( body,body.length() ) );
    for ( int i=0;i<list.size();++i )
    {
        bodyRect.setY ( SPACING*2 + optV4.rect.y() +fontMetrics.height() *i );
        painter->drawText ( bodyRect,fontMetrics.elidedText ( list.at ( i ), Qt::ElideRight, bodyRect.width() ) );
    }


    QPen typePen = painter->pen();
    typePen.setColor ( m_palette->color ( QPalette::Disabled, QPalette::Text ) );
    painter->setPen ( typePen );
    QRect typeRect = optV4.rect;
    typeRect.setX ( SPACING * 2 );
    typeRect.setY ( optV4.rect.y() +SPACING*3 +fontMetrics.height() *list.size() );
    QString type;
    if ( index.data ( SMSList::Type ).toString() ==QString ( "Incoming" ) )
    {
        type = i18n ( "Incoming" );
    }
    else if ( index.data ( SMSList::Type ).toString() ==QString ( "Outgoing" ) )
    {
        type = i18n ( "Outgoing" );
    }
    typeRect.setWidth ( fontMetrics.width ( type,type.length() ) +SPACING );
    painter->drawText ( typeRect,fontMetrics.elidedText ( type, Qt::ElideRight, typeRect.width() ) );


    QDateTime dt;
    dt.setMSecsSinceEpoch ( index.data ( SMSList::Time ).toLongLong() );
    QString dateString = KGlobal::locale()->formatDateTime ( dt,KLocale::FancyLongDate,true );
    QRect dateRect = optV4.rect;
    dateRect.setX ( typeRect.width() +  SPACING * 3 );
    dateRect.setY ( optV4.rect.y() +SPACING*3 +fontMetrics.height() *list.size() );
    dateRect.setWidth ( fontMetrics.width ( dateString,dateString.length() ) +SPACING );
    painter->drawText ( dateRect,fontMetrics.elidedText ( dateString, Qt::ElideRight, dateRect.width() ) );


    painter->restore();
}
Exemple #27
0
void QgsQuickPrint::printMap()
{
  if ( mOutputFileName.isEmpty() )
  {
    return;
  }
  if ( mpMapRenderer == NULL )
  {
    return;
  }
  //ensure the user never omitted the extension from the file name
  if ( !mOutputFileName.toUpper().endsWith( ".PDF" ) )
  {
    mOutputFileName += ".pdf";
  }

  // Initialising the printer this way lets us find out what
  // the screen resolution is which we store and then
  // reset the resolution of the printer after that...
  QPrinter myPrinter( QPrinter::ScreenResolution );

  // Try to force the printer resolution to 300dpi
  // to get past platform specific defaults in printer
  // resolution...
  //
  int myPrintResolutionDpi = 300;
  myPrinter.setResolution( myPrintResolutionDpi );
  myPrinter.setOutputFormat( QPrinter::PdfFormat );
  QgsDebugMsg( QString( "Printing to page size %1" ).arg( pageSizeToString( mPageSize ) ) );
  myPrinter.setPageSize( mPageSize );
  myPrinter.setOutputFileName( mOutputFileName );
  myPrinter.setOrientation( QPrinter::Landscape );
  myPrinter.setDocName( "quickprint Report" );
  QPainter myPrintPainter( &myPrinter );
  myPrintPainter.setPen( Qt::gray );
  myPrintPainter.setBrush( Qt::white );
  // This is what we are aiming for:
  // a
  // +-(1)------ Acme Maps (2) --------------------------------------+
  // |b         12/01/2007 (3)                                         |
  // |                           Earthquakes (4)                       |
  // | +--(5)--------------------------------------------------------+ |
  // | |c                                                            | |
  // | | +-(6)---------------------------------------+  +~(7)~~~~~~+ | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | |                                           |  |          | | |
  // | | +-------------------------------------------+  +~~~~~~~~~~+ | |
  // | |                                                             | |
  // | +-------------------------------------------------------------+ |
  // |                                                                 |
  // |   +-(8)-----+ +-(9-)----+ +-(10)----+                 /|\       |
  // |   |         | |Copyright| |         |                / | \      |
  // |   |         | |  2008   | |         |                  |(11)    |
  // |   +---------+ +---------+ +---------+                           |
  // |                                                  +~(12)~~~~~~+  |
  // +-----------------------------------------------------------------+
  //
  // 1) PageBorder              8) Logo1
  // 2) PageTitle               9) CopyrightText
  // 3) MapDate                 10) Logo2
  // 4) MapTitle                11) NorthArrow
  // 5) MapFrame                12) ScaleBar
  // 6) MapPixmap
  // 7) LegendPixmap
  // a OriginXY
  // b HorizontalSpacing
  // c VerticalSpacing

  //
  // Note: Different operating systems will use different
  // page resolutions for QPrinter::HighResolution so I'm
  // working all coordinates out as percentages of page
  // size so that we can hopefully get comarable print
  // results on all platforms.
  //

  //
  // Note #2: Im defining all measurements here as my plan
  // is to later support templates with different page
  // layouts and paper sizes etc.
  //


  //set the top left origin for the print layout
  int myOriginX = myPrinter.pageRect().left();
  int myOriginY = myPrinter.pageRect().top();
  int myDrawableWidth = myPrinter.pageRect().width() - myOriginX;
  int myDrawableHeight = myPrinter.pageRect().height() - myOriginY;

  //define the spacing between layout elements
  int myHorizontalSpacing = myDrawableWidth / 100; // 1%
  int myVerticalSpacing = myDrawableHeight / 100; // 1%

  //define the proportions for the page layout
  int myMapWidthPercent = 65;
  int myMapHeightPercent = 71;
  int myLegendWidthPercent = 25;
  int myLegendHeightPercent = 65;
  int myLogoWidthPercent = 23;
  int myLogoHeightPercent = 17;
  //
  // Remember the size and dpi of the maprender
  // so we can restore it properly
  //
  int myOriginalDpi = mpMapRenderer->outputDpi();
  //sensible default to prevent divide by zero
  if ( 0 == myOriginalDpi ) myOriginalDpi = 96;
  QSize myOriginalSize = mpMapRenderer->outputSize();

  //define the font sizes and family
  int myMapTitleFontSize = 24;
  int myMapDateFontSize = 16;
  int myMapNameFontSize = 32;
  int myLegendFontSize = 12;
#ifdef Q_OS_LINUX//this sucks...
  myLegendFontSize -= 2;
#endif

#ifdef WIN32 //this sucks too...
  myMapTitleFontSize /= 2;
  myMapDateFontSize /= 2;
  myMapNameFontSize /= 2;
  myLegendFontSize /= 2;
#endif
  QString myFontFamily = "Arial";

  //
  // Draw the PageBorder
  //
  myPrintPainter.drawRect(
    myOriginX, myOriginY, myDrawableWidth, myDrawableHeight );
  //
  // Draw the PageTitle
  //
  QFont myTitleFont( myFontFamily, myMapTitleFontSize );
  myPrintPainter.setFont( myTitleFont );
  QFontMetrics myTitleMetrics( myTitleFont, &myPrinter );
  int myPageTitleHeight = myTitleMetrics.height();
  int myPageTitleWidth = myTitleMetrics.width( mTitleText );
  myOriginX += myHorizontalSpacing;
  myOriginY -= ( myPageTitleHeight / 2 );
  QRect myPageTitleRect( myOriginX,
                         myOriginY,
                         myPageTitleWidth,
                         myPageTitleHeight );
  // make sure the title goes onto a white background
  myPrintPainter.setPen( Qt::white );
  myPrintPainter.drawRect( myPageTitleRect );
  myPrintPainter.setPen( Qt::black );
  myPrintPainter.drawText( myPageTitleRect, Qt::AlignCenter, mTitleText );

  //
  // Draw the MapDate
  //
  QFont myDateFont( myFontFamily, myMapDateFontSize );
  QString myDateText( QDate::currentDate().toString( Qt::LocalDate ) );
  myPrintPainter.setFont( myDateFont );
  QFontMetrics myDateMetrics( myDateFont, &myPrinter );
  int myDateHeight = myDateMetrics.height();
  //int myDateWidth = myDateMetrics.width(myDateText);
  myOriginX += myHorizontalSpacing;
  myOriginY += myPageTitleHeight  + myVerticalSpacing ;
  QRect myDateRect( myOriginX,
                    myOriginY,
                    myPageTitleWidth, //use same width as page title for centering
                    myDateHeight );
  // make sure the title goes onto a white background
  myPrintPainter.setPen( Qt::white );
  myPrintPainter.drawRect( myDateRect );
  myPrintPainter.setPen( Qt::black );
  myPrintPainter.drawText( myDateRect, Qt::AlignCenter, myDateText );

  //
  // Draw the MapName
  //
  QFont myNameFont( myFontFamily, myMapNameFontSize );
  myPrintPainter.setFont( myNameFont );
  QFontMetrics myNameMetrics( myNameFont, &myPrinter );
  int myNameHeight = myNameMetrics.height();
  int myNameWidth = myNameMetrics.width( mNameText );
  myOriginX = myPrinter.pageRect().left() + myDrawableWidth / 2; //page center
  myOriginX -= myNameWidth / 2;
  myOriginY = myPrinter.pageRect().top() + ( myPageTitleHeight / 2 )  + myVerticalSpacing ;
  QRect myNameRect( myOriginX,
                    myOriginY,
                    myNameWidth,
                    myNameHeight );
  // make sure the title goes onto a white background
  myPrintPainter.setPen( Qt::white );
  myPrintPainter.drawRect( myNameRect );
  myPrintPainter.setPen( Qt::black );
  myPrintPainter.drawText( myNameRect, Qt::AlignCenter, mNameText );

  //
  // Draw the MapFrame (top)
  //
  int myMapFrameWidth = myDrawableWidth ;
  myOriginX = myPrinter.pageRect().left() + myHorizontalSpacing;
  myOriginY += myNameHeight + myVerticalSpacing;
  QLine myMapFrameTopLine( myOriginX,
                           myOriginY,
                           myMapFrameWidth,
                           myOriginY );
  myPrintPainter.setPen( Qt::black );
  myPrintPainter.drawLine( myMapFrameTopLine );


  // Draw the map onto a pixmap
  // @TODO: we need to save teh extent of the screen map and
  // then set them again for the print map so that the map scales
  // properly in the print
  int myMapDimensionX = ( myDrawableWidth / 100 ) * myMapHeightPercent;
  int myMapDimensionY = ( myDrawableHeight / 100 ) * myMapWidthPercent;

  QImage myMapImage( QSize( myMapDimensionX, myMapDimensionY ), QImage::Format_ARGB32 );
  myMapImage.setDotsPerMeterX(( double )( myPrinter.logicalDpiX() ) / 25.4 * 1000.0 );
  myMapImage.setDotsPerMeterY(( double )( myPrinter.logicalDpiY() ) / 25.4 * 1000.0 );
  myMapImage.fill( 0 );
  QPainter myMapPainter;
  myMapPainter.begin( &myMapImage );
  // Now resize for print
  mpMapRenderer->setOutputSize( QSize( myMapDimensionX, myMapDimensionY ), ( myPrinter.logicalDpiX() + myPrinter.logicalDpiY() ) / 2 );
  mpMapRenderer->render( &myMapPainter );

  myMapPainter.end();
  //draw the map pixmap onto our pdf print device
  myOriginX = myPrinter.pageRect().left() + myHorizontalSpacing;
  myOriginY += myVerticalSpacing * 2;

  myPrintPainter.drawImage( myOriginX, myOriginY, myMapImage );

  //
  // Draw the legend
  //
  QFont myLegendFont( myFontFamily, myLegendFontSize );
  //myPrintPainter.setFont(myLegendFont);
  int myLegendDimensionX = ( myDrawableWidth / 100 ) * myLegendWidthPercent;
  int myLegendDimensionY = ( myDrawableHeight / 100 ) * myLegendHeightPercent;


  // Create a viewport to make coordinate conversions easier
  // The viewport has the same dimensions as the page(otherwise items
  // drawn into it will appear squashed), but a different origin.
  QRect myOriginalViewport = myPrintPainter.viewport(); //for restoring later
  myOriginX += myMapDimensionX + myHorizontalSpacing;
  myPrintPainter.setViewport( myOriginX,
                              myOriginY,
                              myOriginalViewport.width(),
                              myOriginalViewport.height() );
  //draw a rectangale around the legend frame
  //@TODO make this user settable
  if ( 0 == 1 ) //put some real logic here
  {
    myPrintPainter.drawRect( 0, 0, myLegendDimensionX, myLegendDimensionY );
  }
  //get font metric and other vars needed
  QFontMetrics myLegendFontMetrics( myLegendFont, &myPrinter );
  int myLegendFontHeight = myLegendFontMetrics.height();
  int myLegendXPos = 0;
  int myLegendYPos = 0;
  int myLegendSpacer = myLegendFontHeight / 2; //for vertical and horizontal spacing
  int myLegendVerticalSpacer = myLegendFontHeight / 3; //for vertical between rows
  int myIconWidth = myLegendFontHeight;
  myPrintPainter.setFont( myLegendFont );
  QStringList myLayerSet = mpMapRenderer->layerSet();
  QStringListIterator myLayerIterator( myLayerSet );
  //second clause below is to prevent legend spilling out the bottom
  while ( myLayerIterator.hasNext() &&
          myLegendYPos < myLegendDimensionY )
  {
    QString myLayerId = myLayerIterator.next();
    QgsMapLayer * mypLayer =
      QgsMapLayerRegistry::instance()->mapLayer( myLayerId );
    if ( mypLayer )
    {
      QgsVectorLayer *mypVectorLayer  =
        qobject_cast<QgsVectorLayer *>( mypLayer );
      // TODO: add support for symbology-ng renderers
      if ( mypVectorLayer && mypVectorLayer->renderer() )
      {
        QString myLayerName = mypVectorLayer->name();
        QIcon myIcon;
        QPixmap myPixmap( QSize( myIconWidth, myIconWidth ) );   //square
        //based on code from qgslegendlayer.cpp - see that file for more info
        const QgsRenderer* mypRenderer = mypVectorLayer->renderer();
        const QList<QgsSymbol*> mySymbolList = mypRenderer->symbols();
        //
        // Single symbol
        //
        double widthScale = ( myPrinter.logicalDpiX() + myPrinter.logicalDpiY() ) / 2.0 / 25.4;

        if ( 1 == mySymbolList.size() )
        {
          QgsSymbol * mypSymbol = mySymbolList.at( 0 );
          myPrintPainter.setPen( mypSymbol->pen() );
          myPrintPainter.setBrush( mypSymbol->brush() );
          myLegendXPos = 0 ;
          if ( mypSymbol->type() == QGis::Point )
          {
            QImage myImage;
            myImage = mypSymbol->getPointSymbolAsImage( widthScale );
            myPrintPainter.drawImage( myLegendXPos, myLegendYPos, myImage );
          }
          else if ( mypSymbol->type() == QGis::Line )
          {
            myPrintPainter.drawLine( myLegendXPos, myLegendYPos,
                                     myLegendXPos + myIconWidth,
                                     myLegendYPos + myIconWidth );
          }
          else //polygon
          {
            myPrintPainter.drawRect( myLegendXPos, myLegendYPos, myIconWidth, myIconWidth );
          }
          myLegendXPos += myIconWidth + myLegendSpacer;
          myPrintPainter.setPen( Qt::black );
          QStringList myWrappedLayerNameList = wordWrap( myLayerName,
                                               myLegendFontMetrics,
                                               myLegendDimensionX - myIconWidth );
          //
          // Loop through wrapped legend label lines
          //
          QStringListIterator myLineWrapIterator( myWrappedLayerNameList );
          while ( myLineWrapIterator.hasNext() )
          {
            QString myLine = myLineWrapIterator.next();
            QRect myLegendItemRect( myLegendXPos,
                                    myLegendYPos,
                                    myLegendDimensionX - myIconWidth,
                                    myLegendFontHeight );
            myPrintPainter.drawText( myLegendItemRect, Qt::AlignLeft, myLine );
            myLegendYPos += myLegendVerticalSpacer + myLegendFontHeight;
          }
        }
        else  //class breaks
        {
          // draw in the layer name first, after we loop for the class breaks
          QStringList myWrappedLayerNameList = wordWrap( myLayerName,
                                               myLegendFontMetrics,
                                               myLegendDimensionX - myIconWidth );
          // Check the wrapped layer name wont overrun the space we have
          // for the legend ...
          int myLabelHeight = myLegendFontHeight *
                              myWrappedLayerNameList.count();
          if ( myLegendYPos + myLabelHeight > myLegendDimensionY )
          {
            continue;
          }

          //
          // Loop through wrapped legend label lines
          //
          QStringListIterator myLineWrapIterator( myWrappedLayerNameList );
          while ( myLineWrapIterator.hasNext() )
          {
            QString myLine = myLineWrapIterator.next();
            myLegendXPos = myIconWidth;
            QRect myLegendItemRect( myLegendXPos,
                                    myLegendYPos,
                                    myLegendFontMetrics.width( myLine ),
                                    myLegendFontHeight );
            myPrintPainter.setPen( Qt::black );
            myPrintPainter.drawText( myLegendItemRect, Qt::AlignLeft, myLine );
            myLegendYPos += myLegendVerticalSpacer + myLegendFontHeight;
          }
          //
          // Loop through the class breaks
          //
          QListIterator<QgsSymbol *> myIterator( mySymbolList );
          while ( myIterator.hasNext() && myLegendYPos < myLegendDimensionY )
          {
            QgsSymbol * mypSymbol = myIterator.next();
            myPrintPainter.setPen( mypSymbol->pen() );
            myPrintPainter.setBrush( mypSymbol->brush() );
            myLegendXPos = myLegendSpacer * 3; //extra indent for class breaks
            if ( mypSymbol->type() == QGis::Point )
            {
              QImage myImage;
              myImage = mypSymbol->getPointSymbolAsImage( widthScale );
              myPrintPainter.drawImage( myLegendXPos, myLegendYPos, myImage );
            }
            else if ( mypSymbol->type() == QGis::Line )
            {
              myPrintPainter.drawLine( myLegendXPos, myLegendYPos,
                                       myLegendXPos + myIconWidth,
                                       myLegendYPos + myIconWidth );
            }
            else //polygon
            {
              myPrintPainter.drawRect(
                myLegendXPos, myLegendYPos, myIconWidth, myIconWidth );
            }
            //
            // Now work out the class break label
            //
            QString myLabel;
            QString myLower = mypSymbol->lowerValue();
            if ( !myLower.isEmpty() )
            {
              myLabel = myLower;
            }
            QString myUpper = mypSymbol->upperValue();
            if ( !myUpper.isEmpty() )
            {
              myLabel += " - ";
              myLabel += myUpper;
            }
            QString myText = mypSymbol->label();
            if ( !myText.isEmpty() )
            {
              myLabel += " ";
              myLabel += myText;
            }
            myLabel = myLabel.trimmed();
            myLegendXPos += myIconWidth + myLegendSpacer;
            myPrintPainter.setPen( Qt::black );

            QStringList myWrappedLayerNameList = wordWrap( myLabel,
                                                 myLegendFontMetrics,
                                                 myLegendDimensionX - myLegendXPos );
            //
            // Loop through wrapped legend label lines
            //
            QStringListIterator myLineWrapIterator( myWrappedLayerNameList );
            while ( myLineWrapIterator.hasNext() )
            {
              QString myLine = myLineWrapIterator.next();
              // check if the text will overflow the space we have
              QRect myLegendItemRect( myLegendXPos,
                                      myLegendYPos,
                                      myLegendDimensionX - myIconWidth,
                                      myLegendFontHeight );
              myPrintPainter.drawText( myLegendItemRect, Qt::AlignLeft, myLine );
              myLegendYPos += myLegendVerticalSpacer + myLegendFontHeight;
            } //wordwrap loop
          } //symbol loop
        } //class breaks
      } //if vectorlayer
    } //if maplayer
  } //layer iterator

  //reinstate the viewport
  myPrintPainter.setViewport( myOriginalViewport );


  //
  // Draw the MapFrame (bottom)
  //
  myOriginX = myPrinter.pageRect().left() + myHorizontalSpacing;
  myOriginY += myMapDimensionY + ( myVerticalSpacing * 2 );
  QLine myMapFrameBottomLine( myOriginX,
                              myOriginY,
                              myMapFrameWidth,
                              myOriginY );
  myPrintPainter.setPen( Qt::black );
  myPrintPainter.drawLine( myMapFrameBottomLine );


  //
  // Draw logo 1
  //
  int myLogoXDim = ( myDrawableWidth / 100 ) * myLogoWidthPercent;
  int myLogoYDim = ( myDrawableHeight / 100 ) * myLogoHeightPercent;
  QPixmap myLogo1;
  QgsDebugMsg( QString( "Logo1: %1" ).arg( mLogo1File ) );
  myLogo1.fill( Qt::white );
  myLogo1.load( mLogo1File );
  myLogo1 = myLogo1.scaled( myLogoXDim, myLogoYDim, Qt::KeepAspectRatio );
  myOriginX = myPrinter.pageRect().left() + myHorizontalSpacing;
  myOriginY += myVerticalSpacing ;
  myPrintPainter.drawPixmap( myOriginX,
                             myOriginY,
                             myLogo1 );

  //
  // Draw Copyright Text
  //
  myOriginX += myHorizontalSpacing + myLogoXDim;
  QRect myCopyrightRect( myOriginX, myOriginY, myLogoXDim, myLogoYDim );
  myPrintPainter.setPen( Qt::black );
  QFont myCopyrightFont( myFontFamily, myMapDateFontSize );
  myPrintPainter.setFont( myCopyrightFont );
  //myPrintPainter.drawRect( myCopyrightRect );
  myPrintPainter.drawText( myCopyrightRect, Qt::AlignCenter | Qt::TextWordWrap, mCopyrightText );

  //
  // Draw logo 2
  //
  QPixmap myLogo2;
  myLogo2.fill( Qt::white );
  myLogo2.load( mLogo2File );
  myLogo2 = myLogo2.scaled( myLogoXDim, myLogoYDim, Qt::KeepAspectRatio );
  myOriginX += myHorizontalSpacing + myLogoXDim;
  myPrintPainter.drawPixmap( myOriginX,
                             myOriginY,
                             myLogo2 );

  //
  // Draw the north arrow
  //
  myOriginX += myHorizontalSpacing + myLogoXDim;
  // use half the available space for the n.arrow
  // and the rest for the scale bar (see below)
  QPixmap myNorthArrow( myLogoYDim / 2, myLogoYDim / 2 );
  myNorthArrow.fill( Qt::white );
  QPainter myNorthPainter( &myNorthArrow );
  QSvgRenderer mySvgRenderer( mNorthArrowFile );
  mySvgRenderer.render( &myNorthPainter );
  myPrintPainter.drawPixmap( myOriginX + (( myLogoXDim / 2 ) ),
                             myOriginY,
                             myNorthArrow );

  //
  // Draw the scale bar
  //
  myOriginY += myLogoYDim / 2 + myVerticalSpacing;
  myPrintPainter.setViewport( myOriginX,
                              myOriginY,
                              myOriginalViewport.width(),
                              myOriginalViewport.height() );
  renderPrintScaleBar( &myPrintPainter, mpMapRenderer, myLogoXDim );
  myPrintPainter.setViewport( myOriginalViewport );

  //
  // Finish up
  //


  myPrintPainter.end();
#if 0
  mProgressDialog.setValue( 0 );
  mProgressDialog.setLabelText( tr( "Please wait while your report is generated", "COMMENTED OUT" ) );
  mProgressDialog.show();
  mProgressDialog.setWindowModality( Qt::WindowModal );
  mProgressDialog.setAutoClose( true );
#endif
  //
  // Restore the map render to its former glory
  //
  mpMapRenderer->setOutputSize( myOriginalSize, myOriginalDpi );
}
void LogFileSerializer::importTextFile(Ogre::DataStreamPtr &stream, LogFile *pDest)
{
    pDest->setTextPages(pageWrap(wordWrap(stream->getAsString(),94),22));
}