You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.4KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2013 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include <FL/x.H>
  19. #include <FL/Fl_Double_Window.H>
  20. #include <FL/Fl.H>
  21. #include <FL/Fl_Box.H>
  22. #include <FL/Fl_Socket_Window.H>
  23. #include <stdlib.h>
  24. int main ( int argc, char **argv )
  25. {
  26. Window into = 0;
  27. int wait_for_client = 0;
  28. if ( argc > 1 )
  29. {
  30. if ( !strcmp( argv[1], "--wait" ) )
  31. wait_for_client = 1;
  32. else
  33. sscanf( argv[1], "%lx", &into );
  34. }
  35. fl_open_display();
  36. Fl_Double_Window *plug = NULL;
  37. if ( ! wait_for_client )
  38. {
  39. { Fl_Double_Window *o = plug = new Fl_Double_Window( 300,300, "Plug");
  40. o->color( FL_GRAY );
  41. {
  42. Fl_Box *o = new Fl_Box( 0, 0, 300, 300,
  43. "You should see a gray box in the upper left hand corner on green field if embedding worked.");
  44. o->align( FL_ALIGN_WRAP );
  45. o->box(FL_UP_BOX);
  46. Fl_Group::current()->resizable(o);
  47. }
  48. o->end();
  49. /* NOTE: window to be embedded is never show()'n */
  50. }
  51. }
  52. Fl_Socket_Window *socket = NULL;
  53. if ( ! into )
  54. {
  55. { Fl_Double_Window *o = new Fl_Double_Window( 500, 600, "Top-Level" );
  56. { Fl_Box *o = new Fl_Box( 0, 0, 500, 100, "This is the top-level window, the window for embedding should be nested below" );
  57. o->align( FL_ALIGN_WRAP );
  58. o->box( FL_BORDER_BOX );
  59. }
  60. { Fl_Socket_Window *o = socket = new Fl_Socket_Window( 0, 100, 500,500, "Socket");
  61. o->color(FL_GREEN);
  62. o->end();
  63. o->show();
  64. }
  65. o->end();
  66. o->show();
  67. }
  68. }
  69. if ( ! wait_for_client )
  70. {
  71. if ( ! into )
  72. {
  73. fl_embed( plug, fl_xid( socket ));
  74. }
  75. else
  76. {
  77. fl_embed( plug, into );
  78. }
  79. }
  80. else
  81. {
  82. printf( "Waiting for client... win_id = 0x%lx %ld\n", fl_xid( socket ), fl_xid( socket ) );
  83. }
  84. Fl::run();
  85. return 0;
  86. }