Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CG Ovals with PDF in memory
Required plugins for this example: MBS MacCG Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CG Ovals with PDF in memory
This example is the version from Sun, 17th Mar 2012.
Project "CG Ovals with PDF in memory.rbp"
Filetype text
End FileTypes
Class Window1 Inherits Window
EventHandler Sub Open() dim center as CGPointMBS dim m as MyCGDataConsumer dim c as CGContextMBS dim r as CGRectMBS dim q as CGDataProviderMBS dim data as string // Create PDF in memory m=new MyCGDataConsumer r=new CGRectMBS(0,0,300,300) c=CGNewPDFDocumentMBS(m,r,"","","") if c<>Nil then c.BeginPage r center=new CGPointMBS(150,150) c.BeginPath c.SetRGBFillColor 1,0,0,0.5 c.AddOval center, 100,150 c.FillPath c.BeginPath c.SetRGBFillColor 0,0,1,0.5 c.AddOval center, 100,50 c.FillPath c.EndPage c.Flush end if c=nil // end CGContext data=m.buf // get data q=CGDataProviderMBS.CreateWithData(data) p=CGOpenPDFDocumentMBS(q) End EventHandler
EventHandler Sub Paint(g As Graphics) g.DrawCGPDFDocumentMBS p,new CGRectMBS(0,0,300,300),1 End EventHandler
Property Protected p As cgpdfdocumentMBS
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Module Util
Sub AddOval(extends c as CGContextMBS, center as CGPOintMBS, a as single, b as single) dim pi as single pi=ACos(0)*2.0 c.SaveGState c.TranslateCTM center.x, center.y c.ScaleCTM a,b c.MoveToPoint 1,0 c.AddArc 0, 0, 1, 0.0, 2*pi, false c.ClosePath c.RestoreGState End Sub
End Module
Class MyCGDataConsumer Inherits CGDataConsumerMBS
EventHandler Function Put(data as string) As integer buf=buf+data Return lenb(Data) End EventHandler
Property buf As string
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCG Plugin.

MBS Xojo Chart Plugins