2001-08-02 01:24:49 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
2001-09-29 18:38:59 +04:00
|
|
|
// Fl_File_Icon definitions.
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
2009-01-01 19:11:32 +03:00
|
|
|
// Copyright 1999-2009 by Michael Sweet.
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_File_Icon widget . */
|
|
|
|
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
// Include necessary header files...
|
|
|
|
//
|
|
|
|
|
2001-09-29 18:38:59 +04:00
|
|
|
#ifndef _Fl_Fl_File_Icon_H_
|
|
|
|
# define _Fl_Fl_File_Icon_H_
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2001-08-02 20:17:04 +04:00
|
|
|
# include "Fl.H"
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
|
2001-10-29 06:44:33 +03:00
|
|
|
//
|
|
|
|
// Special color value for the icon color.
|
|
|
|
//
|
|
|
|
|
2008-10-04 16:21:46 +04:00
|
|
|
# define FL_ICON_COLOR (Fl_Color)0xffffffff /**< icon color [background?]*/
|
2001-10-29 06:44:33 +03:00
|
|
|
|
|
|
|
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
2001-09-29 18:38:59 +04:00
|
|
|
// Fl_File_Icon class...
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/**
|
|
|
|
The Fl_File_Icon class manages icon images that can be used
|
|
|
|
as labels in other widgets and as icons in the FileBrowser widget.
|
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
class FL_EXPORT Fl_File_Icon //// Icon data
|
2001-08-02 01:24:49 +04:00
|
|
|
{
|
2002-08-14 20:49:38 +04:00
|
|
|
static Fl_File_Icon *first_; // Pointer to first icon/filetype
|
2001-09-29 18:38:59 +04:00
|
|
|
Fl_File_Icon *next_; // Pointer to next icon/filetype
|
2001-08-02 01:24:49 +04:00
|
|
|
const char *pattern_; // Pattern string
|
|
|
|
int type_; // Match only if directory or file?
|
|
|
|
int num_data_; // Number of data elements
|
|
|
|
int alloc_data_; // Number of allocated elements
|
|
|
|
short *data_; // Icon data
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum // File types
|
|
|
|
{
|
|
|
|
ANY, // Any kind of file
|
|
|
|
PLAIN, // Only plain files
|
|
|
|
FIFO, // Only named pipes
|
|
|
|
DEVICE, // Only character and block devices
|
|
|
|
LINK, // Only symbolic links
|
2001-08-02 20:17:04 +04:00
|
|
|
DIRECTORY // Only directories
|
2001-08-02 01:24:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum // Data opcodes
|
|
|
|
{
|
|
|
|
END, // End of primitive/icon
|
2001-10-29 06:44:33 +03:00
|
|
|
COLOR, // Followed by color value (2 shorts)
|
2001-08-02 01:24:49 +04:00
|
|
|
LINE, // Start of line
|
|
|
|
CLOSEDLINE, // Start of closed line
|
|
|
|
POLYGON, // Start of polygon
|
2001-10-29 06:44:33 +03:00
|
|
|
OUTLINEPOLYGON, // Followed by outline color (2 shorts)
|
2001-08-02 01:24:49 +04:00
|
|
|
VERTEX // Followed by scaled X,Y
|
|
|
|
};
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0);
|
|
|
|
~Fl_File_Icon();
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2002-11-19 19:37:36 +03:00
|
|
|
short *add(short d);
|
2008-10-04 16:21:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a color value to the icon array, returning a pointer to it.
|
|
|
|
\param[in] c color value
|
|
|
|
*/
|
2002-11-19 19:37:36 +03:00
|
|
|
short *add_color(Fl_Color c)
|
|
|
|
{ short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/**
|
|
|
|
Adds a vertex value to the icon array, returning a pointer to it.
|
2008-10-04 16:21:46 +04:00
|
|
|
The integer version accepts coordinates from 0 to 10000.
|
|
|
|
The origin (0.0) is in the lower-lefthand corner of the icon.
|
|
|
|
\param[in] x, y vertex coordinates
|
2008-09-14 19:45:27 +04:00
|
|
|
*/
|
2002-11-19 19:37:36 +03:00
|
|
|
short *add_vertex(int x, int y)
|
|
|
|
{ short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/**
|
|
|
|
Adds a vertex value to the icon array, returning a pointer to it.
|
2008-10-04 16:21:46 +04:00
|
|
|
The floating point version goes from 0.0 to 1.0.
|
|
|
|
The origin (0.0) is in the lower-lefthand corner of the icon.
|
|
|
|
\param[in] x, y vertex coordinates
|
2008-09-14 19:45:27 +04:00
|
|
|
*/
|
2002-11-19 19:37:36 +03:00
|
|
|
short *add_vertex(float x, float y)
|
|
|
|
{ short *d = add((short)VERTEX); add((short)(x * 10000.0));
|
|
|
|
add((short)(y * 10000.0)); return (d); }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/** Clears all icon data from the icon.*/
|
2002-11-19 19:37:36 +03:00
|
|
|
void clear() { num_data_ = 0; }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2002-11-19 19:37:36 +03:00
|
|
|
void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1);
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2002-11-19 19:37:36 +03:00
|
|
|
void label(Fl_Widget *w);
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
|
2002-11-19 19:37:36 +03:00
|
|
|
void load(const char *f);
|
2002-08-14 20:49:38 +04:00
|
|
|
int load_fti(const char *fti);
|
|
|
|
int load_image(const char *i);
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/** Returns next file icon object. See Fl_File_Icon::first() */
|
2002-11-19 19:37:36 +03:00
|
|
|
Fl_File_Icon *next() { return (next_); }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/** Returns the filename matching pattern for the icon.*/
|
2002-11-19 19:37:36 +03:00
|
|
|
const char *pattern() { return (pattern_); }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/** Returns the number of words of data used by the icon.*/
|
2002-11-19 19:37:36 +03:00
|
|
|
int size() { return (num_data_); }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/**
|
|
|
|
Returns the filetype associated with the icon, which can be one of the
|
|
|
|
following:
|
|
|
|
|
2008-10-04 16:21:46 +04:00
|
|
|
\li Fl_File_Icon::ANY, any kind of file.
|
|
|
|
\li Fl_File_Icon::PLAIN, plain files.
|
|
|
|
\li Fl_File_Icon::FIFO, named pipes.
|
|
|
|
\li Fl_File_Icon::DEVICE, character and block devices.
|
|
|
|
\li Fl_File_Icon::LINK, symbolic links.
|
|
|
|
\li Fl_File_Icon::DIRECTORY, directories.
|
2008-09-14 19:45:27 +04:00
|
|
|
*/
|
2002-11-19 19:37:36 +03:00
|
|
|
int type() { return (type_); }
|
2008-10-04 16:21:46 +04:00
|
|
|
|
2008-09-14 19:45:27 +04:00
|
|
|
/** Returns the data array for the icon.*/
|
2002-11-19 19:37:36 +03:00
|
|
|
short *value() { return (data_); }
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
static Fl_File_Icon *find(const char *filename, int filetype = ANY);
|
2008-09-14 19:45:27 +04:00
|
|
|
|
|
|
|
/** Returns a pointer to the first icon in the list.*/
|
2001-09-29 18:38:59 +04:00
|
|
|
static Fl_File_Icon *first() { return (first_); }
|
2002-08-14 20:49:38 +04:00
|
|
|
static void load_system_icons(void);
|
2001-08-02 01:24:49 +04:00
|
|
|
};
|
|
|
|
|
2001-09-29 18:38:59 +04:00
|
|
|
#endif // !_Fl_Fl_File_Icon_H_
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|