On Mon, Feb 14, 2011 at 04:22:06AM -0800, Albrecht Schlosser wrote:
> On 14.02.2011 09:51, Kurt Van Dijck wrote:
>
> > I have an X11 bitmap+mask patch, but requires 1 extra member in Fl_Window.
> > would that be an option to post?
> > I believe I'm even not the first one doing so.
>
> Please post to the STR form on the web site, either to STR 2563,
> if you think that it's related, or to another STR with RFE status,
> so that we can evaluate the patch and that it doesn't get lost.
Yep, I just didn't find the time to clean the patch.
Below you'll find a slightly modified version of a patch I used for
some time.
It extends the Fl_Window class (did not find a decent way to prevent that)
with 1 member. I also added support to load a 'char **' array directly as xpm.
Such data is easily included a C++ program. Therefore, setting a fixed icon
gets real easy.
extern const char *xpm_icon[];
window->icon(xpm_icon);
Regards,
Kurt
Index: fltk-1.3.x-r8365/FL/Fl_Window.H
===================================================================
--- fltk-1.3.x-r8365.orig/FL/Fl_Window.H 2011-02-16 18:41:17.000000000
+0100
+++ fltk-1.3.x-r8365/FL/Fl_Window.H 2011-02-16 18:41:22.000000000 +0100
@@ -65,6 +65,7 @@
const char* iconlabel_;
char* xclass_;
const void* icon_;
+ const void* iconmask_;
// size_range stuff:
int minw, minh, maxw, maxh;
int dw, dh, aspect;
@@ -332,8 +333,10 @@
void xclass(const char* c);
/** Gets the current icon window target dependent data. */
const void* icon() const {return icon_;}
+ const void* iconmask() const {return iconmask_;}
/** Sets the current icon window target dependent data. */
- void icon(const void * ic) {icon_ = ic;}
+ void icon(const void * ic, const void *icm =0);
+ void icon(const char *xpm[]);
/**
Returns non-zero if show() has been called (but not hide()
Index: fltk-1.3.x-r8365/configure.in
===================================================================
--- fltk-1.3.x-r8365.orig/configure.in 2011-02-16 18:41:17.000000000 +0100
+++ fltk-1.3.x-r8365/configure.in 2011-02-16 18:41:22.000000000 +0100
@@ -790,6 +790,14 @@
dnl Restore original LIBS settings...
LIBS="$SAVELIBS"
+AC_ARG_ENABLE(xpm, [ --with-xpm use libxpm for X11 icons,
default=auto])
+AH_TEMPLATE(HAVE_LIBXPM, [define to 1 if you have libxpm present])
+if ! test x$with_xpm = xno ; then
+ AC_CHECK_HEADERS([X11/xpm.h])
+ AC_SEARCH_LIBS(XpmCreatePixmapFromData, Xpm, AC_DEFINE(HAVE_LIBXPM, 1))
+fi
+AC_SUBST(HAVE_LIBXPM)
+
dnl See if we need a .exe extension on executables...
AC_EXEEXT
Index: fltk-1.3.x-r8365/src/Fl_Window.cxx
===================================================================
--- fltk-1.3.x-r8365.orig/src/Fl_Window.cxx 2011-02-16 18:41:17.000000000
+0100
+++ fltk-1.3.x-r8365/src/Fl_Window.cxx 2011-02-16 18:46:48.000000000 +0100
@@ -55,6 +55,7 @@
i = 0;
xclass_ = 0;
icon_ = 0;
+ iconmask_ = 0;
iconlabel_ = 0;
resizable(0);
size_range_set = 0;
@@ -277,6 +278,30 @@
}
}
+/** set icon **/
+void Fl_Window::icon(const void *ic, const void *icm) {
+ icon_ = ic;
+ iconmask_ = icm;
+}
+
+#ifdef HAVE_X11_XPM_H
+#include <X11/xpm.h>
+#include <FL/x.H>
+#endif
+void Fl_Window::icon(const char *xpm[]) {
+#ifdef HAVE_LIBXPM
+ Pixmap pix, msk;
+ int ret;
+
+ fl_open_display();
+ ret = XpmCreatePixmapFromData(fl_display,
+ DefaultRootWindow(fl_display),
+ (char **)xpm, &pix, &msk, 0);
+ if (ret < 0)
+ pix = msk = 0;
+ icon((void *)pix, (void *)msk);
+#endif
+}
//
// End of "$Id: Fl_Window.cxx 8198 2011-01-06 10:24:58Z manolo $".
Index: fltk-1.3.x-r8365/src/Fl_x.cxx
===================================================================
--- fltk-1.3.x-r8365.orig/src/Fl_x.cxx 2011-02-16 18:41:17.000000000 +0100
+++ fltk-1.3.x-r8365/src/Fl_x.cxx 2011-02-16 18:43:22.000000000 +0100
@@ -1694,7 +1694,10 @@
}
if (win->icon()) {
hints->icon_pixmap = (Pixmap)win->icon();
+ hints->icon_mask = (Pixmap)win->iconmask();
hints->flags |= IconPixmapHint;
+ if (hints->icon_mask)
+ hints->flags |= IconMaskHint;
}
XSetWMHints(fl_display, xp->xid, hints);
XFree(hints);
Index: fltk-1.3.x-r8365/configh.in
===================================================================
--- fltk-1.3.x-r8365.orig/configh.in 2011-02-16 18:41:17.000000000 +0100
+++ fltk-1.3.x-r8365/configh.in 2011-02-16 18:44:10.000000000 +0100
@@ -276,6 +276,13 @@
#undef HAVE_PNG_SET_TRNS_TO_ALPHA
/*
+ * Do we have libxpm ?
+ */
+
+#undef HAVE_X11_XPM_H
+#undef HAVE_LIBXPM
+
+/*
* Do we have POSIX threading?
*/
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev