1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
//
// "$Id$"
//
// Definition of Apple Darwin system driver.
//
// Copyright 1998-2016 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#include "../../config_lib.h"
#include "Fl_Darwin_System_Driver.H"
#include <FL/Fl.H>
#include <FL/x.H>
#include <string.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
#include <xlocale.h>
#else
#include <locale.h>
#endif
#include <stdio.h>
#include <dlfcn.h>
int Fl_X::next_marked_length = 0;
//const char* fl_local_alt = "\xe2\x8c\xa5\\"; // U+2325 (option key)
const char* fl_local_alt = "⌥\\"; // U+2325 (option key)
//const char* fl_local_ctrl = "\xe2\x8c\x83\\"; // U+2303 (up arrowhead)
const char* fl_local_ctrl = "⌃\\"; // U+2303 (up arrowhead)
//const char* fl_local_meta = "\xe2\x8c\x98\\"; // U+2318 (place of interest sign)
const char* fl_local_meta = "⌘\\"; // U+2318 (place of interest sign)
//const char* fl_local_shift = "\xe2\x87\xa7\\"; // U+21E7 (upwards white arrow)
const char* fl_local_shift = "⇧\\"; // U+21E7 (upwards white arrow)
/**
Creates a driver that manages all screen and display related calls.
This function must be implemented once for every platform.
*/
Fl_System_Driver *Fl_System_Driver::newSystemDriver()
{
return new Fl_Darwin_System_Driver();
}
Fl_Darwin_System_Driver::Fl_Darwin_System_Driver() {
if (fl_mac_os_version == 0) fl_mac_os_version = Fl_X::calc_mac_os_version();
}
int Fl_Darwin_System_Driver::single_arg(const char *arg) {
// The Finder application in MacOS X passes the "-psn_N_NNNNN" option to all apps.
return (strncmp(arg, "psn_", 4) == 0);
}
int Fl_Darwin_System_Driver::arg_and_value(const char *name, const char *value) {
// Xcode in MacOS X may pass "-NSDocumentRevisionsDebugMode YES"
return strcmp(name, "NSDocumentRevisionsDebugMode") == 0;
}
int Fl_Darwin_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if (fl_mac_os_version >= 100400) {
static locale_t postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0);
return vfprintf_l(output, postscript_locale, format, args);
}
#endif
char *saved_locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
int retval = vfprintf(output, format, args);
setlocale(LC_NUMERIC, saved_locale);
return retval;
}
/* Returns the address of a Carbon function after dynamically loading the Carbon library if needed.
Supports old Mac OS X versions that may use a couple of Carbon calls:
GetKeys used by OS X 10.3 or before (in Fl::get_key())
PMSessionPageSetupDialog and PMSessionPrintDialog used by 10.4 or before (in Fl_Printer::start_job())
*/
void *Fl_Darwin_System_Driver::get_carbon_function(const char *function_name) {
static void *carbon = dlopen("/System/Library/Frameworks/Carbon.framework/Carbon", RTLD_LAZY);
return (carbon ? dlsym(carbon, function_name) : NULL);
}
//
// End of "$Id$".
//
|