Post by Greg ErcolanoPost by AnonymousOne more question. My app also has to run under linux and I would also
like to get the same icon displayed on the linux version. Any suggestions
on how to do this ? Thanks in advance.
I don't know that one offhand.
I use the MSW icon in the resources of the executable. I wanted to
use an XPM on Linux.
For Linux, this is what I do. It is code fragments, and won't
compile.
#include <FL/Fl.h>
#include <FL/Fl_Pixmap.h>
#include <FL/x.h>
/*
* We need to do this stupid Bool trick because of somebody's
* stupid database headers. When pointed out to the vendor, their
* response was: "Well, X11 did it, too," or something like that.
*/
#undef Bool
#define Bool int
#include <xpm.h>
#undef Bool
/*
* This is the WM icon, in XPM format
*/
#ifdef __unix__
# include <inX_icon.xpm>
#endif
/*
* NOTE: this is global in our code, because it is used for several
* purposes, one of which is the WM icon (at least on UNIX).
*/
#ifdef __unix__
Pixmap Icon_ID;
#else
HICON Icon_ID;
#endif
/*
* This is a class that encapsulates the main window for a number
* of our programs. It is where the WM icon is set. We don't write
* for Macs yet, so it is either X11 or MSWindows.
*/
inXMain::inXMain(inXDB *&data_base, const char *title,
const char *program_class, const char *icon_label,
cnst char *icon_name, const bool is_inX_Services_program,
const int extra_width
)
: Fl_Window(520 + extra_width, 210, title),
Menu(0, 0, 520 + extra_width, 30),
Box(5, 35, 510 + extra_width, 140),
Status_Line(5, 180, 510 + extra_width, 25),
Height_10(0),
Trx(0),
Data_Base(data_base),
Children(0) {
xclass(program_class);
#ifdef __unix__
if (! Icon_ID) {
fl_open_display();
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
const_cast<char **>(inX_icon),
&Icon_ID, 0, 0
);
}
icon(reinterpret_cast<char *>(Icon_ID));
#else
if (! Icon_ID) {
Icon_ID = Get_icon_from_resource(icon_name);
}
if (Icon_ID) {
icon(reinterpret_cast<char *>(Icon_ID));
}
#endif
iconlabel(icon_label);
/*
* The rest of the constructor deals with our standard main
* window; not very interesting.
*/
}