Added demo opengl view as well as corrected a memory leak.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21333 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-06-20 23:44:20 +00:00
parent 0471cd39bf
commit c1c8b949d8
8 changed files with 165 additions and 51 deletions

View file

@ -1,3 +1,14 @@
2005-06-20 19:32 Gregory John Casamento <greg_casamento@yahoo.com>
* GNUmakefile.preamble: Add -lGL to ADDITIONAL_LIBS
* GormCore/GNUmakefile: Added new opengl view.
* GormCore/GormCustomView.m: Added include for GormOpenGLView and
modified _bestPossibleSuperClass to return the GormOpenGLView.
* GormCore/GormOpenGLView.[hm]: Displays a rotating polygon to
illustrate that this is a OpenGL view to the user when in test mode.
* GormCore/GormViewWithSubviewsEditor.m: Corrected includes.
* Gorm.m: Corrected a memory leak in testInterface and endTesting.
2005-06-17 17:33 Gregory John Casamento <greg_casamento@yahoo.com> 2005-06-17 17:33 Gregory John Casamento <greg_casamento@yahoo.com>
* Palettes/0Menus/GormNSMenu.m: Code cleanup. * Palettes/0Menus/GormNSMenu.m: Code cleanup.

View file

@ -28,7 +28,8 @@ ADDITIONAL_GUI_LIBS += \
-lGormCore \ -lGormCore \
-lGorm \ -lGorm \
-lGormObjCHeaderParser \ -lGormObjCHeaderParser \
-lGormPrefs -lGormPrefs \
-lGL
ADDITIONAL_INCLUDE_DIRS += \ ADDITIONAL_INCLUDE_DIRS += \
-IInterfaceBuilder \ -IInterfaceBuilder \

58
Gorm.m
View file

@ -45,8 +45,8 @@
BOOL isTesting; BOOL isTesting;
id testContainer; id testContainer;
id gormMenu; id gormMenu;
NSMenu *mainMenu; // saves the main menu when testing... NSMenu *mainMenu; // saves the main menu...
NSMenu *servicesMenu; // saves the services menu when testing... NSMenu *servicesMenu; // saves the services menu...
NSMenu *classMenu; // so we can set it for the class view NSMenu *classMenu; // so we can set it for the class view
NSMenuItem *guideLineMenuItem; NSMenuItem *guideLineMenuItem;
NSDictionary *menuLocations; NSDictionary *menuLocations;
@ -63,6 +63,7 @@
NSRect connectDRect; NSRect connectDRect;
NSPoint cascadePoint; NSPoint cascadePoint;
NSMutableArray *testingWindows; NSMutableArray *testingWindows;
NSMutableArray *topObjects;
} }
// handle notifications the object recieves. // handle notifications the object recieves.
@ -550,6 +551,9 @@
} }
else else
{ {
// top level objects
topObjects = [[NSMutableArray alloc] init];
NS_DURING NS_DURING
{ {
NSUserDefaults *defaults; NSUserDefaults *defaults;
@ -561,6 +565,8 @@
NSDictionary *substituteClasses = [palettesManager substituteClasses]; NSDictionary *substituteClasses = [palettesManager substituteClasses];
NSString *subClassName; NSString *subClassName;
id obj; id obj;
NSDictionary *context = [NSDictionary dictionaryWithObject: topObjects
forKey: @"NSTopLevelObjects"];
// which windows were open when testing started... // which windows were open when testing started...
testingWindows = [[NSMutableArray alloc] init]; testingWindows = [[NSMutableArray alloc] init];
@ -573,26 +579,15 @@
} }
} }
isTesting = YES; // set here, so that beginArchiving and endArchiving do not use templates. // set here, so that beginArchiving and endArchiving do not use templates.
isTesting = YES;
[self setApplicationIconImage: testingImage]; [self setApplicationIconImage: testingImage];
archiver = [[NSArchiver alloc] init]; archiver = [[NSArchiver alloc] init];
[activeDoc beginArchiving]; [activeDoc beginArchiving];
[archiver encodeClassName: @"GormCustomView" [archiver encodeClassName: @"GormCustomView"
intoClassName: @"GormTestCustomView"]; intoClassName: @"GormTestCustomView"];
/* // substitute classes from palettes.
[archiver encodeClassName: @"GormNSMenu"
intoClassName: @"NSMenu"];
[archiver encodeClassName: @"GormNSWindow"
intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSPanel"
intoClassName: @"NSPanel"];
[archiver encodeClassName: @"GormNSPopUpButton"
intoClassName: @"NSPopUpButton"];
[archiver encodeClassName: @"GormNSPopUpButtonCell"
intoClassName: @"NSPopUpButtonCell"];
*/
en = [substituteClasses keyEnumerator]; en = [substituteClasses keyEnumerator];
while((subClassName = [en nextObject]) != nil) while((subClassName = [en nextObject]) != nil)
{ {
@ -601,22 +596,15 @@
intoClassName: realClassName]; intoClassName: realClassName];
} }
/* // do not allow custom classes during testing.
[archiver encodeClassName: @"GormNSBrowser" [GSClassSwapper setIsInInterfaceBuilder: YES];
intoClassName: @"NSBrowser"];
[archiver encodeClassName: @"GormNSTableView"
intoClassName: @"NSTableView"];
[archiver encodeClassName: @"GormNSOutlineView"
intoClassName: @"NSOutlineView"];
*/
[GSClassSwapper setIsInInterfaceBuilder: YES]; // do not allow custom classes during testing.
[archiver encodeRootObject: activeDoc]; [archiver encodeRootObject: activeDoc];
data = RETAIN([archiver archiverData]); // Released below... data = RETAIN([archiver archiverData]); // Released below...
[activeDoc endArchiving]; [activeDoc endArchiving];
RELEASE(archiver); RELEASE(archiver);
[GSClassSwapper setIsInInterfaceBuilder: NO]; // begin allowing custom classes... [GSClassSwapper setIsInInterfaceBuilder: NO];
// signal the start of testing...
[notifCenter postNotificationName: IBWillBeginTestingInterfaceNotification [notifCenter postNotificationName: IBWillBeginTestingInterfaceNotification
object: self]; object: self];
@ -636,8 +624,7 @@
NSMutableDictionary *nameTable = [testContainer nameTable]; NSMutableDictionary *nameTable = [testContainer nameTable];
[nameTable removeObjectForKey: @"NSServicesMenu"]; [nameTable removeObjectForKey: @"NSServicesMenu"];
[nameTable removeObjectForKey: @"NSWindowsMenu"]; [nameTable removeObjectForKey: @"NSWindowsMenu"];
[testContainer awakeWithContext: nil]; [testContainer awakeWithContext: context];
RETAIN(testContainer); // released in endTesting:
} }
/* /*
@ -678,10 +665,7 @@
// so we don't get the warning... // so we don't get the warning...
[self setServicesMenu: nil]; [self setServicesMenu: nil];
// display the current main menu...
[[self mainMenu] display]; [[self mainMenu] display];
[notifCenter postNotificationName: IBDidBeginTestingInterfaceNotification [notifCenter postNotificationName: IBDidBeginTestingInterfaceNotification
object: self]; object: self];
@ -936,15 +920,14 @@
NSEnumerator *e; NSEnumerator *e;
id val; id val;
CREATE_AUTORELEASE_POOL(pool); // CREATE_AUTORELEASE_POOL(pool);
[nc postNotificationName: IBWillEndTestingInterfaceNotification [nc postNotificationName: IBWillEndTestingInterfaceNotification
object: self]; object: self];
/* /*
* Make sure windows will go away when the container is destroyed. * Make sure windows will go away when the container is destroyed.
*/ */
e = [[testContainer nameTable] objectEnumerator]; e = [topObjects objectEnumerator];
while ((val = [e nextObject]) != nil) while ((val = [e nextObject]) != nil)
{ {
if ([val isKindOfClass: [NSWindow class]] == YES) if ([val isKindOfClass: [NSWindow class]] == YES)
@ -990,7 +973,6 @@
NS_ENDHANDLER NS_ENDHANDLER
[mainMenu display]; // bring it to the front... [mainMenu display]; // bring it to the front...
isTesting = NO; isTesting = NO;
if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES) if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES)
@ -1002,8 +984,10 @@
DESTROY(testingWindows); DESTROY(testingWindows);
// RELEASE(pool);
RELEASE(pool); // deallocate top leve objects
RELEASE(topObjects);
return self; return self;
} }

View file

@ -59,6 +59,8 @@ GormCore_HEADER_FILES = \
GormInternalViewEditor.h \ GormInternalViewEditor.h \
GormMatrixEditor.h \ GormMatrixEditor.h \
GormNSSplitViewInspector.h \ GormNSSplitViewInspector.h \
GormObjectEditor.h \
GormOpenGLView.h \
GormOutlineView.h \ GormOutlineView.h \
GormPalettesManager.h \ GormPalettesManager.h \
GormPlacementInfo.h \ GormPlacementInfo.h \
@ -109,6 +111,7 @@ GormCore_OBJC_FILES = \
GormNSSplitViewInspector.m \ GormNSSplitViewInspector.m \
GormObjectEditor.m \ GormObjectEditor.m \
GormObjectInspector.m \ GormObjectInspector.m \
GormOpenGLView.m \
GormOutlineView.m \ GormOutlineView.m \
GormPalettesManager.m \ GormPalettesManager.m \
GormResource.m \ GormResource.m \

View file

@ -22,14 +22,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/ */
#include "GormCustomView.h" #include <GormCore/GormCustomView.h>
#include <GormCore/GormPrivate.h>
#include <GormCore/GormOpenGLView.h>
#include <AppKit/NSColor.h> #include <AppKit/NSColor.h>
#include <AppKit/NSGraphics.h> #include <AppKit/NSGraphics.h>
#include <AppKit/NSFont.h> #include <AppKit/NSFont.h>
#include <AppKit/NSNibLoading.h> #include <AppKit/NSNibLoading.h>
#include <GNUstepGUI/GSNibTemplates.h> #include <GNUstepGUI/GSNibTemplates.h>
#include "GormPrivate.h"
@class GSCustomView; @class GSCustomView;
@ -132,7 +134,12 @@
Class cls = [NSView class]; Class cls = [NSView class];
GormClassManager *classManager = [(id<Gorm>)NSApp classManager]; GormClassManager *classManager = [(id<Gorm>)NSApp classManager];
if([classManager isSuperclass: @"NSView" linkedToClass: theClass]) if([classManager isSuperclass: @"NSOpenGLView" linkedToClass: theClass] ||
[theClass isEqual: @"NSOpenGLView"])
{
cls = [GormOpenGLView class];
}
else if([classManager isSuperclass: @"NSView" linkedToClass: theClass])
{ {
NSString *superClass = [classManager nonCustomSuperClassOf: theClass]; NSString *superClass = [classManager nonCustomSuperClassOf: theClass];
@ -155,6 +162,7 @@
id obj; id obj;
Class cls; Class cls;
unsigned int mask; unsigned int mask;
GormClassManager *classManager = [(id<Gorm>)NSApp classManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass]; [aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
theFrame = [aCoder decodeRect]; theFrame = [aCoder decodeRect];
@ -162,7 +170,8 @@
at: &mask]; at: &mask];
cls = NSClassFromString(theClass); cls = NSClassFromString(theClass);
if (cls == nil) if([classManager isSuperclass: @"NSOpenGLView" linkedToClass: theClass] ||
[theClass isEqual: @"NSOpenGLView"] || cls == nil)
{ {
cls = [self _bestPossibleSuperClass]; cls = [self _bestPossibleSuperClass];
} }
@ -178,11 +187,12 @@
[obj setAutoresizingMask: mask]; [obj setAutoresizingMask: mask];
} }
/*
if (![self isKindOfClass: [GSCustomView class]]) if (![self isKindOfClass: [GSCustomView class]])
{ {
RETAIN(obj); RETAIN(obj);
} }
*/
RELEASE(self); RELEASE(self);
return obj; return obj;

40
GormCore/GormOpenGLView.h Normal file
View file

@ -0,0 +1,40 @@
/* GormOpenGLView.h - Demo view for show when displaying a NSOpenGLView during
* testing only.
*
* Copyright (C) 2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 2005
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/
#ifndef INCLUDED_GormOpenGLView_h
#define INCLUDED_GormOpenGLView_h
#include <AppKit/NSOpenGLView.h>
@class NSTimer;
@interface GormOpenGLView : NSOpenGLView
{
float rtri;
NSTimer *timer;
}
@end
#endif

67
GormCore/GormOpenGLView.m Normal file
View file

@ -0,0 +1,67 @@
/* GormOpenGLView.h - Demo view for show when displaying a NSOpenGLView during
* testing only.
*
* Copyright (C) 2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 2005
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/
#include <GormCore/GormOpenGLView.h>
#include <Foundation/NSTimer.h>
#include <AppKit/NSOpenGL.h>
#include <GL/gl.h>
@implementation GormOpenGLView
- (id) initWithFrame: (NSRect)rect
{
if((self = [super initWithFrame: rect]) != nil)
{
rtri = 0.0f;
timer = [NSTimer scheduledTimerWithTimeInterval: 0.05
target: self
selector: @selector(oneStep)
userInfo: nil
repeats: YES];
}
return self;
}
- (void) dealloc
{
[timer invalidate];
[super dealloc];
}
- (void) oneStep
{
// rotate.
// rtri -= 0.2f;
rtri = 0.5f; // fabs( sin( 2.0 * M_PI * [startTime timeIntervalSinceNow] ) ) ;
[self setNeedsDisplay: YES];
}
- (void) drawRect: (NSRect)rect
{
// do nothing for now...
}
@end

View file

@ -24,11 +24,9 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include "GormPrivate.h" #include <GormCore/GormPrivate.h>
#include <GormCore/GormViewWithSubviewsEditor.h>
#include "GormViewWithSubviewsEditor.h" #include <GormCore/GormFontViewController.h>
#include "GormFontViewController.h"
@class GormEditorToParent; @class GormEditorToParent;