]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/dcclient.mm
removed OnIdle() which didn't compile any longer
[wxWidgets.git] / src / cocoa / dcclient.mm
CommitLineData
891d0563
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/cocoa/dcclient.mm
3// Purpose: wxWindowDC, wxPaintDC, and wxClientDC classes
4// Author: David Elliott
5// Modified by:
6// Created: 2003/04/01
7// RCS-ID: $Id$
8// Copyright: (c) 2003 David Elliott
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/dcclient.h"
13#include "wx/window.h"
14
15#import <AppKit/NSView.h>
16#import <AppKit/NSAffineTransform.h>
9d180f3a
DE
17#import <AppKit/NSColor.h>
18#import <AppKit/NSGraphicsContext.h>
19#import <AppKit/NSBezierPath.h>
891d0563
DE
20
21/*
22 * wxWindowDC
23 */
24IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
25
26wxWindowDC::wxWindowDC(void)
fcc9de54 27: m_window(NULL)
891d0563
DE
28{
29};
30
31wxWindowDC::wxWindowDC( wxWindow *window )
fcc9de54 32: m_window(window)
891d0563
DE
33{
34 wxFAIL_MSG("non-client window DC's are not supported");
35};
36
37wxWindowDC::~wxWindowDC(void)
38{
39};
40
9d180f3a
DE
41void wxWindowDC::Clear()
42{
43 wxASSERT(m_window);
44
45 NSGraphicsContext *context = [NSGraphicsContext currentContext];
46 [context saveGraphicsState];
47
48 [m_backgroundBrush.GetNSColor() set];
49 [NSBezierPath fillRect:[m_window->GetNSView() bounds]];
50
51 [context restoreGraphicsState];
52}
53
891d0563
DE
54/*
55 * wxClientDC
56 */
57IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
58
59wxClientDC::wxClientDC(void)
60{
61};
62
63wxClientDC::wxClientDC( wxWindow *window )
64{
d630f41d 65 m_window = window;
891d0563
DE
66};
67
68wxClientDC::~wxClientDC(void)
69{
70};
71
72/*
73 * wxPaintDC
74 */
75IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
76
77wxPaintDC::wxPaintDC(void)
78{
79};
80
81wxPaintDC::wxPaintDC( wxWindow *window )
82{
d630f41d 83 m_window = window;
891d0563 84 wxASSERT_MSG([NSView focusView]==window->GetNSView(), "PaintDC's NSView does not have focus. Please use wxPaintDC only as the first DC created in a paint handler");
891d0563
DE
85 // This transform flips the graphics since wxDC uses top-left origin
86 if(![window->GetNSView() isFlipped])
87 {
88 // The transform is auto released
89 NSAffineTransform *transform = [NSAffineTransform transform];
90 /* x' = 1x + 0y + 0
91 y' = 0x + -1y + window's height
92 */
93 NSAffineTransformStruct matrix = {
94 1, 0
95 , 0, -1
96 , 0, [window->GetNSView() bounds].size.height
97 };
98 [transform setTransformStruct: matrix];
99 // Apply the transform
100 [transform concat];
101 }
102 // TODO: Apply scaling transformation
103};
104
105wxPaintDC::~wxPaintDC(void)
106{
891d0563
DE
107};
108