[Linux] Cursor_From_PNG

Share your advanced PureBasic knowledge/code with the community.
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Re: [Linux] Cursor_From_PNG

Post by Erlend »

Another way to create custom gdk cursor from PNG file or just draw like here...

Code: Select all

Procedure CreateCursor(Image,x,y)
   ProcedureReturn gdk_cursor_new_from_pixbuf_(gdk_display_get_default_(),ImageID(image),x,y)
EndProcedure
Procedure SetCursor(Handle,Cursor)
  *widget.gtkwidget=Handle
  gdk_window_set_cursor_(*widget\window,Cursor)    
EndProcedure

OpenWindow(0,0,0,300,300,"Cursor Test Gdk/Gtk")
CreateImage(0,32,32,32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0,0,32,32,0)
DrawingMode(#PB_2DDrawing_AlphaBlend)
LineXY(16,0,16,32,RGBA(0,255,0,155))
LineXY(0,16,32,16,RGBA(0,255,0,155))
StopDrawing()

result=createcursor(0,16,16)
Setcursor(WindowID(0),result)
ButtonGadget(0,0,0,100,30,"TEST") 

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
GBeebe
Enthusiast
Enthusiast
Posts: 263
Joined: Sat Oct 09, 2004 6:52 pm
Location: Franklin, PA - USA
Contact:

Re: [Linux] Cursor_From_PNG

Post by GBeebe »

:) Ok, you win. Thank you though. I knew it was possible to have multi color cursors, with different alpha levels, but hadn't gotten to figuring out gdk_cursor_new_from_pixbuf_() because I thought images in PB were pixmaps. Thank you again.
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Re: [Linux] Cursor_From_PNG

Post by Erlend »

You are right but the PB Team changed PBImage in 4.40 from pixmaps to pixbufs under linux...
Post Reply