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.

103 lines
3.1KB

  1. //
  2. // "$Id: pixmap.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Pixmap label 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 <stdio.h>
  32. #include "pixmaps/porsche.xpm"
  33. #include <FL/Fl_Toggle_Button.H>
  34. Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*overb,*inactb;
  35. Fl_Button *b;
  36. Fl_Double_Window *w;
  37. void button_cb(Fl_Widget *,void *) {
  38. int i = 0;
  39. if (leftb->value()) i |= FL_ALIGN_LEFT;
  40. if (rightb->value()) i |= FL_ALIGN_RIGHT;
  41. if (topb->value()) i |= FL_ALIGN_TOP;
  42. if (bottomb->value()) i |= FL_ALIGN_BOTTOM;
  43. if (insideb->value()) i |= FL_ALIGN_INSIDE;
  44. if (overb->value()) i |= FL_ALIGN_TEXT_OVER_IMAGE;
  45. b->align(i);
  46. if (inactb->value()) b->deactivate();
  47. else b->activate();
  48. w->redraw();
  49. }
  50. int dvisual = 0;
  51. int arg(int, char **argv, int &i) {
  52. if (argv[i][1] == '8') {dvisual = 1; i++; return 1;}
  53. return 0;
  54. }
  55. #include <FL/Fl_Multi_Label.H>
  56. int main(int argc, char **argv) {
  57. int i = 1;
  58. if (Fl::args(argc,argv,i,arg) < argc)
  59. Fl::fatal(" -8 # : use default visual\n%s\n",Fl::help);
  60. Fl_Double_Window window(400,400); ::w = &window;
  61. Fl_Button b(140,160,120,120,"Pixmap"); ::b = &b;
  62. Fl_Pixmap *pixmap = new Fl_Pixmap(porsche_xpm);
  63. Fl_Pixmap *depixmap;
  64. depixmap = (Fl_Pixmap *)pixmap->copy();
  65. depixmap->inactive();
  66. b.image(pixmap);
  67. b.deimage(depixmap);
  68. leftb = new Fl_Toggle_Button(25,50,50,25,"left");
  69. leftb->callback(button_cb);
  70. rightb = new Fl_Toggle_Button(75,50,50,25,"right");
  71. rightb->callback(button_cb);
  72. topb = new Fl_Toggle_Button(125,50,50,25,"top");
  73. topb->callback(button_cb);
  74. bottomb = new Fl_Toggle_Button(175,50,50,25,"bottom");
  75. bottomb->callback(button_cb);
  76. insideb = new Fl_Toggle_Button(225,50,50,25,"inside");
  77. insideb->callback(button_cb);
  78. overb = new Fl_Toggle_Button(25,75,100,25,"text over");
  79. overb->callback(button_cb);
  80. inactb = new Fl_Toggle_Button(125,75,100,25,"inactive");
  81. inactb->callback(button_cb);
  82. if (!dvisual) Fl::visual(FL_RGB);
  83. window.resizable(window);
  84. window.end();
  85. window.show(argc,argv);
  86. return Fl::run();
  87. }
  88. //
  89. // End of "$Id: pixmap.cxx 7903 2010-11-28 21:06:39Z matt $".
  90. //