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.

106 lines
2.7KB

  1. //
  2. // "$Id: tiled_image.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Fl_Tiled_Image test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. #include <FL/Fl.H>
  28. #include <FL/Fl_Double_Window.H>
  29. #include <FL/Fl_Button.H>
  30. #include <FL/Fl_Pixmap.H>
  31. #include <FL/Fl_Tiled_Image.H>
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <math.h>
  35. #include "pixmaps/tile.xpm"
  36. Fl_Button *b;
  37. Fl_Double_Window *w;
  38. void button_cb(Fl_Widget *,void *) {
  39. w->hide();
  40. }
  41. #include <FL/x.H>
  42. #if !defined(WIN32) && !defined(__APPLE__)
  43. #include "list_visuals.cxx"
  44. #endif
  45. int visid = -1;
  46. int arg(int argc, char **argv, int &i) {
  47. if (argv[i][1] == 'v') {
  48. if (i+1 >= argc) return 0;
  49. visid = atoi(argv[i+1]);
  50. i += 2;
  51. return 2;
  52. }
  53. return 0;
  54. }
  55. int main(int argc, char **argv) {
  56. #if !defined(WIN32) && !defined(__APPLE__)
  57. int i = 1;
  58. Fl::args(argc,argv,i,arg);
  59. if (visid >= 0) {
  60. fl_open_display();
  61. XVisualInfo templt; int num;
  62. templt.visualid = visid;
  63. fl_visual = XGetVisualInfo(fl_display, VisualIDMask, &templt, &num);
  64. if (!fl_visual) {
  65. fprintf(stderr, "No visual with id %d, use one of:\n",visid);
  66. list_visuals();
  67. exit(1);
  68. }
  69. fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
  70. fl_visual->visual, AllocNone);
  71. fl_xpixel(FL_BLACK); // make sure black is allocated in overlay visuals
  72. } else {
  73. Fl::visual(FL_RGB);
  74. }
  75. #endif
  76. Fl_Double_Window window(400,400); ::w = &window;
  77. Fl_Group group(0,0,400,400);
  78. group.image(new Fl_Tiled_Image(new Fl_Pixmap((const char * const *)tile_xpm)));
  79. group.align(FL_ALIGN_INSIDE);
  80. Fl_Button b(340,365,50,25,"Close"); ::b = &b;
  81. b.callback(button_cb);
  82. group.end();
  83. window.resizable(group);
  84. window.end();
  85. window.show(argc, argv);
  86. return Fl::run();
  87. }
  88. //
  89. // End of "$Id: tiled_image.cxx 7903 2010-11-28 21:06:39Z matt $".
  90. //