Page 1 of 1

Re: [Linux] Cursor_From_PNG

Posted: Mon Feb 22, 2010 3:45 am
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

Re: [Linux] Cursor_From_PNG

Posted: Mon Feb 22, 2010 4:30 am
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.

Re: [Linux] Cursor_From_PNG

Posted: Mon Feb 22, 2010 5:09 pm
by Erlend
You are right but the PB Team changed PBImage in 4.40 from pixmaps to pixbufs under linux...