2008-03-04 10:14:29 +00:00
|
|
|
/*
|
|
|
|
Win32CairoSurface.m
|
|
|
|
|
|
|
|
Copyright (C) 2008 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Xavier Glattard <xavier.glattard@online.fr>
|
|
|
|
Based on the work of:
|
|
|
|
Banlu Kemiyatorn <object at gmail dot com>
|
|
|
|
|
|
|
|
This file is part of GNUstep.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:12:46 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2008-03-04 10:14:29 +00:00
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cairo/Win32CairoSurface.h"
|
|
|
|
#include <cairo-win32.h>
|
|
|
|
|
|
|
|
#define GSWINDEVICE ((HWND)gsDevice)
|
|
|
|
|
|
|
|
@implementation Win32CairoSurface
|
|
|
|
|
|
|
|
- (id) initWithDevice: (void *)device
|
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
WIN_INTERN *win;
|
|
|
|
gsDevice = device;
|
|
|
|
|
|
|
|
win = (WIN_INTERN *)GetWindowLong(GSWINDEVICE, GWL_USERDATA);
|
2008-03-29 13:16:58 +00:00
|
|
|
if (win && win->useHDC)
|
2008-03-04 10:14:29 +00:00
|
|
|
hDC = win->hdc;
|
|
|
|
else
|
|
|
|
hDC = GetDC(GSWINDEVICE);
|
|
|
|
|
2008-03-29 13:16:58 +00:00
|
|
|
if (!hDC)
|
|
|
|
{
|
|
|
|
NSLog(@"Win32CairoSurface : %d : no device context",__LINE__);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2008-03-04 10:14:29 +00:00
|
|
|
_surface = cairo_win32_surface_create(hDC);
|
2008-03-29 13:16:58 +00:00
|
|
|
if (!(win && win->useHDC))
|
|
|
|
ReleaseDC(GSWINDEVICE, hDC);
|
|
|
|
if (cairo_surface_status(_surface))
|
|
|
|
{
|
|
|
|
DESTROY(self);
|
|
|
|
}
|
2008-03-04 10:14:29 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSSize) size
|
|
|
|
{
|
|
|
|
RECT sz;
|
2008-03-29 13:16:58 +00:00
|
|
|
|
|
|
|
GetClientRect(GSWINDEVICE, &sz);
|
|
|
|
return NSMakeSize(sz.right - sz.left, sz.top - sz.bottom);
|
2008-03-04 10:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|