FLTK 1.3.0
|
00001 // 00002 // "$Id: Fl_File_Icon.H 8306 2011-01-24 17:04:22Z matt $" 00003 // 00004 // Fl_File_Icon definitions. 00005 // 00006 // Copyright 1999-2010 by Michael Sweet. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 /* \file 00029 Fl_File_Icon widget . */ 00030 00031 // 00032 // Include necessary header files... 00033 // 00034 00035 #ifndef _Fl_Fl_File_Icon_H_ 00036 # define _Fl_Fl_File_Icon_H_ 00037 00038 # include "Fl.H" 00039 00040 00041 // 00042 // Special color value for the icon color. 00043 // 00044 00045 # define FL_ICON_COLOR (Fl_Color)0xffffffff 00048 // 00049 // Fl_File_Icon class... 00050 // 00051 00056 class FL_EXPORT Fl_File_Icon { 00057 00058 static Fl_File_Icon *first_; // Pointer to first icon/filetype 00059 Fl_File_Icon *next_; // Pointer to next icon/filetype 00060 const char *pattern_; // Pattern string 00061 int type_; // Match only if directory or file? 00062 int num_data_; // Number of data elements 00063 int alloc_data_; // Number of allocated elements 00064 short *data_; // Icon data 00065 00066 public: 00067 00068 enum // File types 00069 { 00070 ANY, // Any kind of file 00071 PLAIN, // Only plain files 00072 FIFO, // Only named pipes 00073 DEVICE, // Only character and block devices 00074 LINK, // Only symbolic links 00075 DIRECTORY // Only directories 00076 }; 00077 00078 enum // Data opcodes 00079 { 00080 END, // End of primitive/icon 00081 COLOR, // Followed by color value (2 shorts) 00082 LINE, // Start of line 00083 CLOSEDLINE, // Start of closed line 00084 POLYGON, // Start of polygon 00085 OUTLINEPOLYGON, // Followed by outline color (2 shorts) 00086 VERTEX // Followed by scaled X,Y 00087 }; 00088 00089 Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0); 00090 ~Fl_File_Icon(); 00091 00092 short *add(short d); 00093 00098 short *add_color(Fl_Color c) 00099 { short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); } 00100 00107 short *add_vertex(int x, int y) 00108 { short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); } 00109 00116 short *add_vertex(float x, float y) 00117 { short *d = add((short)VERTEX); add((short)(x * 10000.0)); 00118 add((short)(y * 10000.0)); return (d); } 00119 00121 void clear() { num_data_ = 0; } 00122 00123 void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1); 00124 00125 void label(Fl_Widget *w); 00126 00127 static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a); 00128 void load(const char *f); 00129 int load_fti(const char *fti); 00130 int load_image(const char *i); 00131 00133 Fl_File_Icon *next() { return (next_); } 00134 00136 const char *pattern() { return (pattern_); } 00137 00139 int size() { return (num_data_); } 00140 00152 int type() { return (type_); } 00153 00155 short *value() { return (data_); } 00156 00157 static Fl_File_Icon *find(const char *filename, int filetype = ANY); 00158 00160 static Fl_File_Icon *first() { return (first_); } 00161 static void load_system_icons(void); 00162 }; 00163 00164 #endif // !_Fl_Fl_File_Icon_H_ 00165 00166 // 00167 // End of "$Id: Fl_File_Icon.H 8306 2011-01-24 17:04:22Z matt $". 00168 //