FLTK 1.4.4: Fl_System_Driver.H Source File

FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_System_Driver.H
1//
2// A base class for platform specific system calls
3// for the Fast Light Tool Kit (FLTK).
4//
5// Copyright 2010-2022 by Bill Spitzak and others.
6//
7// This library is free software. Distribution and use rights are outlined in
8// the file "COPYING" which should have been included with this file. If this
9// file is missing or damaged, see the license at:
10//
11// https://www.fltk.org/COPYING.php
12//
13// Please see the following page on how to report bugs and issues:
14//
15// https://www.fltk.org/bugs.php
16//
17
23
27
28/* Class hierarchy
29 + Fl_System_Driver
30 | + Fl_Posix_System_Driver
31 | | + Fl_Unix_System_Driver
32 | | + Fl_Darwin_System_Driver
33 | + Fl_WinAPI_System_Driver
34 */
35
36#ifndef FL_SYSTEM_DRIVER_H
37#define FL_SYSTEM_DRIVER_H
38
39#include <FL/Fl.H>
40#include <FL/Fl_Export.H>
41#include <FL/filename.H>
42#include <FL/Fl_Preferences.H>
43#include <stdio.h>
44#include <stdlib.h>
45#include <stdarg.h>
46#include <string.h>
47#include <time.h>
48
49class Fl_File_Icon;
50class Fl_File_Browser;
51class Fl_Pixmap;
52class Fl_Widget;
53class Fl_Sys_Menu_Bar_Driver;
54
60class Fl_System_Driver {
61 friend class Fl;
62protected:
63 // implement once for each platform
64 static Fl_System_Driver *newSystemDriver();
65 Fl_System_Driver();
66 static bool awake_ring_empty();
67public:
68 virtual ~Fl_System_Driver();
69 static int command_key;
70 static int control_key;
71
72 // implement if the system adds unwanted program argument(s)
73 virtual int single_arg(const char *) { return 0; }
74 // implement if the system adds unwanted program argument pair(s)
75 virtual int arg_and_value(const char * /*name*/, const char * /*value*/) { return 0; }
76 static void warning(const char* format, ...);
77 // implement to set the default effect of Fl::warning()
78 virtual void warning(const char* format, va_list args);
79 static void error(const char* format, ...);
80 // implement to set the default effect of Fl::error()
81 virtual void error(const char* format, va_list args);
82 static void fatal(const char* format, ...);
83 // implement to set the default effect of Fl::error()
84 virtual void fatal(const char* format, va_list args);
85
86 // implement these to support cross-platform file operations
87 virtual char *utf2mbcs(const char *s) {return (char*)s;}
88 virtual char *getenv(const char*) {return NULL;}
89 virtual int putenv(const char *) {return -1;}
90 virtual int open(const char* /*f*/, int /*oflags*/, int /*pmode*/) {return -1;}
91
92 // implement these to support cross-platform string operations
93 virtual char *strdup(const char *) {return NULL;}
94
95 // Note: the default implementation ignores the 'binary' argument.
96 // Some platforms (notably Windows) may use this argument.
97 virtual int open_ext(const char* f, int /*binary*/, int oflags, int pmode) {
98 return this->open(f, oflags, pmode);
99 }
100 virtual FILE *fopen(const char* f, const char *mode);
101 virtual int system(const char*) {return -1;}
102 virtual int execvp(const char * /*file*/, char *const * /*argv*/) {return -1;}
103 virtual int chmod(const char* /*f*/, int /*mode*/) {return -1;}
104 virtual int access(const char* /*f*/, int /*mode*/) { return -1;}
105 virtual int flstat(const char* /*f*/, struct stat *) { return -1;}
106 virtual char *getcwd(char* /*b*/, int /*l*/) {return NULL;}
107 virtual int chdir(const char*) {return -1;}
108 virtual int unlink(const char*) {return -1;}
109 virtual int mkdir(const char* /*f*/, int /*mode*/) {return -1;}
110 virtual int rmdir(const char*) {return -1;}
111 virtual int rename(const char* /*f*/, const char * /*n*/) {return -1;}
112
113 // Windows commandline argument conversion to UTF-8.
114 // Default implementation: no-op, overridden only on Windows
115 virtual int args_to_utf8(int argc, char ** &argv) { return argc; }
116
117 // the default implementation of these utf8... functions should be enough
118 virtual unsigned utf8towc(const char* src, unsigned srclen, wchar_t* dst, unsigned dstlen);
119 virtual unsigned utf8fromwc(char* dst, unsigned dstlen, const wchar_t* src, unsigned srclen);
120 virtual int utf8locale() {return 1;}
121 virtual unsigned utf8to_mb(const char* src, unsigned srclen, char* dst, unsigned dstlen);
122 virtual unsigned utf8from_mb(char* dst, unsigned dstlen, const char* src, unsigned srclen);
123 // implement to shield fprintf() from locale changes in decimal point
124 virtual int clocale_vprintf(FILE *output, const char *format, va_list args);
125 virtual int clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args);
126 virtual int clocale_vsscanf(const char *input, const char *format, va_list args);
127 // implement scandir-like function
128 virtual int filename_list(const char * /*d*/, dirent ***,
129 int (* /*sort*/)(struct dirent **, struct dirent **),
130 char *errmsg=NULL, int errmsg_sz=0) {
131 (void)errmsg; (void)errmsg_sz;
132 return -1;
133 }
134 // the default implementation of filename_expand() may be enough
135 virtual int filename_expand(char *to, int tolen, const char *from);
136 // to implement
137 virtual const char *getpwnam(const char *) {return NULL;}
138 // the default implementation of filename_relative() is in src/filename_absolute.cxx and may be enough
139 virtual int filename_relative(char *to, int tolen, const char *from, const char *base);
140 // the default implementation of filename_absolute() is in src/filename_absolute.cxx and may be enough
141 virtual int filename_absolute(char *to, int tolen, const char *from, const char *base);
142 // the default implementation of filename_isdir() is in src/filename_isdir.cxx and may be enough
143 virtual int filename_isdir(const char* n);
144 // the default implementation of filename_isdir_quick() is in src/filename_isdir.cxx and may be enough
145 virtual int filename_isdir_quick(const char* n);
146 // the default implementation of filename_ext() is in src/filename_ext.cxx and may be enough
147 virtual const char *filename_ext(const char *buf);
148 // implement to support fl_filename_name()
149 virtual const char *filename_name(const char *buf) {return buf;}
150 // implement to support fl_open_uri()
151 virtual int open_uri(const char * /*uri*/, char * /*msg*/, int /*msglen*/) {return 0;}
152 // the default implementation of use_tooltip_timeout_condition() may be enough
153 virtual int use_tooltip_timeout_condition() {return 0;}
154 // the default implementation of use_recent_tooltip_fix() may be enough
155 virtual int use_recent_tooltip_fix() {return 0;}
156 // the default implementation of need_test_shortcut_extra() may be enough
157 virtual int need_test_shortcut_extra() {return 0;}
158 // implement to support Fl_File_Browser::load()
159 virtual int file_browser_load_filesystem(Fl_File_Browser *, char * /*filename*/, int /*lname*/, Fl_File_Icon *) {return 0;}
160 // the default implementation of file_browser_load_directory() should be enough
161 virtual int file_browser_load_directory(const char *directory, char *filename, size_t name_size,
162 dirent ***pfiles, Fl_File_Sort_F *sort,
163 char *errmsg=NULL, int errmsg_sz=0);
164 // implement to support Fl_Preferences
165 virtual void newUUID(char *uuidBuffer) { uuidBuffer[0] = 0; }
166 // implement to support Fl_Preferences
167 virtual char *preference_rootnode(Fl_Preferences *, Fl_Preferences::Root,
168 const char * /*vendor*/,
169 const char * /*application*/) {return NULL;}
170 // the default implementation of preferences_need_protection_check() may be enough
171 virtual int preferences_need_protection_check() {return 0;}
172 // implement to support Fl_Plugin_Manager::load()
173 virtual void *load(const char *) {return NULL;}
174 // the default implementation is most probably enough
175 virtual void png_extra_rgba_processing(unsigned char * /*array*/, int /*w*/, int /*h*/) {}
176 // the default implementation is most probably enough
177 virtual const char *next_dir_sep(const char *start) { return strchr(start, '/');}
178 // implement to support threading
179 virtual void awake(void*) {}
180 virtual int lock() {return 1;}
181 virtual void unlock() {}
182 virtual void* thread_message() {return NULL;}
183 // implement to support Fl_File_Icon
184 virtual int file_type(const char *filename);
185 // implement to return the user's home directory name
186 virtual const char *home_directory_name() { return ""; }
187 // the default implementation is most probably enough
188 virtual const char *filesystems_label() { return "File Systems"; }
189 // return TRUE means \ same as / in file names
190 virtual int backslash_as_slash() {return 0;}
191 // return TRUE means : indicates a drive letter in file names
192 virtual int colon_is_drive() {return 0;}
193 // return TRUE means that files whose name begins with dot are hidden
194 virtual int dot_file_hidden() {return 0;}
195 // return TRUE when file names are case insensitive
196 virtual int case_insensitive_filenames() {return 0;}
197 // the implementations of local_to_latin1() and latin1_to_local() are in fl_encoding_latin1.cxx
198 virtual const char *local_to_latin1(const char *t, int n);
199 virtual const char *latin1_to_local(const char *t, int n);
200 // the implementations of local_to_mac_roman() and mac_roman_to_local() are in fl_encoding_mac_roman.cxx
201 virtual const char *local_to_mac_roman(const char *t, int n);
202 virtual const char *mac_roman_to_local(const char *t, int n);
203 // draw default tree view expando button
204 virtual void tree_draw_expando_button(int x, int y, bool state, bool active);
205 // the default implementation of tree_connector_style() is in Fl_Tree_Prefs.cxx and can be enough
206 virtual int tree_connector_style();
207 virtual void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0);
208 virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
209 virtual void remove_fd(int, int when);
210 virtual void remove_fd(int);
211 // the default implementation of open_callback() may be enough
212 virtual void open_callback(void (*)(const char *));
213 // The default implementation may be enough.
214 virtual void gettime(time_t *sec, int *usec);
215 // The default implementation of the next 4 functions may be enough.
216 virtual const char *shift_name() { return "Shift"; }
217 virtual const char *meta_name() { return "Meta"; }
218 virtual const char *alt_name() { return "Alt"; }
219 virtual const char *control_name() { return "Ctrl"; }
220 virtual Fl_Sys_Menu_Bar_Driver *sys_menu_bar_driver() { return NULL; }
221 virtual void lock_ring() {}
222 virtual void unlock_ring() {}
223 virtual double wait(double); // must FL_OVERRIDE
224 virtual int ready() { return 0; } // must FL_OVERRIDE
225 virtual int close_fd(int) {return -1;} // to close a file descriptor
226};
227
228#endif // FL_SYSTEM_DRIVER_H
229
Fl.H
Fl static class.
Fl_File_Browser
The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons.
Definition Fl_File_Browser.H:37
Fl_File_Icon
The Fl_File_Icon class manages icon images that can be used as labels in other widgets and as icons i...
Definition Fl_File_Icon.H:45
Fl_Pixmap
The Fl_Pixmap class supports caching and drawing of colormap (pixmap) images, including transparency.
Definition Fl_Pixmap.H:36
Fl_Preferences::Root
Root
Define the scope of the preferences.
Definition Fl_Preferences.H:131
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:112
Fl::wait
static int wait()
Waits until "something happens" and then returns.
Definition Fl.cxx:672
Fl::args
static int args(int argc, char **argv, int &i, Fl_Args_Handler cb=0)
Parse command line switches using the cb argument handler.
Definition Fl_arg.cxx:276
Fl::system
static int system(const char *command)
Run a command line on the computer.
Definition Fl.cxx:2434
Fl::ready
static int ready()
This is similar to Fl::check() except this does not call Fl::flush() or any callbacks,...
Definition Fl.cxx:717
Fl::remove_fd
static void remove_fd(int, int when)
Removes a file descriptor handler.
Definition Fl.cxx:2241
Fl::add_fd
static void add_fd(int fd, int when, Fl_FD_Handler cb, void *=0)
Adds file descriptor fd to listen to.
Definition Fl.cxx:2228
Fl::args_to_utf8
static int args_to_utf8(int argc, char **&argv)
Convert Windows commandline arguments to UTF-8.
Definition Fl.cxx:2514
filename.H
File names and URI utility functions.
Fl_FD_Handler
void(* Fl_FD_Handler)(FL_SOCKET fd, void *data)
Signature of add_fd functions passed as parameters.
Definition Fl.H:109
Fl_File_Sort_F
int Fl_File_Sort_F(struct dirent **, struct dirent **)
File sorting function.
Definition filename.H:114
Fl::unlock
static void unlock()
The unlock() method releases the lock that was set using the lock() method.
Definition Fl_lock.cxx:204
Fl::thread_message
static void * thread_message()
The thread_message() method returns the last message that was sent from a child by the awake() method...
Definition Fl_lock.cxx:196
Fl::awake
static void awake(void *message=0)
Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that ...
Definition Fl_lock.cxx:192
Fl::lock
static int lock()
The lock() method blocks the current thread until it can safely access FLTK widgets and data.
Definition Fl_lock.cxx:200
Fl::x
static int x()
Returns the leftmost x coordinate of the main screen work area.
Definition screen_xywh.cxx:31
Fl::y
static int y()
Returns the topmost y coordinate of the main screen work area.
Definition screen_xywh.cxx:38
Fl::error
static void(* error)(const char *,...)
FLTK calls Fl::error() to output a normal error message.
Definition Fl.H:546
Fl::fatal
static void(* fatal)(const char *,...)
FLTK calls Fl::fatal() to output a fatal error message.
Definition Fl.H:563
Fl::warning
static void(* warning)(const char *,...)
FLTK calls Fl::warning() to output a warning message.
Definition Fl.H:531