diff options
| author | Manolo Gouy <Manolo> | 2016-03-10 22:26:40 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-10 22:26:40 +0000 |
| commit | 31fcd84ca990ded6b96f0e3a82adc3f38d0cdb2c (patch) | |
| tree | 13212ec1fa76ebbfb144b831df6edd669acf5d69 /src/drivers/X11 | |
| parent | 7098924b82110cf468d3cbdc4742bd9a2632296d (diff) | |
Rewrite all window icon-related Fl_Window API with the window driver approach.
It seems this allows not to #include <windows.h> in the public header files.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11342 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/X11')
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.H | 11 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.cxx | 40 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H index c7ea3d382..e4f8862bd 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.H +++ b/src/drivers/X11/Fl_X11_Window_Driver.H @@ -42,6 +42,13 @@ ? where do we handle the interface between OpenGL/DirectX and Cocoa/WIN32/Glx? */ +struct Fl_Window_Driver::icon_data { + const void *legacy_icon; + Fl_RGB_Image **icons; + int count; +}; + + struct Fl_Window_Driver::shape_data_type { int lw_; ///< width of shape image int lh_; ///< height of shape image @@ -62,6 +69,10 @@ public: virtual void take_focus(); virtual void shape(const Fl_Image* img); virtual void draw(); + virtual void icons(const Fl_RGB_Image *icons[], int count); + virtual const void *icon() const; + virtual void icon(const void * ic); + virtual void free_icons(); }; diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 833891ae4..d1f377793 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -56,6 +56,8 @@ Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w) Fl_X11_Window_Driver::Fl_X11_Window_Driver(Fl_Window *win) : Fl_Window_Driver(win) { + icon_ = new Fl_Window_Driver::icon_data; + memset(icon_, 0, sizeof(Fl_Window_Driver::icon_data)); } @@ -65,6 +67,7 @@ Fl_X11_Window_Driver::~Fl_X11_Window_Driver() delete shape_data_->todelete_; delete shape_data_; } + delete icon_; } void Fl_X11_Window_Driver::take_focus() @@ -235,6 +238,43 @@ void Fl_X11_Window_Driver::draw() { Fl_Window_Driver::draw(); } +void Fl_X11_Window_Driver::icons(const Fl_RGB_Image *icons[], int count) { + free_icons(); + + if (count > 0) { + icon_->icons = new Fl_RGB_Image*[count]; + icon_->count = count; + // FIXME: Fl_RGB_Image lacks const modifiers on methods + for (int i = 0;i < count;i++) + icon_->icons[i] = (Fl_RGB_Image*)((Fl_RGB_Image*)icons[i])->copy(); + } + + if (Fl_X::i(pWindow)) + Fl_X::i(pWindow)->set_icons(); +} + +const void *Fl_X11_Window_Driver::icon() const { + return icon_->legacy_icon; +} + +void Fl_X11_Window_Driver::icon(const void * ic) { + free_icons(); + icon_->legacy_icon = ic; +} + +void Fl_X11_Window_Driver::free_icons() { + int i; + icon_->legacy_icon = 0L; + if (icon_->icons) { + for (i = 0;i < icon_->count;i++) + delete icon_->icons[i]; + delete [] icon_->icons; + icon_->icons = 0L; + } + icon_->count = 0; +} + + // // End of "$Id$". // |
