QVector<QImage> CSThumbProviderWords::createThumbnails(const QSize &thumbSize) { KWCanvasItem *canvasItem = static_cast<KWCanvasItem*>(m_doc->documentPart()->canvasItem(m_doc)); KoZoomHandler zoomHandler; while (!m_doc->layoutFinishedAtleastOnce()) { QCoreApplication::processEvents(); if (!QCoreApplication::hasPendingEvents()) break; } KWPageManager *pageManager = m_doc->pageManager(); KoShapeManager *shapeManager = canvasItem->shapeManager(); QVector<QImage> thumbnails; foreach(const KWPage &page, pageManager->pages()) { QRectF pRect(page.rect()); KoPageLayout layout; layout.width = pRect.width(); layout.height = pRect.height(); KoPAUtil::setZoom(layout, thumbSize, zoomHandler); QRect pageRect = KoPAUtil::pageRect(layout, thumbSize, zoomHandler); QImage thumbnail(thumbSize, QImage::Format_RGB32); thumbnail.fill(QColor(Qt::white).rgb()); QPainter p(&thumbnail); QImage img = page.thumbnail(pageRect.size(), shapeManager); p.drawImage(pageRect, img); p.setPen(Qt::black); p.drawRect(pageRect); thumbnails.append(thumbnail); } return thumbnails; }
void CCJControlBar::DrawGripper(CDC* pDC) { if (IsFloating()) return; if (m_bGripper) { // draw the gripper. CRect pRect(GetGripperRect()); pDC->Draw3dRect( pRect, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW) ); if(IsHorzDocked()) pRect.OffsetRect(4,0); else pRect.OffsetRect(0,4); pDC->Draw3dRect( pRect, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW) ); } m_pDockSite->RecalcLayout(); }
status_t ConvertFromAMessage(const os::Message & from, Message & to) { to.Clear(); to.what = from.GetCode(); int numNames = from.GetNumNames(); for (int32 i=0; i<numNames; i++) { int type; int count; std::string name = from.GetName(i); if (from.GetNameInfo(name.c_str(), &type, &count) == B_NO_ERROR) { for (int j=0; j<count; j++) { const void * nextItem; size_t itemSize; if (from.FindData(name.c_str(), type, &nextItem, &itemSize, j) != B_NO_ERROR) return B_ERROR; // do any necessary translation from the AtheOS data types to Muscle data types switch(type) { case os::T_POINT: { const os::Point * p = static_cast<const os::Point *>(nextItem); Point pPoint(p->x, p->y); if (to.AddPoint(name.c_str(), pPoint) != B_NO_ERROR) return B_ERROR; } break; case os::T_RECT: { const os::Rect * r = static_cast<const os::Rect *>(nextItem); Rect pRect(r->left, r->top, r->right, r->bottom); if (to.AddRect(name.c_str(), pRect) != B_NO_ERROR) return B_ERROR; } break; case os::T_MESSAGE: { os::Message amsg; if (amsg.Unflatten(static_cast<const uint8 *>(nextItem)) != B_NO_ERROR) return B_ERROR; Message * newMsg = newnothrow Message; if (newMsg) { MessageRef msgRef(newMsg); if (ConvertFromAMessage(amsg, *newMsg) != B_NO_ERROR) return B_ERROR; if (to.AddMessage(name.c_str(), msgRef) != B_NO_ERROR) return B_ERROR; } else {WARN_OUT_OF_MEMORY; return B_ERROR;} } break; default: if (to.AddData(name.c_str(), type, nextItem, itemSize) != B_NO_ERROR) return B_ERROR; break; } } } } return B_NO_ERROR; }