Don't use -lsupc++ with gcc 2.96; just tried it on RH 7.2 and that
library isn't present or needed. PNG image support updates for Fl_Help_View and Fl_File_Icon; didn't handle transparency properly. Support KDE 2.x icons. Separate image/load_system_icons code from main Fl_File_Icon sources, so that apps that don't use load_system_icons() won't need the image libraries... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1687 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
74bff0b300
commit
ab1e093308
8
CHANGES
8
CHANGES
@ -1,6 +1,10 @@
|
||||
CHANGES IN FLTK 1.1.0
|
||||
CHANGES IN FLTK 1.1.0b6
|
||||
|
||||
- Now use -lsupc++ for Red Hat's GCC 2.96.
|
||||
- Documentation updates...
|
||||
- Implemented the Fl_File_Icon::load_png() method.
|
||||
- The Fl_File_Icon::load_system_icons() method now
|
||||
supports KDE 2.x icons.
|
||||
- Fixed PNG support in Fl_Help_View.
|
||||
- Removed the "Microsoft" mode button from the menubar
|
||||
demo.
|
||||
- The browser demo now makes sure that the input field
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_File_Icon.H,v 1.1.2.2 2001/10/29 03:44:31 easysw Exp $"
|
||||
// "$Id: Fl_File_Icon.H,v 1.1.2.3 2001/11/17 15:27:14 easysw Exp $"
|
||||
//
|
||||
// Fl_File_Icon definitions.
|
||||
//
|
||||
@ -94,6 +94,7 @@ class Fl_File_Icon //// Icon data
|
||||
FL_EXPORT static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
|
||||
FL_EXPORT void load(const char *f);
|
||||
FL_EXPORT void load_fti(const char *fti);
|
||||
FL_EXPORT void load_png(const char *png);
|
||||
FL_EXPORT void load_xpm(const char *xpm);
|
||||
const char *pattern() { return (pattern_); }
|
||||
int size() { return (num_data_); }
|
||||
@ -108,5 +109,5 @@ class Fl_File_Icon //// Icon data
|
||||
#endif // !_Fl_Fl_File_Icon_H_
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_File_Icon.H,v 1.1.2.2 2001/10/29 03:44:31 easysw Exp $".
|
||||
// End of "$Id: Fl_File_Icon.H,v 1.1.2.3 2001/11/17 15:27:14 easysw Exp $".
|
||||
//
|
||||
|
11
configure.in
11
configure.in
@ -1,7 +1,7 @@
|
||||
dnl -*- sh -*-
|
||||
dnl the "configure" script is made from this by running GNU "autoconf"
|
||||
dnl
|
||||
dnl "$Id: configure.in,v 1.33.2.31.2.20 2001/11/02 20:40:29 easysw Exp $"
|
||||
dnl "$Id: configure.in,v 1.33.2.31.2.21 2001/11/17 15:27:14 easysw Exp $"
|
||||
dnl
|
||||
dnl Configuration script for the Fast Light Tool Kit (FLTK).
|
||||
dnl
|
||||
@ -347,15 +347,8 @@ if test -n "$GXX"; then
|
||||
#
|
||||
# Previous versions of GCC do not have the reliance on the stdc++
|
||||
# or g++ libraries, so the extra supc++ library is not needed.
|
||||
#
|
||||
# [Apparently this "feature" is also present in the unofficial
|
||||
# RedHat 2.96 release...]
|
||||
|
||||
case "`$CXX --version`" in
|
||||
2.96*)
|
||||
AC_MSG_WARN(GCC 2.96.x is not an official GCC release - use with caution!)
|
||||
LIBS="$LIBS -lsupc++"
|
||||
;;
|
||||
3*)
|
||||
AC_MSG_WARN(GCC 3.0.x is known to produce incorrect code - use with caution!)
|
||||
LIBS="$LIBS -lsupc++"
|
||||
@ -501,5 +494,5 @@ AC_OUTPUT(makeinclude fltk-config)
|
||||
chmod +x fltk-config
|
||||
|
||||
dnl
|
||||
dnl End of "$Id: configure.in,v 1.33.2.31.2.20 2001/11/02 20:40:29 easysw Exp $".
|
||||
dnl End of "$Id: configure.in,v 1.33.2.31.2.21 2001/11/17 15:27:14 easysw Exp $".
|
||||
dnl
|
||||
|
@ -33,8 +33,7 @@ double-buffering, overlay, menu, and OpenGL support. </P>
|
||||
<P>The window's callback is done if the user tries to close a window
|
||||
using the window manager and <A href=functions.html#modal><TT>
|
||||
Fl::modal()</TT></A> is zero or equal to the window. <TT>Fl_Window</TT>
|
||||
has a default callback that calls <TT>Fl_Window::hide()</TT> and calls <TT>
|
||||
exit(0)</TT> if this is the last top-level window. </P>
|
||||
has a default callback that calls <TT>Fl_Window::hide()</TT>. </P>
|
||||
<H3>Methods</H3>
|
||||
<CENTER>
|
||||
<TABLE width=90% summary="Fl_Window methods.">
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_File_Icon.cxx,v 1.1.2.4 2001/10/29 21:59:14 easysw Exp $"
|
||||
// "$Id: Fl_File_Icon.cxx,v 1.1.2.5 2001/11/17 15:27:15 easysw Exp $"
|
||||
//
|
||||
// Fl_File_Icon routines.
|
||||
//
|
||||
@ -33,10 +33,6 @@
|
||||
// Fl_File_Icon::draw() - Draw an icon.
|
||||
// Fl_File_Icon::label() - Set the widgets label to an icon.
|
||||
// Fl_File_Icon::labeltype() - Draw the icon label.
|
||||
// Fl_File_Icon::load() - Load an icon file...
|
||||
// Fl_File_Icon::load_fti() - Load an SGI-format FTI file...
|
||||
// Fl_File_Icon::load_xpm() - Load an XPM icon file...
|
||||
// Fl_File_Icon::load_system_icons() - Load the standard system icons/filetypes.
|
||||
//
|
||||
|
||||
//
|
||||
@ -49,7 +45,7 @@
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRINGS_H */
|
||||
#endif // HAVE_STRINGS_H
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
@ -89,16 +85,6 @@
|
||||
Fl_File_Icon *Fl_File_Icon::first_ = (Fl_File_Icon *)0;
|
||||
|
||||
|
||||
//
|
||||
// Local functions...
|
||||
//
|
||||
|
||||
static void load_kde_icons(const char *directory);
|
||||
static void load_kde_mimelnk(const char *filename);
|
||||
static char *kde_to_fltk_pattern(const char *kdepattern);
|
||||
static char *get_kde_val(char *str, const char *key);
|
||||
|
||||
|
||||
//
|
||||
// 'Fl_File_Icon::Fl_File_Icon()' - Create a new file icon.
|
||||
//
|
||||
@ -481,758 +467,5 @@ Fl_File_Icon::labeltype(const Fl_Label *o, // I - Label data
|
||||
|
||||
|
||||
//
|
||||
// 'Fl_File_Icon::load()' - Load an icon file...
|
||||
//
|
||||
|
||||
void
|
||||
Fl_File_Icon::load(const char *f) // I - File to read from
|
||||
{
|
||||
const char *ext; // File extension
|
||||
|
||||
|
||||
if ((ext = filename_ext(f)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load(): Unknown file type for \"%s\".\n", f);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ext, ".fti") == 0)
|
||||
load_fti(f);
|
||||
else if (strcmp(ext, ".xpm") == 0)
|
||||
load_xpm(f);
|
||||
// else if (strcmp(ext, ".png") == 0)
|
||||
// load_png(f);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load(): Unknown file type for \"%s\".\n", f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'Fl_File_Icon::load_fti()' - Load an SGI-format FTI file...
|
||||
//
|
||||
|
||||
void
|
||||
Fl_File_Icon::load_fti(const char *fti) // I - File to read from
|
||||
{
|
||||
FILE *fp; // File pointer
|
||||
int ch; // Current character
|
||||
char command[255], // Command string ("vertex", etc.)
|
||||
params[255], // Parameter string ("10.0,20.0", etc.)
|
||||
*ptr; // Pointer into strings
|
||||
int outline; // Outline polygon
|
||||
|
||||
|
||||
// Try to open the file...
|
||||
if ((fp = fopen(fti, "rb")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load_fti(): Unable to open \"%s\" - %s\n",
|
||||
fti, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the entire file, adding data as needed...
|
||||
outline = 0;
|
||||
|
||||
while ((ch = getc(fp)) != EOF)
|
||||
{
|
||||
// Skip whitespace
|
||||
if (isspace(ch))
|
||||
continue;
|
||||
|
||||
// Skip comments starting with "#"...
|
||||
if (ch == '#')
|
||||
{
|
||||
while ((ch = getc(fp)) != EOF)
|
||||
if (ch == '\n')
|
||||
break;
|
||||
|
||||
if (ch == EOF)
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
// OK, this character better be a letter...
|
||||
if (!isalpha(ch))
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load_fti(): Expected a letter at file position %ld (saw '%c')\n",
|
||||
ftell(fp) - 1, ch);
|
||||
break;
|
||||
}
|
||||
|
||||
// Scan the command name...
|
||||
ptr = command;
|
||||
*ptr++ = ch;
|
||||
|
||||
while ((ch = getc(fp)) != EOF)
|
||||
{
|
||||
if (ch == '(')
|
||||
break;
|
||||
else if (ptr < (command + sizeof(command) - 1))
|
||||
*ptr++ = ch;
|
||||
}
|
||||
|
||||
*ptr++ = '\0';
|
||||
|
||||
// Make sure we stopped on a parenthesis...
|
||||
if (ch != '(')
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load_fti(): Expected a ( at file position %ld (saw '%c')\n",
|
||||
ftell(fp) - 1, ch);
|
||||
break;
|
||||
}
|
||||
|
||||
// Scan the parameters...
|
||||
ptr = params;
|
||||
|
||||
while ((ch = getc(fp)) != EOF)
|
||||
{
|
||||
if (ch == ')')
|
||||
break;
|
||||
else if (ptr < (params + sizeof(params) - 1))
|
||||
*ptr++ = ch;
|
||||
}
|
||||
|
||||
*ptr++ = '\0';
|
||||
|
||||
// Make sure we stopped on a parenthesis...
|
||||
if (ch != ')')
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load_fti(): Expected a ) at file position %ld (saw '%c')\n",
|
||||
ftell(fp) - 1, ch);
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure the next character is a semicolon...
|
||||
if ((ch = getc(fp)) != ';')
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load_fti(): Expected a ; at file position %ld (saw '%c')\n",
|
||||
ftell(fp) - 1, ch);
|
||||
break;
|
||||
}
|
||||
|
||||
// Now process the command...
|
||||
if (strcmp(command, "color") == 0)
|
||||
{
|
||||
// Set the color; for negative colors blend the two primaries to
|
||||
// produce a composite color. Also, the following symbolic color
|
||||
// names are understood:
|
||||
//
|
||||
// name FLTK color
|
||||
// ------------- ----------
|
||||
// iconcolor FL_ICON_COLOR; mapped to the icon color in
|
||||
// Fl_File_Icon::draw()
|
||||
// shadowcolor FL_DARK3
|
||||
// outlinecolor FL_BLACK
|
||||
if (strcmp(params, "iconcolor") == 0)
|
||||
add_color(FL_ICON_COLOR);
|
||||
else if (strcmp(params, "shadowcolor") == 0)
|
||||
add_color(FL_DARK3);
|
||||
else if (strcmp(params, "outlinecolor") == 0)
|
||||
add_color(FL_BLACK);
|
||||
else
|
||||
{
|
||||
int c = atoi(params); // Color value
|
||||
|
||||
|
||||
if (c < 0)
|
||||
{
|
||||
// Composite color; compute average...
|
||||
c = -c;
|
||||
add_color(fl_color_average((Fl_Color)(c >> 4),
|
||||
(Fl_Color)(c & 15), 0.5));
|
||||
}
|
||||
else
|
||||
add_color((Fl_Color)c);
|
||||
}
|
||||
}
|
||||
else if (strcmp(command, "bgnline") == 0)
|
||||
add(LINE);
|
||||
else if (strcmp(command, "bgnclosedline") == 0)
|
||||
add(CLOSEDLINE);
|
||||
else if (strcmp(command, "bgnpolygon") == 0)
|
||||
add(POLYGON);
|
||||
else if (strcmp(command, "bgnoutlinepolygon") == 0)
|
||||
{
|
||||
add(OUTLINEPOLYGON);
|
||||
outline = add(0) - data_;
|
||||
add(0);
|
||||
}
|
||||
else if (strcmp(command, "endoutlinepolygon") == 0 && outline)
|
||||
{
|
||||
unsigned cval; // Color value
|
||||
|
||||
// Set the outline color; see above for valid values...
|
||||
if (strcmp(params, "iconcolor") == 0)
|
||||
cval = FL_ICON_COLOR;
|
||||
else if (strcmp(params, "shadowcolor") == 0)
|
||||
cval = FL_DARK3;
|
||||
else if (strcmp(params, "outlinecolor") == 0)
|
||||
cval = FL_BLACK;
|
||||
else
|
||||
{
|
||||
int c = atoi(params); // Color value
|
||||
|
||||
|
||||
if (c < 0)
|
||||
{
|
||||
// Composite color; compute average...
|
||||
c = -c;
|
||||
cval = fl_color_average((Fl_Color)(c >> 4), (Fl_Color)(c & 15), 0.5);
|
||||
}
|
||||
else
|
||||
cval = c;
|
||||
}
|
||||
|
||||
// Store outline color...
|
||||
data_[outline] = cval >> 16;
|
||||
data_[outline + 1] = cval;
|
||||
|
||||
outline = 0;
|
||||
add(END);
|
||||
}
|
||||
else if (strncmp(command, "end", 3) == 0)
|
||||
add(END);
|
||||
else if (strcmp(command, "vertex") == 0)
|
||||
{
|
||||
float x, y; // Coordinates of vertex
|
||||
|
||||
|
||||
if (sscanf(params, "%f,%f", &x, &y) != 2)
|
||||
break;
|
||||
|
||||
add_vertex((short)(x * 100.0 + 0.5), (short)(y * 100.0 + 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Fl_File_Icon::load_fti(): Unknown command \"%s\" at file position %ld.\n",
|
||||
command, ftell(fp) - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Close the file and return...
|
||||
fclose(fp);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Icon File \"%s\":\n", fti);
|
||||
for (int i = 0; i < num_data_; i ++)
|
||||
printf(" %d,\n", data_[i]);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'Fl_File_Icon::load_xpm()' - Load an XPM icon file...
|
||||
//
|
||||
|
||||
void
|
||||
Fl_File_Icon::load_xpm(const char *xpm) // I - File to read from
|
||||
{
|
||||
FILE *fp; // File pointer
|
||||
int i, j; // Looping vars
|
||||
int ch; // Current character
|
||||
int bg; // Background color
|
||||
char line[1024], // Line from file
|
||||
val[16], // Color value
|
||||
*ptr; // Pointer into line
|
||||
int x, y; // X & Y in image
|
||||
int startx; // Starting X coord
|
||||
int width, height; // Width and height of image
|
||||
int ncolors; // Number of colors
|
||||
Fl_Color colors[256]; // Colors
|
||||
int red, green, blue; // Red, green, and blue values
|
||||
|
||||
|
||||
// Try to open the file...
|
||||
if ((fp = fopen(xpm, "rb")) == NULL)
|
||||
return;
|
||||
|
||||
// Read the file header until we find the first string...
|
||||
ptr = NULL;
|
||||
while (fgets(line, sizeof(line), fp) != NULL)
|
||||
if ((ptr = strchr(line, '\"')) != NULL)
|
||||
break;
|
||||
|
||||
if (ptr == NULL)
|
||||
{
|
||||
// Nothing to load...
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the size of the image...
|
||||
sscanf(ptr + 1, "%d%d%d", &width, &height, &ncolors);
|
||||
|
||||
// Now read the colormap...
|
||||
memset(colors, 0, sizeof(colors));
|
||||
bg = ' ';
|
||||
|
||||
for (i = 0; i < ncolors; i ++)
|
||||
{
|
||||
while (fgets(line, sizeof(line), fp) != NULL)
|
||||
if ((ptr = strchr(line, '\"')) != NULL)
|
||||
break;
|
||||
|
||||
if (ptr == NULL)
|
||||
{
|
||||
// Nothing to load...
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the color's character
|
||||
ptr ++;
|
||||
ch = *ptr++;
|
||||
|
||||
// Get the color value...
|
||||
if ((ptr = strstr(ptr, "c ")) == NULL)
|
||||
{
|
||||
// No color; make this black...
|
||||
colors[ch] = FL_BLACK;
|
||||
}
|
||||
else if (ptr[2] == '#')
|
||||
{
|
||||
// Read the RGB triplet...
|
||||
ptr += 3;
|
||||
for (j = 0; j < 12; j ++)
|
||||
if (!isxdigit(ptr[j]))
|
||||
break;
|
||||
|
||||
switch (j)
|
||||
{
|
||||
case 0 :
|
||||
bg = ch;
|
||||
default :
|
||||
red = green = blue = 0;
|
||||
break;
|
||||
|
||||
case 3 :
|
||||
val[0] = ptr[0];
|
||||
val[1] = '\0';
|
||||
red = 255 * strtol(val, NULL, 16) / 15;
|
||||
|
||||
val[0] = ptr[1];
|
||||
val[1] = '\0';
|
||||
green = 255 * strtol(val, NULL, 16) / 15;
|
||||
|
||||
val[0] = ptr[2];
|
||||
val[1] = '\0';
|
||||
blue = 255 * strtol(val, NULL, 16) / 15;
|
||||
break;
|
||||
|
||||
case 6 :
|
||||
case 9 :
|
||||
case 12 :
|
||||
j /= 3;
|
||||
|
||||
val[0] = ptr[0];
|
||||
val[1] = ptr[1];
|
||||
val[2] = '\0';
|
||||
red = strtol(val, NULL, 16);
|
||||
|
||||
val[0] = ptr[j + 0];
|
||||
val[1] = ptr[j + 1];
|
||||
val[2] = '\0';
|
||||
green = strtol(val, NULL, 16);
|
||||
|
||||
val[0] = ptr[2 * j + 0];
|
||||
val[1] = ptr[2 * j + 1];
|
||||
val[2] = '\0';
|
||||
blue = strtol(val, NULL, 16);
|
||||
break;
|
||||
}
|
||||
|
||||
colors[ch] = fl_rgb_color(red, green, blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read a color name...
|
||||
if (strncasecmp(ptr + 2, "white", 5) == 0)
|
||||
colors[ch] = FL_WHITE;
|
||||
else if (strncasecmp(ptr + 2, "black", 5) == 0)
|
||||
colors[ch] = FL_BLACK;
|
||||
else if (strncasecmp(ptr + 2, "none", 4) == 0)
|
||||
{
|
||||
colors[ch] = FL_BLACK;
|
||||
bg = ch;
|
||||
}
|
||||
else
|
||||
colors[ch] = FL_GRAY;
|
||||
}
|
||||
}
|
||||
|
||||
// Read the image data...
|
||||
for (y = height - 1; y >= 0; y --)
|
||||
{
|
||||
while (fgets(line, sizeof(line), fp) != NULL)
|
||||
if ((ptr = strchr(line, '\"')) != NULL)
|
||||
break;
|
||||
|
||||
if (ptr == NULL)
|
||||
{
|
||||
// Nothing to load...
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
startx = 0;
|
||||
ch = bg;
|
||||
ptr ++;
|
||||
|
||||
for (x = 0; x < width; x ++, ptr ++)
|
||||
if (*ptr != ch)
|
||||
{
|
||||
if (ch != bg)
|
||||
{
|
||||
add_color(colors[ch]);
|
||||
add(POLYGON);
|
||||
add_vertex(startx * 9000 / width + 1000, y * 9000 / height + 500);
|
||||
add_vertex(x * 9000 / width + 1000, y * 9000 / height + 500);
|
||||
add_vertex(x * 9000 / width + 1000, (y + 1) * 9000 / height + 500);
|
||||
add_vertex(startx * 9000 / width + 1000, (y + 1) * 9000 / height + 500);
|
||||
add(END);
|
||||
}
|
||||
|
||||
ch = *ptr;
|
||||
startx = x;
|
||||
}
|
||||
|
||||
if (ch != bg)
|
||||
{
|
||||
add_color(colors[ch]);
|
||||
add(POLYGON);
|
||||
add_vertex(startx * 9000 / width + 1000, y * 9000 / height + 500);
|
||||
add_vertex(x * 9000 / width + 1000, y * 9000 / height + 500);
|
||||
add_vertex(x * 9000 / width + 1000, (y + 1) * 9000 / height + 500);
|
||||
add_vertex(startx * 9000 / width + 1000, (y + 1) * 9000 / height + 500);
|
||||
add(END);
|
||||
}
|
||||
}
|
||||
|
||||
// Close the file and return...
|
||||
fclose(fp);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Icon File \"%s\":\n", xpm);
|
||||
for (i = 0; i < num_data_; i ++)
|
||||
printf(" %d,\n", data_[i]);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'Fl_File_Icon::load_system_icons()' - Load the standard system icons/filetypes.
|
||||
|
||||
void
|
||||
Fl_File_Icon::load_system_icons(void)
|
||||
{
|
||||
Fl_File_Icon *icon; // New icons
|
||||
static int init = 0; // Have the icons been initialized?
|
||||
static short plain[] = // Plain file icon
|
||||
{
|
||||
COLOR, -1, -1, OUTLINEPOLYGON, 0, FL_GRAY,
|
||||
VERTEX, 2000, 1000, VERTEX, 2000, 9000,
|
||||
VERTEX, 6000, 9000, VERTEX, 8000, 7000,
|
||||
VERTEX, 8000, 1000, END, OUTLINEPOLYGON, 0, FL_GRAY,
|
||||
VERTEX, 6000, 9000, VERTEX, 6000, 7000,
|
||||
VERTEX, 8000, 7000, END,
|
||||
COLOR, 0, FL_BLACK, LINE, VERTEX, 6000, 7000,
|
||||
VERTEX, 8000, 7000, VERTEX, 8000, 1000,
|
||||
VERTEX, 2000, 1000, END, LINE, VERTEX, 3000, 7000,
|
||||
VERTEX, 5000, 7000, END, LINE, VERTEX, 3000, 6000,
|
||||
VERTEX, 5000, 6000, END, LINE, VERTEX, 3000, 5000,
|
||||
VERTEX, 7000, 5000, END, LINE, VERTEX, 3000, 4000,
|
||||
VERTEX, 7000, 4000, END, LINE, VERTEX, 3000, 3000,
|
||||
VERTEX, 7000, 3000, END, LINE, VERTEX, 3000, 2000,
|
||||
VERTEX, 7000, 2000, END,
|
||||
END
|
||||
};
|
||||
static short image[] = // Image file icon
|
||||
{
|
||||
COLOR, -1, -1, OUTLINEPOLYGON, 0, FL_GRAY,
|
||||
VERTEX, 2000, 1000, VERTEX, 2000, 9000,
|
||||
VERTEX, 6000, 9000, VERTEX, 8000, 7000,
|
||||
VERTEX, 8000, 1000, END, OUTLINEPOLYGON, 0, FL_GRAY,
|
||||
VERTEX, 6000, 9000, VERTEX, 6000, 7000,
|
||||
VERTEX, 8000, 7000, END,
|
||||
COLOR, 0, FL_BLACK, LINE, VERTEX, 6000, 7000,
|
||||
VERTEX, 8000, 7000, VERTEX, 8000, 1000,
|
||||
VERTEX, 2000, 1000, END,
|
||||
COLOR, 0, FL_RED, POLYGON, VERTEX, 3500, 2500,
|
||||
VERTEX, 3000, 3000, VERTEX, 3000, 4000,
|
||||
VERTEX, 3500, 4500, VERTEX, 4500, 4500,
|
||||
VERTEX, 5000, 4000, VERTEX, 5000, 3000,
|
||||
VERTEX, 4500, 2500, END,
|
||||
COLOR, 0, FL_GREEN, POLYGON, VERTEX, 5500, 2500,
|
||||
VERTEX, 5000, 3000, VERTEX, 5000, 4000,
|
||||
VERTEX, 5500, 4500, VERTEX, 6500, 4500,
|
||||
VERTEX, 7000, 4000, VERTEX, 7000, 3000,
|
||||
VERTEX, 6500, 2500, END,
|
||||
COLOR, 0, FL_BLUE, POLYGON, VERTEX, 4500, 3500,
|
||||
VERTEX, 4000, 4000, VERTEX, 4000, 5000,
|
||||
VERTEX, 4500, 5500, VERTEX, 5500, 5500,
|
||||
VERTEX, 6000, 5000, VERTEX, 6000, 4000,
|
||||
VERTEX, 5500, 3500, END,
|
||||
END
|
||||
};
|
||||
static short dir[] = // Directory icon
|
||||
{
|
||||
COLOR, -1, -1, POLYGON, VERTEX, 1000, 1000,
|
||||
VERTEX, 1000, 7500, VERTEX, 9000, 7500,
|
||||
VERTEX, 9000, 1000, END,
|
||||
POLYGON, VERTEX, 1000, 7500, VERTEX, 2500, 9000,
|
||||
VERTEX, 5000, 9000, VERTEX, 6500, 7500, END,
|
||||
COLOR, 0, FL_WHITE, LINE, VERTEX, 1500, 1500,
|
||||
VERTEX, 1500, 7000, VERTEX, 9000, 7000, END,
|
||||
COLOR, 0, FL_BLACK, LINE, VERTEX, 9000, 7500,
|
||||
VERTEX, 9000, 1000, VERTEX, 1000, 1000, END,
|
||||
COLOR, 0, FL_GRAY, LINE, VERTEX, 1000, 1000,
|
||||
VERTEX, 1000, 7500, VERTEX, 2500, 9000,
|
||||
VERTEX, 5000, 9000, VERTEX, 6500, 7500,
|
||||
VERTEX, 9000, 7500, END,
|
||||
END
|
||||
};
|
||||
|
||||
|
||||
// Add symbols if they haven't been added already...
|
||||
if (!init)
|
||||
{
|
||||
if (!access("/usr/share/mimelnk", F_OK))
|
||||
{
|
||||
// Load KDE icons...
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
|
||||
icon->load_xpm("/usr/share/icons/unknown.xpm");
|
||||
|
||||
load_kde_icons("/usr/share/mimelnk");
|
||||
}
|
||||
else if (!access("/usr/share/icons/folder.xpm", F_OK))
|
||||
{
|
||||
// Load GNOME icons...
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
|
||||
icon->load_xpm("/usr/share/icons/page.xpm");
|
||||
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
|
||||
icon->load_xpm("/usr/share/icons/folder.xpm");
|
||||
}
|
||||
else if (!access("/usr/dt/appconfig/icons", F_OK))
|
||||
{
|
||||
// Load CDE icons...
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
|
||||
icon->load_xpm("/usr/dt/appconfig/icons/C/Dtdata.m.pm");
|
||||
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
|
||||
icon->load_xpm("/usr/dt/appconfig/icons/C/DtdirB.m.pm");
|
||||
|
||||
icon = new Fl_File_Icon("core", Fl_File_Icon::PLAIN);
|
||||
icon->load_xpm("/usr/dt/appconfig/icons/C/Dtcore.m.pm");
|
||||
|
||||
icon = new Fl_File_Icon("*.{bmp|bw|gif|jpg|pbm|pcd|pgm|ppm|png|ras|rgb|tif|xbm|xpm}", Fl_File_Icon::PLAIN);
|
||||
icon->load_xpm("/usr/dt/appconfig/icons/C/Dtimage.m.pm");
|
||||
|
||||
icon = new Fl_File_Icon("*.{eps|pdf|ps}", Fl_File_Icon::PLAIN);
|
||||
icon->load_xpm("/usr/dt/appconfig/icons/C/Dtps.m.pm");
|
||||
|
||||
icon = new Fl_File_Icon("*.ppd", Fl_File_Icon::PLAIN);
|
||||
icon->load_xpm("/usr/dt/appconfig/icons/C/DtPrtpr.m.pm");
|
||||
}
|
||||
else if (!access("/usr/lib/filetype", F_OK))
|
||||
{
|
||||
// Load SGI icons...
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/iconlib/generic.doc.fti");
|
||||
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
|
||||
icon->load_fti("/usr/lib/filetype/iconlib/generic.folder.closed.fti");
|
||||
|
||||
icon = new Fl_File_Icon("core", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/default/iconlib/CoreFile.fti");
|
||||
|
||||
icon = new Fl_File_Icon("*.{bmp|bw|gif|jpg|pbm|pcd|pgm|ppm|png|ras|rgb|tif|xbm|xpm}", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/system/iconlib/ImageFile.fti");
|
||||
|
||||
if (!access("/usr/lib/filetype/install/iconlib/acroread.doc.fti", F_OK))
|
||||
{
|
||||
icon = new Fl_File_Icon("*.{eps|ps}", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
|
||||
|
||||
icon = new Fl_File_Icon("*.pdf", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/install/iconlib/acroread.doc.fti");
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = new Fl_File_Icon("*.{eps|pdf|ps}", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/system/iconlib/PostScriptFile.closed.fti");
|
||||
}
|
||||
|
||||
if (!access("/usr/lib/filetype/install/iconlib/html.fti", F_OK))
|
||||
{
|
||||
icon = new Fl_File_Icon("*.{htm|html|shtml}", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/iconlib/generic.doc.fti");
|
||||
icon->load_fti("/usr/lib/filetype/install/iconlib/html.fti");
|
||||
}
|
||||
|
||||
if (!access("/usr/lib/filetype/install/iconlib/color.ps.idle.fti", F_OK))
|
||||
{
|
||||
icon = new Fl_File_Icon("*.ppd", Fl_File_Icon::PLAIN);
|
||||
icon->load_fti("/usr/lib/filetype/install/iconlib/color.ps.idle.fti");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create the default icons...
|
||||
new Fl_File_Icon("*", Fl_File_Icon::PLAIN, sizeof(plain) / sizeof(plain[0]), plain);
|
||||
new Fl_File_Icon("*.{bmp|bw|gif|jpg|pbm|pcd|pgm|ppm|png|ras|rgb|tif|xbm|xpm}", Fl_File_Icon::PLAIN,
|
||||
sizeof(image) / sizeof(image[0]), image);
|
||||
new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY, sizeof(dir) / sizeof(dir[0]), dir);
|
||||
}
|
||||
|
||||
// Mark things as initialized...
|
||||
init = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'load_kde_icons()' - Load KDE icon files.
|
||||
//
|
||||
|
||||
static void
|
||||
load_kde_icons(const char *directory) // I - Directory to load
|
||||
{
|
||||
int i; // Looping var
|
||||
int n; // Number of entries in directory
|
||||
dirent **entries; // Entries in directory
|
||||
char full[1024]; // Full name of file
|
||||
|
||||
|
||||
entries = (dirent **)0;
|
||||
n = filename_list(directory, &entries);
|
||||
|
||||
for (i = 0; i < n; i ++)
|
||||
{
|
||||
if (entries[i]->d_name[0] != '.')
|
||||
{
|
||||
strcpy(full, directory);
|
||||
strcat(full,"/");
|
||||
strcat(full, entries[i]->d_name);
|
||||
|
||||
if (filename_isdir(full))
|
||||
load_kde_icons(full);
|
||||
else
|
||||
load_kde_mimelnk(full);
|
||||
}
|
||||
|
||||
free((void *)entries[i]);
|
||||
}
|
||||
|
||||
free((void*)entries);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'load_kde_mimelnk()' - Load a KDE "mimelnk" file.
|
||||
//
|
||||
|
||||
static void
|
||||
load_kde_mimelnk(const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
char tmp[256];
|
||||
char iconfilename[1024];
|
||||
char pattern[1024];
|
||||
char mimetype[1024];
|
||||
char *val;
|
||||
char full_iconfilename[1024];
|
||||
Fl_File_Icon *icon;
|
||||
|
||||
|
||||
if ((fp = fopen(filename, "rb")) != NULL)
|
||||
{
|
||||
while (fgets(tmp, sizeof(tmp), fp))
|
||||
{
|
||||
if ((val = get_kde_val(tmp, "Icon")) != NULL)
|
||||
strcpy(iconfilename, val);
|
||||
else if ((val = get_kde_val(tmp, "MimeType")) != NULL)
|
||||
strcpy(mimetype, val);
|
||||
else if ((val = get_kde_val(tmp, "Patterns")) != NULL)
|
||||
strcpy(pattern, val);
|
||||
}
|
||||
|
||||
if (iconfilename && pattern)
|
||||
{
|
||||
sprintf(full_iconfilename, "/usr/share/icons/%s", iconfilename);
|
||||
|
||||
if (strcmp(mimetype, "inode/directory") == 0)
|
||||
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
|
||||
else
|
||||
icon = new Fl_File_Icon(kde_to_fltk_pattern(pattern), Fl_File_Icon::PLAIN);
|
||||
|
||||
icon->load_xpm(full_iconfilename);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'kde_to_fltk_pattern()' - Convert a KDE pattern to a FLTK pattern.
|
||||
//
|
||||
|
||||
static char *
|
||||
kde_to_fltk_pattern(const char *kdepattern)
|
||||
{
|
||||
char *pattern,
|
||||
*patptr;
|
||||
|
||||
|
||||
pattern = (char *)malloc(strlen(kdepattern) + 3);
|
||||
strcpy(pattern, "{");
|
||||
strcat(pattern, kdepattern);
|
||||
|
||||
if (pattern[strlen(pattern) - 1] == ';')
|
||||
pattern[strlen(pattern) - 1] = '\0';
|
||||
|
||||
strcat(pattern, "}");
|
||||
|
||||
for (patptr = pattern; *patptr; patptr ++)
|
||||
if (*patptr == ';')
|
||||
*patptr = '|';
|
||||
|
||||
return (pattern);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'get_kde_val()' - Get a KDE value.
|
||||
//
|
||||
|
||||
static char *
|
||||
get_kde_val(char *str,
|
||||
const char *key)
|
||||
{
|
||||
while (*str == *key)
|
||||
{
|
||||
str ++;
|
||||
key ++;
|
||||
}
|
||||
|
||||
if (*key == '\0' && *str == '=')
|
||||
{
|
||||
if (str[strlen(str) - 1] == '\n')
|
||||
str[strlen(str) - 1] = '\0';
|
||||
|
||||
return (str + 1);
|
||||
}
|
||||
|
||||
return ((char *)0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_File_Icon.cxx,v 1.1.2.4 2001/10/29 21:59:14 easysw Exp $".
|
||||
// End of "$Id: Fl_File_Icon.cxx,v 1.1.2.5 2001/11/17 15:27:15 easysw Exp $".
|
||||
//
|
||||
|
1024
src/Fl_File_Icon2.cxx
Normal file
1024
src/Fl_File_Icon2.cxx
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Help_View.cxx,v 1.1.2.9 2001/10/29 21:59:15 easysw Exp $"
|
||||
// "$Id: Fl_Help_View.cxx,v 1.1.2.10 2001/11/17 15:27:15 easysw Exp $"
|
||||
//
|
||||
// Fl_Help_View widget routines.
|
||||
//
|
||||
@ -2903,7 +2903,7 @@ Fl_Help_View::load(const char *f)// I - Filename to load (may also have target)
|
||||
|
||||
int // O - 0 = success, -1 = fail
|
||||
Fl_Help_View::load_gif(Fl_Help_Image *img,// I - Image pointer
|
||||
FILE *fp) // I - File to load from
|
||||
FILE *fp)// I - File to load from
|
||||
{
|
||||
unsigned char buf[1024]; // Input buffer
|
||||
gif_cmap_t cmap; // Colormap
|
||||
@ -3062,22 +3062,18 @@ Fl_Help_View::load_png(Fl_Help_Image *img,// I - Image pointer
|
||||
if (info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand(pp);
|
||||
|
||||
if (info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
img->d = 1;
|
||||
else
|
||||
if (info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
img->d = 3;
|
||||
else
|
||||
img->d = 1;
|
||||
|
||||
img->w = (int)info->width;
|
||||
img->h = (int)info->height;
|
||||
img->data = (unsigned char *)malloc(img->w * img->h * 3);
|
||||
if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans)
|
||||
img->d ++;
|
||||
|
||||
if (info->bit_depth < 8)
|
||||
{
|
||||
png_set_packing(pp);
|
||||
png_set_expand(pp);
|
||||
|
||||
if (info->valid & PNG_INFO_sBIT)
|
||||
png_set_shift(pp, &(info->sig_bit));
|
||||
}
|
||||
else if (info->bit_depth == 16)
|
||||
png_set_strip_16(pp);
|
||||
@ -3088,6 +3084,10 @@ Fl_Help_View::load_png(Fl_Help_Image *img,// I - Image pointer
|
||||
png_set_tRNS_to_alpha(pp);
|
||||
#endif // HAVE_PNG_GET_VALID && HAVE_SET_TRNS_TO_ALPHA
|
||||
|
||||
img->w = (int)info->width;
|
||||
img->h = (int)info->height;
|
||||
img->data = (unsigned char *)malloc(img->w * img->h * img->d);
|
||||
|
||||
// Background color...
|
||||
unsigned rgba = fltk_colors[bgcolor_];
|
||||
|
||||
@ -3101,10 +3101,7 @@ Fl_Help_View::load_png(Fl_Help_Image *img,// I - Image pointer
|
||||
rows = (png_bytep *)calloc(info->height, sizeof(png_bytep));
|
||||
|
||||
for (i = 0; i < (int)info->height; i ++)
|
||||
if (info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
rows[i] = img->data + i * img->w;
|
||||
else
|
||||
rows[i] = img->data + i * img->w * 3;
|
||||
rows[i] = img->data + i * img->w * img->d;
|
||||
|
||||
// Read the image, handling interlacing as needed...
|
||||
for (i = png_set_interlace_handling(pp); i > 0; i --)
|
||||
@ -3584,5 +3581,5 @@ scrollbar_callback(Fl_Widget *s, void *)
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.9 2001/10/29 21:59:15 easysw Exp $".
|
||||
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.10 2001/11/17 15:27:15 easysw Exp $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# "$Id: Makefile,v 1.18.2.14.2.15 2001/10/27 03:33:25 easysw Exp $"
|
||||
# "$Id: Makefile,v 1.18.2.14.2.16 2001/11/17 15:27:15 easysw Exp $"
|
||||
#
|
||||
# Library makefile for the Fast Light Tool Kit (FLTK).
|
||||
#
|
||||
@ -45,6 +45,7 @@ CPPFILES = \
|
||||
Fl_File_Chooser.cxx \
|
||||
Fl_File_Chooser2.cxx \
|
||||
Fl_File_Icon.cxx \
|
||||
Fl_File_Icon2.cxx \
|
||||
Fl_Group.cxx \
|
||||
Fl_Help_Dialog.cxx \
|
||||
Fl_Help_View.cxx \
|
||||
@ -267,5 +268,5 @@ install: $(LIBNAME) $(DSONAME) $(GLLIBNAME) $(GLDSONAME)
|
||||
ln -s FL $(includedir)/Fl
|
||||
|
||||
#
|
||||
# End of "$Id: Makefile,v 1.18.2.14.2.15 2001/10/27 03:33:25 easysw Exp $".
|
||||
# End of "$Id: Makefile,v 1.18.2.14.2.16 2001/11/17 15:27:15 easysw Exp $".
|
||||
#
|
||||
|
@ -87,6 +87,9 @@ Fl_File_Chooser2.o: ../FL/Fl_Window.H
|
||||
Fl_File_Icon.o: ../config.h ../FL/Fl_File_Icon.H ../FL/Fl.H
|
||||
Fl_File_Icon.o: ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Widget.H
|
||||
Fl_File_Icon.o: ../FL/fl_draw.H ../FL/filename.H
|
||||
Fl_File_Icon2.o: ../config.h ../FL/Fl_File_Icon.H ../FL/Fl.H
|
||||
Fl_File_Icon2.o: ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Widget.H
|
||||
Fl_File_Icon2.o: ../FL/fl_draw.H ../FL/filename.H
|
||||
Fl_Group.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
|
||||
Fl_Group.o: ../FL/Fl_Group.H ../FL/Fl_Window.H ../FL/Fl_Group.H
|
||||
Fl_Group.o: ../FL/Fl_Widget.H ../FL/fl_draw.H ../FL/Fl_Tooltip.H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# "$Id: Makefile,v 1.19.2.7.2.6 2001/08/05 16:28:03 easysw Exp $"
|
||||
# "$Id: Makefile,v 1.19.2.7.2.7 2001/11/17 15:27:15 easysw Exp $"
|
||||
#
|
||||
# Test/example program makefile for the Fast Light Tool Kit (FLTK).
|
||||
#
|
||||
@ -70,6 +70,12 @@ gldemos: $(GLALL)
|
||||
$(ALL): ../lib/$(LIBNAME)
|
||||
|
||||
# Programs needing special instructions...
|
||||
editor: editor.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) editor.cxx -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS)
|
||||
file_chooser: file_chooser.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) file_chooser.cxx -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS)
|
||||
help: help.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) help.cxx -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS)
|
||||
@ -79,6 +85,9 @@ keyboard: keyboard.cxx keyboard_ui.cxx
|
||||
mandelbrot: mandelbrot.cxx mandelbrot_ui.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) mandelbrot.cxx $(LINKFLTK) $(LDLIBS) -o $@
|
||||
pixmap_browser: pixmap_browser.cxx
|
||||
echo Compiling and linking $@...
|
||||
$(CXX) -I.. $(CXXFLAGS) pixmap_browser.cxx -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS)
|
||||
|
||||
# OpenGL demos...
|
||||
CubeView: CubeMain.o CubeView.o CubeViewUI.o
|
||||
@ -127,5 +136,5 @@ install:
|
||||
@echo Nothing to install in test directory.
|
||||
|
||||
#
|
||||
# End of "$Id: Makefile,v 1.19.2.7.2.6 2001/08/05 16:28:03 easysw Exp $".
|
||||
# End of "$Id: Makefile,v 1.19.2.7.2.7 2001/11/17 15:27:15 easysw Exp $".
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user