|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: Fl_Menu_Window.cxx 8198 2011-01-06 10:24:58Z manolo $" 00003 // 00004 // Menu window code for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 // This is the window type used by Fl_Menu to make the pop-ups. 00029 // It draws in the overlay planes if possible. 00030 00031 // Also here is the implementation of the mouse & keyboard grab, 00032 // which are used so that clicks outside the program's windows 00033 // can be used to dismiss the menus. 00034 00035 #include <config.h> 00036 #include <FL/Fl.H> 00037 #include <FL/x.H> 00038 #include <FL/fl_draw.H> 00039 #include <FL/Fl_Menu_Window.H> 00040 00041 // WIN32 note: HAVE_OVERLAY is false 00042 #if HAVE_OVERLAY 00043 extern XVisualInfo *fl_find_overlay_visual(); 00044 extern XVisualInfo *fl_overlay_visual; 00045 extern Colormap fl_overlay_colormap; 00046 extern unsigned long fl_transparent_pixel; 00047 static GC gc; // the GC used by all X windows 00048 extern uchar fl_overlay; // changes how fl_color(x) works 00049 #endif 00050 00051 #include <stdio.h> 00052 00053 void Fl_Menu_Window::show() { 00054 #if HAVE_OVERLAY 00055 if (!shown() && overlay() && fl_find_overlay_visual()) { 00056 XInstallColormap(fl_display, fl_overlay_colormap); 00057 fl_background_pixel = int(fl_transparent_pixel); 00058 Fl_X::make_xid(this, fl_overlay_visual, fl_overlay_colormap); 00059 fl_background_pixel = -1; 00060 } else 00061 #endif 00062 Fl_Single_Window::show(); 00063 } 00064 00065 void Fl_Menu_Window::flush() { 00066 #if HAVE_OVERLAY 00067 if (!fl_overlay_visual || !overlay()) {Fl_Single_Window::flush(); return;} 00068 Fl_X *myi = Fl_X::i(this); 00069 fl_window = myi->xid; 00070 if (!gc) { 00071 gc = XCreateGC(fl_display, myi->xid, 0, 0); 00072 # if defined(FLTK_USE_CAIRO) 00073 if(Fl::autolink_context()) Fl::cairo_make_current(gc); // capture gc changes automatically to update the cairo context adequately 00074 # endif 00075 } 00076 fl_gc = gc; 00077 fl_overlay = 1; 00078 fl_clip_region(myi->region); myi->region = 0; current_ = this; 00079 draw(); 00080 fl_overlay = 0; 00081 #else 00082 Fl_Single_Window::flush(); 00083 #endif 00084 } 00085 00087 void Fl_Menu_Window::erase() { 00088 #if HAVE_OVERLAY 00089 if (!gc || !shown()) return; 00090 //XSetForeground(fl_display, gc, 0); 00091 //XFillRectangle(fl_display, fl_xid(this), gc, 0, 0, w(), h()); 00092 XClearWindow(fl_display, fl_xid(this)); 00093 #endif 00094 } 00095 00096 // Fix the colormap flashing on Maximum Impact Graphics by erasing the 00097 // menu before unmapping it: 00098 void Fl_Menu_Window::hide() { 00099 erase(); 00100 Fl_Single_Window::hide(); 00101 } 00102 00104 Fl_Menu_Window::~Fl_Menu_Window() { 00105 hide(); 00106 } 00107 00108 // 00109 // End of "$Id: Fl_Menu_Window.cxx 8198 2011-01-06 10:24:58Z manolo $". 00110 //