ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Source/MiscKit/MiscWindowButtons.m

This is MiscWindowButtons.m in view mode; [Download] [Up]

//
//	MiscWindowButtons.m -- extension to Window class
//		Written by John Randolph
//		Copyright (c) 1994, 1995 by John Randolph.
//				Version 1.0.  All rights reserved.
//		This notice may not be removed from this source code.
//
//	This object is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	

/******************************************************************************
  
		 Class: Window
  Category: WindowButtons
		 
Created By:	John C. Randolph,  <jcr@wildrose.com>	(408) 369-8433
						Wildrose Corporation			 
						3438 Fawn Drive
						San Jose, CA 95124
						
	 Created: Tue Apr  4 04:27:33 PDT 1995
	 
    Does:  This category allows a programmer to add or remove
            the miniaturize and close buttons in a Window's title bar.
					
		Copyright (c) 1995 John C. Randolph
		
		You may use this code any way that you like, but if you use it
		in a commercial application, you owe me dinner.  
		
		All rights reserved.
		
		RESTRICTED RIGHTS LEGEND
		Use, duplication, or disclosure by the Government is subject to
		restrictions as set forth in subparagraph (c) (I) (ii) of the Rights
		in Technical Data and Computer Software Clause at DFARS 252.227-7013.
			
*///---------------------------------------------------------------------------

#import <misckit/misckit.h>

#import "MiscWBWraps.h"

@interface Window (MiscWindowButtonsPrivate)

- (int) globalWindowNum;
- toggleClose:sender;
- toggleMiniaturize:sender;
- updateBorder;

@end

@interface View (MiscWindowButtons)
- _setMask:(unsigned int) mask;
@end

@implementation Window (MiscWindowButtonsPrivate)

- (int) globalWindowNum
	{
	unsigned int
		global;
	NXConvertWinNumToGlobal([self windowNum],&global);
	return global;
	}

// So, you may be wondering, why use this XOR to toggle the bit,
// instead of explicitly setting or clearing it, in the public
// methods below?  Good Question!  I tried to do it that way, and
// it didn't work.  I don't know why it didn't work.  I REALLY want
// to see NeXT's source code for the Window class.
	
- toggleClose:sender
	{
	wFlags.buttonMask ^= NX_CLOSEBUTTONMASK;
	return [self updateBorder];
	}

- toggleMiniaturize:sender
	{
	wFlags.buttonMask ^= NX_MINIATURIZEBUTTONMASK;
	return [self updateBorder];
	}
	
// This method is sheer Voodoo. _borderView is declared in
// <AppKit/Window.h>, but it is of a class that has no
// published API, the "FrameView" class. 
// If NeXT had published the API for FrameView, just think!
// We might violate their UI guidelines by making windows that
// confuse the user by turning the title bar controls on and off!
// Like, say, the Submenus do!
	
- updateBorder
	{
	[_borderView _setMask:wFlags.buttonMask];
	[_borderView tile];    // Not sure I *have* to do this.
	[_borderView display];
	return [self display];
	}
	
@end

@implementation Window (MiscWindowButtons)
- showCloseBox:sender
	{
	if (!(wFlags.buttonMask & NX_CLOSEBUTTONMASK))
		{
		PSWaddCloseButtonRect([self windowNum]);
		return [self toggleClose:sender];
		}
	return self;
	}
	
- showMiniaturizeButton:sender
	{
	if (!(wFlags.buttonMask & NX_MINIATURIZEBUTTONMASK))
		{
		PSWaddMiniaturizeButtonRect([self windowNum]);
		return [self toggleMiniaturize:sender];
		}
	return self;
	}
	
- hideCloseBox:sender
	{
	if (wFlags.buttonMask & NX_CLOSEBUTTONMASK)
		{
		PSWremoveCloseButtonRect([self windowNum]);
		return [self toggleClose:sender];
		}
	return self;
	}
	
- hideMiniaturizeButton:sender
	{
	if (wFlags.buttonMask & NX_MINIATURIZEBUTTONMASK)
		{
		PSWremoveMiniaturizeButtonRect([self windowNum]);
		return [self toggleMiniaturize:sender];
		}
	return self;
	}
	

	
@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.