diff options
| author | Manolo Gouy <Manolo> | 2016-03-22 17:47:44 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-22 17:47:44 +0000 |
| commit | 6ec8ebc4f83fa2c143bff54e66672226cdf7d85c (patch) | |
| tree | f91bde6630403fd3961ae4bdf9a2c554ea5c12d1 | |
| parent | 6302b3da00f8116e1bf62629c6d3ab0f719d1a33 (diff) | |
Rewrite Fl_Window::show() and Fl_Menu_Window::show() under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11400 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/Fl_Window_Driver.H | 2 | ||||
| -rw-r--r-- | src/Fl_Menu_Window.cxx | 11 | ||||
| -rw-r--r-- | src/Fl_Window.cxx | 13 | ||||
| -rw-r--r-- | src/Fl_Window_Driver.cxx | 8 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 21 | ||||
| -rw-r--r-- | src/Fl_win32.cxx | 15 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 38 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.cxx | 21 |
11 files changed, 74 insertions, 59 deletions
diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H index bc9e1d57c..c5b7bc3c7 100644 --- a/FL/Fl_Window_Driver.H +++ b/FL/Fl_Window_Driver.H @@ -77,6 +77,8 @@ public: virtual Fl_X *makeWindow() { /* FIXME: move Fl_X::make(Fl_Window*) here for OSX, MSWin, and X11 */ return 0; } virtual void wait_for_expose() {} // TODO: check virtual void destroy_double_buffer(); // TODO: check + virtual void show(); + virtual void show_menu(); // --- window shape stuff void shape_pixmap_(Fl_Image* pixmap); // TODO: check diff --git a/src/Fl_Menu_Window.cxx b/src/Fl_Menu_Window.cxx index 3a51b8657..36ddc4722 100644 --- a/src/Fl_Menu_Window.cxx +++ b/src/Fl_Menu_Window.cxx @@ -28,6 +28,7 @@ #include <FL/x.H> #include <FL/fl_draw.H> #include <FL/Fl_Menu_Window.H> +#include <FL/Fl_Window_Driver.H> // WIN32 note: HAVE_OVERLAY is false #if HAVE_OVERLAY @@ -41,15 +42,7 @@ extern uchar fl_overlay; // changes how fl_color(x) works #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(); + driver()->show_menu(); } void Fl_Menu_Window::flush() { diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index cbd0863ff..c6e3454ef 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -26,6 +26,7 @@ #include <FL/Fl_Window_Driver.H> #include <FL/Fl_RGB_Image.H> #include <FL/Fl_Window.H> +#include <FL/Fl_Tooltip.H> #include <stdlib.h> #include "flstring.h" @@ -493,6 +494,18 @@ void Fl_Window::label(const char *name, const char *mininame) { pWindowDriver->label(name, mininame); } +void Fl_Window::show() { + image(Fl::scheme_bg_); + if (Fl::scheme_bg_) { + labeltype(FL_NORMAL_LABEL); + align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); + } else { + labeltype(FL_NO_LABEL); + } + Fl_Tooltip::exit(this); + pWindowDriver->show(); +} + // // End of "$Id$". // diff --git a/src/Fl_Window_Driver.cxx b/src/Fl_Window_Driver.cxx index 2dac00f95..b48040b9b 100644 --- a/src/Fl_Window_Driver.cxx +++ b/src/Fl_Window_Driver.cxx @@ -41,10 +41,16 @@ int Fl_Window_Driver::maxh() {return pWindow->maxh;} unsigned char Fl_Window_Driver::size_range_set() {return pWindow->size_range_set;} void Fl_Window_Driver::flush_single() { pWindow->Fl_Window::flush(); } + void Fl_Window_Driver::draw() { pWindow->draw(); } + void Fl_Window_Driver::make_current() { } -void Fl_Window_Driver::label(const char *name, const char *mininame) {} +void Fl_Window_Driver::show() { } + +void Fl_Window_Driver::show_menu() { pWindow->Fl_Window::show(); } + +void Fl_Window_Driver::label(const char *name, const char *mininame) {} void Fl_Window_Driver::take_focus() { diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index b6bd51f6a..7982b4ccc 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3145,21 +3145,14 @@ void Fl_Cocoa_Window_Driver::label(const char *name, const char *mininame) { /* * make a window visible */ -void Fl_Window::show() { - image(Fl::scheme_bg_); - if (Fl::scheme_bg_) { - labeltype(FL_NORMAL_LABEL); - align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); - } else { - labeltype(FL_NO_LABEL); - } - Fl_Tooltip::exit(this); +void Fl_Cocoa_Window_Driver::show() { Fl_X *top = NULL; - if (parent()) top = top_window()->i; - if (!shown() && (!parent() || (top && ![top->xid isMiniaturized]))) { - Fl_X::make(this); + if (pWindow->parent()) top = Fl_X::i(pWindow->top_window()); + if (!pWindow->shown() && (!pWindow->parent() || (top && ![top->xid isMiniaturized]))) { + Fl_X::make(pWindow); } else { - if ( !parent() ) { + if ( !pWindow->parent() ) { + Fl_X *i = Fl_X::i(pWindow); if ([i->xid isMiniaturized]) { i->w->redraw(); [i->xid deminiaturize:nil]; @@ -3168,7 +3161,7 @@ void Fl_Window::show() { [i->xid makeKeyAndOrderFront:nil]; } } - else set_visible(); + else pWindow->set_visible(); } } diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 506c6706c..9334c90d5 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -2277,20 +2277,13 @@ int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) { // Fl_Widget *fl_boxcheat; //static inline int can_boxcheat(uchar b) {return (b==1 || (b&2) && b<=15);} -void Fl_Window::show() { - image(Fl::scheme_bg_); - if (Fl::scheme_bg_) { - labeltype(FL_NORMAL_LABEL); - align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); - } else { - labeltype(FL_NO_LABEL); - } - Fl_Tooltip::exit(this); - if (!shown()) { +void Fl_WinAPI_Window_Driver::show() { + if (!pWindow->shown()) { // if (can_boxcheat(box())) fl_background_pixel = fl_xpixel(color()); - Fl_X::make(this); + Fl_X::make(pWindow); } else { // Once again, we would lose the capture if we activated the window. + Fl_X *i = Fl_X::i(pWindow); if (IsIconic(i->xid)) OpenIcon(i->xid); if (!fl_capture) BringWindowToTop(i->xid); //ShowWindow(i->xid,fl_capture?SW_SHOWNOACTIVATE:SW_RESTORE); diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 2e3d49183..4ca3ad67d 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -2901,29 +2901,17 @@ void Fl_X11_Window_Driver::label(const char *name, const char *iname) { // Fl_Window *fl_boxcheat; static inline int can_boxcheat(uchar b) {return (b==1 || ((b&2) && b<=15));} -void Fl_Window::show() { - image(Fl::scheme_bg_); - if (Fl::scheme_bg_) { - labeltype(FL_NORMAL_LABEL); - align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); - } else { - labeltype(FL_NO_LABEL); - } - Fl_Tooltip::exit(this); - if (!shown()) { +void Fl_X11_Window_Driver::show() { + if (!pWindow->shown()) { fl_open_display(); // Don't set background pixel for double-buffered windows... - if (type() != FL_DOUBLE_WINDOW && can_boxcheat(box())) { - fl_background_pixel = int(fl_xpixel(color())); + if (pWindow->type() != FL_DOUBLE_WINDOW && can_boxcheat(pWindow->box())) { + fl_background_pixel = int(fl_xpixel(pWindow->color())); } - Fl_X::make_xid(this); + Fl_X::make_xid(pWindow); } else { - XMapRaised(fl_display, i->xid); + XMapRaised(fl_display, fl_xid(pWindow)); } -#ifdef USE_PRINT_BUTTON -void preparePrintFront(void); -preparePrintFront(); -#endif } @@ -2932,11 +2920,13 @@ FL_EXPORT Window fl_xid_(const Fl_Window *w) { return temp ? temp->xid : 0; } +//#define USE_PRINT_BUTTON 1 #ifdef USE_PRINT_BUTTON + // to test the Fl_Printer class creating a "Print front window" button in a separate window -// contains also preparePrintFront call above #include <FL/Fl_Printer.H> #include <FL/Fl_Button.H> + void printFront(Fl_Widget *o, void *data) { Fl_Printer printer; @@ -2987,11 +2977,7 @@ void copyFront(Fl_Widget *o, void *data) o->window()->show(); } -void preparePrintFront(void) -{ - static int first=1; - if(!first) return; - first=0; +static int prepare_print_button() { static Fl_Window w(0,0,140,60); static Fl_Button bp(0,0,w.w(),30, "Print front window"); bp.callback(printFront); @@ -2999,7 +2985,11 @@ void preparePrintFront(void) bc.callback(copyFront); w.end(); w.show(); + return 0; } + +static int unused = prepare_print_button(); + #endif // USE_PRINT_BUTTON #endif diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H index 057b5fcd2..4925f1c33 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H @@ -75,6 +75,7 @@ public: virtual void draw_end(); virtual void make_current(); virtual void label(const char *name, const char *mininame); + virtual void show(); virtual void shape(const Fl_Image* img); // that one is implemented in Fl_Cocoa.mm because it uses Objective-c diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H index 051a86300..70129e75b 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H @@ -79,6 +79,7 @@ public: virtual void flush_overlay(); virtual void draw_begin(); virtual void make_current(); + virtual void show(); virtual void label(const char *name,const char *iname); virtual void shape(const Fl_Image* img); diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H index b28a19ab9..06e38a39c 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.H +++ b/src/drivers/X11/Fl_X11_Window_Driver.H @@ -86,6 +86,8 @@ public: virtual void flush_overlay(); virtual void draw_begin(); virtual void make_current(); + virtual void show(); + virtual void show_menu(); virtual void label(const char *name, const char *mininame); virtual void destroy_double_buffer(); diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 1c64b24e9..0458c2b4f 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -22,6 +22,7 @@ #include <FL/Fl_Shared_Image.H> #include <FL/Fl_Overlay_Window.H> +#include <FL/Fl_Menu_Window.H> #include <FL/fl_draw.H> #include <FL/fl_ask.H> #include <FL/Fl.H> @@ -32,6 +33,13 @@ #define ShapeBounding 0 #define ShapeSet 0 +#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; +#endif + Window fl_window; @@ -440,6 +448,19 @@ void Fl_X11_Window_Driver::make_current() { } +void Fl_X11_Window_Driver::show_menu() +{ +#if HAVE_OVERLAY + if (!pWindow->shown() && ((Fl_Menu_Window*)pWindow)->overlay() && fl_find_overlay_visual()) { + XInstallColormap(fl_display, fl_overlay_colormap); + fl_background_pixel = int(fl_transparent_pixel); + Fl_X::make_xid(pWindow, fl_overlay_visual, fl_overlay_colormap); + fl_background_pixel = -1; + } else +#endif + pWindow->Fl_Window::show(); +} + // // End of "$Id$". // |
