mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 19:31:00 +00:00
Compatibnility fixes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3909 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d4546cd5dc
commit
f1c05d996a
3 changed files with 106 additions and 85 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Sun Mar 14 10:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Source/NSScroller.m: Rewrite and tidy various stuff to bring into
|
||||||
|
conformance with MacOS-X documentation and to be more compatible -
|
||||||
|
Scrollers are now flipped views.
|
||||||
|
* Source/NSScrollView.m: Minor changes to work with corrections to
|
||||||
|
NSScroller.
|
||||||
|
|
||||||
Thu Mar 11 Felipe A. Rodriguez <farz@mindspring.com>
|
Thu Mar 11 Felipe A. Rodriguez <farz@mindspring.com>
|
||||||
|
|
||||||
* gui/Images: common_Right.tiff add alpha channel to image.
|
* gui/Images: common_Right.tiff add alpha channel to image.
|
||||||
|
|
|
@ -304,7 +304,7 @@ static Class rulerViewClass = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([_contentView isFlipped])
|
if (![_contentView isFlipped])
|
||||||
{
|
{
|
||||||
// If view is flipped
|
// If view is flipped
|
||||||
// reverse the scroll direction
|
// reverse the scroll direction
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
Date: July 1997
|
Date: July 1997
|
||||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
Date: August 1998
|
Date: August 1998
|
||||||
|
Author: Richard frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
Date: Mar 1999 - Use flipped views and make conform to spec
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
@ -47,10 +49,10 @@
|
||||||
//
|
//
|
||||||
// Class variables
|
// Class variables
|
||||||
//
|
//
|
||||||
static NSButtonCell* upCell = nil; // button cells used by
|
static NSButtonCell* upCell = nil; // button cells used by
|
||||||
static NSButtonCell* downCell = nil; // scroller instances
|
static NSButtonCell* downCell = nil; // scroller instances
|
||||||
static NSButtonCell* leftCell = nil; // to draw scroller
|
static NSButtonCell* leftCell = nil; // to draw scroller
|
||||||
static NSButtonCell* rightCell = nil; // buttons and knob.
|
static NSButtonCell* rightCell = nil; // buttons and knob.
|
||||||
static NSButtonCell* knobCell = nil;
|
static NSButtonCell* knobCell = nil;
|
||||||
|
|
||||||
static const float scrollerWidth = 17;
|
static const float scrollerWidth = 17;
|
||||||
|
@ -82,6 +84,11 @@ static BOOL preCalcValues = NO;
|
||||||
return scrollerWidth;
|
return scrollerWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isFlipped
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSScrollArrowPosition) arrowsPosition
|
- (NSScrollArrowPosition) arrowsPosition
|
||||||
{
|
{
|
||||||
return _arrowsPosition;
|
return _arrowsPosition;
|
||||||
|
@ -158,9 +165,15 @@ static BOOL preCalcValues = NO;
|
||||||
[super initWithFrame: frameRect];
|
[super initWithFrame: frameRect];
|
||||||
|
|
||||||
if (_isHorizontal)
|
if (_isHorizontal)
|
||||||
_arrowsPosition = NSScrollerArrowsMinEnd;
|
{
|
||||||
|
_arrowsPosition = NSScrollerArrowsMinEnd;
|
||||||
|
_floatValue = 0.0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_arrowsPosition = NSScrollerArrowsMaxEnd;
|
{
|
||||||
|
_arrowsPosition = NSScrollerArrowsMaxEnd;
|
||||||
|
_floatValue = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
_hitPart = NSScrollerNoPart;
|
_hitPart = NSScrollerNoPart;
|
||||||
[self drawParts];
|
[self drawParts];
|
||||||
|
@ -239,16 +252,26 @@ static BOOL preCalcValues = NO;
|
||||||
|
|
||||||
- (void) checkSpaceForParts
|
- (void) checkSpaceForParts
|
||||||
{
|
{
|
||||||
NSSize frameSize = [self frame].size;
|
NSSize frameSize = [self frame].size;
|
||||||
float size = (_isHorizontal ? frameSize.width : frameSize.height);
|
float size = (_isHorizontal ? frameSize.width : frameSize.height);
|
||||||
float scrollerWidth = [isa scrollerWidth];
|
float scrollerWidth = [isa scrollerWidth];
|
||||||
|
|
||||||
if (size > 3 * scrollerWidth + 2)
|
if (_arrowsPosition == NSScrollerArrowsNone)
|
||||||
_usableParts = NSAllScrollerParts;
|
{
|
||||||
else if (size > 2 * scrollerWidth + 1)
|
if (size > scrollerWidth + 1)
|
||||||
_usableParts = NSOnlyScrollerArrows;
|
_usableParts = NSAllScrollerParts;
|
||||||
|
else
|
||||||
|
_usableParts = NSNoScrollerParts;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_usableParts = NSNoScrollerParts;
|
{
|
||||||
|
if (size > 3 * scrollerWidth + 2)
|
||||||
|
_usableParts = NSAllScrollerParts;
|
||||||
|
else if (size > 2 * scrollerWidth + 1)
|
||||||
|
_usableParts = NSOnlyScrollerArrows;
|
||||||
|
else
|
||||||
|
_usableParts = NSNoScrollerParts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setEnabled: (BOOL)flag
|
- (void) setEnabled: (BOOL)flag
|
||||||
|
@ -346,10 +369,6 @@ static BOOL preCalcValues = NO;
|
||||||
if ([self mouse: thePoint inRect: rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerKnob;
|
return NSScrollerKnob;
|
||||||
|
|
||||||
rect = [self rectForPart: NSScrollerKnobSlot];
|
|
||||||
if ([self mouse: thePoint inRect: rect])
|
|
||||||
return NSScrollerKnobSlot;
|
|
||||||
|
|
||||||
rect = [self rectForPart: NSScrollerDecrementPage];
|
rect = [self rectForPart: NSScrollerDecrementPage];
|
||||||
if ([self mouse: thePoint inRect: rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerDecrementPage;
|
return NSScrollerDecrementPage;
|
||||||
|
@ -358,6 +377,10 @@ static BOOL preCalcValues = NO;
|
||||||
if ([self mouse: thePoint inRect: rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerIncrementPage;
|
return NSScrollerIncrementPage;
|
||||||
|
|
||||||
|
rect = [self rectForPart: NSScrollerKnobSlot];
|
||||||
|
if ([self mouse: thePoint inRect: rect])
|
||||||
|
return NSScrollerKnobSlot;
|
||||||
|
|
||||||
return NSScrollerNoPart;
|
return NSScrollerNoPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +429,6 @@ static BOOL preCalcValues = NO;
|
||||||
// Compute float value given the knob size
|
// Compute float value given the knob size
|
||||||
floatValue = (position - (slotRect.origin.y + halfKnobRectHeight)) /
|
floatValue = (position - (slotRect.origin.y + halfKnobRectHeight)) /
|
||||||
(slotRect.size.height - knobRect.size.height);
|
(slotRect.size.height - knobRect.size.height);
|
||||||
floatValue = 1 - floatValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return floatValue;
|
return floatValue;
|
||||||
|
@ -463,7 +485,6 @@ static BOOL preCalcValues = NO;
|
||||||
|
|
||||||
floatValue = (position - slotOriginPlusKnobHeight) /
|
floatValue = (position - slotOriginPlusKnobHeight) /
|
||||||
slotHeightMinusKnobHeight;
|
slotHeightMinusKnobHeight;
|
||||||
floatValue = 1 - floatValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return floatValue;
|
return floatValue;
|
||||||
|
@ -627,12 +648,12 @@ static BOOL preCalcValues = NO;
|
||||||
{
|
{
|
||||||
case NSScrollerIncrementLine:
|
case NSScrollerIncrementLine:
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
theCell = (_isHorizontal ? rightCell : upCell);
|
theCell = (_isHorizontal ? rightCell : downCell);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollerDecrementLine:
|
case NSScrollerDecrementLine:
|
||||||
case NSScrollerDecrementPage:
|
case NSScrollerDecrementPage:
|
||||||
theCell = (_isHorizontal ? leftCell : downCell);
|
theCell = (_isHorizontal ? leftCell : upCell);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -681,11 +702,11 @@ static BOOL preCalcValues = NO;
|
||||||
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
|
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
|
||||||
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||||
|
|
||||||
|
[self drawKnobSlot];
|
||||||
|
[self drawKnob];
|
||||||
[self drawArrow: NSScrollerDecrementArrow highlight: NO];
|
[self drawArrow: NSScrollerDecrementArrow highlight: NO];
|
||||||
[self drawArrow: NSScrollerIncrementArrow highlight: NO];
|
[self drawArrow: NSScrollerIncrementArrow highlight: NO];
|
||||||
|
|
||||||
[self drawKnobSlot];
|
|
||||||
[self drawKnob];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawArrow: (NSScrollerArrow)whichButton highlight: (BOOL)flag
|
- (void) drawArrow: (NSScrollerArrow)whichButton highlight: (BOOL)flag
|
||||||
|
@ -701,10 +722,10 @@ static BOOL preCalcValues = NO;
|
||||||
switch (whichButton)
|
switch (whichButton)
|
||||||
{
|
{
|
||||||
case NSScrollerDecrementArrow:
|
case NSScrollerDecrementArrow:
|
||||||
theCell = (_isHorizontal ? leftCell : downCell);
|
theCell = (_isHorizontal ? leftCell : upCell);
|
||||||
break;
|
break;
|
||||||
case NSScrollerIncrementArrow:
|
case NSScrollerIncrementArrow:
|
||||||
theCell = (_isHorizontal ? rightCell : upCell);
|
theCell = (_isHorizontal ? rightCell : downCell);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,11 +751,30 @@ static BOOL preCalcValues = NO;
|
||||||
NSRectFill(rect);
|
NSRectFill(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) highlight: (BOOL)flag
|
||||||
|
{
|
||||||
|
switch (_hitPart)
|
||||||
|
{
|
||||||
|
case NSScrollerIncrementLine:
|
||||||
|
case NSScrollerIncrementPage:
|
||||||
|
[self drawArrow: NSScrollerIncrementArrow highlight: flag];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSScrollerDecrementLine:
|
||||||
|
case NSScrollerDecrementPage:
|
||||||
|
[self drawArrow: NSScrollerDecrementArrow highlight: flag];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // No button currently hit for highlighting.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSRect) rectForPart: (NSScrollerPart)partCode
|
- (NSRect) rectForPart: (NSScrollerPart)partCode
|
||||||
{
|
{
|
||||||
NSRect scrollerFrame = frame;
|
NSRect scrollerFrame = frame;
|
||||||
float x = 1, y = 1, width = 0, height = 0, floatValue;
|
float x = 0, y = 0;
|
||||||
NSScrollArrowPosition arrowsPosition;
|
float width, height;
|
||||||
NSUsableScrollerParts usableParts;
|
NSUsableScrollerParts usableParts;
|
||||||
// If the scroller is disabled then the scroller buttons and the
|
// If the scroller is disabled then the scroller buttons and the
|
||||||
// knob are not displayed at all.
|
// knob are not displayed at all.
|
||||||
|
@ -743,41 +783,21 @@ static BOOL preCalcValues = NO;
|
||||||
else
|
else
|
||||||
usableParts = _usableParts;
|
usableParts = _usableParts;
|
||||||
|
|
||||||
// Since we haven't yet flipped views we have
|
|
||||||
// to swap the meaning of the arrows position
|
|
||||||
// if the scroller's orientation is vertical.
|
|
||||||
if (!_isHorizontal)
|
|
||||||
{
|
|
||||||
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
|
||||||
arrowsPosition = NSScrollerArrowsMinEnd;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
|
||||||
arrowsPosition = NSScrollerArrowsMaxEnd;
|
|
||||||
else
|
|
||||||
arrowsPosition = NSScrollerArrowsNone;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
arrowsPosition = _arrowsPosition;
|
|
||||||
|
|
||||||
// Assign to `width' and `height' values describing
|
// Assign to `width' and `height' values describing
|
||||||
// the width and height of the scroller regardless
|
// the width and height of the scroller regardless
|
||||||
// of its orientation. Also compute the `floatValue'
|
// of its orientation.
|
||||||
// which is essentially the same width as _floatValue
|
|
||||||
// but keeps track of the scroller's orientation.
|
// but keeps track of the scroller's orientation.
|
||||||
if (_isHorizontal)
|
if (_isHorizontal)
|
||||||
{
|
{
|
||||||
width = scrollerFrame.size.height;
|
width = scrollerFrame.size.height;
|
||||||
height = scrollerFrame.size.width;
|
height = scrollerFrame.size.width;
|
||||||
floatValue = _floatValue;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
width = scrollerFrame.size.width;
|
width = scrollerFrame.size.width;
|
||||||
height = scrollerFrame.size.height;
|
height = scrollerFrame.size.height;
|
||||||
floatValue = 1 - _floatValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The x, y, width and height values are computed below for the vertical
|
// The x, y, width and height values are computed below for the vertical
|
||||||
// scroller. The height of the scroll buttons is assumed to be equal to
|
// scroller. The height of the scroll buttons is assumed to be equal to
|
||||||
// the width.
|
// the width.
|
||||||
|
@ -791,17 +811,17 @@ static BOOL preCalcValues = NO;
|
||||||
usableParts == NSOnlyScrollerArrows)
|
usableParts == NSOnlyScrollerArrows)
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
// calc the slot Height
|
// calc the slot Height
|
||||||
slotHeight = height - (arrowsPosition == NSScrollerArrowsNone ?
|
slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone ?
|
||||||
0 : 2 * (buttonsWidth + buttonsDistance));
|
0 : 2 * (buttonsWidth + buttonsDistance));
|
||||||
knobHeight = _knobProportion * slotHeight;
|
knobHeight = _knobProportion * slotHeight;
|
||||||
if (knobHeight < buttonsWidth)
|
if (knobHeight < buttonsWidth)
|
||||||
knobHeight = buttonsWidth;
|
knobHeight = buttonsWidth;
|
||||||
// calc knob's position
|
// calc knob's position
|
||||||
knobPosition = floatValue * (slotHeight - knobHeight);
|
knobPosition = _floatValue * (slotHeight - knobHeight);
|
||||||
knobPosition = (float)floor(knobPosition); // avoid rounding error
|
knobPosition = (float)floor(knobPosition); // avoid rounding error
|
||||||
// calc actual position
|
// calc actual position
|
||||||
y = knobPosition + (arrowsPosition == NSScrollerArrowsMaxEnd
|
y = knobPosition + (_arrowsPosition == NSScrollerArrowsMaxEnd
|
||||||
|| arrowsPosition == NSScrollerArrowsNone ?
|
|| _arrowsPosition == NSScrollerArrowsNone ?
|
||||||
0 : 2 * (buttonsWidth + buttonsDistance));
|
0 : 2 * (buttonsWidth + buttonsDistance));
|
||||||
height = knobHeight;
|
height = knobHeight;
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
|
@ -813,27 +833,18 @@ static BOOL preCalcValues = NO;
|
||||||
case NSScrollerKnobSlot:
|
case NSScrollerKnobSlot:
|
||||||
// if the scroller does not have buttons the slot completely
|
// if the scroller does not have buttons the slot completely
|
||||||
// fills the scroller.
|
// fills the scroller.
|
||||||
x = 0;
|
|
||||||
width = scrollerWidth;
|
|
||||||
if (usableParts == NSNoScrollerParts)
|
if (usableParts == NSNoScrollerParts)
|
||||||
{
|
{
|
||||||
y = 0; // `height' unchanged
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (arrowsPosition == NSScrollerArrowsMaxEnd)
|
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
{
|
{
|
||||||
y = 0;
|
height -= 2 * (buttonsWidth + buttonsDistance);
|
||||||
height -= 2 * (buttonsWidth + buttonsDistance) + 1;
|
|
||||||
}
|
}
|
||||||
else
|
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
||||||
{
|
{
|
||||||
if (arrowsPosition == NSScrollerArrowsMinEnd)
|
y = 2 * (buttonsWidth + buttonsDistance);
|
||||||
{
|
height -= y;
|
||||||
y = 2 * (buttonsWidth + buttonsDistance) + 1;
|
|
||||||
height -= y;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
y = 0; // `height' unchanged
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -842,16 +853,17 @@ static BOOL preCalcValues = NO;
|
||||||
// if scroller has no parts or knob then return a zero rect
|
// if scroller has no parts or knob then return a zero rect
|
||||||
if (usableParts == NSNoScrollerParts)
|
if (usableParts == NSNoScrollerParts)
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
width = buttonsWidth;
|
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
if (arrowsPosition == NSScrollerArrowsMaxEnd)
|
|
||||||
y = height - 2 * (buttonsWidth + buttonsDistance);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (arrowsPosition == NSScrollerArrowsMinEnd)
|
y = height - 2 * (buttonsWidth + buttonsDistance);
|
||||||
y = 1;
|
|
||||||
else
|
|
||||||
return NSZeroRect;
|
|
||||||
}
|
}
|
||||||
|
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
||||||
|
{
|
||||||
|
y = buttonsDistance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NSZeroRect;
|
||||||
|
width = buttonsWidth;
|
||||||
height = buttonsWidth;
|
height = buttonsWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -859,17 +871,18 @@ static BOOL preCalcValues = NO;
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
if (usableParts == NSNoScrollerParts)
|
if (usableParts == NSNoScrollerParts)
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
width = buttonsWidth;
|
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
if (arrowsPosition == NSScrollerArrowsMaxEnd)
|
|
||||||
y = height - (buttonsWidth + buttonsDistance);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (arrowsPosition == NSScrollerArrowsMinEnd)
|
y = height - (buttonsWidth + buttonsDistance);
|
||||||
y = buttonsWidth + buttonsDistance + 1;
|
|
||||||
else
|
|
||||||
return NSZeroRect;
|
|
||||||
}
|
}
|
||||||
|
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
||||||
|
{
|
||||||
|
y = buttonsWidth + buttonsDistance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NSZeroRect;
|
||||||
height = buttonsWidth;
|
height = buttonsWidth;
|
||||||
|
width = buttonsWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollerNoPart:
|
case NSScrollerNoPart:
|
||||||
|
|
Loading…
Reference in a new issue