]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/dcclient.mm
regenerated
[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>
17
18/*
19 * wxWindowDC
20 */
21IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
22
23wxWindowDC::wxWindowDC(void)
24{
25};
26
27wxWindowDC::wxWindowDC( wxWindow *window )
28{
29 wxFAIL_MSG("non-client window DC's are not supported");
30};
31
32wxWindowDC::~wxWindowDC(void)
33{
34};
35
36/*
37 * wxClientDC
38 */
39IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
40
41wxClientDC::wxClientDC(void)
42{
43};
44
45wxClientDC::wxClientDC( wxWindow *window )
46{
47};
48
49wxClientDC::~wxClientDC(void)
50{
51};
52
53/*
54 * wxPaintDC
55 */
56IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
57
58wxPaintDC::wxPaintDC(void)
59{
60};
61
62wxPaintDC::wxPaintDC( wxWindow *window )
63{
64 wxASSERT_MSG(!sm_focusedDC,"Found another wxDC with focus. Do not use wxPaintDC outside of paint handlers!");
65 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");
66 sm_focusedDC=this;
67 // This transform flips the graphics since wxDC uses top-left origin
68 if(![window->GetNSView() isFlipped])
69 {
70 // The transform is auto released
71 NSAffineTransform *transform = [NSAffineTransform transform];
72 /* x' = 1x + 0y + 0
73 y' = 0x + -1y + window's height
74 */
75 NSAffineTransformStruct matrix = {
76 1, 0
77 , 0, -1
78 , 0, [window->GetNSView() bounds].size.height
79 };
80 [transform setTransformStruct: matrix];
81 // Apply the transform
82 [transform concat];
83 }
84 // TODO: Apply scaling transformation
85};
86
87wxPaintDC::~wxPaintDC(void)
88{
89 if(sm_focusedDC==this)
90 sm_focusedDC=NULL;
91};
92