[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSSplitView patch
From: |
Enrico Sersale |
Subject: |
NSSplitView patch |
Date: |
Sat, 15 Feb 2003 13:16:21 +0200 (EET) |
NSSplitView is broken because, in -mouseDown:, it uses un IMP for the
delegate method -splitView:constrainSplitPosition:ofSubviewAt: that
returns a float.
It should be declared something like:
typedef float (*floatIMP)(id, SEL, id, float, int);
Moreover, actually, the return value of the delegate method is ignored.
This patch fixes the problem.
--- NSSplitView.m Sat Feb 15 12:49:20 2003
+++ ../../../CVS/core/gui/Source/NSSplitView.m Thu Jan 30 06:28:18 2003
@@ -104,7 +104,6 @@
static NSRect oldRect; //only one can be dragged at a time
static BOOL lit = NO;
NSPoint p;
- NSPoint costrP;
NSEvent *e;
NSRect r, r1, bigRect, vis;
id v = nil, prev = nil;
@@ -119,8 +118,8 @@
BOOL delegateConstrains = NO;
SEL constrainSel =
@selector(splitView:constrainSplitPosition:ofSubviewAt:);
- typedef float (*floatIMP)(id, SEL, id, float, int);
- floatIMP constrainImp = 0;
+ IMP constrainImp = 0;
+
/* if there are less the two subviews, there is nothing to do */
if (count < 2)
@@ -290,8 +289,7 @@
if (delegateConstrains)
{
- constrainImp = (floatIMP)[_delegate methodForSelector:
constrainSel];
-
+ constrainImp = [_delegate methodForSelector: constrainSel];
}
// user is moving the knob loop until left mouse up
@@ -306,22 +304,19 @@
p.x = [_delegate splitView: self constrainSplitPosition:
p.x
ofSubviewAt: offset];
*/
- costrP.y = p.y;
- costrP.x = (*constrainImp)(_delegate, constrainSel, self, p.x,
offset);
- }
+ (*constrainImp)(_delegate, constrainSel, self,
+ p.x, offset);
+ }
else
{
/*
p.y = [_delegate splitView: self constrainSplitPosition:
p.y
ofSubviewAt: offset];
*/
- costrP.x = p.x;
- costrP.y = (*constrainImp)(_delegate, constrainSel, self,
p.y, offset);
+ (*constrainImp)(_delegate, constrainSel, self,
+ p.y, offset);
}
- } else {
- costrP.x = p.x;
- costrP.y = p.y;
- }
+ }
if (_isVertical == NO)
{
@@ -541,7 +536,7 @@
r = [prev frame];
if (_isVertical == NO)
{
- r.size.height = costrP.y - NSMinY(bigRect) - (divVertical/2.);
+ r.size.height = p.y - NSMinY(bigRect) - (divVertical/2.);
if (NSHeight(r) < 1.)
{
r.size.height = 1.;
@@ -549,7 +544,7 @@
}
else
{
- r.size.width = costrP.x - NSMinX(bigRect) - (divHorizontal/2.);
+ r.size.width = p.x - NSMinX(bigRect) - (divHorizontal/2.);
if (NSWidth(r) < 1.)
{
r.size.width = 1.;
@@ -562,7 +557,7 @@
r1 = [v frame];
if (_isVertical == NO)
{
- r1.origin.y = costrP.y + (divVertical/2.);
+ r1.origin.y = p.y + (divVertical/2.);
if (NSMinY(r1) < 0.)
{
r1.origin.y = 0.;
@@ -575,7 +570,7 @@
}
else
{
- r1.origin.x = costrP.x + (divHorizontal/2.);
+ r1.origin.x = p.x + (divHorizontal/2.);
if (NSMinX(r1) < 0.)
{
r1.origin.x = 0.;
- NSSplitView patch,
Enrico Sersale <=