Changeset 57 for trunk


Ignore:
Timestamp:
Jan 19, 2006, 10:22:10 PM (20 years ago)
Author:
dmik
Message:

Implemented QWidget::setIcon().

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/qwidget.h

    r8 r57  
    946946    uint     opacity : 8;                      // Stores opacity level on Windows/Mac OS X.
    947947#endif
    948 //@@TODO (dmik): savedFlags seems not to be used by OS/2 version. enclose it with ifndef?
     948#if !defined(Q_WS_PM)
    949949    uint     savedFlags;                        // Save widgetflags while showing fullscreen
     950#endif   
    950951    short    basew, baseh;                      // base sizes
    951952#if defined(Q_WS_X11)
     
    974975    WId      fId;                               // frame window handle
    975976    HSWITCH  swEntry;                           // window list entry handle
     977    HPOINTER pmIcon;                            // internal OS/2 icon
    976978#endif
    977979    QRect    normalGeometry;                    // used by showMin/maximized/FullScreen
  • trunk/src/kernel/qwidget.cpp

    r8 r57  
    11301130        x->ussize = 0;
    11311131#endif
     1132#if !defined(Q_WS_PM)
    11321133        x->savedFlags = 0;
     1134#endif       
    11331135#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
    11341136        x->decor_allocated_region = QRegion();
  • trunk/src/kernel/qwidget_pm.cpp

    r53 r57  
    769769}
    770770
    771 //@@TODO (dmik): later
    772 ///*
    773 //  Create an icon mask the way Windows wants it using CreateBitmap.
    774 //*/
    775 //
    776 //HBITMAP qt_createIconMask( const QBitmap &bitmap )
    777 //{
    778 //    QImage bm = bitmap.convertToImage();
    779 //    int w = bm.width();
    780 //    int h = bm.height();
    781 //    int bpl = ((w+15)/16)*2;                  // bpl, 16 bit alignment
    782 //    uchar *bits = new uchar[bpl*h];
    783 //    bm.invertPixels();
    784 //    for ( int y=0; y<h; y++ )
    785 //      memcpy( bits+y*bpl, bm.scanLine(y), bpl );
    786 //    HBITMAP hbm = CreateBitmap( w, h, 1, 1, bits );
    787 //    delete [] bits;
    788 //    return hbm;
    789 //}
    790 
    791771void QWidget::setIcon( const QPixmap &pixmap )
    792772{
    793     qWarning( "QWidget::setIcon() is not yet implemented on OS/2" );
    794 //@@TODO (dmik): later
    795 //    QTLWExtra* x = topData();
    796 //    delete x->icon;
    797 //    x->icon = 0;
    798 //    if ( x->winIcon ) {
    799 //      DestroyIcon( x->winIcon );
    800 //      x->winIcon = 0;
    801 //    }
    802 //    if ( !pixmap.isNull() ) {                 // valid icon
    803 //      QPixmap pm( pixmap.size(), pixmap.depth(), QPixmap::NormalOptim );
    804 //      QBitmap mask( pixmap.size(), FALSE, QPixmap::NormalOptim );
    805 //      if ( pixmap.mask() ) {
    806 //          pm.fill( black );                   // make masked area black
    807 //          bitBlt( &mask, 0, 0, pixmap.mask() );
    808 //      } else {
    809 //          mask.fill( color1 );
    810 //      }
    811 //      bitBlt( &pm, 0, 0, &pixmap );
    812 //      HBITMAP im = qt_createIconMask(mask);
    813 //      ICONINFO ii;
    814 //      ii.fIcon    = TRUE;
    815 //      ii.hbmMask  = im;
    816 //      ii.hbmColor = pm.hbm();
    817 //      ii.xHotspot = 0;
    818 //      ii.yHotspot = 0;
    819 //      x->icon = new QPixmap( pixmap );
    820 //      x->winIcon = CreateIconIndirect( &ii );
    821 //      DeleteObject( im );
    822 //    }
    823 //    SendMessageA( winId(), WM_SETICON, 0, /* ICON_SMALL */
    824 //                (long)x->winIcon );
    825 //    SendMessageA( winId(), WM_SETICON, 1, /* ICON_BIG */
    826 //                (long)x->winIcon );
    827 //
    828 //    QEvent e( QEvent::IconChange );
    829 //    QApplication::sendEvent( this, &e );
     773    QTLWExtra* x = topData();
     774    delete x->icon;
     775    x->icon = 0;
     776    HPOINTER oldIcon = x->pmIcon;
     777    x->pmIcon = 0;
     778   
     779    if ( !pixmap.isNull() ) {                   // valid icon
     780        x->icon = new QPixmap( pixmap );
     781       
     782        if ( isTopLevel() ) {
     783            const QPixmap *normal = 0;
     784            const QPixmap *mini = 0;
     785           
     786            // QPixmap::createIcon() is not yet capable to create both normal
     787            // and mini icons (due to a bug in WinCreateIconIndirect), so
     788            // if the specified pixmap is equal or larger than the normal icon
     789            // size, then we create a normal icon, otherwise a mini one.
     790           
     791            int iconw = WinQuerySysValue( HWND_DESKTOP, SV_CXICON );
     792            int iconh = WinQuerySysValue( HWND_DESKTOP, SV_CYICON );
     793            if ( pixmap.width() >= iconw && pixmap.height() >= iconh ) {
     794                normal = &pixmap;
     795            } else {
     796                mini = &pixmap;
     797            }
     798           
     799            x->pmIcon = QPixmap::createIcon( false, 0, 0, normal, mini );
     800        }
     801    }
     802
     803    if ( isTopLevel() )
     804        WinSendMsg( x->fId, WM_SETICON, MPFROMLONG( x->pmIcon ), 0 );
     805   
     806    if ( oldIcon )
     807        WinDestroyPointer( oldIcon );
     808   
     809    QEvent e( QEvent::IconChange );
     810    QApplication::sendEvent( this, &e );
    830811}
    831812
     
    17471728void QWidget::createTLSysExtra()
    17481729{
    1749 //@@TODO (dmik): remove?
    1750 //    extra->topextra->winIcon = 0;
    17511730    extra->topextra->fId = 0;
    17521731    extra->topextra->swEntry = 0;
     1732    extra->topextra->pmIcon = 0;
    17531733}
    17541734
    17551735void QWidget::deleteTLSysExtra()
    17561736{
    1757     if ( extra->topextra->swEntry ) {
     1737    if ( extra->topextra->pmIcon )
     1738        WinDestroyPointer( extra->topextra->pmIcon );
     1739    if ( extra->topextra->swEntry )
    17581740        WinRemoveSwitchEntry( extra->topextra->swEntry );
    1759     }
    17601741    // frame window (extra->topextra->fId) is destroyed in
    17611742    // destroy() if it exists
    1762 //@@TODO (dmik): remove?
    1763 //    if ( extra->topextra->winIcon )
    1764 //      DestroyIcon( extra->topextra->winIcon );
    17651743}
    17661744
Note: See TracChangeset for help on using the changeset viewer.