From d4768073fa67e7f78872bc80f4dff1dd8aa32f69 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 10 Mar 2016 17:19:34 +0000 Subject: Implement non-rectangular windows using the Window Driver mechanism. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11336 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Double_Window.H | 1 + FL/Fl_Window.H | 47 ++++++++--------------------------------------- FL/Fl_Window_Driver.H | 9 ++++++++- FL/fl_draw.H | 3 +-- 4 files changed, 18 insertions(+), 42 deletions(-) (limited to 'FL') diff --git a/FL/Fl_Double_Window.H b/FL/Fl_Double_Window.H index 4ffcb65d1..fc7d1a93d 100644 --- a/FL/Fl_Double_Window.H +++ b/FL/Fl_Double_Window.H @@ -41,6 +41,7 @@ class Fl_Overlay_Window; class FL_EXPORT Fl_Double_Window : public Fl_Window { protected: void flush(int eraseoverlay); + Fl_Double_Window(int X, int Y, int W, int H, const char *l, Fl_Window_Driver *driver); public: /** Return non-null if this is an Fl_Overlay_Window object. diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H index ce9582475..8884d0b67 100644 --- a/FL/Fl_Window.H +++ b/FL/Fl_Window.H @@ -101,42 +101,6 @@ class FL_EXPORT Fl_Window : public Fl_Group { // cursor stuff Fl_Cursor cursor_default; -protected: - /** Data supporting a non-rectangular window shape */ - struct shape_data_type { - int lw_; ///< width of shape image - int lh_; ///< height of shape image - Fl_Image* shape_; ///< shape image -#if defined(__APPLE__) // PORTME: Fl_Window_Driver - per-window shape information, move to Fl_X/Fl_Window_Driver - typedef struct CGImage* CGImageRef; - CGImageRef mask; -#elif defined(WIN32) - // not needed -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: define storage for a window mask here if needed" -#else // X11 - // not needed -#endif - Fl_Bitmap *todelete_; ///< auxiliary bitmap image - }; - - shape_data_type *shape_data_; ///< non-null means the window has a non-rectangular shape -private: - void shape_bitmap_(Fl_Image* b); - void shape_alpha_(Fl_Image* img, int offset); - void shape_pixmap_(Fl_Image* pixmap); -public: - void shape(const Fl_Image* img); - /** Set the window's shape with an Fl_Image. - \see void shape(const Fl_Image* img) - */ - inline void shape(const Fl_Image& b) { shape(&b); } -#if defined(WIN32) || defined(__APPLE__) || defined(FL_DOXYGEN) // PORTME: Fl_Window_Driver - per-window shape -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: do you need a combine_mask() function in Fl_Window?" -#else // X11 - void combine_mask(void); -#endif private: void size_range_(); @@ -152,7 +116,7 @@ protected: /** Stores the last window that was made current. See current() const */ static Fl_Window *current_; - virtual void draw(); + void draw(); /** Forces the window to be drawn, this window is also made current and calls draw(). */ virtual void flush(); @@ -180,6 +144,7 @@ protected: void free_icons(); + Fl_Window(int x, int y, int w, int h, const char* title, Fl_Window_Driver *driver); public: /** @@ -640,9 +605,13 @@ public: Fl_Window_Driver *driver() { return pWindowDriver; } /** - Return non-null if this is an Fl_Overlay_Window object. + Return non-null if this is an Fl_Double_Window object. */ - virtual Fl_Double_Window *as_double_window() {return NULL; } + virtual Fl_Double_Window *as_double_window() {return NULL;} + void shape(const Fl_Image* img); + void shape(const Fl_Image& b) ; + int is_shaped(); + }; #endif diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H index e252d22bf..98934a3d4 100644 --- a/FL/Fl_Window_Driver.H +++ b/FL/Fl_Window_Driver.H @@ -28,14 +28,18 @@ class Fl_Window; +class Fl_Image; /** \brief A base class for platform specific window handling code. */ class FL_EXPORT Fl_Window_Driver { + friend class Fl_Window; protected: Fl_Window *pWindow; + struct shape_data_type; + shape_data_type *shape_data_; ///< non-null means the window has a non-rectangular shape public: Fl_Window_Driver(Fl_Window *); virtual ~Fl_Window_Driver(); @@ -47,7 +51,10 @@ public: virtual void take_focus() { } virtual int double_flush(int eraseoverlay); virtual void destroy_double_buffer(); - void draw(); + virtual void draw(); + void shape_pixmap_(Fl_Image* pixmap); + virtual void shape(const Fl_Image* img) {} + virtual void shape_alpha_(Fl_Image* img, int offset) {} }; diff --git a/FL/fl_draw.H b/FL/fl_draw.H index ecd6c1410..605f17d51 100644 --- a/FL/fl_draw.H +++ b/FL/fl_draw.H @@ -755,8 +755,7 @@ inline void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int \returns 1 if true alpha blending supported by platform \returns 0 not supported so FLTK will use screen door transparency */ -/* note: doxygen comment here to avoid triplication in os-speciic files */ -FL_EXPORT char fl_can_do_alpha_blending(); +inline char fl_can_do_alpha_blending() {return Fl_Display_Device::display_device()->driver()->can_do_alpha_blending();} /** Reads an RGB(A) image from the current window or off-screen buffer. -- cgit v1.2.3