Qt 4.8
Public Functions | Properties | List of all members
QCocoaWindow Class Reference

#include <qcocoawindow.h>

Inheritance diagram for QCocoaWindow:
QPlatformWindow

Public Functions

NSView * contentView () const
 
 QCocoaWindow (QWidget *tlw)
 
void setContentView (NSView *contentView)
 
void setGeometry (const QRect &rect)
 This function is called by Qt whenever a window is moved or the window is resized. More...
 
void setVisible (bool visible)
 Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false. More...
 
void windowDidResize ()
 
WId winId () const
 Reimplement in subclasses to return a handle to the native window. More...
 
 ~QCocoaWindow ()
 
- Public Functions inherited from QPlatformWindow
virtual QRect geometry () const
 Returnes the current geometry of a window. More...
 
virtual QPlatformGLContextglContext () const
 Reimplement to return the glContext associated with the window. More...
 
virtual void lower ()
 Reimplement to be able to let Qt lower windows to the bottom of the desktop. More...
 
 QPlatformWindow (QWidget *tlw)
 Constructs a platform window with the given top level widget. More...
 
virtual void raise ()
 Reimplement to be able to let Qt rais windows to the top of the desktop. More...
 
virtual void requestActivateWindow ()
 Reimplement to let Qt be able to request activation/focus for a window. More...
 
virtual void setOpacity (qreal level)
 Reimplement to be able to let Qt set the opacity level of a window. More...
 
virtual void setParent (const QPlatformWindow *window)
 This function is called to enable native child widgets in QPA. More...
 
virtual Qt::WindowFlags setWindowFlags (Qt::WindowFlags flags)
 Requests setting the window flags of this surface to type. More...
 
virtual void setWindowTitle (const QString &title)
 Reimplement to set the window title to title. More...
 
QWidgetwidget () const
 Returnes the widget which belongs to the QPlatformWindow. More...
 
virtual Qt::WindowFlags windowFlags () const
 Returns the effective window flags for this surface. More...
 
virtual ~QPlatformWindow ()
 Virtual destructor does not delete its top level widget. More...
 

Properties

NSWindow * m_nsWindow
 

Additional Inherited Members

- Protected Variables inherited from QPlatformWindow
QScopedPointer< QPlatformWindowPrivated_ptr
 

Detailed Description

Definition at line 51 of file qcocoawindow.h.

Constructors and Destructors

◆ QCocoaWindow()

QCocoaWindow::QCocoaWindow ( QWidget tlw)

Definition at line 53 of file qcocoawindow.mm.

54  : QPlatformWindow(tlw)
55 {
57  const QRect geo = tlw->geometry();
58  NSRect frame = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
59 
60  m_nsWindow = [[NSWindow alloc] initWithContentRect:frame
61  styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
62  backing:NSBackingStoreBuffered
63  defer:YES];
64 
65  QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
66  [m_nsWindow setDelegate:delegate];
67 
68  [m_nsWindow makeKeyAndOrderFront:nil];
69  [m_nsWindow setAcceptsMouseMovedEvents:YES];
70 
71 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
72  if ([m_nsWindow respondsToSelector:@selector(setRestorable:)])
73  [m_nsWindow setRestorable: NO];
74 #endif
75 }
NSWindow * m_nsWindow
Definition: qcocoawindow.h:69
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QPlatformWindow(QWidget *tlw)
Constructs a platform window with the given top level widget.
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158

◆ ~QCocoaWindow()

QCocoaWindow::~QCocoaWindow ( )

Definition at line 77 of file qcocoawindow.mm.

78 {
79 }

Functions

◆ contentView()

NSView * QCocoaWindow::contentView ( ) const

Definition at line 99 of file qcocoawindow.mm.

Referenced by setContentView(), setGeometry(), and windowDidResize().

100 {
101  return [m_nsWindow contentView];
102 }
NSWindow * m_nsWindow
Definition: qcocoawindow.h:69
NSView * contentView() const
Definition: qcocoawindow.mm:99

◆ setContentView()

void QCocoaWindow::setContentView ( NSView *  contentView)

Definition at line 104 of file qcocoawindow.mm.

Referenced by QCocoaWindowSurface::QCocoaWindowSurface().

105 {
107 }
NSWindow * m_nsWindow
Definition: qcocoawindow.h:69
NSView * contentView() const
Definition: qcocoawindow.mm:99
void setContentView(NSView *contentView)

◆ setGeometry()

void QCocoaWindow::setGeometry ( const QRect rect)
virtual

This function is called by Qt whenever a window is moved or the window is resized.

The resize can happen programatically(from ie. user application) or by the window manager. This means that there is no need to call this function specifically from the window manager callback, instead call QWindowSystemInterface::handleGeometryChange(QWidget *w, const QRect &newRect);

Reimplemented from QPlatformWindow.

Definition at line 81 of file qcocoawindow.mm.

82 {
84 
85  NSRect bounds = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
86  [[m_nsWindow contentView]setFrameSize:bounds.size];
87 }
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or the window is resized.
NSWindow * m_nsWindow
Definition: qcocoawindow.h:69
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
NSView * contentView() const
Definition: qcocoawindow.mm:99
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252

◆ setVisible()

void QCocoaWindow::setVisible ( bool  visible)
virtual

Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.

Reimplemented from QPlatformWindow.

Definition at line 89 of file qcocoawindow.mm.

90 {
91  Q_UNUSED(visible);
92 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ windowDidResize()

void QCocoaWindow::windowDidResize ( )

Definition at line 109 of file qcocoawindow.mm.

110 {
111  //jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing...
112  NSRect rect = [[m_nsWindow contentView]frame];
113  QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
115 }
NSWindow * m_nsWindow
Definition: qcocoawindow.h:69
NSView * contentView() const
Definition: qcocoawindow.mm:99
static void handleGeometryChange(QWidget *w, const QRect &newRect)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ winId()

WId QCocoaWindow::winId ( ) const
virtual

Reimplement in subclasses to return a handle to the native window.

Reimplemented from QPlatformWindow.

Definition at line 94 of file qcocoawindow.mm.

95 {
96  return WId([m_nsWindow windowNumber]);
97 }
unsigned long WId
Definition: qwindowdefs.h:119
NSWindow * m_nsWindow
Definition: qcocoawindow.h:69

Properties

◆ m_nsWindow

NSWindow* QCocoaWindow::m_nsWindow
private

The documentation for this class was generated from the following files: