2002-03-27 23:44:41 +00:00
|
|
|
/* GSBackend - backend initialize class
|
|
|
|
|
|
|
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Adam Fedor <fedor@gnu.org>
|
|
|
|
Date: Mar 2002
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 23:25:10 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2002-03-27 23:44:41 +00:00
|
|
|
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.
|
2007-10-29 23:25:10 +00:00
|
|
|
|
2002-03-27 23:44:41 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 23:25:10 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2002-03-27 23:44:41 +00:00
|
|
|
|
2007-10-29 23:25:10 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2002-03-27 23:44:41 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 23:25:10 +00:00
|
|
|
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.
|
2002-03-27 23:44:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
|
|
|
|
|
|
|
@interface GSBackend : NSObject
|
|
|
|
{
|
|
|
|
}
|
|
|
|
+ (void) initializeBackend;
|
|
|
|
@end
|
|
|
|
|
2002-05-06 17:13:31 +00:00
|
|
|
#if BUILD_SERVER == SERVER_x11
|
2002-03-27 23:44:41 +00:00
|
|
|
#include <x11/XGServer.h>
|
2006-07-04 21:54:48 +00:00
|
|
|
@interface XGServer (Initialize)
|
|
|
|
+ (void) initializeBackend;
|
|
|
|
@end
|
2002-05-06 17:13:31 +00:00
|
|
|
#elif BUILD_SERVER == SERVER_win32
|
2002-04-21 22:46:39 +00:00
|
|
|
#include <win32/WIN32Server.h>
|
2006-07-04 21:54:48 +00:00
|
|
|
@interface WIN32Server (Initialize)
|
|
|
|
+ (void) initializeBackend;
|
|
|
|
@end
|
2002-03-27 23:44:41 +00:00
|
|
|
#endif
|
|
|
|
|
2002-05-06 02:03:29 +00:00
|
|
|
/* Call the correct initalization routines for the choosen
|
|
|
|
backend. This depends both on configuration data and defaults.
|
|
|
|
*/
|
2002-03-27 23:44:41 +00:00
|
|
|
@implementation GSBackend
|
|
|
|
|
|
|
|
+ (void) initializeBackend
|
|
|
|
{
|
|
|
|
Class contextClass;
|
|
|
|
NSString *context;
|
|
|
|
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
|
|
|
/* Load in only one server */
|
2002-05-06 17:13:31 +00:00
|
|
|
#if BUILD_SERVER == SERVER_x11
|
2002-03-27 23:44:41 +00:00
|
|
|
[XGServer initializeBackend];
|
2002-05-06 17:13:31 +00:00
|
|
|
#elif BUILD_SERVER == SERVER_win32
|
2002-04-21 22:46:39 +00:00
|
|
|
[WIN32Server initializeBackend];
|
2002-03-27 23:44:41 +00:00
|
|
|
#else
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
format: @"No Window Server configured in backend"];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The way the frontend is currently structured
|
|
|
|
it's not possible to have more than one */
|
2002-05-06 02:03:29 +00:00
|
|
|
context = [NSString stringWithCString: STRINGIFY(BUILD_GRAPHICS)];
|
2002-03-27 23:44:41 +00:00
|
|
|
|
|
|
|
/* What backend context? */
|
|
|
|
if ([defs stringForKey: @"GSContext"])
|
|
|
|
context = [defs stringForKey: @"GSContext"];
|
|
|
|
|
|
|
|
if ([context isEqual: @"xdps"])
|
|
|
|
contextClass = objc_get_class("NSDPSContext");
|
2002-05-06 02:03:29 +00:00
|
|
|
else if ([context isEqual: @"art"])
|
|
|
|
contextClass = objc_get_class("ARTContext");
|
|
|
|
else if ([context isEqual: @"winlib"])
|
2002-03-27 23:44:41 +00:00
|
|
|
contextClass = objc_get_class("WIN32Context");
|
2004-08-02 21:50:17 +00:00
|
|
|
else if ([context isEqual: @"cairo"])
|
|
|
|
contextClass = objc_get_class("CairoContext");
|
|
|
|
else
|
2002-03-27 23:44:41 +00:00
|
|
|
contextClass = objc_get_class("XGContext");
|
|
|
|
|
|
|
|
[contextClass initializeBackend];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|