summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Window.cxx44
-rw-r--r--src/Fl_win32.cxx31
-rw-r--r--src/Fl_x.cxx10
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H15
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx57
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.H11
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx40
7 files changed, 143 insertions, 65 deletions
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 0a2d083ad..7c2131341 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -44,8 +44,6 @@ void Fl_Window::_Fl_Window() {
}
i = 0;
xclass_ = 0;
- icon_ = new icon_data;
- memset(icon_, 0, sizeof(*icon_));
iconlabel_ = 0;
resizable(0);
size_range_set = 0;
@@ -91,7 +89,6 @@ Fl_Window::~Fl_Window() {
free(xclass_);
}
free_icons();
- delete icon_;
delete pWindowDriver;
}
@@ -342,61 +339,28 @@ void Fl_Window::icon(const Fl_RGB_Image *icon) {
\see Fl_Window::icon(const Fl_RGB_Image *)
*/
void Fl_Window::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 (i)
- i->set_icons();
+ pWindowDriver->icons(icons, count);
}
/** Gets the current icon window target dependent data.
\deprecated in 1.3.3
*/
const void *Fl_Window::icon() const {
- return icon_->legacy_icon;
+ return pWindowDriver->icon();
}
/** Sets the current icon window target dependent data.
\deprecated in 1.3.3
*/
void Fl_Window::icon(const void * ic) {
- free_icons();
- icon_->legacy_icon = ic;
+ pWindowDriver->icon(ic);
}
/** Deletes all icons previously attached to the window.
\see Fl_Window::icons(const Fl_RGB_Image *icons[], int count)
*/
void Fl_Window::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;
-
-#ifdef WIN32
- if (icon_->big_icon)
- DestroyIcon(icon_->big_icon);
- if (icon_->small_icon)
- DestroyIcon(icon_->small_icon);
-
- icon_->big_icon = NULL;
- icon_->small_icon = NULL;
-#endif
+ pWindowDriver->free_icons();
}
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 3de627208..1c2548782 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -25,6 +25,7 @@
#ifndef FL_DOXYGEN
#include <FL/Fl.H>
#include <FL/Fl_Window_Driver.H>
+#include <src/Drivers/WinAPI//Fl_WinAPI_Window_Driver.H>
#include <FL/fl_utf8.h>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
@@ -1764,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->icon_->count)
+ if (!w->icon() && !w->pWindowDriver->icon_->count)
w->icon((void *)LoadIcon(NULL, IDI_APPLICATION));
wcw.hIcon = wcw.hIconSm = (HICON)w->icon();
wcw.hCursor = LoadCursor(NULL, IDC_ARROW);
@@ -2175,24 +2176,24 @@ void Fl_X::set_icons() {
big_icon = NULL;
small_icon = NULL;
- if (w->icon_->count) {
+ if (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->icon_->icons,
- w->icon_->count);
+ (const Fl_RGB_Image **)w->pWindowDriver->icon_->icons,
+ w->pWindowDriver->icon_->count);
best_small = find_best_icon(GetSystemMetrics(SM_CXSMICON),
- (const Fl_RGB_Image **)w->icon_->icons,
- w->icon_->count);
+ (const Fl_RGB_Image **)w->pWindowDriver->icon_->icons,
+ 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->icon_->big_icon != NULL) || (w->icon_->small_icon != NULL)) {
- big_icon = w->icon_->big_icon;
- small_icon = w->icon_->small_icon;
+ 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;
} else {
big_icon = default_big_icon;
small_icon = default_small_icon;
@@ -2244,16 +2245,8 @@ void Fl_Window::default_icons(HICON big_icon, HICON small_icon) {
\see Fl_Window::icons(const Fl_RGB_Image *[], int)
*/
void Fl_Window::icons(HICON big_icon, HICON small_icon) {
- free_icons();
-
- if (big_icon != NULL)
- icon_->big_icon = CopyIcon(big_icon);
- if (small_icon != NULL)
- icon_->small_icon = CopyIcon(small_icon);
-
- if (i)
- i->set_icons();
-}
+ ((Fl_WinAPI_Window_Driver*)pWindowDriver)->icons(big_icon, small_icon);
+ }
////////////////////////////////////////////////////////////////
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index cd3a70f6c..82af113b7 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -2531,8 +2531,8 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
fl_show_iconic = 0;
showit = 0;
}
- if (win->icon_->legacy_icon) {
- hints->icon_pixmap = (Pixmap)win->icon_->legacy_icon;
+ if (win->pWindowDriver->icon_->legacy_icon) {
+ hints->icon_pixmap = (Pixmap)win->pWindowDriver->icon_->legacy_icon;
hints->flags |= IconPixmapHint;
}
XSetWMHints(fl_display, xp->xid, hints);
@@ -2728,8 +2728,8 @@ void Fl_X::set_icons() {
unsigned long *net_wm_icons;
size_t net_wm_icons_size;
- if (w->icon_->count) {
- icons_to_property((const Fl_RGB_Image **)w->icon_->icons, w->icon_->count,
+ if (w->pWindowDriver->icon_->count) {
+ icons_to_property((const Fl_RGB_Image **)w->pWindowDriver->icon_->icons, w->pWindowDriver->icon_->count,
&net_wm_icons, &net_wm_icons_size);
} else {
net_wm_icons = default_net_wm_icons;
@@ -2739,7 +2739,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->icon_->count) {
+ if (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 2517130bb..605a0547c 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
@@ -26,6 +26,7 @@
#define FL_WINAPI_WINDOW_DRIVER_H
#include <FL/Fl_Window_Driver.H>
+#include <windows.h>
/*
Move everything here that manages the native window interface.
@@ -42,6 +43,14 @@
? 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
int lh_; ///< height of shape image
@@ -59,10 +68,14 @@ public:
~Fl_WinAPI_Window_Driver();
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();
+ void icons(HICON big_icon, HICON small_icon);
};
-
#endif // FL_WINAPI_WINDOW_DRIVER_H
//
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index e61fa4799..796f60c36 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -30,6 +30,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));
}
Fl_WinAPI_Window_Driver::~Fl_WinAPI_Window_Driver()
@@ -190,6 +192,61 @@ void Fl_WinAPI_Window_Driver::draw() {
} Fl_Window_Driver::draw();
}
+void Fl_WinAPI_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_WinAPI_Window_Driver::icon() const {
+ return icon_->legacy_icon;
+}
+
+void Fl_WinAPI_Window_Driver::icon(const void * ic) {
+ free_icons();
+ icon_->legacy_icon = ic;
+}
+
+void Fl_WinAPI_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;
+ if (icon_->big_icon)
+ DestroyIcon(icon_->big_icon);
+ if (icon_->small_icon)
+ DestroyIcon(icon_->small_icon);
+ icon_->big_icon = NULL;
+ icon_->small_icon = NULL;
+}
+
+void Fl_WinAPI_Window_Driver::icons(HICON big_icon, HICON small_icon)
+{
+ free_icons();
+
+ if (big_icon != NULL)
+ icon_->big_icon = CopyIcon(big_icon);
+ if (small_icon != NULL)
+ icon_->small_icon = CopyIcon(small_icon);
+
+ if (Fl_X::i(pWindow))
+ Fl_X::i(pWindow)->set_icons();
+}
+
//
// End of "$Id$".
//
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$".
//