home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / Fl_Menu_Window.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-03  |  2.9 KB  |  102 lines

  1. //
  2. // "$Id: Fl_Menu_Window.cxx,v 1.8 1999/02/03 08:43:33 bill Exp $"
  3. //
  4. // Menu window code for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 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 to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. // This is the window type used by Fl_Menu to make the pop-ups.
  27. // It draws in the overlay planes if possible.
  28.  
  29. // Also here is the implementation of the mouse & keyboard grab,
  30. // which are used so that clicks outside the program's windows
  31. // can be used to dismiss the menus.
  32.  
  33. #include <config.h>
  34. #include <FL/Fl.H>
  35. #include <FL/x.H>
  36. #include <FL/fl_draw.H>
  37. #include <FL/Fl_Menu_Window.H>
  38.  
  39. // WIN32 note: HAVE_OVERLAY is false
  40. #if HAVE_OVERLAY
  41. extern XVisualInfo *fl_find_overlay_visual();
  42. extern XVisualInfo *fl_overlay_visual;
  43. extern Colormap fl_overlay_colormap;
  44. extern unsigned long fl_transparent_pixel;
  45. static GC gc;    // the GC used by all X windows
  46. extern uchar fl_overlay; // changes how fl_color(x) works
  47. #endif
  48.  
  49. #include <stdio.h>
  50.  
  51. void Fl_Menu_Window::show() {
  52. #if HAVE_OVERLAY
  53.   if (!shown() && overlay() && fl_find_overlay_visual()) {
  54.     XInstallColormap(fl_display, fl_overlay_colormap);
  55.     fl_background_pixel = int(fl_transparent_pixel);
  56.     Fl_X::make_xid(this, fl_overlay_visual, fl_overlay_colormap);
  57.     fl_background_pixel = -1;
  58.   } else
  59. #endif
  60.     Fl_Single_Window::show();
  61. }
  62.  
  63. void Fl_Menu_Window::flush() {
  64. #if HAVE_OVERLAY
  65.   if (!fl_overlay_visual || !overlay()) {Fl_Single_Window::flush(); return;}
  66.   Fl_X *i = Fl_X::i(this);
  67.   fl_window = i->xid;
  68.   if (!gc) gc = XCreateGC(fl_display, i->xid, 0, 0);
  69.   fl_gc = gc;
  70.   fl_overlay = 1;
  71.   fl_clip_region(i->region); i->region = 0;
  72.   draw();
  73.   fl_overlay = 0;
  74. #else
  75.   Fl_Single_Window::flush();
  76. #endif
  77. }
  78.  
  79. void Fl_Menu_Window::erase() {
  80. #if HAVE_OVERLAY
  81.   if (!gc || !shown()) return;
  82. //XSetForeground(fl_display, gc, 0);
  83. //XFillRectangle(fl_display, fl_xid(this), gc, 0, 0, w(), h());
  84.   XClearWindow(fl_display, fl_xid(this));
  85. #endif
  86. }
  87.  
  88. // Fix the colormap flashing on Maximum Impact Graphics by erasing the
  89. // menu before unmapping it:
  90. void Fl_Menu_Window::hide() {
  91.   erase();
  92.   Fl_Single_Window::hide();
  93. }
  94.  
  95. Fl_Menu_Window::~Fl_Menu_Window() {
  96.   hide();
  97. }
  98.  
  99. //
  100. // End of "$Id: Fl_Menu_Window.cxx,v 1.8 1999/02/03 08:43:33 bill Exp $".
  101. //
  102.