Added new MacOSX classes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19693 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-07-07 22:43:04 +00:00
parent 5db71a9678
commit 605f60b151
7 changed files with 717 additions and 0 deletions

View file

@ -1,3 +1,13 @@
2004-07-08 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSMovie.h:
* Source/NSMovie.m:
* Headers/AppKit/NSMovieView.h:
* Source/NSMovieView.m:
* Headers/AppKit/NSAlert.h:
* Source/NSAlert.m:
New MacOSX classes, implementation still empty.
2004-07-08 Serg Stoyan <stoyan255@ukr.net>
* Images/common_ArrowDownH.tiff: added.

136
Headers/AppKit/NSAlert.h Normal file
View file

@ -0,0 +1,136 @@
/** <title>NSAlert</title>
<abstract>Encapsulate an alert panel</abstract>
Copyright <copy>(C) 2004 Free Software Foundation, Inc.</copy>
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: July 2004
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNUstep_H_NSAlert
#define _GNUstep_H_NSAlert
#include <Foundation/NSObject.h>
@class NSArray;
@class NSString;
@class NSMutableArray;
@class NSButton;
@class NSImage;
@class NSWindow;
typedef enum _NSAlertStyle {
NSWarningAlertStyle = 0,
NSInformationalAlertStyle = 1,
NSCriticalAlertStyle = 2
} NSAlertStyle;
enum {
NSAlertFirstButtonReturn = 1000,
NSAlertSecondButtonReturn = 1001,
NSAlertThirdButtonReturn = 1002
};
@interface NSAlert : NSObject
{
@private
NSString *_informative_text;
NSString *_message_text;
NSImage *_icon;
NSMutableArray *_buttons;
NSString *_help_anchor;
NSWindow *_window;
id _delegate;
NSAlertStyle _style;
BOOL _shows_help;
}
+ (NSAlert *)alertWithMessageText:(NSString *)messageTitle
defaultButton:(NSString *)defaultButtonTitle
alternateButton:(NSString *)alternateButtonTitle
otherButton:(NSString *)otherButtonTitle
informativeTextWithFormat:(NSString *)format, ...;
//
// Alert text
//
- (void)setInformativeText:(NSString *)informativeText;
- (NSString *)informativeText;
- (void)setMessageText:(NSString *)messageText;
- (NSString *)messageText;
//
// Alert icon
//
- (void)setIcon:(NSImage *)icon;
- (NSImage *)icon;
//
// Buttons
//
- (NSButton *)addButtonWithTitle:(NSString *)aTitle;
- (NSArray *)buttons;
//
// Help
//
- (void)setShowsHelp:(BOOL)showsHelp;
- (BOOL)showsHelp;
- (void)setHelpAnchor:(NSString *)anchor;
- (NSString *)helpAnchor;
//
// Alert style
//
- (void)setAlertStyle:(NSAlertStyle)style;
- (NSAlertStyle)alertStyle;
//
// Delegate
//
- (void)setDelegate:(id)delegate;
- (id)delegate;
//
// Running the alert
//
- (int)runModal;
- (void)beginSheetModalForWindow:(NSWindow *)window
modalDelegate:(id)delegate
didEndSelector:(SEL)didEndSelector
contextInfo:(void *)contextInfo;
- (id)window;
@end
/*
* Implemented by the delegate
*/
#ifdef GNUSTEP
@interface NSObject (NSAlertDelegate)
- (BOOL)alertShowHelp:(NSAlert *)alert;
@end
#endif
#endif /* _GNUstep_H_NSAlert */

58
Headers/AppKit/NSMovie.h Normal file
View file

@ -0,0 +1,58 @@
/** <title>NSMovie</title>
<abstract>Encapsulate a Quicktime movie</abstract>
Copyright <copy>(C) 2003 Free Software Foundation, Inc.</copy>
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: March 2003
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNUstep_H_NSMovie
#define _GNUstep_H_NSMovie
#include <Foundation/NSObject.h>
@class NSArray;
@class NSData;
@class NSURL;
@class NSPasteboard;
@interface NSMovie : NSObject <NSCopying, NSCoding>
{
@private
NSData* _movie;
NSURL* _url;
}
+ (NSArray*) movieUnfilteredFileTypes;
+ (NSArray*) movieUnfilteredPasteboardTypes;
+ (BOOL) canInitWithPasteboard: (NSPasteboard*)pasteboard;
- (id) initWithMovie: (void*)movie;
- (id) initWithURL: (NSURL*)url byReference: (BOOL)byRef;
- (id) initWithPasteboard: (NSPasteboard*)pasteboard;
- (void*) QTMovie;
- (NSURL*) URL;
@end
#endif /* _GNUstep_H_NSMovie */

View file

@ -0,0 +1,106 @@
/** <title>NSMovieView</title>
<abstract>Encapsulate a view for Quicktime movies</abstract>
Copyright <copy>(C) 2003 Free Software Foundation, Inc.</copy>
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: March 2003
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNUstep_H_NSMovieView
#define _GNUstep_H_NSMovieView
#include <AppKit/NSView.h>
@class NSMovie;
typedef enum {
NSQTMovieNormalPlayback,
NSQTMovieLoopingPlayback,
NSQTMovieLoopingBackAndForthPlayback
} NSQTMovieLoopMode;
@interface NSMovieView : NSView
{
@protected
NSMovie* _movie;
float _rate;
float _volume;
struct NSMovieViewFlags {
unsigned int muted: 1;
NSQTMovieLoopMode loopMode: 3;
unsigned int plays_selection_only: 1;
unsigned int plays_every_frame: 1;
unsigned int is_controller_visible: 1;
unsigned int editable: 1;
unsigned int reserved: 24;
} _flags;
}
- (void) setMovie: (NSMovie*)movie;
- (NSMovie*) movie;
- (void) start: (id)sender;
- (void) stop: (id)sender;
- (BOOL) isPlaying;
- (void) gotoPosterFrame: (id)sender;
- (void) gotoBeginning: (id)sender;
- (void) gotoEnd: (id)sender;
- (void) stepForward: (id)sender;
- (void) stepBack: (id)sender;
- (void) setRate: (float)rate;
- (float) rate;
- (void) setVolume: (float)volume;
- (float) volume;
- (void) setMuted: (BOOL)mute;
- (BOOL) isMuted;
- (void) setLoopMode: (NSQTMovieLoopMode)mode;
- (NSQTMovieLoopMode) loopMode;
- (void) setPlaysSelectionOnly: (BOOL)flag;
- (BOOL) playsSelectionOnly;
- (void) setPlaysEveryFrame: (BOOL)flag;
- (BOOL) playsEveryFrame;
- (void) showController: (BOOL)show adjustingSize: (BOOL)adjustSize;
- (void*) movieController;
- (BOOL) isControllerVisible;
- (NSRect) movieRect;
- (void) resizeWithMagnification: (float)magnification;
- (NSSize) sizeForMagnification: (float)magnification;
- (void) setEditable: (BOOL)editable;
- (BOOL) isEditable;
- (void) cut: (id)sender;
- (void) copy: (id)sender;
- (void) paste: (id)sender;
- (void) clear: (id)sender;
- (void) undo: (id)sender;
- (void) selectAll: (id)sender;
@end
#endif /* _GNUstep_H_NSMovieView */

View file

@ -46,6 +46,7 @@ libgnustep-gui_C_FILES =
libgnustep-gui_OBJC_FILES = Functions.m \
NSActionCell.m \
NSAffineTransform.m \
NSAlert.m \
NSApplication.m \
NSAttributedString.m \
NSBezierPath.m \
@ -103,6 +104,8 @@ NSMenu.m \
NSMenuView.m \
NSMenuItem.m \
NSMenuItemCell.m \
NSMovie.m \
NSMovieView.m \
NSNib.m \
NSOpenGLContext.m \
NSOpenGLPixelFormat.m \
@ -208,6 +211,7 @@ AppKitDefines.h \
AppKitExceptions.h \
NSActionCell.h \
NSAffineTransform.h \
NSAlert.h \
NSApplication.h \
NSBezierPath.h \
NSBox.h \
@ -259,6 +263,8 @@ NSMenu.h \
NSMenuItem.h \
NSMenuItemCell.h \
NSMenuView.h \
NSMovie.h \
NSMovieView.h \
NSOpenPanel.h \
NSOpenGL.h \
NSOpenGLView.h \

238
Source/NSAlert.m Normal file
View file

@ -0,0 +1,238 @@
/** <title>NSAlert</title>
<abstract>Encapsulate an alert panel</abstract>
Copyright <copy>(C) 2004 Free Software Foundation, Inc.</copy>
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: July 2004
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <Foundation/NSString.h>
#include "AppKit/NSAlert.h"
#include "AppKit/NSPanel.h"
#include "AppKit/NSButton.h"
#include "AppKit/NSImage.h"
@implementation NSAlert
/*
* Class methods
*/
+ (void)initialize
{
if (self == [NSAlert class])
{
[self setVersion: 1];
}
}
+ (NSAlert *)alertWithMessageText:(NSString *)messageTitle
defaultButton:(NSString *)defaultButtonTitle
alternateButton:(NSString *)alternateButtonTitle
otherButton:(NSString *)otherButtonTitle
informativeTextWithFormat:(NSString *)format, ...
{
va_list ap;
NSAlert *alert = [[self alloc] init];
NSString *text;
va_start(ap, format);
if (format != nil)
{
text = [[NSString alloc] initWithFormat: format arguments: ap];
[alert setInformativeText: text];
RELEASE(text);
}
va_end(ap);
[alert setMessageText: messageTitle];
if (defaultButtonTitle != nil)
{
[alert addButtonWithTitle: defaultButtonTitle];
}
else
{
[alert addButtonWithTitle: _(@"OK")];
}
if (alternateButtonTitle != nil)
{
[alert addButtonWithTitle: alternateButtonTitle];
}
if (otherButtonTitle != nil)
{
[alert addButtonWithTitle: otherButtonTitle];
}
return AUTORELEASE(alert);
}
- (id) init
{
_buttons = [[NSMutableArray alloc] init];
_style = NSWarningAlertStyle;
return self;
}
- (void) dealloc
{
RELEASE(_informative_text);
RELEASE(_message_text);
RELEASE(_icon);
RELEASE(_buttons);
RELEASE(_help_anchor);
RELEASE(_window);
[super dealloc];
}
- (void)setInformativeText:(NSString *)informativeText
{
ASSIGN(_informative_text, informativeText);
}
- (NSString *)informativeText
{
return _informative_text;
}
- (void)setMessageText:(NSString *)messageText
{
ASSIGN(_message_text, messageText);
}
- (NSString *)messageText
{
return _message_text;
}
- (void)setIcon:(NSImage *)icon
{
ASSIGN(_icon, icon);
}
- (NSImage *)icon
{
return _icon;
}
- (NSButton *)addButtonWithTitle:(NSString *)aTitle
{
NSButton *button = [[NSButton alloc] init];
int count = [_buttons count];
[button setTitle: aTitle];
[button setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
[button setButtonType: NSMomentaryPushButton];
[button setTarget: self];
[button setAction: @selector(buttonAction: )];
[button setFont: [NSFont systemFontOfSize: 0]];
if (count == 0)
{
[button setTag: NSAlertFirstButtonReturn];
[button setKeyEquivalent: @"\r"];
}
else
{
[button setTag: NSAlertFirstButtonReturn + count];
if ([aTitle isEqualToString: @"Cancel"])
{
[button setKeyEquivalent: @"\e"];
}
else if ([aTitle isEqualToString: @"Don't Save"])
{
[button setKeyEquivalent: @"D"];
[button setKeyEquivalentModifierMask: NSCommandKeyMask];
}
}
[_buttons addObject: button];
RELEASE(button);
return button;
}
- (NSArray *)buttons
{
return _buttons;
}
- (void)setShowsHelp:(BOOL)showsHelp
{
_shows_help = showsHelp;
}
- (BOOL)showsHelp
{
return _shows_help;
}
- (void)setHelpAnchor:(NSString *)anchor
{
ASSIGN(_help_anchor, anchor);
}
- (NSString *)helpAnchor
{
return _help_anchor;
}
- (void)setAlertStyle:(NSAlertStyle)style
{
_style = style;
}
- (NSAlertStyle)alertStyle
{
return _style;
}
- (void)setDelegate:(id)delegate
{
_delegate = delegate;
}
- (id)delegate
{
return _delegate;
}
- (int)runModal
{
// FIXME
return NSAlertFirstButtonReturn;
}
- (void)beginSheetModalForWindow:(NSWindow *)window
modalDelegate:(id)delegate
didEndSelector:(SEL)didEndSelector
contextInfo:(void *)contextInfo
{
// FIXME
}
- (id)window
{
return _window;
}
@end

163
Source/NSMovie.m Normal file
View file

@ -0,0 +1,163 @@
/** <title>NSMovie</title>
<abstract>Encapsulate a Quicktime movie</abstract>
Copyright <copy>(C) 2003 Free Software Foundation, Inc.</copy>
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: March 2003
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <Foundation/NSArray.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSData.h>
#include <Foundation/NSURL.h>
#include <AppKit/NSMovie.h>
#include <AppKit/NSPasteboard.h>
@implementation NSMovie
+ (NSArray*) movieUnfilteredFileTypes
{
return [NSArray arrayWithObject: @"mov"];
}
+ (NSArray*) movieUnfilteredPasteboardTypes
{
// FIXME
return [NSArray arrayWithObject: @"QuickTimeMovie"];
}
+ (BOOL) canInitWithPasteboard: (NSPasteboard*)pasteboard
{
NSArray *pbTypes = [pasteboard types];
NSArray *myTypes = [self movieUnfilteredPasteboardTypes];
return ([pbTypes firstObjectCommonWithArray: myTypes] != nil);
}
- (id) initWithData: (NSData *)movie
{
if (movie == nil)
{
RELEASE(self);
return nil;
}
[super init];
ASSIGN(_movie, movie);
return self;
}
- (id) initWithMovie: (void*)movie
{
//FIXME
return self;
}
- (id) initWithURL: (NSURL*)url byReference: (BOOL)byRef
{
NSData* data = [url resourceDataUsingCache: YES];
self = [self initWithData: data];
if (byRef)
{
ASSIGN(_url, url);
}
return self;
}
- (id) initWithPasteboard: (NSPasteboard*)pasteboard
{
NSString *type;
NSData* data;
type = [pasteboard availableTypeFromArray:
[isa movieUnfilteredPasteboardTypes]];
if (type == nil)
{
//NSArray *array = [pasteboard propertyListForType: NSFilenamesPboardType];
// FIXME
data = nil;
}
else
{
data = [pasteboard dataForType: type];
}
if (data == nil)
{
RELEASE(self);
return nil;
}
self = [self initWithData: data];
return self;
}
- (void) dealloc
{
TEST_RELEASE(_url);
TEST_RELEASE(_movie);
[super dealloc];
}
- (void*) QTMovie
{
return (void*)[_movie bytes];
}
- (NSURL*) URL
{
return _url;
}
// NSCopying protocoll
- (id) copyWithZone: (NSZone *)zone
{
NSMovie *new = (NSMovie*)NSCopyObject (self, 0, zone);
new->_movie = [_movie copyWithZone: zone];
new->_url = [_url copyWithZone: zone];
return new;
}
// NSCoding protocoll
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: _movie];
[aCoder encodeObject: _url];
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
ASSIGN (_movie, [aDecoder decodeObject]);
ASSIGN (_url, [aDecoder decodeObject]);
return self;
}
@end