Changeset 174 for trunk/src/kernel


Ignore:
Timestamp:
Nov 6, 2007, 11:27:57 PM (18 years ago)
Author:
dmik
Message:

Styles: Implemented the first version of the Warp4 style (contributed by Cornelis Bockemuehl).

Location:
trunk/src/kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel/qapplication.cpp

    r172 r174  
    12351235            else
    12361236                style = "Windows";              // default styles for Windows
    1237 #elif defined(Q_WS_PM)
    1238             /// @todo (dmik) temporary, until the native style is done
    1239             style = "Windows";          // default style for OS/2
     1237// this is temporarily disabled until most bugs are fixed,
     1238// see http://svn.netlabs.org/qr3/ticket/9 for details
     1239//#elif defined(Q_WS_PM)
     1240//          style = "Warp4";            // default style for OS/2
     1241//#endif
    12401242#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS)
    12411243            style = "CDE";                      // default style for X11 on Solaris
     
    12531255        if ( !app_style &&              // platform default style not available, try alternatives
    12541256             !(app_style = QStyleFactory::create( "Windows" ) ) &&
     1257//           !(app_style = QStyleFactory::create( "Warp4" ) ) &&
    12551258             !(app_style = QStyleFactory::create( "Platinum" ) ) &&
    12561259             !(app_style = QStyleFactory::create( "MotifPlus" ) ) &&
     
    13701373  The string must be one of the QStyleFactory::keys(), typically one
    13711374  of "windows", "motif", "cde", "motifplus", "platinum", "sgi" and
    1372   "compact". Depending on the platform, "windowsxp", "aqua" or
     1375  "compact". Depending on the platform, "windowsxp", "warp4", "aqua" or
    13731376  "macintosh" may be available.
    13741377
  • trunk/src/kernel/qapplication_pm.cpp

    r171 r174  
    131131                           const QPixmap *, int, int, int );
    132132
     133Q_EXPORT
    133134QRgb qt_sysclr2qrgb( LONG sysClr )
    134135{
     
    139140}
    140141
    141 QFont qt_sysfont2qfont( const PSZ scope ) {
     142static
     143QFont qt_sysfont2qfont( const PSZ scope )
     144{
    142145    static const PSZ app = "PM_SystemFonts";
    143     static const PSZ def = "8.Helv";
     146    static const PSZ def = "10.System Proportional";
    144147    ULONG keyLen = 0;
    145     QFont f( "Helv", 8 );
     148    QFont f( "System Proportional", 10 );
    146149
    147150    if ( PrfQueryProfileSize( HINI_USERPROFILE, app, scope, &keyLen ) && keyLen ) {
     
    369372    // Do the font settings
    370373
     374#ifndef QT_PM_NO_DEFAULTFONT_OVERRIDE
    371375    QFont windowFont = qt_sysfont2qfont( "WindowText" );
     376#else
     377    QFont windowFont = qt_sysfont2qfont( "DefaultFont" );
     378#endif
    372379    QFont menuFont = qt_sysfont2qfont( "Menus" );
    373380    QFont iconFont = qt_sysfont2qfont( "IconText" );
     
    440447    *qt_std_pal = pal;
    441448
    442     // a special palette for menus
    443     acg.setColor( QColorGroup::Highlight,
     449    // special palettes
     450    QColorGroup scg;
     451
     452    // menus
     453    scg = acg;
     454    scg.setColor( QColorGroup::Background,
     455                  QColor( qt_sysclr2qrgb( SYSCLR_MENU ) ) );
     456    scg.setColor( QColorGroup::Highlight,
    444457                  QColor( qt_sysclr2qrgb( SYSCLR_MENUHILITEBGND ) ) );
    445     acg.setColor( QColorGroup::HighlightedText,
     458    scg.setColor( QColorGroup::HighlightedText,
    446459                  QColor( qt_sysclr2qrgb( SYSCLR_MENUHILITE ) ) );
    447     QApplication::setPalette( QPalette( acg, dcg, icg ), TRUE, "QPopupMenu");
    448     QApplication::setPalette( QPalette( acg, dcg, icg ), TRUE, "QMenuBar");
     460    pal.setActive( scg );
     461    pal.setInactive( scg );
     462    QApplication::setPalette( pal, TRUE, "QPopupMenu" );
     463    QApplication::setPalette( pal, TRUE, "QMenuBar" );
     464
     465    // static widget texts
     466    scg = acg;
     467    QColor staticTextCol( qt_sysclr2qrgb( SYSCLR_WINDOWSTATICTEXT ) );
     468    scg.setColor( QColorGroup::Foreground, staticTextCol );
     469    scg.setColor( QColorGroup::Text, staticTextCol );
     470    pal.setActive( scg );
     471    pal.setInactive( scg );
     472    QApplication::setPalette( pal, TRUE, "QLabel" );
     473    QApplication::setPalette( pal, TRUE, "QGroupBox" );
    449474}
    450475
     
    457482{
    458483public:
    459     static bool &installed() { return QtOS2SysXcptMainHandler::installed; } 
     484    static bool &installed() { return QtOS2SysXcptMainHandler::installed; }
    460485    static ERR &libcHandler() { return QtOS2SysXcptMainHandler::libcHandler; }
    461486    static ERR handler() { return QtOS2SysXcptMainHandler::handler; }
     
    486511    DosGetInfoBlocks( &ptib, NULL );
    487512    Q_ASSERT( ptib && ptib->tib_ptib2 );
    488    
     513
    489514    if ( ptib && ptib->tib_ptib2 ) {
    490         // must be called only on the main (first) thread 
     515        // must be called only on the main (first) thread
    491516        Q_ASSERT( ptib->tib_ptib2->tib2_ultid == 1 );
    492517        // also make sure that QtOS2SysXcptMainHandler was not already
     
    551576    // default font
    552577    if ( !qt_app_has_font )
    553         QApplication::setFont( QFont( "Helv", 8 ) );
     578        QApplication::setFont( QFont( "System Proportional", 10 ) );
    554579
    555580    // QFont::locale_init();  ### Uncomment when it does something on OS/2
     
    590615
    591616#if !defined(QT_OS2_NO_SYSEXCEPTIONS)
    592     // remove the exception handler if it was installed in qt_init() 
     617    // remove the exception handler if it was installed in qt_init()
    593618    PTIB ptib = NULL;
    594619    DosGetInfoBlocks( &ptib, NULL );
    595620    Q_ASSERT( ptib && ptib->tib_ptib2 );
    596    
     621
    597622    if ( ptib && ptib->tib_ptib2 ) {
    598         // must be called only on the main (first) thread 
     623        // must be called only on the main (first) thread
    599624        Q_ASSERT( ptib->tib_ptib2->tib2_ultid == 1 );
    600625        // also make sure the handler was really installed by qt_init()
     
    10031028enum {
    10041029    // some undocumented messages (they have the WM_U_ prefix for clarity)
    1005    
     1030
    10061031    // sent to hwnd that has been entered to by a mouse pointer.
    10071032    // FID_CLIENT also receives enter messages of its WC_FRAME.
     
    20642089        return;
    20652090    }
    2066    
     2091
    20672092    // find the modal's group leader
    20682093    QWidget *mgl = modal->parentWidget();
     
    25482573#endif
    25492574        if ( curWin != winId() ) {              // new current window
    2550 /// @todo (dmik)           
     2575/// @todo (dmik)
    25512576//  add CS_HITTEST to our window classes and handle WM_HITTEST,
    25522577//  otherwise disabled windows will not get mouse events?
     
    27642789//  Alt+letter shortcuts in the NLS keyboard mode together with Alt+NLS_letter
    27652790//  shortcuts  (nice feature imho). Note that Alt+NLS_letter shortcuts are
    2766 //  correctly processed in any case. 
     2791//  correctly processed in any case.
    27672792
    27682793// cache table to store Qt::Key_... values for 256 hardware scancodes
  • trunk/src/kernel/qfont_pm.cpp

    r8 r174  
    5858{
    5959    switch( styleHint ) {
    60         case QFont::Times:
    61             return QString::fromLatin1("Times New Roman");
    62         case QFont::Courier:
    63             return QString::fromLatin1("Courier");
    64         case QFont::Decorative:
    65             return QString::fromLatin1("Times New Roman");
    66         case QFont::Helvetica:
    67             return QString::fromLatin1("Helvetica");
    68         case QFont::System:
    69 //@@TODO (dmik): check for OS/2 ver and return the appropriate system font
    70 //  (i.e. "System Proportional" for ver <= Warp 3)
    71             return QString::fromLatin1("WarpSans");
    72         default:
     60        case QFont::Times:
     61            return QString::fromLatin1( "Times New Roman" );
     62        case QFont::Courier:
     63            return QString::fromLatin1( "Courier" );
     64        case QFont::Decorative:
     65            return QString::fromLatin1( "Times New Roman" );
     66        case QFont::Helvetica:
     67            return QString::fromLatin1( "Helvetica" );
     68        case QFont::System: {
     69#ifndef QT_PM_NO_DEFAULTFONT_OVERRIDE
     70            static ULONG ver[2] = {0};
     71            if ( ver[0] == ver[1] == 0 ) {
     72                DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
     73                                 &ver, sizeof(ver) );
     74            }
     75            if ( ver[0] == 20 && ver[1] >= 40 )
     76                return QString::fromLatin1( "WarpSans" );
     77            else
     78#endif
     79            return QString::fromLatin1( "System Proportional" );
     80        }
     81        default:
    7382            // the family to be used when no StyleHint is set (in accordance
    7483            // with the font matching algorithm stated in QFont docs)
    75             return QString::fromLatin1("Helvetica");
     84            return QString::fromLatin1( "Helvetica" );
    7685    }
    7786//@@TODO (dmik): should we also add default font substitutions to
     
    7988}
    8089
    81 //@@TODO (dmik): remove
    82 //extern HDC   shared_dc;               // common dc for all fonts
    83 
    84 //@@TODO (dmik): remove?
    85 //// ### maybe move to qapplication_win
    86 //QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/)
    87 //{
    88 //    QString family = QT_WA_INLINE( QString::fromUcs2((ushort*)lf.lfFaceName),
    89 //                                 QString::fromLocal8Bit((char*)lf.lfFaceName) );
    90 //    QFont qf(family);
    91 //    qf.setItalic(lf.lfItalic);
    92 //    if (lf.lfWeight != FW_DONTCARE) {
    93 //      int weight;
    94 //      if ( lf.lfWeight < 400 )
    95 //          weight = QFont::Light;
    96 //      else if ( lf.lfWeight < 600 )
    97 //          weight = QFont::Normal;
    98 //      else if ( lf.lfWeight < 700 )
    99 //          weight = QFont::DemiBold;
    100 //      else if ( lf.lfWeight < 800 )
    101 //          weight = QFont::Bold;
    102 //      else
    103 //          weight = QFont::Black;
    104 //      qf.setWeight(weight);
    105 //    }
    106 //    int lfh = QABS( lf.lfHeight );
    107 //    Q_ASSERT(shared_dc);
    108 //    qf.setPointSizeFloat( lfh * 72.0 / GetDeviceCaps(shared_dc,LOGPIXELSY) );
    109 //    qf.setUnderline(FALSE);
    110 //    qf.setOverline(FALSE);
    111 //    qf.setStrikeOut(FALSE);
    112 //    return qf;
    113 //}
    114 
    115 
    116 //@@TODO (dmik): need these two funcs?
    117 //static inline float pixelSize( const QFontDef &request, QPaintDevice *paintdevice,
    118 //                             int )
    119 //{
    120 //    float pSize;
    121 //    if ( request.pointSize != -1 ) {
    122 //      if ( paintdevice ) {
    123 //          pSize = request.pointSize *
    124 //                  QPaintDeviceMetrics( paintdevice ).logicalDpiY() / 720.;
    125 //      } else {
    126 //            LONG dpi;
    127 //            DevQueryCaps( GpiQueryDevice( qt_display_ps() ),
    128 //                CAPS_VERTICAL_FONT_RES, 1, &val );
    129 //          pSize = (request.pointSize*dpi + 360) / 720;
    130 //        }
    131 //    } else {
    132 //      pSize = request.pixelSize;
    133 //    }
    134 //    return pSize;
    135 //}
    136 //
    137 //static inline float pointSize( const QFontDef &fd, QPaintDevice *paintdevice,
    138 //                             int )
    139 //{
    140 //    float pSize;
    141 //    if ( fd.pointSize == -1 ) {
    142 //      if ( paintdevice ) {
    143 //          pSize = fd.pixelSize * 720. /
    144 //                  QPaintDeviceMetrics( paintdevice ).logicalDpiY();
    145 //      } else {
    146 //            LONG dpi;
    147 //            DevQueryCaps( GpiQueryDevice( qt_display_ps() ),
    148 //                CAPS_VERTICAL_FONT_RES, 1, &val );
    149 //          pSize = fd.pixelSize * 72.0 / dpi;
    150 //        }
    151 //    } else {
    152 //      pSize = fd.pointSize;
    153 //    }
    154 //    return pSize;
    155 //}
    156 
    15790/*****************************************************************************
    15891  QFont member functions
     
    16598    if ( QFontCache::instance )
    16699        return;
    167 //@@TODO (dmik): remove
    168 //    shared_dc = CreateCompatibleDC( qt_display_dc() );
    169 //#if defined(QT_CHECK_RANGE)
    170 //    if ( !shared_dc )
    171 //      qSystemWarning( "QFont::initialize() (qfont_win.cpp, 163): couldn't create device context" );
    172 //#endif
    173100    new QFontCache();
    174101
     
    180107{
    181108    delete QFontCache::instance;
    182 //@@TODO (dmik): remove
    183 //    DeleteDC( shared_dc );
    184 //    shared_dc = 0;
    185109}
    186110
     
    194118    // sanity checks
    195119    if (!QFontCache::instance)
    196         qWarning("Must construct a QApplication before a QFont");
     120        qWarning("Must construct a QApplication before a QFont");
    197121    Q_ASSERT( script >= 0 && script < QFont::LastPrivateScript );
    198122#endif // QT_CHECK_STATE
     
    204128    } else {
    205129        DevQueryCaps( GpiQueryDevice( qt_display_ps() ),
    206             CAPS_VERTICAL_FONT_RES, 1, (PLONG) &dpi );
     130                      CAPS_VERTICAL_FONT_RES, 1, (PLONG) &dpi );
    207131    }
    208132    if (req.pointSize != -1)
     
    212136
    213137    if ( ! engineData ) {
    214         QFontCache::Key key( req, QFont::NoScript, (int)paintdevice );
    215 
    216         // look for the requested font in the engine data cache
    217         engineData = QFontCache::instance->findEngineData( key );
    218 
    219         if ( ! engineData) {
    220             // create a new one
    221             engineData = new QFontEngineData;
    222             QFontCache::instance->insertEngineData( key, engineData );
    223         } else {
    224             engineData->ref();
    225         }
     138        QFontCache::Key key( req, QFont::NoScript, (int)paintdevice );
     139
     140        // look for the requested font in the engine data cache
     141        engineData = QFontCache::instance->findEngineData( key );
     142
     143        if ( ! engineData) {
     144            // create a new one
     145            engineData = new QFontEngineData;
     146            QFontCache::instance->insertEngineData( key, engineData );
     147        } else {
     148            engineData->ref();
     149        }
    226150    }
    227151
     
    239163
    240164    if (!req.family.isEmpty()) {
    241         family_list = QStringList::split( ',', req.family );
    242 
    243         // append the substitute list for each family in family_list
    244         QStringList subs_list;
    245         QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
    246         for ( ; it != end; ++it )
    247             subs_list += QFont::substitutes( *it );
    248         family_list += subs_list;
     165        family_list = QStringList::split( ',', req.family );
     166
     167        // append the substitute list for each family in family_list
     168        QStringList subs_list;
     169        QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
     170        for ( ; it != end; ++it )
     171            subs_list += QFont::substitutes( *it );
     172        family_list += subs_list;
    249173
    250174//@@TODO (dmik): need something here?
    251         // append the default fallback font for the specified script
    252         // family_list << ... ; ###########
     175        // append the default fallback font for the specified script
     176        // family_list << ... ; ###########
    253177
    254178        // add the family corresponding to font's styleHint
    255179        QString hintFamily = qt_pm_default_family( request.styleHint );
    256         if ( ! family_list.contains( hintFamily ) )
     180        if ( ! family_list.contains( hintFamily ) )
    257181            family_list << hintFamily;
    258182
     
    262186//  below added to the list.
    263187
    264         // add the default family
    265         QString defaultFamily = QApplication::font().family();
    266         if ( ! family_list.contains( defaultFamily ) )
    267             family_list << defaultFamily;
    268 
    269         // add QFont::defaultFamily() to the list, for compatibility with
    270         // previous versions
    271         family_list << QApplication::font().defaultFamily();
     188        // add the default family
     189        QString defaultFamily = QApplication::font().family();
     190        if ( ! family_list.contains( defaultFamily ) )
     191            family_list << defaultFamily;
     192
     193        // add QFont::defaultFamily() to the list, for compatibility with
     194        // previous versions
     195        family_list << QApplication::font().defaultFamily();
    272196    }
    273197
     
    277201    QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
    278202    for ( ; ! engine && it != end; ++it ) {
    279         req.family = *it;
    280 
    281         engine = QFontDatabase::findFont( script, this, req );
    282         if ( engine ) {
    283             if ( engine->type() != QFontEngine::Box )
    284                 break;
    285 
    286             if ( ! req.family.isEmpty() )
    287                 engine = 0;
    288 
    289             continue;
    290         }
     203        req.family = *it;
     204
     205        engine = QFontDatabase::findFont( script, this, req );
     206        if ( engine ) {
     207            if ( engine->type() != QFontEngine::Box )
     208                break;
     209
     210            if ( ! req.family.isEmpty() )
     211                engine = 0;
     212
     213            continue;
     214        }
    291215    }
    292216
     
    343267QString QFont::lastResortFont() const
    344268{
    345     return QString::fromLatin1("System Proportional");
     269    return QString::fromLatin1( "System Proportional" );
    346270}
    347271
     
    351275  QFontMetrics member functions
    352276 *****************************************************************************/
    353 
    354 //@@TODO (dmik): remove
    355 //#define IS_TRUETYPE (QT_WA_INLINE( engine->tm.w.tmPitchAndFamily, engine->tm.a.tmPitchAndFamily ) & TMPF_TRUETYPE)
    356 //#define TMX engine->tm.w
    357 //#define TMW engine->tm.w
    358 //#define TMA engine->tm.a
    359277
    360278//@@TODO (dmik): do we need a separate (other than in qfont.cpp)
Note: See TracChangeset for help on using the changeset viewer.