mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
Moved over from X11 backend.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@15945 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9be730bc7e
commit
2eedf0acc2
2 changed files with 0 additions and 213 deletions
|
@ -1,43 +0,0 @@
|
|||
/** -*- mode: ObjC -*-
|
||||
<title>XGSlideView</title>
|
||||
|
||||
<abstract>View that is slid by NSWorkspace</abstract>
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written By: <author name="Enrico Sersale"><email>enrico@imago.ro</email></author>
|
||||
Date: Jan 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface 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; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <AppKit/NSView.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
#include "x11/XGServerWindow.h"
|
||||
|
||||
@class NSCell;
|
||||
|
||||
@interface XGSlideView : NSView
|
||||
{
|
||||
NSCell *slideCell;
|
||||
gswindow_device_t *slideWindev;
|
||||
}
|
||||
|
||||
+ (BOOL) _slideImage: (NSImage*)image
|
||||
from: (NSPoint)fromPoint
|
||||
to: (NSPoint)toPoint;
|
||||
@end
|
|
@ -1,170 +0,0 @@
|
|||
/** <title>XGSlideView</title>
|
||||
|
||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
Created by: Enrico Sersale <enrico@imago.ro>
|
||||
Date: Jan 2002
|
||||
Author: Fred Kiefer <fredkiefer@gmx.de>
|
||||
Date: Jan 2003
|
||||
Removed all dependencies on X.
|
||||
|
||||
This file is part of the GNU Objective C User Interface 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; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSCell.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
|
||||
#include "AppKit/GSDisplayServer.h"
|
||||
#include "x11/XGSlideView.h"
|
||||
#include <math.h>
|
||||
|
||||
// Minimal slide distance per step in pixel
|
||||
#define MINDIST 18
|
||||
// Time for each slide step in seconds
|
||||
#define SLIDE_TIME_STEP 0.02
|
||||
|
||||
@interface XGSlideView (Private)
|
||||
- (void) _setupImage: (NSImage*) image startPoint: (NSPoint)slideStart;
|
||||
- (void) _slideFrom: (NSPoint)fromPoint to: (NSPoint)toPoint;
|
||||
@end
|
||||
|
||||
@implementation XGSlideView (Private)
|
||||
|
||||
- (void) _setupImage: (NSImage*) image startPoint: (NSPoint)slideStart
|
||||
{
|
||||
NSSize imageSize = [image size];
|
||||
|
||||
[slideCell setImage: image];
|
||||
[_window setFrame: NSMakeRect(slideStart.x, slideStart.y,
|
||||
imageSize.width, imageSize.height)
|
||||
display: NO];
|
||||
|
||||
// Only display the image
|
||||
[GSServerForWindow(_window) restrictWindow: [_window windowNumber]
|
||||
toImage: image];
|
||||
|
||||
[_window orderFrontRegardless];
|
||||
}
|
||||
|
||||
- (void) _slideFrom: (NSPoint)fromPoint to: (NSPoint)toPoint
|
||||
{
|
||||
float distx = toPoint.x - fromPoint.x;
|
||||
float disty = toPoint.y - fromPoint.y;
|
||||
float dist = sqrt((distx * distx) + (disty * disty));
|
||||
int steps = (int)(dist / MINDIST);
|
||||
int windowNumber = [_window windowNumber];
|
||||
GSDisplayServer *server = GSServerForWindow(_window);
|
||||
|
||||
if (steps > 2)
|
||||
{
|
||||
float unitx = distx / steps;
|
||||
float unity = disty / steps;
|
||||
|
||||
[NSEvent startPeriodicEventsAfterDelay: SLIDE_TIME_STEP
|
||||
withPeriod: SLIDE_TIME_STEP];
|
||||
while(steps--)
|
||||
{
|
||||
NSEvent *theEvent = [NSApp nextEventMatchingMask: NSPeriodicMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
|
||||
if ([theEvent type] != NSPeriodic)
|
||||
{
|
||||
NSDebugLLog (@"NSDragging",
|
||||
@"Unexpected event type: %d during slide",
|
||||
[theEvent type]);
|
||||
}
|
||||
fromPoint.x += unitx;
|
||||
fromPoint.y += unity;
|
||||
[server movewindow: fromPoint : windowNumber];
|
||||
}
|
||||
[NSEvent stopPeriodicEvents];
|
||||
}
|
||||
// Go exactly to the point
|
||||
[server movewindow: toPoint : windowNumber];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation XGSlideView
|
||||
|
||||
+ (BOOL) _slideImage: (NSImage *)image
|
||||
from: (NSPoint)fromPoint
|
||||
to: (NSPoint)toPoint
|
||||
{
|
||||
static XGSlideView *v = nil;
|
||||
BOOL result = NO;
|
||||
|
||||
if (image != nil)
|
||||
{
|
||||
if (v == nil)
|
||||
{
|
||||
v = [[self alloc] init];
|
||||
}
|
||||
[NSApp preventWindowOrdering];
|
||||
[v _setupImage: image startPoint: fromPoint];
|
||||
[v _slideFrom: fromPoint to: toPoint];
|
||||
[[v window] orderOut: nil];
|
||||
|
||||
result = YES;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
// This is never used, as the window gets resized before displaying
|
||||
NSRect winRect = {{0, 0}, {48, 48}};
|
||||
NSWindow *slideWindow;
|
||||
|
||||
slideCell = [[NSCell alloc] initImageCell: nil];
|
||||
[slideCell setBordered: NO];
|
||||
|
||||
slideWindow = [[NSWindow alloc] initWithContentRect: winRect
|
||||
styleMask: NSBorderlessWindowMask
|
||||
backing: NSBackingStoreNonretained
|
||||
defer: NO];
|
||||
[slideWindow setReleasedWhenClosed: YES];
|
||||
[slideWindow setExcludedFromWindowsMenu: YES];
|
||||
[slideWindow setContentView: self];
|
||||
RELEASE (self);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE (slideCell);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
[slideCell drawWithFrame: rect inView: self];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue