Buchempfehlung
Windows System Programming
Windows System Programming
Das Kompendium liefert viele interessante Informationen zur Windows-Programmierung auf Englisch. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

GTK - Entry im Fenster frei plazieren - fixed_2

Uploader:Mitgliedrieselkalk
Datum/Zeit:22.04.2010 02:24:46

'- rieselkalk 2010
'- fixed_2.bas

#include once "gtk/gtk.bi"

Dim Shared Schalter As Integer

Dim Shared xpos As Integer
Dim Shared ypos As Integer
Dim Shared laenge As Integer
Dim Shared hoehe As Integer
Dim Shared maxlength As Integer
Dim Shared faktor As Integer

Declare Sub callback_links cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_rechts cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_oben cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_unten cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_laenge_k cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_laenge_g cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_hoehe_k cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_hoehe_g cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_maxlength_k cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_maxlength_g cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_faktor_k cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Declare Sub callback_faktor_g cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)

Declare Sub show_xpos()
Declare Sub show_ypos()
Declare Sub show_laenge()
Declare Sub show_hoehe()
Declare Sub show_maxlength()
Declare Sub show_faktor()

gtk_init (0, 0)

Schalter = 0

xpos = 0
ypos = 0
laenge = 90
hoehe = 20
maxlength = 10
faktor = 10

dim as GtkWidget ptr win_1 = gtk_window_new (GTK_WINDOW_TOPLEVEL)
gtk_window_set_title (GTK_WINDOW (win_1), "Test fixed 2")
gtk_window_move (GTK_WINDOW (win_1), 300, 300)
gtk_window_resize (GTK_WINDOW (win_1), 500, 300)

dim Shared As GtkWidget ptr button_links
button_links = gtk_button_new_with_label("< Links")
g_signal_connect(GTK_OBJECT(button_links),"clicked",G_CALLBACK(@callback_links),0)

dim Shared As GtkWidget ptr button_rechts
button_rechts = gtk_button_new_with_label("Rechts >")
g_signal_connect(GTK_OBJECT(button_rechts),"clicked",G_CALLBACK(@callback_rechts),0)

dim Shared As GtkWidget ptr button_oben
button_oben = gtk_button_new_with_label("< Oben ")
g_signal_connect(GTK_OBJECT(button_oben),"clicked",G_CALLBACK(@callback_oben),0)

dim Shared As GtkWidget ptr button_unten
button_unten = gtk_button_new_with_label("Unten >")
g_signal_connect(GTK_OBJECT(button_unten),"clicked",G_CALLBACK(@callback_unten),0)

dim Shared As GtkWidget ptr button_laenge_k
button_laenge_k = gtk_button_new_with_label("< Laenge")
g_signal_connect(GTK_OBJECT(button_laenge_k),"clicked",G_CALLBACK(@callback_laenge_k),0)

dim Shared As GtkWidget ptr button_laenge_g
button_laenge_g = gtk_button_new_with_label("Laenge >")
g_signal_connect(GTK_OBJECT(button_laenge_g),"clicked",G_CALLBACK(@callback_laenge_g),0)

dim Shared As GtkWidget ptr button_hoehe_k
button_hoehe_k = gtk_button_new_with_label("< Hoehe")
g_signal_connect(GTK_OBJECT(button_hoehe_k),"clicked",G_CALLBACK(@callback_hoehe_k),0)

dim Shared As GtkWidget ptr button_hoehe_g
button_hoehe_g = gtk_button_new_with_label("Hoehe >")
g_signal_connect(GTK_OBJECT(button_hoehe_g),"clicked",G_CALLBACK(@callback_hoehe_g),0)

dim Shared As GtkWidget ptr button_maxlength_k
button_maxlength_k = gtk_button_new_with_label("<MaxLength")
g_signal_connect(GTK_OBJECT(button_maxlength_k),"clicked",G_CALLBACK(@callback_maxlength_k),0)

dim Shared As GtkWidget ptr button_maxlength_g
button_maxlength_g = gtk_button_new_with_label("MaxLength>")
g_signal_connect(GTK_OBJECT(button_maxlength_g),"clicked",G_CALLBACK(@callback_maxlength_g),0)

dim Shared As GtkWidget ptr button_faktor_k
button_faktor_k = gtk_button_new_with_label("< Faktor")
g_signal_connect(GTK_OBJECT(button_faktor_k),"clicked",G_CALLBACK(@callback_faktor_k),0)

dim Shared As GtkWidget ptr button_faktor_g
button_faktor_g = gtk_button_new_with_label("Faktor >")
g_signal_connect(GTK_OBJECT(button_faktor_g),"clicked",G_CALLBACK(@callback_faktor_g),0)


Dim Shared As GtkWidget Ptr entry_test
entry_test = gtk_entry_new_with_max_length (maxlength)

Dim Shared As GtkWidget Ptr entry_xpos
entry_xpos = gtk_entry_new_with_max_length (10)

Dim Shared As GtkWidget Ptr entry_ypos
entry_ypos = gtk_entry_new_with_max_length (10)

Dim Shared As GtkWidget Ptr entry_laenge
entry_laenge = gtk_entry_new_with_max_length (10)

Dim Shared As GtkWidget Ptr entry_hoehe
entry_hoehe = gtk_entry_new_with_max_length (10)

Dim Shared As GtkWidget Ptr entry_maxlength
entry_maxlength = gtk_entry_new_with_max_length (10)

Dim Shared As GtkWidget Ptr entry_faktor
entry_faktor = gtk_entry_new_with_max_length (10)


Dim Shared As GtkWidget ptr vbox_1 '- Als Variable nur in Sub verfügbar
vbox_1 = gtk_vbox_new(FALSE,0)

Dim Shared As GtkWidget Ptr fbox_1
fbox_1 = gtk_fixed_new ()

Dim Shared As GtkWidget Ptr fbox_2
fbox_2 = gtk_fixed_new ()

gtk_container_add (GTK_CONTAINER(win_1), vbox_1)
gtk_box_pack_start (GTK_Box(vbox_1), fbox_1, FALSE, FALSE, 2)
gtk_box_pack_start (GTK_Box(vbox_1), fbox_2, TRUE, TRUE, 2)

gtk_fixed_put (GTK_FIXED(fbox_1), button_links, 80, 5)
gtk_fixed_put (GTK_FIXED(fbox_1), button_rechts, 80, 35)
gtk_fixed_put (GTK_FIXED(fbox_1), button_oben, 5, 5)
gtk_fixed_put (GTK_FIXED(fbox_1), button_unten, 5, 35)
gtk_fixed_put (GTK_FIXED(fbox_1), button_laenge_k, 155, 5)
gtk_fixed_put (GTK_FIXED(fbox_1), button_laenge_g, 155, 35)
gtk_fixed_put (GTK_FIXED(fbox_1), button_hoehe_k, 230, 5)
gtk_fixed_put (GTK_FIXED(fbox_1), button_hoehe_g, 230, 35)
gtk_fixed_put (GTK_FIXED(fbox_1), button_maxlength_k, 305, 5)
gtk_fixed_put (GTK_FIXED(fbox_1), button_maxlength_g, 305, 35)
gtk_fixed_put (GTK_FIXED(fbox_1), button_faktor_k, 390, 5)
gtk_fixed_put (GTK_FIXED(fbox_1), button_faktor_g, 390, 35)

gtk_fixed_put (GTK_FIXED(fbox_1), entry_xpos, 80, 65)
gtk_fixed_put (GTK_FIXED(fbox_1), entry_ypos, 5, 65)
gtk_fixed_put (GTK_FIXED(fbox_1), entry_laenge, 155, 65)
gtk_fixed_put (GTK_FIXED(fbox_1), entry_hoehe, 230, 65)
gtk_fixed_put (GTK_FIXED(fbox_1), entry_maxlength, 305, 65)
gtk_fixed_put (GTK_FIXED(fbox_1), entry_faktor, 390, 65)

gtk_fixed_put (GTK_FIXED(fbox_2), entry_test, xpos, ypos)
gtk_widget_set_size_request (GTK_WIDGET(entry_test), laenge, hoehe)

gtk_widget_set_size_request (GTK_WIDGET(button_links), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(button_rechts), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(entry_xpos), 70, 20)
show_xpos()

gtk_widget_set_size_request (GTK_WIDGET(button_oben), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(button_unten), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(entry_ypos), 70, 20)
show_ypos()

gtk_widget_set_size_request (GTK_WIDGET(button_laenge_k), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(button_laenge_g), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(entry_laenge), 70, 20)
show_laenge()

gtk_widget_set_size_request (GTK_WIDGET(button_hoehe_k), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(button_hoehe_g), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(entry_hoehe), 70, 20)
show_hoehe()

gtk_widget_set_size_request (GTK_WIDGET(button_maxlength_k), 80, 20)
gtk_widget_set_size_request (GTK_WIDGET(button_maxlength_g), 80, 20)
gtk_widget_set_size_request (GTK_WIDGET(entry_maxlength), 80, 20)
show_maxlength()

gtk_widget_set_size_request (GTK_WIDGET(button_faktor_k), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(button_faktor_g), 70, 20)
gtk_widget_set_size_request (GTK_WIDGET(entry_faktor), 70, 20)
show_faktor()

gtk_widget_show_all (win_1)


gtk_main()


sub callback_links cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Links geklickt! "
xpos = xpos - faktor
If xpos < 0 Then
xpos = 0
End If
gtk_fixed_move (GTK_FIXED(fbox_2), GTK_WIDGET(entry_test), xpos, ypos)
show_xpos
end sub

sub callback_rechts cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Rechts geklickt! "
xpos = xpos + faktor
gtk_fixed_move (GTK_FIXED(fbox_2), GTK_WIDGET(entry_test), xpos, ypos)
show_xpos
end sub

sub callback_oben cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Oben geklickt! "
ypos = ypos - faktor
If ypos < 0 Then
ypos = 0
End If
gtk_fixed_move (GTK_FIXED(fbox_2), GTK_WIDGET(entry_test), xpos, ypos)
show_ypos
end sub

sub callback_unten cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Unten geklickt! "
ypos = ypos + faktor
gtk_fixed_move (GTK_FIXED(fbox_2), GTK_WIDGET(entry_test), xpos, ypos)
show_ypos
end sub

sub callback_laenge_k cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Laenge geklickt! "
laenge = laenge - faktor
If laenge < 20 Then
laenge = 20
End If
gtk_widget_set_size_request (GTK_WIDGET(entry_test), laenge, hoehe)
show_laenge
End sub

sub callback_laenge_g cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Laenge geklickt! "
laenge = laenge + faktor
gtk_widget_set_size_request (GTK_WIDGET(entry_test), laenge, hoehe)
show_laenge
End sub

sub callback_hoehe_k Cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Hoehe geklickt! "
hoehe = hoehe - faktor
If hoehe < 20 Then
hoehe = 20
EndIf
gtk_widget_set_size_request (GTK_WIDGET(entry_test), laenge, hoehe)
show_hoehe
End sub

sub callback_hoehe_g Cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Hoehe geklickt! "
hoehe = hoehe + faktor
gtk_widget_set_size_request (GTK_WIDGET(entry_test), laenge, hoehe)
show_hoehe
end sub

Sub callback_maxlength_k cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button MaxLength geklickt! "
maxlength = maxlength - faktor
If maxlength < 1 Then
maxlength = faktor
EndIf
gtk_entry_set_max_length (GTK_ENTRY(entry_test), maxlength)
show_maxlength
End Sub

Sub callback_maxlength_g cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button MaxLength geklickt! "
maxlength = maxlength + faktor
gtk_entry_set_max_length (GTK_ENTRY(entry_test), maxlength)
show_maxlength
End Sub

Sub callback_faktor_k cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Faktor geklickt! "
faktor = faktor - 1
If faktor < 1 Then
faktor = 1
EndIf
show_faktor
End Sub

Sub callback_faktor_g cdecl (byval widget as GtkWidget ptr, byval user_data as gpointer)
Print "Button Faktor geklickt! "
faktor = faktor + 1
show_faktor
End Sub

Sub show_xpos
gtk_entry_set_text (Gtk_Entry(entry_xpos), Str(xpos))
End Sub

Sub show_ypos
gtk_entry_set_text (Gtk_Entry(entry_ypos), Str(ypos))
End Sub

Sub show_laenge
gtk_entry_set_text (Gtk_Entry(entry_laenge), Str(laenge))
End Sub

Sub show_hoehe
gtk_entry_set_text (Gtk_Entry(entry_hoehe), Str(hoehe))
End Sub

Sub show_maxlength
gtk_entry_set_text (Gtk_Entry(entry_maxlength), Str(maxlength))
End Sub

Sub show_faktor
gtk_entry_set_text (Gtk_Entry(entry_faktor), Str(faktor))
End Sub