mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 11:51:27 +00:00
New MS Windows backend
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@13523 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9b5717b4ad
commit
5a9f41a919
17 changed files with 3246 additions and 0 deletions
31
ChangeLog
31
ChangeLog
|
@ -1,3 +1,34 @@
|
|||
2002-04-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/win32
|
||||
* Headers/win32/WIN32Server.h
|
||||
* Headers/win32/WIN32Geometry.h
|
||||
* Source/win32
|
||||
* Source/win32/GNUmakefile
|
||||
* Source/win32/GNUmakefile.preamble
|
||||
* Source/win32/WIN32Server.m
|
||||
New directories and files with Display Server for MS Windows.
|
||||
* Headers/winlib
|
||||
* Headers/winlib/WIN32Context.h
|
||||
* Headers/winlib/WIN32GState.h
|
||||
* Headers/winlib/WIN32FontEnumerator.h
|
||||
* Headers/winlib/WIN32FontInfo.h
|
||||
* Source/winlib
|
||||
* Source/winlib/GNUmakefile
|
||||
* Source/winlib/GNUmakefile.preamble
|
||||
* Source/winlib/WIN32Context.m
|
||||
* Source/winlib/WIN32GState.m
|
||||
* Source/winlib/WIN32FontEnumerator.m
|
||||
* Source/winlib/WIN32FontInfo.m
|
||||
New directories and files for drawing on MS Windows.
|
||||
* configure
|
||||
Add library gdi32 for winlib back end.
|
||||
* Source/GSBackend.m
|
||||
Corrected to handle the winlib/win32 backend correctly.
|
||||
* Tools/gpbs.m
|
||||
Ifdefed some signals that are not defined in mingw and use spawn
|
||||
instead of fork on mingw.
|
||||
|
||||
2002-04-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Tools/gpbs.m: If given -NSHost specification for the current host,
|
||||
|
|
183
Headers/win32/WIN32Geometry.h
Normal file
183
Headers/win32/WIN32Geometry.h
Normal file
|
@ -0,0 +1,183 @@
|
|||
/* WIN32Geometry - Implements coordinate transformations for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: April 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32Geometry_h_INCLUDE
|
||||
#define _WIN32Geometry_h_INCLUDE
|
||||
|
||||
#include <Foundation/NSGeometry.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static inline
|
||||
NSPoint MSWindowPointToGS(HWND hwnd, int x, int y)
|
||||
{
|
||||
NSPoint p1;
|
||||
RECT rect;
|
||||
int h;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
p1.x = x;
|
||||
p1.y = h - y;
|
||||
return p1;
|
||||
}
|
||||
|
||||
static inline
|
||||
POINT GSWindowPointToMS(HWND hwnd, NSPoint p)
|
||||
{
|
||||
POINT p1;
|
||||
RECT rect;
|
||||
int h;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
p1.x = p.x;
|
||||
p1.y = h -p.y;
|
||||
|
||||
return p1;
|
||||
}
|
||||
|
||||
static inline
|
||||
NSRect MSWindowRectToGS(HWND hwnd, RECT r)
|
||||
{
|
||||
NSRect r1;
|
||||
RECT rect;
|
||||
int h;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
r1.origin.x = r.left;
|
||||
r1.origin.y = h - r.bottom;
|
||||
r1.size.width = r.right - r.left;
|
||||
r1.size.height = r.bottom -r.top;
|
||||
|
||||
return r1;
|
||||
}
|
||||
|
||||
static inline
|
||||
RECT GSWindowRectToMS(HWND hwnd, NSRect r)
|
||||
{
|
||||
RECT r1;
|
||||
RECT rect;
|
||||
int h;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
r1.left = r.origin.x;
|
||||
r1.bottom = h - r.origin.y;
|
||||
r1.right = r.origin.x + r.size.width;
|
||||
r1.top = h - r.origin.y - r.size.height;
|
||||
|
||||
return r1;
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
NSPoint MSWindowOriginToGS(HWND hwnd, int x, int y)
|
||||
{
|
||||
NSPoint p1;
|
||||
RECT rect;
|
||||
int h;
|
||||
int screen_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
GetWindowRect(hwnd, &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
p1.x = x;
|
||||
p1.y = screen_height - y - h;
|
||||
return p1;
|
||||
}
|
||||
|
||||
static inline
|
||||
POINT GSWindowOriginToMS(HWND hwnd, NSPoint p)
|
||||
{
|
||||
POINT p1;
|
||||
RECT rect;
|
||||
int h;
|
||||
int screen_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
GetWindowRect(hwnd, &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
p1.x = p.x;
|
||||
p1.y = screen_height - p.y + h;
|
||||
return p1;
|
||||
}
|
||||
|
||||
static inline
|
||||
NSPoint MSScreenPointToGS(int x, int y)
|
||||
{
|
||||
NSPoint p1;
|
||||
int screen_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
p1.x = x;
|
||||
p1.y = screen_height - y;
|
||||
return p1;
|
||||
}
|
||||
|
||||
static inline
|
||||
NSRect MSScreenRectToGS(RECT r)
|
||||
{
|
||||
NSRect r1;
|
||||
int screen_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
r1.origin.x = r.left;
|
||||
r1.origin.y = screen_height - r.bottom;
|
||||
r1.size.width = r.right - r.left;
|
||||
r1.size.height = r.bottom - r.top;
|
||||
|
||||
return r1;
|
||||
}
|
||||
|
||||
static inline
|
||||
POINT GSScreenPointToMS(NSPoint p)
|
||||
{
|
||||
POINT p1;
|
||||
int screen_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
p1.x = p.x;
|
||||
p1.y = screen_height - p.y;
|
||||
return p1;
|
||||
}
|
||||
|
||||
static inline
|
||||
RECT GSScreenRectToMS(NSRect r)
|
||||
{
|
||||
RECT r1;
|
||||
int screen_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
r1.left = r.origin.x;
|
||||
r1.bottom = screen_height - r.origin.y;
|
||||
r1.right = r.origin.x + r.size.width;
|
||||
r1.top = screen_height - r.origin.y - r.size.height;
|
||||
|
||||
return r1;
|
||||
}
|
||||
|
||||
|
||||
#endif /* _WIN32Geometry_h_INCLUDE */
|
46
Headers/win32/WIN32Server.h
Normal file
46
Headers/win32/WIN32Server.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32Server_h_INCLUDE
|
||||
#define _WIN32Server_h_INCLUDE
|
||||
|
||||
#include <AppKit/GSDisplayServer.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
@interface WIN32Server : GSDisplayServer
|
||||
{
|
||||
@public
|
||||
HINSTANCE hinstance;
|
||||
}
|
||||
@end
|
||||
|
||||
typedef struct _win_intern {
|
||||
BOOL useHDC;
|
||||
HDC hdc;
|
||||
MINMAXINFO minmax;
|
||||
} WIN_INTERN;
|
||||
|
||||
|
||||
#endif /* _WIN32Server_h_INCLUDE */
|
37
Headers/winlib/WIN32Context.h
Normal file
37
Headers/winlib/WIN32Context.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* WIN32Context - Implements graphic context for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32Context_h_INCLUDE
|
||||
#define _WIN32Context_h_INCLUDE
|
||||
|
||||
#include "gsc/GSContext.h"
|
||||
|
||||
@interface WIN32Context : GSContext
|
||||
{
|
||||
@public
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* _WIN32Context_h_INCLUDE */
|
35
Headers/winlib/WIN32FontEnumerator.h
Normal file
35
Headers/winlib/WIN32FontEnumerator.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Win32FontEnumerator - Implements font enumerator for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32FontEnumerator_h_INCLUDE
|
||||
#define _WIN32FontEnumerator_h_INCLUDE
|
||||
|
||||
#include "AppKit/GSFontInfo.h"
|
||||
|
||||
@interface WIN32FontEnumerator : GSFontEnumerator
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
#endif/* _WIN32FontEnumerator_h_INCLUDE */
|
41
Headers/winlib/WIN32FontInfo.h
Normal file
41
Headers/winlib/WIN32FontInfo.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* Win32FontInfo - Implements font enumerator for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32FontInfo_h_INCLUDE
|
||||
#define _WIN32FontInfo_h_INCLUDE
|
||||
|
||||
#include "windows.h"
|
||||
#include "AppKit/GSFontInfo.h"
|
||||
|
||||
@interface WIN32FontInfo : GSFontInfo
|
||||
{
|
||||
}
|
||||
|
||||
- (void) draw: (const char*)s lenght: (int)len
|
||||
onDC: (HDC)hdc at: (POINT)p;
|
||||
@end
|
||||
|
||||
#endif/* _WIN32FontInfo_h_INCLUDE */
|
||||
|
||||
|
49
Headers/winlib/WIN32GState.h
Normal file
49
Headers/winlib/WIN32GState.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* WIN32GState - Implements graphic state drawing for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32GState_h_INCLUDE
|
||||
#define _WIN32GState_h_INCLUDE
|
||||
|
||||
#include "gsc/GSGState.h"
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
@interface WIN32GState : GSGState
|
||||
{
|
||||
@public
|
||||
HWND window;
|
||||
COLORREF color;
|
||||
int joinStyle;
|
||||
int lineCap;
|
||||
float lineWidth;
|
||||
float miterlimit;
|
||||
HRGN clipRegion;
|
||||
}
|
||||
|
||||
- (void) setWindow: (HWND)number;
|
||||
- (HWND) window;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* _WIN32GState_h_INCLUDE */
|
52
Source/win32/GNUmakefile
Normal file
52
Source/win32/GNUmakefile
Normal file
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# Main makefile for GNUstep Backend win32
|
||||
#
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Adam Fedor <fedor@gnu.org>
|
||||
#
|
||||
# This file is part of the GNUstep Backend.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# If you are interested in a warranty or support for this source code,
|
||||
# contact Scott Christley at scottc@net-community.com
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../../back.make
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
include ../../config.make
|
||||
|
||||
# The library to be compiled, as a library or as a bundle
|
||||
SUBPROJECT_NAME=win32
|
||||
|
||||
# The C source files to be compiled
|
||||
win32_C_FILES = \
|
||||
|
||||
# The Objective-C source files to be compiled
|
||||
win32_OBJC_FILES = \
|
||||
WIN32Server.m
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/subproject.make
|
||||
|
||||
-include GNUmakefile.postamble
|
51
Source/win32/GNUmakefile.preamble
Normal file
51
Source/win32/GNUmakefile.preamble
Normal file
|
@ -0,0 +1,51 @@
|
|||
|
||||
# GNUmakefile.preamble
|
||||
#
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Adam Fedor <fedor@gnu.org>
|
||||
#
|
||||
# This file is part of the GNUstep Backend.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#
|
||||
# Flags dealing with compiling and linking
|
||||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
GNUSTEP_INSTALL_LIBDIR=$(GNUSTEP_LIBRARIES_ROOT)
|
||||
ADDITIONAL_CPPFLAGS += -Wall $(CONFIG_SYSTEM_DEFS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS =
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
ADDITIONAL_CFLAGS =
|
||||
|
||||
# Additional include directories the compiler should search
|
||||
ADDITIONAL_INCLUDE_DIRS += -I../../Headers \
|
||||
-I../$(GNUSTEP_TARGET_DIR) $(GRAPHIC_CFLAGS)
|
||||
|
||||
# Additional LDFLAGS to pass to the linker
|
||||
ADDITIONAL_LDFLAGS =
|
||||
|
||||
# Additional library directories the linker should search
|
||||
ADDITIONAL_LIB_DIRS =
|
||||
|
||||
#
|
||||
# Flags dealing with installing and uninstalling
|
||||
#
|
1440
Source/win32/WIN32Server.m
Normal file
1440
Source/win32/WIN32Server.m
Normal file
File diff suppressed because it is too large
Load diff
52
Source/winlib/GNUmakefile
Normal file
52
Source/winlib/GNUmakefile
Normal file
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# Main makefile for GNUstep WIN32 GUI Backend
|
||||
#
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Fred Kiefer <FredKiefer@gmx.de>
|
||||
#
|
||||
# This file is part of the GNUstep WIN32 GUI Backend.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../../back.make
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
include ../../config.make
|
||||
|
||||
SUBPROJECT_NAME=winlib
|
||||
|
||||
# The C source files to be compiled
|
||||
winlib_C_FILES =
|
||||
|
||||
# The Objective-C source files to be compiled
|
||||
winlib_OBJC_FILES = \
|
||||
WIN32Context.m \
|
||||
WIN32GState.m \
|
||||
WIN32FontEnumerator.m \
|
||||
WIN32FontInfo.m
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
-include GNUmakefile.local
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/subproject.make
|
||||
|
||||
-include GNUmakefile.postamble
|
63
Source/winlib/GNUmakefile.preamble
Normal file
63
Source/winlib/GNUmakefile.preamble
Normal file
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# Makefile.preamble
|
||||
#
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Fred Kiefer <FredKiefer@gmx.de>
|
||||
#
|
||||
# This file is part of the GNUstep WIN32 GUI Backend.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#
|
||||
# GNUmakefile.preamble
|
||||
#
|
||||
# Project specific makefile variables
|
||||
#
|
||||
# Do not put any GNUMakefile rules in this file, instead they should
|
||||
# be put into GNUmakefile.postamble.
|
||||
#
|
||||
|
||||
#
|
||||
# Flags dealing with compiling and linking
|
||||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
GNUSTEP_INSTALL_LIBDIR=$(GNUSTEP_LIBRARIES_ROOT)
|
||||
ADDITIONAL_CPPFLAGS += -Wall $(CONFIG_SYSTEM_DEFS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
#ADDITIONAL_OBJCFLAGS =
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
#ADDITIONAL_CFLAGS =
|
||||
|
||||
# Additional include directories the compiler should search
|
||||
ADDITIONAL_INCLUDE_DIRS = -I../../Headers \
|
||||
-I$(GNUSTEP_TARGET_DIR) $(GRAPHIC_CFLAGS)
|
||||
|
||||
# Additional LDFLAGS to pass to the linker
|
||||
# ADDITIONAL_LDFLAGS =
|
||||
|
||||
# Additional library directories the linker should search
|
||||
# ADDITIONAL_LIB_DIRS =
|
||||
|
||||
#
|
||||
# Flags dealing with installing and uninstalling
|
||||
#
|
||||
|
||||
# Additional directories to be created during installation
|
||||
# ADDITIONAL_INSTALL_DIRS =
|
88
Source/winlib/WIN32Context.m
Normal file
88
Source/winlib/WIN32Context.m
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* WIN32Context - Implements graphic context for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
#include "winlib/WIN32GState.h"
|
||||
#include "winlib/WIN32FontEnumerator.h"
|
||||
#include "winlib/WIN32FontInfo.h"
|
||||
#include "winlib/WIN32Context.h"
|
||||
|
||||
/* Common graphics functions */
|
||||
@implementation WIN32Context
|
||||
|
||||
/* Initialize AppKit backend */
|
||||
+ (void)initializeBackend
|
||||
{
|
||||
NSDebugLog(@"Initializing GNUstep GUI Win32 backend.\n");
|
||||
|
||||
[NSGraphicsContext setDefaultContextClass: [WIN32Context class]];
|
||||
[GSFontEnumerator setDefaultClass: [WIN32FontEnumerator class]];
|
||||
[GSFontInfo setDefaultClass: [WIN32FontInfo class]];
|
||||
}
|
||||
|
||||
- (id) initWithContextInfo: (NSDictionary *)info
|
||||
{
|
||||
[super initWithContextInfo: info];
|
||||
|
||||
/* Create a default gstate */
|
||||
gstate = [[WIN32GState allocWithZone: [self zone]] initWithDrawContext: self];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)flushGraphics
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WIN32Context (Ops)
|
||||
|
||||
- (void) GSCurrentDevice: (void **)device : (int *)x : (int *)y
|
||||
{
|
||||
void *windevice = [(WIN32GState *)gstate window];
|
||||
if (device)
|
||||
*device = windevice;
|
||||
if (x && y)
|
||||
{
|
||||
NSPoint offset = [gstate offset];
|
||||
*x = offset.x;
|
||||
*y = offset.y;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) GSSetDevice: (void *)device : (int)x : (int)y
|
||||
{
|
||||
[(WIN32GState*)gstate setWindow: (HWND)device];
|
||||
[gstate setOffset: NSMakePoint(x, y)];
|
||||
}
|
||||
|
||||
- (void) NSBeep
|
||||
{
|
||||
Beep(400, 500);
|
||||
}
|
||||
|
||||
@end
|
80
Source/winlib/WIN32FontEnumerator.m
Normal file
80
Source/winlib/WIN32FontEnumerator.m
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* Win32FontEnumerator - Implements font enumerator for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
|
||||
#include "winlib/WIN32FontEnumerator.h"
|
||||
|
||||
@implementation WIN32FontEnumerator
|
||||
|
||||
- (void) enumerateFontsAndFamilies
|
||||
{
|
||||
/*
|
||||
int CALLBACK EnumFontFamProc(
|
||||
ENUMLOGFONT *lpelf, // logical-font data
|
||||
NEWTEXTMETRIC *lpntm, // physical-font data
|
||||
DWORD FontType, // type of font
|
||||
LPARAM lParam // application-defined data
|
||||
);
|
||||
|
||||
EnumFontFamilies(hdc, (LPCTSTR) NULL,
|
||||
(FONTENUMPROC) EnumFamCallBack, (LPARAM) aFontCount);
|
||||
|
||||
if (cache == nil)
|
||||
{
|
||||
if (load_cache(cache_name(), NO))
|
||||
{
|
||||
allFontNames = [[cache objectForKey: @"AllFontNames"] allObjects];
|
||||
allFontFamilies = [cache objectForKey: @"AllFontFamilies"];
|
||||
// This dictionary stores the XLFD for each font
|
||||
creationDictionary = [cache objectForKey: @"CreationDictionary"];
|
||||
}
|
||||
}
|
||||
*/
|
||||
static BOOL done = NO;
|
||||
|
||||
if (!done)
|
||||
{
|
||||
NSArray *fontDef;
|
||||
NSMutableArray *fontDefs;
|
||||
|
||||
ASSIGN(allFontNames, [NSArray arrayWithObject: @"Helvetica"]);
|
||||
allFontFamilies = [[NSMutableDictionary alloc] init];
|
||||
|
||||
fontDefs = [NSMutableArray arrayWithCapacity: 10];
|
||||
[allFontFamilies setObject: fontDefs forKey: @"Helvetica"];
|
||||
|
||||
|
||||
fontDef = [NSArray arrayWithObjects: @"Helvetica", @"",
|
||||
[NSNumber numberWithInt: 6],
|
||||
[NSNumber numberWithUnsignedInt: 0], nil];
|
||||
[fontDefs addObject: fontDef];
|
||||
|
||||
done = YES;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
174
Source/winlib/WIN32FontInfo.m
Normal file
174
Source/winlib/WIN32FontInfo.m
Normal file
|
@ -0,0 +1,174 @@
|
|||
/* Win32FontInfo - Implements font enumerator for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
|
||||
#include "winlib/WIN32FontInfo.h"
|
||||
|
||||
@interface WIN32FontInfo (Private)
|
||||
- (BOOL) setupAttributes;
|
||||
@end
|
||||
|
||||
@implementation WIN32FontInfo
|
||||
|
||||
- initWithFontName: (NSString*)name matrix: (const float *)fmatrix
|
||||
{
|
||||
[super init];
|
||||
ASSIGN(fontName, name);
|
||||
memcpy(matrix, fmatrix, sizeof(matrix));
|
||||
|
||||
if (![self setupAttributes])
|
||||
{
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (float) widthOf: (const char*) s lenght: (int) len
|
||||
{
|
||||
SIZE size;
|
||||
HDC hdc;
|
||||
|
||||
hdc = GetDC(NULL);
|
||||
GetTextExtentPoint32(hdc, s, len, &size);
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
return size.cx;
|
||||
}
|
||||
|
||||
- (float) widthOfString: (NSString*)string
|
||||
{
|
||||
const char *s;
|
||||
int len;
|
||||
|
||||
s = [string cString];
|
||||
len = strlen(s);
|
||||
|
||||
return [self widthOf: s lenght: len];
|
||||
}
|
||||
|
||||
- (NSMultibyteGlyphPacking)glyphPacking
|
||||
{
|
||||
return NSOneByteGlyphPacking;
|
||||
}
|
||||
|
||||
- (NSSize) advancementForGlyph: (NSGlyph)glyph
|
||||
{
|
||||
HDC hdc;
|
||||
float w;
|
||||
ABCFLOAT abc;
|
||||
|
||||
hdc = GetDC(NULL);
|
||||
//GetCharWidthFloat(hdc, glyph, glyph, &w);
|
||||
GetCharABCWidthsFloat(hdc, glyph, glyph, &abc);
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
//NSLog(@"Width for %d is %f or %f", glyph, w, (abc.abcfA + abc.abcfB + abc.abcfC));
|
||||
w = abc.abcfA + abc.abcfB + abc.abcfC;
|
||||
return NSMakeSize(w, 0);
|
||||
}
|
||||
|
||||
- (NSRect) boundingRectForGlyph: (NSGlyph)glyph
|
||||
{
|
||||
return NSMakeRect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
- (BOOL) glyphIsEncoded: (NSGlyph)glyph
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSGlyph) glyphWithName: (NSString*)glyphName
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSPoint) positionOfGlyph: (NSGlyph)curGlyph
|
||||
precededByGlyph: (NSGlyph)prevGlyph
|
||||
isNominal: (BOOL*)nominal
|
||||
{
|
||||
return NSMakePoint(0, 0);
|
||||
}
|
||||
|
||||
- (void) drawString: (NSString*)string
|
||||
onDC: (HDC)hdc at: (POINT)p
|
||||
{
|
||||
}
|
||||
|
||||
- (void) draw:(const char*)s lenght: (int)len
|
||||
onDC: (HDC)hdc at: (POINT)p
|
||||
{
|
||||
TextOut(hdc, p.x, p.y - ascender, s, len);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WIN32FontInfo (Private)
|
||||
|
||||
- (BOOL) setupAttributes
|
||||
{
|
||||
HDC hdc;
|
||||
TEXTMETRIC metric;
|
||||
|
||||
hdc = GetDC(NULL);
|
||||
GetTextMetrics(hdc, &metric);
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
// Fill the afmDitionary and ivars
|
||||
[fontDictionary setObject: fontName forKey: NSAFMFontName];
|
||||
//ASSIGN(familyName, XGFontFamily(xdpy, font_info));
|
||||
//[fontDictionary setObject: familyName forKey: NSAFMFamilyName];
|
||||
isFixedPitch = TMPF_FIXED_PITCH & metric.tmPitchAndFamily;
|
||||
isBaseFont = NO;
|
||||
ascender = metric.tmAscent;
|
||||
[fontDictionary setObject: [NSNumber numberWithFloat: ascender]
|
||||
forKey: NSAFMAscender];
|
||||
descender = -metric.tmDescent;
|
||||
[fontDictionary setObject: [NSNumber numberWithFloat: descender]
|
||||
forKey: NSAFMDescender];
|
||||
|
||||
fontBBox = NSMakeRect((float)(0),
|
||||
(float)(0 - metric.tmAscent),
|
||||
(float)metric.tmMaxCharWidth,
|
||||
(float)metric.tmHeight);
|
||||
|
||||
// Should come from metric.tmCharSet
|
||||
mostCompatibleStringEncoding = NSISOLatin1StringEncoding;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
796
Source/winlib/WIN32GState.m
Normal file
796
Source/winlib/WIN32GState.m
Normal file
|
@ -0,0 +1,796 @@
|
|||
/* WIN32GState - Implements graphic state drawing for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: <author name="Fred Kiefer><email>FredKiefer@gmx.de</email></author>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <AppKit/NSAffineTransform.h>
|
||||
#include <AppKit/NSBezierPath.h>
|
||||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
|
||||
#include "winlib/WIN32GState.h"
|
||||
#include "winlib/WIN32Context.h"
|
||||
#include "winlib/WIN32FontInfo.h"
|
||||
#include "win32/WIN32Server.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
static inline
|
||||
POINT GSWindowPointToMS(WIN32GState *s, NSPoint p)
|
||||
{
|
||||
POINT p1;
|
||||
RECT rect;
|
||||
int h;
|
||||
|
||||
GetClientRect((HWND)[s window], &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
p.x += s->offset.x;
|
||||
p.y += s->offset.y;
|
||||
p1.x = p.x;
|
||||
p1.y = h -p.y;
|
||||
|
||||
return p1;
|
||||
}
|
||||
|
||||
static inline
|
||||
RECT GSWindowRectToMS(WIN32GState *s, NSRect r)
|
||||
{
|
||||
RECT r1;
|
||||
RECT rect;
|
||||
int h;
|
||||
|
||||
GetClientRect((HWND)[s window], &rect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
r.origin.x += s->offset.x;
|
||||
r.origin.y += s->offset.y;
|
||||
|
||||
r1.left = r.origin.x;
|
||||
r1.right = r.origin.x + r.size.width;
|
||||
r1.bottom = h - r.origin.y;
|
||||
r1.top = h - r.origin.y - r.size.height;
|
||||
|
||||
return r1;
|
||||
}
|
||||
|
||||
static inline
|
||||
POINT GSViewPointToWin(WIN32GState *s, NSPoint p)
|
||||
{
|
||||
p = [s->ctm pointInMatrixSpace: p];
|
||||
return GSWindowPointToMS(s, p);
|
||||
}
|
||||
|
||||
static inline
|
||||
RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||
{
|
||||
r = [s->ctm rectInMatrixSpace: r];
|
||||
return GSWindowRectToMS(s, r);
|
||||
}
|
||||
|
||||
@interface WIN32GState (WinOps)
|
||||
- (void) setStyle: (HDC)hdc;
|
||||
- (HDC) getHDC;
|
||||
- (void) releaseHDC: (HDC)hdc;
|
||||
@end
|
||||
|
||||
@implementation WIN32GState
|
||||
|
||||
- (void) setWindow: (HWND)number
|
||||
{
|
||||
window = (HWND)number;
|
||||
}
|
||||
|
||||
- (HWND) window
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
- (void) copyBits: (WIN32GState*)source fromRect: (NSRect)aRect
|
||||
toPoint: (NSPoint)aPoint
|
||||
{
|
||||
HDC otherDC;
|
||||
HDC hdc;
|
||||
POINT p;
|
||||
RECT rect;
|
||||
WINBOOL result;
|
||||
int h;
|
||||
int y1;
|
||||
|
||||
//NSLog(@"Orig Copy Bits to %f, %f from %@", aPoint.x, aPoint.y, NSStringFromRect(aRect));
|
||||
p = GSViewPointToWin(self, aPoint);
|
||||
rect = GSViewRectToWin(source, aRect);
|
||||
h = rect.bottom - rect.top;
|
||||
|
||||
if (viewIsFlipped)
|
||||
y1 = p.y;
|
||||
else
|
||||
y1 = p.y - h;
|
||||
|
||||
otherDC = [source getHDC];
|
||||
hdc = [self getHDC];
|
||||
|
||||
//NSLog(@"Copy Bits to %d %d from %d %d size %d %d", p.x , y1, rect.left, rect.top,
|
||||
// (rect.right - rect.left), h);
|
||||
result = BitBlt(hdc, p.x, y1, (rect.right - rect.left), h,
|
||||
otherDC, rect.left, rect.top, SRCCOPY);
|
||||
if (!result)
|
||||
NSLog(@"Copy bitmap failed %d", GetLastError());
|
||||
[source releaseHDC: otherDC];
|
||||
[self releaseHDC: hdc];
|
||||
}
|
||||
|
||||
- (void) compositeGState: (GSGState *)source
|
||||
fromRect: (NSRect)aRect
|
||||
toPoint: (NSPoint)aPoint
|
||||
op: (NSCompositingOperation)op
|
||||
{
|
||||
// FIXME
|
||||
[self copyBits: (WIN32GState *)source fromRect: aRect toPoint: aPoint];
|
||||
}
|
||||
|
||||
- (void) dissolveGState: (GSGState *)source
|
||||
fromRect: (NSRect)aRect
|
||||
toPoint: (NSPoint)aPoint
|
||||
delta: (float)delta
|
||||
{
|
||||
// FIXME
|
||||
[self copyBits: (WIN32GState *)source fromRect: aRect toPoint: aPoint];
|
||||
}
|
||||
|
||||
- (void) compositerect: (NSRect)aRect
|
||||
op: (NSCompositingOperation)op
|
||||
{
|
||||
HDC hdc;
|
||||
float gray;
|
||||
RECT rect = GSViewRectToWin(self, aRect);
|
||||
|
||||
[self DPScurrentgray: &gray];
|
||||
if (fabs(gray - 0.667) < 0.005)
|
||||
[self DPSsetgray: 0.333];
|
||||
else
|
||||
[self DPSsetrgbcolor: 0.121 : 0.121 : 0];
|
||||
|
||||
hdc = [self getHDC];
|
||||
switch (op)
|
||||
{
|
||||
case NSCompositeClear:
|
||||
break;
|
||||
case NSCompositeHighlight:
|
||||
InvertRect(hdc, &rect);
|
||||
break;
|
||||
case NSCompositeCopy:
|
||||
// FIXME
|
||||
case NSCompositeSourceOver:
|
||||
case NSCompositeSourceIn:
|
||||
case NSCompositeSourceOut:
|
||||
case NSCompositeSourceAtop:
|
||||
case NSCompositeDestinationOver:
|
||||
case NSCompositeDestinationIn:
|
||||
case NSCompositeDestinationOut:
|
||||
case NSCompositeDestinationAtop:
|
||||
case NSCompositeXOR:
|
||||
case NSCompositePlusDarker:
|
||||
case NSCompositePlusLighter:
|
||||
default:
|
||||
[self DPSrectfill: NSMinX(aRect) : NSMinY(aRect)
|
||||
: NSWidth(aRect) : NSHeight(aRect)];
|
||||
break;
|
||||
}
|
||||
[self releaseHDC: hdc];
|
||||
}
|
||||
|
||||
- (void)DPSimage: (NSAffineTransform*) matrix
|
||||
: (int) pixelsWide : (int) pixelsHigh
|
||||
: (int) bitsPerSample : (int) samplesPerPixel
|
||||
: (int) bitsPerPixel : (int) bytesPerRow : (BOOL) isPlanar
|
||||
: (BOOL) hasAlpha : (NSString *) colorSpaceName
|
||||
: (const unsigned char *const [5]) data
|
||||
{
|
||||
NSRect rect;
|
||||
NSAffineTransform *old_ctm = nil;
|
||||
HDC hdc;
|
||||
|
||||
rect = NSZeroRect;
|
||||
rect.size.width = (float) pixelsWide;
|
||||
rect.size.height = (float) pixelsHigh;
|
||||
|
||||
// default is 8 bit grayscale
|
||||
if (!bitsPerSample)
|
||||
bitsPerSample = 8;
|
||||
if (!samplesPerPixel)
|
||||
samplesPerPixel = 1;
|
||||
|
||||
// FIXME - does this work if we are passed a planar image but no hints ?
|
||||
if (!bitsPerPixel)
|
||||
bitsPerPixel = bitsPerSample * samplesPerPixel;
|
||||
if (!bytesPerRow)
|
||||
bytesPerRow = (bitsPerPixel * pixelsWide) / 8;
|
||||
|
||||
/* make sure its sane - also handles row padding if hint missing */
|
||||
while((bytesPerRow * 8) < (bitsPerPixel * pixelsWide))
|
||||
bytesPerRow++;
|
||||
|
||||
// Apply the additional transformation
|
||||
if (matrix)
|
||||
{
|
||||
old_ctm = [ctm copy];
|
||||
[ctm appendTransform: matrix];
|
||||
}
|
||||
|
||||
if (!isPlanar && [colorSpaceName isEqualToString: NSDeviceRGBColorSpace])
|
||||
{
|
||||
HBITMAP hbitmap;
|
||||
BITMAP bitmap;
|
||||
HDC hdc2;
|
||||
POINT p;
|
||||
int h;
|
||||
int y1;
|
||||
|
||||
p = GSViewPointToWin(self, NSMakePoint(0, 0));
|
||||
bitmap.bmType = 0;
|
||||
bitmap.bmWidth = pixelsWide;
|
||||
bitmap.bmHeight = pixelsHigh;
|
||||
bitmap.bmWidthBytes = bytesPerRow;
|
||||
bitmap.bmPlanes = 1;
|
||||
bitmap.bmBitsPixel = bitsPerPixel;
|
||||
bitmap.bmBits = (LPVOID)data;
|
||||
|
||||
h = pixelsHigh;
|
||||
//NSLog(@"DPSimage with %d %d %d %d to %d, %d", pixelsWide, pixelsHigh,
|
||||
// bytesPerRow, bitsPerPixel, p.x, p.y - h);
|
||||
hbitmap = CreateBitmapIndirect(&bitmap);
|
||||
if (!hbitmap)
|
||||
NSLog(@"Created bitmap failed %d", GetLastError());
|
||||
|
||||
hdc = GetDC((HWND)window);
|
||||
hdc2 = CreateCompatibleDC(hdc);
|
||||
SelectObject(hdc2, hbitmap);
|
||||
//SetMapMode(hdc2, GetMapMode(hdc));
|
||||
ReleaseDC((HWND)window, hdc);
|
||||
|
||||
hdc = [self getHDC];
|
||||
if (viewIsFlipped)
|
||||
y1 = p.y;
|
||||
else
|
||||
y1 = p.y - h;
|
||||
|
||||
if (!BitBlt(hdc, p.x, y1, pixelsWide, pixelsHigh,
|
||||
hdc2, 0, 0, SRCCOPY))
|
||||
NSLog(@"Copy bitmap failed %d", GetLastError());
|
||||
|
||||
DeleteDC(hdc2);
|
||||
DeleteObject(hbitmap);
|
||||
|
||||
[self releaseHDC: hdc];
|
||||
}
|
||||
|
||||
if (old_ctm != nil)
|
||||
{
|
||||
RELEASE(ctm);
|
||||
// old_ctm is already retained
|
||||
ctm = old_ctm;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WIN32GState (ColorOps)
|
||||
|
||||
- (void)DPScurrentrgbcolor: (float *)r : (float *)g : (float *)b
|
||||
{
|
||||
*r = GetRValue(color) / 255;
|
||||
*g = GetGValue(color) / 255;
|
||||
*b = GetBValue(color) / 255;
|
||||
}
|
||||
|
||||
- (void)DPSsetrgbcolor: (float)r : (float)g : (float)b
|
||||
{
|
||||
color = RGB(r*255, g*255, b*255);
|
||||
|
||||
// Use in pen and brush!!
|
||||
}
|
||||
|
||||
- (void)DPScurrentcmykcolor: (float *)c : (float *)m : (float *)y : (float *)k
|
||||
{
|
||||
float alpha;
|
||||
float r, g, b;
|
||||
NSColor *c1, *c2;
|
||||
|
||||
[self DPScurrentrgbcolor: &r : &g : &b];
|
||||
|
||||
c1 = [NSColor colorWithDeviceRed: r green: g
|
||||
blue: b alpha: 1.0];
|
||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceCMYKColorSpace];
|
||||
[c2 getCyan: c magenta: m
|
||||
yellow: y black: k
|
||||
alpha: &alpha];
|
||||
}
|
||||
|
||||
- (void)DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
|
||||
{
|
||||
NSColor *c1, *c2;
|
||||
|
||||
c1 = [NSColor colorWithDeviceCyan: c
|
||||
magenta: m
|
||||
yellow: y
|
||||
black: k
|
||||
alpha: 1.0];
|
||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
||||
[self DPSsetrgbcolor: [c2 redComponent] : [c2 greenComponent] :
|
||||
[c2 blueComponent]];
|
||||
}
|
||||
|
||||
- (void)DPScurrentgray: (float *)gray
|
||||
{
|
||||
float r, g, b;
|
||||
NSColor *c1, *c2;
|
||||
|
||||
[self DPScurrentrgbcolor: &r : &g : &b];
|
||||
|
||||
c1 = [NSColor colorWithDeviceRed: r
|
||||
green: g
|
||||
blue: b
|
||||
alpha: 1.0];
|
||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceWhiteColorSpace];
|
||||
// Or 1.0 - x ???
|
||||
*gray = [c2 whiteComponent];
|
||||
}
|
||||
|
||||
- (void)DPSsetgray: (float)gray
|
||||
{
|
||||
NSColor *c1, *c2;
|
||||
|
||||
// Or 1.0 - x ???
|
||||
c1 = [NSColor colorWithDeviceWhite: gray
|
||||
alpha: 1.0];
|
||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
||||
[self DPSsetrgbcolor: [c2 redComponent] : [c2 greenComponent] :
|
||||
[c2 blueComponent]];
|
||||
}
|
||||
|
||||
- (void)DPScurrenthsbcolor: (float *)h : (float *)s : (float *)b
|
||||
{
|
||||
float alpha;
|
||||
float r, g, bl;
|
||||
NSColor *c1;
|
||||
|
||||
[self DPScurrentrgbcolor: &r : &g : &bl];
|
||||
|
||||
c1 = [NSColor colorWithDeviceRed: r
|
||||
green: g
|
||||
blue: bl
|
||||
alpha: 1.0];
|
||||
[c1 getHue: h saturation: s
|
||||
brightness: b alpha: &alpha];
|
||||
}
|
||||
|
||||
- (void)DPSsethsbcolor: (float)h : (float)s : (float)b
|
||||
{
|
||||
NSColor *c1, *c2;
|
||||
|
||||
c1 = [NSColor colorWithDeviceHue: h
|
||||
saturation: s
|
||||
brightness: b
|
||||
alpha: 1.0];
|
||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
||||
[self DPSsetrgbcolor: [c2 redComponent] : [c2 greenComponent] :
|
||||
[c2 blueComponent]];
|
||||
}
|
||||
|
||||
- (void) DPSsetalpha: (float)a
|
||||
{
|
||||
}
|
||||
|
||||
- (void) DPScurrentalpha: (float *)alpha
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WIN32GState (PathOps)
|
||||
|
||||
- (void) _paintPath: (ctxt_object_t) drawType
|
||||
{
|
||||
unsigned count;
|
||||
HDC hdc;
|
||||
|
||||
hdc = [self getHDC];
|
||||
|
||||
count = [path elementCount];
|
||||
if (count)
|
||||
{
|
||||
NSBezierPathElement type;
|
||||
NSPoint points[3];
|
||||
unsigned j, i = 0;
|
||||
POINT p;
|
||||
|
||||
BeginPath(hdc);
|
||||
|
||||
for(j = 0; j < count; j++)
|
||||
{
|
||||
type = [path elementAtIndex: j associatedPoints: points];
|
||||
switch(type)
|
||||
{
|
||||
case NSMoveToBezierPathElement:
|
||||
p = GSWindowPointToMS(self, points[0]);
|
||||
MoveToEx(hdc, p.x, p.y, NULL);
|
||||
break;
|
||||
case NSLineToBezierPathElement:
|
||||
p = GSWindowPointToMS(self, points[0]);
|
||||
// FIXME This gives one pixel to few
|
||||
LineTo(hdc, p.x, p.y);
|
||||
break;
|
||||
case NSCurveToBezierPathElement:
|
||||
{
|
||||
POINT bp[3];
|
||||
|
||||
for (i = 1; i < 3; i++)
|
||||
{
|
||||
bp[i] = GSWindowPointToMS(self, points[i]);
|
||||
}
|
||||
PolyBezierTo(hdc, bp, 3);
|
||||
}
|
||||
break;
|
||||
case NSClosePathBezierPathElement:
|
||||
CloseFigure(hdc);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
EndPath(hdc);
|
||||
|
||||
// Now operate on the path
|
||||
switch (drawType)
|
||||
{
|
||||
case path_stroke:
|
||||
StrokePath(hdc);
|
||||
break;
|
||||
case path_eofill:
|
||||
SetPolyFillMode(hdc, ALTERNATE);
|
||||
FillPath(hdc);
|
||||
break;
|
||||
case path_fill:
|
||||
SetPolyFillMode(hdc, WINDING);
|
||||
FillPath(hdc);
|
||||
break;
|
||||
case path_eoclip:
|
||||
{
|
||||
HRGN region;
|
||||
|
||||
SetPolyFillMode(hdc, ALTERNATE);
|
||||
region = PathToRegion(hdc);
|
||||
ExtSelectClipRgn(hdc, region, RGN_COPY);
|
||||
clipRegion = region;
|
||||
break;
|
||||
}
|
||||
case path_clip:
|
||||
{
|
||||
HRGN region;
|
||||
|
||||
SetPolyFillMode(hdc, WINDING);
|
||||
region = PathToRegion(hdc);
|
||||
ExtSelectClipRgn(hdc, region, RGN_COPY);
|
||||
clipRegion = region;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
[self releaseHDC: hdc];
|
||||
|
||||
/*
|
||||
* clip does not delete the current path, so we only clear the path if the
|
||||
* operation was not a clipping operation.
|
||||
*/
|
||||
if ((drawType != path_clip) && (drawType != path_eoclip))
|
||||
{
|
||||
[path removeAllPoints];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)DPSclip
|
||||
{
|
||||
[self _paintPath: path_clip];
|
||||
}
|
||||
|
||||
- (void)DPSeoclip
|
||||
{
|
||||
[self _paintPath: path_eoclip];
|
||||
}
|
||||
|
||||
- (void)DPSeofill
|
||||
{
|
||||
[self _paintPath: path_eofill];
|
||||
}
|
||||
|
||||
- (void)DPSfill
|
||||
{
|
||||
[self _paintPath: path_fill];
|
||||
}
|
||||
|
||||
- (void)DPSstroke
|
||||
{
|
||||
[self _paintPath: path_stroke];
|
||||
}
|
||||
|
||||
|
||||
- (void) DPSinitclip;
|
||||
{
|
||||
HDC hdc;
|
||||
|
||||
hdc = [self getHDC];
|
||||
SelectClipRgn(hdc, NULL);
|
||||
clipRegion = NULL;
|
||||
[self releaseHDC: hdc];
|
||||
}
|
||||
|
||||
- (void)DPSrectfill: (float)x : (float)y : (float)w : (float)h
|
||||
{
|
||||
NSPoint origin = [ctm pointInMatrixSpace: NSMakePoint(x, y)];
|
||||
NSSize size = [ctm sizeInMatrixSpace: NSMakeSize(w, h)];
|
||||
|
||||
if (viewIsFlipped)
|
||||
origin.y -= size.height;
|
||||
ASSIGN(path, [NSBezierPath bezierPathWithRect:
|
||||
NSMakeRect(origin.x, origin.y,
|
||||
size.width, size.height)]);
|
||||
//NSLog(@"Fill rect %@", NSStringFromRect(NSMakeRect(origin.x, origin.y,
|
||||
// size.width, size.height)));
|
||||
[self DPSfill];
|
||||
}
|
||||
|
||||
- (void)DPSrectstroke: (float)x : (float)y : (float)w : (float)h
|
||||
{
|
||||
NSPoint origin = [ctm pointInMatrixSpace: NSMakePoint(x, y)];
|
||||
NSSize size = [ctm sizeInMatrixSpace: NSMakeSize(w, h)];
|
||||
|
||||
if (size.width > 0)
|
||||
size.width--;
|
||||
if (size.height > 0)
|
||||
size.height--;
|
||||
if (viewIsFlipped)
|
||||
origin.y -= size.height;
|
||||
else
|
||||
origin.y += 1;
|
||||
|
||||
ASSIGN(path, [NSBezierPath bezierPathWithRect:
|
||||
NSMakeRect(origin.x, origin.y,
|
||||
size.width, size.height)]);
|
||||
//NSLog(@"Stroke rect %@", NSStringFromRect(NSMakeRect(origin.x, origin.y,
|
||||
// size.width, size.height)));
|
||||
[self DPSstroke];
|
||||
}
|
||||
|
||||
- (void)DPSrectclip: (float)x : (float)y : (float)w : (float)h
|
||||
{
|
||||
NSPoint origin = [ctm pointInMatrixSpace: NSMakePoint(x, y)];
|
||||
NSSize size = [ctm sizeInMatrixSpace: NSMakeSize(w, h)];
|
||||
|
||||
if (viewIsFlipped)
|
||||
origin.y -= size.height;
|
||||
ASSIGN(path, [NSBezierPath bezierPathWithRect:
|
||||
NSMakeRect(origin.x, origin.y,
|
||||
size.width, size.height)]);
|
||||
//NSLog(@"Clip rect %@", NSStringFromRect(NSMakeRect(origin.x, origin.y,
|
||||
// size.width, size.height)));
|
||||
[self DPSclip];
|
||||
}
|
||||
|
||||
- (void)DPSshow: (const char *)s
|
||||
{
|
||||
NSPoint current = [path currentPoint];
|
||||
POINT p;
|
||||
HDC hdc;
|
||||
//float ascent = [font ascender];
|
||||
|
||||
p = GSWindowPointToMS(self, current);
|
||||
hdc = [self getHDC];
|
||||
[(WIN32FontInfo*)[font fontInfo] draw: s lenght: strlen(s)
|
||||
onDC: hdc at: p];
|
||||
//TextOut(hdc, p.x, p.y - ascent, s, strlen(s));
|
||||
[self releaseHDC: hdc];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation WIN32GState (GStateOps)
|
||||
|
||||
- (void)DPSinitgraphics
|
||||
{
|
||||
[ctm makeIdentityMatrix];
|
||||
DESTROY(path);
|
||||
|
||||
color = RGB(0*255, 0*255, 0*255);
|
||||
}
|
||||
|
||||
- (void) DPSsetdash: (const float*)pattern : (int)count : (float)phase
|
||||
{
|
||||
if (!path)
|
||||
{
|
||||
path = [NSBezierPath new];
|
||||
}
|
||||
|
||||
[path setLineDash: pattern count: count phase: phase];
|
||||
}
|
||||
|
||||
- (void)DPScurrentmiterlimit: (float *)limit
|
||||
{
|
||||
*limit = miterlimit;
|
||||
}
|
||||
|
||||
- (void)DPSsetmiterlimit: (float)limit
|
||||
{
|
||||
miterlimit = limit;
|
||||
}
|
||||
|
||||
- (void)DPScurrentlinecap: (int *)linecap
|
||||
{
|
||||
*linecap = lineCap;
|
||||
}
|
||||
|
||||
- (void)DPSsetlinecap: (int)linecap
|
||||
{
|
||||
lineCap = linecap;
|
||||
}
|
||||
|
||||
- (void)DPScurrentlinejoin: (int *)linejoin
|
||||
{
|
||||
*linejoin = joinStyle;
|
||||
}
|
||||
|
||||
- (void)DPSsetlinejoin: (int)linejoin
|
||||
{
|
||||
joinStyle = linejoin;
|
||||
}
|
||||
|
||||
- (void)DPScurrentlinewidth: (float *)width
|
||||
{
|
||||
*width = lineWidth;
|
||||
}
|
||||
|
||||
- (void)DPSsetlinewidth: (float)width
|
||||
{
|
||||
lineWidth = width;
|
||||
}
|
||||
|
||||
- (void)DPScurrentstrokeadjust: (int *)b
|
||||
{
|
||||
}
|
||||
|
||||
- (void)DPSsetstrokeadjust: (int)b
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WIN32GState (WinOps)
|
||||
|
||||
- (void) setStyle: (HDC)hdc
|
||||
{
|
||||
HANDLE old;
|
||||
HPEN pen;
|
||||
HBRUSH brush;
|
||||
LOGBRUSH br;
|
||||
int join;
|
||||
int cap;
|
||||
DWORD penStyle;
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
/*
|
||||
br.lbStyle = BS_SOLID;
|
||||
br.lbColor = color;
|
||||
brush = CreateBrushIndirect(&br);
|
||||
*/
|
||||
brush = CreateSolidBrush(color);
|
||||
old = SelectObject(hdc, brush);
|
||||
DeleteObject(old);
|
||||
|
||||
switch (joinStyle)
|
||||
{
|
||||
case NSBevelLineJoinStyle:
|
||||
join = PS_JOIN_BEVEL;
|
||||
break;
|
||||
case NSMiterLineJoinStyle:
|
||||
join = PS_JOIN_MITER;
|
||||
break;
|
||||
case NSRoundLineJoinStyle:
|
||||
join = PS_JOIN_ROUND;
|
||||
break;
|
||||
default:
|
||||
join = PS_JOIN_MITER;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (lineCap)
|
||||
{
|
||||
case NSButtLineCapStyle:
|
||||
cap = PS_ENDCAP_FLAT;
|
||||
break;
|
||||
case NSSquareLineCapStyle:
|
||||
cap = PS_ENDCAP_SQUARE;
|
||||
break;
|
||||
case NSRoundLineCapStyle:
|
||||
cap = PS_ENDCAP_ROUND;
|
||||
break;
|
||||
default:
|
||||
cap = PS_ENDCAP_SQUARE;
|
||||
break;
|
||||
}
|
||||
|
||||
penStyle = PS_GEOMETRIC | PS_SOLID;
|
||||
if (path)
|
||||
{
|
||||
float pattern[10];
|
||||
int count = 10;
|
||||
float phase;
|
||||
|
||||
[path getLineDash: pattern count: &count phase: &phase];
|
||||
|
||||
if (count && (count < 10))
|
||||
{
|
||||
penStyle = PS_GEOMETRIC | PS_DASH;
|
||||
}
|
||||
}
|
||||
|
||||
pen = ExtCreatePen(penStyle | join | cap,
|
||||
lineWidth,
|
||||
&br,
|
||||
0, NULL);
|
||||
|
||||
old = SelectObject(hdc, pen);
|
||||
DeleteObject(old);
|
||||
|
||||
SetMiterLimit(hdc, miterlimit, NULL);
|
||||
|
||||
SetTextColor(hdc, color);
|
||||
SelectClipRgn(hdc, clipRegion);
|
||||
}
|
||||
|
||||
- (HDC) getHDC
|
||||
{
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)window, GWL_USERDATA);
|
||||
HDC hdc;
|
||||
|
||||
if (win && win->useHDC)
|
||||
{
|
||||
hdc = win->hdc;
|
||||
}
|
||||
else
|
||||
{
|
||||
hdc = GetDC((HWND)window);
|
||||
}
|
||||
[self setStyle: hdc];
|
||||
return hdc;
|
||||
}
|
||||
|
||||
- (void) releaseHDC: (HDC)hdc
|
||||
{
|
||||
WIN_INTERN *win;
|
||||
|
||||
win = (WIN_INTERN *)GetWindowLong((HWND)window, GWL_USERDATA);
|
||||
if (win && !win->useHDC)
|
||||
ReleaseDC((HWND)window, hdc);
|
||||
}
|
||||
|
||||
@end
|
28
Tools/gpbs.m
28
Tools/gpbs.m
|
@ -29,6 +29,10 @@
|
|||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __MINGW__
|
||||
#include "process.h"
|
||||
#endif
|
||||
|
||||
@class PasteboardServer;
|
||||
@class PasteboardObject;
|
||||
|
||||
|
@ -1058,10 +1062,18 @@ init(int argc, char** argv)
|
|||
{
|
||||
signal((int)count, ihandler);
|
||||
}
|
||||
#ifdef SIGPIPE
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
#ifdef SIGTTOU
|
||||
signal(SIGTTOU, SIG_IGN);
|
||||
#endif
|
||||
#ifdef SIGTTIN
|
||||
signal(SIGTTIN, SIG_IGN);
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
#endif
|
||||
signal(SIGTERM, ihandler);
|
||||
|
||||
if (debug == 0)
|
||||
|
@ -1069,6 +1081,21 @@ init(int argc, char** argv)
|
|||
/*
|
||||
* Now fork off child process to run in background.
|
||||
*/
|
||||
#ifdef __MINGW__
|
||||
{
|
||||
char **a = malloc((argc+2) * sizeof(char*));
|
||||
|
||||
memcpy(a, argv, argc*sizeof(char*));
|
||||
a[argc] = "--no-fork";
|
||||
a[argc+1] = 0;
|
||||
if (_spawnv(_P_NOWAIT, argv[0], a) == -1)
|
||||
{
|
||||
fprintf(stderr, "gpbs - spawn failed - bye.\n");
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
#else
|
||||
switch (fork())
|
||||
{
|
||||
case -1:
|
||||
|
@ -1093,6 +1120,7 @@ init(int argc, char** argv)
|
|||
}
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue