Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Sep 15, 2019 7:27 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Adding a canvas to NSPanelMBS
PostPosted: Mon May 31, 2010 3:55 am 
Offline

Joined: Mon Jun 16, 2008 4:53 pm
Posts: 89
Please could someone give me a clue how to add a canvas to an NSPanelMBS? I've tried using the following:
dim style as integer = NSPanelMBS.NSTitledWindowMask + NSPanelMBS.NSUtilityWindowMask + NSPanelMBS.NSHUDWindowMask

static n as NSPanelMBS = new NSPanelMBS(100,100,200,200, style, NSPanelMBS.NSWindowBackingLocationDefault, false)
n.Title = "Hello World"

static p as CustomNSViewMBS
n.contentView.addSubview p

n.Show


but I can't work out how to set the position and dimensions of the CustomNSViewMBS, nor how to draw a picture into it.

TIA


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding a canvas to NSPanelMBS
PostPosted: Mon May 31, 2010 4:05 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
If you create a new subclass from CustomNSViewMBS you can overwrite the draw event.
And the constructor of CustomNSViewMBS takes the rectangle for position and size.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding a canvas to NSPanelMBS
PostPosted: Mon May 31, 2010 4:33 am 
Offline

Joined: Mon Jun 16, 2008 4:53 pm
Posts: 89
Thank you Christian. I've just created a custom class of type CustomNSViewMBS, and put this in the DrawRect event:
g.SetColorRGB(255, 255, 255)
g.fillRect(0, 0, 100, 100)


As hoped, a white rectangle was drawn. I can't get a picture to draw though. I've used:
g.drawAtPoint(p, 0, 0, 0, 0, 0, 0, 1, 1.00)

in the DrawRect event, but I get Code, "Parameters are not compatible with this function". I checked the manual for the Cocoa plugin, and from what I can tell specifying all zeroes for the dimensions to draw into should draw the whole image, and I checked the Cocoa NSCompositingOperation on Apple's NSImage class reference, which stated that a value of 1 is NSCompositeCopy. I can't work out what I've done wrong :?


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding a canvas to NSPanelMBS
PostPosted: Mon May 31, 2010 4:55 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Well, SetColorRGB has parameters with ranges from 0.0 to 1.0.
And for drawAtPoint the p must be a NSImageMBS object.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Adding a canvas to NSPanelMBS
PostPosted: Mon May 31, 2010 5:06 am 
Offline

Joined: Mon Jun 16, 2008 4:53 pm
Posts: 89
Thanks Christian. It's working now:
dim p as new NSImageMBS(MyPicture)
g.drawAtPoint(p, 0, 0, 0, 0, 0, 0, 1, 1.00)


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

All times are UTC - 5 hours


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group