no code.... yes (till now) but an application which uses a transparent window...
Code: Select all
;demo für ein transparentes fenster....
;
Global support_alpha_channel=#False
Global gtk_label_set_single_line_mode
Global gtk_window_set_icon_name
Global gtk_window_set_has_frame
Global gdk_screen_get_rgba_colormap
Global gdk_cairo_create
Global gdk_window_set_back_pixmap
Global cairo_set_source_rgba
Global cairo_set_source_rgb
Global cairo_set_operator
Global cairo_paint
Global cairo_stroke
Global cairo_destroy
Enumeration
#CAIRO_OPERATOR_CLEAR
#CAIRO_OPERATOR_SOURCE
#CAIRO_OPERATOR_OVER
#CAIRO_OPERATOR_IN
#CAIRO_OPERATOR_OUT
#CAIRO_OPERATOR_ATOP
#CAIRO_OPERATOR_DEST
#CAIRO_OPERATOR_DEST_OVER
#CAIRO_OPERATOR_DEST_IN
#CAIRO_OPERATOR_DEST_OUT
#CAIRO_OPERATOR_DEST_ATOP
#CAIRO_OPERATOR_XOR
#CAIRO_OPERATOR_ADD
#CAIRO_OPERATOR_SATURATE
EndEnumeration
ProcedureCDLL gtk_label_set_single_line_mode(*label,single_line)
ProcedureReturn CallCFunctionFast(gtk_label_set_single_line_mode,*label,single_line)
EndProcedure
ProcedureCDLL gtk_window_set_icon_name(*window,*stock_icon)
ProcedureReturn CallCFunctionFast(gtk_window_set_icon_name,*window,*stock_icon)
EndProcedure
ProcedureCDLL gtk_window_set_has_frame(*window,hasframe)
ProcedureReturn CallCFunctionFast(gtk_window_set_has_frame,*window,hasframe)
EndProcedure
ProcedureCDLL gdk_screen_get_rgba_colormap(*widget)
ProcedureReturn CallCFunctionFast(gdk_screen_get_rgba_colormap,*widget)
EndProcedure
ProcedureCDLL gdk_cairo_create(*context)
ProcedureReturn CallCFunctionFast(gdk_cairo_create,*context)
EndProcedure
ProcedureCDLL gdk_window_set_back_pixmap(*window,*image,relative)
ProcedureReturn CallCFunctionFast(gdk_window_set_back_pixmap,*window,*image,relative)
EndProcedure
ProcedureCDLL cairo_set_source_rgba(*cairo,r.f,g.f,b.f,a.f)
ProcedureReturn CallCFunctionFast(cairo_set_source_rgba,*cairo,r.f,g.f,b.f,a.f)
EndProcedure
ProcedureCDLL cairo_set_source_rgb(*cairo,r.f,g.f,b.f)
ProcedureReturn CallCFunctionFast(cairo_set_source_rgb,*cairo,r.f,g.f,b.f)
EndProcedure
ProcedureCDLL cairo_set_operator(*cairo,type)
ProcedureReturn CallCFunctionFast(cairo_set_operator,*cairo,type)
EndProcedure
ProcedureCDLL cairo_paint(*cairo)
ProcedureReturn CallCFunctionFast(cairo_paint,*cairo)
EndProcedure
ProcedureCDLL cairo_stroke(*cairo);
ProcedureReturn CallCFunctionFast(cairo_stroke,*cairo);
EndProcedure
ProcedureCDLL cairo_destroy(*cairo);
ProcedureReturn CallCFunctionFast(cairo_destroy,*cairo)
EndProcedure
;import needed functions missing in PB
;{
mylib.s=find_library("libgtk-x11-2.0.so")
If OpenLibrary(0,mylib)
gtk_label_set_single_line_mode=GetFunction(0,"gtk_label_set_single_line_mode")
gtk_window_set_icon_name=GetFunction(0,"gtk_window_set_icon_name")
gtk_window_set_has_frame=GetFunction(0,"gtk_window_set_has_frame")
EndIf
mylib1.s=find_library("libgdk_pixbuf-2.0.so")
If OpenLibrary(1,mylib1)
gdk_screen_get_rgba_colormap=GetFunction(1,"gdk_screen_get_rgba_colormap")
gdk_cairo_create=GetFunction(1,"gdk_cairo_create")
gdk_window_set_back_pixmap=GetFunction(1,"gdk_window_set_back_pixmap")
EndIf
If gdk_screen_get_rgba_colormap = 0
CloseLibrary(1)
mylib1.s=find_library("libgdk_pixbuf-2.0.so.0")
If OpenLibrary(1,mylib1)
gdk_screen_get_rgba_colormap=GetFunction(1,"gdk_screen_get_rgba_colormap")
gdk_cairo_create=GetFunction(1,"gdk_cairo_create")
gdk_window_set_back_pixmap=GetFunction(1,"gdk_window_set_back_pixmap")
EndIf
EndIf
mylib2.s=find_library("libcairo.so")
If OpenLibrary(2,mylib2)
cairo_set_source_rgba=GetFunction(2,"cairo_set_source_rgba")
cairo_set_source_rgb=GetFunction(2,"cairo_set_source_rgb")
cairo_set_operator=GetFunction(2,"cairo_set_operator")
cairo_paint=GetFunction(2,"cairo_paint")
cairo_stroke=GetFunction(2,"cairo_stroke")
cairo_destroy=GetFunction(2,"cairo_destroy");
EndIf
;}
ProcedureCDLL expose(hwnd, *event,*user_data)
*xhw.GtkWidget
*xhw=*user_data
*cr=gdk_cairo_create(*xhw\window)
If *cr
If support_alpha_channel = #True
cairo_set_source_rgba(*cr,1.0,1.0,1.0,0.0)
Else
cairo_set_source_rgb(*cr,1.0,1.0,1.0)
EndIf
;drawing the background
cairo_set_operator(*cr,#cairo_operator_source)
cairo_paint(*cr)
cairo_destroy(*cr);
EndIf
ProcedureReturn #False
EndProcedure
ProcedureCDLL screen_changed(*hwnd, *old_screen, *user_data)
;checking if an alpha channel is available for this screen/Windowmanager
*screen=gtk_widget_get_screen_(*hwnd)
*colormap=gdk_screen_get_rgba_colormap(*screen)
If *colormap ;yes, it is
support_alpha_channel=#True
Else ; sorry
MessageRequester("No Alpha Support", "Your Screen doesn't support an alpha channel...",#PB_MessageRequester_Ok)
*colormap=gdk_screen_get_rgb_colormap_(*screen)
support_alpha_channel=#False
EndIf
; using the appropriate colormap For this screen
gtk_widget_set_colormap_(*hwnd,*colormap)
ProcedureReturn 1
EndProcedure
ProcedureCDLL clicked(*hwnd, *event, *user_data)
*hwnd=*user_data; ????? why? *hwnd is always zero.... but shouldn't
gtk_window_get_position_(*hwnd,@x,@y)
If gtk_window_get_decorated_(*hwnd)=#True
gtk_window_set_decorated_(*hwnd, #False)
Else
gtk_window_set_decorated_(*hwnd, #True)
EndIf
gtk_window_move_(*hwnd,x,y)
ProcedureReturn 1
EndProcedure
ProcedureCDLL exit_button_click(*widget,*event,*user_data)
;cleanup
gtk_main_quit_()
End
EndProcedure
*window1=gtk_window_new_(#GTK_WINDOW_TOPLEVEL)
gtk_window_set_title_(*window1,"Alpha test")
gtk_window_set_resizable_(*window1,#False)
gtk_window_move_(*window1,200,20)
*fixed1 = gtk_fixed_new_();
gtk_widget_show_(*fixed1);
gtk_container_add_(*window1, *fixed1);
gtk_widget_set_parent_window_(*window1,*window)
*image=gtk_image_new_from_file_("./skin.png") ;<<<<<<<<<<<<--------------- ändern--------------------<<<<<<<<<<<<<<<<<<<
gtk_fixed_put_(*fixed1,*image,0,0)
gtk_widget_show_(*image)
g_signal_connect_object_(*window1,"expose-event" ,@expose(),*window,#G_CONNECT_SWAPPED);
g_signal_connect_object_(*window1, "screen-changed", @screen_changed(), *pointer,#G_CONNECT_SWAPPED);
g_signal_connect_object_(*window1,"delete-event",@exit_button_click(),*pointer,#G_CONNECT_SWAPPED)
gtk_widget_add_events_(*window1, #GDK_BUTTON_PRESS_MASK);
g_signal_connect_object_(*window1, "button-press-event", @clicked(), *pointer,#G_CONNECT_SWAPPED);
gtk_widget_set_app_paintable_(*window1, #True)
screen_changed(*window1, #Null, #Null);
gtk_widget_show_all_(*window1)
gtk_main_()