示例#1
0
QPixmap BitmapFactoryInst::resize(int w, int h, const QPixmap& p, Qt::BGMode bgmode) const
{
    if (bgmode == Qt::TransparentMode) {
        if (p.width() == 0 || p.height() == 0)
            w = 1;

        QPixmap pix = p;
        int x = pix.width () > w ? 0 : (w - pix.width ())/2;
        int y = pix.height() > h ? 0 : (h - pix.height())/2;

        if (x == 0 && y == 0)
            return pix;

        QPixmap pm (w,h);
        QBitmap mask (w,h);
        mask.fill(Qt::color0);

        QBitmap bm = pix.mask();
        if (!bm.isNull())
        {
            QPainter painter(&mask);
            painter.drawPixmap(QPoint(x, y), bm, QRect(0, 0, pix.width(), pix.height()));
            pm.setMask(mask);
        }
        else
        {
            pm.setMask(mask);
            pm = fillRect(x, y, pix.width(), pix.height(), pm, Qt::OpaqueMode);
        }

        QPainter pt;
        pt.begin( &pm );
        pt.drawPixmap(x, y, pix);
        pt.end();
        return pm;
    } else { // Qt::OpaqueMode
        QPixmap pix = p;

        if (pix.width() == 0 || pix.height() == 0)
            return pix; // do not resize a null pixmap

        QPalette pal = qApp->palette();
        QColor dl = pal.color(QPalette::Disabled, QPalette::Light);
        QColor dt = pal.color(QPalette::Disabled, QPalette::Text);

        QPixmap pm = pix;
        pm = QPixmap(w,h);
        pm.fill(dl);

        QPainter pt;
        pt.begin( &pm );
        pt.setPen( dl );
        pt.drawPixmap(1, 1, pix);
        pt.setPen( dt );
        pt.drawPixmap(0, 0, pix);
        pt.end();
        return pm;
    }
}
示例#2
0
ShapeWidget::ShapeWidget(QWidget *parent)
	: QWidget(parent,Qt::FramelessWindowHint)
{
    QPixmap pix;
    pix.load(":/images/tux.png",0,Qt::AvoidDither|Qt::ThresholdDither|Qt::ThresholdAlphaDither);
    resize(pix.size());
    setMask(pix.mask());
}
示例#3
0
void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
{
#if 0
     QTLWExtra* x = d->topData();
     delete x->icon;
     x->icon = 0;
    QBitmap mask;
    if (unscaledPixmap.isNull()) {
    } else {
        QImage unscaledIcon = unscaledPixmap.toImage();
        QPixmap pixmap =
            QPixmap::fromImage(unscaledIcon.scale(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
        x->icon = new QPixmap(pixmap);
        mask = pixmap.mask() ? *pixmap.mask() : pixmap.createHeuristicMask();
    }
#endif
}
示例#4
0
// Transparent images are converted to 32bpp pixmaps, but
// setting those as window background needs ARGB visual
// and compositing - convert to 24bpp, at least for now.
static QPixmap make24bpp( const QPixmap& p )
    {
    QPixmap ret( p.size());
    QPainter pt( &ret );
    pt.drawPixmap( 0, 0, p );
    pt.end();
    ret.setMask( p.mask());
    return ret;
    }
示例#5
0
void KWM::setIcon(Window w, const QPixmap &pm){
  XWMHints *hints = XGetWMHints(qt_xdisplay(), w);
  if (!hints)
    hints = XAllocWMHints();
  QPixmap *p = new QPixmap;
  *p = pm;
  hints->icon_pixmap=p->handle();
  hints->flags |= IconPixmapHint;
  if(p->mask()){
    hints->icon_mask = p->mask()->handle();
    hints->flags |= IconMaskHint;
  }
  else
    hints->flags &= ~IconMaskHint;
  XSetWMHints( qt_xdisplay(), w, hints );
  XFree((char*)hints);
  delete p;
}
void QSanButton::setSize(QSize newSize) {
    _m_size = newSize;
    if (_m_size.width() == 0 || _m_size.height() == 0) {
        _m_mask = QRegion();
        return;
    }
    Q_ASSERT(!_m_bgPixmap[0].isNull());
    QPixmap pixmap = _m_bgPixmap[0];
    _m_mask = QRegion(pixmap.mask().scaled(newSize));
}
示例#7
0
void
set_background_properties(QWidget *w)
{
    QPixmap bg = getClassPixmap((char*)"EPPLET_BACKGROUND_VERTICAL", (char*)"normal", w);
    if (!bg.isNull()){
        int border = 2;
        QPixmap img = getClassPixmap((char*)"EPPLET_DRAWINGAREA", (char*)"normal", w,
                                     w->width() - border * 2, w->height() - border * 2);
        if (!img.isNull()){
            QPainter p(&bg);
            p.drawPixmap(border, border, img);
        }
        w->setBackgroundPixmap(bg);
        if (bg.mask()){
            w->setMask(*bg.mask());
        }else{
            w->clearMask();
        }
    }
}
示例#8
0
//ÖØдpaintEvent,Ìí¼Ó±³¾°Í¼Æ¬
void MusicListWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QPixmap backgroundImage;
    backgroundImage.load(":/images/musicList.png");

    //ÏÈͨ¹ýpixµÄ·½·¨»ñµÃͼƬµÄ¹ýÂ˵ô͸Ã÷µÄ²¿·ÖµÃµ½µÄͼƬ£¬×÷ΪloginPanelµÄ²»¹æÔò±ß¿ò
    this ->setMask(backgroundImage.mask());
    painter.drawPixmap(0, 0, 400, 450, backgroundImage);
    event ->accept();
}
示例#9
0
//重写paintEvent,添加背景图片
void MinMusicWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QPixmap backgroundImage;
    backgroundImage.load(":/images/minMainBg2.png");

    //先通过pix的方法获得图片的过滤掉透明的部分得到的图片,作为loginPanel的不规则边框
    this ->setMask(backgroundImage.mask());
    painter.drawPixmap(0, 0, 200, 159, backgroundImage);
    event ->accept();
}
//! ----------------------------------------------------------------------------------------------------------------
//!
//! \brief TestWindow::drawBackground
//!
void TestWindow::drawBackground(){
    QPixmap *pixmap = new QPixmap(":/images/background.png");
    QPalette p =  this->palette();

    p.setBrush(QPalette::Background,
               QBrush(pixmap->scaled(QSize(appSize.width(), appSize.height()),
                                     Qt::IgnoreAspectRatio,
                                     Qt::SmoothTransformation)));

    this->setPalette(p);
    this->setMask(pixmap->mask());
}
示例#11
0
QPixmap BitmapFactoryInst::merge(const QPixmap& p1, const QPixmap& p2, bool vertical) const
{
    int width = 0;
    int height = 0;

    int x = 0;
    int y = 0;

    // get the size for the new pixmap
    if (vertical) {
        y = p1.height();
        width  = qMax( p1.width(), p2.width() );
        height = p1.height() + p2.height();
    } else {
        x = p1.width();
        width  = p1.width() + p2.width();
        height = qMax( p1.height(), p2.height() );
    }

    QPixmap res( width, height );
    QBitmap mask( width, height );
    QBitmap mask1 = p1.mask();
    QBitmap mask2 = p2.mask();
    mask.fill( Qt::color0 );

    QPainter* pt1 = new QPainter(&res);
    pt1->drawPixmap(0, 0, p1);
    pt1->drawPixmap(x, y, p2);
    delete pt1;

    QPainter* pt2 = new QPainter(&mask);
    pt2->drawPixmap(0, 0, mask1);
    pt2->drawPixmap(x, y, mask2);
    delete pt2;

    res.setMask(mask);
    return res;
}
示例#12
0
void WharfIcon::set(const char *icon, const char *msg)
{
    const QIconSet &icons = Icon(icon);
    QPixmap *nvis = new QPixmap(icons.pixmap(QIconSet::Large, QIconSet::Normal));
    QPixmap *nvish = new QPixmap(icons.pixmap(QIconSet::Large, QIconSet::Active));
    resize(nvis->width(), nvis->height());
    if (msg){
        QPixmap msgPict = Pict(msg);
        QRegion *rgn = NULL;
        if (nvis->mask() && msgPict.mask()){
            rgn = new QRegion(*msgPict.mask());
            rgn->translate(nvis->width() - msgPict.width() - 2,
                           nvis->height() - msgPict.height() - 2);
            *rgn += *nvis->mask();
        }
        QPainter p;
        p.begin(nvis);
        p.drawPixmap(nvis->width() - msgPict.width() - 2,
                     nvis->height() - msgPict.height() - 2, msgPict);
        p.end();
        p.begin(nvish);
        p.drawPixmap(nvish->width() - msgPict.width() - 2,
                     nvish->height() - msgPict.height() - 2, msgPict);
        p.end();
        if (rgn){
            setMask(*rgn);
            delete rgn;
        }
    }else{
        const QBitmap *mask = nvis->mask();
        if (mask) setMask(*mask);
    }
    if (vis) delete vis;
    vis = nvis;
    if (vish) delete vish;
    vish = nvish;
    repaint();
}
示例#13
0
void QWidget::setIcon( const QPixmap &unscaledPixmap )
{
    if ( extra && extra->topextra ) {
	delete extra->topextra->icon;
	extra->topextra->icon = 0;
    } else {
	createTLExtra();
    }
    QBitmap mask;
    if ( unscaledPixmap.isNull() ) {
    } else {
	QImage unscaledIcon = unscaledPixmap.convertToImage();
	QPixmap pixmap;
#ifndef QT_NO_IMAGE_SMOOTHSCALE
	pixmap.convertFromImage( unscaledIcon.smoothScale( 16, 16 ) );
#else
	pixmap.convertFromImage( unscaledIcon );
#endif
	extra->topextra->icon = new QPixmap( pixmap );
	mask = pixmap.mask() ? *pixmap.mask() : pixmap.createHeuristicMask();
    }
    // XXX
}
示例#14
0
/*------------------------------------------------------------------*
 * MODIFICATIONS													*
 *	Date		Description							Author			*
 * ===========	==================================	===============	*
 *																	*
 *------------------------------------------------------------------*/
void ZUtils::MaskWidget(QWidget* pWidget, const QString& pImage)
{
	QPixmap vPix;
	QBitmap vBitmap;

	QImage vImg(QImage::fromMimeSource(pImage));
	vPix.convertFromImage(vImg);
	if (!vPix.mask())
	{
		if (vImg.hasAlphaBuffer())
		{
			vBitmap = vImg.createAlphaMask();
			vPix.setMask(vBitmap);
		}
		else
		{
			vBitmap = vImg.createHeuristicMask();
			vPix.setMask(vBitmap);
		}
	}
	if (vPix.mask())
		pWidget->setMask(*vPix.mask());
}
示例#15
0
/*------------------------------------------------------------------*
 * MODIFICATIONS													*
 *	Date		Description							Author			*
 * ===========	==================================	===============	*
 *																	*
 *------------------------------------------------------------------*/
void ZPushButton::MaskButton(const QPixmap *pPix)
{
	QPixmap vPix;
	QBitmap vBitMask;

	QImage vImg(pPix->convertToImage());
	vPix = *pPix;
	if (!vPix.mask())
	{
		if (vImg.hasAlphaBuffer())
		{
			vBitMask = vImg.createAlphaMask();
			vPix.setMask(vBitMask);
		}
		else
		{
			vBitMask = vImg.createHeuristicMask();
			vPix.setMask(vBitMask);
		}
	}
	if (vPix.mask())
		setMask(*vPix.mask());
}
示例#16
0
void WharfIcon::set(const char *icon, const char *msg)
{
    const QIconSet *icons = Icon(icon);
    if (icons == NULL)
        return;
    QPixmap *nvis = new QPixmap(icons->pixmap(QIconSet::Large, QIconSet::Normal));
    if (bActivated){
        resize(nvis->width(), nvis->height());
        move((p_width - nvis->width()) / 2, (p_height - nvis->height()) / 2);
    }
    if (msg){
        QPixmap msgPict = Pict(msg);
        QRegion *rgn = NULL;
        if (nvis->mask() && msgPict.mask()){
            rgn = new QRegion(*msgPict.mask());
            rgn->translate(nvis->width() - msgPict.width() - SMALL_PICT_OFFS,
                           nvis->height() - msgPict.height() - SMALL_PICT_OFFS);
            *rgn += *nvis->mask();
        }
        QPainter p;
        p.begin(nvis);
        p.drawPixmap(nvis->width() - msgPict.width() - SMALL_PICT_OFFS,
                     nvis->height() - msgPict.height() - SMALL_PICT_OFFS, msgPict);
        p.end();
        if (rgn){
            setMask(*rgn);
            delete rgn;
        }
    }else{
        const QBitmap *mask = nvis->mask();
        if (mask) setMask(*mask);
    }
    if (vis) delete vis;
    vis = nvis;
    setIcon(*vis);
    repaint();
}
示例#17
0
QPixmap * RazorDeskIconBase::initialPainting(QIcon::Mode mode)
{
    qDebug() << "RazorDeskIconBase::initialPainting";
    
    if (icon().isNull())
    {
        qDebug() << "RazorDeskIconBase::setPos - icon() is null. Skipping for now.";
        return 0;
    }
    
    QPixmap * pm = new QPixmap(70, 70);
    pm->fill(QColor(0,0,0,0));

    QPainter painter(pm);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setRenderHint(QPainter::HighQualityAntialiasing);
    painter.setRenderHint(QPainter::NonCosmeticDefaultPen);
    
    // now the icon
    QPixmap appIcon = icon().pixmap(iconSize(), mode);
    // HACK: in some cases we can get larger icon than expected so rescale
    //       it with brute force if it's required...
    if (appIcon.size().width() > iconSize().width())
        appIcon = appIcon.scaled(iconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);

    QRect source(0, 0, 32, 32);
    int w = pm->width() / 2;
    int h = pm->height() / 2;
    int iw = iconSize().width() / 2;
    int ih = iconSize().height() / 2;
    QRect target(w - iw, h - ih - 10,
                 iconSize().width(), iconSize().height());
    painter.drawPixmap(target, appIcon, source);

    // text now - it has to follow potential QSS
    QColor txt = palette().color(QPalette::WindowText);
    painter.setPen(txt);
    painter.setBrush(palette().color(QPalette::Window));
    painter.drawText(QRectF(2, h+ih-10, pm->width()-4, pm->height()-h-ih+10),
                     Qt::AlignCenter | Qt::TextWordWrap | Qt::TextIncludeTrailingSpaces | Qt::TextDontClip,
                     text());
    painter.end();

    pm->setMask(pm->createHeuristicMask());
    setMask(pm->mask());
    
    return pm;
}
示例#18
0
void tst_QPixmap::mask()
{
    QFETCH(QSize, size);

    QPixmap src = rasterPixmap(size);
    src.fill(Qt::transparent);
    {
        QPainter p(&src);
        p.drawLine(QPoint(0, 0), QPoint(src.width(), src.height()));
    }

    QBENCHMARK {
        QBitmap bitmap = src.mask();
        QVERIFY(bitmap.size() == src.size());
    }
}
示例#19
0
/*!
  \internal
  A static function for reading the sprite files containing
  pixmaps for displaying animated elements seen in the game.
 */
void KSprite::loadSprites()
{
    QString sprites_prefix = IMG_BACKGROUND;
    int sep = sprites_prefix.lastIndexOf("/");
    sprites_prefix.truncate(sep);

    int i = 0;
    QString file_name;
    QString base = sprites_prefix + '/';
    while (animations_[i].id_) {
	QList<QPixmap> p;
	if (animations_[i].frames_) {
	    for (int j=0; j<animations_[i].frames_; ++j) {
		QString s(animations_[i].path_);
		file_name = base + s.arg(j,4,10,QLatin1Char('0'));
		QPixmap pixmap(file_name);
		p.insert(j,pixmap);
	    }
	}
	else {
	    file_name = base + QString(animations_[i].path_);
	    QPixmap pixmap(file_name);
	    p.insert(0,pixmap);
	}

        QList<Frame> frameshape;
        for (int f = 0; f < p.size(); ++f) {
            QPixmap pixmap = p.at(f);
            Frame frame;
            frame.pixmap = pixmap;
            QPainterPath path;
            QBitmap m = pixmap.mask();
            if (m.width())
                path.addRegion(QRegion(m));
            else
                path.addRegion(QRect(pixmap.rect()));
            frame.shape = path;
            frame.boundingRect = path.controlPointRect();
            frameshape << frame;
        }
	shapemap_.insert(animations_[i].id_,frameshape);

        i++;
    }
    spritesLoaded_ = true;
}
示例#20
0
void SetApp::startAppManagerStatus()
{

    appManagerStatus = true;
    label_AppDelFlag = new QLabel(this);
    label_AppDelFlag->setWindowFlags(Qt::CustomizeWindowHint);
    label_AppDelFlag->setObjectName(QString::fromUtf8("label_AppDelFlag"));

    label_AppDelFlag->setGeometry(QRect(5, 5, 22, 22));
    QPixmap  pixMap = QPixmap(QString(":/images/close.png"));
    label_AppDelFlag->setPixmap(pixMap);
    label_AppDelFlag->setMask(pixMap.mask());
    label_AppDelFlag->show();
    appShakeTimer = new QTimer(this);
    connect(appShakeTimer,SIGNAL(timeout()),this,SLOT(appShake()));
    appShakeTimer->start(80);


}
示例#21
0
QPixmap BitmapFactoryInst::fillRect(int x, int y, int w, int h, const QPixmap& p, Qt::BGMode bgmode) const
{
    QBitmap b = p.mask();
    if (b.isNull())
        return p; // sorry, but cannot do anything

    QPixmap pix = p;

    // modify the mask
    QPainter pt;
    pt.begin(&b);
    if (bgmode == Qt::OpaqueMode)
        pt.fillRect(x, y, w, h, Qt::color1); // make opaque
    else // Qt::TransparentMode
        pt.fillRect(x, y, w, h, Qt::color0); // make transparent
    pt.end();

    pix.setMask(b);

    return pix;
}
示例#22
0
void wxQtDCImpl::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
                          bool useMask )
{
    QPixmap pix = *bmp.GetHandle();
    if (pix.depth() == 1) {
        //Monochrome bitmap, draw using text fore/background
        
        //Save pen/brush
        QBrush savedBrush = m_qtPainter->background();
        QPen savedPen = m_qtPainter->pen();
        
        //Use text colors
        m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetHandle()));
        m_qtPainter->setPen(QPen(m_textForegroundColour.GetHandle()));

        //Draw
        m_qtPainter->drawPixmap(x, y, pix);
        
        //Restore saved settings
        m_qtPainter->setBackground(savedBrush);
        m_qtPainter->setPen(savedPen);
    } else {
        if ( !useMask && bmp.GetMask() )
        {
            // Temporarly disable mask
            QBitmap mask;
            mask = pix.mask();
            pix.setMask( QBitmap() );

            // Draw
            m_qtPainter->drawPixmap(x, y, pix);

            // Restore saved mask
            pix.setMask( mask );
        }
        else
            m_qtPainter->drawPixmap(x, y, pix);
    }
}
示例#23
0
PriceChecker::PriceChecker( QWidget *parent )
: KDialog( parent )
{
  setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
  ui = new PriceCheckerUI( this );
  setMainWidget( ui );
  setCaption( i18n("Price Checker") );
  setButtons( KDialog::NoDefault );
  ui->titleTop->setText(i18nc("Price-Checker dialog", "Price")); //FIXME: translation problems!!!!!!
  ui->titleBottom->setText(i18nc("Price-Checker dialog", "Checker")); //FIXME: translation problems!!!!!!
  ui->labelPCCode->setText(i18n("&Code:"));
  ui->labelPCClose->setText(i18n("Press ESC to Close"));
  ui->labelPClPrice->setText(i18n("Regular price:"));
  ui->labelPClTotal->setText(i18n("Final price:"));
  ui->labelPClDiscount->setText(i18n("Discount:"));
  QString path = KStandardDirs::locate("appdata", "styles/");
  QPixmap pix = QPixmap(path + Settings::styleName() + "/priceCheckerBack.png");
  resize(517,309);
  setMask( pix.mask() );
  pix = QPixmap(path + Settings::styleName() + "/pricechecker.png");
  ui->titleImg->setPixmap(pix);

  //connect( ui->editCode, SIGNAL(textEdited(const QString &)),this, SLOT(checkIt()) );
  //NOTE: There are some issues when having the 'textEdited' signal connected to ckeckIt(),
  //      When you want to use the barcode reader, it sends an enter and then the code is ready to be searched.
  //      Then if you want to read another code to search, the edit line is not cleared. it makes difficult to use it.
  //      So we need to execute the query when the 'enter' event is rised and clean the code input line to let it ready for another search.
  //      With textEdited the code is searched every single number is entered (when not using barcode reader)
  //      causing many database queries to be executed.
  connect( ui->editCode, SIGNAL(returnPressed()),this, SLOT(checkIt()) );
  
//  QRegExp regexpC("[0-9]{1,13}");
//  QRegExpValidator * validator = new QRegExpValidator(regexpC, this);
//  ui->editCode->setValidator(validator);

  ui->editCode->setFocus();

  myDb = new Azahar;
}
StudentDashBoard::StudentDashBoard(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::StudentDashBoard)
{
    ui->setupUi(this);
    //set style
    Style style;
    style.styleWork(this);
    statusLabel = new QLabel;
    statusLabel->setAlignment(Qt::AlignRight|Qt::AlignBottom);
    ui->statusbar->addWidget(statusLabel,this->width());
    //set timer
    timer = new QTimer;
    messageCheck = new QTimer;
    hasMessage = false;
    broadCastTimer = new QTimer;
    clearBroadCastContent = new QTimer;
    showBroadCastWin = new ShowBroadCastContent;
    clearHelpContent = new QTimer;
    // ppt window
    pptWin = new PPTView;
    //    pptWin->setWindowFlags(Qt::WType_TopLevel|Qt::WStyle_StaysOnTop |Qt::WindowTitleHint);
    //coding win
    codingWin = new CodingWindow;
    codingWin->setWindowFlags(Qt::WType_TopLevel|Qt::WStyle_StaysOnTop |Qt::WindowTitleHint);
    questionWin = new QuestionWindow;
    message = QString(tr("test message from server"));
    socket = new QTcpSocket;
    videoViewWin = new VideoView;
    //  videoViewWin->setWindowFlags(Qt::WType_TopLevel|Qt::WStyle_StaysOnTop |Qt::WindowTitleHint);
    questionId = 0;
    QPixmap pix;
    pix.load("resource/dashboardbg.jpg",0,Qt::AvoidDither | Qt::ThresholdAlphaDither | Qt::ThresholdDither);
    resize(pix.size());
    setMask(pix.mask());
    createActions();
    createGlobalActions();
    //   showHelpInfo();
}
示例#25
0
void DockWnd::timer()
{
    if (++m_state >= 4) m_state = 0;
    ShowIcon needIcon = State;
    bool bBlinked = pClient->isConnecting();
    unsigned short msgType = 0;
    if (pMain->messages.size()) msgType = pMain->messages.back().type();
    switch (m_state){
    case 1:
        if (msgType){
            needIcon = Message;
        }else if (bBlinked){
            needIcon = Blinked;
        }
        break;
    case 2:
        if (msgType && bBlinked)
            needIcon = Blinked;
        break;
    case 3:
        if (msgType){
            needIcon = Message;
        }else if (bBlinked){
            needIcon = Blinked;
        }
        break;
    }
    if (needIcon == showIcon) return;
    showIcon = needIcon;
    switch (showIcon){
    case State:
        setIcon(Pict(pClient->getStatusIcon()));
        break;
    case Message:
        setIcon(Pict(SIMClient::getMessageIcon(msgType)));
        break;
    case Blinked:
        setIcon(Pict(SIMClient::getStatusIcon(ICQ_STATUS_ONLINE)));
        break;
    default:
        break;
    }
#ifndef WIN32
    if (inTray) return;
    const char *icon = pClient->getStatusIcon();
    const char *msg  = NULL;
    const char *bmsg = NULL;
    if (msgType) bmsg = SIMClient::getMessageIcon(msgType);
    if (bBlinked){
        if (m_state & 1){
            icon = SIMClient::getStatusIcon(ICQ_STATUS_ONLINE);
        }else{
            msg = bmsg;
        }
    }else{
        if (!(m_state & 1)){
            msg = bmsg;
        }
    }
    if (wharfIcon){
        wharfIcon->set(icon, msg);
        return;
    }
    const QIconSet &icons = Icon(icon);
    QPixmap nvis(icons.pixmap(QIconSet::Large, QIconSet::Normal));
    if (!bEnlightenment){
        resize(nvis.width(), nvis.height());
        if (msg){
            QPixmap msgPict = Pict(msg);
            QRegion *rgn = NULL;
            if (nvis.mask() && msgPict.mask()){
                rgn = new QRegion(*msgPict.mask());
                rgn->translate(nvis.width() - msgPict.width() - SMALL_PICT_OFFS,
                               nvis.height() - msgPict.height() - SMALL_PICT_OFFS);
                *rgn += *nvis.mask();
            }
            QPainter p;
            p.begin(&nvis);
            p.drawPixmap(nvis.width() - msgPict.width() - SMALL_PICT_OFFS,
                         nvis.height() - msgPict.height() - SMALL_PICT_OFFS, msgPict);
            p.end();
            if (rgn){
                setMask(*rgn);
                delete rgn;
            }
        }else{
            const QBitmap *mask = nvis.mask();
            if (mask) setMask(*mask);
        }
    }
    drawIcon = nvis;
    repaint();
#endif
}
示例#26
0
InputDialog::InputDialog(QWidget *parent, bool integer, DialogType type, QString msg, double min, double max)
{
  dialogType = type;
  _max = max;
  _min = min;
  setParent(parent);
  setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
  setWindowModality(Qt::ApplicationModal);
  setModal(true);

  vLayout       = new QVBoxLayout(this);
  titleLayout   = new QHBoxLayout();
  gridLayout    = new QGridLayout();
  lPixmap       = new QLabel(this);

  // Icons for each type
  if (type == dialogMeasures) lPixmap->setPixmap(DesktopIcon("kruler", 48));
  else if (type == dialogMoney) lPixmap->setPixmap(DesktopIcon("lemon-money", 48));
  else if (type==dialogCashOut) lPixmap->setPixmap(DesktopIcon("lemon-cashout", 48));
  else if (type == dialogTicket) lPixmap->setPixmap(DesktopIcon("lemon-ticket-cancel", 48));
  else if (type == dialogSpecialOrder) lPixmap->setPixmap(DesktopIcon("lemon-ticket", 48));
  else if (type == dialogStockCorrection) lPixmap->setPixmap(DesktopIcon("squeeze-stock-correction", 48));
  else if (type == dialogTerminalNum) lPixmap->setPixmap(DesktopIcon("lemon-money", 48)); //FIXME: add an icon
  else if (type == dialogTicketMsg)   lPixmap->setPixmap(DesktopIcon("lemon-ticket", 48));


  //labels
  titleLayout->addWidget(lPixmap);
  label = new QLabel(msg, this);
  label->setWordWrap(true);
  titleLayout->addWidget(label);
  QSpacerItem *spacerItem2 = new QSpacerItem(50, 50, QSizePolicy::Minimum, QSizePolicy::Maximum);
  vLayout->addLayout(titleLayout);
  vLayout->addItem(spacerItem2);
  productCodeEdit = new KLineEdit(this);
  reasonEdit = new KLineEdit(this);
  lineEdit = new KLineEdit(this);
  productCodeLabel = new QLabel("Product Code:", this);

  if (type == dialogTicketMsg) qLabel = new QLabel(i18n("Month or Season:"));
  else if (type == dialogStockCorrection) qLabel = new QLabel(i18n("New Stock Qty:"));
  else qLabel = new QLabel(i18n("Amount:"));

  if (type == dialogTicketMsg) reasonLabel = new QLabel(i18n("New Message:"), this);
  else reasonLabel = new QLabel(i18n("Reason:"), this);

  if (type == dialogTicket || type == dialogSpecialOrder) qLabel->setText(i18n("Ticket #:"));


  //layout
  gridLayout->addWidget(productCodeLabel, 0,0,0);//1,1);
  gridLayout->addWidget(productCodeEdit, 0,1,0);//1,1);
  gridLayout->addWidget(reasonLabel, 1,0,0);//1,1);
  gridLayout->addWidget(reasonEdit, 1,1,0);//1,1);
  gridLayout->addWidget(qLabel, 2,0,0);//1,1);
  gridLayout->addWidget(lineEdit, 2,1,0);//1,1);
  vLayout->addLayout(gridLayout);

 if (type == dialogCashOut) {
    lineEdit->setClickMessage(i18n("valid amount between %1 and %2", min,max));
    reasonLabel->show();
    reasonEdit->show();
    productCodeEdit->hide();
    productCodeLabel->hide();
  }
  else if (type == dialogStockCorrection ) {
    productCodeEdit->setClickMessage(i18n("Enter the product code here..."));
    lineEdit->setClickMessage(i18n("Enter the new stock quantity here..."));
    productCodeEdit->show();
    productCodeLabel->show();
    reasonLabel->show();
    reasonEdit->show();
  }
  else if (type == dialogTerminalNum) {
   qLabel->setText("Terminal Number:");
   lineEdit->setClickMessage(i18n("Enter the terminal number here..."));
   productCodeEdit->hide();
   productCodeLabel->hide();
   reasonLabel->hide();
   reasonEdit->hide();
  }
  else if (type == dialogTicketMsg) {
   lineEdit->setClickMessage(i18n("Enter the number of the month or season here..."));
   productCodeEdit->hide();
   productCodeLabel->hide();
  }
  else {
    reasonLabel->hide();
    reasonEdit->hide();
    productCodeEdit->hide();
    productCodeLabel->hide();
  }

  //qDebug()<<"Min:"<<min<<"Max:"<<max;
  if (integer) {
    int imin=min; int imax=0;
    if (max>2147483640) imax=2147483647; else imax=max; //max positive value for INT
    //qulonglong imax=max;
    //qDebug()<<"Min:"<<imin<<"Max:"<<imax;
    //FIXME: El valor pasado a max es un DOUBLE, y es mas chico que qulonglong. en mi compu ambos son de 8 bytes.
    //qDebug()<<"Size of qulonglong is "<<sizeof(qulonglong);
    //qDebug()<<"Size of a double is   "<<sizeof(double);
    //NOTE: Nov 21 2009. Returned value is a qulonglong, so integer validator is not good!
    QIntValidator *validator = new QIntValidator(imin, imax,this);
    lineEdit->setValidator(validator);
    //qintvalidator range is in int (not qlonglong)
    // I NEED TO MAKE VALIDATION WITH REGULAR EXPRESSIONS TO SUPPORT LARGE NUMBERS if we need to do so.. ticket numbers larger
    // than 2,147,483,647. For now, its ok, its at the order of billions (thousand millions).
  } else {
    QDoubleValidator *validator = new QDoubleValidator(min, max, 3,this);
    lineEdit->setValidator(validator);
  }
  QRegExp regexpC("[1-9]+[0-9]*[//.]{0,1}[0-9]{0,2}[xX]{0,1}[0-9]{0,13}");
  QRegExpValidator * validatorEAN13 = new QRegExpValidator(regexpC, this);
  productCodeEdit->setValidator(validatorEAN13);

  
  buttonsLayout = new QHBoxLayout();
  buttonAccept = new QPushButton(this);
  buttonAccept->setText(i18n("Ok"));
  buttonAccept->setDefault( true );
  buttonCancel = new QPushButton(this);
  buttonCancel->setText(i18n("Cancel"));
  buttonCancel->setShortcut(Qt::Key_Escape);
  buttonsLayout->addWidget(buttonCancel);
  buttonsLayout->addWidget(buttonAccept);
  if (type == dialogStockCorrection ) {
    buttonAccept->hide();
    buttonCancel->hide();
  }

  //QSpacerItem *spacerItem3 = new QSpacerItem(70, 70, QSizePolicy::Minimum, QSizePolicy::Maximum);
  //buttonsLayout->addItem(spacerItem3);
  vLayout->addLayout(buttonsLayout);

  buttonAccept->setMaximumSize(QSize(130, 27));
  buttonCancel->setMaximumSize(QSize(130, 27));
  lineEdit->setMaximumSize(QSize(260, 27));
  reasonEdit->setMaximumSize(QSize(260, 27));
  productCodeEdit->setMaximumSize(QSize(260, 27));
  
  iValue = 0;
  dValue = 0.0;
  reason = "";

  label->setObjectName("titleLabelInputDialog");

  //style
  //QRect geom = geometry();
  //qDebug()<<"Geometry before resize:"<<geom;
  resize(362,158);
  //geom = geometry();
  //qDebug()<<"Geometry after resize:"<<geom;
  QString path = KStandardDirs::locate("appdata", "styles/");
  QPixmap pixm = QPixmap(path + Settings::styleName() + "/dialog.png");
  setMask( pixm.mask() );
  
  connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(acceptIt()));
  connect(reasonEdit, SIGNAL(returnPressed()), this, SLOT(acceptIt()));
  connect(buttonAccept, SIGNAL(clicked()), this, SLOT(acceptIt()));
  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
  connect(productCodeEdit, SIGNAL(returnPressed()), this, SLOT(acceptIt()));
}
示例#27
0
static HCURSOR qt_createPixmapCursor( const QCursor &cursor, const QPixmap &pixmap, const QPoint &hotspot )
{
    QSize size;

    /* calculate size of cursor */
    QPoint pt = hotspot - cursor.hotSpot();
    QPoint pixmap_point( 0, 0 );
    QPoint cursor_point( 0, 0 );

    if ( qWinVersion() <= Qt::WV_95 ) {
        /* Win95 can only fixed size */
        size.setWidth( GetSystemMetrics ( SM_CXCURSOR ) );
        size.setHeight ( GetSystemMetrics ( SM_CYCURSOR ) );
    } else {
        /* calculate size (enlarge if needed) */
        const QBitmap *tmp = cursor.bitmap();

        /* Only bitmap cursors allowed... */
        if ( tmp ) {
            QPoint point;

            // curent size
            size = pixmap.size();

            // calc position of lower right cursor pos
            point.setX( pt.x() + tmp->size().width() );
            point.setY( pt.y() + tmp->size().height() );
            // resize when cursor to large
            if ( point.x() > pixmap.width() )
                size.setWidth( point.x() );
            if ( point.y() > pixmap.height() )
                size.setHeight( point.y() );

            // calc upper left corner where both pixmaps have to be drawn
            if ( pt.x() >= 0 ) {
                cursor_point.setX( pt.x() );
            } else {
                pixmap_point.setX( -pt.x() );
                // negative position -> resize
                size.setWidth( size.width() - pt.x() );
            }
            if ( pt.y() >= 0 ) {
                cursor_point.setX( pt.x() );
            } else {
                pixmap_point.setY( -pt.y() );
                // negative position -> resize
                size.setHeight( size.height() - pt.y() );
            }

        }
    }

    /* Mask */
    QBitmap andMask( size );
    BitBlt( andMask.handle(), 0, 0, size.width(), size.height(), NULL, 0, 0, WHITENESS );
    if ( pixmap.mask() )
        BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), pixmap.mask() ->handle(), 0, 0, SRCAND );
    else
        BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), NULL, 0, 0, BLACKNESS );
    const QBitmap *curMsk = cursor.mask();
    if ( curMsk )
        BitBlt( andMask.handle(), cursor_point.x(), cursor_point.y(), curMsk->width(), curMsk->height(), curMsk->handle(), 0, 0, SRCAND );

    /* create Pixmap */
    QPixmap xorMask( size );
    xorMask.fill ( Qt::color1 );
    QPainter paint2( &xorMask );
    paint2.drawPixmap( pixmap_point, pixmap );

    QPixmap pm;
    pm.convertFromImage( cursor.bitmap() ->convertToImage().convertDepth( 8 ) );
    pm.setMask( *cursor.mask() );
    paint2.drawPixmap ( cursor_point, pm );
    paint2.end();

#ifdef DEBUG_QDND_SRC

    andMask.save ( "pand.png", "PNG" );
    xorMask.save ( "pxor.png", "PNG" );
#endif

    HCURSOR cur = qt_createPixmapCursor ( qt_display_dc(), xorMask, andMask, hotspot, size );

    if ( !cur ) {
        qWarning( "Error creating cursor: %d", GetLastError() );
    }
    return cur;
}
示例#28
0
void QSanButton::setSize(QSize newSize)
{
    _m_size = newSize;
    QPixmap pixmap = G_ROOM_SKIN.getButtonPixmap(_m_buttonName, _m_state);
    _m_mask = QRegion(pixmap.mask().scaled(newSize));
}
示例#29
0
// protected virtual [base QWidget]
void kpDualColorButton::paintEvent (QPaintEvent *e)
{
#if DEBUG_KP_DUAL_COLOR_BUTTON && 1
    qCDebug(kpLogWidgets) << "kpDualColorButton::draw() rect=" << rect ()
               << " contentsRect=" << contentsRect ()
               << endl;
#endif

    // Draw frame first.
    QFrame::paintEvent (e);

    QPainter painter (this);

    // Fill with background.
    if (isEnabled ())
    {
        kpView::drawTransparentBackground (&painter,
            contentsRect ().topLeft ()/*checkerboard top-left*/,
            contentsRect (),
            true/*preview*/);
    }
    else
    {
        // Use default widget background.
    }


    painter.translate (contentsRect ().x (), contentsRect ().y ());


    // Draw "Swap Colours" button (top-right).
    QPixmap swapPixmap = UserIcon ("colorbutton_swap_16x16");
    if (!isEnabled ())
    {
        // Don't let the fill() touch the mask.
        QBitmap swapBitmapMask = swapPixmap.mask ();
        swapPixmap.setMask (QBitmap ());

        // Grey out the opaque parts of "swapPixmap".
        swapPixmap.fill (palette ().color (QPalette::Dark));

        swapPixmap.setMask (swapBitmapMask);
    }
    painter.drawPixmap (swapPixmapRect ().topLeft (), swapPixmap);


    // Draw background colour patch.
    QRect bgRect = backgroundRect ();
    QRect bgRectInside = QRect (bgRect.x () + 2, bgRect.y () + 2,
                                bgRect.width () - 4, bgRect.height () - 4);
    if (isEnabled ())
    {
    #if DEBUG_KP_DUAL_COLOR_BUTTON && 1
        qCDebug(kpLogWidgets) << "\tbackgroundColor=" << (int *) m_color [1].toQRgb ()
                   << endl;
    #endif
        if (m_color [1].isTransparent ())  // only if fully transparent
            painter.drawPixmap (bgRectInside, UserIcon ("color_transparent_26x26"));
        else
            painter.fillRect (bgRectInside, m_color [1].toQColor ());
    }
    else
        painter.fillRect (bgRectInside, palette().color (QPalette::Button));
    qDrawShadePanel (&painter, bgRect, palette(),
                     false/*not sunken*/, 2/*lineWidth*/,
                     0/*never fill*/);


    // Draw foreground colour patch.
    // Must be drawn after background patch since we're on top.
    QRect fgRect = foregroundRect ();
    QRect fgRectInside = QRect (fgRect.x () + 2, fgRect.y () + 2,
                                fgRect.width () - 4, fgRect.height () - 4);
    if (isEnabled ())
    {
    #if DEBUG_KP_DUAL_COLOR_BUTTON && 1
        qCDebug(kpLogWidgets) << "\tforegroundColor=" << (int *) m_color [0].toQRgb ()
                   << endl;
    #endif
        if (m_color [0].isTransparent ())  // only if fully transparent
            painter.drawPixmap (fgRectInside, UserIcon ("color_transparent_26x26"));
        else
            painter.fillRect (fgRectInside, m_color [0].toQColor ());
    }
    else
        painter.fillRect (fgRectInside, palette ().color (QPalette::Button));

    qDrawShadePanel (&painter, fgRect, palette (),
                     false/*not sunken*/, 2/*lineWidth*/,
                     0/*never fill*/);
}
static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy)
{
    HCURSOR cur = 0;
#if !defined(Q_WS_WINCE)
    QBitmap mask = pixmap.mask();
    if (mask.isNull()) {
        mask = QBitmap(pixmap.size());
        mask.fill(Qt::color1);
    }

    HBITMAP ic = pixmap.toWinHBITMAP(QPixmap::Alpha);
    HBITMAP im = qt_createIconMask(mask);

    ICONINFO ii;
    ii.fIcon     = 0;
    ii.xHotspot  = hx;
    ii.yHotspot  = hy;
    ii.hbmMask   = im;
    ii.hbmColor  = ic;

    cur = CreateIconIndirect(&ii);

    DeleteObject(ic);
    DeleteObject(im);
#elif defined(GWES_ICONCURS)
    QImage bbits, mbits;
    bool invb, invm;
    bbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
    mbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
    invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
    invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));

    int sysW = GetSystemMetrics(SM_CXCURSOR);
    int sysH = GetSystemMetrics(SM_CYCURSOR);
    int sysN = qMax(1, sysW / 8);
    int n = qMax(1, bbits.width() / 8);
    int h = bbits.height();

    uchar* xBits = new uchar[sysH * sysN];
    uchar* xMask = new uchar[sysH * sysN];
    int x = 0;
    for (int i = 0; i < sysH; ++i) {
        if (i >= h) {
            memset(&xBits[x] , 255, sysN);
            memset(&xMask[x] ,   0, sysN);
            x += sysN;
        } else {
            int fillWidth = n > sysN ? sysN : n;
            uchar *bits = bbits.scanLine(i);
            uchar *mask = mbits.scanLine(i);
            for (int j = 0; j < fillWidth; ++j) {
                uchar b = bits[j];
                uchar m = mask[j];
                if (invb)
                    b ^= 0xFF;
                if (invm)
                    m ^= 0xFF;
                xBits[x] = ~m;
                xMask[x] = b ^ m;
                ++x;
            }
            for (int j = fillWidth; j < sysN; ++j ) {
                xBits[x] = 255;
                xMask[x] = 0;
                ++x;
            }
        }
    }

    cur = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH,
        xBits, xMask);
#else
    Q_UNUSED(pixmap);
    Q_UNUSED(hx);
    Q_UNUSED(hy);
#endif
    return cur;
}