mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 13:11:55 +00:00
Support for miniwindows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6147 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2a2474c3de
commit
381e499e2c
4 changed files with 260 additions and 10 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Wed Mar 01 16:21:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Headers/gnustep/gui/NSWindow.h: New style values added for
|
||||||
|
app iconwindow and miniwindows.
|
||||||
|
New ivar added for miniwindow counterpart. New method ([-counterpart])
|
||||||
|
* Source/NSApplication.m: Create the iconwindow usig the new style.
|
||||||
|
* Source/NSWindow.m: Many modifications to support miniwindow
|
||||||
|
counterparts and create miniwindows when required (when a window
|
||||||
|
is miniaturised).
|
||||||
|
|
||||||
Tue Feb 29 16:34:49 2000 Nicola Pero <n.pero@mi.flashnet.it>
|
Tue Feb 29 16:34:49 2000 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Documentation/gsdoc/Introduction.gsdoc: New file - beginning of
|
* Documentation/gsdoc/Introduction.gsdoc: New file - beginning of
|
||||||
|
|
|
@ -76,7 +76,9 @@ enum {
|
||||||
NSTitledWindowMask = 1,
|
NSTitledWindowMask = 1,
|
||||||
NSClosableWindowMask = 2,
|
NSClosableWindowMask = 2,
|
||||||
NSMiniaturizableWindowMask = 4,
|
NSMiniaturizableWindowMask = 4,
|
||||||
NSResizableWindowMask = 8
|
NSResizableWindowMask = 8,
|
||||||
|
NSIconWindowMask = 64, /* GNUstep extension - app icon window */
|
||||||
|
NSMiniWindowMask = 128 /* GNUstep extension - miniwindows */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef STRICT_OPENSTEP
|
#ifndef STRICT_OPENSTEP
|
||||||
|
@ -123,6 +125,7 @@ extern NSSize NSTokenSize;
|
||||||
|
|
||||||
NSWindowDepth depth_limit;
|
NSWindowDepth depth_limit;
|
||||||
NSWindowController *_windowController;
|
NSWindowController *_windowController;
|
||||||
|
int _counterpart;
|
||||||
|
|
||||||
struct GSWindowFlagsType {
|
struct GSWindowFlagsType {
|
||||||
unsigned accepts_drag:1;
|
unsigned accepts_drag:1;
|
||||||
|
@ -221,6 +224,9 @@ extern NSSize NSTokenSize;
|
||||||
- (NSString *) miniwindowTitle;
|
- (NSString *) miniwindowTitle;
|
||||||
- (void) setMiniwindowImage: (NSImage *)image;
|
- (void) setMiniwindowImage: (NSImage *)image;
|
||||||
- (void) setMiniwindowTitle: (NSString *)title;
|
- (void) setMiniwindowTitle: (NSString *)title;
|
||||||
|
#ifndef NO_GNUSTEP
|
||||||
|
- (NSWindow*) counterpart;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The field editor
|
* The field editor
|
||||||
|
|
|
@ -281,7 +281,7 @@ static NSCell* tileCell = nil;
|
||||||
|
|
||||||
_app_icon_window = [[NSIconWindow alloc] initWithContentRect:
|
_app_icon_window = [[NSIconWindow alloc] initWithContentRect:
|
||||||
NSMakeRect(0,0,64,64)
|
NSMakeRect(0,0,64,64)
|
||||||
styleMask: NSBorderlessWindowMask
|
styleMask: NSIconWindowMask
|
||||||
backing: NSBackingStoreRetained
|
backing: NSBackingStoreRetained
|
||||||
defer: NO
|
defer: NO
|
||||||
screen: nil];
|
screen: nil];
|
||||||
|
|
|
@ -65,6 +65,170 @@
|
||||||
|
|
||||||
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
||||||
|
|
||||||
|
@interface NSMiniWindow : NSWindow
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSMiniWindow
|
||||||
|
|
||||||
|
- (BOOL) canBecomeMainWindow
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) canBecomeKeyWindow
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) initDefaults
|
||||||
|
{
|
||||||
|
[super initDefaults];
|
||||||
|
[self setExcludedFromWindowsMenu: YES];
|
||||||
|
[self setReleasedWhenClosed: NO];
|
||||||
|
window_level = NSDockWindowLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSMiniWindowView : NSView
|
||||||
|
{
|
||||||
|
NSCell *imageCell;
|
||||||
|
NSCell *titleCell;
|
||||||
|
}
|
||||||
|
- (void) setImage: (NSImage*)anImage;
|
||||||
|
- (void) setTitle: (NSString*)aString;
|
||||||
|
@end
|
||||||
|
|
||||||
|
static NSCell* tileCell = nil;
|
||||||
|
|
||||||
|
@implementation NSMiniWindowView
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
NSImage *tileImage = [NSImage imageNamed: @"common_Tile"];
|
||||||
|
|
||||||
|
tileCell = [[NSCell alloc] initImageCell: tileImage];
|
||||||
|
[tileCell setBordered: NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
TEST_RELEASE(imageCell);
|
||||||
|
TEST_RELEASE(titleCell);
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) drawRect: (NSRect)rect
|
||||||
|
{
|
||||||
|
[tileCell drawWithFrame: NSMakeRect(0,0,64,64) inView: self];
|
||||||
|
[imageCell drawWithFrame: NSMakeRect(8,8,48,48) inView: self];
|
||||||
|
[titleCell drawWithFrame: NSMakeRect(0,56,64,8) inView: self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) mouseDown: (NSEvent*)theEvent
|
||||||
|
{
|
||||||
|
if ([theEvent clickCount] >= 2)
|
||||||
|
{
|
||||||
|
NSWindow *w = [_window counterpart];
|
||||||
|
|
||||||
|
[_window orderOut: self];
|
||||||
|
[w orderFront: self];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSPoint lastLocation;
|
||||||
|
NSPoint location;
|
||||||
|
unsigned eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
|
| NSPeriodicMask | NSRightMouseUpMask;
|
||||||
|
NSDate *theDistantFuture = [NSDate distantFuture];
|
||||||
|
BOOL done = NO;
|
||||||
|
|
||||||
|
lastLocation = [theEvent locationInWindow];
|
||||||
|
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.02];
|
||||||
|
|
||||||
|
while (!done)
|
||||||
|
{
|
||||||
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
||||||
|
untilDate: theDistantFuture
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
|
|
||||||
|
switch ([theEvent type])
|
||||||
|
{
|
||||||
|
case NSRightMouseUp:
|
||||||
|
case NSLeftMouseUp:
|
||||||
|
/* right mouse up or left mouse up means we're done */
|
||||||
|
done = YES;
|
||||||
|
break;
|
||||||
|
case NSPeriodic:
|
||||||
|
location = [_window mouseLocationOutsideOfEventStream];
|
||||||
|
if (NSEqualPoints(location, lastLocation) == NO)
|
||||||
|
{
|
||||||
|
NSPoint origin = [_window frame].origin;
|
||||||
|
|
||||||
|
origin.x += (location.x - lastLocation.x);
|
||||||
|
origin.y += (location.y - lastLocation.y);
|
||||||
|
[_window setFrameOrigin: origin];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[NSEvent stopPeriodicEvents];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setImage: (NSImage*)anImage
|
||||||
|
{
|
||||||
|
if (imageCell == nil)
|
||||||
|
{
|
||||||
|
imageCell = [[NSCell alloc] initImageCell: anImage];
|
||||||
|
[imageCell setBordered: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[imageCell setImage: anImage];
|
||||||
|
}
|
||||||
|
if (_window != nil)
|
||||||
|
{
|
||||||
|
[self lockFocus];
|
||||||
|
[self drawRect: [self bounds]];
|
||||||
|
[self unlockFocus];
|
||||||
|
[_window flushWindow];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setTitle: (NSString*)aString
|
||||||
|
{
|
||||||
|
if (titleCell == nil)
|
||||||
|
{
|
||||||
|
titleCell = [[NSCell alloc] initTextCell: aString];
|
||||||
|
[titleCell setBordered: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[titleCell setStringValue: aString];
|
||||||
|
}
|
||||||
|
if (_window != nil)
|
||||||
|
{
|
||||||
|
[self lockFocus];
|
||||||
|
[self drawRect: [self bounds]];
|
||||||
|
[self unlockFocus];
|
||||||
|
[_window flushWindow];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@interface GSWindowView : NSView
|
@interface GSWindowView : NSView
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -221,6 +385,13 @@ static NSMapTable* windowmaps = NULL;
|
||||||
[NSApp removeWindowsItem: self];
|
[NSApp removeWindowsItem: self];
|
||||||
|
|
||||||
[self setFrameAutosaveName: nil];
|
[self setFrameAutosaveName: nil];
|
||||||
|
if (_counterpart != 0 && (style_mask & NSMiniWindowMask) == 0)
|
||||||
|
{
|
||||||
|
NSWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
||||||
|
|
||||||
|
_counterpart = 0;
|
||||||
|
RELEASE(mini);
|
||||||
|
}
|
||||||
TEST_RELEASE(_wv);
|
TEST_RELEASE(_wv);
|
||||||
TEST_RELEASE(_fieldEditor);
|
TEST_RELEASE(_fieldEditor);
|
||||||
TEST_RELEASE(background_color);
|
TEST_RELEASE(background_color);
|
||||||
|
@ -484,11 +655,38 @@ static NSMapTable* windowmaps = NULL;
|
||||||
- (void) setMiniwindowImage: (NSImage *)image
|
- (void) setMiniwindowImage: (NSImage *)image
|
||||||
{
|
{
|
||||||
ASSIGN(miniaturized_image, image);
|
ASSIGN(miniaturized_image, image);
|
||||||
|
if (_counterpart != 0 && (style_mask & NSMiniWindowMask) == 0)
|
||||||
|
{
|
||||||
|
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
||||||
|
id v = [mini contentView];
|
||||||
|
|
||||||
|
if ([v respondsToSelector: @selector(setImage:)])
|
||||||
|
{
|
||||||
|
[v setImage: [self miniwindowImage]];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMiniwindowTitle: (NSString*)title
|
- (void) setMiniwindowTitle: (NSString*)title
|
||||||
{
|
{
|
||||||
ASSIGN(miniaturized_title, title);
|
ASSIGN(miniaturized_title, title);
|
||||||
|
if (_counterpart != 0 && (style_mask & NSMiniWindowMask) == 0)
|
||||||
|
{
|
||||||
|
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
||||||
|
id v = [mini contentView];
|
||||||
|
|
||||||
|
if ([v respondsToSelector: @selector(setTitle:)])
|
||||||
|
{
|
||||||
|
[v setTitle: [self miniwindowTitle]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSWindow*) counterpart
|
||||||
|
{
|
||||||
|
if (_counterpart == 0)
|
||||||
|
return nil;
|
||||||
|
return [NSApp windowWithWindowNumber: _counterpart];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1369,19 +1567,28 @@ resetCursorRectsForView(NSView *theView)
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) miniaturize: sender
|
- (void) miniaturize: sender
|
||||||
|
{
|
||||||
|
if ((style_mask & (NSIconWindowMask | NSMiniWindowMask)) == 0)
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
[nc postNotificationName: NSWindowWillMiniaturizeNotification object: self];
|
[nc postNotificationName: NSWindowWillMiniaturizeNotification
|
||||||
|
object: self];
|
||||||
|
|
||||||
[self performMiniaturize: self];
|
[self performMiniaturize: self];
|
||||||
[nc postNotificationName: NSWindowDidMiniaturizeNotification object: self];
|
[nc postNotificationName: NSWindowDidMiniaturizeNotification
|
||||||
|
object: self];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Attempt to miniaturise miniwindow or iconwindow");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) performClose: sender
|
- (void) performClose: sender
|
||||||
{
|
{
|
||||||
/* self must have a close button in order to be closed */
|
/* self must have a close button in order to be closed */
|
||||||
if (!([self styleMask] & NSClosableWindowMask))
|
if (!(style_mask & NSClosableWindowMask))
|
||||||
{
|
{
|
||||||
NSBeep();
|
NSBeep();
|
||||||
return;
|
return;
|
||||||
|
@ -1427,9 +1634,37 @@ resetCursorRectsForView(NSView *theView)
|
||||||
|
|
||||||
- (void) performMiniaturize: (id)sender
|
- (void) performMiniaturize: (id)sender
|
||||||
{
|
{
|
||||||
|
if ((style_mask & (NSIconWindowMask | NSMiniWindowMask)) == 0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Ensure that we have a miniwindow counterpart.
|
||||||
|
*/
|
||||||
|
if (_counterpart == 0)
|
||||||
|
{
|
||||||
|
NSWindow *mini;
|
||||||
|
NSMiniWindowView *v;
|
||||||
|
|
||||||
|
mini = [[NSMiniWindow alloc]
|
||||||
|
initWithContentRect: NSMakeRect(0,0,64,64)
|
||||||
|
styleMask: NSMiniWindowMask
|
||||||
|
backing: NSBackingStoreBuffered
|
||||||
|
defer: NO];
|
||||||
|
mini->_counterpart = [self windowNumber];
|
||||||
|
_counterpart = [mini windowNumber];
|
||||||
|
v = [[NSMiniWindowView alloc] initWithFrame: NSMakeRect(0,0,64,64)];
|
||||||
|
[v setImage: [self miniwindowImage]];
|
||||||
|
[v setTitle: [self miniwindowTitle]];
|
||||||
|
[mini setContentView: v];
|
||||||
|
RELEASE(v);
|
||||||
|
}
|
||||||
DPSminiwindow(GSCurrentContext(), window_num);
|
DPSminiwindow(GSCurrentContext(), window_num);
|
||||||
_f.is_miniaturized = YES;
|
_f.is_miniaturized = YES;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Attempt to miniaturise miniwindow or iconwindow");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (int) resizeFlags
|
- (int) resizeFlags
|
||||||
{
|
{
|
||||||
|
@ -2719,7 +2954,6 @@ resetCursorRectsForView(NSView *theView)
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
BOOL flag;
|
BOOL flag;
|
||||||
NSPoint p;
|
|
||||||
|
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue