Skip to content

phildow/SPTextAndHeaderView

Repository files navigation

/*
	Copyright 2011 Philip Dow / Sprouted. All rights reserved.
*/

/*

	Redistribution and use in source and binary forms, with or without modification, 
	are permitted provided that the following conditions are met:

	* Redistributions of source code must retain the above copyright notice, this list 
	of conditions and the following disclaimer.

	* Redistributions in binary form must reproduce the above copyright notice, this 
	list of conditions and the following disclaimer in the documentation and/or other 
	materials provided with the distribution.

	* Neither the name of the author nor the names of its contributors may be used to 
	endorse or promote products derived from this software without specific prior 
	written permission.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY 
	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
	SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
	TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
	ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
	DAMAGE.

*/

/*
	For non-attribution licensing options refer to http://phildow.net/licensing/
*/


/*
	SPTextAndHeaderView is a custom view subclass meant to be used as the document view
	of a scroll view. It allows you to lay out a header view alongside a text view inside
	a single NSScrollView.
	
	Scroll views manage single document subviews, for example, a single text view. As the
	text view changes its geometry because of user input, the scroll view adjusts its clip 
	view to encompass the visible area.
	
	There has been a need to lay out additional views alongside the text view while keeping 
	everything within the text view's enclosing scroll view. Scrolling can then encompass
	all the views, so that with a vertical scroll a header view will eventually disappear,
	falling outside the scroll view's clipping area. Apple's Mail program exhibits this 
	behavior when reading messages. Normally, scrolling would only scroll the text, keeping 
	the header view visible. This behavior is not always desirable.
	
	SPTextAndHeaderView coordinates between a header view, which itself can contain any kind
	and number of subviews, a text view, and an enclosing scroll view. The header view is
	kept in place at the top, while changes to the text view's geometry are mediated to the 
	enclosing scroll view. The class remains compatibility with the system's ruler APIs.
*/

About

Combine custom header view with NSTextView in a single NSScrollView for Mac OS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published