FLTK 1.4.4: Fl_File_Icon.H Source File

FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_File_Icon.H
1//
2// Fl_File_Icon definitions.
3//
4// Copyright 1999-2010 by Michael Sweet.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17/* \file
18 Fl_File_Icon widget . */
19
20//
21// Include necessary header files...
22//
23
24#ifndef _Fl_Fl_File_Icon_H_
25# define _Fl_Fl_File_Icon_H_
26
27# include "Fl.H"
28
29
30//
31// Special color value for the icon color.
32//
33
34# define FL_ICON_COLOR (Fl_Color)0xffffffff
35
36
37//
38// Fl_File_Icon class...
39//
40
45 class FL_EXPORT Fl_File_Icon {
46
47 static Fl_File_Icon *first_; // Pointer to first icon/filetype
48 Fl_File_Icon *next_; // Pointer to next icon/filetype
49 const char *pattern_; // Pattern string
50 int type_; // Match only if directory or file?
51 int num_data_; // Number of data elements
52 int alloc_data_; // Number of allocated elements
53 short *data_; // Icon data
54
55 public:
56
57 enum // File types
58 {
59 ANY, // Any kind of file
60 PLAIN, // Only plain files
61 FIFO, // Only named pipes
62 DEVICE, // Only character and block devices
63 LINK, // Only symbolic links
64 DIRECTORY // Only directories
65 };
66
67 enum // Data opcodes
68 {
69 END, // End of primitive/icon
70 COLOR, // Followed by color value (2 shorts)
71 LINE, // Start of line
72 CLOSEDLINE, // Start of closed line
73 POLYGON, // Start of polygon
74 OUTLINEPOLYGON, // Followed by outline color (2 shorts)
75 VERTEX // Followed by scaled X,Y
76 };
77
78 Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0);
79 ~Fl_File_Icon();
80
81 short *add(short d);
82
87 short *add_color(Fl_Color c)
88 { short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); }
89
96 short *add_vertex(int x, int y)
97 { short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); }
98
105 short *add_vertex(float x, float y)
106 { short *d = add((short)VERTEX); add((short)(x * 10000.0));
107 add((short)(y * 10000.0)); return (d); }
108
110 void clear() { num_data_ = 0; }
111
112 void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1);
113
114 void label(Fl_Widget *w);
115
116 static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
117 void load(const char *f);
118 int load_fti(const char *fti);
119 int load_image(const char *i);
120
122 Fl_File_Icon *next() { return (next_); }
123
125 const char *pattern() { return (pattern_); }
126
128 int size() { return (num_data_); }
129
141 int type() { return (type_); }
142
144 short *value() { return (data_); }
145
146 static Fl_File_Icon *find(const char *filename, int filetype = ANY);
147
149 static Fl_File_Icon *first() { return (first_); }
150 static void load_system_icons(void);
151};
152
153#endif // !_Fl_Fl_File_Icon_H_
Fl_Align
unsigned Fl_Align
FLTK type for alignment control.
Definition Enumerations.H:986
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl.H
Fl static class.
Fl_File_Icon
The Fl_File_Icon class manages icon images that can be used as labels in other widgets and as icons i...
Definition Fl_File_Icon.H:45
Fl_File_Icon::type
int type()
Returns the filetype associated with the icon, which can be one of the following:
Definition Fl_File_Icon.H:141
Fl_File_Icon::add_vertex
short * add_vertex(int x, int y)
Adds a vertex value to the icon array, returning a pointer to it.
Definition Fl_File_Icon.H:96
Fl_File_Icon::pattern
const char * pattern()
Returns the filename matching pattern for the icon.
Definition Fl_File_Icon.H:125
Fl_File_Icon::add
short * add(short d)
Adds a keyword value to the icon array, returning a pointer to it.
Definition Fl_File_Icon.cxx:128
Fl_File_Icon::add_vertex
short * add_vertex(float x, float y)
Adds a vertex value to the icon array, returning a pointer to it.
Definition Fl_File_Icon.H:105
Fl_File_Icon::first
static Fl_File_Icon * first()
Returns a pointer to the first icon in the list.
Definition Fl_File_Icon.H:149
Fl_File_Icon::size
int size()
Returns the number of words of data used by the icon.
Definition Fl_File_Icon.H:128
Fl_File_Icon::next
Fl_File_Icon * next()
Returns next file icon object.
Definition Fl_File_Icon.H:122
Fl_File_Icon::Fl_File_Icon
Fl_File_Icon(const char *p, int t, int nd=0, short *d=0)
Creates a new Fl_File_Icon with the specified information.
Definition Fl_File_Icon.cxx:65
Fl_File_Icon::value
short * value()
Returns the data array for the icon.
Definition Fl_File_Icon.H:144
Fl_File_Icon::clear
void clear()
Clears all icon data from the icon.
Definition Fl_File_Icon.H:110
Fl_File_Icon::add_color
short * add_color(Fl_Color c)
Adds a color value to the icon array, returning a pointer to it.
Definition Fl_File_Icon.H:87
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:112
Fl_Label
This struct stores all information for a text or mixed graphics label.
Definition Fl_Widget.H:49