@@ -31,7 +31,7 @@ | |||
#ifndef Fl_Menu_Window_H | |||
#define Fl_Menu_Window_H | |||
#include "Fl_Single_Window.H" | |||
#include "Fl_Double_Window.H" | |||
/** | |||
The Fl_Menu_Window widget is a window type used for menus. By | |||
@@ -39,26 +39,19 @@ | |||
available so that the menu don't force the rest of the window to | |||
redraw. | |||
*/ | |||
class FL_EXPORT Fl_Menu_Window : public Fl_Single_Window { | |||
class FL_EXPORT Fl_Menu_Window : public Fl_Double_Window { | |||
public: | |||
void show(); | |||
void erase(); | |||
void flush(); | |||
void hide(); | |||
/** Tells if hardware overlay mode is set */ | |||
unsigned int overlay() {return !(flags()&NO_OVERLAY);} | |||
/** Tells FLTK to use hardware overlay planes if they are available. */ | |||
void set_overlay() {clear_flag(NO_OVERLAY);} | |||
/** Tells FLTK to use normal drawing planes instead of overlay planes. | |||
This is usually necessary if your menu contains multi-color pixmaps. */ | |||
void clear_overlay() {set_flag(NO_OVERLAY);} | |||
~Fl_Menu_Window(); | |||
/** Creates a new Fl_Menu_Window widget using the given size, and label string. */ | |||
Fl_Menu_Window(int W, int H, const char *l = 0) | |||
: Fl_Single_Window(W,H,l) { image(0); } | |||
: Fl_Double_Window(W,H,l) { image(0); } | |||
/** Creates a new Fl_Menu_Window widget using the given position, size, and label string. */ | |||
Fl_Menu_Window(int X, int Y, int W, int H, const char *l = 0) | |||
: Fl_Single_Window(X,Y,W,H,l) { image(0); } | |||
: Fl_Double_Window(X,Y,W,H,l) { image(0); } | |||
}; | |||
#endif | |||
@@ -277,7 +277,6 @@ menutitle::menutitle(int X, int Y, int W, int H, const Fl_Menu_Item* L) : | |||
clear_border(); | |||
set_menu_window(); | |||
menu = L; | |||
if (L->labelcolor_ || Fl::scheme() || L->labeltype_ > FL_NO_LABEL) clear_overlay(); | |||
} | |||
menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, | |||
@@ -356,7 +355,6 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, | |||
} | |||
} | |||
} | |||
if (m->labelcolor_ || Fl::scheme() || m->labeltype_ > FL_NO_LABEL) clear_overlay(); | |||
} | |||
shortcutWidth = hotKeysw; | |||
if (selected >= 0 && !Wp) X -= W/2; | |||
@@ -38,66 +38,21 @@ | |||
#include <FL/fl_draw.H> | |||
#include <FL/Fl_Menu_Window.H> | |||
// WIN32 note: HAVE_OVERLAY is false | |||
#if HAVE_OVERLAY | |||
extern XVisualInfo *fl_find_overlay_visual(); | |||
extern XVisualInfo *fl_overlay_visual; | |||
extern Colormap fl_overlay_colormap; | |||
extern unsigned long fl_transparent_pixel; | |||
static GC gc; // the GC used by all X windows | |||
extern uchar fl_overlay; // changes how fl_color(x) works | |||
#endif | |||
#include <stdio.h> | |||
void Fl_Menu_Window::show() { | |||
#if HAVE_OVERLAY | |||
if (!shown() && overlay() && fl_find_overlay_visual()) { | |||
XInstallColormap(fl_display, fl_overlay_colormap); | |||
fl_background_pixel = int(fl_transparent_pixel); | |||
Fl_X::make_xid(this, fl_overlay_visual, fl_overlay_colormap); | |||
fl_background_pixel = -1; | |||
} else | |||
#endif | |||
Fl_Single_Window::show(); | |||
Fl_Double_Window::show(); | |||
} | |||
void Fl_Menu_Window::flush() { | |||
#if HAVE_OVERLAY | |||
if (!fl_overlay_visual || !overlay()) {Fl_Single_Window::flush(); return;} | |||
Fl_X *myi = Fl_X::i(this); | |||
fl_window = myi->xid; | |||
if (!gc) { | |||
gc = XCreateGC(fl_display, myi->xid, 0, 0); | |||
} | |||
fl_gc = gc; | |||
fl_overlay = 1; | |||
fl_clip_region(myi->region); myi->region = 0; x current_ = this; | |||
draw(); | |||
fl_overlay = 0; | |||
#else | |||
// Fl::make_current(this); | |||
Fl_Single_Window::flush(); | |||
#endif | |||
} | |||
/** Erases the window, does nothing if HAVE_OVERLAY is not defined config.h */ | |||
void Fl_Menu_Window::erase() { | |||
#if HAVE_OVERLAY | |||
if (!gc || !shown()) return; | |||
/* XSetForeground(fl_display, gc, 0); */ | |||
/* XFillRectangle(fl_display, fl_xid(this), gc, 0, 0, w(), h()); */ | |||
XClearWindow(fl_display, fl_xid(this)); | |||
#endif | |||
Fl_Double_Window::flush(); | |||
} | |||
// Fix the colormap flashing on Maximum Impact Graphics by erasing the | |||
// menu before unmapping it: | |||
void Fl_Menu_Window::hide() { | |||
erase(); | |||
Fl_Single_Window::hide(); | |||
// erase(); | |||
Fl_Double_Window::hide(); | |||
} | |||
/** Destroys the window and all of its children.*/ | |||
@@ -80,8 +80,6 @@ Fl_Overlay_Window::~Fl_Overlay_Window() { | |||
// delete overlay; this is done by ~Fl_Group | |||
} | |||
#if !HAVE_OVERLAY | |||
int Fl_Overlay_Window::can_do_overlay() {return 0;} | |||
/** | |||
@@ -96,78 +94,6 @@ void Fl_Overlay_Window::redraw_overlay() { | |||
Fl::damage(FL_DAMAGE_CHILD); | |||
} | |||
#else | |||
extern XVisualInfo *fl_find_overlay_visual(); | |||
extern XVisualInfo *fl_overlay_visual; | |||
extern Colormap fl_overlay_colormap; | |||
extern unsigned long fl_transparent_pixel; | |||
static GC gc; // the GC used by all X windows | |||
extern uchar fl_overlay; // changes how fl_color(x) works | |||
class _Fl_Overlay : public Fl_Window { | |||
friend class Fl_Overlay_Window; | |||
void flush(); | |||
void show(); | |||
public: | |||
_Fl_Overlay(int x, int y, int w, int h) : | |||
Fl_Window(x,y,w,h) {set_flag(INACTIVE);} | |||
}; | |||
int Fl_Overlay_Window::can_do_overlay() { | |||
return fl_find_overlay_visual() != 0; | |||
} | |||
void _Fl_Overlay::show() { | |||
if (shown()) {Fl_Window::show(); return;} | |||
fl_background_pixel = int(fl_transparent_pixel); | |||
Fl_X::make_xid(this, fl_overlay_visual, fl_overlay_colormap); | |||
fl_background_pixel = -1; | |||
// find the outermost window to tell wm about the colormap: | |||
Fl_Window *w = window(); | |||
for (;;) {Fl_Window *w1 = w->window(); if (!w1) break; w = w1;} | |||
XSetWMColormapWindows(fl_display, fl_xid(w), &(Fl_X::i(this)->xid), 1); | |||
} | |||
void _Fl_Overlay::flush() { | |||
fl_window = fl_xid(this); | |||
if (!gc) { | |||
gc = XCreateGC(fl_display, fl_xid(this), 0, 0); | |||
} | |||
fl_gc = gc; | |||
make_current(); | |||
fl_overlay = 1; | |||
Fl_Overlay_Window *w = (Fl_Overlay_Window *)parent(); | |||
Fl_X *myi = Fl_X::i(this); | |||
if (damage() != FL_DAMAGE_EXPOSE) XClearWindow(fl_display, fl_xid(this)); | |||
fl_clip_region(myi->region); myi->region = 0; | |||
w->draw_overlay(); | |||
fl_overlay = 0; | |||
} | |||
void Fl_Overlay_Window::redraw_overlay() { | |||
if (!fl_display) return; // this prevents fluid -c from opening display | |||
if (!overlay_) { | |||
if (can_do_overlay()) { | |||
Fl_Group::current(this); | |||
overlay_ = new _Fl_Overlay(0,0,w(),h()); | |||
Fl_Group::current(0); | |||
} else { | |||
overlay_ = this; // fake the overlay | |||
} | |||
} | |||
if (shown()) { | |||
if (overlay_ == this) { | |||
clear_damage(damage()|FL_DAMAGE_OVERLAY); | |||
Fl::damage(FL_DAMAGE_CHILD); | |||
} else if (!overlay_->shown()) | |||
overlay_->show(); | |||
else | |||
overlay_->redraw(); | |||
} | |||
} | |||
#endif | |||
// | |||
// End of "$Id: Fl_Overlay_Window.cxx 8198 2011-01-06 10:24:58Z manolo $". | |||
@@ -151,7 +151,6 @@ CPPFILES = \ | |||
fl_open_uri.cxx \ | |||
fl_oval_box.cxx \ | |||
fl_overlay.cxx \ | |||
fl_overlay_visual.cxx \ | |||
fl_plastic.cxx \ | |||
fl_read_image.cxx \ | |||
fl_rect.cxx \ | |||
@@ -533,7 +532,6 @@ Fl_Image.o: ../FL/mac.H ../FL/win32.H | |||
fl_line_style.o: ../FL/mac.H ../FL/win32.H | |||
Fl_Menu_Window.o: ../FL/mac.H ../FL/win32.H | |||
fl_overlay.o: ../FL/mac.H ../FL/win32.H | |||
fl_overlay_visual.o: ../FL/mac.H ../FL/win32.H | |||
Fl_Overlay_Window.o: ../FL/mac.H ../FL/win32.H | |||
Fl_own_colormap.o: ../FL/mac.H ../FL/win32.H | |||
Fl_Pixmap.o: ../FL/mac.H ../FL/win32.H | |||
@@ -109,20 +109,8 @@ static unsigned fl_cmap[256] = { | |||
#include "fl_cmap.h" // this is a file produced by "cmap.cxx": | |||
}; | |||
# if HAVE_OVERLAY | |||
/** HAVE_OVERLAY determines whether fl_xmap is one or two planes */ | |||
Fl_XColor fl_xmap[2][256]; | |||
/** HAVE_OVERLAY determines whether fl_overlay is variable or defined as 0 */ | |||
uchar fl_overlay; | |||
Colormap fl_overlay_colormap; | |||
XVisualInfo* fl_overlay_visual; | |||
ulong fl_transparent_pixel; | |||
# else | |||
/** HAVE_OVERLAY determines whether fl_xmap is one or two planes */ | |||
Fl_XColor fl_xmap[1][256]; | |||
/** HAVE_OVERLAY determines whether fl_overlay is variable or defined as 0 */ | |||
# define fl_overlay 0 | |||
# endif | |||
void Fl_Xlib_Graphics_Driver::color(Fl_Color i) { | |||
if (i & 0xffffff00) { | |||
@@ -224,9 +212,6 @@ ulong fl_xpixel(Fl_Color i) { | |||
# if USE_COLORMAP | |||
Colormap colormap = fl_colormap; | |||
# if HAVE_OVERLAY | |||
if (fl_overlay) colormap = fl_overlay_colormap; else | |||
# endif | |||
if (fl_redmask) { | |||
# endif | |||
// return color for a truecolor visual: | |||
@@ -241,15 +226,8 @@ ulong fl_xpixel(Fl_Color i) { | |||
) >> fl_extrashift; | |||
# if USE_COLORMAP | |||
} | |||
# if HAVE_OVERLAY | |||
static XColor* ac[2]; | |||
XColor*& allcolors = ac[fl_overlay]; | |||
static int nc[2]; | |||
int& numcolors = nc[fl_overlay]; | |||
# else | |||
static XColor *allcolors; | |||
static int numcolors; | |||
# endif | |||
// I don't try to allocate colors with XAllocColor once it fails | |||
// with any color. It is possible that it will work, since a color | |||
@@ -269,9 +247,6 @@ ulong fl_xpixel(Fl_Color i) { | |||
// I only read the colormap once. Again this is due to the slowness | |||
// of round-trips to the X server, even though other programs may alter | |||
// the colormap after this and make decisions here wrong. | |||
# if HAVE_OVERLAY | |||
if (fl_overlay) numcolors = fl_overlay_visual->colormap_size; else | |||
# endif | |||
numcolors = fl_visual->colormap_size; | |||
if (!allcolors) allcolors = new XColor[numcolors]; | |||
for (int p = numcolors; p--;) allcolors[p].pixel = p; | |||
@@ -282,9 +257,6 @@ ulong fl_xpixel(Fl_Color i) { | |||
int mindist = 0x7FFFFFFF; | |||
unsigned int bestmatch = 0; | |||
for (unsigned int n = numcolors; n--;) { | |||
# if HAVE_OVERLAY | |||
if (fl_overlay && n == fl_transparent_pixel) continue; | |||
# endif | |||
XColor &a = allcolors[n]; | |||
int d, t; | |||
t = int(r)-int(a.red>>8); d = t*t; | |||
@@ -323,17 +295,10 @@ ulong fl_xpixel(Fl_Color i) { | |||
\param[in] overlay 0 for normal, 1 for overlay color | |||
*/ | |||
void Fl::free_color(Fl_Color i, int overlay) { | |||
# if HAVE_OVERLAY | |||
# else | |||
if (overlay) return; | |||
# endif | |||
if (fl_xmap[overlay][i].mapped) { | |||
# if USE_COLORMAP | |||
# if HAVE_OVERLAY | |||
Colormap colormap = overlay ? fl_overlay_colormap : fl_colormap; | |||
# else | |||
Colormap colormap = fl_colormap; | |||
# endif | |||
if (fl_xmap[overlay][i].mapped == 1) | |||
XFreeColors(fl_display, colormap, &(fl_xmap[overlay][i].pixel), 1, 0); | |||
# endif | |||
@@ -349,9 +314,6 @@ void Fl::free_color(Fl_Color i, int overlay) { | |||
void Fl::set_color(Fl_Color i, unsigned c) { | |||
if (fl_cmap[i] != c) { | |||
free_color(i,0); | |||
# if HAVE_OVERLAY | |||
free_color(i,1); | |||
# endif | |||
fl_cmap[i] = c; | |||
} | |||
} | |||
@@ -1,105 +0,0 @@ | |||
// | |||
// "$Id: fl_overlay_visual.cxx 7903 2010-11-28 21:06:39Z matt $" | |||
// | |||
// X overlay support for the Fast Light Tool Kit (FLTK). | |||
// | |||
// Copyright 1998-2010 by Bill Spitzak and others. | |||
// | |||
// This library is free software; you can redistribute it and/or | |||
// modify it under the terms of the GNU Library General Public | |||
// License as published by the Free Software Foundation; either | |||
// version 2 of the License, or (at your option) any later version. | |||
// | |||
// This library is distributed in the hope that it will be useful, | |||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
// Library General Public License for more details. | |||
// | |||
// You should have received a copy of the GNU Library General Public | |||
// License along with this library; if not, write to the Free Software | |||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |||
// USA. | |||
// | |||
// Please report all bugs and problems on the following page: | |||
// | |||
// http://www.fltk.org/str.php | |||
// | |||
// Return an overlay visual, if any. Also allocate a colormap and | |||
// record the depth for fl_color() to use. | |||
// Another disgusting X interface, based on code extracted and | |||
// purified with great difficulty from XLayerUtil.cxx: | |||
#include <config.h> | |||
#if HAVE_OVERLAY | |||
#include <FL/Fl.H> | |||
#include <FL/x.H> | |||
// SERVER_OVERLAY_VISUALS property element: | |||
struct OverlayInfo { | |||
long overlay_visual; | |||
long transparent_type; | |||
long value; | |||
long layer; | |||
}; | |||
extern Colormap fl_overlay_colormap; | |||
extern XVisualInfo* fl_overlay_visual; | |||
extern ulong fl_transparent_pixel; | |||
XVisualInfo *fl_find_overlay_visual() { | |||
static char beenhere; | |||
if (beenhere) return fl_overlay_visual; | |||
beenhere = 1; | |||
fl_open_display(); | |||
Atom overlayVisualsAtom = | |||
XInternAtom(fl_display,"SERVER_OVERLAY_VISUALS",1); | |||
if (!overlayVisualsAtom) return 0; | |||
OverlayInfo *overlayInfo; | |||
ulong sizeData, bytesLeft; | |||
Atom actualType; | |||
int actualFormat; | |||
if (XGetWindowProperty(fl_display, RootWindow(fl_display, fl_screen), | |||
overlayVisualsAtom, 0L, 10000L, False, | |||
overlayVisualsAtom, &actualType, &actualFormat, | |||
&sizeData, &bytesLeft, | |||
(unsigned char **) &overlayInfo)) return 0; | |||
if (actualType == overlayVisualsAtom && actualFormat == 32) { | |||
int n = int(sizeData/4); | |||
XVisualInfo* v = 0; | |||
// find the greatest depth that has a transparent pixel: | |||
for (int i = 0; i < n; i++) { | |||
if (overlayInfo[i].transparent_type != 1) continue; | |||
if (overlayInfo[i].layer <= 0) continue; | |||
XVisualInfo templt; | |||
templt.visualid = overlayInfo[i].overlay_visual; | |||
int num; | |||
XVisualInfo *v1=XGetVisualInfo(fl_display, VisualIDMask, &templt, &num); | |||
if (v1->screen == fl_screen && v1->c_class == PseudoColor | |||
&& (!v || v1->depth > v->depth && v1->depth <= 8)) { | |||
if (v) XFree((char*)v); | |||
v = v1; | |||
fl_transparent_pixel = overlayInfo[i].value; | |||
} else { | |||
XFree((char*)v1); | |||
} | |||
} | |||
if (v) { | |||
fl_overlay_visual = v; | |||
fl_overlay_colormap = | |||
XCreateColormap(fl_display, RootWindow(fl_display, fl_screen), | |||
v->visual, AllocNone); | |||
} | |||
} | |||
XFree((char*)overlayInfo); | |||
//printf("overlay visual %ld selected\n", fl_overlay_visual->visualid); | |||
return fl_overlay_visual; | |||
} | |||
#endif | |||
// | |||
// End of "$Id: fl_overlay_visual.cxx 7903 2010-11-28 21:06:39Z matt $". | |||
// |