Пример #1
0
void MyLUpdateVisRgn(DialogRef theDialog, ListHandle listHdl)
{
	#if TARGET_API_MAC_CARBON
		RgnHandle   visRgn = NewRgn();
		if(visRgn) GetPortVisibleRegion(GetDialogPort(theDialog), visRgn);
		LUpdate(visRgn,listHdl);
		if(visRgn) DisposeRgn(visRgn);	
	#else
		LUpdate(theDialog->visRgn,listHdl);
	#endif
}
void do_about_box( void)
{
	GrafPtr oldPort;
	DialogPtr dptr;
	short item, itemType;
	Handle itemHdl;
	Rect itemRect;

	dptr = GetNewDialog( rAboutBox, nil, (WindowPtr)-1L);
	
	if( dptr == (DialogPtr)0){
		Handle items = NewHandle( sizeof(missing_DITL));
		static Rect bounds = {40, 20, 150, 340};

		if( ! items) return;
		BlockMove( missing_DITL, *items, sizeof(missing_DITL));

		dptr = NewColorDialog( nil, &bounds, (unsigned char*)"\005About",
					false, dBoxProc, (WindowPtr)-1L, false, 0, items);
                }
	
	if( dptr == (DialogPtr)0) return;
	GetPort (&oldPort);
	SetPort (GetDialogPort(dptr));
	GetDialogItem( dptr, ok, &itemType, &itemHdl, &itemRect);
	InsetRect( &itemRect, -4, -4);
	SetDialogItem( dptr, 6, userItem + itemDisable, (Handle)outline_hook_upp, &itemRect);

	FlushEvents( everyEvent, 0);
        ShowWindow( GetDialogWindow(dptr));

	do {
		ModalDialog( about_filter_upp, &item);
	} while( item != ok);

	DisposeDialog( dptr);
	SetPort( oldPort);
}
char *QTTarg_GetStringFromUser (short thePromptStringIndex)
{
	short 			myItem;
	short 			mySavedResFile;
	GrafPtr			mySavedPort;
	DialogPtr		myDialog = NULL;
	short			myItemKind;
	Handle			myItemHandle;
	Rect			myItemRect;
	Str255			myString;
	char			*myCString = NULL;
	OSErr			myErr = noErr;

	//////////
	//
	// save the current resource file and graphics port
	//
	//////////

	mySavedResFile = CurResFile();
	GetPort(&mySavedPort);

	// set the application's resource file
	UseResFile(gAppResFile);

	//////////
	//
	// create the dialog box in which the user will enter a URL
	//
	//////////

	myDialog = GetNewDialog(kGetStr_DLOGID, NULL, (WindowPtr)-1L);
	if (myDialog == NULL)
		goto bail;

	QTFrame_ActivateController(QTFrame_GetFrontMovieWindow(), false);
	
	MacSetPort(GetDialogPort(myDialog));
	
	SetDialogDefaultItem(myDialog, kGetStr_OKButton);
	SetDialogCancelItem(myDialog, kGetStr_CancelButton);
	
	// set the prompt string	
	GetIndString(myString, kTextKindsResourceID, thePromptStringIndex);

	GetDialogItem(myDialog, kGetStr_StrLabelItem, &myItemKind, &myItemHandle, &myItemRect);
	SetDialogItemText(myItemHandle, myString);
	
	MacShowWindow(GetDialogWindow(myDialog));
	
	//////////
	//
	// display and handle events in the dialog box until the user clicks OK or Cancel
	//
	//////////
	
	do {
		ModalDialog(gModalFilterUPP, &myItem);
	} while ((myItem != kGetStr_OKButton) && (myItem != kGetStr_CancelButton));
	
	//////////
	//
	// handle the selected button
	//
	//////////
	
	if (myItem != kGetStr_OKButton) {
		myErr = userCanceledErr;
		goto bail;
	}
	
	// retrieve the edited text
	GetDialogItem(myDialog, kGetStr_StrTextItem, &myItemKind, &myItemHandle, &myItemRect);
	GetDialogItemText(myItemHandle, myString);
	myCString = QTUtils_ConvertPascalToCString(myString);
	
bail:
	// restore the previous resource file and graphics port
	MacSetPort(mySavedPort);
	UseResFile(mySavedResFile);
	
	if (myDialog != NULL)
		DisposeDialog(myDialog);

	return(myCString);
}
Пример #4
0
Boolean QTInfo_EditAnnotation (Movie theMovie, OSType theType)
{
    DialogPtr		myDialog = NULL;
    short 			myItem;
    short 			mySavedResFile;
    GrafPtr			mySavedPort;
    Handle			myHandle = NULL;
    short			myItemKind;
    Handle			myItemHandle;
    UserData		myUserData = NULL;
    Rect			myItemRect;
    Str255			myString;
    Boolean			myIsChanged = false;
    OSErr			myErr = noErr;

    //////////
    //
    // save the current resource file and graphics port
    //
    //////////

    mySavedResFile = CurResFile();
    GetPort(&mySavedPort);

    // set the application's resource file
    UseResFile(gAppResFile);

    // get the movie user data
    myUserData = GetMovieUserData(theMovie);
    if (myUserData == NULL)
        goto bail;

    //////////
    //
    // create the dialog box in which the user will add or edit the annotation
    //
    //////////

    myDialog = GetNewDialog(kEditTextResourceID, NULL, (WindowPtr)-1L);
    if (myDialog == NULL)
        goto bail;

    MacSetPort(GetDialogPort(myDialog));

    SetDialogDefaultItem(myDialog, kEditTextItemOK);
    SetDialogCancelItem(myDialog, kEditTextItemCancel);

    // get a string for the specified annotation type
    switch (theType) {
    case kUserDataTextFullName:
        GetIndString(myString, kTextKindsResourceID, kTextKindsFullName);
        break;

    case kUserDataTextCopyright:
        GetIndString(myString, kTextKindsResourceID, kTextKindsCopyright);
        break;

    case kUserDataTextInformation:
        GetIndString(myString, kTextKindsResourceID, kTextKindsInformation);
        break;
    }

    GetDialogItem(myDialog, kEditTextItemEditLabel, &myItemKind, &myItemHandle, &myItemRect);
    SetDialogItemText(myItemHandle, myString);

    //////////
    //
    // set the current annotation of the specified type, if it exists
    //
    //////////

    myHandle = NewHandleClear(4);
    if (myHandle != NULL) {
        myErr = GetUserDataText(myUserData, myHandle, theType, 1, GetScriptManagerVariable(smRegionCode));
        if (myErr == noErr) {
            QTInfo_TextHandleToPString(myHandle, myString);
            GetDialogItem(myDialog, kEditTextItemEditBox, &myItemKind, &myItemHandle, &myItemRect);
            SetDialogItemText(myItemHandle, myString);
            SelectDialogItemText(myDialog, kEditTextItemEditBox, 0, myString[0]);
        }

        DisposeHandle(myHandle);
    }

    MacShowWindow(GetDialogWindow(myDialog));

    //////////
    //
    // display and handle events in the dialog box until the user clicks OK or Cancel
    //
    //////////

    do {
        ModalDialog(gModalFilterUPP, &myItem);
    } while ((myItem != kEditTextItemOK) && (myItem != kEditTextItemCancel));

    //////////
    //
    // handle the selected button
    //
    //////////

    if (myItem != kEditTextItemOK)
        goto bail;

    // retrieve the edited text
    myHandle = NewHandleClear(4);
    if (myHandle != NULL) {
        GetDialogItem(myDialog, kEditTextItemEditBox, &myItemKind, &myItemHandle, &myItemRect);
        GetDialogItemText(myItemHandle, myString);
        QTInfo_PStringToTextHandle(myString, myHandle);
        myErr = AddUserDataText(myUserData, myHandle, theType, 1, GetScriptManagerVariable(smRegionCode));
        myIsChanged = (myErr == noErr);
        DisposeHandle(myHandle);
    }

bail:
    // restore the previous resource file and graphics port
    MacSetPort(mySavedPort);
    UseResFile(mySavedResFile);

    if (myDialog != NULL)
        DisposeDialog(myDialog);

    return(myIsChanged);
}
Пример #5
0
/* Initialize the QuickTime grabber */
static int qt_open_grabber(struct qt_grabber_state *s, char *fmt)
{
        GrafPtr savedPort;
        WindowPtr gMonitor;
        //SGModalFilterUPP      seqGrabModalFilterUPP;

        assert(s != NULL);
        assert(s->magic == MAGIC_QT_GRABBER);

        /****************************************************************************************/
        /* Step 0: Initialise the QuickTime movie toolbox.                                      */
        InitCursor();
        EnterMovies();

        /****************************************************************************************/
        /* Step 1: Create an off-screen graphics world object, into which we can capture video. */
        /* Lock it into position, to prevent QuickTime from messing with it while capturing.    */
        OSType pixelFormat;
        pixelFormat = FOUR_CHAR_CODE('BGRA');
        /****************************************************************************************/
        /* Step 2: Open and initialise the default sequence grabber.                            */
        s->grabber = OpenDefaultComponent(SeqGrabComponentType, 0);
        if (s->grabber == 0) {
                debug_msg("Unable to open grabber\n");
                return 0;
        }

        gMonitor = GetDialogWindow(GetNewDialog(1000, NULL, (WindowPtr) - 1L));

        GetPort(&savedPort);
        SetPort((GrafPtr)gMonitor);

        if (SGInitialize(s->grabber) != noErr) {
                debug_msg("Unable to init grabber\n");
                return 0;
        }

        SGSetGWorld(s->grabber, GetDialogPort((DialogPtr)gMonitor), NULL);

        /****************************************************************************************/
        /* Specify the destination data reference for a record operation tell it */
        /* we're not making a movie if the flag seqGrabDontMakeMovie is used,    */
        /* the sequence grabber still calls your data function, but does not     */
        /* write any data to the movie file writeType will always be set to      */
        /* seqGrabWriteAppend                                                    */
        if (SGSetDataRef(s->grabber, 0, 0, seqGrabDontMakeMovie) != noErr) {
                CloseComponent(s->grabber);
                debug_msg("Unable to set data ref\n");
                return 0;
        }

        if (SGSetGWorld(s->grabber, NULL, NULL) != noErr) {
                debug_msg("Unable to get gworld from grabber\n");
                return 0;
        }

        if (SGNewChannel(s->grabber, VideoMediaType, &s->video_channel) !=
            noErr) {
                debug_msg("Unable to open video channel\n");
                return 0;
        }

        /* do not check for grab audio in case that we will only display usage */
        if (SGNewChannel(s->grabber, SoundMediaType, &s->audio_channel) !=
                noErr) {
                fprintf(stderr, "Warning: Creating audio channel failed. "
                                "Disabling sound output.\n");
                s->grab_audio = FALSE;
        }

        /* Print available devices */
        int i;
        int j;
        SGDeviceInputList inputList;
        SGDeviceList deviceList;
        if (strcmp(fmt, "help") == 0) {
                printf("\nUsage:\t-t quicktime:<device>:<mode>:<pixel_type>[:<audio_device>:<audio_mode>]\n\n");
                if (SGGetChannelDeviceList
                    (s->video_channel, sgDeviceListIncludeInputs,
                     &deviceList) == noErr) {
                        fprintf(stdout, "\nAvailable capture devices:\n");
                        for (i = 0; i < (*deviceList)->count; i++) {
                                SGDeviceName *deviceEntry =
                                    &(*deviceList)->entry[i];
                                fprintf(stdout, " Device %d: ", i);
                                nprintf((char *) deviceEntry->name);
                                if (deviceEntry->flags &
                                    sgDeviceNameFlagDeviceUnavailable) {
                                        fprintf(stdout,
                                                "  - ### NOT AVAILABLE ###");
                                }
                                if (i == (*deviceList)->selectedIndex) {
                                        fprintf(stdout, " - ### ACTIVE ###");
                                }
                                fprintf(stdout, "\n");
                                short activeInputIndex = 0;
                                inputList = deviceEntry->inputs;
                                if (inputList && (*inputList)->count >= 1) {
                                        SGGetChannelDeviceAndInputNames
                                            (s->video_channel, NULL, NULL,
                                             &activeInputIndex);
                                        for (j = 0; j < (*inputList)->count;
                                             j++) {
                                                fprintf(stdout, "\t");
                                                fprintf(stdout, "- %d. ", j);
                                                nprintf((char *) &(*inputList)->entry
                                                             [j].name);
                                                if ((i ==
                                                     (*deviceList)->selectedIndex)
                                                    && (j == activeInputIndex))
                                                        fprintf(stdout,
                                                                " - ### ACTIVE ###");
                                                fprintf(stdout, "\n");
                                        }
                                }
                        }
                        SGDisposeDeviceList(s->grabber, deviceList);
                        CodecNameSpecListPtr list;
                        GetCodecNameList(&list, 1);
                        printf("\nCompression types:\n");
                        for (i = 0; i < list->count; i++) {
                                int fcc = list->list[i].cType;
                                printf("\t%d) ", i);
                                nprintf((char *) list->list[i].typeName);
                                printf(" - FCC (%c%c%c%c)",
                                       fcc >> 24,
                                       (fcc >> 16) & 0xff,
                                       (fcc >> 8) & 0xff, (fcc) & 0xff);
                                printf(" - codec id %x",
                                       (unsigned int)(list->list[i].codec));
                                printf(" - cType %x",
                                       (unsigned int)list->list[i].cType);
                                printf("\n");
                        }
                }