diff options
| author | Manolo Gouy <Manolo> | 2016-03-22 13:27:22 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-22 13:27:22 +0000 |
| commit | 6302b3da00f8116e1bf62629c6d3ab0f719d1a33 (patch) | |
| tree | da164eb125131ccefcbcbd1010e70db09a3ae132 /src | |
| parent | b8e6c430e8bb1b4cec2f309f2835d7b81240749a (diff) | |
Move all icon-support data to the platform-specific Fl_XXX_Window_Driver class
because these data are platform-specific.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11399 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_win32.cxx | 61 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 10 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H | 17 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx | 49 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.H | 10 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.cxx | 4 |
6 files changed, 72 insertions, 79 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 504c154dc..506c6706c 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1765,7 +1765,7 @@ Fl_X* Fl_X::make(Fl_Window* w) { wcw.lpfnWndProc = (WNDPROC)WndProc; wcw.cbClsExtra = wcw.cbWndExtra = 0; wcw.hInstance = fl_display; - if (!w->icon() && !w->pWindowDriver->icon_->count) + if (!w->icon() && !((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->count) w->icon((void *)LoadIcon(NULL, IDI_APPLICATION)); wcw.hIcon = wcw.hIconSm = (HICON)w->icon(); wcw.hCursor = LoadCursor(NULL, IDC_ARROW); @@ -2159,24 +2159,24 @@ void Fl_X::set_icons() { big_icon = NULL; small_icon = NULL; - if (w->pWindowDriver->icon_->count) { + if (((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->count) { const Fl_RGB_Image *best_big, *best_small; best_big = find_best_icon(GetSystemMetrics(SM_CXICON), - (const Fl_RGB_Image **)w->pWindowDriver->icon_->icons, - w->pWindowDriver->icon_->count); + (const Fl_RGB_Image **)((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->icons, + ((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->count); best_small = find_best_icon(GetSystemMetrics(SM_CXSMICON), - (const Fl_RGB_Image **)w->pWindowDriver->icon_->icons, - w->pWindowDriver->icon_->count); + (const Fl_RGB_Image **)((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->icons, + ((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->count); if (best_big != NULL) big_icon = image_to_icon(best_big, true, 0, 0); if (best_small != NULL) small_icon = image_to_icon(best_small, true, 0, 0); } else { - if ((w->pWindowDriver->icon_->big_icon != NULL) || (w->pWindowDriver->icon_->small_icon != NULL)) { - big_icon = w->pWindowDriver->icon_->big_icon; - small_icon = w->pWindowDriver->icon_->small_icon; + if ((((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->big_icon != NULL) || (((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->small_icon != NULL)) { + big_icon = ((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->big_icon; + small_icon = ((Fl_WinAPI_Window_Driver*)w->pWindowDriver)->icon_->small_icon; } else { big_icon = default_big_icon; small_icon = default_small_icon; @@ -2187,49 +2187,6 @@ void Fl_X::set_icons() { SendMessage(xid, WM_SETICON, ICON_SMALL, (LPARAM)small_icon); } -/** Sets the default window icons. - - Convenience function to set the default icons using Windows' - native HICON icon handles. - - The given icons are copied. You can free the icons immediately after - this call. - - \param[in] big_icon default large icon for all windows - subsequently created - \param[in] small_icon default small icon for all windows - subsequently created - - \see Fl_Window::default_icon(const Fl_RGB_Image *) - \see Fl_Window::default_icons(const Fl_RGB_Image *[], int) - \see Fl_Window::icon(const Fl_RGB_Image *) - \see Fl_Window::icons(const Fl_RGB_Image *[], int) - \see Fl_Window::icons(HICON, HICON) - */ -void Fl_Window::default_icons(HICON big_icon, HICON small_icon) { - Fl_X::set_default_icons(big_icon, small_icon); -} - -/** Sets the window icons. - - Convenience function to set this window's icons using Windows' - native HICON icon handles. - - The given icons are copied. You can free the icons immediately after - this call. - - \param[in] big_icon large icon for this window - \param[in] small_icon small icon for this windows - - \see Fl_Window::default_icon(const Fl_RGB_Image *) - \see Fl_Window::default_icons(const Fl_RGB_Image *[], int) - \see Fl_Window::default_icons(HICON, HICON) - \see Fl_Window::icon(const Fl_RGB_Image *) - \see Fl_Window::icons(const Fl_RGB_Image *[], int) - */ -void Fl_Window::icons(HICON big_icon, HICON small_icon) { - ((Fl_WinAPI_Window_Driver*)pWindowDriver)->icons(big_icon, small_icon); - } //////////////////////////////////////////////////////////////// diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index ec8361d1b..2e3d49183 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -2533,8 +2533,8 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap) fl_show_iconic = 0; showit = 0; } - if (win->pWindowDriver->icon_->legacy_icon) { - hints->icon_pixmap = (Pixmap)win->pWindowDriver->icon_->legacy_icon; + if (((Fl_X11_Window_Driver*)win->pWindowDriver)->icon_->legacy_icon) { + hints->icon_pixmap = (Pixmap)((Fl_X11_Window_Driver*)win->pWindowDriver)->icon_->legacy_icon; hints->flags |= IconPixmapHint; } XSetWMHints(fl_display, xp->xid, hints); @@ -2730,8 +2730,8 @@ void Fl_X::set_icons() { unsigned long *net_wm_icons; size_t net_wm_icons_size; - if (w->pWindowDriver->icon_->count) { - icons_to_property((const Fl_RGB_Image **)w->pWindowDriver->icon_->icons, w->pWindowDriver->icon_->count, + if (((Fl_X11_Window_Driver*)w->pWindowDriver)->icon_->count) { + icons_to_property((const Fl_RGB_Image **)((Fl_X11_Window_Driver*)w->pWindowDriver)->icon_->icons, ((Fl_X11_Window_Driver*)w->pWindowDriver)->icon_->count, &net_wm_icons, &net_wm_icons_size); } else { net_wm_icons = default_net_wm_icons; @@ -2741,7 +2741,7 @@ void Fl_X::set_icons() { XChangeProperty (fl_display, xid, fl_NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, (unsigned char*) net_wm_icons, net_wm_icons_size); - if (w->pWindowDriver->icon_->count) { + if (((Fl_X11_Window_Driver*)w->pWindowDriver)->icon_->count) { delete [] net_wm_icons; net_wm_icons = 0L; net_wm_icons_size = 0; diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H index d5abdd54e..051a86300 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H @@ -43,13 +43,6 @@ ? 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; - HICON big_icon; - HICON small_icon; -}; struct Fl_Window_Driver::shape_data_type { int lw_; ///< width of shape image @@ -60,6 +53,14 @@ struct Fl_Window_Driver::shape_data_type { class FL_EXPORT Fl_WinAPI_Window_Driver : public Fl_Window_Driver { + friend class Fl_Window; + struct icon_data { + const void *legacy_icon; + Fl_RGB_Image **icons; + int count; + HICON big_icon; + HICON small_icon; + }; private: RECT border_width_title_bar_height(int &bx, int &by, int &bt); void shape_bitmap_(Fl_Image* b); @@ -68,6 +69,7 @@ public: Fl_WinAPI_Window_Driver(Fl_Window*); ~Fl_WinAPI_Window_Driver(); + struct icon_data *icon_; // --- window data virtual int decorated_w(); virtual int decorated_h(); @@ -84,7 +86,6 @@ public: virtual const void *icon() const; virtual void icon(const void * ic); virtual void free_icons(); - void icons(HICON big_icon, HICON small_icon); // this one is implemented in Fl_win32.cxx virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right); virtual void wait_for_expose(); diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx index a0a4e57c0..976fbd606 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx @@ -43,8 +43,8 @@ Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w) Fl_WinAPI_Window_Driver::Fl_WinAPI_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)); + icon_ = new icon_data; + memset(icon_, 0, sizeof(icon_data)); } @@ -54,6 +54,7 @@ Fl_WinAPI_Window_Driver::~Fl_WinAPI_Window_Driver() delete shape_data_->todelete_; delete shape_data_; } + delete icon_; } @@ -358,19 +359,53 @@ void Fl_WinAPI_Window_Driver::free_icons() { icon_->small_icon = NULL; } -void Fl_WinAPI_Window_Driver::icons(HICON big_icon, HICON small_icon) + +/** Sets the window icons using Windows' native HICON icon handles. + + The given icons are copied. You can free the icons immediately after + this call. + + \param[in] big_icon large window icon + \param[in] small_icon small window icon + */ +void Fl_Window::icons(HICON big_icon, HICON small_icon) { free_icons(); if (big_icon != NULL) - icon_->big_icon = CopyIcon(big_icon); + ((Fl_WinAPI_Window_Driver*)pWindowDriver)->icon_->big_icon = CopyIcon(big_icon); if (small_icon != NULL) - icon_->small_icon = CopyIcon(small_icon); + ((Fl_WinAPI_Window_Driver*)pWindowDriver)->icon_->small_icon = CopyIcon(small_icon); - if (Fl_X::i(pWindow)) - Fl_X::i(pWindow)->set_icons(); + if (Fl_X::i(this)) + Fl_X::i(this)->set_icons(); } + +/** Sets the default window icons. + + Convenience function to set the default icons using Windows' + native HICON icon handles. + + The given icons are copied. You can free the icons immediately after + this call. + + \param[in] big_icon default large icon for all windows + subsequently created + \param[in] small_icon default small icon for all windows + subsequently created + + \see Fl_Window::default_icon(const Fl_RGB_Image *) + \see Fl_Window::default_icons(const Fl_RGB_Image *[], int) + \see Fl_Window::icon(const Fl_RGB_Image *) + \see Fl_Window::icons(const Fl_RGB_Image *[], int) + \see Fl_Window::icons(HICON, HICON) + */ +void Fl_Window::default_icons(HICON big_icon, HICON small_icon) { + Fl_X::set_default_icons(big_icon, small_icon); +} + + void Fl_WinAPI_Window_Driver::wait_for_expose() { if (!pWindow->shown()) return; Fl_X *i = Fl_X::i(pWindow); diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H index 8a51bbf2f..b28a19ab9 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.H +++ b/src/drivers/X11/Fl_X11_Window_Driver.H @@ -44,11 +44,6 @@ class Fl_Bitmap; ? 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 { @@ -63,6 +58,11 @@ class FL_EXPORT Fl_X11_Window_Driver : public Fl_Window_Driver friend class Fl_X; private: + struct icon_data { + const void *legacy_icon; + Fl_RGB_Image **icons; + int count; + } *icon_; void decorated_win_size(int &w, int &h); void combine_mask(); void shape_bitmap_(Fl_Image* b); diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 25cb50748..1c64b24e9 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -116,8 +116,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)); + icon_ = new icon_data; + memset(icon_, 0, sizeof(icon_data)); } |
