Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/activeqt/container/qaxwidget.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the ActiveQt framework of the Qt Toolkit.
     
    3839****************************************************************************/
    3940
    40 #ifndef UNICODE
    41 #define UNICODE
    42 #endif
    43 
    44 
    4541#include "qaxwidget.h"
    4642
     
    124120
    125121    int qt_metacall(QMetaObject::Call, int isignal, void **argv);
     122    void* qt_metacast(const char *clname);
     123
    126124    inline QAxClientSite *clientSite() const
    127125    {
     
    384382
    385383private:
    386 #if !defined(Q_OS_WINCE)
     384#if !defined(Q_WS_WINCE)
    387385    struct OleMenuItem {
    388386        OleMenuItem(HMENU hm = 0, int ID = 0, QMenu *menu = 0)
     
    409407
    410408    DWORD m_dwOleObject;
    411 #if !defined(Q_OS_WINCE)
     409#if !defined(Q_WS_WINCE)
    412410    HWND m_menuOwner;
    413411#endif
     
    418416    QAxWidget *widget;
    419417    QAxHostWidget *host;
    420 #if !defined(Q_OS_WINCE)
     418#if !defined(Q_WS_WINCE)
    421419    QPointer<QMenuBar> menuBar;
    422420    QMap<QAction*,OleMenuItem> menuItemMap;
     
    468466#error "Fix QAbstractEventDispatcher::setEventFilter"
    469467#endif
    470 #if defined(Q_OS_WINCE)
     468#if defined(Q_WS_WINCE)
    471469static int filter_ref = 0;
    472470#else
    473 static const char *qaxatom = "QAxContainer4_Atom";
     471static const wchar_t *qaxatom = L"QAxContainer4_Atom";
    474472#endif
    475473
     
    484482        QAxHostWidget *host = 0;
    485483        while (!host && hwnd) {
    486             host = qobject_cast<QAxHostWidget*>(QWidget::find(hwnd));
     484            QWidget *widget = QWidget::find(hwnd);
     485            if (widget && widget->inherits("QAxHostWidget"))
     486                host = qobject_cast<QAxHostWidget*>(widget);
    487487            hwnd = ::GetParent(hwnd);
    488488        }
     
    533533
    534534QAxClientSite::QAxClientSite(QAxWidget *c)
    535 : ref(1), widget(c), host(0), eventTranslated(true)
     535: eventTranslated(true), ref(1), widget(c), host(0)
    536536{
    537537    aggregatedObject = widget->createAggregate();
     
    552552
    553553    m_dwOleObject = 0;
    554 #if !defined(Q_OS_WINCE)
     554#if !defined(Q_WS_WINCE)
    555555    m_menuOwner = 0;
    556556    menuBar = 0;
     
    715715        HRESULT result = m_spOleObject->GetUserType(USERCLASSTYPE_SHORT, &userType);
    716716        if (result == S_OK) {
    717             widget->setWindowTitle(QString::fromUtf16((const ushort *)userType));
     717            widget->setWindowTitle(QString::fromWCharArray(userType));
    718718            CoTaskMemFree(userType);
    719719        }
     
    982982HRESULT WINAPI QAxClientSite::TranslateAccelerator(LPMSG lpMsg, DWORD /*grfModifiers*/)
    983983{
    984     eventTranslated = false;
    985984    if (lpMsg->message == WM_KEYDOWN && !lpMsg->wParam)
    986985        return S_OK;
    987     QT_WA_INLINE(
    988         SendMessage(host->winId(), lpMsg->message, lpMsg->wParam, lpMsg->lParam),
    989         SendMessageA(host->winId(), lpMsg->message, lpMsg->wParam, lpMsg->lParam)
    990     );
     986
     987    bool ActiveQtDetected = false;
     988    bool fromInProcServer = false;
     989#ifdef GWLP_USERDATA
     990    LONG_PTR serverType = GetWindowLongPtr(lpMsg->hwnd, GWLP_USERDATA);
     991#else
     992    LONG serverType = GetWindowLong(lpMsg->hwnd, GWL_USERDATA);
     993#endif
     994    if (serverType == QAX_INPROC_SERVER) {
     995        ActiveQtDetected = true;
     996        fromInProcServer = true;
     997    } else if (serverType == QAX_OUTPROC_SERVER) {
     998        ActiveQtDetected = true;
     999        fromInProcServer = false;
     1000    }
     1001
     1002    eventTranslated = false;
     1003    if (!ActiveQtDetected || !fromInProcServer) {
     1004        // if the request is coming from an out-of-proc server or a non ActiveQt server,
     1005        // we send the message to the host window. This will make sure this key event
     1006        // comes to Qt for processing.
     1007        SendMessage(host->winId(), lpMsg->message, lpMsg->wParam, lpMsg->lParam);
     1008        if (ActiveQtDetected && !fromInProcServer) {
     1009            // ActiveQt based servers will need further processing of the event
     1010            // (eg. <SPACE> key for a checkbox), so we return false.
     1011            return S_FALSE;
     1012        }
     1013    }
     1014    // ActiveQt based in-processes-servers will handle the event properly, so
     1015    // we dont need to send this key event to the host.
    9911016    return S_OK;
    9921017}
     
    11331158
    11341159//**** IOleInPlaceFrame
    1135 #if defined(Q_OS_WINCE)
     1160#if defined(Q_WS_WINCE)
    11361161HRESULT WINAPI QAxClientSite::InsertMenus(HMENU /*hmenuShared*/, LPOLEMENUGROUPWIDTHS /*lpMenuWidths*/)
    11371162{
     
    11741199}
    11751200
    1176 static int menuItemEntry(HMENU menu, int index, MENUITEMINFOA item, QString &text, QPixmap &/*icon*/)
     1201static int menuItemEntry(HMENU menu, int index, MENUITEMINFO item, QString &text, QPixmap &/*icon*/)
    11771202{
    11781203    if (item.fType == MFT_STRING && item.cch) {
    1179         char *titlebuf = new char[item.cch+1];
     1204        wchar_t *titlebuf = new wchar_t[item.cch + 1];
    11801205        item.dwTypeData = titlebuf;
    11811206        item.cch++;
    1182         ::GetMenuItemInfoA(menu, index, true, &item);
    1183         text = QString::fromLocal8Bit(titlebuf);
    1184         delete []titlebuf;
     1207        ::GetMenuItemInfo(menu, index, true, &item);
     1208        text = QString::fromWCharArray(titlebuf);
     1209        delete [] titlebuf;
    11851210        return MFT_STRING;
    11861211    }
     
    11921217        QPixmap pixmap(1,1);
    11931218        QSize sz(MAP_LOGHIM_TO_PIX(bmsize.cx, pixmap.logicalDpiX()),
    1194             MAP_LOGHIM_TO_PIX(bmsize.cy, pixmap.logicalDpiY()));
     1219                 MAP_LOGHIM_TO_PIX(bmsize.cy, pixmap.logicalDpiY()));
    11951220
    11961221        pixmap.resize(bmsize.cx, bmsize.cy);
     
    12161241        popup = new QMenu(parent);
    12171242    for (int i = 0; i < count; ++i) {
    1218         MENUITEMINFOA item;
    1219         memset(&item, 0, sizeof(MENUITEMINFOA));
    1220         item.cbSize = sizeof(MENUITEMINFOA);
     1243        MENUITEMINFO item;
     1244        memset(&item, 0, sizeof(MENUITEMINFO));
     1245        item.cbSize = sizeof(MENUITEMINFO);
    12211246        item.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU;
    1222         ::GetMenuItemInfoA(subMenu, i, true, &item);
     1247        ::GetMenuItemInfo(subMenu, i, true, &item);
    12231248
    12241249        QAction *action = 0;
     
    12961321        int count = GetMenuItemCount(hmenuShared);
    12971322        for (int i = 0; i < count; ++i) {
    1298             MENUITEMINFOA item;
    1299             memset(&item, 0, sizeof(MENUITEMINFOA));
    1300             item.cbSize = sizeof(MENUITEMINFOA);
     1323            MENUITEMINFO item;
     1324            memset(&item, 0, sizeof(MENUITEMINFO));
     1325            item.cbSize = sizeof(MENUITEMINFO);
    13011326            item.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU;
    1302             ::GetMenuItemInfoA(hmenuShared, i, true, &item);
     1327            ::GetMenuItemInfo(hmenuShared, i, true, &item);
    13031328
    13041329            QAction *action = 0;
     
    13801405    OleMenuItem oleItem = menuItemMap.value(action);
    13811406    if (oleItem.hMenu)
    1382         ::PostMessageA(m_menuOwner, WM_COMMAND, oleItem.id, 0);
     1407        ::PostMessage(m_menuOwner, WM_COMMAND, oleItem.id, 0);
    13831408    return -1;
    13841409#endif
     
    14051430HRESULT WINAPI QAxClientSite::SetStatusText(LPCOLESTR pszStatusText)
    14061431{
    1407     QStatusTipEvent tip(QString::fromUtf16((const ushort *)(BSTR)pszStatusText));
     1432    QStatusTipEvent tip(QString::fromWCharArray(pszStatusText));
    14081433    QApplication::sendEvent(widget, &tip);
    14091434    return S_OK;
     
    14141439HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable)
    14151440{
     1441#if !defined(Q_OS_WINCE)
     1442    LockWindowUpdate(host->window()->winId());
     1443#endif
    14161444    EnableWindow(host->window()->winId(), fEnable);
    14171445
     
    14241452    }
    14251453    qt_win_ignoreNextMouseReleaseEvent = false;
    1426 
     1454#if !defined(Q_OS_WINCE)
     1455    LockWindowUpdate(0);
     1456#endif
    14271457    return S_OK;
    14281458}
     
    15121542{
    15131543    AX_DEBUG(QAxClientSite::SetActiveObject);
    1514 
    1515     if (pszObjName && widget)
    1516         widget->setWindowTitle(QString::fromUtf16((const ushort *)(BSTR)pszObjName));
     1544   
     1545    Q_UNUSED(pszObjName);
     1546    // we are ignoring the name of the object, as suggested by MSDN documentation
     1547    // for IOleInPlaceUIWindow::SetActiveObject().
    15171548
    15181549    if (m_spInPlaceActiveObject) {
     
    16241655        return axhost->qt_metacall(call, isignal, argv);
    16251656    return -1;
     1657}
     1658
     1659void* QAxHostWidget::qt_metacast(const char *clname)
     1660{
     1661    if (!clname) return 0;
     1662    if (!qstrcmp(clname,"QAxHostWidget"))
     1663        return static_cast<void*>(const_cast< QAxHostWidget*>(this));
     1664    return QWidget::qt_metacast(clname);
    16261665}
    16271666
     
    19531992
    19541993#if !defined(Q_OS_WINCE)
    1955     ATOM filter_ref = FindAtomA(qaxatom);
     1994    ATOM filter_ref = FindAtom(qaxatom);
    19561995#endif
    19571996    if (!filter_ref)
    19581997        previous_filter = QAbstractEventDispatcher::instance()->setEventFilter(axc_FilterProc);
    19591998#if !defined(Q_OS_WINCE)
    1960     AddAtomA(qaxatom);
     1999    AddAtom(qaxatom);
    19612000#else
    19622001    ++filter_ref;
     
    19932032    if (!control().isEmpty()) {
    19942033#if !defined(Q_OS_WINCE)
    1995         ATOM filter_ref = FindAtomA(qaxatom);
     2034        ATOM filter_ref = FindAtom(qaxatom);
    19962035        if (filter_ref)
    19972036            DeleteAtom(filter_ref);
    1998         filter_ref = FindAtomA(qaxatom);
     2037        filter_ref = FindAtom(qaxatom);
    19992038        if (!filter_ref) {
    20002039#else
     
    20432082
    20442083/*!
    2045     \reimp
     2084    \internal
    20462085*/
    20472086const QMetaObject *QAxWidget::metaObject() const
     
    20512090
    20522091/*!
    2053     \reimp
     2092    \internal
    20542093*/
    20552094const QMetaObject *QAxWidget::parentMetaObject() const
     
    20692108
    20702109/*!
    2071     \reimp
     2110    \internal
    20722111*/
    20732112const char *QAxWidget::className() const
     
    20772116
    20782117/*!
    2079     \reimp
     2118    \internal
    20802119*/
    20812120int QAxWidget::qt_metacall(QMetaObject::Call call, int id, void **v)
Note: See TracChangeset for help on using the changeset viewer.