FLTK 1.3.0
|
00001 // 00002 // "$Id$" 00003 // 00004 // Fl_File_Icon definitions. 00005 // 00006 // Copyright 1999-2010 by Michael Sweet. 00007 // 00008 // This library is free software. Distribution and use rights are outlined in 00009 // the file "COPYING" which should have been included with this file. If this 00010 // file is missing or damaged, see the license at: 00011 // 00012 // http://www.fltk.org/COPYING.php 00013 // 00014 // Please report all bugs and problems on the following page: 00015 // 00016 // http://www.fltk.org/str.php 00017 // 00018 00019 /* \file 00020 Fl_File_Icon widget . */ 00021 00022 // 00023 // Include necessary header files... 00024 // 00025 00026 #ifndef _Fl_Fl_File_Icon_H_ 00027 # define _Fl_Fl_File_Icon_H_ 00028 00029 # include "Fl.H" 00030 00031 00032 // 00033 // Special color value for the icon color. 00034 // 00035 00036 # define FL_ICON_COLOR (Fl_Color)0xffffffff 00039 // 00040 // Fl_File_Icon class... 00041 // 00042 00047 class FL_EXPORT Fl_File_Icon { 00048 00049 static Fl_File_Icon *first_; // Pointer to first icon/filetype 00050 Fl_File_Icon *next_; // Pointer to next icon/filetype 00051 const char *pattern_; // Pattern string 00052 int type_; // Match only if directory or file? 00053 int num_data_; // Number of data elements 00054 int alloc_data_; // Number of allocated elements 00055 short *data_; // Icon data 00056 00057 public: 00058 00059 enum // File types 00060 { 00061 ANY, // Any kind of file 00062 PLAIN, // Only plain files 00063 FIFO, // Only named pipes 00064 DEVICE, // Only character and block devices 00065 LINK, // Only symbolic links 00066 DIRECTORY // Only directories 00067 }; 00068 00069 enum // Data opcodes 00070 { 00071 END, // End of primitive/icon 00072 COLOR, // Followed by color value (2 shorts) 00073 LINE, // Start of line 00074 CLOSEDLINE, // Start of closed line 00075 POLYGON, // Start of polygon 00076 OUTLINEPOLYGON, // Followed by outline color (2 shorts) 00077 VERTEX // Followed by scaled X,Y 00078 }; 00079 00080 Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0); 00081 ~Fl_File_Icon(); 00082 00083 short *add(short d); 00084 00089 short *add_color(Fl_Color c) 00090 { short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); } 00091 00098 short *add_vertex(int x, int y) 00099 { short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); } 00100 00107 short *add_vertex(float x, float y) 00108 { short *d = add((short)VERTEX); add((short)(x * 10000.0)); 00109 add((short)(y * 10000.0)); return (d); } 00110 00112 void clear() { num_data_ = 0; } 00113 00114 void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1); 00115 00116 void label(Fl_Widget *w); 00117 00118 static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a); 00119 void load(const char *f); 00120 int load_fti(const char *fti); 00121 int load_image(const char *i); 00122 00124 Fl_File_Icon *next() { return (next_); } 00125 00127 const char *pattern() { return (pattern_); } 00128 00130 int size() { return (num_data_); } 00131 00143 int type() { return (type_); } 00144 00146 short *value() { return (data_); } 00147 00148 static Fl_File_Icon *find(const char *filename, int filetype = ANY); 00149 00151 static Fl_File_Icon *first() { return (first_); } 00152 static void load_system_icons(void); 00153 }; 00154 00155 #endif // !_Fl_Fl_File_Icon_H_ 00156 00157 // 00158 // End of "$Id$". 00159 //