It is currently Mon Nov 20, 2017 1:11 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: How can I flip coordinate of cocoa
PostPosted: Mon Nov 13, 2017 9:02 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 342
Hi,

is there a way to flip the coordinate on a cocoa window, to have the start point in the upper right corner instead of lower corner?


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Mon Nov 13, 2017 9:42 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
Never tried it, but as far as I know you have to change the origin of the window's view with setBoundsOrigin.
However, if you place ui children based from the new 0,0 location they will be invisible if you use positive numbers.
This is because they are placed in the quadrant that is outside the window.
Bottom line: all ui children need to be placed with negative coordinates in order to be visible.

Hope I'm not too far off with my assumption...

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Tue Nov 14, 2017 7:39 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3002
Location: Netherlands
Do you only want to flip the y coordinate or both x and y ?

To do both, you could rotate things
Code:
If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
    ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left)
    ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right)
    ButtonGadget(3, 10,100, 200, 60, "Multiline Button  (longer text gets automatically wrapped)", #PB_Button_MultiLine)
    ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle)
   
    ContentView = CocoaMessage(0, WindowID(0), "contentView")
   
    Rotation.CGFloat = 180
    CocoaMessage(0, ContentView, "setBoundsRotation:@", @Rotation)
   
    Origin.CGPoint\x = WindowWidth(0)
    Origin\y = WindowHeight(0)
    CocoaMessage(0, ContentView, "setBoundsOrigin:@", @Origin)   
   
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

_________________
MacOS 10.13.1 High Sierra, PB 5.60 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Tue Nov 14, 2017 9:38 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 342
wilbert wrote:
Do you only want to flip the y coordinate or both x and y ?


I need to flip Y only


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Wed Nov 15, 2017 7:30 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3002
Location: Netherlands
The NSView class has a method named isFlipped
You can overwrite this method and return #True .
Is that what you are looking for ?

_________________
MacOS 10.13.1 High Sierra, PB 5.60 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Wed Nov 15, 2017 10:43 am 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 342
wilbert wrote:
The NSView class has a method named isFlipped
You can overwrite this method and return #True .
Is that what you are looking for ?


Hi Wilbert,

isFliped is Deprecated since 10.6 maybe drawInRect:fromRect:operation:fraction:respectFlipped:hints: is the better way.
I will try it in a few days.

Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Wed Nov 15, 2017 10:55 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3002
Location: Netherlands
Wolfram wrote:
isFliped is Deprecated since 10.6

Where does it say it is deprecated ?
The Apple docs don't seem to mention that :?
https://developer.apple.com/documentati ... -isflipped

_________________
MacOS 10.13.1 High Sierra, PB 5.60 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Wed Nov 15, 2017 4:34 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 342
wilbert wrote:
Where does it say it is deprecated ?


In my 10.7 DocSet.
Maybe they recant it.


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I flip coordinate of cocoa
PostPosted: Wed Nov 15, 2017 4:52 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3002
Location: Netherlands
Wolfram wrote:
wilbert wrote:
Where does it say it is deprecated ?


In my 10.7 DocSet.
Maybe they recant it.

Are you sure you didn’t look at NSImage instead of NSView ?
For NSImage isFlipped is marked deprecated.

_________________
MacOS 10.13.1 High Sierra, PB 5.60 x64


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


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