mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Added NSProgressIndicator files
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4738 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
43e9b45cd3
commit
10e5bb5a8f
5 changed files with 382 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
1999-08-22 Gerrit van Dyk <gerritvd@decimax.com>
|
||||
|
||||
* Headers/NSProgressIndicator.h
|
||||
AppKit.h: Added ProgressIndicator
|
||||
* Source/NSProgressIndicator.m: Added ProgressIndicator. Only
|
||||
determinate Indicators works at this stage.
|
||||
|
||||
1999-08-21 Michael Hanni <mhanni@sprintmail.com>
|
||||
|
||||
* Source/NSCell.m: lots of fixes to editWithFrame, and fieldEditor
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
@class NSText,NSCStringText;
|
||||
// Controls
|
||||
@class NSControl, NSButton, NSTextField, NSScroller, NSBox, NSForm, NSMatrix;
|
||||
@class NSPopUpButton, NSSlider, NSBrowser, NSForm;
|
||||
@class NSPopUpButton, NSProgressIndicator, NSSlider, NSBrowser, NSForm;
|
||||
// Cells
|
||||
@class NSCell, NSActionCell, NSButtonCell, NSTextFieldCell, NSFormCell;
|
||||
@class NSSliderCell, NSMenuCell, NSBrowserCell, NSFormCell;
|
||||
|
@ -127,6 +127,7 @@
|
|||
#include <AppKit/NSPrintInfo.h>
|
||||
#include <AppKit/NSPrintOperation.h>
|
||||
#include <AppKit/NSPrintPanel.h>
|
||||
#include <AppKit/NSProgressIndicator.h>
|
||||
#include <AppKit/NSResponder.h>
|
||||
#include <AppKit/NSSavePanel.h>
|
||||
#include <AppKit/NSScreen.h>
|
||||
|
|
96
Headers/gnustep/gui/NSProgressIndicator.h
Normal file
96
Headers/gnustep/gui/NSProgressIndicator.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
NSProgressIndicator.h
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gerrit van Dyk <gerritvd@decimax.com>
|
||||
Date: 1999
|
||||
|
||||
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_NSProgressIndicator
|
||||
#define _GNUstep_H_NSProgressIndicator
|
||||
|
||||
#import <AppKit/NSView.h>
|
||||
|
||||
@interface NSProgressIndicator : NSView
|
||||
{
|
||||
BOOL isIndeterminate;
|
||||
BOOL isBezeled;
|
||||
BOOL usesThreadedAnimation;
|
||||
NSTimeInterval animationDelay;
|
||||
double doubleValue;
|
||||
double minValue;
|
||||
double maxValue;
|
||||
BOOL isVertical;
|
||||
}
|
||||
|
||||
//
|
||||
// Creating an Instance
|
||||
//
|
||||
- (id)initWithFrame:(NSRect)frameRect;
|
||||
|
||||
//
|
||||
// Animating the progress indicator
|
||||
//
|
||||
- (void)animate:(id)sender;
|
||||
- (NSTimeInterval)animationDelay;
|
||||
- (void)setAnimimationDelay:(NSTimeInterval)delay;
|
||||
- (void)startAnimation:(id)sender;
|
||||
- (void)stopAnimation:(id)sender;
|
||||
- (BOOL)usesThreadedAnimation;
|
||||
- (void)setUsesThreadedAnimation:(BOOL)flag;
|
||||
|
||||
//
|
||||
// Advancing the progress bar
|
||||
//
|
||||
- (void)incrementBy:(double)delta;
|
||||
- (double)doubleValue;
|
||||
- (void)setDoubleValue:(double)doubleValue;
|
||||
- (double)minValue;
|
||||
- (void)setMinValue:(double)newMinimum;
|
||||
- (double)maxValue;
|
||||
- (void)setMaxValue:(double)newMaximum;
|
||||
|
||||
//
|
||||
// Setting the appearance
|
||||
//
|
||||
- (BOOL)isBezeled;
|
||||
- (void)setBezeled:(BOOL)flag;
|
||||
- (BOOL)isIndeterminate;
|
||||
- (void)setIndeterminate:(BOOL)flag;
|
||||
|
||||
@end
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
@interface NSProgressIndicator (GNUstepExtensions)
|
||||
|
||||
/*
|
||||
* Enables Vertical ProgressBar
|
||||
*
|
||||
* If isVertical = YES, Progress is from the bottom to the top
|
||||
* If isVertical = NO, Progress is from the left to the right
|
||||
*/
|
||||
- (BOOL)isVertical;
|
||||
- (void)setVertical:(BOOL)flag;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
#endif /* _GNUstep_H_NSProgressIndicator */
|
|
@ -95,6 +95,7 @@ NSPrinter.m \
|
|||
NSPrintInfo.m \
|
||||
NSPrintOperation.m \
|
||||
NSPrintPanel.m \
|
||||
NSProgressIndicator.m \
|
||||
NSResponder.m \
|
||||
NSSavePanel.m \
|
||||
NSScreen.m \
|
||||
|
@ -199,6 +200,7 @@ AppKit/NSPrintInfo.h \
|
|||
AppKit/NSPrintOperation.h \
|
||||
AppKit/NSPrintPanel.h \
|
||||
AppKit/NSPrinter.h \
|
||||
AppKit/NSProgressIndicator.h \
|
||||
AppKit/NSResponder.h \
|
||||
AppKit/NSRulerMarker.h \
|
||||
AppKit/NSRulerView.h \
|
||||
|
|
275
Source/NSProgressIndicator.m
Normal file
275
Source/NSProgressIndicator.m
Normal file
|
@ -0,0 +1,275 @@
|
|||
/*
|
||||
NSProgressIndicator.m
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gerrit van Dyk <gerritvd@decimax.com>
|
||||
Date: 1999
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#import <AppKit/NSProgressIndicator.h>
|
||||
#import <AppKit/NSGraphics.h>
|
||||
#import <AppKit/NSColor.h>
|
||||
#import <AppKit/NSWindow.h>
|
||||
// #import <AppKit/NSDPSContext.h>
|
||||
|
||||
@interface NSProgressIndicator(PrivateMethods)
|
||||
- (void)_update;
|
||||
@end
|
||||
|
||||
@implementation NSProgressIndicator
|
||||
|
||||
- (id)initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
self = [super initWithFrame:frameRect];
|
||||
isIndeterminate = NO; // This should be changed to YES, to conform
|
||||
isBezeled = YES;
|
||||
isVertical = NO;
|
||||
usesThreadedAnimation = NO;
|
||||
animationDelay = 5.0 / 60.0; // 1 fifth a a second
|
||||
doubleValue = 0.0;
|
||||
minValue = 0.0;
|
||||
maxValue = 100.0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
// Nothing to dealloc at this stage
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)animate:(id)sender
|
||||
{
|
||||
// Not implemented
|
||||
}
|
||||
|
||||
- (NSTimeInterval)animationDelay { return animationDelay; }
|
||||
- (void)setAnimimationDelay:(NSTimeInterval)delay
|
||||
{
|
||||
animationDelay = delay;
|
||||
}
|
||||
|
||||
- (void)startAnimation:(id)sender
|
||||
{
|
||||
// Not implemented
|
||||
}
|
||||
|
||||
- (void)stopAnimation:(id)sender
|
||||
{
|
||||
// Not implemented
|
||||
}
|
||||
|
||||
- (BOOL)usesThreadedAnimation
|
||||
{
|
||||
return usesThreadedAnimation;
|
||||
}
|
||||
|
||||
- (void)setUsesThreadedAnimation:(BOOL)flag
|
||||
{
|
||||
usesThreadedAnimation = flag;
|
||||
// This method should be expanded to enable threading
|
||||
}
|
||||
|
||||
- (void)incrementBy:(double)delta
|
||||
{
|
||||
doubleValue += delta;
|
||||
[self setNeedsDisplay:YES];
|
||||
[self _update];
|
||||
}
|
||||
|
||||
- (double)doubleValue { return doubleValue; }
|
||||
- (void)setDoubleValue:(double)aValue
|
||||
{
|
||||
if (doubleValue != aValue)
|
||||
{
|
||||
doubleValue = aValue;
|
||||
[self setNeedsDisplay:YES];
|
||||
[self _update];
|
||||
}
|
||||
}
|
||||
|
||||
- (double)minValue { return minValue; }
|
||||
- (void)setMinValue:(double)newMinimum
|
||||
{
|
||||
if (minValue != newMinimum)
|
||||
{
|
||||
minValue = newMinimum;
|
||||
[self setNeedsDisplay:YES];
|
||||
[self _update];
|
||||
}
|
||||
}
|
||||
|
||||
- (double)maxValue { return maxValue; }
|
||||
- (void)setMaxValue:(double)newMaximum
|
||||
{
|
||||
if (maxValue != newMaximum)
|
||||
{
|
||||
maxValue = newMaximum;
|
||||
[self setNeedsDisplay:YES];
|
||||
[self _update];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isBezeled { return isBezeled; }
|
||||
- (void)setBezeled:(BOOL)flag
|
||||
{
|
||||
if (isBezeled != flag)
|
||||
{
|
||||
isBezeled = flag;
|
||||
[self setNeedsDisplay:YES];
|
||||
[self _update];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isIndeterminate { return isIndeterminate; }
|
||||
- (void)setIndeterminate:(BOOL)flag
|
||||
{
|
||||
isIndeterminate = flag;
|
||||
isIndeterminate = NO; // Just for now
|
||||
// Maybe we need more functionality here when we implement indeterminate
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)rect
|
||||
{
|
||||
NSRect bnds,r;
|
||||
|
||||
bnds = [self bounds];
|
||||
|
||||
// Draw the Bezel
|
||||
if (isBezeled)
|
||||
NSDrawGrayBezel(bnds,rect);
|
||||
|
||||
// Calc the inside rect to be drawn
|
||||
if (isBezeled)
|
||||
{
|
||||
r = NSMakeRect(NSMinX(bnds) + 2.0,
|
||||
NSMinY(bnds) + 2.0,
|
||||
NSWidth(bnds) - 4.0,
|
||||
NSHeight(bnds) - 4.0);
|
||||
}
|
||||
else
|
||||
r = bnds;
|
||||
|
||||
if (isIndeterminate) // Draw indeterminate
|
||||
{
|
||||
// Do nothing at this stage
|
||||
}
|
||||
else // Draw determinate
|
||||
{
|
||||
if (doubleValue > minValue)
|
||||
{
|
||||
if (isVertical)
|
||||
r.size.height =
|
||||
NSHeight(r) * (doubleValue / (maxValue - minValue));
|
||||
else
|
||||
r.size.width =
|
||||
NSWidth(r) * (doubleValue / (maxValue - minValue));
|
||||
r = NSIntersectionRect(r,rect);
|
||||
if (!NSIsEmptyRect(r))
|
||||
{
|
||||
[[NSColor blueColor] set];
|
||||
NSRectFill(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// It does not seem that Gnustep has a copyWithZone: on NSView, it is private
|
||||
// under openstep
|
||||
|
||||
// NSCopying
|
||||
/* - (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
NSProgressIndicator *newInd;
|
||||
|
||||
newInd = [super copyWithZone:zone];
|
||||
[newInd setIndeterminate:isIndeterminate];
|
||||
[newInd setBezeled:isBezeled];
|
||||
[newInd setUsesThreadedAnimation:usesThreadedAnimation];
|
||||
[newInd setAnimimationDelay:animationDelay];
|
||||
[newInd setDoubleValue:doubleValue];
|
||||
[newInd setMinValue:minValue];
|
||||
[newInd setMaxValue:maxValue];
|
||||
[newInd setVertical:isVertical];
|
||||
return newInd;
|
||||
}
|
||||
*/
|
||||
|
||||
// NSCoding
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&isIndeterminate];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&isBezeled];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&usesThreadedAnimation];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTimeInterval) at:&animationDelay];
|
||||
[aCoder encodeValueOfObjCType: @encode(double) at:&doubleValue];
|
||||
[aCoder encodeValueOfObjCType: @encode(double) at:&minValue];
|
||||
[aCoder encodeValueOfObjCType: @encode(double) at:&maxValue];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at:&isVertical];
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
self = [super initWithCoder:aDecoder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&isIndeterminate];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&isBezeled];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&usesThreadedAnimation];
|
||||
[aDecoder decodeValueOfObjCType: @encode(NSTimeInterval)
|
||||
at:&animationDelay];
|
||||
[aDecoder decodeValueOfObjCType: @encode(double) at:&doubleValue];
|
||||
[aDecoder decodeValueOfObjCType: @encode(double) at:&minValue];
|
||||
[aDecoder decodeValueOfObjCType: @encode(double) at:&maxValue];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&isVertical];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSProgressIndicator (GNUstepExtensions)
|
||||
|
||||
- (BOOL)isVertical { return isVertical; }
|
||||
- (void)setVertical:(BOOL)flag
|
||||
{
|
||||
if (isVertical != flag)
|
||||
{
|
||||
isVertical = flag;
|
||||
[self setNeedsDisplay:YES];
|
||||
[self _update];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSProgressIndicator(PrivateMethods)
|
||||
|
||||
- (void)_update
|
||||
{
|
||||
if ([self window] != nil)
|
||||
if ([[self window] isVisible])
|
||||
{
|
||||
[[self window] display];
|
||||
#warning It does not seem that GNUstep has a NSDPSContext
|
||||
// [[NSDPSContext currentContext] flush];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue