It is currently Sun May 19, 2013 3:32 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: carbon question
PostPosted: Sat Sep 03, 2011 3:54 pm 
Offline
User
User

Joined: Tue Jun 21, 2011 6:11 pm
Posts: 38
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


Top
 Profile  
 
 Post subject: Re: carbon question
PostPosted: Sun Oct 30, 2011 10:53 am 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 813
Location: Germany
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:
; 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


Top
 Profile  
 
 Post subject: Re: carbon question
PostPosted: Mon Oct 31, 2011 8:16 pm 
Offline
User
User

Joined: Tue Jun 21, 2011 6:11 pm
Posts: 38
thank you for the very well sample. :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye