License
BSD-3-Clause
File icon module for FLTK.
This module provides the FileIcon class for managing file type icons that can be used in file browsers and as widget labels.
Example:
import fltk.fileicon;
// Load system icons
FileIcon.loadSystemIcons();
// Find an icon for a file
auto icon = FileIcon.find("/path/to/file.txt");
// Create a custom icon
auto customIcon = new FileIcon("*.d", FileIconType.PLAIN);
customIcon.addColor(Colors.BLUE);
customIcon.add(FileIconOpcode.POLYGON);
customIcon.addVertex(0.0f, 0.0f);
customIcon.addVertex(1.0f, 0.0f);
customIcon.addVertex(0.5f, 1.0f);
customIcon.add(FileIconOpcode.END);Class for managing file type icons.
FileIcon manages icon images that can be used as labels in widgets and as icons in the FileBrowser widget. Icons can be loaded from files or constructed programmatically using drawing primitives.
FLTK maintains a linked list of all file icons. Use the static methods first(), find(), and loadSystemIcons() to work with the global icon list.
Example:
// Load system file icons
FileIcon.loadSystemIcons();
// Find icon for a specific file
auto icon = FileIcon.find("document.pdf");
if (icon !is null) {
// Use the icon
}
// Create a custom directory icon
auto dirIcon = new FileIcon("dir", FileIconType.DIRECTORY);
dirIcon.addColor(0x0000FF00); // Blue
dirIcon.add(FileIconOpcode.POLYGON);
dirIcon.addVertex(0, 0);
dirIcon.addVertex(10000, 0);
dirIcon.addVertex(10000, 10000);
dirIcon.addVertex(0, 10000);
dirIcon.add(FileIconOpcode.END);void addVertex(int x, int y) nothrow @nogcAdds a vertex value to the icon using integer coordinates.void addVertex(float x, float y) nothrow @nogcAdds a vertex value to the icon using float coordinates.void draw(int x, int y, int w, int h, uint ic, bool active = true) nothrow @nogcDraws the icon at the specified position and size.void load(string filename)Loads icon data from a file.int loadFti(string fti)Loads icon data from an FTI (FLTK Icon) file.int loadImage(string filename)Loads icon data from an image file.string pattern()Returns the filename matching pattern.FileIcon find(string filename, FileIconType filetype = FileIconType.ANY)Finds an icon for a given filename.void loadSystemIcons()Loads the standard system file icons.this(string pattern, FileIconType type)Creates a new file icon.this(FileIconPtr ptr, bool owns)Creates a wrapper around an existing file icon handle.