From: SCHALK1@AppleLink.Apple.COM (Euro Tech Svcs, OOP Spec)
Newsgroups: comp.sys.mac.oop.macapp3
Subject: Re: TPopup Testing
Date: 17 Dec 92 10:23:00 GMT
Organization: AppleLink Gateway


 
Paul,
 
Although you can access the menuhandle data structure to get the status of
items (it is kept in the enableFlags of a MenuInfo data structure), this is not
the way to go. What I would do, is subclass my TPopup and add a field that
keeps track of enabled items. I actually added a object (TBitMap, which come to
think of it is a really confusing name) that is an array of Booleans.
 
Included the MacApp 2.0 source code of UBitMap.cp and UBitMap.h. Adding it to
your subclass of TPopup is easy. For MacApp 3.0 some changes might be
necessary.
 
pascal void TMyPopup::IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *
itsParams)
/*
Task:
   Initialize popup with bitmap of enabled/disabled items.
*/
{
   // do private initialization
   fEnabledItems = NULL;
 
   // and inherited one
   inherited::IRes(itsDocument, itsSuperView, itsParams);
 
   // allocate BitMap object that keeps track of enabled items
   fEnabledItems = new TBitMap;
   FailNIL(fEnabledItems);
   fEnabledItems->IBitMap();
}
 
pascal void TMyPopup::Free()
/*
Task:
   Free allocated BitMap object first.
*/
{
   FreeIfObject(fEnabledItems);
 
   inherited::Free();
}
 
Boolean TMyPopup::IsEnabled(short item)
/*
Task:
   Test if popup item is enabled.
 
Parameters:
   item: (IN) item to test.
 
Return Value:
   'true' If enabled, 'false' otherwise.
*/
{
   return fEnabledItems->IsEnabled(item);
}
 
short TMyPopup::FirstEnabled()
/*
Task:
   Determine first enabled item in a popup.
 
Return Value:
   Number of first enabled item, 0 if none.
*/
{
   return short(fEnabledItems->FirstEnabled());
}
 
void TMyPopup::SetValidSelection()
/*
Task:
   Make sure there is an enabled item selected in the popup.
*/
{
   if (! this->IsEnabled(this->GetCurrentItem())) {
   if (this->FirstEnabled()) {
   this->SetCurrentItem(this->FirstEnabled(), kRedraw);
   }
   }
}
 
Hope this helps, regards,
 
Jeroen Schalk
Object Programming Specialist
European Technology Services
Apple Computer Europe
 

begin 644 CompressedFile%2ePKG
M``46```"``````````````````````````4````#````5@```!(````)````
M:````"`````!````B```$',````"```0^P`````````(```0^P````A#;VUP
M<F5S<V5D1FEL92Y02T=(0E-&1T5/3```````````````````````````````
M``(!```````````````````"60``"!,```%V```)B51%6%1-4%,@`0`!'@0G
M```*54)I=$UA<"YC<````````````````````````````*50+^.FD9[(```#
M+0``$9N```````````'=```"M```"^(```Z65$585$U04R`!``&+!`\```E5
M0FET36%P+F@`````````````````````````````I5`REZ:1G@\```)@```$
MLX```````@````````````$```````````)9```($P```78```F)5$585$U0
M4R`!``$>!"<```I50FET36%P+F-P````````````````````````````I5`O
MXZ:1GL@```,M```1FX````$```````````'=```"M```"^(```Z65$585$U0
M4R`!``&+!`\```E50FET36%P+F@`````````````````````````````I5`R
MEZ:1G@\```)@```$LX``+U2T&$BPH,&#"!,J7,BPH4.$#:@$F;*D00(A:>B`
M:!(&#H@W8M24&4/'10.+I4!0`8$$1!$03T!(`9$%!$P01FS&A.)2)H@@*D$D
MN>G$HD6@:,*X(<.F#(@T<T"$8</FS9@P=,J0D;H41)TY6D'0>0-B39DR'L.`
M@!-FC-FM8>3("9/GHQD00MZ\::ITC@N<;^2`&//&S1RH6=V,J7LG(YJ-;8/`
M@6.1"A/$'T..I,-"+!JH3Z-.90."3&&G,5J("0.6C,D$E3'2X0C'11"J;^XD
MR=H&18H$P(,#OUWU#@@S@4'(T=OF>'*L(/C.T9AF:9JK6;=6)U,&SVLJLFF[
M&,)7SNXR;>;X%AZ<"IKEQM_4T3CZ*>^H*.24`4M?+EVQ9.E1QG(@'"9@"M^%
MUY$+*!3A1@HH$`%5"F&(T=1YO?T6W!1E4,<;@&+)48=3R9DQ%5@)9B1>$G,X
M6&%39*S''G!4[*?1=%B1>%=&Z*4XVX)&I"''="Y:J)6,PE5!1QIL9%27&74H
MMF1A()Z1AAU.F2'D=!^YX10=25$751ENO*C5:Y5]%A5((I$4FE>M/>6&5`76
M(<88;+"VYEUJ40'%&W#4X1&8T)F%5E1TS.6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