mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 06:40:38 +00:00
Tidyup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6216 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6956d4e182
commit
bb0bd00009
3 changed files with 20 additions and 65 deletions
|
@ -46,49 +46,6 @@
|
|||
}
|
||||
@end
|
||||
|
||||
/* Same as [NSWindow -convertBaseToScreen:] with the difference
|
||||
that detects and fixes at run time bugs in the window frame management */
|
||||
/* frame is a frame where the mouse is supposed to be.
|
||||
If the mouse is out of that frame, it means the window code has got the
|
||||
window origin wrong -- presumably by a decoration height.
|
||||
Looking if mouse is upper or lower than the given frame we determine
|
||||
if decoration window size need to be added or subtracted. */
|
||||
NSPoint
|
||||
_convertBaseToScreen_with_fix(NSRect frame, NSWindow *window, NSPoint point)
|
||||
{
|
||||
/* We get mouse position */
|
||||
NSPoint mouse = [window mouseLocationOutsideOfEventStream];
|
||||
float l, r, b;
|
||||
float t = 0;
|
||||
NSPoint ret;
|
||||
|
||||
/* If the reported mouse position is not in frame
|
||||
this means that the window frame origin is broken. */
|
||||
if (mouse.y > frame.origin.y + frame.size.height)
|
||||
{
|
||||
NSLog (@"Window Frame Origin Bug Detected: point reported higher");
|
||||
NSLog (@"Workaround enabled.");
|
||||
DPSstyleoffsets (GSCurrentContext (), &l, &r, &t, &b,
|
||||
[window styleMask]);
|
||||
}
|
||||
else if (mouse.y < frame.origin. y)
|
||||
{
|
||||
NSLog (@"Window Frame Origin Bug Detected: point reported lower");
|
||||
NSLog (@"Workaround enabled.");
|
||||
DPSstyleoffsets (GSCurrentContext (), &l, &r, &t, &b,
|
||||
[window styleMask]);
|
||||
t = -t;
|
||||
}
|
||||
|
||||
/* Convert the origin */
|
||||
ret = [window convertBaseToScreen: point];
|
||||
|
||||
/* Add the bug correction */
|
||||
ret.y += t;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* The image to use in a specific popupbutton is
|
||||
* _pbc_image[_pbcFlags.pullsDown]; that is, _pbc_image[0] if it is a
|
||||
* popup menu, _pbc_image[1] if it is a pulls down list. */
|
||||
|
@ -477,21 +434,21 @@ static NSImage *_pbc_image[2];
|
|||
NSWindow *cvWin = [controlView window];
|
||||
NSMenuView *mr = [_menu menuRepresentation];
|
||||
int items;
|
||||
NSRect origCellFrame = [controlView convertRect: cellFrame
|
||||
toView: nil];
|
||||
|
||||
[nc postNotificationName: NSPopUpButtonCellWillPopUpNotification
|
||||
object: self];
|
||||
object: self];
|
||||
|
||||
[nc postNotificationName: NSPopUpButtonCellWillPopUpNotification
|
||||
object: controlView];
|
||||
object: controlView];
|
||||
|
||||
[mr _setCellSize: cellFrame.size];
|
||||
[_menu sizeToFit];
|
||||
|
||||
// Compute the frame (NB: the temporary frame to be passed
|
||||
// to mr as per spec, not yet the definitive frame where
|
||||
// the menu is going to appear)
|
||||
/*
|
||||
* Compute the frame (NB: the temporary frame to be passed
|
||||
* to mr as per spec, not yet the definitive frame where
|
||||
* the menu is going to appear)
|
||||
*/
|
||||
items = [_menu numberOfItems];
|
||||
if (items > 1)
|
||||
{
|
||||
|
@ -506,10 +463,9 @@ static NSImage *_pbc_image[2];
|
|||
|
||||
/* Convert to content view */
|
||||
cellFrame = [controlView convertRect: cellFrame
|
||||
toView: nil];
|
||||
toView: nil];
|
||||
|
||||
cellFrame.origin = _convertBaseToScreen_with_fix (origCellFrame, cvWin,
|
||||
cellFrame.origin);
|
||||
cellFrame.origin = [cvWin convertBaseToScreen: cellFrame.origin];
|
||||
|
||||
// Ask the MenuView to attach the menu to this rect
|
||||
if (_pbcFlags.pullsDown)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue