* Headers/AppKit/NSDrawer.h: Added new ivars.

* Source/NSDrawer.m: Addition implementation of NSDrawer.  Corrected
	drag problem.  Added border.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25873 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
gcasa 2008-01-05 20:27:10 +00:00
parent 0c7b8fad15
commit 77071bf68c
3 changed files with 115 additions and 38 deletions

View file

@ -1,3 +1,9 @@
2008-01-05 15:25-EST Gregory John Casamento <greg_casamento@yahoo.com>
* Headers/AppKit/NSDrawer.h: Added new ivars.
* Source/NSDrawer.m: Addition implementation of NSDrawer. Corrected
drag problem. Added border.
2008-01-04 Fred Kiefer <FredKiefer@gmx.de> 2008-01-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextContainer.m: Replace tabs with spaces. * Source/NSTextContainer.m: Replace tabs with spaces.

View file

@ -39,10 +39,10 @@
@class NSNotification; @class NSNotification;
enum { enum {
NSDrawerClosedState, NSDrawerClosedState = 0,
NSDrawerOpeningState, NSDrawerOpeningState = 1,
NSDrawerOpenState, NSDrawerOpenState = 2,
NSDrawerClosingState NSDrawerClosingState = 3
}; };
@interface NSDrawer : NSResponder @interface NSDrawer : NSResponder

View file

@ -33,10 +33,12 @@
#include <Foundation/NSKeyedArchiver.h> #include <Foundation/NSKeyedArchiver.h>
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include "AppKit/NSWindow.h" #include <Foundation/NSTimer.h>
#include "AppKit/NSBox.h" #include <AppKit/NSWindow.h>
#include "AppKit/NSView.h" #include <AppKit/NSBox.h>
#include "AppKit/NSDrawer.h" #include <AppKit/NSView.h>
#include <AppKit/NSDrawer.h>
#include <AppKit/NSGraphics.h>
static NSNotificationCenter *nc = nil; static NSNotificationCenter *nc = nil;
@ -45,7 +47,8 @@ static NSNotificationCenter *nc = nil;
NSWindow *_parentWindow; NSWindow *_parentWindow;
NSWindow *_pendingParentWindow; NSWindow *_pendingParentWindow;
NSDrawer *_drawer; NSDrawer *_drawer;
NSBox *_box; id _container;
NSTimer *_timer;
} }
- (NSRect) frameFromParentWindowFrame; - (NSRect) frameFromParentWindowFrame;
@ -53,6 +56,8 @@ static NSNotificationCenter *nc = nil;
- (void) openOnEdge; - (void) openOnEdge;
- (void) closeOnEdge; - (void) closeOnEdge;
- (void) slide; - (void) slide;
- (void) startTimer;
- (void) stopTimer;
// window/drawer properties // window/drawer properties
- (void) setParentWindow: (NSWindow *)window; - (void) setParentWindow: (NSWindow *)window;
@ -84,6 +89,11 @@ static NSNotificationCenter *nc = nil;
defer: (BOOL)flag defer: (BOOL)flag
screen: (NSScreen*)aScreen screen: (NSScreen*)aScreen
{ {
if(NSIsEmptyRect(contentRect))
{
contentRect = NSMakeRect(0,0,100,100);
}
self = [super initWithContentRect: contentRect self = [super initWithContentRect: contentRect
styleMask: aStyle styleMask: aStyle
backing: bufferingType backing: bufferingType
@ -91,30 +101,43 @@ static NSNotificationCenter *nc = nil;
screen: aScreen]; screen: aScreen];
if (self != nil) if (self != nil)
{ {
/* NSRect rect = contentRect;
_box = [[NSBox alloc] init]; NSRect border = contentRect;
[_box setTitle: @""]; NSBox *borderBox = nil;
[_box setTitlePosition: NSNoTitle];
[_box setBorderType: NSBezelBorder]; rect.origin.x += 6;
[_box setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; rect.origin.y += 6;
[[super contentView] addSubview: _box]; rect.size.width -= 16;
*/ rect.size.height -= 16;
border.origin.x += 1;
border.origin.y += 1;
border.size.width -= 2;
border.size.height -= 2;
borderBox = [[NSBox alloc] initWithFrame: border];
[borderBox setTitle: @""];
[borderBox setTitlePosition: NSNoTitle];
[borderBox setBorderType: NSLineBorder];
[borderBox setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[borderBox setContentViewMargins: NSMakeSize(0,0)];
[[super contentView] addSubview: borderBox];
_container = [[NSBox alloc] initWithFrame: rect];
[_container setTitle: @""];
[_container setTitlePosition: NSNoTitle];
[_container setBorderType: NSBezelBorder];
[_container setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[borderBox addSubview: _container];
} }
return self; return self;
} }
/* - (id) container
- (void) setContentView: (NSView *)view
{ {
[_box setContentView: view]; return _container;
} }
- (NSView *) contentView
{
return [_box contentView];
}
*/
- (NSRect) frameFromParentWindowFrame - (NSRect) frameFromParentWindowFrame
{ {
NSRect newFrame = [_parentWindow frame]; NSRect newFrame = [_parentWindow frame];
@ -177,16 +200,51 @@ static NSNotificationCenter *nc = nil;
[self setFrame: tempFrame display: YES]; [self setFrame: tempFrame display: YES];
} }
- (void) startTimer
{
NSTimeInterval time = 3.0;
_timer = [NSTimer scheduledTimerWithTimeInterval: time
target: self
selector: @selector(_timedWindowReset)
userInfo: nil
repeats: YES];
}
- (void) stopTimer
{
[_timer invalidate];
}
- (void) orderFrontRegardless
{
[self orderFront: self];
}
- (void) orderOut: (id)sender
{
[super orderOut: sender];
}
/*
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)windowNum
{
NSLog(@"Ordering window....");
[super orderWindow: place relativeTo: windowNum];
}
*/
- (void) openOnEdge - (void) openOnEdge
{ {
[self orderFront: self]; [self orderFront: self];
[self slide]; [self slide];
// [self startTimer];
} }
- (void) closeOnEdge - (void) closeOnEdge
{ {
NSRect frame = [self frameFromParentWindowFrame]; // : [_parentWindow frame]]; NSRect frame = [self frameFromParentWindowFrame];
// slide the drawer closed....
// [self stopTimer];
[self slide]; [self slide];
[self setFrame: frame display: YES]; [self setFrame: frame display: YES];
[self orderOut: self]; [self orderOut: self];
@ -255,21 +313,34 @@ static NSNotificationCenter *nc = nil;
} }
} }
- (void) _resetWindowPosition
{
NSRect frame = [self frameFromParentWindowFrame];
[self setFrame: frame display: YES];
}
- (void) _timedWindowReset
{
NSRect frame = [_parentWindow frame];
[self _resetWindowPosition];
[_parentWindow setFrame: frame display: YES];
}
- (void) handleWindowClose: (NSNotification *)notification - (void) handleWindowClose: (NSNotification *)notification
{ {
[self stopTimer];
[self close]; [self close];
} }
- (void) handleWindowMiniaturize: (NSNotification *)notification - (void) handleWindowMiniaturize: (NSNotification *)notification
{ {
[self stopTimer];
[self close]; [self close];
} }
- (void) handleWindowMove: (NSNotification *)notification - (void) handleWindowMove: (NSNotification *)notification
{ {
NSRect frame = [self frameFromParentWindowFrame]; // : [obj frame]]; [self _resetWindowPosition];
NSLog(@"%@",NSStringFromRect(frame));
[self setFrame: frame display: NO];
} }
- (void) setParentWindow: (NSWindow *)window - (void) setParentWindow: (NSWindow *)window
@ -281,8 +352,7 @@ static NSNotificationCenter *nc = nil;
if (_parentWindow != nil) if (_parentWindow != nil)
{ {
NSRect frame = [self frameFromParentWindowFrame]; [self _resetWindowPosition];
[self setFrame: frame display: YES];
// add observers.... // add observers....
[nc addObserver: self [nc addObserver: self
@ -297,7 +367,7 @@ static NSNotificationCenter *nc = nil;
[nc addObserver: self [nc addObserver: self
selector: @selector(handleWindowMove:) selector: @selector(handleWindowMove:)
name: NSWindowDidMoveNotification name: NSWindowWillMoveNotification
object: _parentWindow]; object: _parentWindow];
[nc addObserver: self [nc addObserver: self
@ -336,6 +406,7 @@ static NSNotificationCenter *nc = nil;
- (void) dealloc - (void) dealloc
{ {
[self stopTimer];
RELEASE(_parentWindow); RELEASE(_parentWindow);
TEST_RELEASE(_pendingParentWindow); TEST_RELEASE(_pendingParentWindow);
[super dealloc]; [super dealloc];
@ -356,7 +427,7 @@ static NSNotificationCenter *nc = nil;
// Creation // Creation
- (id) init - (id) init
{ {
return [self initWithContentSize: NSZeroSize return [self initWithContentSize: NSMakeSize(100,100)
preferredEdge: NSMinXEdge]; preferredEdge: NSMinXEdge];
} }
@ -550,7 +621,7 @@ static NSNotificationCenter *nc = nil;
// Managing Views // Managing Views
- (NSView *) contentView - (NSView *) contentView
{ {
return [_drawerWindow contentView]; return [[_drawerWindow container] contentView];
} }
- (NSWindow *) parentWindow - (NSWindow *) parentWindow
@ -560,7 +631,7 @@ static NSNotificationCenter *nc = nil;
- (void) setContentView: (NSView *)aView - (void) setContentView: (NSView *)aView
{ {
[_drawerWindow setContentView: aView]; [[_drawerWindow container] setContentView: aView];
} }
- (void) setParentWindow: (NSWindow *)parent - (void) setParentWindow: (NSWindow *)parent