mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 19:30:59 +00:00
Fix up lockFocus, restoring graphics context.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4243 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7b54630f98
commit
115b3cdbf6
12 changed files with 129 additions and 12 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
||||||
|
1999-05-11 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSButtonCell.m ([NSButtonCell
|
||||||
|
-drawInteriorWithFrame:inView:]): gsave/grestore around image/text
|
||||||
|
to return to original clipping rect for second half of drawing.
|
||||||
|
|
||||||
|
* Source/NSCell.m ([NSCell -_drawText:title:cellFrame]): PointSize
|
||||||
|
does not include descender.
|
||||||
|
(-highlight:withFrame:inView:): gsave/grestore to return to
|
||||||
|
original for second highlight call.
|
||||||
|
|
||||||
|
* Source/NSControl.m ([NSControl -mouseDown:]): Remove extra
|
||||||
|
lockFocus.
|
||||||
|
|
||||||
|
* Source/NSMenu.m ([NSMenuMatrix -initWithFrame:]): Font descender
|
||||||
|
is a negative number.
|
||||||
|
* Source/NSStringDrawing.m (sizeLine): Likewise.
|
||||||
|
(setupRun): Likewise.
|
||||||
|
(drawRun): Awful hack to get DGS to flush strings.
|
||||||
|
|
||||||
|
* Headers/gnustep/gui/DPSOperators.h (DPSflush): Added operator.
|
||||||
|
* Headers/gnustep/gui/GSMethodTable.h: Likewise.
|
||||||
|
* Headers/gnustep/gui/NSGraphicsContext.h: Likewise.
|
||||||
|
* Headers/gnustep/gui/PSOperators.h: Likewise.
|
||||||
|
* Source/NSGraphicsContext.m: Likewise.
|
||||||
|
|
||||||
Mon May 10 9:50:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Mon May 10 9:50:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Headers/AppKit/NSGraphicsContext.h: Added GSCurrentContext() for
|
* Headers/AppKit/NSGraphicsContext.h: Added GSCurrentContext() for
|
||||||
|
|
|
@ -340,6 +340,13 @@ static inline void
|
||||||
DPStranslate(GSCTXT *ctxt, float x, float y)
|
DPStranslate(GSCTXT *ctxt, float x, float y)
|
||||||
__attribute__((unused));
|
__attribute__((unused));
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* I/O Operations operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
static inline void
|
||||||
|
DPSflush(GSCTXT *ctxt)
|
||||||
|
__attribute__((unused));
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -1223,6 +1230,16 @@ DPStranslate(GSCTXT *ctxt, float x, float y)
|
||||||
(ctxt, @selector(DPStranslate::), x, y);
|
(ctxt, @selector(DPStranslate::), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* I/O Operations operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
static inline void
|
||||||
|
DPSflush(GSCTXT *ctxt)
|
||||||
|
{
|
||||||
|
(ctxt->methods->DPSflush)
|
||||||
|
(ctxt, @selector(DPSflush));
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -196,6 +196,11 @@ typedef struct {
|
||||||
void (*DPStranslate__)
|
void (*DPStranslate__)
|
||||||
(NSGraphicsContext*, SEL, float, float);
|
(NSGraphicsContext*, SEL, float, float);
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* I/O operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
void (*DPSflush)
|
||||||
|
(NSGraphicsContext*, SEL);
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
void (*DPSconcatmatrix)
|
void (*DPSconcatmatrix)
|
||||||
|
|
|
@ -229,6 +229,10 @@ NSGraphicsContext *GSCurrentContext();
|
||||||
- (void) DPSsettransfer;
|
- (void) DPSsettransfer;
|
||||||
- (void) DPStranslate: (float)x : (float)y ;
|
- (void) DPStranslate: (float)x : (float)y ;
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* I/O operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
- (void) DPSflush;
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
- (void) DPSconcatmatrix;
|
- (void) DPSconcatmatrix;
|
||||||
|
|
|
@ -340,6 +340,13 @@ static inline void
|
||||||
PStranslate(float x, float y)
|
PStranslate(float x, float y)
|
||||||
__attribute__((unused));
|
__attribute__((unused));
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* I/O Operations operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
static inline void
|
||||||
|
PSflush()
|
||||||
|
__attribute__((unused));
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -1147,6 +1154,15 @@ PStranslate(float x, float y)
|
||||||
DPStranslate(DEFCTXT, x, y);
|
DPStranslate(DEFCTXT, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* I/O Operations operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
static inline void
|
||||||
|
PSflush()
|
||||||
|
{
|
||||||
|
DPSflush(DEFCTXT);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -54,10 +54,10 @@ ADDITIONAL_CPPFLAGS = -DGNUSTEP_INSTALL_LIBDIR=\"$(GNUSTEP_INSTALL_LIBDIR)\" \
|
||||||
|
|
||||||
|
|
||||||
# Additional flags to pass to the Objective-C compiler
|
# Additional flags to pass to the Objective-C compiler
|
||||||
ADDITIONAL_OBJCFLAGS = -g -Wall
|
ADDITIONAL_OBJCFLAGS = -Wall
|
||||||
|
|
||||||
# Additional flags to pass to the C compiler
|
# Additional flags to pass to the C compiler
|
||||||
ADDITIONAL_CFLAGS = -g
|
ADDITIONAL_CFLAGS =
|
||||||
|
|
||||||
# Additional include directories the compiler should search
|
# Additional include directories the compiler should search
|
||||||
ADDITIONAL_INCLUDE_DIRS = -I../Headers
|
ADDITIONAL_INCLUDE_DIRS = -I../Headers
|
||||||
|
|
|
@ -501,7 +501,11 @@
|
||||||
rect.origin = cellFrame.origin;
|
rect.origin = cellFrame.origin;
|
||||||
rect.size.width = imageSize.width;
|
rect.size.width = imageSize.width;
|
||||||
rect.size.height = cellFrame.size.height;
|
rect.size.height = cellFrame.size.height;
|
||||||
|
/* Have to save the gstate, since a new clip rect may be defined
|
||||||
|
when drawing */
|
||||||
|
PSgsave();
|
||||||
[self _drawImage: imageToDisplay inFrame: rect];
|
[self _drawImage: imageToDisplay inFrame: rect];
|
||||||
|
PSgrestore();
|
||||||
|
|
||||||
// draw title
|
// draw title
|
||||||
rect.origin.x += imageSize.width + xDist;
|
rect.origin.x += imageSize.width + xDist;
|
||||||
|
@ -515,7 +519,11 @@
|
||||||
rect.origin.y = cellFrame.origin.y;
|
rect.origin.y = cellFrame.origin.y;
|
||||||
rect.size.width = imageSize.width;
|
rect.size.width = imageSize.width;
|
||||||
rect.size.height = cellFrame.size.height;
|
rect.size.height = cellFrame.size.height;
|
||||||
|
/* Have to save the gstate, since a new clip rect may be defined
|
||||||
|
when drawing */
|
||||||
|
PSgsave();
|
||||||
[self _drawImage: imageToDisplay inFrame: rect];
|
[self _drawImage: imageToDisplay inFrame: rect];
|
||||||
|
PSgrestore();
|
||||||
|
|
||||||
// draw title
|
// draw title
|
||||||
rect.origin = cellFrame.origin;
|
rect.origin = cellFrame.origin;
|
||||||
|
@ -527,7 +535,11 @@
|
||||||
case NSImageBelow:
|
case NSImageBelow:
|
||||||
// draw image below title
|
// draw image below title
|
||||||
cellFrame.size.height /= 2;
|
cellFrame.size.height /= 2;
|
||||||
|
/* Have to save the gstate, since a new clip rect may be defined
|
||||||
|
when drawing */
|
||||||
|
PSgsave();
|
||||||
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
||||||
|
PSgrestore();
|
||||||
cellFrame.origin.y += cellFrame.size.height;
|
cellFrame.origin.y += cellFrame.size.height;
|
||||||
[self _drawText: titleToDisplay inFrame: cellFrame];
|
[self _drawText: titleToDisplay inFrame: cellFrame];
|
||||||
break;
|
break;
|
||||||
|
@ -535,14 +547,22 @@
|
||||||
case NSImageAbove:
|
case NSImageAbove:
|
||||||
// draw image above title
|
// draw image above title
|
||||||
cellFrame.size.height /= 2;
|
cellFrame.size.height /= 2;
|
||||||
|
/* Have to save the gstate, since a new clip rect may be defined
|
||||||
|
when drawing */
|
||||||
|
PSgsave();
|
||||||
[self _drawText: titleToDisplay inFrame: cellFrame];
|
[self _drawText: titleToDisplay inFrame: cellFrame];
|
||||||
|
PSgrestore();
|
||||||
cellFrame.origin.y += cellFrame.size.height;
|
cellFrame.origin.y += cellFrame.size.height;
|
||||||
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageOverlaps:
|
case NSImageOverlaps:
|
||||||
// draw title over the image
|
// draw title over the image
|
||||||
|
/* Have to save the gstate, since a new clip rect may be defined
|
||||||
|
when drawing */
|
||||||
|
PSgsave();
|
||||||
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
||||||
|
PSgrestore();
|
||||||
[self _drawText: titleToDisplay inFrame: cellFrame];
|
[self _drawText: titleToDisplay inFrame: cellFrame];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -573,7 +573,7 @@
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Request to draw a text cell but no font specified!"];
|
format: @"Request to draw a text cell but no font specified!"];
|
||||||
titleWidth = [font widthOfString: title];
|
titleWidth = [font widthOfString: title];
|
||||||
titleHeight = [font pointSize];
|
titleHeight = [font pointSize] - [font descender];
|
||||||
|
|
||||||
// Determine the y position of the text
|
// Determine the y position of the text
|
||||||
cellFrame.origin.y = NSMidY (cellFrame) - titleHeight / 2;
|
cellFrame.origin.y = NSMidY (cellFrame) - titleHeight / 2;
|
||||||
|
@ -708,7 +708,9 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
|
||||||
if (cell_highlighted != lit)
|
if (cell_highlighted != lit)
|
||||||
{
|
{
|
||||||
cell_highlighted = lit;
|
cell_highlighted = lit;
|
||||||
|
PSgsave();
|
||||||
[self drawWithFrame: cellFrame inView: controlView];
|
[self drawWithFrame: cellFrame inView: controlView];
|
||||||
|
PSgrestore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,6 @@ static id _NSCONTROL_CELL_CLASS = nil;
|
||||||
|
|
||||||
if (mouseUp)
|
if (mouseUp)
|
||||||
{
|
{
|
||||||
[self lockFocus];
|
|
||||||
// [cell setState: ![cell state]];
|
// [cell setState: ![cell state]];
|
||||||
[cell highlight: NO withFrame: bounds inView: self];
|
[cell highlight: NO withFrame: bounds inView: self];
|
||||||
[window flushWindow];
|
[window flushWindow];
|
||||||
|
|
|
@ -436,6 +436,11 @@ struct NSWindow_struct
|
||||||
methodTable.DPStranslate__ =
|
methodTable.DPStranslate__ =
|
||||||
GET_IMP(@selector(DPStranslate::));
|
GET_IMP(@selector(DPStranslate::));
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* I/O operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
methodTable.DPSflush =
|
||||||
|
GET_IMP(@selector(DPSflush));
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
methodTable.DPSconcatmatrix =
|
methodTable.DPSconcatmatrix =
|
||||||
|
@ -1031,6 +1036,14 @@ struct NSWindow_struct
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
/* Matrix operations */
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
- (void) DPSflush
|
||||||
|
{
|
||||||
|
[self subclassResponsibility: _cmd];
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Matrix operations */
|
/* Matrix operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -83,7 +83,7 @@ static NSFont* menuFont = nil;
|
||||||
if (!menuFont)
|
if (!menuFont)
|
||||||
menuFont = [[NSFont systemFontOfSize: 0] retain];
|
menuFont = [[NSFont systemFontOfSize: 0] retain];
|
||||||
|
|
||||||
cellSize = NSMakeSize (1, [menuFont pointSize] - [menuFont descender] + 6);
|
cellSize = NSMakeSize (1, [menuFont pointSize] + [menuFont descender] + 6);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,8 +238,8 @@ sizeLine(NSAttributedString *str,
|
||||||
*/
|
*/
|
||||||
// FIXME - superscript should have some effect on height.
|
// FIXME - superscript should have some effect on height.
|
||||||
|
|
||||||
below = [font descender];
|
below = -([font descender]);
|
||||||
above = [font pointSize] - below;
|
above = [font pointSize];
|
||||||
if (base > 0)
|
if (base > 0)
|
||||||
above += base; // Character is above baseline.
|
above += base; // Character is above baseline.
|
||||||
else if (base < 0)
|
else if (base < 0)
|
||||||
|
@ -484,11 +484,11 @@ drawRun(GSTextRun *run, NSPoint origin, GSDrawInfo *draw)
|
||||||
*/
|
*/
|
||||||
if (draw->flip)
|
if (draw->flip)
|
||||||
{
|
{
|
||||||
origin.y += run->height - run->baseline;
|
origin.y += (run->height - run->baseline);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
origin.y -= run->height - run->baseline;
|
origin.y -= (run->height - run->baseline);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -522,6 +522,14 @@ drawRun(GSTextRun *run, NSPoint origin, GSDrawInfo *draw)
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
||||||
DPSshow(draw->ctxt, buf);
|
DPSshow(draw->ctxt, buf);
|
||||||
|
/* FIXME - Figure out why DGS fails to flush strings and remove this
|
||||||
|
aweful hack which doesn't even work all the time: */
|
||||||
|
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
||||||
|
DPSshow(draw->ctxt, buf);
|
||||||
|
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
||||||
|
DPSshow(draw->ctxt, buf);
|
||||||
|
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
||||||
|
DPSshow(draw->ctxt, buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -536,6 +544,14 @@ drawRun(GSTextRun *run, NSPoint origin, GSDrawInfo *draw)
|
||||||
DPSshow(draw->ctxt, buf);
|
DPSshow(draw->ctxt, buf);
|
||||||
origin.x += run->glyphs[i].adv.width;
|
origin.x += run->glyphs[i].adv.width;
|
||||||
}
|
}
|
||||||
|
/* FIXME - Figure out why DGS fails to flush strings and remove this
|
||||||
|
aweful hack which doesn't even work all the time: */
|
||||||
|
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
||||||
|
DPSshow(draw->ctxt, buf);
|
||||||
|
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
||||||
|
DPSshow(draw->ctxt, buf);
|
||||||
|
DPSmoveto(draw->ctxt, origin.x, origin.y);
|
||||||
|
DPSshow(draw->ctxt, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run->underline)
|
if (run->underline)
|
||||||
|
@ -623,8 +639,8 @@ setupRun(GSTextRun *run, unsigned length, unichar *chars, unsigned pos,
|
||||||
* Calculate height of line from font information and base offset.
|
* Calculate height of line from font information and base offset.
|
||||||
* FIXME - should include superscript information here.
|
* FIXME - should include superscript information here.
|
||||||
*/
|
*/
|
||||||
below = [run->font descender];
|
below = -([run->font descender]);
|
||||||
above = [run->font pointSize] - below;
|
above = [run->font pointSize];
|
||||||
if (run->base > 0)
|
if (run->base > 0)
|
||||||
above += run->base; // Character is above baseline.
|
above += run->base; // Character is above baseline.
|
||||||
else if (run->base < 0)
|
else if (run->base < 0)
|
||||||
|
@ -1236,7 +1252,6 @@ setupLine(GSTextLine *line, NSAttributedString *str, NSRange range,
|
||||||
point.y = rect.origin.y + rect.size.height;
|
point.y = rect.origin.y + rect.size.height;
|
||||||
|
|
||||||
[self drawAtPoint: point];
|
[self drawAtPoint: point];
|
||||||
NSRectClip([view bounds]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSSize) size
|
- (NSSize) size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue