Пример #1
0
static pascal OSStatus MusicBoxEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *userData)
{
    #pragma unused (inHandlerCallRef)

    OSStatus	err, result = eventNotHandledErr;
	WindowRef	tWindowRef = (WindowRef) userData;

	switch (GetEventClass(inEvent))
	{
		case kEventClassCommand:
			switch (GetEventKind(inEvent))
			{
				HICommand	cmd;

				case kEventCommandUpdateStatus:
					err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, nil, sizeof(HICommand), nil, &cmd);
					if (err == noErr && cmd.commandID == 'clos')
					{
						UpdateMenuCommandStatus(false);
						result = noErr;
					}

					break;

				case kEventCommandProcess:
					err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, nil, sizeof(HICommand), nil, &cmd);
					if (err == noErr)
					{
						HIViewRef	root, c1, c2, c3, c4;
						HIViewID	cid;
						Rect		rct;

						switch (cmd.commandID)
						{
							case 'bar1': so.stereo_switch ^= (1 <<  0);	result = noErr;	break;
							case 'bar2': so.stereo_switch ^= (1 <<  1);	result = noErr;	break;
							case 'bar3': so.stereo_switch ^= (1 <<  2);	result = noErr;	break;
							case 'bar4': so.stereo_switch ^= (1 <<  3);	result = noErr;	break;
							case 'bar5': so.stereo_switch ^= (1 <<  4);	result = noErr;	break;
							case 'bar6': so.stereo_switch ^= (1 <<  5);	result = noErr;	break;
							case 'bar7': so.stereo_switch ^= (1 <<  6);	result = noErr;	break;
							case 'bar8': so.stereo_switch ^= (1 <<  7);	result = noErr;	break;
							case 'bar9': so.stereo_switch ^= (1 <<  8);	result = noErr;	break;
							case 'bara': so.stereo_switch ^= (1 <<  9);	result = noErr;	break;
							case 'barb': so.stereo_switch ^= (1 << 10);	result = noErr;	break;
							case 'barc': so.stereo_switch ^= (1 << 11);	result = noErr;	break;
							case 'bard': so.stereo_switch ^= (1 << 12);	result = noErr;	break;
							case 'bare': so.stereo_switch ^= (1 << 13);	result = noErr;	break;
							case 'barf': so.stereo_switch ^= (1 << 14);	result = noErr;	break;
							case 'bar0': so.stereo_switch ^= (1 << 15);	result = noErr;	break;

							case 'Paus':
								mboxPause = !mboxPause;
								S9xSetSoundMute(mboxPause);
								result = noErr;
								break;

							case 'Tr_i':
								showIndicator = !showIndicator;

								root = HIViewGetRoot(tWindowRef);
								cid.id = 0;

								cid.signature = 'Pane';
								HIViewFindByID(root, cid, &c1);
								HIViewSetVisible(c1, false);
								cid.signature = 'iMaG';
								HIViewFindByID(root, cid, &c2);
								HIViewSetVisible(c2, false);
								cid.signature = 'rCTL';
								HIViewFindByID(root, cid, &c3);
								HIViewSetVisible(c3, false);
								cid.signature = 'bCTL';
								HIViewFindByID(root, cid, &c4);
								HIViewSetVisible(c4, false);

								GetWindowBounds(tWindowRef, kWindowStructureRgn,  &rct);
								rct.bottom = rct.top + (showIndicator ? mbxOpenedHeight : mbxClosedHeight);

								err = TransitionWindow(tWindowRef, kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &rct);

								HIViewSetVisible(c1, true);
								HIViewSetVisible(c2, true);
								HIViewSetVisible(c3, true);
								HIViewSetVisible(c4, true);

								result = noErr;
								break;

							case 'DONE':
								QuitAppModalLoopForWindow(tWindowRef);
								result = noErr;
								break;

							case 'HEAD':
								showIndicator = !showIndicator;
								SPCPlayDefrost();
								showIndicator = !showIndicator;
								result = noErr;
								break;

							case 'S_EF':
								HideWindow(tWindowRef);
								showIndicator = !showIndicator;
								ConfigureSoundEffects();
								showIndicator = !showIndicator;
								ShowWindow(tWindowRef);
								result = noErr;
						}
					}
			}
	}

	return result;
}
Пример #2
0
static pascal OSStatus PreferencesEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	OSStatus	err, result = eventNotHandledErr;
	WindowRef	tWindowRef = (WindowRef) inUserData;

	switch (GetEventClass(inEvent))
	{
		case kEventClassWindow:
		{
			switch (GetEventKind(inEvent))
			{
				case kEventWindowClose:
				{
					QuitAppModalLoopForWindow(tWindowRef);
					result = noErr;
					break;
				}
			}

			break;
		}

		case kEventClassCommand:
		{
			switch (GetEventKind(inEvent))
			{
				HICommand	tHICommand;

				case kEventCommandUpdateStatus:
				{
					err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
					if (err == noErr && tHICommand.commandID == 'clos')
					{
						UpdateMenuCommandStatus(true);
						result = noErr;
					}

					break;
				}

				case kEventCommandProcess:
				{
					HIViewRef	ctl, root;
					HIViewID	cid;
					SInt32		value;
					FSRef		ref;
					bool8		r;

					root = HIViewGetRoot(tWindowRef);

					err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand);
					if (err == noErr)
					{
						switch (tHICommand.commandID)
						{
							case 'S_EF':
							{
								HideWindow(tWindowRef);
								ConfigureSoundEffects();
								ShowWindow(tWindowRef);

								result = noErr;
								break;
							}

							case 'G_FL':
							{
								if (systemVersion >= 0x1040)
								{
									HideWindow(tWindowRef);
									ConfigureCoreImageFilter();
									ShowWindow(tWindowRef);
								}

								result = noErr;
								break;
							}

							case 'G__7':
							{
								cid.signature = 'grap';
								cid.id = iNibGGLStretch;
								HIViewFindByID(root, cid, &ctl);
								value = GetControl32BitValue(ctl);

								cid.id = iNibGAspectRatio;
								HIViewFindByID(root, cid, &ctl);
								if (value)
									ActivateControl(ctl);
								else
									DeactivateControl(ctl);

								result = noErr;
								break;
							}

							case 'G_13':
							{
								cid.signature = 'grap';
								cid.id = iNibGScreenCurvature;
								HIViewFindByID(root, cid, &ctl);
								value = GetControl32BitValue(ctl);

								cid.id = iNibGCurvatureWarp;
								HIViewFindByID(root, cid, &ctl);
								if (value)
									ActivateControl(ctl);
								else
									DeactivateControl(ctl);

								result = noErr;
								break;
							}

							case 'S__3':
							{
								cid.signature = 'snd_';
								cid.id = iNibSStereo;
								HIViewFindByID(root, cid, &ctl);
								value = GetControl32BitValue(ctl);

								cid.id = iNibSReverseStereo;
								HIViewFindByID(root, cid, &ctl);
								if (value)
									ActivateControl(ctl);
								else
									DeactivateControl(ctl);

								result = noErr;
								break;
							}

							case 'F_FL':
							{
								UInt32	modifierkey;

								err = GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifierkey);
								if (err == noErr)
								{
									if (modifierkey & optionKey)
									{
										CFStringRef	str;
										MenuRef		menu;

										str = CFCopyLocalizedString(CFSTR("NoneSelected"), "NoneSelected");

										cid.signature = 'othe';
										cid.id = iNibOSaveFolder;
										HIViewFindByID(root, cid, &ctl);
										SetControl32BitValue(ctl, 3);
										err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL);
										err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, str);
										DisableMenuItem(menu, iNibSaveFolderNameMenuItem);
										HIViewSetNeedsDisplay(ctl, true);

										CFRelease(str);

										if (saveFolderPath)
											CFRelease(saveFolderPath);
										saveFolderPath = NULL;
									}
									else
										r = NavBeginChooseFolderSheet(tWindowRef);
								}

								result = noErr;
								break;
							}

							case 'NvDn':
							{
								r = NavEndChooseFolderSheet(&ref);
								if (r)
								{
									CFStringRef	str;
									CFURLRef	url;
									MenuRef		menu;

									url = CFURLCreateFromFSRef(kCFAllocatorDefault, &ref);
									str = CFURLCopyLastPathComponent(url);

									cid.signature = 'othe';
									cid.id = iNibOSaveFolder;
									HIViewFindByID(root, cid, &ctl);
									SetControl32BitValue(ctl, iNibSaveFolderNameMenuItem);
									err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL);
									err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, str);
									EnableMenuItem(menu, iNibSaveFolderNameMenuItem);
									HIViewSetNeedsDisplay(ctl, true);

									CFRelease(str);

									str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
									if (saveFolderPath)
										CFRelease(saveFolderPath);
									saveFolderPath = str;

									CFRelease(url);
								}

								result = noErr;
								break;
							}
						}
					}

					break;
				}
			}

			break;
		}
	}

	return (result);
}