Advertisement
Combreal

childsBreakStruct01.cpp

Jun 20th, 2018
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.35 KB | None | 0 0
  1. #include <gtk-3.0/gtk/gtk.h>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. typedef struct t_WINDOWSCBSD
  6. {
  7.     GtkWidget *window, *textView;
  8. } WINDOWSCBSD;
  9.  
  10. static void destroy(GtkWidget *widget, gpointer data)
  11. {
  12.     gtk_main_quit();
  13. }
  14.  
  15. static void buttonClickedD(GtkWidget *buttony, gpointer data)
  16. {
  17.     WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
  18.     const gchar *gtextView;
  19.     std::string stextView;
  20.  
  21.     gtextView = gtk_entry_get_text(GTK_ENTRY(myData->textView));
  22.     stextView = gtextView;
  23.     std::cout<<stextView<<std::endl;
  24. }
  25.  
  26. static void buttonClickedC(GtkWidget *buttony, gpointer data)
  27. {
  28.     GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
  29.     //WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
  30.     WINDOWSCBSD dataB;
  31.  
  32.     windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  33.     gtk_widget_set_size_request(windowB, 160, 80);
  34.     gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
  35.  
  36.     gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
  37.     gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
  38.     g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
  39.     //myData->window = windowB;
  40.     dataB.window = windowB;
  41.  
  42.     grid = gtk_grid_new();
  43.     gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
  44.     gtk_container_add(GTK_CONTAINER(windowB), grid);
  45.  
  46.     label = gtk_label_new(NULL);
  47.     gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
  48.     gtk_widget_set_halign(label, GTK_ALIGN_START);
  49.     gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
  50.     textView = gtk_entry_new();
  51.     gtk_widget_set_size_request(textView, 75, 18);
  52.     //myData->textView = textView;
  53.     dataB.textView = textView;
  54.     gtk_entry_set_text(GTK_ENTRY(textView), "testextD");
  55.     gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
  56.  
  57.     button = gtk_button_new_with_label((gchar *)"Clicky");
  58.     buttonLabel = gtk_bin_get_child(GTK_BIN(button));
  59.     gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
  60.     g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClickedD), &dataB);//&myData //&dataB
  61.     gtk_widget_set_tooltip_text(button, "Click here to start child");
  62.     gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
  63.     gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
  64.  
  65.     gtk_widget_grab_focus(button);
  66.     gtk_widget_show_all(windowB);
  67.     gtk_main();
  68. }
  69.  
  70. static void buttonClickedB(GtkWidget *buttony, gpointer data)
  71. {
  72.     GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
  73.     WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
  74.     //WINDOWSCBSD dataB;
  75.  
  76.     windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  77.     gtk_widget_set_size_request(windowB, 160, 80);
  78.     gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
  79.  
  80.     gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
  81.     gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
  82.     g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
  83.     myData->window = windowB;
  84.  
  85.     grid = gtk_grid_new();
  86.     gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
  87.     gtk_container_add(GTK_CONTAINER(windowB), grid);
  88.  
  89.     label = gtk_label_new(NULL);
  90.     gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
  91.     gtk_widget_set_halign(label, GTK_ALIGN_START);
  92.     gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
  93.     textView = gtk_entry_new();
  94.     gtk_widget_set_size_request(textView, 75, 18);
  95.     myData->textView = textView;
  96.     gtk_entry_set_text(GTK_ENTRY(textView), "testextC");
  97.     gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
  98.  
  99.     button = gtk_button_new_with_label((gchar *)"Clicky");
  100.     buttonLabel = gtk_bin_get_child(GTK_BIN(button));
  101.     gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
  102.     g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClickedC), &myData);
  103.     gtk_widget_set_tooltip_text(button, "Click here to start child");
  104.     gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
  105.     gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
  106.  
  107.     gtk_widget_grab_focus(button);
  108.     gtk_widget_show_all(windowB);
  109.     gtk_main();
  110. }
  111.  
  112. static void buttonClicked(GtkWidget *buttony, gpointer data)
  113. {
  114.     GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
  115.     WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
  116.     //WINDOWSCBSD dataB;
  117.  
  118.     windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  119.     gtk_widget_set_size_request(windowB, 160, 80);
  120.     gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
  121.  
  122.     gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
  123.     gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
  124.     g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
  125.     myData->window = windowB;
  126.  
  127.     grid = gtk_grid_new();
  128.     gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
  129.     gtk_container_add(GTK_CONTAINER(windowB), grid);
  130.  
  131.     label = gtk_label_new(NULL);
  132.     gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
  133.     gtk_widget_set_halign(label, GTK_ALIGN_START);
  134.     gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
  135.     textView = gtk_entry_new();
  136.     gtk_widget_set_size_request(textView, 75, 18);
  137.     myData->textView = textView;
  138.     gtk_entry_set_text(GTK_ENTRY(textView), "testextB");
  139.     gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
  140.  
  141.     button = gtk_button_new_with_label((gchar *)"Clicky");
  142.     buttonLabel = gtk_bin_get_child(GTK_BIN(button));
  143.     gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
  144.     g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClickedB), &myData);
  145.     gtk_widget_set_tooltip_text(button, "Click here to start child");
  146.     gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
  147.     gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
  148.  
  149.     gtk_widget_grab_focus(button);
  150.     gtk_widget_show_all(windowB);
  151.     gtk_main();
  152. }
  153.  
  154. int main(int argc, char *argv[])
  155. {
  156.     GtkWidget *windowB, *grid, *textView, *label, *button, *buttonLabel;
  157.     //WINDOWSCBSD *myData = (struct t_WINDOWSCBSD *)data;
  158.     WINDOWSCBSD dataB;
  159.  
  160.     gtk_init(&argc, &argv);
  161.  
  162.     windowB = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  163.     gtk_widget_set_size_request(windowB, 160, 80);
  164.     gtk_window_set_position(GTK_WINDOW(windowB), GTK_WIN_POS_CENTER_ALWAYS);
  165.     gtk_window_set_resizable(GTK_WINDOW(windowB), FALSE);
  166.     gtk_container_set_border_width(GTK_CONTAINER(windowB), 7);
  167.     g_signal_connect(windowB, "destroy", G_CALLBACK(destroy), NULL);
  168.     dataB.window = windowB;
  169.  
  170.     grid = gtk_grid_new();
  171.     gtk_grid_set_row_spacing(GTK_GRID(grid), 7);
  172.     gtk_container_add(GTK_CONTAINER(windowB), grid);
  173.  
  174.     label = gtk_label_new(NULL);
  175.     gtk_label_set_markup(GTK_LABEL(label), "<b>This is a test : </b>");
  176.     gtk_widget_set_halign(label, GTK_ALIGN_START);
  177.     gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
  178.     textView = gtk_entry_new();
  179.     gtk_widget_set_size_request(textView, 75, 18);
  180.     dataB.textView = textView;
  181.     gtk_entry_set_text(GTK_ENTRY(textView), "testext");
  182.     gtk_grid_attach_next_to(GTK_GRID(grid), textView, label, GTK_POS_RIGHT, 1, 1);
  183.  
  184.     button = gtk_button_new_with_label((gchar *)"Clicky");
  185.     buttonLabel = gtk_bin_get_child(GTK_BIN(button));
  186.     gtk_label_set_markup(GTK_LABEL(buttonLabel), "<b>Clicky</b>");
  187.     g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(buttonClicked), &dataB);
  188.     gtk_widget_set_tooltip_text(button, "Click here to start child");
  189.     gtk_widget_set_halign(button, GTK_ALIGN_CENTER);
  190.     gtk_grid_attach(GTK_GRID(grid), button, 0, 1, 2, 1);
  191.  
  192.     gtk_widget_grab_focus(button);
  193.     gtk_widget_show_all(windowB);
  194.     gtk_main();
  195.  
  196.     return 0;
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement