fltk.fileicon

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 FileIcon

Types 1

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);

Fields
private FileIconPtr handle
private bool ownsHandle
Methods
void clear() nothrow @nogcClears all icon data from the icon.
void add(short d) nothrow @nogcAdds a data value to the icon.
void add(FileIconOpcode opcode) nothrow @nogcAdds an opcode to the icon.
void addColor(uint c) nothrow @nogcAdds a color value to the icon.
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 label(WidgetPtr widget) nothrow @nogcAssociates this icon with a widget as its label.
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.
FileIcon next()Returns the next file icon in the linked list.
string pattern()Returns the filename matching pattern.
int size() nothrow @nogcReturns the number of data words in the icon.
FileIconType type() nothrow @nogcReturns the file type associated with the icon.
FileIconPtr ptr() nothrow @nogcReturns the underlying handle pointer.
FileIcon find(string filename, FileIconType filetype = FileIconType.ANY)Finds an icon for a given filename.
FileIcon first()Returns the first icon in the global linked list.
void loadSystemIcons()Loads the standard system file icons.
Constructors
this(string pattern, FileIconType type)Creates a new file icon.
this(FileIconPtr ptr, bool owns)Creates a wrapper around an existing file icon handle.
Destructors