File: programming/cocoa/UKDockableView.zip/UKDockableWindow/UKDockableView.m


// =============================================================================
//  UKDockableView.m
//  UKDockableWindow
//
//  Created by Uli Kusterer on Tue Feb 03 2004.
//  Copyright (c) 2004 M. Uli Kusterer. All rights reserved.
//
//  PURPOSE:
//		UKDockableView attempts to provide advanced window management with a
//		simple user interface. Some people prefer applications with one large
//		window that contains everything they work with. Others prefer having
//		lots of small windows they can move around and resize.
//
//		Since in many cases there isn't really any "right way" to do it, this
//		class intends to allow splitting each NSindow into several smaller
//		"windows". These smaller parts can be grabbed and dragged out of the
//		NSWindow they are in. Drop them in another window and they end up there,
//		drop them on the desktop and you get a new NSWindow containing only this
//		one "window".
//
//		This allows "tearing apart" a window and re-assembling it as one sees
//		fit.
//
//	DIRECTIONS:
//		UKDockableView is a container view. For each of the "windows" your
//		application has, you create one UKDockableView that contains the views
//		that should be in that "window".
//		Then distribute those UKDockableViews over all the NSWindows you want
//		the user to initially have. Usually, these are several windows, but
//		there'd still be several UKDockableViews in most NSWindows.
// =============================================================================
 
// -----------------------------------------------------------------------------
//	Headers:
// -----------------------------------------------------------------------------
 
#import "UKDockableView.h"
#import "NSApplicationWindowAtPoint.h"
#import "NSViewViewIntersectingRect.h"
 
#if UKDOCKABLEVIEW_SUPPORT_METAL
#import "NSBezierPathRoundRects.h"
#endif
 
 
// -----------------------------------------------------------------------------
//	Class variables / Globals:
// -----------------------------------------------------------------------------
// Window to use for dragging around a view.
// Window the mouse is over while dragging a view (not counting gUKDockableViewOverlayWindow).
// Mouse position while we're dragging the view.
// -----------------------------------------------------------------------------
//	* DESIGNATED INITIALIZER:
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	calculateTitlebar:content:drawbox:inRect:
//		Calculate some rectangles for the various areas of the view.
//		Except for inRect: rect, all parameters are return values.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	drawRect:
//		Draw this view's look to make it obvious to the user that it can be
//		dragged, and what controls will be dragged out.
// -----------------------------------------------------------------------------
#if UKDOCKABLEVIEW_SUPPORT_METAL
#endif
// Content background:
#if UKDOCKABLEVIEW_SUPPORT_METAL
#endif
// Title bar:
#if UKDOCKABLEVIEW_SUPPORT_METAL
#endif
// Titlebar widgets:
"grippy"// Content box:
#if UKDOCKABLEVIEW_SUPPORT_METAL
#endif
// -----------------------------------------------------------------------------
//	mouseDown:
//		Allow dragging the view out of its window.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	mouseDragged:
//		I should probably rename this. This catches mouseDragged: events to the
//		application while the view image is being dragged to move the view.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	mouseUp:
//		I should probably rename this. This catches mouseUp: events to the
//		application while the view image is being dragged to terminate the drag.
// -----------------------------------------------------------------------------
// User moved it a substantial distance and didn't just mis-click?
// If there's a document for the old window, create a new window controller of the same class as the old window's and add it to that document:
// -----------------------------------------------------------------------------
//	mouseDownCanMoveWindow:
//		Otherwise our brushed-metal window moves when our drag area is clicked.
//
//		I wanted to make this depend on whether the user clicked the content or
//		the drag area of this view, but sadly this is called only once when the
//		view is added to a window.
// -----------------------------------------------------------------------------
/*NSRect		drawbox,
				contentbox,
				titlebar;
	NSPoint		pos = [[[self window] currentEvent] locationInWindow];
	
	pos = [self convertPoint: pos fromView: nil];
	[self calculateTitlebar: &titlebar content: &contentbox drawbox: &drawbox
				inRect: [self bounds]];
	return( (pos.x < titlebar.origin.x)
			|| (pos.y < titlebar.origin.y)
			|| (pos.x > (titlebar.origin.x +titlebar.size.width))
			|| (pos.y > (titlebar.origin.y +titlebar.size.height)) );*/	
}
 
 
// -----------------------------------------------------------------------------
//	titleEdge:
//		Accessor to find out on which edge this view will draw its dragging
//		area and the little grippy-thingie.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	setTitleEdge:
//		Mutator to specify on which edge this view will draw its dragging
//		area and the little grippy-thingie. NSMinXEdge (left) is the default,
//		and NSMaxYEdge (top) is a sensible alternative. Avoid the right edge
//		because that's where the scrollbar usually is, and *never* use the
//		bottom edge because it feals really weird to be dragging something by
//		its bottom. Just MHO.
// -----------------------------------------------------------------------------
 

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.