License
BSD-3-Clause
Preferences module for FLTK.
This module provides the Preferences class for storing and retrieving application preferences in a platform-appropriate way (registry on Windows, files on Unix/macOS).
Example:
import fltk.preferences;
// Create user preferences
auto prefs = new Preferences(PreferencesRoot.USER, "MyCompany", "MyApp");
// Store values
prefs.set("window_width", 800);
prefs.set("window_height", 600);
prefs.set("username", "John");
// Retrieve values
int width = prefs.get("window_width", 640);
string name = prefs.get("username", "Guest");
// Create a subgroup
auto displayPrefs = new Preferences(prefs, "display");
displayPrefs.set("fullscreen", 0);Class for storing and retrieving application preferences.
Preferences are stored in a platform-appropriate location:
The preferences are organized hierarchically with groups and entries. Groups can contain other groups and entries. Entries store actual values.
Example:
// Create preferences for current user
auto prefs = new Preferences(PreferencesRoot.USER, "MyCompany", "MyApp");
// Set some values
prefs.set("width", 800);
prefs.set("height", 600);
prefs.set("title", "My Window");
// Get values with defaults
int w = prefs.get("width", 640);
int h = prefs.get("height", 480);
string t = prefs.get("title", "Untitled");
// Create a subgroup
auto colors = new Preferences(prefs, "colors");
colors.set("background", 0xFFFFFF);string group(int index)Returns the name of a group by index.bool groupExists(string key)Checks if a group exists.bool deleteGroup(string groupName)Deletes a group and all its contents.string entry(int index)Returns the name of an entry by index.bool entryExists(string key)Checks if an entry exists.bool deleteEntry(string entryName)Deletes an entry.bool set(string entryName, int value)Sets an integer value.bool set(string entryName, float value)Sets a float value.bool set(string entryName, double value)Sets a double value.bool set(string entryName, string value)Sets a string value.int get(string entryName, int defaultValue)Gets an integer value.float get(string entryName, float defaultValue)Gets a float value.double get(string entryName, double defaultValue)Gets a double value.string get(string entryName, string defaultValue)Gets a string value.int size(string entryName)Gets the size of an entry's data.string getUserdataPath()Gets the user data path for this application.string newUUID()Generates a new UUID string.this(PreferencesRoot root, string vendor, string application)Creates a new preferences object with the specified root location.this(string path, string vendor, string application)Creates a new preferences object with a custom file path.this(Preferences parent, string group)Creates a child preferences group.