fb:porticula NoPaste
GTK - Menü Beispiel - menue_2
Uploader: | rieselkalk |
Datum/Zeit: | 22.04.2010 02:36:46 |
'- rieselkalk 2010
'- menue_2.bas
#include once "gtk/gtk.bi"
Declare Sub TextToLabel(Text As String)
sub callback_1 Cdecl (ByVal widget as GtkWidget ptr, byval user_data as gpointer)
TextToLabel("Neu wurde geklickt!")
End sub
sub callback_2 Cdecl (ByVal widget as GtkWidget ptr, byval user_data as gpointer)
'- UTF8 Zeichensatz Ä 195 132, Ö 195 150, Ü 195 156, ß 195 159, ä 195 164, ö 195 182, ü 195 188
TextToLabel(Chr(195)+Chr(150)+"ffnen wurde geklickt!")
End Sub
sub callback_3 Cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
gtk_main_quit()
end Sub
gtk_init (0, 0)
Dim Shared As GtkWidget ptr win_1 '- Als Variable nur in Sub verfügbar
win_1 = gtk_window_new (GTK_WINDOW_TOPLEVEL)
gtk_window_set_title (GTK_WINDOW (win_1), "Test Menue 2")
gtk_window_move (GTK_WINDOW (win_1), 300, 200)
gtk_window_resize (GTK_WINDOW (win_1), 300, 60)
Dim Shared As GtkWidget Ptr menue_bar
menue_bar = gtk_menu_bar_new ()
Dim Shared As GtkWidget Ptr hmenue_Datei
hmenue_Datei = gtk_menu_item_new_with_label ("Datei")
gtk_widget_show (hmenue_Datei)
gtk_menu_bar_append (GTK_MENU_BAR(menue_bar), GTK_WIDGET(hmenue_Datei))
Dim Shared As GtkWidget Ptr hmenue_down_Datei
hmenue_down_Datei = gtk_menu_new
gtk_menu_item_set_submenu (GTK_MENU_ITEM(hmenue_Datei), GTK_WIDGET(hmenue_down_Datei))
Dim Shared As GtkWidget Ptr vmenue_Neu
vmenue_Neu = gtk_menu_item_new_with_label ("Neu")
gtk_menu_append (GTK_MENU (hmenue_down_Datei), GTK_WIDGET (vmenue_Neu))
gtk_signal_connect_object (GTK_OBJECT(vmenue_Neu),"activate",G_CALLBACK(@callback_1),0)
Dim Shared As GtkWidget Ptr vmenue_Oeffnen
vmenue_Oeffnen = gtk_menu_item_new_with_label (Chr(195)+Chr(150)+"ffnen...")
gtk_menu_append (GTK_MENU (hmenue_down_Datei), GTK_WIDGET (vmenue_Oeffnen))
gtk_signal_connect_object (GTK_OBJECT(vmenue_Oeffnen),"activate",G_CALLBACK(@callback_2),0)
Dim Shared As GtkWidget Ptr vmenue_Beenden
vmenue_Beenden = gtk_menu_item_new_with_label ("Beenden")
gtk_menu_append (GTK_MENU (hmenue_down_Datei), GTK_WIDGET (vmenue_Beenden))
gtk_signal_connect_object (GTK_OBJECT(vmenue_Beenden),"activate",G_CALLBACK(@callback_3),0)
Dim Shared As GtkWidget Ptr label_1 '- Als Variable nur in Sub verfügbar
label_1 = gtk_label_new("_______")
TextToLabel("Keine Auswahl!")
dim Shared As GtkWidget ptr vbox_1 '- Als Variable nur in Sub verfügbar
vbox_1 = gtk_vbox_new(FALSE,0)
gtk_container_add (GTK_CONTAINER(vbox_1), menue_bar)
gtk_container_add (GTK_CONTAINER(vbox_1), label_1)
gtk_container_add (GTK_CONTAINER (win_1), vbox_1)
gtk_widget_show_all (win_1)
gtk_main()
Sub TextToLabel(Text As String)
gtk_label_set_text (GTK_LABEL(label_1), Text)
End Sub