; Module/File: Window_CursorFromLoadedPNG.pb ; Function: Set own cursor for window from loaded png-file - Linux gtk2 2.14+ ; Author: Erlend / GBeebe, updated + gtk3: Omi ; Date: Jul. 27, 2017 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.3/5.4/5.5/5.6 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ; Link to topic: http://www.purebasic.fr/english/viewtopic.php?f=12&t=41209 ;-------------------------------------------------------------- EnableExplicit UsePNGImageDecoder() ImportC "" gtk_widget_get_window(*widget.GtkWidget) EndImport Enumeration GtkIconLookupFlags #GTK_ICON_LOOKUP_ALL = 0; Not gtk-defined, own constant to clearify #GTK_ICON_LOOKUP_NO_SVG = 1 #GTK_ICON_LOOKUP_FORCE_SVG = 2 #GTK_ICON_LOOKUP_USE_BUILTIN = 4 #GTK_ICON_LOOKUP_GENERIC_FALLBACK = 8 #GTK_ICON_LOOKUP_FORCE_SIZE = 16 EndEnumeration #Win_Main = 0 #Text1 = 0 #Image1 = 0 Global *Cursor.GdkCursor Procedure CreateCursorFromPixbuf(*Pixbuf, cx, cy); cx/cy= hotspot ProcedureReturn gdk_cursor_new_from_pixbuf_(gdk_display_get_default_(), *Pixbuf, cx, cy) EndProcedure Procedure SetCursorForWindow(*window.GtkWindow, Cursor) gdk_window_set_cursor_(gtk_widget_get_window(*window), Cursor) EndProcedure Procedure Create_WinMain() If OpenWindow(#Win_Main, 0, 0, 300, 300,"Own Cursor from loaded png", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) If LoadImage(#Image1, #PB_Compiler_Home + "./examples/sources/Data/world.png") Protected Cursor= CreateCursorFromPixbuf(ImageID(#Image1), 8, 8) If Cursor SetCursorForWindow(WindowID(#Win_Main), Cursor) EndIf EndIf TextGadget(#Text1, 0, 0, 200, 30, "Move mouse into the window") EndIf EndProcedure Create_WinMain() Repeat Until WaitWindowEvent() = #PB_Event_CloseWindow ; IDE Options = PureBasic 5.44 LTS (Linux - x86) ; CursorPosition = 26 ; Folding = - ; EnableUnicode ; EnableXP