Exemplo n.º 1
0
void CRecentFilesMenu::populate()
{
	// add recent files from preferences
	CPreferences::recent_type *files = _preferences->recentFiles();
	CPreferences::recent_type_iterator e = files->begin();
	int index = 1;
		 
	// the menu never gets smaller, just add items as needed
	while (e != files->end()) {
		if(::CountMenuItems( GetMacMenuH()) < index)
			InsertCommand( "\p ", cmd_UseMenuItem, 16000 );
		string path = *e;
		//dprintf("addRecentFile %s\n", path.c_str());
		LStr255 theTitle = path.c_str();
		::SetMenuItemText( GetMacMenuH(), index, theTitle );
		e++; index++;
	}
}
Exemplo n.º 2
0
void
LGAMiniArrowPopup::GetCurrentItemTitle ( Str255 outItemTitle )
{
	// е Load the popup menu and then find the title
	MenuHandle	popupMenu = GetMacMenuH ();
	if ( popupMenu )
	{			
		::GetMenuItemText ( popupMenu, GetValue (), outItemTitle );
	}
	
}	//	LGAMiniArrowPopup::GetCurrentItemTitle
Exemplo n.º 3
0
void
LGAMiniArrowPopup::SetPopupMinMaxValues ()
{

	// е We will have to synthesize these values as we dont' have a real
	// control that we are talking too
	MenuHandle	popupMenu = GetMacMenuH ();
	if ( popupMenu )
	{
		// е Setup the values
		mMinValue = 1;
		mMaxValue = ::CountMenuItems ( popupMenu );
	}
		
}	//	LGAMiniArrowPopup::SetPopupMinMaxValues
Exemplo n.º 4
0
void
LGAMiniArrowPopup::SetValue	(	SInt32	inValue )
{

	// е Setup the current item if needed
	if ( GetValue () != inValue )
	{
		// е Get the current item setup in the menu
		MenuHandle menuH = GetMacMenuH ();
		if ( menuH )
		{
			SetupCurrentMenuItem ( menuH, inValue );
		}

		// е Call our superclass to handle the setting of the value
		LControl::SetValue ( inValue );
	
		// е Now we need to get the popup redrawn so that the change
		// will be seen
		Draw ( nil );
	}
	
}	//	LGAMiniArrowPopup::SetValue
Exemplo n.º 5
0
void
LGAMiniArrowPopup::HandlePopupMenuSelect	(	Point		inPopupLoc,
												SInt16		inCurrentItem,
												SInt16		&outMenuID,
												SInt16		&outMenuItem )
{
	
	MenuHandle	menuH = GetMacMenuH ();
	ThrowIfNil_ ( menuH );
	if ( menuH )
	{
		// е Save off the current system font family and size
		SInt16 saveFont = ::LMGetSysFontFam ();
		SInt16 saveSize = ::LMGetSysFontSize ();
		
		// е Enclose this all in a try catch block so that we can
		// at least reset the system font if something goes wrong
		try 
		{

			// е Handle the actual insertion into the hierarchical menubar
			::InsertMenu ( menuH, hierMenu );
			
			// е Reconfigure the system font so that the menu will be drawn in
			// our desired font and size
			FocusDraw ();
			{				
				ResIDT	textTID = GetTextTraitsID ();
				TextTraitsH traitsH = UTextTraits::LoadTextTraits ( textTID );
				if ( traitsH ) 
				{
					::LMSetSysFontFam ( (**traitsH).fontNumber );
					::LMSetSysFontSize ( (**traitsH).size );
					::LMSetLastSPExtra ( -1L );
				}
			}

			// е Before we display the menu we need to make sure that we have the
			// current item marked in the menu. NOTE: we do NOT use the current
			// item that has been passed in here as that always has a value of one
			// in the case of a pulldown menu
			SetupCurrentMenuItem ( menuH, GetValue () );
	
			// е Then we call PopupMenuSelect and wait for it to return
			SInt32 result = ::PopUpMenuSelect ( 	menuH,
															inPopupLoc.v,
															inPopupLoc.h,
															inCurrentItem );
			
			// е Then we extract the values from the returned result
			// these are then passed back out to the caller
			outMenuID = HiWord ( result );
			outMenuItem = LoWord ( result );
			
		}
		catch (...) 
		{
			// ignore errors╔
		}

		// е Restore the system font
		::LMSetSysFontFam ( saveFont );
		::LMSetSysFontSize ( saveSize );
		::LMSetLastSPExtra ( -1L );

		// е Finally get the menu removed
		::DeleteMenu ( GetPopupMenuResID ());
		
	}
	
}	//	LGAMiniArrowPopup::HandlePopupMenuSelect