-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 1ce58fd.
- Loading branch information
Showing
5 changed files
with
63 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
# GIT Help | ||
|
||
Marker : feature-keybord branch | ||
|
||
Noch eine Änderung | ||
|
||
## Strategie | ||
|
||
|
||
|
||
## First steps | ||
|
||
git init | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,85 @@ | ||
#include <gtk/gtk.h> | ||
// https://docs.gtk.org/gtk4/ | ||
|
||
#define BUTTON_NUM 20 | ||
|
||
GtkWidget *window; | ||
GtkWidget *entry; | ||
GtkWidget *button; | ||
GtkWidget *grid; | ||
GtkWidget *buttons[BUTTON_NUM]; | ||
GtkWidget *buttons[10]; | ||
GtkWidget *box; | ||
|
||
const char *buttonlabels[BUTTON_NUM] = {"C","/","*","-","7","8","9","+","4","5","6","(","1","2","3",")"," ","0",",","="}; | ||
|
||
// Funktion zum Behandeln des Button-Klicks | ||
void button_clicked(GtkWidget *button, gpointer data) | ||
{ | ||
const char *text = gtk_editable_get_text(GTK_EDITABLE(data)); | ||
void button_clicked(GtkWidget *button, gpointer data) { | ||
const char *text = gtk_entry_get_text(GTK_ENTRY(data)); | ||
printf("Der eingegebene Text ist: %s\n", text); | ||
} | ||
|
||
// Funktion zum Behandeln der Ziffern-Buttons | ||
void number_button_clicked(GtkWidget *button, gpointer data) | ||
{ | ||
const char *label = gtk_button_get_label(GTK_BUTTON(button)); | ||
char button_char = *label; | ||
switch (button_char) { | ||
case 'C': | ||
// gtk_entry_set_text (GTK_ENTRY(data), ""); | ||
gtk_editable_set_text(GTK_EDITABLE(data), ""); | ||
break; | ||
default: | ||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY(data)); | ||
gtk_entry_buffer_insert_text (buffer, -1, label, -1); | ||
} | ||
void number_button_clicked(GtkWidget *button, gpointer data) { | ||
const char *number = gtk_button_get_label(GTK_BUTTON(button)); | ||
gtk_entry_set_text(GTK_ENTRY(data), number); | ||
// gtk_entry_append_text(GTK_ENTRY(data), number); | ||
} | ||
|
||
static void activate (GtkApplication *app, gpointer user_data) | ||
{ | ||
int main(int argc, char *argv[]) { | ||
gtk_init(&argc, &argv); | ||
|
||
// Erstellen Sie ein Fenster | ||
window = gtk_application_window_new (app); | ||
gtk_window_set_title(GTK_WINDOW(window), "Hello World Gtk4"); | ||
gtk_window_set_default_size(GTK_WINDOW(window), 320, 100); | ||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
gtk_window_set_title(GTK_WINDOW(window), "Hello World"); | ||
gtk_window_set_default_size(GTK_WINDOW(window), 300, 100); | ||
|
||
// Erstellt ein Eingabefeld | ||
// Erstellen Sie ein Eingabefeld | ||
entry = gtk_entry_new(); | ||
|
||
// Erstellt einen Button | ||
// Erstellen Sie einen Button | ||
button = gtk_button_new_with_label("Eingabe ausgeben"); | ||
// Verbindt den Button-Klick mit der Funktion button_clicked | ||
|
||
// Verbinden Sie den Button-Klick mit der Funktion button_clicked | ||
g_signal_connect(button, "clicked", G_CALLBACK(button_clicked), entry); | ||
|
||
// Erstellt ein GtkGrid-Widget für den Tastenblock | ||
// Verbinden Sie den delete-event-Handler mit gtk_main_quit() | ||
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL); | ||
|
||
/**/ | ||
|
||
// Erstellen Sie ein GtkGrid-Widget für den Tastenblock | ||
grid = gtk_grid_new(); | ||
gtk_grid_set_column_spacing(GTK_GRID(grid), 5); | ||
gtk_grid_set_row_spacing(GTK_GRID(grid), 5); | ||
|
||
for (int i = 0; i < BUTTON_NUM; i++) { | ||
// Erstellen der Buttons | ||
buttons[i] = gtk_button_new_with_label(buttonlabels[i]); | ||
// Erstellen Sie 10 Buttons für die Ziffern 0-9 | ||
for (int i = 0; i < 10; i++) { | ||
buttons[i] = gtk_button_new_with_label(g_strdup_printf("%d", i)); | ||
g_signal_connect(buttons[i], "clicked", G_CALLBACK(number_button_clicked), entry); | ||
} | ||
|
||
// Fügt die Buttons in das Grid-Widget ein | ||
gtk_grid_attach(GTK_GRID(grid), buttons[i], i % 4, i / 4, 1, 1); | ||
// Fügen Sie die Buttons in das Grid-Widget ein | ||
int row = 0, column = 0; | ||
for (int i = 0; i < 10; i++) { | ||
gtk_grid_attach(GTK_GRID(grid), buttons[i], column, row, 1, 1); | ||
if (column == 2) { | ||
column = 0; | ||
row++; | ||
} else { | ||
column++; | ||
} | ||
} | ||
|
||
/**/ | ||
// Erstellen Sie einen Box-Container und fügen Sie das Eingabefeld, den Button und den Tastenblock hinzu | ||
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); | ||
gtk_box_append(GTK_BOX(box), entry); | ||
gtk_widget_set_margin_top(entry, 10); | ||
gtk_widget_set_margin_start(entry, 10); | ||
gtk_widget_set_margin_end(entry, 10); | ||
|
||
gtk_box_append(GTK_BOX(box), grid); | ||
gtk_widget_set_halign(grid, GTK_ALIGN_CENTER); | ||
gtk_widget_set_margin_top(grid, 10); | ||
gtk_widget_set_margin_bottom(grid, 10); | ||
|
||
gtk_box_append(GTK_BOX(box), button); | ||
gtk_widget_set_margin_start(button, 10); | ||
gtk_widget_set_margin_end(button, 10); | ||
gtk_widget_set_margin_bottom(button, 10); | ||
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); | ||
gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0); | ||
gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0); | ||
gtk_box_pack_start(GTK_BOX(box), grid, TRUE, TRUE, 0); | ||
|
||
// Fügen Sie den Box-Container zum Fenster hinzu | ||
gtk_window_set_child (GTK_WINDOW (window), box); | ||
|
||
gtk_window_present (GTK_WINDOW (window)); | ||
} | ||
|
||
gtk_container_add(GTK_CONTAINER(window), box); | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
GtkApplication *app; | ||
int status; | ||
// Zeigen Sie alle Widgets an | ||
gtk_widget_show_all(window); | ||
|
||
app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE); | ||
g_signal_connect(app, "activate", G_CALLBACK (activate), NULL); | ||
status = g_application_run (G_APPLICATION (app), argc, argv); | ||
g_object_unref (app); | ||
// Starten Sie die GTK+-Hauptschleife | ||
gtk_main(); | ||
|
||
return status; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"c_cpp.includePath": [ | ||
"/usr/include/gtk-4.0" // Ersetzen Sie diesen Pfad nach Bedarf | ||
"/usr/include/gtk-3.0" // Ersetzen Sie diesen Pfad nach Bedarf | ||
] | ||
} |