demo_fullscreen.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "ftk.h"
  2. #define IDC_TEST_BUTTON 1000
  3. static Ret button_quit_clicked(void* ctx, void* obj)
  4. {
  5. ftk_widget_unref(ctx);
  6. return RET_OK;
  7. }
  8. static Ret button_unfullscreen_clicked(void* ctx, void* obj)
  9. {
  10. ftk_window_set_fullscreen(ctx, 0);
  11. return RET_OK;
  12. }
  13. static Ret button_fullscreen_clicked(void* ctx, void* obj)
  14. {
  15. ftk_window_set_fullscreen(ctx, 1);
  16. return RET_OK;
  17. }
  18. #ifdef FTK_AS_PLUGIN
  19. #include "ftk_app_demo.h"
  20. FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
  21. FtkApp* ftk_app_demo_fullscreen_create()
  22. {
  23. return ftk_app_demo_create(_("fullscreen"), ftk_main);
  24. }
  25. #else
  26. #define FTK_HIDE extern
  27. #endif /*FTK_AS_PLUGIN*/
  28. FTK_HIDE int FTK_MAIN(int argc, char* argv[])
  29. {
  30. int width = 0;
  31. int height = 0;
  32. FtkWidget* win = NULL;
  33. FtkWidget* button = NULL;
  34. FTK_INIT(argc, argv);
  35. win = ftk_app_window_create();
  36. width = ftk_widget_width(win);
  37. height = ftk_widget_height(win);
  38. width = width/2 - 10;
  39. button = ftk_button_create(win, 0, height/4, width, 50);
  40. ftk_widget_set_text(button, "Fullscreen");
  41. ftk_button_set_clicked_listener(button, button_fullscreen_clicked, win);
  42. button = ftk_button_create(win, width + 10, height/4, width, 50);
  43. ftk_widget_set_text(button, "Unfullscreen");
  44. ftk_button_set_clicked_listener(button, button_unfullscreen_clicked, win);
  45. button = ftk_button_create(win, width/2, height/2, width, 60);
  46. ftk_widget_set_text(button, "quit");
  47. ftk_button_set_clicked_listener(button, button_quit_clicked, win);
  48. ftk_window_set_focus(win, button);
  49. ftk_widget_set_text(win, "fullscreen");
  50. ftk_widget_show_all(win, 1);
  51. FTK_QUIT_WHEN_WIDGET_CLOSE(win);
  52. FTK_RUN();
  53. return 0;
  54. }