hi guys,
under x-tools in MacWindows.h there are several definitions to create different windows like document, sheet, toolbar, plain etc.
i want to use the kOverlayWindowClass to create a window under pb.
i have not much experience in carbon/cocoa api.
how can i do that? has some one a sample to show?
kind regards
kurt
carbon question
Re: carbon question
delikanli_19_82 wrote:i want to use the kOverlayWindowClass to create a window under pb.
i have not much experience in carbon/cocoa api.
how can i do that? has some one a sample to show?
Code: Select all
; Converted from example by Jerome Tarantino
; http://lists.apple.com/archives/hit-developers/2001/Nov/msg00009.html
EnableExplicit
ImportC ""
CGContextAddCurveToPoint(CGContextRef.L, x1.F, y1.F, x2.F, y2.F, x3.F, y3.F)
CGContextAddLineToPoint(CGContextRef.L, x.F, y.F)
CGContextBeginPath(CGContextRef.L)
CGContextClearRect(CGContextRef.L, x.F, y.F, Width.F, Height.F)
CGContextClosePath(CGContextRef.L)
CGContextFillPath(CGContextRef.L)
CGContextMoveToPoint(CGContextRef.L, x.F, y.F)
CGContextRelease(CGContextRef.L)
CGContextSetRGBFillColor(CGContextRef.L, Red.F, Green.F, Blue.F, Alpha.F)
CreateCGContextForPort(CGrafPtr.L, *CGContextRef)
CreateNewWindow(WindowClass.L, Attributes.L, *Bounds, *WindowRef)
EraseRect(*Rect)
GetWindowGroupOfClass(WindowClass.L)
GetWindowPort(WindowRef.L)
QDFlushPortBuffer(CGrafPtr.L, RegionHandle.L)
RepositionWindow(WindowRef.L, ParentWindow.L, PositionMethod.L)
RunApplicationEventLoop()
SetPortWindowPort(WindowRef.L)
SetWindowGroup(WindowRef.L, WindowGroupRef.L)
EndImport
#kDocumentWindowClass = 6
#kOverlayWindowClass = 14
#kWindowCenterOnMainScreen = 1
#kWindowOpaqueForEventsAttribute = 1 << 18
#kWindowStandardHandlerAttribute = 1 << 25
Structure Rect
Top.W
Left.W
Bottom.W
Right.W
EndStructure
Define Bounds.Rect
Define CGContext.L
Define WindowRef.L
Bounds\Left = 270
Bounds\Top = 100
Bounds\Right = Bounds\Left + 320
Bounds\Bottom = Bounds\Top + 240
If CreateNewWindow(#kOverlayWindowClass, #kWindowStandardHandlerAttribute | #kWindowOpaqueForEventsAttribute, @Bounds, @WindowRef) = 0
SetWindowGroup(WindowRef, GetWindowGroupOfClass(#kDocumentWindowClass))
RepositionWindow(WindowRef, 0, #kWindowCenterOnMainScreen)
ShowWindow_(WindowRef)
SetPortWindowPort(WindowRef)
EraseRect(@Bounds)
If CreateCGContextForPort(GetWindowPort(WindowRef), @CGContext) = 0
CGContextClearRect(CGContext, 0.0, 0.0, 320.0, 240.0)
CGContextBeginPath(CGContext)
CGContextMoveToPoint(CGContext, 10.0, 10.0)
CGContextAddLineToPoint(CGContext, 50.0, 200.0)
CGContextAddCurveToPoint(CGContext, 80.0, 200.0, 200.0, 80.0, 200.0, 50.0)
CGContextClosePath(CGContext)
CGContextSetRGBFillColor(CGContext, 0.7, 0.0, 0.0, 0.6)
CGContextFillPath(CGContext)
CGContextRelease(CGContext)
QDFlushPortBuffer(GetWindowPort(WindowRef), 0)
EndIf
RunApplicationEventLoop()
EndIf
-
- User
- Posts: 38
- Joined: Tue Jun 21, 2011 6:11 pm
Re: carbon question
thank you for the very well sample. 
