FLTK: Fl_File_Icon.H Source File

FLTK

Fl_File_Icon.H
1 //
2 // "$Id$"
3 //
4 // Fl_File_Icon definitions.
5 //
6 // Copyright 1999-2010 by Michael Sweet.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18
19 /* \file
20 Fl_File_Icon widget . */
21
22 //
23 // Include necessary header files...
24 //
25
26 #ifndef _Fl_Fl_File_Icon_H_
27 # define _Fl_Fl_File_Icon_H_
28
29 # include "Fl.H"
30
31
32 //
33 // Special color value for the icon color.
34 //
35
36 # define FL_ICON_COLOR (Fl_Color)0xffffffff
39 //
40 // Fl_File_Icon class...
41 //
42
47 class FL_EXPORT Fl_File_Icon {
48
49 static Fl_File_Icon *first_; // Pointer to first icon/filetype
50 Fl_File_Icon *next_; // Pointer to next icon/filetype
51 const char *pattern_; // Pattern string
52 int type_; // Match only if directory or file?
53 int num_data_; // Number of data elements
54 int alloc_data_; // Number of allocated elements
55 short *data_; // Icon data
56
57 public:
58
59 enum // File types
60 {
61 ANY, // Any kind of file
62 PLAIN, // Only plain files
63 FIFO, // Only named pipes
64 DEVICE, // Only character and block devices
65 LINK, // Only symbolic links
66 DIRECTORY // Only directories
67 };
68
69 enum // Data opcodes
70 {
71 END, // End of primitive/icon
72 COLOR, // Followed by color value (2 shorts)
73 LINE, // Start of line
74 CLOSEDLINE, // Start of closed line
75 POLYGON, // Start of polygon
76 OUTLINEPOLYGON, // Followed by outline color (2 shorts)
77 VERTEX // Followed by scaled X,Y
78 };
79
80 Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0);
81 ~Fl_File_Icon();
82
83 short *add(short d);
84
89 short *add_color(Fl_Color c)
90 { short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); }
91
98 short *add_vertex(int x, int y)
99 { short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); }
100
107 short *add_vertex(float x, float y)
108 { short *d = add((short)VERTEX); add((short)(x * 10000.0));
109 add((short)(y * 10000.0)); return (d); }
110
112 void clear() { num_data_ = 0; }
113
114 void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1);
115
116 void label(Fl_Widget *w);
117
118 static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
119 void load(const char *f);
120 int load_fti(const char *fti);
121 int load_image(const char *i);
122
124 Fl_File_Icon *next() { return (next_); }
125
127 const char *pattern() { return (pattern_); }
128
130 int size() { return (num_data_); }
131
143 int type() { return (type_); }
144
146 short *value() { return (data_); }
147
148 static Fl_File_Icon *find(const char *filename, int filetype = ANY);
149
151 static Fl_File_Icon *first() { return (first_); }
152 static void load_system_icons(void);
153 };
154
155 #endif // !_Fl_Fl_File_Icon_H_
156
157 //
158 // End of "$Id$".
159 //
Fl_File_Icon::next
Fl_File_Icon * next()
Returns next file icon object.
Definition: Fl_File_Icon.H:124
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:47
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:107
Fl.H
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:934
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:143
Fl_File_Icon::clear
void clear()
Clears all icon data from the icon.
Definition: Fl_File_Icon.H:112
Fl_File_Icon::value
short * value()
Returns the data array for the icon.
Definition: Fl_File_Icon.H:146
Fl_File_Icon::first
static Fl_File_Icon * first()
Returns a pointer to the first icon in the list.
Definition: Fl_File_Icon.H:151
Fl_File_Icon::pattern
const char * pattern()
Returns the filename matching pattern for the icon.
Definition: Fl_File_Icon.H:127
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:89
Fl_Label
This struct stores all information for a text or mixed graphics label.
Definition: Fl_Widget.H:65
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:101
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:98
Fl_File_Icon::size
int size()
Returns the number of words of data used by the icon.
Definition: Fl_File_Icon.H:130
Fl_Align
unsigned Fl_Align
FLTK type for alignment control.
Definition: Enumerations.H:828
- © 1998-2016 by Bill Spitzak and others.