void MacQTVideoConfig(WindowRef parent) { OSStatus err; ComponentInstance ci; if (running) return; MacQTOpenVideoComponent(&ci); long flag; flag = scListEveryCodec | scAllowZeroKeyFrameRate | scDisableFrameRateItem; flag |= ((qtVersion >= 0x7008000) ? scAllowEncodingWithCompressionSession : 0); err = SCSetInfo(ci, scPreferenceFlagsType, &flag); #ifdef MAC_QT6_SUPPORT PicHandle pict = nil; if (qtVersion < 0x7008000) { Rect rct; int width, height; width = IPPU.RenderedScreenWidth; height = IPPU.RenderedScreenHeight; pict = GetScreenAsPicHandle(width, height, width, height); HNoPurge((Handle) pict); rct.left = (width - scTestImageWidth) >> 1; rct.top = (height - scTestImageHeight) >> 1; rct.right = rct.left + scTestImageWidth; rct.bottom = rct.top + scTestImageHeight; err = SCSetTestImagePictHandle(ci, pict, &rct, scPreferCropping); }
cursInit() { InitCursor(); waitCursHand = (CursHandle) GetCursor(WAIT_CURSOR_ID); HNoPurge(&waitCursHand); cursIndex = 0; cursStack[0] = CURS_NORM; }
Handle MADGet1Resource( OSType type, short id, MADLibrary* init) { if( init->sysMemory) { Handle tH, dH; tH = Get1Resource( type, id); if( tH == NULL) return NULL; DetachResource( tH); HNoPurge( tH); dH = NewHandle( GetHandleSize( tH)); if( dH == NULL) MyDebugStr( __LINE__, __FILE__, ""); if( MemError() != noErr) MyDebugStr( __LINE__, __FILE__, ""); HLock( dH); HLock( tH); BlockMoveData( *tH, *dH, GetHandleSize( tH)); HUnlock( dH); HUnlock( tH); DisposeHandle( tH); tH = NULL; return dH; } else { Handle dH = Get1Resource( type, id); if( dH == NULL) return NULL; DetachResource( dH); HNoPurge( dH); return dH; } }
/* ---------------------------------------------------------------------------- tbitStartup Initialize TPS off-screen bitmap subsystem at startup. Returns error code indicating success. ---------------------------------------------------------------------------- */ TPSAPI_DECLP( BOOLEAN ) tbitStartup (uWORD NrPorts, uWORD depth, HNATIVE hColor) { sWORD i; Rect Bounds; OSErr osError = noErr; SignedByte saveState; PixMapHandle hPixMap = nil; // handle to new off-screen PixMap short bytesPerRow; // bytes per row in PixMap fHasColorQuickdraw = tsysMacHasCQD(true); /** validations/initializations **/ TpsAssert((_TPorts == nil), "Bitmap subsystem was already been started up!"); TpsAssert((hColor != nil), "Bitmap subsystem color table must be provided!"); TpsAssert(tsysMacHasSys7(), "System 7 or greater required!"); TpsAssert(fHasColorQuickdraw, "32Bit Color QuickDraw required!"); TpsAssert(tsysMacHasGWorlds(), "QuickDraw Color GWorlds required!"); GetPort(&_pStartupPort); _hStartupDevice = GetGDevice(); /** clone the clut (to be used throughout) **/ saveState = HGetState((Handle)hColor); // save color tableÕs current state HNoPurge((Handle)hColor); // make sure it isnÕt purgeable _hColorTable = (CTabHandle)hColor; osError = HandToHand((Handle *)&_hColorTable); HSetState((Handle)hColor, saveState); // restore color tableÕs state if (osError != noErr) { // terrSetErrorCode(TERR_TMEMSECTION, TMEM_ERRALLOC); return FALSE; } /** create device (to be used throughout) **/ //SetRect(&Bounds, 0, 0, 1, 1); Bounds.left = 0; Bounds.top = 0; Bounds.right = 1; Bounds.bottom = 1; bytesPerRow = 16; // 16 byte align rowbytes if ((hPixMap = (PixMapHandle)NewHandleClear(sizeof(PixMap))) == nil) goto Failure; if (_SetUpPixMap(depth, &Bounds, _hColorTable, bytesPerRow, hPixMap) != noErr) goto Failure; if ((_hTBitDevice = (GDHandle)NewHandleClear(sizeof(GDevice))) == nil) goto Failure; if (_CreateGDevice(hPixMap, _hTBitDevice) != noErr) goto Failure; /** create internal port list **/ if ((_TPorts = (TBitPort *)NewPtrClear(sizeof(TBitPort) * (NrPorts + 1))) == nil) goto Failure; /** create pool of off-screen ports **/ //SetRect(&Bounds, 0, 0, 1, 1); Bounds.left = 0; Bounds.top = 0; Bounds.right = 1; Bounds.bottom = 1; for (i = 0; i < NrPorts; i++) { if ((_TPorts[i].pPort = (CGrafPtr)NewPtrClear(sizeof(CGrafPort))) == nil) goto Failure; OpenCPort(_TPorts[i].pPort); _TPorts[i].hOldPixMap = (_TPorts[i].pPort)->portPixMap; SetPortPix(nil); } /** clean up and out **/ SetPort(_pStartupPort); SetGDevice(_hStartupDevice); _NrTPorts = NrPorts; return TRUE; Failure: if (hPixMap != nil) { if ((**hPixMap).pmTable != nil) DisposCTable((**hPixMap).pmTable); if ((**hPixMap).baseAddr != nil) DisposHandle((Handle)(**hPixMap).baseAddr); DisposHandle((Handle)hPixMap); } if (_hTBitDevice != nil) { if ((**_hTBitDevice).gdITable != nil) DisposHandle((Handle)(**_hTBitDevice).gdITable); DisposHandle((Handle)_hTBitDevice); _hTBitDevice = nil; } if (_TPorts != nil) { for (i = 0; i < NrPorts; i++) { if (_TPorts[i].pPort != nil) { SetPort((GrafPtr)_TPorts[i].pPort); SetPortPix(_TPorts[i].hOldPixMap); CloseCPort(_TPorts[i].pPort); } } tmemFreeNativePtr(_TPorts); _TPorts = nil; } if (_hColorTable != nil) DisposCTable(_hColorTable); SetGDevice(_hStartupDevice); SetPort(_pStartupPort); // terrSetErrorCode(TERR_TMEMSECTION, TMEM_ERRALLOC); return FALSE; }
McoStatus ThermDialog::SetUpTherm(int therm_num) { Rect r; Handle h; short itemType; short wi,hi; short ids1[] = THERM_IDs_1; short ids2[] = THERM_IDs_2; int i; Str255 theString; Quit = FALSE; //if (therm_num == 3) for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids2[i]; //else for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids1[i]; GetPort(&olddp); dt = (DialogTHndl) GetResource ('DLOG',ids[THERM_DLG]); if (! dt) return(MCO_RSRC_ERROR); HNoPurge ((Handle) dt); r = (**dt).boundsRect; #define menuHeight 20 wi = qd.screenBits.bounds.right; hi = qd.screenBits.bounds.bottom; OffsetRect (&r, -r.left, -r.top); OffsetRect (&r, (wi - r.right) / 2, (hi - r.bottom - menuHeight) / 3 + menuHeight); (**dt).boundsRect = r; #undef menuHeight dp = GetNewDialog (ids[THERM_DLG], nil, (WindowPtr) -1); if (! dp) { HPurge ((Handle) dt); return(MCO_RSRC_ERROR); } GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r); GetIndString(theString,THERM_MESS,therm_num); SetIText(h,theString); SetPort(dp); ShowWindow(dp); DrawDialog(dp); box_d_item(dp,ids[THERM_BOX]); return MCO_SUCCESS; }
Boolean DoUI (GPtr globals) { short item; Str255 hS = ""; //histstatus int16 currentResources = 0; DialogPtr dp; DialogTHndl dt; gStuff->theRect.top = gStuff->theRect.left = gStuff->theRect.bottom = gStuff->theRect.right = 0; dt = (DialogTHndl) GetResource ('DLOG', uiID); HNoPurge ((Handle) dt); CenterDialog (dt); dp = GetNewDialog (uiID, nil, (WindowPtr) -1); (void) SetDialogDefaultItem (dp, ok); (void) SetDialogCancelItem (dp, cancel); PIGetString(kHistStatus, hS); // get status string do { currentResources = CountPIResources(histResource); if (gCurrentHistory < 1) gCurrentHistory = 1; if (gCurrentHistory > currentResources) gCurrentHistory = currentResources; if (currentResources <= kDHistTotal || gCurrentHistory+kDHistTotal > currentResources) PIDisableControl (dp, kDDownButton); // nothing extra to show else PIEnableControl (dp, kDDownButton); if (gCurrentHistory < 2) PIDisableControl (dp, kDUpButton); else PIEnableControl (dp, kDUpButton); if (currentResources >= gCurrentHistory && currentResources > 0) { PIEnableControl (dp, kDTrimFirst); PIEnableControl (dp, kDTrimLast); } else { PIDisableControl (dp, kDTrimFirst); PIDisableControl (dp, kDTrimLast); } UpdateHistories(globals, dp, currentResources, hS); MoveableModalDialog (dp, gStuff->processEvent, nil, &item); switch (item) { case cancel: gResult = userCanceledErr; // have to set this so we don't get recorded break; case kDTrimFirst: if (currentResources >= gCurrentHistory) { DeletePIResource (histResource, gCurrentHistory); gStuff->dirty = TRUE; } break; case kDTrimLast: if (currentResources >= gCurrentHistory + kDHistTotal-1) { DeletePIResource (histResource, gCurrentHistory+ kDHistTotal-1); gStuff->dirty = TRUE; } else if (currentResources > 0) { DeletePIResource (histResource, currentResources); gStuff->dirty = TRUE; } break; case kDUpButton: gCurrentHistory--; break; case kDDownButton: gCurrentHistory++; break; } // end switch (item) } while (item != ok && item != cancel); DisposeDialog (dp); HPurge ((Handle) dt); return (item == ok); }
void createOffscreen() { Rect rect; Handle iclHandle; char *image; int row, col, index, value; SetRect( &rect, 0, 0, 32, 32 ); /* Create offscreen pixmap image using an 'icl8' icon resource. */ iclHandle = GetResource( 'icl8', 129 ); HandToHand( &iclHandle ); HLock( iclHandle ); HNoPurge( iclHandle ); //gPixmap = (PixMapHandle)NewHandle( sizeof( PixMap ) ); gPixmap = NewPixMap(); (**gPixmap).baseAddr = *iclHandle; (**gPixmap).rowBytes = ((32 * 8) / 8) | 0x8000; (**gPixmap).bounds = rect; (**gPixmap).pmVersion = 0; (**gPixmap).packType = 0; (**gPixmap).packSize = 0; (**gPixmap).hRes = 72; (**gPixmap).vRes = 72; (**gPixmap).pixelSize = 8; //(**gPixmap).planeBytes = 0; //(**gPixmap).pmReserved = 0; (**gPixmap).pixelType = 0; (**gPixmap).cmpCount = 1; (**gPixmap).cmpSize = 8; (**gPixmap).pmTable = GetCTable( 8 ); (**gPixmap).pixelFormat = 0; /* Give a unique seed for the pixmap's colortable. */ (**(**gPixmap).pmTable).ctSeed = GetCTSeed(); SetRect( &rect, 0, 0, 20, 20 ); /* Set the pointer to the beginning of the pixel image. */ image = GetPixBaseAddr( gPixmap ); /*****************************************************************/ /* For this example, let's set the pixel values of the left half */ /* of the image to half their original values. */ /*****************************************************************/ for (row = 0; row < rect.bottom; row++) { // Loop through the first 10 columns of the pixel image. for (index = 0, col = 0; col < rect.right / 2; col++) { // Set the value at this index to half its value. value = (unsigned char)*(image + index); *(image + index) = value / 2; index++; } // Increment the pointer to the next row of the pixel image. image += ((**gPixmap).rowBytes & 0x7fff); } }
OSErr NetDDPOpenSocket( short *socketNumber, packetHandlerProcPtr packetHandler) { OSErr error; Handle socket_listener_resource; ProcPtr initialize_socket_listener, socket_listener; MPPPBPtr myMPPPBPtr= (MPPPBPtr) NewPtrClear(sizeof(MPPParamBlock)); static ProcPtr initialize_upp = NULL; static UniversalProcPtr packet_handler_upp = NULL; assert(packetHandler); /* canÕt have NULL packet handlers */ assert(!ddpPacketBuffer); /* canÕt have more than one socket listener installed */ socket_listener_resource = GetResource(SOCKET_LISTENER_RESOURCE_TYPE, SOCKET_LISTENER_ID); assert(socket_listener_resource); HLock(socket_listener_resource); HNoPurge(socket_listener_resource); initialize_socket_listener = (ProcPtr) StripAddress(*socket_listener_resource); ddpPacketBuffer= (DDPPacketBufferPtr) NewPtrClear(sizeof(DDPPacketBuffer)); error= MemError(); if (error==noErr) { if (packet_handler_upp == NULL) { packet_handler_upp = (UniversalProcPtr) NewRoutineDescriptor((ProcPtr) packetHandler, uppPacketHandlerProcInfo, GetCurrentISA()); } assert(packet_handler_upp); if (initialize_upp == NULL) { initialize_upp = (ProcPtr) NewRoutineDescriptor((ProcPtr) initialize_socket_listener, uppInitializeListenerProcInfo, kM68kISA); // it's in a 68k code resource } assert(initialize_upp); #ifdef env68k // it seems that we don't have CallUniversalProc() in the library. strange... #ifndef VULCAN socket_listener = (ProcPtr) initialize_socket_listener(packet_handler_upp, ddpPacketBuffer, 1); #else debugstr("Hey, socket listener was never initialized"); #endif #else socket_listener = (ProcPtr) CallUniversalProc((UniversalProcPtr) initialize_upp, uppInitializeListenerProcInfo, packet_handler_upp, ddpPacketBuffer, 1); #endif listenerUPP = (DDPSocketListenerUPP) NewRoutineDescriptor((ProcPtr) socket_listener, uppDDPSocketListenerProcInfo, kM68kISA); // have to force it to realize that it's a 68K resource assert(listenerUPP); myMPPPBPtr->DDP.socket= 0; myMPPPBPtr->DDP.u.listener= listenerUPP; error= POpenSkt(myMPPPBPtr, FALSE); if (error==noErr) { *socketNumber= myMPPPBPtr->DDP.socket; } DisposePtr((Ptr)myMPPPBPtr); } return error; }
Boolean DoUI (GPtr globals) { short item, lastitem; short numberErr = noErr; long x; DialogPtr dp; DialogTHndl dialogHdl; dialogHdl = (DialogTHndl) GetResource ('DLOG', uiID); if (dialogHdl == NULL || *dialogHdl == NULL) return false; else { HNoPurge ((Handle) dialogHdl); CenterDialog (dialogHdl); dp = GetNewDialog (uiID, nil, (WindowPtr) -1); /* I am throwing away the results from these routines. Toolbox TechNote 37 does not document what error values they return. Also, the worst that happens is that the interface isn't quite right. */ (void) SetDialogDefaultItem (dp, ok); (void) SetDialogCancelItem (dp, cancel); (void) SetDialogTracksCursor (dp, TRUE); SetRadioGroupState (dp, kFirstItem, kLastItem, kFirstItem + gWhatArea); SetRadioGroupState (dp, kUseRadio1, kUseRadioLast, kUseRadio1 + gWhatChannels); SetRadioGroupState (dp, kCreateRadio1, kCreateRadioLast, kCreateRadio1 + gCreate); ShowHideItem (dp, kPercentStatic, (gWhatArea == iSelectRandom)); ShowHideItem (dp, kPercentEdit, (gWhatArea == iSelectRandom)); ShowHideItem (dp, kPercentSymbol, (gWhatArea == iSelectRandom)); StuffNumber(dp, kPercentEdit, gPercent); if (gWhatArea == iSelectRandom) SelectTextItem(dp, kPercentEdit); SelectWindow (GetDialogWindow(dp)); do { MoveableModalDialog (dp, gStuff->processEvent, nil, &item); if (lastitem != item && item != cancel) { /* we just left this area. Check to make sure its within bounds. */ switch (lastitem) { case kPercentEdit: numberErr = FetchNumber(dp, kPercentEdit, kPercentMin, kPercentMax, &x); if (numberErr != noErr) { // shows alert if there's an error AlertNumber(dp, kPercentEdit, kPercentMin, kPercentMax, &x, AlertID, numberErr); item = kPercentEdit; // stay here } gPercent = x; break; } } switch (item) { case ok: gWhatArea = GetRadioGroupState(dp, kFirstItem, kLastItem) - kFirstItem; gWhatChannels = GetRadioGroupState(dp, kUseRadio1, kUseRadioLast) - kUseRadio1; gCreate = GetRadioGroupState(dp, kCreateRadio1, kCreateRadioLast) - kCreateRadio1; if (gWhatArea == iSelectRandom) { numberErr = FetchNumber(dp, kPercentEdit, kPercentMin, kPercentMax, &x); if (numberErr != noErr) { // shows alert if there's an error AlertNumber(dp, kPercentEdit, kPercentMin, kPercentMax, &x, AlertID, numberErr); item = kPercentEdit; // go back } else gPercent = x; // it's okay, move on } break; case cancel: gResult = userCanceledErr; break; case kPercentEdit: // grab the number whether it's right or not numberErr = FetchNumber(dp, kPercentEdit, kPercentMin, kPercentMax, &x); if (numberErr == noErr) { // no errors getting the number gPercent = x; // update display here } break; default: if (item >= kFirstItem && item <= kLastItem) { SetRadioGroupState (dp, kFirstItem, kLastItem, item); ShowHideItem (dp, kPercentStatic, (item == iSelectRandom + kFirstItem)); ShowHideItem (dp, kPercentEdit, (item == iSelectRandom + kFirstItem)); ShowHideItem (dp, kPercentSymbol, (item == iSelectRandom + kFirstItem)); if (item == iSelectRandom + kFirstItem) SelectTextItem(dp, kPercentEdit); } else if (item >= kUseRadio1 && item <= kUseRadioLast) SetRadioGroupState (dp, kUseRadio1, kUseRadioLast, item); else if (item >= kCreateRadio1 && item <= kCreateRadioLast) SetRadioGroupState (dp, kCreateRadio1, kCreateRadioLast, item); break; } lastitem = item; } while (item != ok && item != cancel); DisposeDialog (dp); if (dialogHdl != NULL && *dialogHdl != NULL) HPurge ((Handle) dialogHdl); dp = NULL; dialogHdl = NULL; return item == ok; } // else }
void MacQTVideoConfig(WindowRef parent) { OSStatus err; ComponentInstance ci; if (running) return; MacQTOpenVideoComponent(&ci); long flag; flag = scListEveryCodec | scAllowZeroKeyFrameRate | scDisableFrameRateItem; err = SCSetInfo(ci, scPreferenceFlagsType, &flag); PicHandle pict; Rect rct; int width, height; width = IPPU.RenderedScreenWidth; height = IPPU.RenderedScreenHeight; pict = GetScreenAsPicHandle(width, height, width, height); HNoPurge((Handle) pict); rct.left = (width - scTestImageWidth) >> 1; rct.top = (height - scTestImageHeight) >> 1; rct.right = rct.left + scTestImageWidth; rct.bottom = rct.top + scTestImageHeight; err = SCSetTestImagePictHandle(ci, pict, &rct, scPreferCropping); SCWindowSettings ws; ws.size = sizeof(SCWindowSettings); ws.windowRefKind = scWindowRefKindCarbon; ws.parentWindow = parent; err = SCSetInfo(ci, scWindowOptionsType, &ws); err = SCRequestSequenceSettings(ci); if (err == noErr) { CFDataRef data; Handle hdl; err = SCGetInfo(ci, scSettingsStateType, &hdl); if (err == noErr) { HLock(hdl); data = CFDataCreate(kCFAllocatorDefault, (unsigned char *) *hdl, GetHandleSize(hdl)); if (data) { CFPreferencesSetAppValue(CFSTR("QTVideoSetting"), data, kCFPreferencesCurrentApplication); CFRelease(data); } DisposeHandle(hdl); } } MacQTCloseVideoComponent(ci); KillPicture(pict); }