Index: /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 24106)
+++ /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 24107)
@@ -272,5 +272,4 @@
 	include/QITreeWidget.h \
 	include/QIMainDialog.h \
-	include/QIHelpButton.h \
 	include/QIDialog.h \
 	include/QIFileDialog.h \
@@ -335,5 +334,6 @@
 	include/VBoxImportApplianceWzd.h \
 	include/VBoxExportApplianceWgt.h \
-	include/VBoxExportApplianceWzd.h
+	include/VBoxExportApplianceWzd.h \
+	include/VBoxSpecialControls.h
 
 # Sources containing local definitions of classes that use the Q_OBJECT macro.
@@ -374,5 +374,4 @@
 	src/QIMainDialog.cpp \
 	src/QILineEdit.cpp \
-	src/QIHelpButton.cpp \
 	src/QISplitter.cpp \
 	src/QITreeView.cpp \
@@ -435,5 +434,6 @@
 	src/VBoxImportApplianceWzd.cpp \
 	src/VBoxExportApplianceWgt.cpp \
-	src/VBoxExportApplianceWzd.cpp
+	src/VBoxExportApplianceWzd.cpp \
+	src/VBoxSpecialControls.cpp
 
 ifeq ($(filter-out freebsd linux netbsd openbsd solaris,$(KBUILD_TARGET)),) # X11
@@ -473,8 +473,13 @@
 
 ifdef VBOX_WITH_COCOA_QT
+ VirtualBox_DEFS += VBOX_DARWIN_USE_NATIVE_CONTROLS
  VirtualBox_SOURCES.darwin += \
  	src/darwin/VBoxCocoaApplication.m \
- 	src/darwin/VBoxUtils-darwin-cocoa.m \
- 	src/darwin/VBoxDockIconPreview-cocoa.m
+ 	src/darwin/VBoxUtils-darwin-cocoa.mm \
+	src/darwin/VBoxCocoaSpecialControls.mm \
+	src/darwin/VBoxDockIconPreview-cocoa.m
+ VirtualBox_QT_MOCHDRS.darwin = \
+	include/VBoxCocoaSpecialControls.h
+
 else
  VirtualBox_SOURCES.darwin += \
Index: /trunk/src/VBox/Frontends/VirtualBox/include/QIDialogButtonBox.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/QIDialogButtonBox.h	(revision 24106)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/QIDialogButtonBox.h	(revision 24107)
@@ -32,5 +32,5 @@
 class QBoxLayout;
 
-class QIHelpButton;
+class VBoxHelpButton;
 
 class QIDialogButtonBox: public QIWithRetranslateUI<QDialogButtonBox>
@@ -60,5 +60,5 @@
 private:
 
-    QPointer<QIHelpButton> mHelpButton;
+    QPointer<VBoxHelpButton> mHelpButton;
 };
 
Index: unk/src/VBox/Frontends/VirtualBox/include/QIHelpButton.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/QIHelpButton.h	(revision 24106)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * QIHelpButton class declaration
- */
-
-/*
- * Copyright (C) 2008 Sun Microsystems, Inc.
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
- * Clara, CA 95054 USA or visit http://www.sun.com if you need
- * additional information or have any questions.
- */
-
-#ifndef __QIHelpButton_h_
-#define __QIHelpButton_h_
-
-#include "QIWithRetranslateUI.h"
-
-/* Qt includes */
-#include <QPushButton>
-
-class QIHelpButton: public QIWithRetranslateUI<QPushButton>
-{
-    Q_OBJECT;
-
-public:
-
-    QIHelpButton (QWidget *aParent = NULL);
-
-    void initFrom (QPushButton *aOther);
-
-#ifdef Q_WS_MAC
-    ~QIHelpButton();
-
-    QSize sizeHint() const;
-
-protected:
-
-    bool hitButton (const QPoint &pos) const;
-
-    void mousePressEvent (QMouseEvent *aEvent);
-    void mouseReleaseEvent (QMouseEvent *aEvent);
-    void leaveEvent (QEvent *aEvent);
-
-    void paintEvent (QPaintEvent *aEvent);
-#endif /* Q_WS_MAC */
-
-protected:
-
-    void retranslateUi();
-
-private:
-    
-#ifdef Q_WS_MAC
-    /* Private member vars */
-    bool mButtonPressed;
-
-    QSize mSize;
-    QPixmap *mNormalPixmap;
-    QPixmap *mPressedPixmap;
-    QImage *mMask;
-    QRect mBRect;
-#endif /* Q_WS_MAC */
-};
-
-#endif /* __QIHelpButton_h_ */
-
Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxCocoaHelper.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxCocoaHelper.h	(revision 24107)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxCocoaHelper.h	(revision 24107)
@@ -0,0 +1,103 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VBoxCocoa Helper
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#ifndef ___darwin_VBoxCocoaHelper_h
+#define ___darwin_VBoxCocoaHelper_h
+
+/* Macro which add a typedef of the given Cocoa class in an appropriate form
+ * for the current context. This means void* in the C/CPP context and
+ * NSWhatever* in the ObjC/ObjCPP context. Use NativeNSWhateverRef when you
+ * reference the Cocoa type somewhere. The use of this prevents extensive
+ * casting of void* to the right type in the Cocoa context. */
+#ifdef __OBJC__
+#define ADD_COCOA_NATIVE_REF(CocoaClass) \
+@class CocoaClass; \
+typedef CocoaClass *Native##CocoaClass##Ref
+#else /* __OBJC__ */
+#define ADD_COCOA_NATIVE_REF(CocoaClass) typedef void *Native##CocoaClass##Ref
+#endif /* __OBJC__ */
+
+#ifdef __OBJC__
+
+/* System includes */
+#import <Appkit/NSImage.h>
+#import <Foundation/NSAutoreleasePool.h>
+#import <CoreFoundation/CFString.h>
+
+/* Qt includes */
+#include <QString>
+#include <QVarLengthArray>
+
+inline NSString *darwinQStringToNSString (const QString &aString)
+{
+    return [reinterpret_cast<const NSString *>(CFStringCreateWithCharacters (0, reinterpret_cast<const UniChar *> (aString.unicode()),
+                                                                             aString.length())) autorelease];
+}
+
+inline QString darwinNSStringToQString (const NSString *aString)
+{
+    CFStringRef str = reinterpret_cast<const CFStringRef> (aString);
+    if(!str)
+        return QString();
+    CFIndex length = CFStringGetLength (str);
+    const UniChar *chars = CFStringGetCharactersPtr (str);
+    if (chars)
+        return QString (reinterpret_cast<const QChar *> (chars), length);
+
+    QVarLengthArray<UniChar> buffer (length);
+    CFStringGetCharacters (str, CFRangeMake (0, length), buffer.data());
+    return QString (reinterpret_cast<const QChar *> (buffer.constData()), length);
+}
+
+inline NSImage *darwinCGImageToNSImage (const CGImageRef aImage)
+{
+    /* Create a bitmap rep from the image. */
+    NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:aImage];
+    /* Create an NSImage and add the bitmap rep to it */
+    NSImage *image = [[NSImage alloc] init];
+    [image addRepresentation:bitmapRep];
+    [bitmapRep release];
+    return image;
+}
+
+/* Helper class for automatic creation & destroying of a cocoa auto release
+   pool. */
+class CocoaAutoreleasePool
+{
+public:
+    inline CocoaAutoreleasePool()
+    {
+         mPool = [[NSAutoreleasePool alloc] init];
+    }
+    inline ~CocoaAutoreleasePool()
+    {
+        [mPool release];
+    }
+
+private:
+    NSAutoreleasePool *mPool;
+};
+
+#endif /* __OBJC__ */
+
+#endif /* ___darwin_VBoxCocoaHelper_h */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxCocoaSpecialControls.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxCocoaSpecialControls.h	(revision 24107)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxCocoaSpecialControls.h	(revision 24107)
@@ -0,0 +1,116 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VBoxCocoaSpecialControls class declaration
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#ifndef ___darwin_VBoxCocoaSpecialControls_h__
+#define ___darwin_VBoxCocoaSpecialControls_h__
+
+/* VBox includes */
+#include "VBoxCocoaHelper.h"
+
+/* Qt includes */
+#include <QMacCocoaViewContainer>
+
+/* Add typedefs for Cocoa types */
+ADD_COCOA_NATIVE_REF (NSButton);
+ADD_COCOA_NATIVE_REF (NSSegmentedControl);
+ADD_COCOA_NATIVE_REF (NSSearchField);
+
+class VBoxCocoaButton: public QMacCocoaViewContainer
+{
+    Q_OBJECT;
+
+public:
+    enum CocoaButtonType
+    {
+        HelpButton,
+        CancelButton
+    };
+
+    VBoxCocoaButton (CocoaButtonType aType, QWidget *aParent = 0);
+    QSize sizeHint() const;
+
+    void setToolTip (const QString& aTip);
+
+    void onClicked();
+
+signals:
+    void clicked (bool checked = false);
+
+private:
+    /* Private member vars */
+    NativeNSButtonRef mNativeRef;
+};
+
+class VBoxCocoaSegmentedButton: public QMacCocoaViewContainer
+{
+    Q_OBJECT;
+
+public:
+    VBoxCocoaSegmentedButton (int aCount, QWidget *aParent = 0);
+    QSize sizeHint() const;
+
+    void setTitle (int aSegment, const QString &aTitle);
+
+    void setToolTip (int aSegment, const QString &aTip);
+
+    void setEnabled (int aSegment, bool fEnabled);
+
+    void animateClick (int aSegment);
+
+    void onClicked (int aSegment);
+
+signals:
+    void clicked (int aSegment, bool aChecked = false);
+
+private:
+    /* Private member vars */
+    NativeNSSegmentedControlRef mNativeRef;
+};
+
+class VBoxCocoaSearchField: public QMacCocoaViewContainer
+{
+    Q_OBJECT;
+
+public:
+    VBoxCocoaSearchField (QWidget* aParent = 0);
+    QSize sizeHint() const;
+
+    QString text() const;
+    void insert (const QString &aText);
+    void setToolTip (const QString &aTip);
+    void selectAll();
+
+    void markError();
+    void unmarkError();
+
+    void onTextChanged (const QString &aText);
+
+signals:
+    void textChanged (const QString& aText);
+
+private:
+    /* Private member vars */
+    NativeNSSearchFieldRef mNativeRef;
+};
+
+#endif /* ___darwin_VBoxCocoaSpecialControls_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxSpecialControls.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxSpecialControls.h	(revision 24107)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxSpecialControls.h	(revision 24107)
@@ -0,0 +1,230 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VBoxSpecialButtons declarations
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#ifndef ___VBoxSpecialControls_h__
+#define ___VBoxSpecialControls_h__
+
+/* VBox includes */
+#include "QIWithRetranslateUI.h"
+
+/* Qt includes */
+#include <QPushButton>
+
+#ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
+
+/* VBox includes */
+#include "VBoxCocoaSpecialControls.h"
+
+/********************************************************************************
+ *
+ * A mini cancel button in the native Cocoa version.
+ *
+ ********************************************************************************/
+class VBoxMiniCancelButton: public QAbstractButton
+{
+    Q_OBJECT;
+
+public:
+    VBoxMiniCancelButton (QWidget *aParent = 0);
+
+    void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); }
+
+protected:
+    void paintEvent (QPaintEvent * /* aEvent */) {}
+
+private:
+    VBoxCocoaButton *mButton;
+};
+
+/********************************************************************************
+ *
+ * A help button in the native Cocoa version.
+ *
+ ********************************************************************************/
+class VBoxHelpButton: public QPushButton
+{
+    Q_OBJECT;
+
+public:
+    VBoxHelpButton (QWidget *aParent = 0);
+
+    void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); }
+
+    void initFrom (QPushButton * /* aOther */) {}
+
+protected:
+    void paintEvent (QPaintEvent * /* aEvent */) {}
+
+private:
+    VBoxCocoaButton *mButton;
+};
+
+/********************************************************************************
+ *
+ * A segmented button in the native Cocoa version.
+ *
+ ********************************************************************************/
+class VBoxSegmentedButton: public VBoxCocoaSegmentedButton
+{
+    Q_OBJECT;
+
+public:
+    VBoxSegmentedButton (int aCount, QWidget *aParent = 0);
+
+    void setIcon (int /* aSegment */, const QIcon & /* aIcon */) {}
+};
+
+/********************************************************************************
+ *
+ * A search field in the native Cocoa version.
+ *
+ ********************************************************************************/
+class VBoxSearchField: public VBoxCocoaSearchField
+{
+    Q_OBJECT;
+
+public:
+    VBoxSearchField (QWidget *aParent = 0);
+};
+
+#else /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
+
+/* VBox includes */
+#include "QIToolButton.h"
+
+/* Qt includes */
+#include <QLineEdit>
+
+/* Qt forward declarations */
+class QSignalMapper;
+
+/********************************************************************************
+ *
+ * A mini cancel button for the other OS's.
+ *
+ ********************************************************************************/
+class VBoxMiniCancelButton: public QIWithRetranslateUI<QIToolButton>
+{
+    Q_OBJECT;
+
+public:
+    VBoxMiniCancelButton (QWidget *aParent = 0);
+
+protected:
+    void retranslateUi() {};
+};
+
+/********************************************************************************
+ *
+ * A help button for the other OS's.
+ *
+ ********************************************************************************/
+class VBoxHelpButton: public QIWithRetranslateUI<QPushButton>
+{
+    Q_OBJECT;
+
+public:
+    VBoxHelpButton (QWidget *aParent = 0);
+#ifdef Q_WS_MAC
+    ~VBoxHelpButton();
+    QSize sizeHint() const;
+#endif /* Q_WS_MAC */
+
+    void initFrom (QPushButton *aOther);
+
+protected:
+    void retranslateUi();
+
+#ifdef Q_WS_MAC
+    void paintEvent (QPaintEvent *aEvent);
+
+    bool hitButton (const QPoint &pos) const;
+
+    void mousePressEvent (QMouseEvent *aEvent);
+    void mouseReleaseEvent (QMouseEvent *aEvent);
+    void leaveEvent (QEvent *aEvent);
+
+private:
+    /* Private member vars */
+    bool mButtonPressed;
+
+    QSize mSize;
+    QPixmap *mNormalPixmap;
+    QPixmap *mPressedPixmap;
+    QImage *mMask;
+    QRect mBRect;
+#endif /* Q_WS_MAC */
+};
+
+/********************************************************************************
+ *
+ * A segmented button for the other OS's.
+ *
+ ********************************************************************************/
+class VBoxSegmentedButton: public QWidget
+{
+    Q_OBJECT;
+
+public:
+    VBoxSegmentedButton (int aCount, QWidget *aParent = 0);
+    ~VBoxSegmentedButton();
+
+    void setTitle (int aSegment, const QString &aTitle);
+    void setToolTip (int aSegment, const QString &aTip);
+    void setIcon (int aSegment, const QIcon &aIcon);
+    void setEnabled (int aSegment, bool fEnabled);
+
+    void animateClick (int aSegment);
+
+signals:
+    void clicked (int aSegment);
+
+private:
+    /* Private member vars */
+    QList<QIToolButton*> mButtons;
+    QSignalMapper *mSignalMapper;
+};
+
+/********************************************************************************
+ *
+ * A search field  for the other OS's.
+ *
+ ********************************************************************************/
+class VBoxSearchField: public QLineEdit
+{
+    Q_OBJECT;
+
+public:
+    VBoxSearchField (QWidget *aParent = 0);
+
+    void markError();
+    void unmarkError();
+
+private:
+    /* Private member vars */
+    QBrush mBaseBrush;
+};
+
+#endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
+
+#endif /* ___VBoxSpecialControls_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h	(revision 24106)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h	(revision 24107)
@@ -41,5 +41,4 @@
 
 # include <qglobal.h> /* for QT_MAC_USE_COCOA */
-# include <QRect>
 
 # include <ApplicationServices/ApplicationServices.h>
@@ -62,4 +61,5 @@
 
 #include <iprt/cdefs.h> /* for RT_C_DECLS_BEGIN/RT_C_DECLS_END & stuff */
+#include <QRect>
 
 RT_C_DECLS_BEGIN
@@ -93,89 +93,7 @@
 void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow);
 int  darwinWindowToolBarHeight (NativeWindowRef aWindow);
+float darwinSmallFontSize();
 
 RT_C_DECLS_END
-
-#ifndef __OBJC__
-/********************************************************************************
- *
- * Window/View management (Qt Wrapper)
- *
- ********************************************************************************/
-
-/**
- * Returns a reference to the native View of the QWidget.
- *
- * @returns either HIViewRef or NSView* of the QWidget.
- * @param   aWidget   Pointer to the QWidget
- */
-NativeViewRef darwinToNativeView (QWidget *aWidget);
-
-/**
- * Returns a reference to the native Window of the QWidget.
- *
- * @returns either WindowRef or NSWindow* of the QWidget.
- * @param   aWidget   Pointer to the QWidget
- */
-NativeWindowRef darwinToNativeWindow (QWidget *aWidget);
-
-/* This is necessary because of the C calling convention. Its a simple wrapper
-   for darwinToNativeWindowImpl to allow operator overloading which isn't
-   allowed in C. */
-/**
- * Returns a reference to the native Window of the View..
- *
- * @returns either WindowRef or NSWindow* of the View.
- * @param   aWidget   Pointer to the native View
- */
-NativeWindowRef darwinToNativeWindow (NativeViewRef aView);
-
-/**
- * Returns a reference to the native View of the Window.
- *
- * @returns either HIViewRef or NSView* of the Window.
- * @param   aWidget   Pointer to the native Window
- */
-NativeViewRef darwinToNativeView (NativeWindowRef aWindow);
-
-/********************************************************************************
- *
- * Simple setter methods (Qt Wrapper)
- *
- ********************************************************************************/
-void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);
-void darwinSetShowsResizeIndicator (QWidget *aWidget, bool aEnabled);
-void darwinSetHidesAllTitleButtons (QWidget *aWidget);
-void darwinSetShowsWindowTransparent (QWidget *aWidget, bool aEnabled);
-void darwinDisableIconsInMenus (void);
-
-/********************************************************************************
- *
- * Simple helper methods (Qt Wrapper)
- *
- ********************************************************************************/
-void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
-void darwinWindowInvalidateShape (QWidget *aWidget);
-void darwinWindowInvalidateShadow (QWidget *aWidget);
-int  darwinWindowToolBarHeight (QWidget *aWidget);
-QString darwinSystemLanguage (void);
-QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);
-
-
-/********************************************************************************
- *
- * Graphics stuff (Qt Wrapper)
- *
- ********************************************************************************/
-/**
- * Returns a reference to the CGContext of the QWidget.
- *
- * @returns CGContextRef of the QWidget.
- * @param   aWidget      Pointer to the QWidget
- */
-CGContextRef darwinToCGContextRef (QWidget *aWidget);
-
-CGImageRef darwinToCGImageRef (const QImage *aImage);
-CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
-CGImageRef darwinToCGImageRef (const char *aSource);
 
 DECLINLINE(CGRect) darwinToCGRect (const QRect& aRect) { return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height()); }
@@ -188,4 +106,88 @@
     return aRect;
 }
+
+
+#ifndef __OBJC__
+/********************************************************************************
+ *
+ * Window/View management (Qt Wrapper)
+ *
+ ********************************************************************************/
+
+/**
+ * Returns a reference to the native View of the QWidget.
+ *
+ * @returns either HIViewRef or NSView* of the QWidget.
+ * @param   aWidget   Pointer to the QWidget
+ */
+NativeViewRef darwinToNativeView (QWidget *aWidget);
+
+/**
+ * Returns a reference to the native Window of the QWidget.
+ *
+ * @returns either WindowRef or NSWindow* of the QWidget.
+ * @param   aWidget   Pointer to the QWidget
+ */
+NativeWindowRef darwinToNativeWindow (QWidget *aWidget);
+
+/* This is necessary because of the C calling convention. Its a simple wrapper
+   for darwinToNativeWindowImpl to allow operator overloading which isn't
+   allowed in C. */
+/**
+ * Returns a reference to the native Window of the View..
+ *
+ * @returns either WindowRef or NSWindow* of the View.
+ * @param   aWidget   Pointer to the native View
+ */
+NativeWindowRef darwinToNativeWindow (NativeViewRef aView);
+
+/**
+ * Returns a reference to the native View of the Window.
+ *
+ * @returns either HIViewRef or NSView* of the Window.
+ * @param   aWidget   Pointer to the native Window
+ */
+NativeViewRef darwinToNativeView (NativeWindowRef aWindow);
+
+/********************************************************************************
+ *
+ * Simple setter methods (Qt Wrapper)
+ *
+ ********************************************************************************/
+void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);
+void darwinSetShowsResizeIndicator (QWidget *aWidget, bool aEnabled);
+void darwinSetHidesAllTitleButtons (QWidget *aWidget);
+void darwinSetShowsWindowTransparent (QWidget *aWidget, bool aEnabled);
+void darwinDisableIconsInMenus (void);
+
+/********************************************************************************
+ *
+ * Simple helper methods (Qt Wrapper)
+ *
+ ********************************************************************************/
+void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
+void darwinWindowInvalidateShape (QWidget *aWidget);
+void darwinWindowInvalidateShadow (QWidget *aWidget);
+int  darwinWindowToolBarHeight (QWidget *aWidget);
+QString darwinSystemLanguage (void);
+QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);
+
+
+/********************************************************************************
+ *
+ * Graphics stuff (Qt Wrapper)
+ *
+ ********************************************************************************/
+/**
+ * Returns a reference to the CGContext of the QWidget.
+ *
+ * @returns CGContextRef of the QWidget.
+ * @param   aWidget      Pointer to the QWidget
+ */
+CGContextRef darwinToCGContextRef (QWidget *aWidget);
+
+CGImageRef darwinToCGImageRef (const QImage *aImage);
+CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
+CGImageRef darwinToCGImageRef (const char *aSource);
 
 
Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMLogViewer.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMLogViewer.h	(revision 24106)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMLogViewer.h	(revision 24107)
@@ -32,7 +32,9 @@
 class QTabWidget;
 class QTextEdit;
-class QLineEdit;
+class VBoxSearchField;
 class QLabel;
 class QIToolButton;
+class VBoxMiniCancelButton;
+class VBoxSegmentedButton;
 class QCheckBox;
 
@@ -104,4 +106,5 @@
 private slots:
 
+    void find (int aButton);
     void findNext() { search (true); }
     void findBack() { search (false); }
@@ -120,14 +123,13 @@
     void toggleWarning (bool aHide);
 
-    VBoxVMLogViewer *mViewer;
-    QIToolButton    *mButtonClose;
-    QLabel          *mSearchName;
-    QLineEdit       *mSearchString;
-    QIToolButton    *mButtonPrev;
-    QIToolButton    *mButtonNext;
-    QCheckBox       *mCaseSensitive;
-    QSpacerItem     *mWarningSpacer;
-    QLabel          *mWarningIcon;
-    QLabel          *mWarningString;
+    VBoxVMLogViewer      *mViewer;
+    VBoxMiniCancelButton *mButtonClose;
+    QLabel               *mSearchName;
+    VBoxSearchField      *mSearchString;
+    VBoxSegmentedButton  *mButtonsNextPrev;
+    QCheckBox            *mCaseSensitive;
+    QSpacerItem          *mWarningSpacer;
+    QLabel               *mWarningIcon;
+    QLabel               *mWarningString;
 };
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/QIDialogButtonBox.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/QIDialogButtonBox.cpp	(revision 24106)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/QIDialogButtonBox.cpp	(revision 24107)
@@ -22,5 +22,5 @@
 
 #include "QIDialogButtonBox.h"
-#include "QIHelpButton.h"
+#include "VBoxSpecialControls.h"
 
 #include <iprt/assert.h>
@@ -114,5 +114,5 @@
         /* Use our very own help button if the user requested for one. */
         if (!mHelpButton)
-            mHelpButton = new QIHelpButton;
+            mHelpButton = new VBoxHelpButton;
         mHelpButton->initFrom (btn);
         removeButton (btn);
Index: unk/src/VBox/Frontends/VirtualBox/src/QIHelpButton.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/QIHelpButton.cpp	(revision 24106)
+++ 	(revision )
@@ -1,124 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * QIHelpButton class implementation
- */
-
-/*
- * Copyright (C) 2008 Sun Microsystems, Inc.
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
- * Clara, CA 95054 USA or visit http://www.sun.com if you need
- * additional information or have any questions.
- */
-
-#include "QIHelpButton.h"
-
-/* Qt includes */
-#include <QPainter>
-#include <QBitmap>
-#include <QMouseEvent>
-
-/* From: src/gui/styles/qmacstyle_mac.cpp */
-static const int PushButtonLeftOffset = 6;
-static const int PushButtonTopOffset = 4;
-static const int PushButtonRightOffset = 12;
-static const int PushButtonBottomOffset = 4;
-
-QIHelpButton::QIHelpButton(QWidget *aParent /* = NULL */)
-    : QIWithRetranslateUI<QPushButton> (aParent)
-{
-#ifdef Q_WS_MAC
-    mButtonPressed = false;
-    mNormalPixmap = new QPixmap (":/help_button_normal_mac_22px.png");
-    mPressedPixmap = new QPixmap (":/help_button_pressed_mac_22px.png");
-    mSize = mNormalPixmap->size();
-    mMask = new QImage (mNormalPixmap->mask().toImage());
-    mBRect = QRect (PushButtonLeftOffset, 
-                    PushButtonTopOffset,
-                    mSize.width(),
-                    mSize.height());
-#endif /* Q_WS_MAC */
-    /* Applying language settings */
-    retranslateUi();
-}
-
-void QIHelpButton::initFrom (QPushButton *aOther)
-{
-    setIcon (aOther->icon());
-    setText (aOther->text());
-    setShortcut (aOther->shortcut());
-    setFlat (aOther->isFlat());
-    setAutoDefault (aOther->autoDefault());
-    setDefault (aOther->isDefault());
-    /* Applying language settings */
-    retranslateUi();
-}
-
-#ifdef Q_WS_MAC
-QIHelpButton::~QIHelpButton()
-{
-    delete mNormalPixmap;
-    delete mPressedPixmap;
-    delete mMask;
-}
-
-QSize QIHelpButton::sizeHint() const
-{
-    return QSize (mSize.width() + PushButtonLeftOffset + PushButtonRightOffset,
-                  mSize.height() + PushButtonTopOffset + PushButtonBottomOffset);
-}
-
-bool QIHelpButton::hitButton (const QPoint &pos) const
-{
-    if (mBRect.contains (pos))
-        return  mMask->pixel (pos.x() - PushButtonLeftOffset,
-                              pos.y() - PushButtonTopOffset) == 0xff000000;
-    else
-        return false;
-}
-
-void QIHelpButton::mousePressEvent (QMouseEvent *aEvent) 
-{
-    if (hitButton (aEvent->pos()))
-        mButtonPressed = true;
-    QPushButton::mousePressEvent (aEvent);
-    update();
-}
-
-void QIHelpButton::mouseReleaseEvent (QMouseEvent *aEvent) 
-{
-    QPushButton::mouseReleaseEvent (aEvent);
-    mButtonPressed = false;
-    update();
-}
-
-void QIHelpButton::leaveEvent (QEvent * aEvent)
-{
-    QPushButton::leaveEvent (aEvent);
-    mButtonPressed = false;
-    update();
-}
-
-void QIHelpButton::paintEvent (QPaintEvent * /* aEvent */)
-{
-    QPainter painter (this);
-    painter.drawPixmap (PushButtonLeftOffset, PushButtonTopOffset, mButtonPressed ? *mPressedPixmap: *mNormalPixmap);
-}
-#endif /* Q_WS_MAC */
-
-void QIHelpButton::retranslateUi()
-{
-    QPushButton::setText (tr ("&Help"));
-    if (QPushButton::shortcut().isEmpty())
-        QPushButton::setShortcut (QKeySequence::HelpContents); 
-}
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSpecialControls.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSpecialControls.cpp	(revision 24107)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSpecialControls.cpp	(revision 24107)
@@ -0,0 +1,268 @@
+/* VBox includes */
+#include "VBoxSpecialControls.h"
+
+/* VBox includes */
+#include "VBoxGlobal.h"
+
+#ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
+
+/********************************************************************************
+ *
+ * A mini cancel button in the native Cocoa version.
+ *
+ ********************************************************************************/
+VBoxMiniCancelButton::VBoxMiniCancelButton (QWidget *aParent /* = 0 */)
+  : QAbstractButton (aParent)
+{
+    setShortcut (QKeySequence (Qt::Key_Escape));
+    mButton = new VBoxCocoaButton (VBoxCocoaButton::CancelButton, this);
+    connect (mButton, SIGNAL (clicked()),
+             this, SIGNAL (clicked()));
+    setFixedSize (mButton->size());
+}
+
+/********************************************************************************
+ *
+ * A help button in the native Cocoa version.
+ *
+ ********************************************************************************/
+VBoxHelpButton::VBoxHelpButton (QWidget *aParent /* = 0 */)
+  : QPushButton (aParent)
+{
+    setShortcut (QKeySequence (QKeySequence::HelpContents));
+    mButton = new VBoxCocoaButton (VBoxCocoaButton::HelpButton, this);
+    connect (mButton, SIGNAL (clicked()),
+             this, SIGNAL (clicked()));
+    setFixedSize (mButton->size());
+}
+
+/********************************************************************************
+ *
+ * A segmented button in the native Cocoa version.
+ *
+ ********************************************************************************/
+VBoxSegmentedButton::VBoxSegmentedButton (int aCount, QWidget *aParent /* = 0 */)
+  : VBoxCocoaSegmentedButton (aCount, aParent)
+{
+}
+/********************************************************************************
+ *
+ * A search field in the native Cocoa version.
+ *
+ ********************************************************************************/
+VBoxSearchField::VBoxSearchField (QWidget *aParent /* = 0 */)
+  : VBoxCocoaSearchField (aParent)
+{
+}
+
+#else /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
+
+/* Qt includes */
+#include <QPainter>
+#include <QBitmap>
+#include <QMouseEvent>
+#include <QSignalMapper>
+
+/********************************************************************************
+ *
+ * A mini cancel button for the other OS's.
+ *
+ ********************************************************************************/
+VBoxMiniCancelButton::VBoxMiniCancelButton (QWidget *aParent /* = 0 */)
+  : QIWithRetranslateUI<QIToolButton> (aParent)
+{
+    setAutoRaise (true);
+    setFocusPolicy (Qt::TabFocus);
+    setShortcut (QKeySequence (Qt::Key_Escape));
+    setIcon (VBoxGlobal::iconSet (":/delete_16px.png",
+                                  ":/delete_dis_16px.png"));
+}
+
+/********************************************************************************
+ *
+ * A help button for the other OS's.
+ *
+ ********************************************************************************/
+/* From: src/gui/styles/qmacstyle_mac.cpp */
+static const int PushButtonLeftOffset = 6;
+static const int PushButtonTopOffset = 4;
+static const int PushButtonRightOffset = 12;
+static const int PushButtonBottomOffset = 4;
+
+VBoxHelpButton::VBoxHelpButton (QWidget *aParent /* = 0 */)
+    : QIWithRetranslateUI<QPushButton> (aParent)
+{
+#ifdef Q_WS_MAC
+    mButtonPressed = false;
+    mNormalPixmap = new QPixmap (":/help_button_normal_mac_22px.png");
+    mPressedPixmap = new QPixmap (":/help_button_pressed_mac_22px.png");
+    mSize = mNormalPixmap->size();
+    mMask = new QImage (mNormalPixmap->mask().toImage());
+    mBRect = QRect (PushButtonLeftOffset,
+                    PushButtonTopOffset,
+                    mSize.width(),
+                    mSize.height());
+#endif /* Q_WS_MAC */
+    /* Applying language settings */
+    retranslateUi();
+}
+
+void VBoxHelpButton::initFrom (QPushButton *aOther)
+{
+    setIcon (aOther->icon());
+    setText (aOther->text());
+    setShortcut (aOther->shortcut());
+    setFlat (aOther->isFlat());
+    setAutoDefault (aOther->autoDefault());
+    setDefault (aOther->isDefault());
+    /* Applying language settings */
+    retranslateUi();
+}
+
+void VBoxHelpButton::retranslateUi()
+{
+    QPushButton::setText (tr ("&Help"));
+    if (QPushButton::shortcut().isEmpty())
+        QPushButton::setShortcut (QKeySequence::HelpContents);
+}
+
+#ifdef Q_WS_MAC
+VBoxHelpButton::~VBoxHelpButton()
+{
+    delete mNormalPixmap;
+    delete mPressedPixmap;
+    delete mMask;
+}
+
+QSize VBoxHelpButton::sizeHint() const
+{
+    return QSize (mSize.width() + PushButtonLeftOffset + PushButtonRightOffset,
+                  mSize.height() + PushButtonTopOffset + PushButtonBottomOffset);
+}
+
+void VBoxHelpButton::paintEvent (QPaintEvent * /* aEvent */)
+{
+    QPainter painter (this);
+    painter.drawPixmap (PushButtonLeftOffset, PushButtonTopOffset, mButtonPressed ? *mPressedPixmap: *mNormalPixmap);
+}
+
+bool VBoxHelpButton::hitButton (const QPoint &pos) const
+{
+    if (mBRect.contains (pos))
+        return  mMask->pixel (pos.x() - PushButtonLeftOffset,
+                              pos.y() - PushButtonTopOffset) == 0xff000000;
+    else
+        return false;
+}
+
+void VBoxHelpButton::mousePressEvent (QMouseEvent *aEvent)
+{
+    if (hitButton (aEvent->pos()))
+        mButtonPressed = true;
+    QPushButton::mousePressEvent (aEvent);
+    update();
+}
+
+void VBoxHelpButton::mouseReleaseEvent (QMouseEvent *aEvent)
+{
+    QPushButton::mouseReleaseEvent (aEvent);
+    mButtonPressed = false;
+    update();
+}
+
+void VBoxHelpButton::leaveEvent (QEvent * aEvent)
+{
+    QPushButton::leaveEvent (aEvent);
+    mButtonPressed = false;
+    update();
+}
+#endif /* Q_WS_MAC */
+
+/********************************************************************************
+ *
+ * A segmented button for the other OS's.
+ *
+ ********************************************************************************/
+VBoxSegmentedButton::VBoxSegmentedButton (int aCount, QWidget *aParent /* = 0 */)
+  : QWidget (aParent)
+{
+    mSignalMapper = new QSignalMapper (this);
+
+    QHBoxLayout *layout = new QHBoxLayout (this);
+    for (int i=0; i < aCount; ++i)
+    {
+        QIToolButton *button = new QIToolButton (this);
+        button->setAutoRaise (true);
+        button->setFocusPolicy (Qt::TabFocus);
+        button->setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
+        mButtons.append (button);
+        layout->addWidget (button);
+        connect (button, SIGNAL(clicked()),
+                 mSignalMapper, SLOT(map()));
+        mSignalMapper->setMapping (button, i);
+    }
+    connect (mSignalMapper, SIGNAL(mapped(int)),
+             this, SIGNAL(clicked(int)));
+
+}
+
+VBoxSegmentedButton::~VBoxSegmentedButton()
+{
+    delete mSignalMapper;
+    qDeleteAll (mButtons);
+}
+
+void VBoxSegmentedButton::setTitle (int aSegment, const QString &aTitle)
+{
+    mButtons.at (aSegment)->setText (aTitle);
+}
+
+void VBoxSegmentedButton::setToolTip (int aSegment, const QString &aTip)
+{
+    mButtons.at (aSegment)->setToolTip (aTip);
+}
+
+void VBoxSegmentedButton::setIcon (int aSegment, const QIcon &aIcon)
+{
+    mButtons.at (aSegment)->setIcon (aIcon);
+}
+
+void VBoxSegmentedButton::setEnabled (int aSegment, bool fEnabled)
+{
+    mButtons.at (aSegment)->setEnabled (fEnabled);
+}
+
+void VBoxSegmentedButton::animateClick (int aSegment)
+{
+    mButtons.at (aSegment)->animateClick();
+}
+
+/********************************************************************************
+ *
+ * A search field  for the other OS's.
+ *
+ ********************************************************************************/
+VBoxSearchField::VBoxSearchField (QWidget *aParent /* = 0 */)
+  : QLineEdit (aParent)
+{
+    mBaseBrush = palette().base();
+}
+
+void VBoxSearchField::markError()
+{
+    QPalette pal = palette();
+    QColor c (Qt::red);
+    c.setAlphaF (0.3);
+    pal.setBrush (QPalette::Base, c);
+    setPalette (pal);
+}
+
+void VBoxSearchField::unmarkError()
+{
+    QPalette pal = palette();
+    pal.setBrush (QPalette::Base, mBaseBrush);
+    setPalette (pal);
+}
+
+#endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp	(revision 24106)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp	(revision 24107)
@@ -21,8 +21,9 @@
  */
 
-#include <VBoxVMLogViewer.h>
-#include <VBoxGlobal.h>
-#include <VBoxProblemReporter.h>
-#include "QIToolButton.h"
+#include "VBoxVMLogViewer.h"
+#include "VBoxGlobal.h"
+#include "VBoxProblemReporter.h"
+#include "VBoxSpecialControls.h"
+#include "VBoxUtils.h"
 
 /* Qt includes */
@@ -121,4 +122,7 @@
     /* We have to force this to get the default button L&F on the mac. */
     defaultButton()->setEnabled (true);
+# ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
+    logsFrameLayout->setSpacing (4);
+# endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
 #endif /* Q_WS_MAC */
     /* Loading language constants */
@@ -339,18 +343,13 @@
     , mButtonClose (0)
     , mSearchName (0), mSearchString (0)
-    , mButtonPrev (0), mButtonNext (0)
+    , mButtonsNextPrev (0)
     , mCaseSensitive (0)
     , mWarningSpacer (0), mWarningIcon (0), mWarningString (0)
 {
-    mButtonClose = new QIToolButton (this);
-    mButtonClose->setAutoRaise (true);
-    mButtonClose->setFocusPolicy (Qt::TabFocus);
-    mButtonClose->setShortcut (QKeySequence (Qt::Key_Escape));
+    mButtonClose = new VBoxMiniCancelButton (this);
     connect (mButtonClose, SIGNAL (clicked()), this, SLOT (hide()));
-    mButtonClose->setIcon (VBoxGlobal::iconSet (":/delete_16px.png",
-                                                ":/delete_dis_16px.png"));
 
     mSearchName = new QLabel (this);
-    mSearchString = new QLineEdit (this);
+    mSearchString = new VBoxSearchField (this);
     mSearchString->setSizePolicy (QSizePolicy::Preferred,
                                   QSizePolicy::Fixed);
@@ -358,21 +357,12 @@
              this, SLOT (findCurrent (const QString &)));
 
-    mButtonNext = new QIToolButton (this);
-    mButtonNext->setEnabled (false);
-    mButtonNext->setAutoRaise (true);
-    mButtonNext->setFocusPolicy (Qt::TabFocus);
-    mButtonNext->setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
-    connect (mButtonNext, SIGNAL (clicked()), this, SLOT (findNext()));
-    mButtonNext->setIcon (VBoxGlobal::iconSet (":/list_movedown_16px.png",
-                                               ":/list_movedown_disabled_16px.png"));
-
-    mButtonPrev = new QIToolButton (this);
-    mButtonPrev->setEnabled (false);
-    mButtonPrev->setAutoRaise (true);
-    mButtonPrev->setFocusPolicy (Qt::TabFocus);
-    mButtonPrev->setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
-    connect (mButtonPrev, SIGNAL (clicked()), this, SLOT (findBack()));
-    mButtonPrev->setIcon (VBoxGlobal::iconSet (":/list_moveup_16px.png",
-                                               ":/list_moveup_disabled_16px.png"));
+    mButtonsNextPrev = new VBoxSegmentedButton (2, this);
+    mButtonsNextPrev->setEnabled (0, false);
+    mButtonsNextPrev->setIcon (0, VBoxGlobal::iconSet (":/list_movedown_16px.png",
+                                                       ":/list_movedown_disabled_16px.png"));
+    mButtonsNextPrev->setEnabled (1, false);
+    mButtonsNextPrev->setIcon (1, VBoxGlobal::iconSet (":/list_moveup_16px.png",
+                                                       ":/list_moveup_disabled_16px.png"));
+    connect (mButtonsNextPrev, SIGNAL (clicked (int)), this, SLOT (find (int)));
 
     mCaseSensitive = new QCheckBox (this);
@@ -391,4 +381,12 @@
     QSpacerItem *spacer = new QSpacerItem (0, 0, QSizePolicy::Expanding,
                                                  QSizePolicy::Minimum);
+
+#ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
+    QFont font = mSearchName->font();
+    font.setPointSize (::darwinSmallFontSize());
+    mSearchName->setFont (font);
+    mCaseSensitive->setFont (font);
+    mWarningString->setFont (font);
+#endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
 
     QHBoxLayout *mainLayout = new QHBoxLayout (this);
@@ -398,6 +396,5 @@
     mainLayout->addWidget (mSearchName);
     mainLayout->addWidget (mSearchString);
-    mainLayout->addWidget (mButtonNext);
-    mainLayout->addWidget (mButtonPrev);
+    mainLayout->addWidget (mButtonsNextPrev);
     mainLayout->addWidget (mCaseSensitive);
     mainLayout->addItem   (mWarningSpacer);
@@ -419,11 +416,12 @@
     mSearchString->setToolTip (tr ("Enter a search string here"));
 
-    VBoxGlobal::setTextLabel (mButtonPrev, tr ("&Previous"));
-    mButtonPrev->setToolTip (tr ("Search for the previous occurrence "
-                                 "of the string"));
-
-    VBoxGlobal::setTextLabel (mButtonNext, tr ("&Next"));
-    mButtonNext->setToolTip (tr ("Search for the next occurrence of "
-                                 "the string"));
+    mButtonsNextPrev->setTitle (0, tr ("&Next"));
+    mButtonsNextPrev->setToolTip (0, tr ("Search for the previous occurrence "
+                                         "of the string"));
+
+    mButtonsNextPrev->setTitle (1, tr ("&Previous"));
+    mButtonsNextPrev->setToolTip (1, tr ("Search for the next occurrence of "
+                                         "the string"));
+
 
     mCaseSensitive->setText (tr ("C&ase Sensitive"));
@@ -436,6 +434,6 @@
 void VBoxLogSearchPanel::findCurrent (const QString &aSearchString)
 {
-    mButtonNext->setEnabled (aSearchString.length());
-    mButtonPrev->setEnabled (aSearchString.length());
+    mButtonsNextPrev->setEnabled (0, aSearchString.length());
+    mButtonsNextPrev->setEnabled (1, aSearchString.length());
     toggleWarning (!aSearchString.length());
     if (aSearchString.length())
@@ -507,5 +505,5 @@
                 (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return))
             {
-                mButtonNext->animateClick();
+                mButtonsNextPrev->animateClick (0);
                 return true;
             }
@@ -514,7 +512,7 @@
             {
                 if (e->QInputEvent::modifiers() == 0)
-                    mButtonNext->animateClick();
+                    mButtonsNextPrev->animateClick (0);
                 else if (e->QInputEvent::modifiers() == Qt::ShiftModifier)
-                    mButtonPrev->animateClick();
+                    mButtonsNextPrev->animateClick (1);
                 return true;
             }
@@ -573,6 +571,17 @@
     mWarningSpacer->changeSize (aHide ? 0 : 16, 0, QSizePolicy::Fixed,
                                                    QSizePolicy::Minimum);
+    if (!aHide)
+        mSearchString->markError();
+    else
+        mSearchString->unmarkError();
     mWarningIcon->setHidden (aHide);
     mWarningString->setHidden (aHide);
 }
 
+void VBoxLogSearchPanel::find (int aButton)
+{
+    if (aButton == 0)
+        findNext();
+    else
+        findBack();
+}
Index: /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaSpecialControls.mm
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaSpecialControls.mm	(revision 24107)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaSpecialControls.mm	(revision 24107)
@@ -0,0 +1,386 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VBoxCocoaSpecialControls implementation
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+/* VBox includes */
+#include "VBoxCocoaSpecialControls.h"
+
+/* System includes */
+#import <AppKit/NSButton.h>
+#import <AppKit/NSApplication.h>
+#import <AppKit/NSImage.h>
+#import <AppKit/NSFont.h>
+#import <AppKit/NSSegmentedControl.h>
+#import <AppKit/NSBezierPath.h>
+
+/* Qt includes */
+#include <QApplication>
+#include <QKeyEvent>
+
+@interface NSButtonTarget: NSObject 
+{
+    VBoxCocoaButton *mRealTarget;
+}
+-(id)initWithObject:(VBoxCocoaButton*)object;
+-(IBAction)clicked:(id)sender;
+@end
+
+@implementation NSButtonTarget
+-(id)initWithObject:(VBoxCocoaButton*)object
+{
+    self = [super init];
+
+    mRealTarget = object;
+
+    return self;
+}
+
+-(IBAction)clicked:(id)sender;
+{
+    mRealTarget->onClicked();
+}
+@end
+
+@interface NSSegmentedButtonTarget: NSObject 
+{
+    VBoxCocoaSegmentedButton *mRealTarget;
+}
+-(id)initWithObject1:(VBoxCocoaSegmentedButton*)object;
+-(IBAction)segControlClicked:(id)sender;
+@end
+
+@implementation NSSegmentedButtonTarget
+-(id)initWithObject1:(VBoxCocoaSegmentedButton*)object
+{
+    self = [super init];
+
+    mRealTarget = object;
+
+    return self;
+}
+
+-(IBAction)segControlClicked:(id)sender;
+{
+    mRealTarget->onClicked([sender selectedSegment]);
+}
+@end
+
+@interface VBSearchField: NSSearchField 
+{
+    VBoxCocoaSearchField *mRealTarget;
+}
+-(id)initWithObject2:(VBoxCocoaSearchField*)object;
+@end
+
+@implementation VBSearchField
+-(id)initWithObject2:(VBoxCocoaSearchField*)object
+{
+    self = [super init];
+
+    mRealTarget = object;
+
+    return self;
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+    /* This here is a little bit hacky. Grab important keys & forward they to
+       the parent Qt widget. There a special key handling is done. */
+    NSString *str = [theEvent charactersIgnoringModifiers];
+    unichar ch = 0;
+
+    /* Get the pressed character */
+    if ([str length] > 0) 
+        ch = [str characterAtIndex:0];
+
+    if (ch == NSCarriageReturnCharacter || ch == NSEnterCharacter) 
+    {
+        QKeyEvent ke(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
+        QApplication::sendEvent (mRealTarget, &ke);
+    } 
+    else if (ch == 27) /* Escape */
+    {
+        QKeyEvent ke(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+        QApplication::sendEvent (mRealTarget, &ke);
+    } 
+    else if (ch == NSF3FunctionKey)
+    {
+        QKeyEvent ke(QEvent::KeyPress, Qt::Key_F3, [theEvent modifierFlags] & NSShiftKeyMask ? Qt::ShiftModifier : Qt::NoModifier);
+        QApplication::sendEvent (mRealTarget, &ke);
+    }
+
+    [super keyUp:theEvent];
+}
+
+//{
+//    QWidget *w = QApplication::focusWidget();
+//    if (w)
+//        w->clearFocus();
+//}
+
+- (void)textDidChange:(NSNotification *)aNotification
+{
+    mRealTarget->onTextChanged (::darwinNSStringToQString ([[aNotification object] string]));
+}
+@end
+
+#if MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_6
+@interface VBSearchFieldDelegate: NSObject<NSTextFieldDelegate>
+#else
+@interface VBSearchFieldDelegate: NSObject
+#endif
+{}
+@end
+@implementation VBSearchFieldDelegate
+-(BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector 
+{
+//    NSLog (NSStringFromSelector (commandSelector));
+    /* Don't execute the selector for Enter & Escape. */
+    if (   commandSelector == @selector(insertNewline:) 
+	    || commandSelector == @selector(cancelOperation:)) 
+		return YES;
+    return NO;
+}
+@end
+
+@interface VBSearchFieldCell: NSSearchFieldCell 
+{
+    NSColor *mBGColor;
+}
+- (void)setBackgroundColor:(NSColor*)aBGColor;
+@end
+
+@implementation VBSearchFieldCell
+- (void)setBackgroundColor:(NSColor*)aBGColor
+{
+    if (mBGColor != aBGColor) 
+    {
+        [mBGColor release];
+        mBGColor = [aBGColor retain];
+    }
+}
+
+- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
+{
+    if (mBGColor)
+    {
+        [mBGColor setFill];
+        NSRect frame = cellFrame;
+        frame.size.height -= 1;
+        frame.origin.y += 1;
+        double radius = MIN(frame.size.width, frame.size.height) / 2.0;
+        [[NSBezierPath bezierPathWithRoundedRect:frame xRadius:radius yRadius:radius] fill];
+    }
+
+    [super drawInteriorWithFrame:cellFrame inView:controlView];
+}
+@end
+
+NSRect darwinCenterRectVerticalTo (NSRect aRect, const NSRect& aToRect)
+{
+    aRect.origin.y = (aToRect.size.height - aRect.size.height) / 2.0;
+    return aRect;
+}
+
+VBoxCocoaButton::VBoxCocoaButton (CocoaButtonType aType, QWidget *aParent /* = 0 */)
+  : QMacCocoaViewContainer (0, aParent)
+{
+    switch (aType)
+    {
+        case HelpButton:
+        {
+            mNativeRef = [[NSButton alloc] init];
+            [mNativeRef setTitle: @""];
+            [mNativeRef setBezelStyle: NSHelpButtonBezelStyle];
+            [mNativeRef setBordered: YES];
+            [mNativeRef setAlignment: NSCenterTextAlignment];
+            [mNativeRef sizeToFit];
+            NSRect frame = [mNativeRef frame];
+            frame.size.width += 12; /* Margin */
+            [mNativeRef setFrame:frame];
+            break;
+        };
+        case CancelButton:
+        {
+            mNativeRef = [[NSButton alloc] initWithFrame: NSMakeRect(0, 0, 13, 13)];
+            [mNativeRef setTitle: @""];
+            [mNativeRef setBezelStyle:NSShadowlessSquareBezelStyle];
+            [mNativeRef setButtonType:NSMomentaryChangeButton];
+            [mNativeRef setImage: [NSImage imageNamed: NSImageNameStopProgressFreestandingTemplate]];
+            [mNativeRef setBordered: NO];
+            [[mNativeRef cell] setImageScaling: NSImageScaleProportionallyDown];
+            break;
+        }
+    }
+
+    NSButtonTarget *bt = [[NSButtonTarget alloc] initWithObject:this];
+    [mNativeRef setTarget:bt];
+    [mNativeRef setAction:@selector(clicked:)];
+
+    NSRect frame = [mNativeRef frame];
+    setFixedSize (frame.size.width, frame.size.height);
+
+    setCocoaView (mNativeRef);
+}
+
+QSize VBoxCocoaButton::sizeHint() const
+{
+    NSRect frame = [mNativeRef frame];
+    return QSize (frame.size.width, frame.size.height);
+}
+
+void VBoxCocoaButton::setToolTip (const QString& aTip)
+{
+    [mNativeRef setToolTip: ::darwinQStringToNSString (aTip)];
+}
+
+void VBoxCocoaButton::onClicked()
+{
+    emit clicked (false);
+}
+
+VBoxCocoaSegmentedButton::VBoxCocoaSegmentedButton (int aCount, QWidget *aParent /* = 0 */)
+  : QMacCocoaViewContainer (0, aParent)
+{
+    mNativeRef = [[NSSegmentedControl alloc] init];
+    [mNativeRef setSegmentCount:aCount];
+    [mNativeRef setSegmentStyle:NSSegmentStyleRoundRect];
+    [[mNativeRef cell] setTrackingMode: NSSegmentSwitchTrackingMomentary];
+    [mNativeRef setFont: [NSFont controlContentFontOfSize: 
+        [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
+    [mNativeRef sizeToFit];
+
+    NSSegmentedButtonTarget *bt = [[NSSegmentedButtonTarget alloc] initWithObject1:this];
+    [mNativeRef setTarget:bt];
+    [mNativeRef setAction:@selector(segControlClicked:)];
+
+    setCocoaView (mNativeRef);
+
+    NSRect frame = [mNativeRef frame];
+    resize (frame.size.width, frame.size.height);
+}
+
+QSize VBoxCocoaSegmentedButton::sizeHint() const
+{
+    NSRect frame = [mNativeRef frame];
+    return QSize (frame.size.width, frame.size.height);
+}
+
+void VBoxCocoaSegmentedButton::setTitle (int aSegment, const QString &aTitle)
+{
+    QString s (aTitle);
+    [mNativeRef setLabel: ::darwinQStringToNSString (s.remove ('&')) forSegment: aSegment];
+    [mNativeRef sizeToFit];
+    NSRect frame = [mNativeRef frame];
+    resize (frame.size.width, frame.size.height);
+}
+
+void VBoxCocoaSegmentedButton::setToolTip (int aSegment, const QString &aTip)
+{
+    [[mNativeRef cell] setToolTip: ::darwinQStringToNSString (aTip) forSegment: aSegment];
+}
+
+void VBoxCocoaSegmentedButton::setEnabled (int aSegment, bool fEnabled)
+{
+    [[mNativeRef cell] setEnabled: fEnabled forSegment: aSegment];
+}
+
+void VBoxCocoaSegmentedButton::animateClick (int aSegment)
+{
+    [mNativeRef setSelectedSegment: aSegment];
+    [[mNativeRef cell] performClick: mNativeRef];
+}
+
+void VBoxCocoaSegmentedButton::onClicked (int aSegment)
+{
+    emit clicked (aSegment, false);
+}
+
+VBoxCocoaSearchField::VBoxCocoaSearchField (QWidget *aParent /* = 0 */)
+  : QMacCocoaViewContainer (0, aParent)
+{
+    mNativeRef = [[VBSearchField alloc] initWithObject2: this];
+    [[mNativeRef cell] setControlSize: NSSmallControlSize];
+    [mNativeRef setFont: [NSFont controlContentFontOfSize: 
+        [NSFont systemFontSizeForControlSize: NSSmallControlSize]]];
+    [mNativeRef sizeToFit];
+    NSRect f = [mNativeRef frame];
+    f.size.width = 180;
+    [mNativeRef setFrame: f];
+
+    setCocoaView (mNativeRef);
+    setFocusPolicy(Qt::StrongFocus);
+
+    /* Replace the cell class used for the NSSearchField */
+    [NSKeyedArchiver setClassName:@"VBSearchFieldCell" forClass:[NSSearchFieldCell class]];
+    [mNativeRef setCell:[NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:[mNativeRef cell]]]];
+    /* Get the original behavior back */
+    [NSKeyedArchiver setClassName:@"NSSearchFieldCell" forClass:[NSSearchFieldCell class]];
+
+    /* Use our own delegate */
+    VBSearchFieldDelegate *sfd = [[VBSearchFieldDelegate alloc] init];
+    [mNativeRef setDelegate: sfd];
+
+    NSRect frame = [mNativeRef frame];
+    resize (frame.size.width, frame.size.height + 1);
+}
+
+QSize VBoxCocoaSearchField::sizeHint() const
+{
+    NSRect frame = [mNativeRef frame];
+    return QSize (frame.size.width, frame.size.height);
+}
+
+QString VBoxCocoaSearchField::text() const
+{
+    return ::darwinNSStringToQString ([mNativeRef stringValue]);
+}
+
+void VBoxCocoaSearchField::insert (const QString &aText)
+{
+    [[mNativeRef currentEditor] setString: [[mNativeRef stringValue] stringByAppendingString: ::darwinQStringToNSString (aText)]];
+}
+
+void VBoxCocoaSearchField::setToolTip (const QString &aTip)
+{
+    [mNativeRef setToolTip: ::darwinQStringToNSString (aTip)];
+}
+
+void VBoxCocoaSearchField::selectAll()
+{
+    [mNativeRef selectText: mNativeRef];
+}
+
+void VBoxCocoaSearchField::markError()
+{
+    [[mNativeRef cell] setBackgroundColor: [[NSColor redColor] colorWithAlphaComponent: 0.3]];
+}
+
+void VBoxCocoaSearchField::unmarkError()
+{
+    [[mNativeRef cell] setBackgroundColor: nil];
+}
+
+void VBoxCocoaSearchField::onTextChanged (const QString &aText)
+{
+    emit textChanged (aText);
+}
+
Index: unk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.m
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.m	(revision 24106)
+++ 	(revision )
@@ -1,157 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * Declarations of utility classes and functions for handling Darwin Cocoa
- * specific tasks
- */
-
-/*
- * Copyright (C) 2009 Sun Microsystems, Inc.
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
- * Clara, CA 95054 USA or visit http://www.sun.com if you need
- * additional information or have any questions.
- */
-
-#include "VBoxUtils-darwin.h"
-
-#include <iprt/assert.h>
-
-#import <AppKit/NSEvent.h>
-#import <AppKit/NSColor.h>
-
-NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    NativeWindowRef window = NULL;
-    if (aView)
-        window = [aView window];
-
-    [pool release];
-    return window;
-}
-
-NativeViewRef darwinToNativeViewImpl (NativeWindowRef aWindow)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    NativeViewRef view = NULL;
-    if (aWindow)
-        view = [aWindow contentView];
-
-    [pool release];
-    return view;
-}
-
-void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    [aWindow setShowsToolbarButton:aEnabled];
-
-    [pool release];
-}
-
-void darwinSetShowsResizeIndicatorImpl (NativeWindowRef aWindow, bool aEnabled)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    [aWindow setShowsResizeIndicator:aEnabled];
-
-    [pool release];
-}
-
-void darwinSetHidesAllTitleButtonsImpl (NativeWindowRef aWindow)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    NSButton *closeButton = [aWindow standardWindowButton:NSWindowCloseButton];
-    if (closeButton != Nil)
-        [closeButton setHidden:YES];
-    NSButton *minButton = [aWindow standardWindowButton:NSWindowMiniaturizeButton];
-    if (minButton != Nil)
-        [minButton setHidden:YES];
-    NSButton *zoomButton = [aWindow standardWindowButton:NSWindowZoomButton];
-    if (zoomButton != Nil)
-        [zoomButton setHidden:YES];
-    NSButton *iconButton = [aWindow standardWindowButton:NSWindowDocumentIconButton];
-    if (iconButton != Nil)
-        [iconButton setHidden:YES];
-
-    [pool release];
-}
-
-void darwinSetShowsWindowTransparentImpl (NativeWindowRef aWindow, bool aEnabled)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    if (aEnabled)
-    {
-        [aWindow setOpaque:NO];
-        [aWindow setBackgroundColor:[NSColor clearColor]];
-        [aWindow setHasShadow:NO];
-    }
-    else
-    {
-        [aWindow setOpaque:YES];
-        [aWindow setBackgroundColor:[NSColor windowBackgroundColor]];
-        [aWindow setHasShadow:YES];
-    }
-
-    [pool release];
-}
-
-/**
- * Calls the + (void)setMouseCoalescingEnabled:(BOOL)flag class method.
- *
- * @param   fEnabled    Whether to enable or disable coalescing.
- */
-void darwinSetMouseCoalescingEnabled (bool aEnabled)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    [NSEvent setMouseCoalescingEnabled:aEnabled];
-
-    [pool release];
-}
-
-void darwinWindowAnimateResizeImpl (NativeWindowRef aWindow, int x, int y, int width, int height)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    /* It seems that Qt doesn't return the height of the window with the
-     * toolbar height included. So add this size manually. Could easily be that
-     * the Trolls fix this in the final release. */
-    NSToolbar *toolbar = [aWindow toolbar];
-    NSRect windowFrame = [aWindow frame];
-    int toolbarHeight = 0;
-    if(toolbar && [toolbar isVisible])
-        toolbarHeight = NSHeight (windowFrame) - NSHeight ([[aWindow contentView] frame]);
-    int h = height + toolbarHeight;
-    int h1 = h - NSHeight (windowFrame);
-    windowFrame.size.height = h;
-    windowFrame.origin.y -= h1;
-
-    [aWindow setFrame:windowFrame display:YES animate:YES];
-
-    [pool release];
-}
-
-void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    [aWindow invalidateShadow];
-
-    [pool release];
-}
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm	(revision 24107)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm	(revision 24107)
@@ -0,0 +1,180 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * Declarations of utility classes and functions for handling Darwin Cocoa
+ * specific tasks
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#include "VBoxUtils-darwin.h"
+
+#include <iprt/assert.h>
+
+#import <AppKit/NSEvent.h>
+#import <AppKit/NSColor.h>
+#import <AppKit/NSFont.h>
+
+NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NativeWindowRef window = NULL;
+    if (aView)
+        window = [aView window];
+    
+    [pool release];
+    return window;
+}
+
+NativeViewRef darwinToNativeViewImpl (NativeWindowRef aWindow)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NativeViewRef view = NULL;
+    if (aWindow)
+        view = [aWindow contentView];   
+
+    [pool release];
+    return view;
+}
+
+void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    [aWindow setShowsToolbarButton:aEnabled];
+
+    [pool release];
+}
+
+void darwinSetShowsResizeIndicatorImpl (NativeWindowRef aWindow, bool aEnabled)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    [aWindow setShowsResizeIndicator:aEnabled];
+
+    [pool release];
+}
+
+void darwinSetHidesAllTitleButtonsImpl (NativeWindowRef aWindow)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NSButton *closeButton = [aWindow standardWindowButton:NSWindowCloseButton];
+    if (closeButton != Nil)
+        [closeButton setHidden:YES];
+    NSButton *minButton = [aWindow standardWindowButton:NSWindowMiniaturizeButton];
+    if (minButton != Nil)
+        [minButton setHidden:YES];
+    NSButton *zoomButton = [aWindow standardWindowButton:NSWindowZoomButton];
+    if (zoomButton != Nil)
+        [zoomButton setHidden:YES];
+    NSButton *iconButton = [aWindow standardWindowButton:NSWindowDocumentIconButton];
+    if (iconButton != Nil)
+        [iconButton setHidden:YES];
+
+    [pool release];
+}
+
+void darwinSetShowsWindowTransparentImpl (NativeWindowRef aWindow, bool aEnabled)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    if (aEnabled)
+    {
+        [aWindow setOpaque:NO];
+        [aWindow setBackgroundColor:[NSColor clearColor]];
+        [aWindow setHasShadow:NO];
+    }
+    else
+    {
+        [aWindow setOpaque:YES];
+        [aWindow setBackgroundColor:[NSColor windowBackgroundColor]];
+        [aWindow setHasShadow:YES];
+    }
+
+    [pool release];
+}
+
+/**
+ * Calls the + (void)setMouseCoalescingEnabled:(BOOL)flag class method.
+ *
+ * @param   fEnabled    Whether to enable or disable coalescing.
+ */
+void darwinSetMouseCoalescingEnabled (bool aEnabled)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    [NSEvent setMouseCoalescingEnabled:aEnabled];
+
+    [pool release];
+}
+
+void darwinWindowAnimateResizeImpl (NativeWindowRef aWindow, int x, int y, int width, int height)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    /* It seems that Qt doesn't return the height of the window with the
+     * toolbar height included. So add this size manually. Could easily be that
+     * the Trolls fix this in the final release. */
+    NSToolbar *toolbar = [aWindow toolbar];
+    NSRect windowFrame = [aWindow frame];
+    int toolbarHeight = 0;
+    if(toolbar && [toolbar isVisible])
+        toolbarHeight = NSHeight (windowFrame) - NSHeight ([[aWindow contentView] frame]);
+    int h = height + toolbarHeight;
+    int h1 = h - NSHeight (windowFrame);
+    windowFrame.size.height = h;
+    windowFrame.origin.y -= h1;
+
+    [aWindow setFrame:windowFrame display:YES animate:YES];
+
+    [pool release];
+}
+
+void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    [aWindow invalidateShadow];
+
+    [pool release];
+}
+
+int darwinWindowToolBarHeight (NativeWindowRef aWindow)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NSToolbar *toolbar = [aWindow toolbar];
+    NSRect windowFrame = [aWindow frame];
+    int toolbarHeight = 0;
+    int theight = (NSHeight([NSWindow contentRectForFrameRect:[aWindow frame] styleMask:[aWindow styleMask]]) - NSHeight([[aWindow contentView] frame]));
+    /* toolbar height: */
+    if(toolbar && [toolbar isVisible])
+        /* title bar height: */
+        toolbarHeight = NSHeight (windowFrame) - NSHeight ([[aWindow contentView] frame]) - theight;
+
+    [pool release];
+    return toolbarHeight;
+}
+
+float darwinSmallFontSize()
+{
+    return [NSFont systemFontSizeForControlSize: NSSmallControlSize];
+}
+
