ftp.nice.ch/pub/next/text/apps/eText5.0.93.s.tar.gz#/eText5/Kludges.subproj/WidePopupManager.h

This is WidePopupManager.h in view mode; [Download] [Up]

{\rtf0\ansi{\fonttbl\f0\fmodern Courier;\f1\ftech Symbol;\f2\fmodern Ohlfs;}
\margl40
\margr40
{\colortbl;\red0\green0\blue0;}
\pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b0\i0\ulnone\fs24\fc0\cf0 //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\
//
\i 	
\b FILENAME
\b0 :	
\b\i0 WidePopupManager.h\

\b0 //
\i 	
\b SUMMARY
\b0 :	
\b\i0 Header for an AndrewStone
\f1\b0 Ô
\f0\b  PopUp Hack
\b0 \
//	
\b\i SUPERCLASS
\b0 :
\i0 	
\b Object:WidePopupManager
\b0 \
//	
\b\i PROTOCOLS
\b0 :
\i0 	
\b None
\b0 \
//	
\b\i INTERFACE
\b0 :
\i0 	
\b None
\b0 \
//	
\b\i AUTHOR
\b0 :		
\b\i0 Andrew Stone & Charles Perkins
\b0 \
//ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\
//	
\b\i Description\

\b0\i0\fc1\cf1 // > 2) How can I make the pop-up list resize to the longest string in the\
// > list?  I have tried various combinations of sizeToFit to both the\
// > pop-up list and the button, but none give the desired results.\
// \
// Charles Perkins and I wrote a hack to do this [IE, when it's not popped,\
// it's a certain fixed size in your UI, but when it's popped, it sizes to\
// the widest entry] by creating a class which goes between the button and\
// the pop up list as manager, and munges the frame of the Menu before it\
// shows itself.\
//\
// Here's how you'd invoke it:\
// \
// - initializeFindButton:theButton\
// \{ \
//     NXAttachPopUpList(theButton,findPopUp);\
//     [[WidePopupManager allocFromZone:[theButton  \
// zone]]initForButton:theButton andList:findPopUp];\
//     .....\
// \}\

\fc0\cf0 //ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\
//	
\b\i History
\b0\i0 \
//	09/27/94:	
\b Snarfed from mlist.next-programmer archives.
\b0 \
//ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\
//	
\b Imported Interfaces
\b0 \
//\
	#import <appkit/
\b appkit.h
\b0 >\

\i \
/*************************************************************************\
*	Copyright (c) 1989,1990 Stone Design Corp.  All rights reserved. \
*	programmer: Andrew C. Stone/ Charles L. Perkins \
*	Date:	 Feb 2 1992 \
*	Purpose:  To fool a popup into being wider than normal as needed \
***************************************************************************/\
\
@interface WidePopupManager:Object 
\i0 \{\
    id	
\b button
\b0 ;\
    id	
\b popupList
\b0 ;\
\}\
\
- 
\b initForButton
\b0 :aButton 
\b andList
\b0 :aPopupList;\
- 
\b popUp
\b0 :sender;\
\

\i @end\

\i0 \

\i @implementation WidePopupManager\

\i0 \
- 
\b initForButton
\b0 :aButton 
\b andList
\b0 :aPopupList\
\{\
    button = aButton;\
    popupList = aPopupList;\
    \
    [popupList sizeToFit];		\
    \
    [button setAction:@selector(popUp:)];\
    [button setTarget:self];\
\
    return self;\
\}\
\
//ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ\
//	
\b The Fake-Out Stuff
\b0 \
//\
\
- 
\b popUp
\b0 :sender\
\{\
    return [popupList popUp: self];	// we are the surrogate button\
\}\
\
\
- 
\b getBounds
\b0 :(NXRect *)theRect\
\{		/* so we have the correct width */\
    NXRect  popupFrame;\
    \
    [popupList getFrame: &popupFrame];\
    [button getBounds: theRect];\
    if (theRect->size.width < popupFrame.size.width - 1)\
    theRect->size.width = popupFrame.size.width - 1;  \
    return self;\
\}\
\
// 
\i this and next 4 messages so we can masquerade as Button to PopUpList\

\i0 - 
\b convertPoint
\b0 :(NXPoint *)aPoint 
\b toView
\b0 :aView\
\{\
    return [button convertPoint:aPoint toView:aView];\
\} \
\
- 
\b window
\b0 \
\{\
    return [button window];\
\}\
\
- 
\b display
\b0 \
\{\
    return [button display];\
\}\
\
- (BOOL)
\b needsDisplay
\b0 \
\{\
    return [button needsDisplay];\
\}\
\
- (const char *)
\b title
\b0 \
\{\
    return [button title];\
\}\
\
- 
\b setTitle
\b0 :(const char *)aString\
\{\
    [button setTitle: aString];\
    return self;\
\}\
\

\i @end
}

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