Beispiel #1
0
void OpException::Do(OpDescriptor* WhichOp)
{
	if (WhichOp->Token == String( OPTOKEN_EXCEPTION_PTR) )
		GlobalByte = *lpByte;
	else if (WhichOp->Token == String( OPTOKEN_EXCEPTION_INT ) )
		iZero[1] = 1 / iZero[0];
	else if (WhichOp->Token == String( OPTOKEN_EXCEPTION_DBL ) )
		dZero[1] = 1 / dZero[0];									
	else
	{
		DocView *pDocView = DocView::GetSelected();
		if (pDocView != NULL)
		{
			pDocView->ForceRedraw();										// posts the paint message
			CWindowID pWnd = DocView::GetCurrentRenderWindow();
			if (pWnd)
			{
				// Set trap for later
				RenderTrap = TRUE;										
				// Now do the paint
				TRACE( _T("Into update explosion\n"));
				pWnd->Update();										// do the paint
				TRACE( _T("Out of update explosion\n"));
			}
		}
	}
}
Beispiel #2
0
void OpPush::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag)
{
	DocView* pDocView = DocView::GetSelected();
	ENSURE( pDocView != NULL, "OpPush::DragPointerMove - DocView was NULL" );
	if (pDocView==NULL)
		return;

	// Declare a few WorkCoords we will need
	WorkCoord ScrollOffsets;
	WorkCoord Change;	
	WorkCoord MoveClick = pDocView->GetClickWorkCoord();
	
	// How Much has it changed
	Change.x = AnchorPoint.x - MoveClick.x;
	Change.y = AnchorPoint.y - MoveClick.y;
	
	// Find the Scroll Offsets and change them
	ScrollOffsets = pDocView->GetScrollOffsets(); 
	ScrollOffsets.x += Change.x;
	ScrollOffsets.y += Change.y;
	
	// Make sure the ScrollOffsets are valid and then set them
	if ( ScrollOffsets.x < 0 ) ScrollOffsets.x = 0;
	if ( ScrollOffsets.y > 0 ) ScrollOffsets.y = 0;
	pDocView->SetScrollOffsets( ScrollOffsets, TRUE );
}
Beispiel #3
0
OpState OpShowGuides::GetState(String_256* pUIDescription, OpDescriptor*)
{
	OpState OpSt;

	DocView *pDocView = DocView::GetSelected();
	if (pDocView != NULL)
		OpSt.Ticked = pDocView->GetShowGuidesState();

	Spread* pSpread = Document::GetSelectedSpread();
	if (pSpread != NULL)
	{
		// if we have a guide layer, then make the menu item available, if not, grey it 
		//	and give a reason.
		if (pSpread->FindFirstGuideLayer() != NULL)
		{
			OpSt.Greyed = FALSE;
		}
		else
		{
			OpSt.Greyed = TRUE;
			*pUIDescription = String_256 (_R(IDS_NO_GUIDES));
		}

	}	// if (pSpread != NULL)

	return OpSt;
}
Beispiel #4
0
BOOL ThumbnailFilterPNG::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath, 
								Document* TheDocument, BOOL ShowOptions)
{
	// set ourselves up - this flags the BaseBitmapFilter to do resizing, which needs to be
	// done there because of Accusoft.
	SetPreviewBitmap(TRUE);

	// create a new view for the document
	DocView *pView = new DocView(TheDocument);

	if (pView && pView->Init())
	{
		// set the view as current, but remember the last current one
		View *pOldView = View::GetCurrent();
		pView->SetCurrent();

		// Export the thumbnail to the file by doing what our base class does
		BOOL ok = PNGFilter::DoExport(pOp, pFile, pPath, TheDocument, TRUE);

		// restore the last view
		if (pOldView != NULL)
			pOldView->SetCurrent();
		else
			View::SetNoCurrent();

		// delete our view
		delete pView;

		return ok;
	}
	else
		return FALSE; // view creation failed
}
Beispiel #5
0
void PreviewEditorWindow::onWindowResize()
{
  Window::onWindowResize();

  DocView* view = UIContext::instance()->activeView();
  if (view)
    updateUsingEditor(view->editor());
}
Beispiel #6
0
/********************************************************************************************

>	BOOL MakeBitmapFilter::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)

	Author:		Will_Cowling (Xara Group Ltd) <*****@*****.**> (from Simon)
	Created:	12/6/96
	Inputs:		-
	Outputs:	Spread:  The spread to place the clipboard objects on
				Position:The centre of the view (Spread coords)
	Purpose:	Finds the centre insertion position for clipboard objects

********************************************************************************************/
BOOL MakeBitmapFilter::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
{
	// ---------------------------------------------------------------------------------
	// Find out which spread is in the centre of the view 
	// this is the spread that the pasted objects will be placed on

	// Obtain the current DocView
	DocView* CurDocView = DocView::GetCurrent();

	ENSURE(CurDocView != NULL, "The current DocView is NULL"); 
	if (CurDocView == NULL)
		return FALSE; // No DocView

	// Get the view rect
	WorkRect WrkViewRect = CurDocView->GetViewRect();

	if (WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) )
		return FALSE; // Defensive
	
	// Determine the centre of the view
	WorkCoord WrkCentreOfView; 
	WrkCentreOfView.x = WrkViewRect.lox	+ (WrkViewRect.Width()/2); 
	WrkCentreOfView.y = WrkViewRect.loy	+ (WrkViewRect.Height()/2);
	
	// FindEnclosing spread requires an OilCoord
	OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets()); 

	// Find out which spread to insert the pasteboard objects onto
	(*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView);
	if ((*Spread) == NULL)
		return FALSE; // There is no spread

	// Phew
	// ---------------------------------------------------------------------------------
	// Now lets find the spread coordinate of the centre of the view
	DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread);
	
	if ( DocViewRect.IsEmpty() || (!DocViewRect.IsValid()) )
	{
		ERROR3("DocViewRect is invalid");
		return FALSE; // Defensive
	}

	// Find the centre of the DocViewRect
   	DocCoord DocCentreOfView; 
	DocCentreOfView.x = DocViewRect.lox	+ (DocViewRect.Width()/2); 
	DocCentreOfView.y = DocViewRect.loy	+ (DocViewRect.Height()/2);

	// --------------------------------------------------------------------------------
	// Now convert from DocCoords to spread coords

	DocRect PhysSpreadRect = (*Spread)->GetPasteboardRect();
	
	(*Position).x = DocCentreOfView.x - PhysSpreadRect.lo.x; 
	(*Position).y = DocCentreOfView.y - PhysSpreadRect.lo.y;
	
	return TRUE;  
}
Beispiel #7
0
BOOL ScaleTab::InitSection()
{
TRACEUSER( "Neville", _T("ScaleTab::InitSection\n"));
	ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::InitSection called with no dialog pointer");

//	BOOL ReadOk = FALSE; 	// Flag to say whether the preference value was read ok 

	// Make sure the information field displaying the name of the current document
	// is correct.
	String_256	DocumentName(_R(IDT_OPTS_SCALING_INFO)); 
	DocumentName +=	*GetDocumentName();
	pPrefsDlg->SetStringGadgetValue(_R(IDC_OPTS_INFO), DocumentName);

	// Section = Scale settings

	DocView* pSelectedView = DocView::GetSelected();
	// This may now be a valid state so must not error
	//ERROR3IF(pSelectedView == NULL,"ScaleTab::InitSection Where's the current view eh?");
	if (pSelectedView != NULL)
	{
		Spread* pSpread = pSelectedView->GetFirstSelectedSpread();

		// If no selected spread then use the visible spread
		if (pSpread == NULL)
			pSpread = pSelectedView->GetVisibleSpread();

		// If no selected spread then use the first spread
		// Of course, this should not be here but above routines seem to return
		// null a bit too often for my liking
		if (pSpread == NULL)
		{
TRACEUSER( "Neville", _T("ScaleTab::InitSection BODGE! using 1st spread\n"));
			Document* pSelectedDoc = Document::GetSelected();
			if (pSelectedDoc !=NULL )
				pSpread = pSelectedDoc->FindFirstSpread();
		}

		// Go and get a pointer to the scaling values
		if (pSpread != NULL)
		{
			pDimScale = pSpread->GetPtrDimScale();
			if (pDimScale != NULL)
			{
				// And now show the initial state of the controls given this
				// scaling 
				ShowScaleDetails();
			}
		}
	}
	else
	{
		// If no current view then ensure section is greyed
		GreySection();
	}

	return TRUE;
}
Beispiel #8
0
void OpSnapToGuides::Do(OpDescriptor*)
{
	DocView *pDocView = DocView::GetSelected();

	if (pDocView != NULL)
		pDocView->SetSnapToGuidesState(!pDocView->GetSnapToGuidesState());

	End();
}
Beispiel #9
0
OpState OpShowGrid::GetState(String_256*, OpDescriptor*)
{
	OpState OpSt;

	DocView *pDocView = DocView::GetSelected();
	if (pDocView != NULL)
		OpSt.Ticked = pDocView->GetShowGridState();

	return OpSt;
}
Beispiel #10
0
OpState OpSnapToObjects::GetState(String_256*, OpDescriptor*)
{
	OpState OpSt;

	DocView *pDocView = DocView::GetSelected();
	if (pDocView != NULL)
		OpSt.Ticked = pDocView->GetSnapToObjectsState();
	
	return OpSt;
}
Beispiel #11
0
KernelBitmap* SGNameDrag::MakeImage(UINT32 nDepth)
{
	// If there's no current View, or no Spread, then fail.
	DocView* pView = DocView::GetCurrent();
	if (pView == 0) return 0;
	Spread* pSpread = pView->FindEnclosingSpread(OilCoord(0, 0));
	if (pSpread == 0) return 0;

	// Create a device context for the display.
	CDC sdc;
	sdc.CreateDC("DISPLAY", 0, 0, 0); 

	// Calculate the size of the rendering and set up the rendering matrix etc.
	Matrix matConvert;
	FIXED16 fxScale = 1;
	INT32 nSel = NameGallery::Instance()->GetSelectedItemCount();
	DocRect drClip(0, 0, SG_DefaultNameText, nSel * SG_DefaultSmallIcon);

	// Work out the destination bitmap's characteristics.
	double dpi = (double) GetDeviceCaps(sdc.m_hDC, LOGPIXELSX);
	if (nDepth == 0)
			nDepth = GetDeviceCaps(sdc.m_hDC, BITSPIXEL) * GetDeviceCaps(sdc.m_hDC, PLANES);

	// Create a render region with the given properties of the display etc.
	GRenderBitmap* pRenderer = new GRenderBitmap(drClip, matConvert, fxScale, nDepth, dpi);
	ERRORIF(pRenderer == 0, _R(IDE_NOMORE_MEMORY), 0);
	pRenderer->AttachDevice(pView, &sdc, pSpread);
	pRenderer->StartRender();
	pRenderer->SaveContext();

	// Blank the background.
	pRenderer->SetLineWidth(0);
	pRenderer->SetLineColour(COLOUR_WHITE);
	pRenderer->SetFillColour(COLOUR_WHITE);
	pRenderer->DrawRect(&drClip);

	// Render the item's name.
	DocColour dcText(COLOUR_BLACK), dcBack(COLOUR_WHITE);
	pRenderer->SetFixedSystemTextColours(&dcText, &dcBack);

	String_256 strName;
	m_pSourceItem->GetNameText(&strName);
	pRenderer->DrawFixedSystemText(&strName, drClip);

	// Create a kernel bitmap from the OIL bitmap and return it.
	pRenderer->RestoreContext();
	pRenderer->StopRender();
	OILBitmap* pOilMaskBmp = pRenderer->ExtractBitmap();
	delete pRenderer;

	KernelBitmap* pkb = new KernelBitmap(pOilMaskBmp, TRUE);
	ERRORIF(pkb == 0, _R(IDE_NOMORE_MEMORY), 0);
	return pkb;
}
Beispiel #12
0
void OpShowGrid::Do(OpDescriptor*)
{
	DocView *pDocView = DocView::GetSelected();

	if (pDocView != NULL)
	{
		if (Tool::GetCurrentID() != TOOLID_GRID)
			NodeGrid::ForceRedrawAllGrids();

		pDocView->SetShowGridState(!pDocView->GetShowGridState());
	}

	End();
}
Beispiel #13
0
gfx::Point MoveThing::getDelta(Context* context) const
{
  gfx::Point delta(0, 0);

  DocView* view = static_cast<UIContext*>(context)->activeView();
  if (!view)
    return delta;

  DocumentPreferences& docPref = Preferences::instance().document(view->document());
  Editor* editor = view->editor();
  gfx::Rect vp = view->viewWidget()->viewportBounds();
  gfx::Rect gridBounds = docPref.grid.bounds();
  int pixels = 0;

  switch (units) {
    case Pixel:
      pixels = 1;
      break;
    case TileWidth:
      pixels = gridBounds.w;
      break;
    case TileHeight:
      pixels = gridBounds.h;
      break;
    case ZoomedPixel:
      pixels = editor->zoom().apply(1);
      break;
    case ZoomedTileWidth:
      pixels = editor->zoom().apply(gridBounds.w);
      break;
    case ZoomedTileHeight:
      pixels = editor->zoom().apply(gridBounds.h);
      break;
    case ViewportWidth:
      pixels = vp.h;
      break;
    case ViewportHeight:
      pixels = vp.w;
      break;
  }

  switch (direction) {
    case Left:  delta.x = -quantity * pixels; break;
    case Right: delta.x = +quantity * pixels; break;
    case Up:    delta.y = -quantity * pixels; break;
    case Down:  delta.y = +quantity * pixels; break;
  }

  return delta;
}
Beispiel #14
0
KernelBitmap* GalleryLineDragInfo::GetSolidDragMask()
{
	// Note we abuse this call (like our base class abuses this call) to create the bitmap
	// itself. We don't use DragMask itself anymore (i.e. it stays NULL)
	if (!DragMask && !TheBitmap)
	{
		DocView *View = DocView::GetCurrent();
		if (View == NULL)
		{
			return NULL;
		}
		
		Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
		if (pSpread == NULL)
		{
			return NULL;
		}

		// Find the size of the rendered item.
		DocRect ClipRegion(0,0, 750*100, 750*50);
//		ClipRegion.lo.x = ClipRegion.lo.y = 0;
//		SourceItem->GetSize(c_eLineAttrDragTextPos, &ClipRegion.hi.x, &ClipRegion.hi.y);
		Matrix ConvertMatrix;
		FIXED16 ViewScale = 1;

		wxScreenDC DisplayDC;
		double dpi = (double) OSRenderRegion::GetFixedDCPPI(DisplayDC).GetWidth();

		GRenderBitmap* pMaskRegion 	= new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale, 
														32, dpi);

		pMaskRegion->SetDoCompression(TRUE); // misnamed call to indicate we want transparency
		pMaskRegion->AttachDevice(View, &DisplayDC, pSpread);

		// Make a Mask Bitmap
		pMaskRegion->StartRender();
	  	SourceItem->Render(pMaskRegion, ClipRegion, c_eLineAttrDragTextPos);
		pMaskRegion->StopRender();

		OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
		TheBitmap = new KernelBitmap(pOilMaskBmp, TRUE);	

		delete pMaskRegion;
	}

	return BitmapDragInformation::GetSolidDragMask();
}
Beispiel #15
0
void OpShowGuides::Do(OpDescriptor*)
{
	DocView *pDocView = DocView::GetSelected();

	if (pDocView != NULL)
	{
		pDocView->SetShowGuidesState(!pDocView->GetShowGuidesState());

		Spread* pSpread = Document::GetSelectedSpread();
		Document* pDoc  = Document::GetSelected();
		if (pSpread != NULL && pDoc != NULL)
		{
			Layer* pLayer = pSpread->FindFirstGuideLayer();
			if (pLayer != NULL)
				LayerSGallery::ForceRedrawLayer(pDoc,pLayer);
		}

		BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
	}

	End();
}
Beispiel #16
0
void OpSnapToObjects::Do(OpDescriptor*)
{
	DocView *pDocView = DocView::GetSelected();

	if (pDocView != NULL)
	{
		// Find out the new value for the magnetic snapping
		BOOL NewState = !pDocView->GetSnapToObjectsState();
		pDocView->SetSnapToObjectsState(NewState);

		// update all slider controls that show the view quality
		OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SNAPTOOBJECTS);
		if (pOpDesc!=NULL)
		{
			// Found the opdescriptor. Now find all the gadgets associated with it
			List Gadgets;
			if (pOpDesc->BuildGadgetList(&Gadgets))
			{
				// Found some. Set the controls position according to the quality
				GadgetListItem* pGadgetItem = (GadgetListItem*) Gadgets.GetHead();

				while (pGadgetItem!=NULL)
				{
					// Set the sliders position
					pGadgetItem->pDialogOp->SetLongGadgetValue(pGadgetItem->gidGadgetID, NewState, FALSE);

					// go find the next gadget
					pGadgetItem = (GadgetListItem*) Gadgets.GetNext(pGadgetItem);
				}
		
				// Clean out the list
				Gadgets.DeleteAll();
			}
		}
	}

	End();
}
Beispiel #17
0
BOOL ScaleTab::CommitSection()
{
TRACEUSER( "Neville", _T("commit Scale section\n"));
	ERROR3IF(pPrefsDlg == NULL, "ScaleTab::CommitSection called with no dialog pointer");

	BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE));	// The Scale tab identifier
	if (!ok)
		return TRUE;	// Talk to View failed to return now

	// Ok has been pressed so take the values from this section of the dialog box
	// Takes the values in the dialog and sets the DimScale object accordingly.
	BOOL Valid=TRUE;		// Flag for validity of value
//	BOOL State=FALSE;		// Flag for state of button/switch
	BOOL SetOk=TRUE;		// Preference value set ok

	// Section = Scale settings

	// Now check that we have the selected view still, just in case it has switched
	// without us being told about it or even we have no current document/view.
	// This may be a valid state now, so do not complain about it. 
	DocView* pCurrentView = DocView::GetSelected();
	if (pCurrentView != NULL)
	{
		// Only if there is a current view do we read the values.
		String_256 DrawingStr;
		String_256 RealStr;
		//TCHAR* pDrawingStr = DrawingStr;
		//TCHAR* pRealStr = RealStr;
		BOOL Active;

		// Get the values from the dialog box
		Active 		= pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_USESCALEFACTOR),0,1,0, &Valid);
		DrawingStr  = pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_DRAWINGSCALE), &Valid);
		RealStr 	= pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_REALSCALE), &Valid);

		Spread* pSpread = pCurrentView->GetFirstSelectedSpread();
		// If no selected spread then use the visible spread
		if (pSpread == NULL)
			pSpread = pCurrentView->GetVisibleSpread();

		// Only do the chnage if we have a valid spread pointer and we have changed something.
		if ( (pSpread != NULL) &&
			 (
			 	(OldActiveState != Active) ||
			 	(OldDrawingStr != DrawingStr) ||
			 	(OldRealStr != RealStr)
			 )
		   )
		{
			pDimScale = pSpread->GetPtrDimScale();
			if (pDimScale != NULL)
			{
				// Only if active is set do we need to try and set new strings
				// and hence a new drawing scale
				if (Active)
				{
					// Dim Scales can only be 32 characters long
					String_32 DrawingStr32 = _T("");
					String_32 RealStr32 = _T("");
					// Check if read in strings are longer than this
					if (DrawingStr.Length() > DrawingStr32.MaxLength())
					{
						InformError(_R(IDE_OPTS_INVALIDDRAWSCALE));
						return FALSE;
					}
					if (RealStr.Length() > RealStr32.MaxLength())
					{
						InformError(_R(IDE_OPTS_INVALIDREALSCALE));
						return FALSE;
					}

					RealStr32 = RealStr;
					DrawingStr32 = DrawingStr;

					// Try and set these strings as new drawing and real scales strings
					SetOk = pDimScale->SetDrawingScaleStr(DrawingStr32);
					if (!SetOk)
					{
						InformError(_R(IDE_OPTS_INVALIDDRAWSCALE));
						return FALSE;
					}

					SetOk = SetOk && pDimScale->SetRealScaleStr(RealStr32);
					if (!SetOk)
					{
						InformError(_R(IDE_OPTS_INVALIDREALSCALE));
						return FALSE;
					}
				
					// Now try to convert these into a new scaling factor
					if (SetOk)
						SetOk = SetOk && pDimScale->SetScaleFactor();
				
					// If we failed in any of the conversions then warn the user and fail
					if (!SetOk)
					{
						InformError(_R(IDE_OPTS_INVALIDSCALING));
						return FALSE;
					}
				}
				
				// Set up a possibly new active state
				pDimScale->SetActiveState(Active);

			}

			// Now tell other users of units/scaling factors that there they are likely
			// to need to update any currently displayed units. 
			Document *pCurrentDoc = (Document *)pSpread->FindOwnerDoc();
			BROADCAST_TO_ALL(OptionsChangingMsg(pCurrentDoc, OptionsChangingMsg::NEWUNITS));
// unfortunately pScopeDoc is NULL!, and since pCurrentDoc is calulated I thought it ought to use! - Ed 17/10/95
//			BROADCAST_TO_ALL(OptionsChangingMsg(pScopeDocument, OptionsChangingMsg::OptionsState::NEWUNITS));

			// Make sure the document is marked as modified.
			pCurrentDoc->SetModified(TRUE);
			
			// And note the new states
			OldActiveState = Active;
			OldDrawingStr = DrawingStr;
			OldRealStr = RealStr;
		}
	}
//	else
//		ERROR2(FALSE,_R(IDE_OPTS_READPREF_SCALE));
	
	return TRUE;
}
Beispiel #18
0
void ScreenCamView::OnSize( wxSizeEvent &event )
{
	// This is called early, so if pDocView is null do nothing
	if( NULL == pDocView )
		return;

	SetCurrentStates();

	Document* pCurDoc = Document::GetCurrent();
	DocView* pCurView = DocView::GetCurrent();
	
	// these lines are here to stop very strange things happening on exit under Win32s
	// when this fn gets called when it really shouldn't. I would like to really know
	// just what on earth os going on under Win32s but it iss something strange in message
	// handling as far as I can tell.

	wxSize	size( event.GetSize() );

	// Check for irrelevant or potty messages.
	if (size.x <= 0 || size.y <= 0)
	{
//		TRACEUSER( "JustinF", _T("Strange size msg in ScreenView::OnSize(0x%X, %d, %d)\n"), 
//					nType, cx, cy);
		return;
	}

	// Handle OLE 2.0 in-place activation stuff.
#if (_OLE_VER >= 0x200)
	if(GetDocument())
	{
		COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
		if (pActiveItem) pActiveItem->SetItemRects();
	}	
#endif

	if (Status->ScrollersVisible)
	{
PORTNOTETRACE( "other", "ScreenCamView::OnSize - Removed scroller usage" );
#if !defined(EXCLUDE_FROM_XARALX)
		// Resize and reposition the proportional scrollers.
		wxRect hrect, vrect;
		HScrollBar->CalcPosFromParentClient(&hrect);

		UINT32 RulerWidth = OILRuler::GetWidth();
		//if rulers are switched on the scroll bars are made
		// smaller to accomodate them
		if (Status->RulersVisible)
			hrect.left += RulerWidth;
		if (RULER_BORDERS)
			hrect.left-=2;

		HScrollBar->MoveWindow(&hrect, TRUE);
		VScrollBar->CalcPosFromParentClient(&vrect);

		if (Status->RulersVisible)
			vrect.top += RulerWidth;
		if (RULER_BORDERS)
			vrect.top-=2;

		VScrollBar->MoveWindow(&vrect, TRUE);

 		// Reposition the corner window at the bottom-right.
		Corner->MoveWindow(vrect.left, hrect.top, vrect.Width(), hrect.Height());
	 
		// Resize/reposition the rendering window.
		CurrentSize.left = CurrentSize.top = 0;
		CurrentSize.right = cx - vrect.Width() + 1;
		CurrentSize.bottom = cy - hrect.Height() + 1;
#endif
	}
	else
	{	
		CurrentSize.x = CurrentSize.y = 0;
		CurrentSize.width  = size.x;
		CurrentSize.height = size.y;
	}

	if (Status->RulersVisible)
	{
PORTNOTETRACE( "other", "ScreenCamView::OnSize - Removed scroller / ruler usage" );
#if !defined(EXCLUDE_FROM_XARALX)
	 	wxRect hRect, vRect, oRect;

	 	HRuler->CalcPosFromParentClient(&hRect);
		HRuler->MoveWindow(&hRect, TRUE);
		HRuler->PositionLegend();
		
		CurrentSize.top = 0 + hRect.Height() ;
			
	 	VRuler->CalcPosFromParentClient(&vRect);
		VRuler->MoveWindow(&vRect, TRUE);
		CurrentSize.left = 0 + vRect.Width(); 

	 	OGadget->CalcPosFromParentClient(&oRect);
		OGadget->MoveWindow(&oRect, TRUE);
		if (RULER_BORDERS)
		{
			CurrentSize.top --;
			CurrentSize.left--; 
		}
#endif
	}

PORTNOTE( "other", "ScreenCamView::OnSize - Removed RenderWindow usage -not sure if needed" )
#ifndef EXCLUDE_FROM_XARALX
	RenderWindow->MoveWindow(&CurrentSize, TRUE);
#endif
	// Update the rest of the window placement information.
	UpdateViewPosition();

	// Calculate the work area, page & line sizes etc etc.
	FIXED16 PixelWidth, PixelHeight;
	pDocView->GetPixelSize(&PixelWidth, &PixelHeight);

PORTNOTE( "other", "ScreenCamView::OnSize - Removed scroller usage" )
#if !defined(EXCLUDE_FROM_XARALX)
	XLONG x1 = CurrentSize.GetWidth() * PixelWidth;
	XLONG x2 = CurrentSize.GetHeight() * PixelHeight;
	HScrollBar->SetPageSize(x1);
	VScrollBar->SetPageSize(x2);
	HScrollBar->SetLineSize(x1 / xlong(10) + xlong(1));	
	VScrollBar->SetLineSize(x2 / xlong(10) + xlong(1));
#endif
	SetWorkAreaExtent(Status->WorkAreaExtent, FALSE);

	// Make sure the scroll offsets are valid - if we resize the bottom of the window
	// when at the extreme bottom of the view, then the scroll offsets should be
	// changed - we use the scrollers' own integrity checks to do this automatically.
	// Don't do this until the setup flag is TRUE, so we don't overwrite scroll offsets
	// that have been reloaded.
	if (fSetupDone)
	{
		WorkCoord CurrScrollPos;
		GetScrollOffset(&CurrScrollPos);
		SetScrollOffset(CurrScrollPos, TRUE);
	}	

	// Inform the associated DocView object that something has happened.
	pDocView->ViewStateChanged();
	pCurDoc->SetCurrent();
	pCurView->SetCurrent();
}
Beispiel #19
0
BOOL ScreenCamView::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
{
	if (!m_DropFormatOK || pDataObject == NULL)
		return FALSE;

//	Document* pSelDoc = Document::GetSelected();

	Document* pClipDoc = InternalClipboard::Instance();
	if (pClipDoc != NULL)
	{
		Document::SetSelectedViewAndSpread(pClipDoc);
		pClipDoc->ResetInsertionPosition();
		pClipDoc->SetCurrent();

		// If there is *still* a format on the external clip board we like, then it's ok to drop
		CLIPFORMAT ClipFormat = ExternalClipboard::GetBestPasteFormat(pDataObject);
		ExternalClipboard* pExtClipBoard = ExternalClipboard::GetExternalClipboard();

		if (ClipFormat != 0 && pExtClipBoard !=NULL && pExtClipBoard->PrepareForOlePaste(pDataObject))
		{
			Document::SetSelectedViewAndSpread(GetDocument()->GetKernelDoc(),GetDocViewPtr());
			DocView *pDocView = DocView::GetCurrent();

			if (pDocView != NULL)
			{
				// Make the drop point a WinCoord so we can turn it into an oil coord
				WinCoord DropPoint(point.x,point.y);

				// Turn it into Oil coordinates...
				OilCoord OilPos = DropPoint.ToOil(pDocView);

				// Find the spread that contains the coord
				Spread* pSpread = pDocView->FindEnclosingSpread(OilPos);
				if (pSpread != NULL)
				{
					// First of all convert the OilCoord into device coords
					DocCoord Centre = OilPos.ToDoc(pSpread, pDocView);
				
					// Translate the coord to spread coords
					pSpread->DocCoordToSpreadCoord(&Centre);

					// 'Centre' now contains the centre point for the paste, in spread coords

					TRY
					{
						// Wrap all this in a TRY/CATCH block so that if OLE throws a wobbly, we can
						// ensure that the clipboard remains intacted on exit.

						// Copy the selection to the drag'n'drop clipboard.
						OpDescriptor* pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_PASTE);
						ERROR3IF(!pOp, "No paste operation in ScreenCamView::OnDrop");

						if (pOp != NULL)
						{
							Document::SetSelectedViewAndSpread(pClipDoc);
							pClipDoc->SetCurrent();
							pClipDoc->ResetInsertionPosition();
							InsertionNode* pInsertNode = pClipDoc->GetInsertionPosition();
							if (pInsertNode != NULL)
							{
								pInsertNode->UnlinkNodeFromTree();
								delete pInsertNode;
								pInsertNode = NULL;
							}

							Document::SetSelectedViewAndSpread(GetDocument()->GetKernelDoc(),GetDocViewPtr());
							
							// create a param object that contains the centre point in the spread at which
							// we would like the objects to be pasted
							OpParamPasteAtPosition Param(pSpread,Centre);

							// Call the paste op via its DoWithParams() funtion
							pOp->Invoke(&Param);
						}
					}
					CATCH_ALL(e)
					{
						if (m_ClipBoardSwapped = FALSE)
						{
//							TRACEUSER( "Markn", _T("Swapping back to clipboard doc (Catch in ScreenCamView::OnDrop())\n"));
							InternalClipboard::Swap();
							ExternalClipboard::UpdateSystemClipboard(TRUE);
						}
						THROW_LAST();
					}
					END_CATCH_ALL
				}