CProgressMac::CProgressMac(PW_WindowType type) { ResIDT windowID; fCancelcb = NULL; fCancelClosure = NULL; switch (type) { case pwApplicationModal: windowID = kProgressModalWindowID; break; case pwStandard: windowID = kProgressStandardWindowID; break; default: XP_ASSERT(false); // invalid window type } fWindow = LWindow::CreateWindow( windowID, (type == pwApplicationModal) ? NULL : LCommander::GetTopCommander()); ThrowIfNil_(fWindow); fLine1 = (LCaption*)fWindow->FindPaneByID('LIN1'); fLine2 = (LCaption*)fWindow->FindPaneByID('LIN2'); fLine3 = (LCaption*)fWindow->FindPaneByID('LIN3'); fProgress = (CPatternProgressBar *)fWindow->FindPaneByID('PtPb'); ThrowIfNil_(fLine1); ThrowIfNil_(fLine2); ThrowIfNil_(fLine3); ThrowIfNil_(fProgress); }
/*=============================================== FinishCreateSelf ================================================*/ void PTCursorView::FinishCreateSelf() { PTPaintView::FinishCreateSelf(); /* note: crsr - has mColorSample, mBWSample, mMaskSample CURS - has mBWSample & mMaskSample */ mColorSample = (PTDraggableTargetBox*) this->FindPaneByID( ImageType_ColorCursor ); mBWSample = (PTDraggableTargetBox*) this->FindPaneByID( ImageType_Cursor ); mMaskSample = (PTDraggableTargetBox*) this->FindPaneByID( PaneID_Mask ); ThrowIfNil_( mBWSample ); ThrowIfNil_( mMaskSample ); /* keep track of the sample panes */ mNumSamplePanes = 0; if ( mColorSample ) mSamplePaneList[ mNumSamplePanes++ ] = mColorSample; mSamplePaneList[ mNumSamplePanes++ ] = mBWSample; mSamplePaneList[ mNumSamplePanes++ ] = mMaskSample; /* we need to listen to the sample panes (click and/or drop operations) */ this->BecomeListenerTo( mNumSamplePanes, mSamplePaneList ); }
ADataStore::ADataStore(SInt16 inStrcResID) { // ** NOT THREAD SAFE ** ASSERT(inStrcResID >= 128); // Strc ids 0..127 are reserved for internal use itsDefaultComparator = (LComparator*)nil; mBatchMode = false; mLastRecID = 0; mFileOpen = false; mOwnsComparator = false; itsStream = (LStream*)nil; SetDefaultComparator(new CRecIDComparator, true); // use a ID comparator as initial default mStrcResID = inStrcResID; mStructure = (UStructure*)nil; #if DB_THREAD_SUPPORT if (UEnvironment::HasFeature(env_HasThreadsManager)) { mChangeID = new LMutexSemaphore(); mAccessHeader = new LMutexSemaphore(); mAccessData = new LMutexSemaphore(); mChangeInfo = new LMutexSemaphore(); ThrowIfNil_(mChangeID); ThrowIfNil_(mAccessHeader); ThrowIfNil_(mAccessData); ThrowIfNil_(mChangeInfo); } else { mChangeID = (LMutexSemaphore*)nil; mAccessHeader = (LMutexSemaphore*)nil; mAccessData = (LMutexSemaphore*)nil; mChangeInfo = (LMutexSemaphore*)nil; } #endif DB_DEBUG("Contructed v1.5 Datastore: struct id " << inStrcResID, DEBUG_TRIVIA); }
ADataStore::ADataStore() { // ** NOT THREAD SAFE ** itsDefaultComparator = (LComparator*)nil; mBatchMode = false; mLastRecID = 0; mFileOpen = false; itsStream = (LStream*)nil; SetDefaultComparator(new CRecIDComparator); // use a ID comparator as initial default #if DB_THREAD_SUPPORT if (UEnvironment::HasFeature(env_HasThreadsManager)) { mChangeID = new LMutexSemaphore(); mAccessHeader = new LMutexSemaphore(); mAccessData = new LMutexSemaphore(); mChangeInfo = new LMutexSemaphore(); ThrowIfNil_(mChangeID); ThrowIfNil_(mAccessHeader); ThrowIfNil_(mAccessData); ThrowIfNil_(mChangeInfo); } else { mChangeID = (LMutexSemaphore*)nil; mAccessHeader = (LMutexSemaphore*)nil; mAccessData = (LMutexSemaphore*)nil; mChangeInfo = (LMutexSemaphore*)nil; } #endif DB_DEBUG("Contructed v1.0 Datastore", DEBUG_TRIVIA); }
/*=============================================== PutOnDuty ================================================*/ void PTPaintView::PutOnDuty( LCommander *inNewTarget ) { /* flush pending mouseDown events because Constructor has "set front clicks" flag set and users don't expect to accidentally start painting when they click on our paint window when we're not the foreground application. this is probably a bug in PowerPlant -- we shouldn't really see the click because we have cleared our "getfrontclick" flag for this particular window. but this fixes it. */ ::FlushEvents( mDownMask, 0 ); LWindow::PutOnDuty(inNewTarget); /***************************************** put up our menus when we're on duty *****************************************/ { StApplicationContext appContext; //¥ 2.3b3: BUG FIX #934: must load from application file if ( !sOptionsMenu ) { sOptionsMenu = new LMenu( MenuID_PaintOptions ); ThrowIfNil_( sOptionsMenu ); } if ( !sColorsMenu ) { sColorsMenu = new LMenu( MenuID_PaintColors ); ThrowIfNil_( sColorsMenu ); } if ( !sStyleMenu ) { sStyleMenu = new LMenu( MenuID_PaintStyle ); ThrowIfNil_( sStyleMenu ); } if ( !sFontMenu ) { sFontMenu = new LMenu( MenuID_PaintFont ); ThrowIfNil_( sFontMenu ); MenuHandle macH = sFontMenu->GetMacMenuH(); if ( macH ) ::AppendResMenu( macH, 'FONT' ); } } LMenuBar *theBar = LMenuBar::GetCurrentMenuBar(); theBar->InstallMenu( sOptionsMenu, menu_Windows ); theBar->InstallMenu( sColorsMenu, menu_Windows ); theBar->InstallMenu( sFontMenu, menu_Windows ); theBar->InstallMenu( sStyleMenu, menu_Windows ); mWindowIsActive = true; }
/*============================================ SUMiscUtils::FindSibblingPaneByID ==============================================*/ LPane *SUMiscUtils::FindSibblingPaneByID( LPane *inPane, PaneIDT inPaneID ) { ThrowIfNil_( inPane ); LView *topView = SUMiscUtils::GetTopView( inPane ); ThrowIfNil_( topView ); return( topView->FindPaneByID( inPaneID ) ); }
/*=============================================== SaveAsResource ================================================*/ void PTFamilyView::SaveAsResource( RFMap *inMap, ResIDT inResID ) { PaintFamilyMember memberInfo; Int32 numIcons = this->GetFamilyMemberCount(); PTDraggableTargetBox *mainPane, *maskPane; SUOffscreen *mainBuffer, *maskBuffer; for ( Int32 count = 1; count <= numIcons; count++ ) { this->GetFamilyMemberInfo( count, &memberInfo ); /************************************* find the main buffer **************************************/ mainPane = (PTDraggableTargetBox*) this->FindPaneByID( memberInfo.samplePaneID ); ThrowIfNil_( mainPane ); mainBuffer = mainPane->GetBuffer(); ThrowIfNil_( mainBuffer ); /************************************* find the mask buffer (if any) **************************************/ if ( memberInfo.maskRowBytes == 0 ) { maskPane = nil; maskBuffer = nil; } else { maskPane = (PTDraggableTargetBox*) this->FindPaneByID( memberInfo.maskSamplePaneID ); ThrowIfNil_( maskPane ); maskBuffer = maskPane->GetBuffer(); ThrowIfNil_( maskBuffer ); } if ( mainPane->IsUsed() /*|| (maskPane && maskPane->IsUsed())*/ ) { PTGraphicConversions::SaveOffscreenAsResource( inMap, memberInfo.resourceType, inResID, mainBuffer, memberInfo.rowBytes, maskBuffer, memberInfo.maskOffset, memberInfo.maskRowBytes ); } else // delete it if it's unused { RFResource *theResource = inMap->FindResource( memberInfo.resourceType, inResID, false ); if ( theResource ) theResource->DeleteResource(); } } this->SetChangedFlag( false ); }
/*=================================== CopyToUndo ====================================*/ void PTPaintView::CopyToUndo() { ThrowIfNil_( mCurrentImage ); ThrowIfNil_( mUndoBuffer ); // copy the image to the undo buffer mCurrentImage->CopyTo( mUndoBuffer ); // copy the selection to the undo area mUndoSelection->SetSelection( mCurrentSelection ); }
/*=============================================== ParseBWCursor ================================================*/ void PTCursorView::ParseBWCursor( RFMap *inMap, ResIDT inResID, SUOffscreen **outBW, SUOffscreen **outMask, Point *outHotSpot ) { CursHandle h = nil; SUOffscreen *bw = nil, *mask = nil; try { /************************************************** get the raw resource handle **************************************************/ RFResource *theRes = inMap->FindResource( ImageType_Cursor, inResID, false ); ThrowIfNil_( theRes ); h = (CursHandle) theRes->GetResData(); ThrowIfNil_( h ); ::HLock( (Handle) h ); // 2 rowBytes x 16 rows x 2 images + sizeof(Point) if ( ::GetHandleSize( (Handle) h ) != BWCursor_Bytes ) LException::Throw( err_CorruptedResource ); /************************************************** create the bw bitmap **************************************************/ bw = SUOffscreen::CreateBuffer( Cursor_Width, Cursor_Height, 1 ); ThrowIfMemFail_( bw ); //bw->AssignPalette( oneBitTable ); bw->CopyFromRawData( (UInt8*) &(**h).data, BWCursor_RowBytes ); /************************************************** create the mask bitmap **************************************************/ mask = SUOffscreen::CreateBuffer( Cursor_Width, Cursor_Height, 1 ); ThrowIfMemFail_( bw ); mask->CopyFromRawData( (UInt8*) &(**h).mask, BWCursor_RowBytes ); /************************************************** and return stuff to the caller **************************************************/ *outBW = bw; *outMask = mask; *outHotSpot = (**h).hotSpot; } catch( ... ) { SUMiscUtils::DisposeHandle( h ); if ( bw ) delete ( bw ); if ( mask ) delete( mask ); throw; } SUMiscUtils::DisposeHandle( h ); }
/*================================ PastePicture =================================*/ void PTPaintSelection::PastePicture( SUOffscreen *inParentBuffer, PicHandle inPict, RgnHandle inRegion ) { ThrowIfNil_( inParentBuffer ); ThrowIfNil_( inPict ); this->SelectNone(); try { // note: this is after SelectNone() because it might destroy a gworld StSaveGWorld aSaver; Rect r; /**************************************** width & height of our buffer match the picture ****************************************/ SInt32 width = (**inPict).picFrame.right - (**inPict).picFrame.left; SInt32 height = (**inPict).picFrame.bottom - (**inPict).picFrame.top; /**************************************** create an offscreen gworld using the paint view's gworld as a base (use same depth, ctable) ****************************************/ mSelectionBuffer = inParentBuffer->CreateSimilarOffscreen( false /* device???*/, width, height ); /**************************************** image the picture into the offscreen buffer ****************************************/ mSelectionBuffer->BeginDrawing(); // should we erase to the background color instead of white? no. SetRect( &r, 0, 0, width, height ); DrawPicture( inPict, &r ); mSelectionBuffer->EndDrawing(); /**************************************** restore the selection area from the clipboard -- if none, use the entire picture frame ****************************************/ if ( inRegion ) this->SetRawSelection( inRegion ); else { RgnHandle tempRgn = SURegionUtils::NewRegionFromRect( r ); this->SetRawSelection( tempRgn ); SURegionUtils::DisposeRegion( tempRgn ); } } catch( ... ) { this->SelectNone(); throw; } }
RgnHandle VEBackdrop::MakeBackdropRegion( const Rect& inWindowFrameArea) { // Validate pointers. ValidateThis_(); // Make sure we can get the necessary regions. RgnHandle deskRgn = ::NewRgn(); #if PP_Target_Carbon ThrowIfNil_(deskRgn); #else ValidateHandle_((Handle) deskRgn); #endif RgnHandle rootRgn = ::NewRgn(); #if PP_Target_Carbon ThrowIfNil_(rootRgn); #else ValidateHandle_((Handle) rootRgn); #endif // Build a region representing the entire backdrop area. Rect localFrame; CalcLocalFrameRect(localFrame); ::RectRgn(deskRgn, &localFrame); // Build a region for the cutout (root pane) // and cut it out of the backdrop area. Rect baseFrame = inWindowFrameArea; if (baseFrame.right > baseFrame.left) { ::InsetRect(&baseFrame, -1, -1); ::RectRgn(rootRgn, &baseFrame); ::DiffRgn(deskRgn, rootRgn, deskRgn); } // Release temporary region. ::DisposeRgn(rootRgn); // Return the desktop region. return deskRgn; }
/*================================ SetSelection Note: We copy the region and allocate a new selection buffer. =================================*/ void PTPaintSelection::SetSelection( SUOffscreen *inBuffer, RgnHandle inRegion ) { ThrowIfNil_( inBuffer ); ThrowIfNil_( inRegion ); //StSaveGWorld aSaver; -- don't do this because the current gworld might be deleted??? Rect sourceR, destR; SInt32 newWidth, newHeight; Rect theRect; #if PP_Target_Carbon ::GetRegionBounds(inRegion, &theRect); #else theRect = (**inRegion).rgnBBox; #endif newWidth = theRect.right - theRect.left; newHeight = theRect.bottom - theRect.top; if ( (newWidth <= 0) || (newHeight <= 0) ) { this->SelectNone(); return; } try { this->DisposeBuffer(); // make a copy of the region this->SetRawSelection( inRegion ); // create a new offscreen buffer and copy the image #if PP_Target_Carbon ::GetRegionBounds(inRegion, &sourceR); #else sourceR = (**inRegion).rgnBBox; #endif SetRect( &destR, 0, 0, newWidth, newHeight ); mSelectionBuffer = inBuffer->CreateSimilarOffscreen( false, newWidth, newHeight ); mSelectionBuffer->CopyFrom( inBuffer, &destR, &sourceR ); } catch( ... ) { this->SelectNone(); // if an error occurs, force no selection or things get weird throw; } }
void CPrintAttachment::DoPrint() { nsCOMPtr<nsIWebBrowser> wb; mBrowserShell->GetWebBrowser(getter_AddRefs(wb)); ThrowIfNil_(wb); nsCOMPtr<nsIWebBrowserPrint> wbPrint(do_GetInterface(wb)); ThrowIfNil_(wbPrint); nsCOMPtr<nsIPrintSettings> settings; mBrowserShell->GetPrintSettings(getter_AddRefs(settings)); ThrowIfNil_(settings); nsresult rv = wbPrint->Print(settings, nsnull); if (rv != NS_ERROR_ABORT) ThrowIfError_(rv); }
/*================================ PasteOffscreenBuffer =================================*/ void PTPaintSelection::PasteOffscreenBuffer( SUOffscreen *inParentBuffer, SUOffscreen *inBuffer, RgnHandle inRegion ) { ThrowIfNil_( inParentBuffer ); ThrowIfNil_( inBuffer ); this->SelectNone(); try { // note: this is after SelectNone() because it might destroy a gworld StSaveGWorld aSaver; /**************************************** width & height of our buffer match the picture ****************************************/ SInt32 width = inBuffer->GetWidth(); SInt32 height = inBuffer->GetHeight(); /**************************************** create an offscreen gworld using the paint view's gworld as a base (use same depth, ctable) ****************************************/ mSelectionBuffer = inParentBuffer->CreateSimilarOffscreen( false /* device???*/, width, height ); /**************************************** image the picture into the offscreen buffer ****************************************/ mSelectionBuffer->CopyFrom( inBuffer ); /**************************************** restore the selection area from the clipboard -- if none, use the entire picture frame ****************************************/ if ( inRegion ) this->SetRawSelection( inRegion ); else { RgnHandle tempRgn = SURegionUtils::NewRegionFromRect( 0, 0, width, height ); this->SetRawSelection( tempRgn ); SURegionUtils::DisposeRegion( tempRgn ); } } catch( ... ) { this->SelectNone(); throw; } }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ Constructor /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Can either take ownership of the gworld or not. Doens't dispose of the gworld on fail of construction. CBLCanvas::CBLCanvas( GWorldPtr inWorld, bool inAdopt) : mWorld(inWorld), mOwnsWorld(inAdopt), mBuffer(0), mBackColour(TColourPresets::kBlack), mForeColour(TColourPresets::kWhite), mInvalCanvasAsDraw(false), mIsWindow(false) { ThrowIfNil_(inWorld); if (!MakeABCRecFromGWorld(inWorld,&mABCRec)) Throw_(memFullErr); #if TARGET_API_MAC_CARBON ::GetPortBounds(inWorld,&mBoundsRect); #else mBoundsRect=inWorld->portRect; #endif mWidth=FRectWidth(mBoundsRect); mHeight=FRectHeight(mBoundsRect); ZeroRectCorner(mBoundsRect); }
void CProfileManager::DoLogout() { enum { iPersist = 1, iCancel, iCleanse }; nsresult rv; nsCOMPtr<nsIProfile> profileService = do_GetService(NS_PROFILE_CONTRACTID, &rv); ThrowIfNil_(profileService); nsXPIDLString currentProfile; Str255 pStr; profileService->GetCurrentProfile(getter_Copies(currentProfile)); CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsDependentString(currentProfile.get()), pStr); ::ParamText(pStr, "\p", "\p", "\p"); DialogItemIndex item = UModalAlerts::StopAlert(alrt_ConfirmLogout); if (item == iCancel) return; if (item == iPersist) rv = profileService->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST); else rv = profileService->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_CLEANSE); if (NS_SUCCEEDED(rv)) { // Just put this up modally until they pick a new profile DoManageProfilesDialog(); } }
void CAPrintingAttachment::FindCommandStatus( SCommandStatus* inCommandStatus) { // Validate pointers. ValidateThis_(); ThrowIfNil_(inCommandStatus); // Don't allow host commander to take command status, unless specifically allowed. SetExecuteHost(false); // Make sure menu title strings come from application's resource fork, not // any user document. StApplicationContext appContext; // Dispatch command. switch (inCommandStatus->command) { case cmd_PageSetup: case cmd_Print: case cmd_PrintOne: *(inCommandStatus->enabled) = true; break; default: SetExecuteHost(true); } }
/*======================================= HandleControlClick ======================================*/ void PTPaintView::HandleControlClick( LPane *thePane ) { ThrowIfNil_( thePane ); PaneIDT thePaneID = thePane->GetPaneID(); if ( thePaneID != mCurrentTool ) { switch( thePaneID ) { case Tool_Eraser: case Tool_Pen: case Tool_Dropper: case Tool_Bucket: case Tool_Line: case Tool_Rect: case Tool_FilledRect: case Tool_RoundRect: case Tool_FilledRoundRect: case Tool_Oval: case Tool_FilledOval: case Tool_Lasso: case Tool_Selection: case Tool_HotSpot: case Tool_Text: this->SelectNone(); mCurrentTool = thePaneID; // keep track of previous tool - double-click on eraser reverts to orig tool if ( thePaneID != Tool_Eraser ) mPreviousTool = thePaneID; break; } } }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ Constructor /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Can either take ownership of the window or not. Doens't dispose of the window on fail of construction. CBLCanvas::CBLCanvas( WindowPtr inWindow, bool inAdopt) : mWorld(GetWindowPort(inWindow)), mOwnsWorld(inAdopt), mBuffer(0), mBackColour(TColourPresets::kBlack), mForeColour(TColourPresets::kWhite), mInvalCanvasAsDraw(false), mIsWindow(true) { ThrowIfNil_(inWindow); MakeBCRecFromWindow(inWindow,&mABCRec.rec,::GetMainDevice()); if (!BCToABCRec(&mABCRec)) Throw_(memFullErr); #if TARGET_API_MAC_CARBON ::GetPortBounds(mWorld,&mBoundsRect); #else mBoundsRect=inWorld->portRect; #endif mWidth=FRectWidth(mBoundsRect); mHeight=FRectHeight(mBoundsRect); ZeroRectCorner(mBoundsRect); }
void CLTypeEntryItem::MakeDragRegion( const STableCell& inCell, RgnHandle outGlobalDragRgn, Rect& outGlobalItemBounds) { // Validate pointers. ValidateThis_(); ValidateObject_(mOutlineTable); // Make sure this cell is visible. Rect ignore; if (!mOutlineTable->GetLocalCellRect(inCell, ignore)) return; // Find out what we're supposed to draw. SOutlineDrawContents drawInfo; GetDrawContents(inCell, drawInfo); // Create a bounds rect that starts at the upper left corner // of the icon and has the width & height of the placed item. if (drawInfo.outHasIcon && (drawInfo.outIconSuite != nil) && !::EmptyRect(&drawInfo.prIconFrame)) outGlobalItemBounds = drawInfo.prIconFrame; else outGlobalItemBounds = drawInfo.prTextFrame; SDimension32 dragSize; mTypeEntry->GetDragSize(dragSize); outGlobalItemBounds.bottom = outGlobalItemBounds.top + dragSize.height; outGlobalItemBounds.right = outGlobalItemBounds.left + dragSize.width; // Convert to global coordinates. mOutlineTable->LocalToPortPoint(topLeft(outGlobalItemBounds)); mOutlineTable->LocalToPortPoint(botRight(outGlobalItemBounds)); mOutlineTable->PortToGlobalPoint(topLeft(outGlobalItemBounds)); mOutlineTable->PortToGlobalPoint(botRight(outGlobalItemBounds)); // Item bounds have been created. Now create drag region that // is the same size. RgnHandle tempRgn = ::NewRgn(); #if PP_Target_Carbon ThrowIfNil_(tempRgn); #else ValidateHandle_((Handle) tempRgn); #endif ::RectRgn(tempRgn, &outGlobalItemBounds); ::UnionRgn(outGlobalDragRgn, tempRgn, outGlobalDragRgn); ::DisposeRgn(tempRgn); }
/*================================= SetGWorld ==================================*/ void SUMiscUtils::SetGWorld( CGrafPtr inPort, GDHandle inDevice ) { ThrowIfNil_( inPort ); // shouldn't happen ::SetGWorld( inPort, inDevice ); // tell PP the port has changed since it caches it LView::OutOfFocus( nil ); }
/*============================================ SUMiscUtils::SetMemory ==============================================*/ void SUMiscUtils::SetMemory( void *buffer, UInt8 toWhat, UInt32 numBytes ) { UInt8 *p = (UInt8*) buffer; ThrowIfNil_( p ); // can't hurt to check while( numBytes-- > 0 ) *p++ = toWhat; }
void CPrintAttachment::DoPageSetup() { nsCOMPtr<nsIWebBrowser> wb; mBrowserShell->GetWebBrowser(getter_AddRefs(wb)); ThrowIfNil_(wb); nsCOMPtr<nsIDOMWindow> domWindow; wb->GetContentDOMWindow(getter_AddRefs(domWindow)); ThrowIfNil_(domWindow); nsCOMPtr<nsIPrintSettings> settings; mBrowserShell->GetPrintSettings(getter_AddRefs(settings)); ThrowIfNil_(settings); nsCOMPtr<nsIPrintingPromptService> printingPromptService = do_GetService("@mozilla.org/embedcomp/printingprompt-service;1"); ThrowIfNil_(printingPromptService); nsresult rv = printingPromptService->ShowPageSetup(domWindow, settings, nsnull); if (rv != NS_ERROR_ABORT) ThrowIfError_(rv); }
CControlPanel::CControlPanel() { _totalMem = 0; _renderingMode = 0; _floatWindow = LWindow::CreateWindow(PPob_ControlWindow, this); if (_floatWindow) { // Get the main multi panel view and load up all the panels LMultiPanelView* mainMPV = dynamic_cast<LMultiPanelView*> (_floatWindow->FindPaneByID(item_ControlMainPanelView)); ThrowIfNil_(mainMPV); mainMPV->CreateAllPanels(); LPageController* thePage = dynamic_cast<LPageController*> (_floatWindow->FindPaneByID(item_ControlPageController)); ThrowIfNil_(thePage); thePage->AddListener(mainMPV); LView* theRenderingView = dynamic_cast<LView*> (_floatWindow->FindPaneByID(kRenderingView)); LView* thePositionView = dynamic_cast<LView*> (_floatWindow->FindPaneByID(kPositionView)); LView* theAnimationView = dynamic_cast<LView*> (_floatWindow->FindPaneByID(kAnimationView)); UReanimator::LinkListenerToControls(this, theRenderingView, PPob_RenderingView); UReanimator::LinkListenerToControls(this, thePositionView, PPob_PositionView); UReanimator::LinkListenerToControls(this, theAnimationView, PPob_AnimationView); UpdateValues(true); StartIdling(); _lastDraw = 0; _drawInterval = 60; // in Ticks // position GDHandle dominantDevice = ::GetMainDevice(); Rect screenRect = (**dominantDevice).gdRect; Rect windowBounds; _floatWindow->GetGlobalBounds(windowBounds); _floatWindow->MoveWindowTo(screenRect.right - (windowBounds.right - windowBounds.left + 13), ::GetMBarHeight() + 23 ); _floatWindow->Show(); } }
CProgressMac::CProgressMac(PW_WindowType type) { fCancelcb = NULL; fCancelClosure = NULL; // Create the window // Our default resource stores an application modal, need to change the resource // before loading it in SWINDResourceH theWIND = NULL; if ( type == pwStandard ) { theWIND = (SWINDResourceH) ::GetResource('WIND', PW_WINDOW_ID); if ( theWIND ) { HLock( (Handle)theWIND ); (*theWIND)->procID = 4; } } LCommander::SetDefaultCommander(CFrontApp::GetApplication()); fWindow = LWindow::CreateWindow( PW_WINDOW_ID, NULL ); ThrowIfNil_(fWindow); if ( type == pwStandard ) { (*theWIND)->procID = 5; // revert HUnlock( (Handle)theWIND ); } fLine1 = (LCaption*)fWindow->FindPaneByID('LIN1'); fLine2 = (LCaption*)fWindow->FindPaneByID('LIN2'); fLine3 = (LCaption*)fWindow->FindPaneByID('LIN3'); fProgress = (CPatternProgressBar *)fWindow->FindPaneByID('PtPb'); ThrowIfNil_(fLine1); ThrowIfNil_(fLine2); ThrowIfNil_(fLine3); ThrowIfNil_(fProgress); }
/*================================== SaveAsResource ===================================*/ void PTCursorView::SaveAsResource( RFMap *inMap, ResIDT inResID ) { Handle h = nil; ThrowIf_( !mBWSample || !mMaskSample ); SUOffscreen *bwBuffer = mBWSample->GetBuffer(); SUOffscreen *maskBuffer = mMaskSample->GetBuffer(); Point theHotSpot = mCanvas->GetHotSpot(); try { switch( mResourceType ) { case ImageType_Cursor: h = this->CreateBWCursor( bwBuffer, maskBuffer, theHotSpot ); break; case ImageType_ColorCursor: ThrowIfNil_( mColorSample ); h = this->CreateColorCursor( mColorSample->GetBuffer(), bwBuffer, maskBuffer, theHotSpot ); break; default: LException::Throw( err_InvalidImageFormat ); } RFResource *theResource = inMap->FindResource( mResourceType, inResID, true ); ThrowIfNil_( theResource ); theResource->SetResData( h ); } catch( ... ) { SUMiscUtils::DisposeHandle( h ); throw; } this->SetChangedFlag( false ); SUMiscUtils::DisposeHandle( h ); }
/*==================================== InitializeFromResource =====================================*/ void PTFamilyView::InitializeFromResource( RFMap *inMap, ResIDT inResID ) { StSaveGWorld aSaver2; SInt32 numTypes = GetFamilyMemberCount(); /********************************************* initialize each family member **********************************************/ for ( SInt32 count = 1; count <= numTypes; count++ ) { PaintFamilyMember memberInfo; GetFamilyMemberInfo( count, &memberInfo ); // initialize the main image Boolean hasImage = this->InitializeOneMember( inMap, memberInfo.resourceType, inResID, memberInfo.width, memberInfo.height, memberInfo.depth, 0, memberInfo.rowBytes, memberInfo.samplePaneID, false ); // initialize the mask (ICN#, etc) if ( memberInfo.maskRowBytes != 0 ) this->InitializeOneMember( inMap, memberInfo.resourceType, inResID, memberInfo.width, memberInfo.height, 1, memberInfo.maskOffset, memberInfo.maskRowBytes, memberInfo.maskSamplePaneID, true ); /********************************************* default to the first non-empty resource we find *********************************************/ if ( hasImage && !mCurrentSamplePane ) mCurrentSamplePane = (PTDraggableTargetBox*) this->FindPaneByID( memberInfo.samplePaneID ); } /********************************************* need to listen to the sample panes (drag & drop, etc) *********************************************/ this->BecomeListenerTo( mNumSamplePanes, mSamplePaneList ); /********************************************* if the entire family is empty, default to whichever target pane is indicated by the resource *********************************************/ if ( !mCurrentSamplePane ) { mCurrentSamplePane = (PTDraggableTargetBox*) this->FindPaneByID( (**mFamilyListH).defaultPane ); ThrowIfNil_( mCurrentSamplePane ); } mCurrentSamplePane->SetTarget( true, redraw_Dont ); this->SetImage( mCurrentSamplePane->GetBuffer(), PTResize_Canvas ); }
Boolean CProfileManager::DoNewProfileDialog(char *outName, UInt32 bufSize) { Boolean confirmed; StDialogHandler theHandler(dlog_NewProfile, LCommander::GetTopCommander()); LWindow *theDialog = theHandler.GetDialog(); ThrowIfNil_(theDialog); LEditText *responseText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Name')); ThrowIfNil_(responseText); theDialog->SetLatentSub(responseText); theDialog->Show(); theDialog->Select(); while (true) // This is our modal dialog event loop { MessageT hitMessage = theHandler.DoDialog(); if (hitMessage == msg_OK) { Str255 pStr; UInt32 outLen; responseText->GetDescriptor(pStr); outLen = pStr[0] >= bufSize ? bufSize - 1 : pStr[0]; memcpy(outName, &pStr[1], outLen); outName[outLen] = '\0'; confirmed = PR_TRUE; break; } else if (hitMessage == msg_Cancel) { confirmed = PR_FALSE; break; } } return confirmed; }
/*==================================== FinishCreateSelf =====================================*/ void PTFamilyView::FinishCreateSelf() { PTPaintView::FinishCreateSelf(); #ifdef EBS_OUT // default to 8-bit large color icon if ( (**mFamilyListH).defaultPane ) { mCurrentSamplePane = (PTDraggableTargetBox*) this->FindPaneByID( (**mFamilyListH).defaultPane ); ThrowIfNil_( mCurrentSamplePane ); mCurrentSamplePane->SetTarget( true, redraw_Dont ); } #endif }
/*================================== SaveAsResource ===================================*/ void PTPatternView::SaveAsResource( RFMap *inMap, ResIDT inResID ) { Handle h = nil; ThrowIfNil_( mBWSample ); SUOffscreen *bwBuffer = mBWSample->GetBuffer(); try { switch( mResourceType ) { case ImageType_Pattern: h = this->CreateBWPattern( bwBuffer ); break; case ImageType_PixPat: ThrowIfNil_( mColorSample ); h = this->CreateColorPattern( mColorSample->GetBuffer(), bwBuffer ); break; default: LException::Throw( err_InvalidImageFormat ); } RFResource *theResource = inMap->FindResource( mResourceType, inResID, true ); ThrowIfNil_( theResource ); theResource->SetResData( h ); } catch( ... ) { SUMiscUtils::DisposeHandle( h ); throw; } SUMiscUtils::DisposeHandle( h ); this->SetChangedFlag( false ); }