Advertisement
Combreal

childsBreakStructSolution.cpp

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