From 9fa6e8f627d0c61fd5a3b993903a362dc04bf707 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 29 Sep 2011 14:29:05 +0200 Subject: Clean-up a macro for Cocoa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the usage of Q_MAC_USE_COCOA and Carbon code paths. Change-Id: Ib569ad8c6d9ffe258f454b3c3b06e95294a10112 Reviewed-on: http://codereview.qt-project.org/5100 Reviewed-by: Morten Johan Sørvig Sanity-Review: Morten Johan Sørvig --- examples/mainwindows/macmainwindow/macmainwindow.h | 19 -------- .../mainwindows/macmainwindow/macmainwindow.mm | 51 ---------------------- 2 files changed, 70 deletions(-) (limited to 'examples') diff --git a/examples/mainwindows/macmainwindow/macmainwindow.h b/examples/mainwindows/macmainwindow/macmainwindow.h index d6f8b4cbdd..6be34654ab 100644 --- a/examples/mainwindows/macmainwindow/macmainwindow.h +++ b/examples/mainwindows/macmainwindow/macmainwindow.h @@ -47,7 +47,6 @@ #import -#ifdef QT_MAC_USE_COCOA class SearchWidget : public QMacCocoaViewContainer { Q_OBJECT @@ -59,24 +58,6 @@ public: private: }; -#else -#include - -// The SearchWidget class wraps a native HISearchField. -class SearchWidget : public QWidget -{ - Q_OBJECT -private: - HIViewRef searchField; - CFStringRef searchFieldText; - -public: - QSize sizeHint() const; - SearchWidget(QWidget *parent = 0); - ~SearchWidget(); -}; - -#endif QMenu *createMenu(QWidget *parent); diff --git a/examples/mainwindows/macmainwindow/macmainwindow.mm b/examples/mainwindows/macmainwindow/macmainwindow.mm index 3b0ba6f02a..4ad0134ec7 100644 --- a/examples/mainwindows/macmainwindow/macmainwindow.mm +++ b/examples/mainwindows/macmainwindow/macmainwindow.mm @@ -47,7 +47,6 @@ #include -#ifdef QT_MAC_USE_COCOA //![0] SearchWidget::SearchWidget(QWidget *parent) @@ -84,56 +83,6 @@ QSize SearchWidget::sizeHint() const return QSize(150, 40); } -#else - -// The SearchWidget class wraps a native HISearchField. -SearchWidget::SearchWidget(QWidget *parent) - :QWidget(parent) -{ - - // Create a native search field and pass its window id to QWidget::create. - searchFieldText = CFStringCreateWithCString(0, "search", 0); - HISearchFieldCreate(NULL/*bounds*/, kHISearchFieldAttributesSearchIcon | kHISearchFieldAttributesCancel, - NULL/*menu ref*/, searchFieldText, &searchField); - create(reinterpret_cast(searchField)); - - // Use a Qt menu for the search field menu. - QMenu *searchMenu = createMenu(this); - MenuRef menuRef = searchMenu->macMenu(0); - HISearchFieldSetSearchMenu(searchField, menuRef); - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); -} - -SearchWidget::~SearchWidget() -{ - CFRelease(searchField); - CFRelease(searchFieldText); -} - -// Get the size hint from the search field. -QSize SearchWidget::sizeHint() const -{ - EventRef event; - HIRect optimalBounds; - CreateEvent(0, kEventClassControl, - kEventControlGetOptimalBounds, - GetCurrentEventTime(), - kEventAttributeUserEvent, &event); - - SendEventToEventTargetWithOptions(event, - HIObjectGetEventTarget(HIObjectRef(winId())), - kEventTargetDontPropagate); - - GetEventParameter(event, - kEventParamControlOptimalBounds, typeHIRect, - 0, sizeof(HIRect), 0, &optimalBounds); - - ReleaseEvent(event); - return QSize(optimalBounds.size.width + 100, // make it a bit wider. - optimalBounds.size.height); -} - -#endif QMenu *createMenu(QWidget *parent) { -- cgit v1.2.3