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>
* Palettes/0Menus/GormNSMenu.m: Code cleanup.

View file

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

58
Gorm.m
View file

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

View file

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

View file

@ -22,14 +22,16 @@
* 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/NSGraphics.h>
#include <AppKit/NSFont.h>
#include <AppKit/NSNibLoading.h>
#include <GNUstepGUI/GSNibTemplates.h>
#include "GormPrivate.h"
@class GSCustomView;
@ -132,7 +134,12 @@
Class cls = [NSView class];
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];
@ -155,6 +162,7 @@
id obj;
Class cls;
unsigned int mask;
GormClassManager *classManager = [(id<Gorm>)NSApp classManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
theFrame = [aCoder decodeRect];
@ -162,7 +170,8 @@
at: &mask];
cls = NSClassFromString(theClass);
if (cls == nil)
if([classManager isSuperclass: @"NSOpenGLView" linkedToClass: theClass] ||
[theClass isEqual: @"NSOpenGLView"] || cls == nil)
{
cls = [self _bestPossibleSuperClass];
}
@ -178,11 +187,12 @@
[obj setAutoresizingMask: mask];
}
/*
if (![self isKindOfClass: [GSCustomView class]])
{
RETAIN(obj);
}
*/
RELEASE(self);
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 "GormPrivate.h"
#include "GormViewWithSubviewsEditor.h"
#include "GormFontViewController.h"
#include <GormCore/GormPrivate.h>
#include <GormCore/GormViewWithSubviewsEditor.h>
#include <GormCore/GormFontViewController.h>
@class GormEditorToParent;