FLTK 1.3.0
Fl_File_Icon.H
1 //
2 // "$Id: Fl_File_Icon.H 8306 2011-01-24 17:04:22Z matt $"
3 //
4 // Fl_File_Icon definitions.
5 //
6 // Copyright 1999-2010 by Michael Sweet.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
22 //
23 // Please report all bugs and problems on the following page:
24 //
25 // http://www.fltk.org/str.php
26 //
27 
28 /* \file
29  Fl_File_Icon widget . */
30 
31 //
32 // Include necessary header files...
33 //
34 
35 #ifndef _Fl_Fl_File_Icon_H_
36 # define _Fl_Fl_File_Icon_H_
37 
38 # include "Fl.H"
39 
40 
41 //
42 // Special color value for the icon color.
43 //
44 
45 # define FL_ICON_COLOR (Fl_Color)0xffffffff
48 //
49 // Fl_File_Icon class...
50 //
51 
56 class FL_EXPORT Fl_File_Icon {
57 
58  static Fl_File_Icon *first_; // Pointer to first icon/filetype
59  Fl_File_Icon *next_; // Pointer to next icon/filetype
60  const char *pattern_; // Pattern string
61  int type_; // Match only if directory or file?
62  int num_data_; // Number of data elements
63  int alloc_data_; // Number of allocated elements
64  short *data_; // Icon data
65 
66  public:
67 
68  enum // File types
69  {
70  ANY, // Any kind of file
71  PLAIN, // Only plain files
72  FIFO, // Only named pipes
73  DEVICE, // Only character and block devices
74  LINK, // Only symbolic links
75  DIRECTORY // Only directories
76  };
77 
78  enum // Data opcodes
79  {
80  END, // End of primitive/icon
81  COLOR, // Followed by color value (2 shorts)
82  LINE, // Start of line
83  CLOSEDLINE, // Start of closed line
84  POLYGON, // Start of polygon
85  OUTLINEPOLYGON, // Followed by outline color (2 shorts)
86  VERTEX // Followed by scaled X,Y
87  };
88 
89  Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0);
90  ~Fl_File_Icon();
91 
92  short *add(short d);
93 
98  short *add_color(Fl_Color c)
99  { short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); }
100 
107  short *add_vertex(int x, int y)
108  { short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); }
109 
116  short *add_vertex(float x, float y)
117  { short *d = add((short)VERTEX); add((short)(x * 10000.0));
118  add((short)(y * 10000.0)); return (d); }
119 
121  void clear() { num_data_ = 0; }
122 
123  void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1);
124 
125  void label(Fl_Widget *w);
126 
127  static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a);
128  void load(const char *f);
129  int load_fti(const char *fti);
130  int load_image(const char *i);
131 
133  Fl_File_Icon *next() { return (next_); }
134 
136  const char *pattern() { return (pattern_); }
137 
139  int size() { return (num_data_); }
140 
152  int type() { return (type_); }
153 
155  short *value() { return (data_); }
156 
157  static Fl_File_Icon *find(const char *filename, int filetype = ANY);
158 
160  static Fl_File_Icon *first() { return (first_); }
161  static void load_system_icons(void);
162 };
163 
164 #endif // !_Fl_Fl_File_Icon_H_
165 
166 //
167 // End of "$Id: Fl_File_Icon.H 8306 2011-01-24 17:04:22Z matt $".
168 //