Advertisement
Korotkodul

make_button

Nov 24th, 2024 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <stdexcept>
  4. #include <string>
  5.  
  6. #include <FL/Fl.H>
  7. #include <FL/Fl_Window.H>
  8. #include <FL/Fl_Button.H>
  9.  
  10. #include <Graph_lib/Graph.h>
  11. #include <Graph_lib/Simple_window.h>
  12.  
  13. using namespace Graph_lib;
  14.  
  15. const int cell_size = 100;
  16.  
  17. struct cell {
  18.   int x;
  19.   int y;
  20.   std::string state;
  21.   cell () { this->x = 0; this->y = 0; this->state = "free"; }
  22.   cell (int X, int Y) {this->x = X; this->y = Y; this->state = "free";}
  23.  
  24. };
  25.  
  26. // Функция для обработки нажатия кнопки
  27. void button_callback(Fl_Widget *widget, void *data) {
  28.     std::string *label = (std::string*)data;
  29.     std::cout << "Pushed: " << *label << std::endl;
  30. }
  31.  
  32. int main ()
  33. try
  34. {
  35.   Fl_Window *window = new Fl_Window(400, 300, "Window");
  36.   std::string button_name = "Button1";
  37.   Fl_Button *button = new Fl_Button(100, 100, 100, 30, "Button1");
  38.   button->callback(button_callback, (void*)&button_name);
  39.   window->end();
  40.   window->show();
  41.   return Fl::run();
  42. }
  43. catch (std::exception& e)
  44. {
  45.   std::cerr << e.what() << std::endl;
  46.   return 1;
  47. }
  48. catch (...)
  49. {
  50.   std::cerr << "Oops, something went wrong..." << std::endl;
  51.   return 2;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement