diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-10-04 10:58:57 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-04 11:16:34 +0200 |
commit | 53ca8a7a66d4ff811516774c010237d195cec1cb (patch) | |
tree | 7142b66314f8cb9d2a0900e3e6b6077851630d8d | |
parent | eb0849338fc951c7efe758de5b50276b83219ac4 (diff) | |
download | qtactiveqt-53ca8a7a66d4ff811516774c010237d195cec1cb.tar.gz |
Fix compilation after refactor merge.
Comment out Some functionality for the moment.
Change-Id: Ia7d1d3ba982e97776ae7259be06689b5477450a1
Reviewed-on: http://codereview.qt-project.org/5972
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
29 files changed, 430 insertions, 59 deletions
diff --git a/examples/activeqt/comapp/comapp.pro b/examples/activeqt/comapp/comapp.pro index 84ce072..c7feb02 100644 --- a/examples/activeqt/comapp/comapp.pro +++ b/examples/activeqt/comapp/comapp.pro @@ -1,6 +1,8 @@ TEMPLATE = app CONFIG += qaxserver +QT += widgets + # Input SOURCES += main.cpp diff --git a/examples/activeqt/comapp/main.cpp b/examples/activeqt/comapp/main.cpp index 66af248..0f5fe43 100644 --- a/examples/activeqt/comapp/main.cpp +++ b/examples/activeqt/comapp/main.cpp @@ -217,7 +217,7 @@ DocumentList *Application::documents() const void Application::setVisible(bool on) { - ui->setShown(on); + ui->setVisible(on); } bool Application::isVisible() const diff --git a/examples/activeqt/hierarchy/hierarchy.pro b/examples/activeqt/hierarchy/hierarchy.pro index 732bbde..f2c9c56 100644 --- a/examples/activeqt/hierarchy/hierarchy.pro +++ b/examples/activeqt/hierarchy/hierarchy.pro @@ -3,6 +3,7 @@ TARGET = hierarchyax CONFIG += qt warn_off qaxserver dll contains(CONFIG, static):DEFINES += QT_NODLL +QT += widgets SOURCES = objects.cpp main.cpp HEADERS = objects.h diff --git a/examples/activeqt/menus/menus.pro b/examples/activeqt/menus/menus.pro index fc61e8a..c181393 100644 --- a/examples/activeqt/menus/menus.pro +++ b/examples/activeqt/menus/menus.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = menusax CONFIG += qt warn_off qaxserver +QT += widgets SOURCES = main.cpp menus.cpp HEADERS = menus.h diff --git a/examples/activeqt/multiple/multiple.pro b/examples/activeqt/multiple/multiple.pro index 058e966..5eae66a 100644 --- a/examples/activeqt/multiple/multiple.pro +++ b/examples/activeqt/multiple/multiple.pro @@ -2,6 +2,8 @@ TEMPLATE = lib TARGET = multipleax CONFIG += qt warn_off qaxserver dll +QT += widgets + contains(CONFIG, static):DEFINES += QT_NODLL SOURCES = main.cpp diff --git a/examples/activeqt/opengl/opengl.pro b/examples/activeqt/opengl/opengl.pro index f570dbe..2762345 100644 --- a/examples/activeqt/opengl/opengl.pro +++ b/examples/activeqt/opengl/opengl.pro @@ -3,7 +3,7 @@ TARGET = openglax CONFIG += qt warn_off qaxserver -QT += opengl +QT += widgets opengl HEADERS = glbox.h \ globjwin.h diff --git a/examples/activeqt/qutlook/addressview.cpp b/examples/activeqt/qutlook/addressview.cpp index 45ce662..ec06cd3 100644 --- a/examples/activeqt/qutlook/addressview.cpp +++ b/examples/activeqt/qutlook/addressview.cpp @@ -41,7 +41,7 @@ //! [0] #include "addressview.h" #include "msoutl.h" -#include <QtGui> +#include <QtWidgets> class AddressBookModel : public QAbstractListModel { diff --git a/examples/activeqt/qutlook/qutlook.pro b/examples/activeqt/qutlook/qutlook.pro index c1154e0..4e0e027 100644 --- a/examples/activeqt/qutlook/qutlook.pro +++ b/examples/activeqt/qutlook/qutlook.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = qutlook CONFIG += qaxcontainer +QT += widgets TYPELIBS = $$system(dumpcpp -getfile {00062FFF-0000-0000-C000-000000000046}) #! [0] diff --git a/examples/activeqt/simple/simple.pro b/examples/activeqt/simple/simple.pro index 4742370..8703ecb 100644 --- a/examples/activeqt/simple/simple.pro +++ b/examples/activeqt/simple/simple.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = simpleax CONFIG += qt warn_off qaxserver +QT += widgets SOURCES = main.cpp RC_FILE = $$QT.activeqt.sources/control/qaxserver.rc diff --git a/examples/activeqt/webbrowser/webbrowser.pro b/examples/activeqt/webbrowser/webbrowser.pro index 32eac71..859f62a 100644 --- a/examples/activeqt/webbrowser/webbrowser.pro +++ b/examples/activeqt/webbrowser/webbrowser.pro @@ -1,6 +1,7 @@ TEMPLATE = app CONFIG += qaxcontainer +QT += widgets QTDIR_build:REQUIRES = shared diff --git a/examples/activeqt/wrapper/wrapper.pro b/examples/activeqt/wrapper/wrapper.pro index d5443dc..d1209a3 100644 --- a/examples/activeqt/wrapper/wrapper.pro +++ b/examples/activeqt/wrapper/wrapper.pro @@ -2,6 +2,8 @@ TEMPLATE = lib TARGET = wrapperax CONFIG += qt warn_off qaxserver dll +QT += widgets + contains(CONFIG, static):DEFINES += QT_NODLL SOURCES = main.cpp diff --git a/src/activeqt/container/container.pro b/src/activeqt/container/container.pro index 9b2a320..80810a9 100644 --- a/src/activeqt/container/container.pro +++ b/src/activeqt/container/container.pro @@ -2,6 +2,7 @@ TEMPLATE = lib TARGET = ActiveQt CONFIG += qt_install_headers + SYNCQT.HEADER_FILES = qaxbase.h qaxobject.h qaxscript.h qaxselect.h qaxwidget.h SYNCQT.HEADER_CLASSES = ../../../include/ActiveQt/QAxBase ../../../include/ActiveQt/QAxObject ../../../include/ActiveQt/QAxScriptEngine ../../../include/ActiveQt/QAxScript ../../../include/ActiveQt/QAxScriptManager ../../../include/ActiveQt/QAxSelect ../../../include/ActiveQt/QAxWidget load(qt_installs) @@ -16,7 +17,8 @@ TARGET = QAxContainer INCLUDEPATH *= $$QT.activeqt.includes -QT += core-private gui-private +QT += core-private gui gui-private widgets widgets-private + CONFIG += qt warn_on staticlib DESTDIR = $$QT.activeqt.libs @@ -30,7 +32,8 @@ HEADERS = ../control/qaxaggregated.h \ qaxobject.h \ qaxscript.h \ qaxselect.h \ - ../shared/qaxtypes.h + ../shared/qaxtypes.h \ + ../shared/qaxutils_p.h SOURCES = qaxbase.cpp \ qaxdump.cpp \ @@ -39,6 +42,7 @@ SOURCES = qaxbase.cpp \ qaxscript.cpp \ qaxscriptwrapper.cpp \ qaxselect.cpp \ - ../shared/qaxtypes.cpp + ../shared/qaxtypes.cpp \ + ../shared/qaxutils.cpp FORMS = qaxselect.ui diff --git a/src/activeqt/container/qaxscript.cpp b/src/activeqt/container/qaxscript.cpp index 7e038a5..6ba075c 100644 --- a/src/activeqt/container/qaxscript.cpp +++ b/src/activeqt/container/qaxscript.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ #include "qaxscript.h" +#include "../shared/qaxutils_p.h" #ifndef QT_NO_WIN_ACTIVEQT @@ -346,7 +347,8 @@ HRESULT WINAPI QAxScriptSite::GetWindow(HWND *phwnd) if (!w) return E_FAIL; - *phwnd = w->winId(); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + *phwnd = hwndForWidget(w); return S_OK; } @@ -361,8 +363,9 @@ HRESULT WINAPI QAxScriptSite::EnableModeless(BOOL fEnable) QWidget *w = window(); if (!w) return E_FAIL; - - EnableWindow(w->winId(), fEnable); + + // FIXME: 4.10.2011 Does this work with the parent's HWND? + EnableWindow(hwndForWidget(w), fEnable); return S_OK; } diff --git a/src/activeqt/container/qaxselect.h b/src/activeqt/container/qaxselect.h index 063d87e..2c138f9 100644 --- a/src/activeqt/container/qaxselect.h +++ b/src/activeqt/container/qaxselect.h @@ -41,7 +41,7 @@ #ifndef QAXSELECT_H #define QAXSELECT_H -#include <QtGui/qdialog.h> +#include <QtWidgets/QDialog> #ifndef QT_NO_WIN_ACTIVEQT #include "ui_qaxselect.h" diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 800bc8d..b5fbeec 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ #include "qaxwidget.h" +#include "../shared/qaxutils_p.h" #ifndef QT_NO_WIN_ACTIVEQT @@ -191,7 +192,10 @@ public: return OLE_E_NOT_INPLACEACTIVE; RECT rcPos = { host->x(), host->y(), host->x()+host->width(), host->y()+host->height() }; - return m_spOleObject->DoVerb(index, 0, this, 0, host->winId(), &rcPos); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + return m_spOleObject->DoVerb(index, 0, this, 0, + hwndForWidget(host), + &rcPos); } // IUnknown @@ -486,14 +490,16 @@ bool axc_FilterProc(void *m) QAxWidget *ax = 0; QAxHostWidget *host = 0; while (!host && hwnd) { - QWidget *widget = QWidget::find(hwnd); + // FIXME: 4.10.2011: Does this still work? + QWidget *widget = QWidget::find(reinterpret_cast<WId>(hwnd)); if (widget && widget->inherits("QAxHostWidget")) host = qobject_cast<QAxHostWidget*>(widget); hwnd = ::GetParent(hwnd); } if (host) ax = qobject_cast<QAxWidget*>(host->parentWidget()); - if (ax && msg->hwnd != host->winId()) { + // FIXME: 4.10.2011 Does this work with the parent's HWND? + if (ax && msg->hwnd != hwndForWidget(host)) { if (message >= WM_KEYFIRST && message <= WM_KEYLAST) { QAxClientSite *site = host->clientSite(); site->eventTranslated = true; // reset in QAxClientSite::TranslateAccelerator @@ -702,7 +708,10 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) RECT rcPos = { host->x(), host->y(), host->x()+sizehint.width(), host->y()+sizehint.height() }; - hr = m_spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, (IOleClientSite*)this, 0, host->winId(), &rcPos); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + hr = m_spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, (IOleClientSite*)this, 0, + hwndForWidget(host), + &rcPos); if (!m_spOleControl) m_spOleObject->QueryInterface(IID_IOleControl, (void**)&m_spOleControl); @@ -1009,7 +1018,8 @@ HRESULT WINAPI QAxClientSite::TranslateAccelerator(LPMSG lpMsg, DWORD /*grfModif // if the request is coming from an out-of-proc server or a non ActiveQt server, // we send the message to the host window. This will make sure this key event // comes to Qt for processing. - SendMessage(host->winId(), lpMsg->message, lpMsg->wParam, lpMsg->lParam); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + SendMessage(hwndForWidget(host), lpMsg->message, lpMsg->wParam, lpMsg->lParam); if (ActiveQtDetected && !fromInProcServer) { // ActiveQt based servers will need further processing of the event // (eg. <SPACE> key for a checkbox), so we return false. @@ -1044,7 +1054,7 @@ HRESULT WINAPI QAxClientSite::GetWindow(HWND *phwnd) if (!phwnd) return E_POINTER; - *phwnd = host->winId(); + *phwnd = hwndForWidget(host); return S_OK; } @@ -1097,17 +1107,20 @@ HRESULT WINAPI QAxClientSite::GetWindowContext(IOleInPlaceFrame **ppFrame, IOleI if (!ppFrame || !ppDoc || !lprcPosRect || !lprcClipRect || !lpFrameInfo) return E_POINTER; + // FIXME: 4.10.2011 Does this work with the parent's HWND? QueryInterface(IID_IOleInPlaceFrame, (void**)ppFrame); QueryInterface(IID_IOleInPlaceUIWindow, (void**)ppDoc); - ::GetClientRect(host->winId(), lprcPosRect); - ::GetClientRect(host->winId(), lprcClipRect); + const HWND hwnd = hwndForWidget(host); + ::GetClientRect(hwnd, lprcPosRect); + ::GetClientRect(hwnd, lprcClipRect); lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO); lpFrameInfo->fMDIApp = false; lpFrameInfo->haccel = 0; lpFrameInfo->cAccelEntries = 0; - lpFrameInfo->hwndFrame = widget ? widget->window()->winId() : 0; + // FIXME: 4.10.2011: Parent's HWND required, should work. + lpFrameInfo->hwndFrame = widget ? hwnd : 0; return S_OK; } @@ -1386,7 +1399,8 @@ HRESULT WINAPI QAxClientSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND menuItemMap.clear(); } - OleSetMenuDescriptor(holemenu, widget ? widget->window()->winId() : 0, m_menuOwner, this, m_spInPlaceActiveObject); + // FIXME: 4.10.2011: Parent's HWND required, should work. + OleSetMenuDescriptor(holemenu, widget ? hwndForWidget(widget) : 0, m_menuOwner, this, m_spInPlaceActiveObject); return S_OK; #endif } @@ -1443,7 +1457,8 @@ extern Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent; HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) { - EnableWindow(host->window()->winId(), fEnable); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + EnableWindow(hwndForWidget(host), fEnable); if (!fEnable) { if (!QApplicationPrivate::isBlockedByModal(host)) @@ -1452,7 +1467,8 @@ HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) if (QApplicationPrivate::isBlockedByModal(host)) QApplicationPrivate::leaveModal(host); } - qt_win_ignoreNextMouseReleaseEvent = false; + // FIXME 4.10.2011: No longer exists in Lighthouse. + // qt_win_ignoreNextMouseReleaseEvent = false; return S_OK; } @@ -1588,8 +1604,9 @@ HRESULT WINAPI QAxClientSite::ActivateMe(IOleDocumentView *pViewToActivate) m_spActiveView->UIActivate(TRUE); + // FIXME: 4.10.2011 Does this work with the parent's HWND? RECT rect; - GetClientRect(widget->winId(), &rect); + GetClientRect(hwndForWidget(widget), &rect); m_spActiveView->SetRect(&rect); m_spActiveView->Show(TRUE); @@ -1686,7 +1703,7 @@ void QAxHostWidget::resizeObject() // document server - talk to view? if (axhost->m_spActiveView) { RECT rect; - GetClientRect(winId(), &rect); + GetClientRect(hwndForWidget(this), &rect); axhost->m_spActiveView->SetRect(&rect); return; @@ -1716,6 +1733,7 @@ void QAxHostWidget::showEvent(QShowEvent *) bool QAxHostWidget::winEvent(MSG *msg, long *result) { + // FIXME: 4.10.2011: no longer implemented if (axhost && axhost->inPlaceObjectWindowless) { Q_ASSERT(axhost->m_spInPlaceObject); IOleInPlaceObjectWindowless *windowless = (IOleInPlaceObjectWindowless*)axhost->m_spInPlaceObject; @@ -1725,7 +1743,8 @@ bool QAxHostWidget::winEvent(MSG *msg, long *result) if (hres == S_OK) return true; } - return QWidget::winEvent(msg, result); + // QWidget::winEvent(msg, result); + return false; } bool QAxHostWidget::event(QEvent *e) @@ -1736,14 +1755,18 @@ bool QAxHostWidget::event(QEvent *e) killTimer(setFocusTimer); setFocusTimer = 0; RECT rcPos = { x(), y(), x()+size().width(), y()+size().height() }; - axhost->m_spOleObject->DoVerb(OLEIVERB_UIACTIVATE, 0, (IOleClientSite*)axhost, 0, winId(), &rcPos); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + axhost->m_spOleObject->DoVerb(OLEIVERB_UIACTIVATE, 0, (IOleClientSite*)axhost, 0, + hwndForWidget(this), + &rcPos); if (axhost->m_spActiveView) axhost->m_spActiveView->UIActivate(TRUE); } break; case QEvent::WindowBlocked: - if (IsWindowEnabled(winId())) { - EnableWindow(winId(), false); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + if (IsWindowEnabled(hwndForWidget(this))) { + EnableWindow(hwndForWidget(this), false); if (axhost && axhost->m_spInPlaceActiveObject) { axhost->inPlaceModelessEnabled = false; axhost->m_spInPlaceActiveObject->EnableModeless(false); @@ -1751,8 +1774,9 @@ bool QAxHostWidget::event(QEvent *e) } break; case QEvent::WindowUnblocked: - if (!IsWindowEnabled(winId())) { - EnableWindow(winId(), true); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + if (!IsWindowEnabled(hwndForWidget(this))) { + EnableWindow(hwndForWidget(this), true); if (axhost && axhost->m_spInPlaceActiveObject) { axhost->inPlaceModelessEnabled = true; axhost->m_spInPlaceActiveObject->EnableModeless(true); @@ -1826,7 +1850,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*) QPixmap pm(size()); pm.fill(); - HBITMAP hBmp = pm.toWinHBITMAP(); + HBITMAP hBmp = qaxPixmapToWinHBITMAP(pm); HDC hBmp_hdc = CreateCompatibleDC(qt_win_display_dc()); HGDIOBJ old_hBmp = SelectObject(hBmp_hdc, hBmp); @@ -1840,7 +1864,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*) view->Release(); QPainter painter(this); - painter.drawPixmap(0, 0, QPixmap::fromWinHBITMAP(hBmp)); + painter.drawPixmap(0, 0, qaxPixmapFromWinHBITMAP(hBmp)); SelectObject(hBmp_hdc, old_hBmp); DeleteObject(hBmp); diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h index 58069a1..1242caa 100644 --- a/src/activeqt/container/qaxwidget.h +++ b/src/activeqt/container/qaxwidget.h @@ -42,7 +42,7 @@ #define QAXWIDGET_H #include <ActiveQt/qaxbase.h> -#include <QtGui/qwidget.h> +#include <QtWidgets/QWidget> QT_BEGIN_HEADER diff --git a/src/activeqt/control/control.pro b/src/activeqt/control/control.pro index d0decdf..676368d 100644 --- a/src/activeqt/control/control.pro +++ b/src/activeqt/control/control.pro @@ -2,6 +2,8 @@ TEMPLATE = lib TARGET = ActiveQt CONFIG += qt_install_headers +QT += widgets + SYNCQT.HEADER_FILES = qaxaggregated.h qaxbindable.h qaxfactory.h SYNCQT.HEADER_CLASSES = ../../../include/ActiveQt/QAxAggregated ../../../include/ActiveQt/QAxBindable ../../../include/ActiveQt/QAxFactory ../../../include/ActiveQt/QAxClass load(qt_installs) @@ -30,7 +32,8 @@ win32-g++*:LIBS += -luuid HEADERS = qaxaggregated.h \ qaxbindable.h \ qaxfactory.h \ - ../shared/qaxtypes.h + ../shared/qaxtypes.h \ + ../shared/qaxutils_p.h SOURCES = qaxserver.cpp \ qaxserverbase.cpp \ @@ -39,4 +42,5 @@ SOURCES = qaxserver.cpp \ qaxservermain.cpp \ qaxserverdll.cpp \ qaxmain.cpp \ - ../shared/qaxtypes.cpp + ../shared/qaxtypes.cpp \ + ../shared/qaxutils.cpp diff --git a/src/activeqt/control/qaxbindable.h b/src/activeqt/control/qaxbindable.h index 1e1a6dd..631163c 100644 --- a/src/activeqt/control/qaxbindable.h +++ b/src/activeqt/control/qaxbindable.h @@ -41,7 +41,7 @@ #ifndef QAXBINDABLE_H #define QAXBINDABLE_H -#include <QtGui/qwidget.h> +#include <QtWidgets/QWidget> struct IUnknown; diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index a2f9579..8f14e8f 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -68,6 +68,7 @@ #include "qaxaggregated.h" #include "../shared/qaxtypes.h" +#include "../shared/qaxutils_p.h" #if defined Q_CC_GNU # include <w32api.h> @@ -781,11 +782,12 @@ bool qax_winEventFilter(void *message) return false; bool ret = false; - QWidget *aqt = QWidget::find(pMsg->hwnd); + QWidget *aqt = QWidget::find(reinterpret_cast<WId>(pMsg->hwnd)); if (!aqt) return ret; - HWND baseHwnd = ::GetParent(aqt->winId()); + // FIXME: 4.10.211: was '::GetParent(hwndForWidget(aqt));' + HWND baseHwnd = hwndForWidget(aqt); QAxServerBase *axbase = 0; while (!axbase && baseHwnd) { #ifdef GWLP_USERDATA @@ -1292,10 +1294,11 @@ bool QAxServerBase::internalCreate() internalBind(); if (isWidget) { + // FIXME: 4.10.2011 Does this work with the parent's HWND? if (!stayTopLevel) { QEvent e(QEvent::EmbeddingControl); QApplication::sendEvent(qt.widget, &e); - ::SetWindowLong(qt.widget->winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + ::SetWindowLong(hwndForWidget(qt.widget), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); } qt.widget->setAttribute(Qt::WA_QuitOnClose, false); qt.widget->move(0, 0); @@ -1388,17 +1391,19 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM case WM_QUERYENDSESSION: case WM_DESTROY: // save the window handle + // FIXME: 4.10.2011 Does this work with the parent's HWND? if (that->qt.widget) { that->qt.widget->hide(); - ::SetParent(that->qt.widget->winId(), 0); + ::SetParent(hwndForWidget(that->qt.widget), 0); } break; case WM_SHOWWINDOW: if(wParam) { that->internalCreate(); + // FIXME: 4.10.2011 Does this work with the parent's HWND? if (!that->stayTopLevel) { - ::SetParent(that->qt.widget->winId(), that->m_hWnd); + ::SetParent(hwndForWidget(that->qt.widget), that->m_hWnd); that->qt.widget->raise(); that->qt.widget->move(0, 0); } @@ -1823,12 +1828,13 @@ void QAxServerBase::updateMask() return; QRegion rgn = qt.widget->mask(); - HRGN hrgn = rgn.handle(); + HRGN hrgn = qaxHrgnFromQRegion(rgn); // Since SetWindowRegion takes ownership HRGN wr = CreateRectRgn(0,0,0,0); CombineRgn(wr, hrgn, 0, RGN_COPY); SetWindowRgn(m_hWnd, wr, true); + DeleteObject(hrgn); } static bool checkHRESULT(HRESULT hres) @@ -3165,7 +3171,7 @@ HRESULT WINAPI QAxServerBase::Draw(DWORD dwAspect, LONG lindex, void *pvAspect, ::LPtoDP(hicTargetDev, (LPPOINT)&rc, 2); QPixmap pm = QPixmap::grabWidget(qt.widget); - HBITMAP hbm = pm.toWinHBITMAP(); + HBITMAP hbm = qaxPixmapToWinHBITMAP(pm); HDC hdc = CreateCompatibleDC(0); SelectObject(hdc, hbm); ::StretchBlt(hdcDraw, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdc, 0, 0,pm.width(), pm.height(), SRCCOPY); @@ -3598,8 +3604,9 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) state |= Qt::AltModifier; int key = pMsg->wParam; - if (!(key >= 'A' && key <= 'Z') && !(key >= '0' && key <= '9')) - key = qt_translateKeyCode(pMsg->wParam); + // FIXME 4.10.2011: No longer exists in Lighthouse. + // if (!(key >= 'A' && key <= 'Z') && !(key >= '0' && key <= '9')) + // key = qt_translateKeyCode(pMsg->wParam); QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state); override.ignore(); @@ -3673,7 +3680,8 @@ HRESULT WINAPI QAxServerBase::EnableModeless(BOOL fEnable) if (!isWidget) return S_OK; - EnableWindow(qt.widget->winId(), fEnable); + // FIXME: 4.10.2011 Does this work with the parent's HWND? + EnableWindow(hwndForWidget(qt.widget), fEnable); return S_OK; } @@ -4422,10 +4430,11 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) if (PeekMessage(&msg, 0, WM_USER+3078, WM_USER+3078, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); + // FIXME: 4.10.2011 Does this work with the parent's HWND? QWidget *modalWidget = QApplication::activeModalWidget(); if (modalWidget && modalWidget->isVisible() && modalWidget->isEnabled() - && !IsWindowEnabled(modalWidget->effectiveWinId())) - EnableWindow(modalWidget->effectiveWinId(), TRUE); + && !IsWindowEnabled(hwndForWidget(modalWidget))) + EnableWindow(hwndForWidget(modalWidget), TRUE); } break; } diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp index 8835caf..7e8dc56 100644 --- a/src/activeqt/shared/qaxtypes.cpp +++ b/src/activeqt/shared/qaxtypes.cpp @@ -42,6 +42,7 @@ #include <olectl.h> #include "qaxtypes.h" +#include "qaxutils_p.h" #ifndef QT_NO_WIN_ACTIVEQT @@ -141,10 +142,12 @@ static IPictureDisp *QPixmapToIPicture(const QPixmap &pixmap) desc.picType = PICTYPE_BITMAP; desc.bmp.hbitmap = 0; - desc.bmp.hpal = QColormap::hPal(); + /* FIXME 4.10.2011: was "desc.bmp.hpal = QColormap::hPal();", but + * with Lighthouse, QColormap no longer has a handle. */ + desc.bmp.hpal = 0; if (!pixmap.isNull()) { - desc.bmp.hbitmap = pixmap.toWinHBITMAP(); + desc.bmp.hbitmap = qaxPixmapToWinHBITMAP(pixmap); Q_ASSERT(desc.bmp.hbitmap); } @@ -172,7 +175,7 @@ static QPixmap IPictureToQPixmap(IPicture *ipic) if (!hbm) return QPixmap(); - return QPixmap::fromWinHBITMAP(hbm); + return qaxPixmapFromWinHBITMAP(hbm); } static QDateTime DATEToQDateTime(DATE ole) @@ -215,13 +218,14 @@ static DATE QDateTimeToDATE(const QDateTime &dt) QColor OLEColorToQColor(uint col) { -#if defined(Q_OS_WINCE) - return QColor(GetBValue(col),GetGValue(col),GetRValue(col)); -#else + Q_UNIMPLEMENTED(); + return QColor(); +/* FIXME: 4.10.2011: COLORREF cref; OleTranslateColor(col, QColormap::hPal(), &cref); return QColor(GetRValue(cref),GetGValue(cref),GetBValue(cref)); -#endif + +*/ } /* diff --git a/src/activeqt/shared/qaxutils.cpp b/src/activeqt/shared/qaxutils.cpp new file mode 100644 index 0000000..e717012 --- /dev/null +++ b/src/activeqt/shared/qaxutils.cpp @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaxutils_p.h" + +#include <QtWidgets/QWidget> +#include <QtGui/QPixmap> +#include <QtGui/QRegion> +#include <QtGui/QWindow> +#include <QtGui/QGuiApplication> +#include <QtGui/QPlatformNativeInterface> +#include <QtGui/QPlatformPixmap> +#include <QtGui/private/qpixmap_raster_p.h> +#include <QtCore/QScopedArrayPointer> +#include <QtCore/QRect> + +#include <QtCore/QDebug> + +QT_BEGIN_NAMESPACE + +static inline QWindow *windowForWidget(QWidget *widget) +{ + if (QWindow *window = widget->windowHandle()) + return window; + if (QWidget *nativeParent = widget->nativeParentWidget()) + return nativeParent->windowHandle(); + return 0; +} + +HWND hwndForWidget(QWidget *widget) +{ + QWindow *window = widget->windowHandle(); + return static_cast<HWND> (QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window)); + if (QWindow *window = windowForWidget(widget)) + return static_cast<HWND> (QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window)); + return 0; +} + +// Code courtesy of the Windows platform plugin (see pixmaputils.cpp/h). +HBITMAP qaxPixmapToWinHBITMAP(const QPixmap &p, HBitmapFormat format) +{ + if (p.isNull()) + return 0; + + HBITMAP bitmap = 0; + if (p.handle()->classId() != QPlatformPixmap::RasterClass) { + QRasterPlatformPixmap *data = new QRasterPlatformPixmap(p.depth() == 1 ? + QRasterPlatformPixmap::BitmapType : QRasterPlatformPixmap::PixmapType); + data->fromImage(p.toImage(), Qt::AutoColor); + return qaxPixmapToWinHBITMAP(QPixmap(data), format); + } + + QRasterPlatformPixmap *d = static_cast<QRasterPlatformPixmap*>(p.handle()); + const QImage *rasterImage = d->buffer(); + const int w = rasterImage->width(); + const int h = rasterImage->height(); + + HDC display_dc = GetDC(0); + + // Define the header + BITMAPINFO bmi; + memset(&bmi, 0, sizeof(bmi)); + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = w; + bmi.bmiHeader.biHeight = -h; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biSizeImage = w * h * 4; + + // Create the pixmap + uchar *pixels = 0; + bitmap = CreateDIBSection(display_dc, &bmi, DIB_RGB_COLORS, (void **) &pixels, 0, 0); + ReleaseDC(0, display_dc); + if (!bitmap) { + qErrnoWarning("%s, failed to create dibsection", __FUNCTION__); + return 0; + } + if (!pixels) { + qErrnoWarning("%s, did not allocate pixel data", __FUNCTION__); + return 0; + } + + // Copy over the data + QImage::Format imageFormat = QImage::Format_ARGB32; + if (format == HBitmapAlpha) + imageFormat = QImage::Format_RGB32; + else if (format == HBitmapPremultipliedAlpha) + imageFormat = QImage::Format_ARGB32_Premultiplied; + const QImage image = rasterImage->convertToFormat(imageFormat); + const int bytes_per_line = w * 4; + for (int y=0; y < h; ++y) + memcpy(pixels + y * bytes_per_line, image.scanLine(y), bytes_per_line); + + return bitmap; +} + +QPixmap qaxPixmapFromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format) +{ + // Verify size + BITMAP bitmap_info; + memset(&bitmap_info, 0, sizeof(BITMAP)); + + const int res = GetObject(bitmap, sizeof(BITMAP), &bitmap_info); + if (!res) { + qErrnoWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap info"); + return QPixmap(); + } + const int w = bitmap_info.bmWidth; + const int h = bitmap_info.bmHeight; + + BITMAPINFO bmi; + memset(&bmi, 0, sizeof(bmi)); + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = w; + bmi.bmiHeader.biHeight = -h; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biSizeImage = w * h * 4; + + // Get bitmap bits + QScopedArrayPointer<uchar> data(new uchar[bmi.bmiHeader.biSizeImage]); + HDC display_dc = GetDC(0); + if (!GetDIBits(display_dc, bitmap, 0, h, data.data(), &bmi, DIB_RGB_COLORS)) { + ReleaseDC(0, display_dc); + qWarning("%s, failed to get bitmap bits", __FUNCTION__); + return QPixmap(); + } + + QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied; + uint mask = 0; + if (format == HBitmapNoAlpha) { + imageFormat = QImage::Format_RGB32; + mask = 0xff000000; + } + + // Create image and copy data into image. + QImage image(w, h, imageFormat); + if (image.isNull()) { // failed to alloc? + ReleaseDC(0, display_dc); + qWarning("%s, failed create image of %dx%d", __FUNCTION__, w, h); + return QPixmap(); + } + const int bytes_per_line = w * sizeof(QRgb); + for (int y = 0; y < h; ++y) { + QRgb *dest = (QRgb *) image.scanLine(y); + const QRgb *src = (const QRgb *) (data.data() + y * bytes_per_line); + for (int x = 0; x < w; ++x) { + const uint pixel = src[x]; + if ((pixel & 0xff000000) == 0 && (pixel & 0x00ffffff) != 0) + dest[x] = pixel | 0xff000000; + else + dest[x] = pixel | mask; + } + } + ReleaseDC(0, display_dc); + return QPixmap::fromImage(image); +} + +// Code courtesy of QWindowsXPStyle +static void addRectToHrgn(HRGN &winRegion, const QRect &r) +{ + HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height()); + if (rgn) { + HRGN dest = CreateRectRgn(0,0,0,0); + int result = CombineRgn(dest, winRegion, rgn, RGN_OR); + if (result) { + DeleteObject(winRegion); + winRegion = dest; + } + DeleteObject(rgn); + } +} + +HRGN qaxHrgnFromQRegion(const QRegion ®ion) +{ + HRGN hRegion = CreateRectRgn(0, 0, 0, 0); + if (region.rectCount() == 1) { + addRectToHrgn(hRegion, region.boundingRect()); + return hRegion; + } + foreach (const QRect &rect, region.rects()) + addRectToHrgn(hRegion, rect); + return hRegion; +} + +QT_END_NAMESPACE diff --git a/src/activeqt/shared/qaxutils_p.h b/src/activeqt/shared/qaxutils_p.h new file mode 100644 index 0000000..70c0152 --- /dev/null +++ b/src/activeqt/shared/qaxutils_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAXUTILS_P_H +#define QAXUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qt_windows.h> +#include <QtCore/QtGlobal> + +QT_BEGIN_NAMESPACE + +class QWidget; +class QPixmap; +class QRect; +class QRegion; + +enum HBitmapFormat +{ + HBitmapNoAlpha, + HBitmapPremultipliedAlpha, + HBitmapAlpha +}; + +HWND hwndForWidget(QWidget *widget); +HBITMAP qaxPixmapToWinHBITMAP(const QPixmap &p, HBitmapFormat format = HBitmapNoAlpha); +QPixmap qaxPixmapFromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format = HBitmapNoAlpha); +HRGN qaxHrgnFromQRegion(const QRegion ®ion); + +QT_END_NAMESPACE + +#endif diff --git a/tools/dumpcpp/dumpcpp.pro b/tools/dumpcpp/dumpcpp.pro index 09a339b..e49d99f 100644 --- a/tools/dumpcpp/dumpcpp.pro +++ b/tools/dumpcpp/dumpcpp.pro @@ -2,5 +2,6 @@ TEMPLATE = app CONFIG += console qaxcontainer DESTDIR = ../../../bin +QT += widgets SOURCES += main.cpp diff --git a/tools/dumpdoc/dumpdoc.pro b/tools/dumpdoc/dumpdoc.pro index 3c93525..5ee96e7 100644 --- a/tools/dumpdoc/dumpdoc.pro +++ b/tools/dumpdoc/dumpdoc.pro @@ -1,5 +1,6 @@ TEMPLATE = app CONFIG += console qaxcontainer +QT += widgets SOURCES += main.cpp diff --git a/tools/testcon/ambientproperties.cpp b/tools/testcon/ambientproperties.cpp index cfdc47e..645fc96 100644 --- a/tools/testcon/ambientproperties.cpp +++ b/tools/testcon/ambientproperties.cpp @@ -41,7 +41,7 @@ #include "ambientproperties.h" -#include <QtGui> +#include <QtWidgets> QT_BEGIN_NAMESPACE diff --git a/tools/testcon/changeproperties.cpp b/tools/testcon/changeproperties.cpp index 67bd10d..6a33e52 100644 --- a/tools/testcon/changeproperties.cpp +++ b/tools/testcon/changeproperties.cpp @@ -41,7 +41,7 @@ #include "changeproperties.h" -#include <QtGui> +#include <QtWidgets> #include <qt_windows.h> #include <ActiveQt/ActiveQt> diff --git a/tools/testcon/docuwindow.cpp b/tools/testcon/docuwindow.cpp index cb6adfd..3a8a413 100644 --- a/tools/testcon/docuwindow.cpp +++ b/tools/testcon/docuwindow.cpp @@ -143,6 +143,9 @@ void DocuWindow::save() void DocuWindow::print() { +#ifdef QT_NO_PRINTER + Q_UNIMPLEMENTED(); +#else QPrinter printer; if (printer.printerName().isEmpty()) { statusBar()->showMessage(tr("No printer installed"), 2000); @@ -156,6 +159,7 @@ void DocuWindow::print() } browser->document()->print(&printer); +#endif } QT_END_NAMESPACE diff --git a/tools/testcon/mainwindow.cpp b/tools/testcon/mainwindow.cpp index e448427..b17b0b7 100644 --- a/tools/testcon/mainwindow.cpp +++ b/tools/testcon/mainwindow.cpp @@ -46,7 +46,7 @@ #include "controlinfo.h" #include "docuwindow.h" -#include <QtGui> +#include <QtWidgets> #include <qt_windows.h> #include <ActiveQt/ActiveQt> diff --git a/tools/testcon/testcon.pro b/tools/testcon/testcon.pro index 3540afb..b2d919a 100644 --- a/tools/testcon/testcon.pro +++ b/tools/testcon/testcon.pro @@ -1,7 +1,7 @@ TEMPLATE = app CONFIG += qaxserver qaxserver_no_postlink qaxcontainer -# QT += qt3support +QT += widgets printsupport # ui_qaxselect.h INCLUDEPATH += $$QT.activeqt.sources/../../tools/container/debug \ |