It is currently Mon Jul 06, 2020 2:06 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: COCOA quests?
PostPosted: Sat Feb 11, 2017 5:05 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jul 08, 2013 8:43 pm
Posts: 247
Exist some thing in OSX (cocoa or other way) similar to MSAPI:

FindWindow_(0, win_name.s)
SetParent_(hWnd,WindowID(window))
SendMessage_(hWnd,#WM_CLOSE,0,0)
MoveWindow_(hWnd,x,y,w,h,#True)

Somebody can help with this?
Thanks a lot!

_________________
If translation=Error: reply="Sorry, Im Spanish": Endif


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Sat Feb 11, 2017 5:40 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3624
Location: Netherlands
It helps if you explain what those windows api calls actually do.

On OSX you use CocoaMessage.
For example to close a window
Code:
CocoaMessage(0, WindowID(0), "close")

or to add a child window
Code:
CocoaMessage(0, WindowID(0), "addChildWindow:", WindowID(1), "ordered:", 1); NSWindowAbove = 1

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Sat Feb 11, 2017 7:43 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jul 08, 2013 8:43 pm
Posts: 247
Wow! Thanks willbert!
Do you know how set position window?, some thing like setposition(hwnd,x,y,w,h)

_________________
If translation=Error: reply="Sorry, Im Spanish": Endif


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Sat Feb 11, 2017 8:39 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2535
Location: Germany
minimy wrote:
Do you know how set position window?, some thing like setposition(hwnd,x,y,w,h)


Why not with native PB-Function ResizeWindow(...)

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Mon Feb 13, 2017 8:53 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jul 08, 2013 8:43 pm
Posts: 247
mk-soft wrote:
minimy wrote:
Do you know how set position window?, some thing like setposition(hwnd,x,y,w,h)


Why not with native PB-Function ResizeWindow(...)


Hi mk-soft! because i need a window based in a handle not in windowid or window number. Is not a PBwindow.
Thanks for help.

_________________
If translation=Error: reply="Sorry, Im Spanish": Endif


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Tue Feb 14, 2017 7:02 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3624
Location: Netherlands
minimy wrote:
Do you know how set position window?

Screen coordinates are flipped. (0, 0) is the bottom left of the screen.

Set bottom left coordinate of window
Code:
Point.NSPoint\x = 100
Point\y = 100
CocoaMessage(0, WindowID(0), "setFrameOrigin:@", @Point)


Set top left coordinate of window
Code:
Point.NSPoint\x = 100
Point\y = 100
CocoaMessage(0, WindowID(0), "setFrameTopLeftPoint:@", @Point)


Center window
Code:
CocoaMessage(0, WindowID(0), "center")

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Tue Feb 14, 2017 1:58 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jul 08, 2013 8:43 pm
Posts: 247
Hi willbert! Fantastic! :shock: its exactly i need. :D
Thousend thanks to both for quick and perfect answer!

_________________
If translation=Error: reply="Sorry, Im Spanish": Endif


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Tue Feb 14, 2017 9:49 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
In regards to Center Window:

Just be aware that your perception of center will probably not match Apple's perception of center.

More info in this thread.

:mrgreen:

_________________

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


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Thu Jan 03, 2019 8:08 pm 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 819
Is there something like this in cocoa?
Code:
SetParent_ (GadgetID (Gadget_1), GadgetID (Gadget_2))


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Fri Jan 04, 2019 7:42 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3624
Location: Netherlands
mestnyi wrote:
Is there something like this in cocoa?
Code:
SetParent_ (GadgetID (Gadget_1), GadgetID (Gadget_2))

You can use addSubview:
Code:
OpenWindow(0, 0, 0, 320, 250, "addSubview: example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
FrameGadget(0, 10, 10, 300, 50, "FrameGadget")
TextGadget(1, 0, 0, 250, 20, "TextGadget")

CocoaMessage(0, GadgetID(0), "addSubview:", GadgetID(1))

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Fri Jan 04, 2019 8:49 am 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 819
Hi, in principle, it solved my problem at the moment, thank you.
But why here from the bottom up?
It does not move the listview, listicon, tree.
Can you help me with this?
Thanks again. :)
Code:
OpenWindow(0, 0, 0, 320, 320, "addSubview: example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 10, 300, 300)
ButtonGadget(1, 50, 10, 150, 20, "ButtonGadget")

CocoaMessage(0, GadgetID(0), "addSubview:", GadgetID(1))


; ResizeGadget(1, #PB_Ignore, 300-20-10, #PB_Ignore, #PB_Ignore)
     
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Fri Jan 04, 2019 3:49 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3624
Location: Netherlands
mestnyi wrote:
But why here from the bottom up?

I'm not sure if I understand your question but with Cocoa, coordinates are different.
(0,0) is bottom left instead of top left.
PureBasic normally handles this for you so coordinates work the same on all supported platforms but in this case you will have to handle the different coordinates yourself.

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Fri Jan 04, 2019 6:12 pm 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 819
I talk about it.
Code:
OpenWindow(0, 0, 0, 320, 320, "addSubview: example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

CanvasGadget(0, 10, 10, 300, 300)
ListViewGadget(1, 50, 10, 150, 50)
AddGadgetItem(1,-1, "ListView_1")
AddGadgetItem(1,-1, "ListView_2")

CocoaMessage(0, GadgetID(0), "addSubview:", GadgetID(1))
     
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Fri Jan 04, 2019 7:48 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3624
Location: Netherlands
mestnyi wrote:
I talk about it.

Sorry, I don't know a solution. :(
Canvas is not just a simple Cocoa object. It's made up of multiple objects.

I don't know if you are aware of it but you can use a canvas as a container.
Code:
OpenWindow(0, 0, 0, 320, 320, "Canvas container", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

CanvasGadget(0, 10, 10, 300, 300, #PB_Canvas_Container)
ListViewGadget(1, 50, 10, 150, 50)
CloseGadgetList()
AddGadgetItem(1,-1, "ListView_1")
AddGadgetItem(1,-1, "ListView_2")

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
macOS 10.15 Catalina, Windows 10


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Fri Jan 04, 2019 9:02 pm 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 819
Quote:
Canvas is not just a simple Cocoa object. It's made up of multiple objects.

Similarly, the list view consists of several objects. I think the problem is with this.
in Linux it was also similar, but there I could get a parent and a child, but here I do not know how to do it. :oops:

And generally, how do you convert the code of the apple into the code of the purebasic
why the apple documentation has two functions?
How to use these functions in the Purebasic?
I do not understand help me please.
Code:
; func addSubview(_ view: UIView)
; func addSubview(_ view: NSView)
CocoaMessage (0, GadgetID (Gadget), "addSubview:", GadgetID (Gadget_1))

Why doesn't it work in the same way?
What is going on here where you can find out how you know where you read it?
Code:
; func bringSubviewToFront(_ view: UIView)
CocoaMessage (0, GadgetID (Gadget), "bringSubviewToFront:", GadgetID (Gadget_1))


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 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