OSXOperatingSystem.st
author Claus Gittinger <cg@exept.de>
Tue, 19 Jun 2018 14:50:06 +0200
changeset 23114 21306b85ca30
parent 22970 ff49ded84d3a
child 23314 1f3913819f30
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
     1
"{ Encoding: utf8 }"
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
     2
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     3
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     4
 COPYRIGHT (c) 2013 by Claus Gittinger
21455
a657a28cab85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21452
diff changeset
     5
	      All Rights Reserved
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     6
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     7
 This software is furnished under a license and may be used
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     8
 only in accordance with the terms of that license and with the
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    10
 be provided or otherwise made available to, or used by, any
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    11
 other person.  No title to or ownership of the software is
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    12
 hereby transferred.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    13
"
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    14
"{ Package: 'stx:libbasic' }"
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    15
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    16
"{ NameSpace: Smalltalk }"
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    18
UnixOperatingSystem subclass:#OSXOperatingSystem
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    19
	instanceVariableNames:''
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
    20
	classVariableNames:'NSApp'
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    21
	poolDictionaries:''
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    22
	category:'OS-Unix'
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    23
!
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    24
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    25
!OSXOperatingSystem primitiveDefinitions!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    26
%{
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    27
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    28
#ifdef __osx__
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    29
// mhm - how could they forget this????
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    30
# ifndef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    31
#  define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING(version)
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    32
# endif
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    33
#endif
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    34
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    35
#ifndef __osx__
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    36
# define NO_QUARTZ
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    37
# define NO_COCOA
22959
a88673d40f15 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22833
diff changeset
    38
# define NO_CARBON
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    39
#endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    40
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    41
// #include <mach/clock.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    42
// #include <mach/mach.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    43
// #include <sys/time.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    44
// #include <mach/clock.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    45
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    46
#ifndef NO_COCOA
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    47
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    48
#   undef Array
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    49
#   undef Number
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    50
#   undef Method
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    51
#   undef Point
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    52
#   undef Rectangle
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    53
#   undef Block
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    54
#   undef String
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    55
#   undef Character
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    56
#   undef Message
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    57
#   undef Object
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    58
#   undef Context
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    59
#   undef Time
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    60
#   undef Date
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    61
#   undef Set
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    62
#   undef Signal
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    63
#   undef Delay
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    64
#   undef NameSpace
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    65
#   undef Process
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    66
#   undef Processor
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    67
#   undef Class
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    68
#   undef FixedPoint
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    69
#   undef true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    70
#   undef false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    71
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    72
#   undef INT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    73
#   undef UINT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    74
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    75
# include <ApplicationServices/ApplicationServices.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    76
# include <CoreFoundation/CoreFoundation.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    77
// #include <Foundation/Foundation.h>
21595
10b14f01369b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21594
diff changeset
    78
10b14f01369b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21594
diff changeset
    79
// #include <CoreGraphics/CGEventTypes.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    80
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    81
# include <stdlib.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    82
# include <stdio.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    83
# include <IOKit/graphics/IOGraphicsLib.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    84
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    85
# include <objc/runtime.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    86
# include <objc/message.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    87
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    88
#  ifdef __DEF_Array
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    89
#   define Array __DEF_Array
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    90
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    91
#  ifdef __DEF_Number
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    92
#   define Number __DEF_Number
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    93
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    94
#  ifdef __DEF_Method
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    95
#   define Method __DEF_Method
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    96
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    97
#  ifdef __DEF_Point
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    98
#   define Point __DEF_Point
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    99
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   100
#  ifdef __DEF_Rectangle
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   101
#   define Rectangle __DEF_Rectangle
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   102
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   103
#  ifdef __DEF_Block
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   104
#   define Block __DEF_Block
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   105
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   106
#  ifdef __DEF_String
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   107
#   define String __DEF_String
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   108
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   109
#  ifdef __DEF_Character
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   110
#   define Character __DEF_Character
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   111
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   112
#  ifdef __DEF_Message
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   113
#   define Message __DEF_Message
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   114
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   115
#  ifdef __DEF_Object
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   116
#   define Object __DEF_Object
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   117
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   118
#  ifdef __DEF_Context
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   119
#   define Context __DEF_Context
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   120
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   121
#  ifdef __DEF_Date
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   122
#   define Date __DEF_Date
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   123
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   124
#  ifdef __DEF_Time
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   125
#   define Time __DEF_Time
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   126
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   127
#  ifdef __DEF_Set
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   128
#   define Set __DEF_Set
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   129
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   130
#  ifdef __DEF_Signal
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   131
#   define Signal __DEF_Signal
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   132
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   133
#  ifdef __DEF_Delay
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   134
#   define Delay __DEF_Delay
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   135
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   136
#  ifdef __DEF_NameSpace
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   137
#   define NameSpace __DEF_NameSpace
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   138
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   139
#  ifdef __DEF_Process
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   140
#   define Process __DEF_Process
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   141
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   142
#  ifdef __DEF_Processor
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   143
#   define Processor __DEF_Processor
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   144
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   145
#  ifdef __DEF_Class
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   146
#   define STX_Class __DEF_Class
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   147
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   148
#  ifdef __DEF_FixedPoint
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   149
#   define FixedPoint __DEF_FixedPoint
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   150
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   151
#  ifdef __DEF_true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   152
#   undef true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   153
#   define true __DEF_true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   154
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   155
#  ifdef __DEF_false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   156
#   undef false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   157
#   define false __DEF_false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   158
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   159
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   160
#  define INT STX_INT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   161
#  define UINT STX_UINT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   162
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   163
typedef struct CMPoint {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   164
	double x;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   165
	double y;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   166
} CMPoint;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   167
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   168
typedef struct CMSize {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   169
	double width;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   170
	double height;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   171
} CMSize;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   172
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   173
typedef struct CMRect {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   174
	CMPoint origin;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   175
	CMSize size;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   176
} CMRect;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   177
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   178
typedef struct AppDel {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   179
	Class isa;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   180
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   181
	// Will be an NSWindow later.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   182
	id window;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   183
} AppDelegate;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   184
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   185
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   186
enum {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   187
	NSBorderlessWindowMask          = 0,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   188
	NSTitledWindowMask                      = 1 << 0,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   189
	NSClosableWindowMask            = 1 << 1,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   190
	NSMiniaturizableWindowMask      = 1 << 2,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   191
	NSResizableWindowMask           = 1 << 3,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   192
};
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   193
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   194
typedef id(*CMacsSimpleMessage)(id, SEL);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   195
typedef void(*CMacsVoidMessage)(id, SEL);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   196
typedef void(*CMacsVoidMessage1)(id, SEL, void *);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   197
typedef id(*CMacsRectMessage1)(id, SEL, CMRect);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   198
typedef id(*CMacsWindowInitMessage)(id, SEL, CMRect, int, int, bool);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   199
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   200
extern CMacsSimpleMessage cmacs_simple_msgSend;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   201
extern CMacsVoidMessage cmacs_void_msgSend;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   202
extern CMacsVoidMessage1 cmacs_void_msgSend1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   203
extern CMacsRectMessage1 cmacs_rect_msgSend1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   204
extern CMacsWindowInitMessage cmacs_window_init_msgSend;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   205
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   206
#endif // NO_COCOA
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   207
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   208
%}
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   209
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   210
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   211
!OSXOperatingSystem primitiveFunctions!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   212
%{
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   213
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   214
#ifndef NO_COCOA
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   215
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   216
CGEventRef
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   217
myCGEventCallback(CGEventTapProxy proxy, CGEventType type,
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   218
		  CGEventRef event, void *refcon)
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   219
{
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   220
    // Paranoid sanity check.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   221
    if ((type != kCGEventKeyDown) && (type != kCGEventKeyUp))
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   222
	return event;
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   223
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   224
    // The incoming keycode.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   225
    CGKeyCode keycode = (CGKeyCode)CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   226
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   227
    //Keypress code goes here.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   228
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   229
    // We must return the event for it to be useful.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   230
    return event;
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   231
}
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   232
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   233
BOOL
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   234
AppDel_didFinishLaunching(AppDelegate *self, SEL _cmd, id notification) {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   235
//    self->window = cmacs_simple_msgSend((id)objc_getClass("NSWindow"), sel_getUid("alloc"));
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   236
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   237
//    /// Create an instance of the window.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   238
//    self->window = cmacs_window_init_msgSend(self->window, sel_getUid("initWithContentRect:styleMask:backing:defer:"), (CMRect){0,0,1024,460}, (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask), 0, false);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   239
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   240
//    /// Create an instance of our view class.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   241
//    ///
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   242
//    /// Relies on the view having declared a constructor that allocates a class pair for it.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   243
//    id view = cmacs_rect_msgSend1(cmacs_simple_msgSend((id)objc_getClass("View"), sel_getUid("alloc")), sel_getUid("initWithFrame:"), (CMRect){ 0, 0, 320, 480 });
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   244
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   245
//    // here we simply add the view to the window.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   246
//    cmacs_void_msgSend1(self->window, sel_getUid("setContentView:"), view);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   247
//    cmacs_simple_msgSend(self->window, sel_getUid("becomeFirstResponder"));
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   248
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   249
//    // Shows our window in the bottom-left hand corner of the screen.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   250
//    cmacs_void_msgSend1(self->window, sel_getUid("makeKeyAndOrderFront:"), self);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   251
    return YES;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   252
}
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   253
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   254
#endif // NO_COCOA
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   255
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   256
%}
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   257
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   258
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   259
!OSXOperatingSystem class methodsFor:'documentation'!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   260
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   261
copyright
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   262
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   263
 COPYRIGHT (c) 2013 by Claus Gittinger
21455
a657a28cab85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21452
diff changeset
   264
	      All Rights Reserved
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   265
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   266
 This software is furnished under a license and may be used
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   267
 only in accordance with the terms of that license and with the
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   268
 inclusion of the above copyright notice.   This software may not
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   269
 be provided or otherwise made available to, or used by, any
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   270
 other person.  No title to or ownership of the software is
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   271
 hereby transferred.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   272
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   273
!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   274
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   275
documentation
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   276
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   277
    a small number of OS-X specific redefinitions here.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   278
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   279
    [Author:]
21455
a657a28cab85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21452
diff changeset
   280
	Claus Gittinger
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   281
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   282
! !
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   283
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   284
!OSXOperatingSystem class methodsFor:'initialization'!
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   285
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   286
initializeCodeset
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   287
    super initializeCodeset.
17493
25361a7bc7e7 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17471
diff changeset
   288
    Codeset := #'utf8-mac'.
17494
4734c3c6fe43 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17493
diff changeset
   289
    CodesetEncoder := nil.
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   290
! !
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   292
!OSXOperatingSystem class methodsFor:'cocoa - events'!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   293
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   294
finishLaunching
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   295
    "tell the system, that I have finished my startup phase.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   296
     OSX will stop bounding the launch icon then."
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   297
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   298
    NSApp isNil ifTrue:[
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   299
	self getNSApp
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   300
    ].
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   301
%{
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   302
#ifndef NO_COCOA
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   303
    id NSApp = __externalAddressVal(@global(NSApp));
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   304
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   305
    objc_msgSend(NSApp, sel_getUid("finishLaunching"));
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   306
    RETURN(self);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   307
#endif // NO_COCOA
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   308
%}.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   309
    "/ if compiled without COCOA support (which you should not),
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   310
    "/ the icon will probably continue to bounce...
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   311
    "/ ... but we do not want an error here.
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   312
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   313
    "/ self primitiveFailed
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   314
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   315
    "
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   316
     self finishLaunching
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   317
    "
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   318
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   319
    "Modified: / 28-02-2017 / 10:59:15 / cg"
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   320
!
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   321
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   322
generateButtonEvent:button down:down x:screenX y:screenY
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   323
    "synthesize and send a button event to the screen"
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   324
%{
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   325
#ifndef NO_COCOA
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   326
    if (__bothSmallInteger(screenX, screenY)
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   327
     && __isSmallInteger(button)) {
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   328
	CGPoint pt;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   329
	pt.x = __intVal(screenX);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   330
	pt.y = __intVal(screenY);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   331
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   332
	CGEventType evType;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   333
	CGMouseButton evButton = __intVal(button);
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   334
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   335
	switch (evButton) {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   336
	    case 1:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   337
		evType = (down == true) ? kCGEventLeftMouseDown : kCGEventLeftMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   338
		evButton = 0;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   339
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   340
	    case 2:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   341
		evType = (down == true) ? kCGEventRightMouseDown : kCGEventRightMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   342
		evButton = 1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   343
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   344
	    case 3:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   345
		evType = (down == true) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   346
		evButton = 2;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   347
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   348
	    default:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   349
		evType = (down == true) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   350
		evButton = __intVal(button) - 1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   351
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   352
	}
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   353
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   354
	CGEventRef theEvent = CGEventCreateMouseEvent(NULL, evType, pt, evButton);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   355
	CGEventSetType(theEvent, evType);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   356
	CGEventPost(kCGHIDEventTap, theEvent);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   357
	CFRelease(theEvent);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   358
	RETURN(self);
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   359
    }
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   360
#endif // NO_COCOA
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   361
%}.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   362
    self primitiveFailed
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   363
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   364
    "
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   365
     OperatingSystem generateButtonEvent:1 down:true x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   366
     OperatingSystem generateButtonEvent:1 down:false x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   367
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   368
     OperatingSystem generateButtonEvent:2 down:true x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   369
     OperatingSystem generateButtonEvent:2 down:false x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   370
    "
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   371
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   372
    "Created: / 28-02-2017 / 00:15:18 / cg"
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   373
!
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   374
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   375
generateKeyboardEvent:keyCode down:down
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   376
    "synthesize and send a keyboard event to the screen"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   377
%{
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   378
#ifndef NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   379
    if (__isSmallInteger(keyCode)) {
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   380
	int evType;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   381
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   382
	CGEventRef theEvent = CGEventCreateKeyboardEvent(NULL, __intVal(keyCode), (down==true)?1:0);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   383
	CGEventSetType(theEvent, (down==true) ? kCGEventKeyDown:kCGEventKeyUp);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   384
	CGEventPost(kCGHIDEventTap, theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   385
	CFRelease(theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   386
	RETURN(self);
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   387
    }
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   388
#endif // NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   389
%}.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   390
    self primitiveFailed
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   391
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   392
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   393
     OperatingSystem generateKeyboardEvent:6 down:true.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   394
     OperatingSystem generateKeyboardEvent:6 down:false.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   395
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   396
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   397
    "Created: / 02-03-2017 / 16:35:04 / cg"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   398
!
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   399
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   400
generateMouseMoveEventX:screenX y:screenY
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   401
    "synthesize and send a mosue move event to the screen"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   402
%{
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   403
#ifndef NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   404
    if (__bothSmallInteger(screenX, screenY)) {
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   405
	CGPoint pt;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   406
	pt.x = __intVal(screenX);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   407
	pt.y = __intVal(screenY);
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   408
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   409
	CGEventType evType;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   410
	CGEventRef theEvent = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pt, 0);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   411
	CGEventSetType(theEvent, kCGEventMouseMoved);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   412
	CGEventPost(kCGHIDEventTap, theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   413
	CFRelease(theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   414
	RETURN(self);
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   415
    }
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   416
#endif // NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   417
%}.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   418
    self primitiveFailed
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   419
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   420
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   421
     OperatingSystem generateMouseMoveEventX:150 y:5.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   422
     Delay waitFor:(1 seconds).
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   423
     OperatingSystem generateMouseMoveEventX:1050 y:150.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   424
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   425
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   426
    "Created: / 02-03-2017 / 20:01:51 / cg"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   427
!
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   428
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   429
getNSApp
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   430
    "get the NSApplication instance and remember in the global named NSApp"
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   431
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   432
%{
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   433
#ifndef NO_COCOA
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   434
    Class AppDelClass = NULL;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   435
    id NSApp = NULL;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   436
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   437
# if 0 /* not needed */
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   438
    Class poolClass = objc_getClass("NSAutoreleasePool");
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   439
    if (poolClass == NULL) {
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   440
	fprintf(stderr, "OSX: Unable to get NSAutoreleasePool\n");
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   441
	RETURN(false);
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   442
    }
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   443
    id pool = objc_msgSend(poolClass, sel_registerName("alloc"));
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   444
    if (pool == NULL) {
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   445
	fprintf(stderr, "OSX: Unable to create NSAutoreleasePool\n");
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   446
	RETURN(false);
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   447
    }
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   448
    objc_msgSend(pool, sel_registerName("init"));
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   449
# endif
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   450
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   451
# if 0 /* not needed */
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   452
    AppDelClass = objc_allocateClassPair((Class)objc_getClass("NSObject"), "AppDelegate", 0);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   453
    class_addMethod(AppDelClass, sel_getUid("applicationDidFinishLaunching:"), (IMP)AppDel_didFinishLaunching, "i@:@");
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   454
    objc_registerClassPair(AppDelClass);
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   455
# endif
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   456
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   457
    NSApp = objc_msgSend((id)objc_getClass("NSApplication"), sel_getUid("sharedApplication"));
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   458
    if (NSApp == NULL) {
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   459
	fprintf(stderr,"OSX: Failed to initialize NSApplication\n");
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   460
	RETURN(false);
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   461
    }
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   462
    @global(NSApp) = __MKEXTERNALADDRESS(NSApp);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   463
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   464
    id req = objc_msgSend(NSApp,sel_getUid("requestUserAttention:"),0);
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   465
    objc_msgSend(NSApp,sel_getUid("cancelUserAttentionRequest:"),req);
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   466
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   467
# if 0 /* not needed */
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   468
    id appDelInst = objc_msgSend((id)objc_getClass("AppDelegate"), sel_getUid("alloc"));
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   469
    objc_msgSend(appDelInst, sel_getUid("init"));
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   470
    objc_msgSend(NSApp, sel_getUid("setDelegate:"), appDelInst);
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   471
# endif
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   472
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   473
# if 0 /* not needed */
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   474
    objc_msgSend(pool, sel_registerName("release"));
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   475
# endif
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   476
    RETURN(true);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   477
#endif // NO_COCOA
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   478
%}.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   479
    self primitiveFailed
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   480
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   481
    "
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   482
     self getNSApp
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   483
    "
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   484
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   485
    "Modified: / 28-02-2017 / 13:45:39 / cg"
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   486
!
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   487
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   488
receiveNextEvent
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   489
%{
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   490
#ifndef NO_COCOA
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   491
    CFMachPortRef      eventTap;
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   492
    CGEventMask        eventMask;
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   493
    CFRunLoopSourceRef runLoopSource;
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   494
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   495
    // Create an event tap. We are interested in key presses.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   496
    eventMask = ((1 << kCGEventKeyDown) | (1 << kCGEventKeyUp));
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   497
    eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0,
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   498
				eventMask, NULL, myCGEventCallback);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   499
    if (!eventTap) {
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   500
	fprintf(stderr, "failed to create event tap\n");
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   501
    } else {
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   502
	fprintf(stderr, "ok\n");
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   503
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   504
	// Create a run loop source.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   505
	runLoopSource = CFMachPortCreateRunLoopSource( kCFAllocatorDefault, eventTap, 0);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   506
	// Enable the event tap.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   507
	CGEventTapEnable(eventTap, true);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   508
    }
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   509
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   510
#endif // NO_COCOA
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   511
%}.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   512
    self primitiveFailed
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   513
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   514
    "Modified: / 28-02-2017 / 01:05:04 / cg"
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   515
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   516
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   517
!OSXOperatingSystem class methodsFor:'dummy shell operations'!
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   518
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   519
openApplicationForDocument:aFilenameOrString operation:operationSymbol
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   520
    "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   521
     This is typically used to present help-files, html documents, pdf documents etc.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   522
     operationSymbol is one of:
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   523
	open
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   524
	edit
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   525
	explore
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   526
    "
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   527
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   528
    |openCmd|
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   529
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   530
    (openCmd := self openApplicationHelperCommand) notNil ifTrue:[
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   531
	(operationSymbol = 'open') ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   532
	    self executeCommand:'open "',aFilenameOrString asFilename pathName,'"'
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   533
	] ifFalse:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   534
	    (operationSymbol = 'explore') ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   535
		self executeCommand:'open -R "',aFilenameOrString asFilename pathName,'"'
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   536
	    ].
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   537
	].
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   538
    ].
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   539
!
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   540
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   541
openApplicationHelperCommand
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   542
    "Return a command line helper to open a default application for file or URL"
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   543
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   544
    (self canExecuteCommand: 'open') ifTrue:[
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   545
	^ 'open'
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   546
    ].
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   547
    ^ nil
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   548
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   549
    "Created: / 13-01-2015 / 09:23:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   550
!
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   551
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   552
openTerminalWithCommand:shellCommand inBackground:inBackground
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   553
    "open a new terminal, which executes a command"
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   554
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   555
    |cmd|
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   556
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   557
    cmd := 'osascript -e ''tell application "Terminal" to do script "%1"''' bindWith:shellCommand.
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   558
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   559
    inBackground ifTrue:[
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   560
	^ self
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   561
	    startProcess:cmd
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   562
	    inputFrom:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   563
	    outputTo:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   564
	    errorTo:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   565
	    auxFrom:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   566
	    environment:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   567
	    inDirectory:nil
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   568
    ] ifFalse:[
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   569
	^ self executeCommand:cmd
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   570
    ].
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   571
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   572
    "
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   573
     OSXOperatingSystem openTerminalWithCommand:'ls -l' inBackground:true
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   574
    "
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   575
! !
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   576
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
!OSXOperatingSystem class methodsFor:'file queries'!
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
caseSensitiveFilenames
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
    "return true, if the OS has caseSensitive file naming.
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
     On MSDOS, this will return false;
19817
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
   582
     on a real OS, we return true.
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
   583
     Be aware, that OSX can be configured to be either.
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
   584
     Also, that it actually depends on the mounted volume"
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   586
    "/ actually, this is wrong and depends on the mounted volume;
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   587
    "/ so we need a query for a particular directory (and/or volume).
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
    ^ false
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
    "Modified: / 5.6.1998 / 18:35:18 / cg"
16381
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   591
!
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   592
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   593
defaultPackagePath
20639
3bf77812174f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20637
diff changeset
   594
    "redefined to add /Application and /Library stuff"
20642
56c52db3521a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20639
diff changeset
   595
    "called by Smalltalk initSystemPath"
56c52db3521a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20639
diff changeset
   596
    "self defaultPackagePath"
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   597
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   598
    |path executablePath executableDir packagesDir
20637
a9b41f05ca91 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19817
diff changeset
   599
     libDir appDir versionsDir vsnDirName vsnDir|
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   600
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   601
    path := super defaultPackagePath.
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   602
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   603
    executablePath := OperatingSystem pathOfSTXExecutable.
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   604
    executablePath notNil ifTrue:[
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   605
	executableDir := executablePath asFilename directory.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   606
	packagesDir := executableDir directory directory / 'Packages'.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   607
	packagesDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   608
	    packagesDir := packagesDir pathName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   609
	    (path includes:packagesDir) ifFalse:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   610
		path add:packagesDir.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   611
	    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   612
	].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   613
	libDir := '/Library/Frameworks/SmalltalkX.framework' asFilename.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   614
	libDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   615
	    versionsDir := libDir / 'Versions'.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   616
	    versionsDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   617
		vsnDirName := '%1.%2.%3'
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   618
				    bindWith:Smalltalk majorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   619
				    with:Smalltalk minorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   620
				    with:Smalltalk revisionNr.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   621
		vsnDir := versionsDir / vsnDirName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   622
		vsnDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   623
		    vsnDir := vsnDir pathName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   624
		    (path includes:vsnDir) ifFalse:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   625
			path add:vsnDir.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   626
		    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   627
		].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   628
	    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   629
	].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   630
	appDir := '/Applications/SmalltalkX/' asFilename.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   631
	appDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   632
	    versionsDir := appDir / 'Versions'.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   633
	    versionsDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   634
		vsnDirName := '%1.%2.%3'
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   635
				    bindWith:Smalltalk majorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   636
				    with:Smalltalk minorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   637
				    with:Smalltalk revisionNr.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   638
		vsnDir := versionsDir / vsnDirName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   639
		vsnDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   640
		    vsnDir := vsnDir pathName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   641
		    (path includes:vsnDir) ifFalse:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   642
			path add:vsnDir.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   643
		    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   644
		].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   645
	    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   646
	].
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   647
    ].
16647
4c196996c402 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16644
diff changeset
   648
    ^ path
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   649
!
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   650
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   651
getDocumentsDirectory
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   652
    "return your documents directory.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   653
     Under osx, that's the user's 'Documents' folder.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   654
     The fallback for other OS's may return the user's home directory."
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   656
    "{ Pragma: +optSpace }"
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   657
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   658
    |home documentsFolder|
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   659
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   660
    (home := self getHomeDirectory) notNil ifTrue:[
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   661
	(documentsFolder := home asFilename / 'Documents') exists ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   662
	    ^ documentsFolder pathName
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   663
	].
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   664
    ].
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   665
    ^ home
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   666
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   667
    "
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   668
     OperatingSystem getDocumentsDirectory
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   669
    "
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   670
!
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   671
16677
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   672
getDriveList
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   673
    "return a list of volumes in the system."
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   674
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   675
    ^ ('/Volumes' asFilename directoryContents)
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   676
      , super getDriveList
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   677
!
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   678
16381
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   679
getTrashDirectory
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   680
    "get the name of a trash folder (if the OS supports it),
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   681
     or nil, if not.
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   682
     Must be redefined to return non nil in concrete operating systems"
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   683
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   684
    ^ '~/.Trash'
16677
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   685
!
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   686
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   687
pathNameForDrive:driveName
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   688
    "given a drive name, return the pathname to open it as a directory.
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   689
     For Windows, this is the driveName itself.
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   690
     For OSX, '/Volumes' is prepended.
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   691
     Other OSs might prepent the pount point (i.e. /mnt/)"
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   692
16905
46653de3c189 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16677
diff changeset
   693
    driveName isNil ifTrue:[^ nil].
16677
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   694
    driveName asFilename isAbsolute ifTrue:[^ driveName].
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   695
    ^ '/Volumes/',driveName
17177
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   696
!
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   697
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   698
supportsVolumes
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   699
    "return true if the os support a list of drives/volumes
17179
d12edae8391b class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17177
diff changeset
   700
     (here we can return a list of mounted drives in /Volumes)"
17177
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   701
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   702
    ^ true
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
! !
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   705
!OSXOperatingSystem class methodsFor:'quartz - screen'!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   706
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   707
getFrameBufferImage:displayNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   708
    "returns the framebuffer as an image object"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   709
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   710
    ^ self getFrameBufferImage:displayNr in:nil
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   711
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   712
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   713
     self getFrameBufferImage:0
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   714
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   715
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   716
    "Modified: / 25-02-2017 / 10:57:17 / cg"
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   717
!
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   718
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   719
getFrameBufferImage:displayNr in:aRectangleOrNil
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   720
    "returns the frameBuffer (if rect-arg is nil)
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   721
     or part of the framebuffer (if non-nil) as an image object"
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   722
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   723
    |rx ry rwidth rheight bytesPerPixel bytesPerRow address pixels depth pad img ok|
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   724
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   725
    aRectangleOrNil notNil ifTrue:[
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   726
	rx := aRectangleOrNil left.
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   727
	ry := aRectangleOrNil top.
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   728
	rwidth := aRectangleOrNil width.
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   729
	rheight := aRectangleOrNil height.
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   730
    ].
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   731
%{
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   732
#ifndef NO_COCOA
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   733
    CGImageRef image_ref;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   734
    CGDirectDisplayID displayID = CGMainDisplayID();
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   735
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   736
    ok = false;
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   737
    if (rx == nil) {
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   738
	image_ref  = CGDisplayCreateImage(displayID);
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   739
    } else {
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   740
	CGRect rect;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   741
	rect.origin.x = (CGFloat)__intVal(rx);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   742
	rect.origin.y = (CGFloat)__intVal(ry);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   743
	rect.size.width = (CGFloat)__intVal(rwidth);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   744
	rect.size.height = (CGFloat)__intVal(rheight);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   745
	image_ref  = CGDisplayCreateImageForRect(displayID, rect);
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   746
    }
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   747
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   748
    if (image_ref != NULL) {
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   749
	CGDataProviderRef provider = CGImageGetDataProvider(image_ref);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   750
	CFDataRef dataref = CGDataProviderCopyData(provider);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   751
	size_t c_width = CGImageGetWidth(image_ref);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   752
	size_t c_height = CGImageGetHeight(image_ref);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   753
	size_t c_bytesPerRow = CGImageGetBytesPerRow(image_ref);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   754
	size_t c_bytesPerPixel = CGImageGetBitsPerPixel(image_ref) / 8;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   755
	unsigned char *c_pixels = (unsigned char *)CFDataGetBytePtr(dataref);
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   756
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   757
	if (c_bytesPerPixel == 4) {
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   758
	    int row;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   759
	    pixels = __BYTEARRAY_UNINITIALIZED_NEW_INT(c_width * c_height * 3);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   760
	    unsigned char *srcRowPtr = c_pixels;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   761
	    unsigned char *dstRowPtr = __byteArrayVal(pixels);
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   762
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   763
	    for (row=c_height; row>0; row--) {
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   764
		int col;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   765
		unsigned int *pixSrcPtr = (int*)srcRowPtr;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   766
		unsigned char *pixDstPtr = dstRowPtr;
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   767
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   768
		// swap abgr to argb
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   769
		for (col=c_width; col>0;col--) {
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   770
		    unsigned int pix = *pixSrcPtr++;
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   771
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   772
		    pix = ((pix >> 16) & 0x0000FF)|((pix << 16) & 0xFF0000)|(pix & 0x00FF00);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   773
		    pixDstPtr[0] = (pix >> 0);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   774
		    pixDstPtr[1] = (pix >> 8);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   775
		    pixDstPtr[2] = (pix >> 16);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   776
		    pixDstPtr += 3;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   777
		}
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   778
		dstRowPtr += c_width * 3;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   779
		srcRowPtr += c_bytesPerRow;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   780
	    }
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   781
	    bytesPerPixel = __MKSMALLINT(3);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   782
	    bytesPerRow = __MKSMALLINT( c_width*3 );
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   783
	    ok = true;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   784
	} else {
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   785
	    // to be determined what we get...
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   786
	    ok = false;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   787
	}
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   788
	CFRelease(dataref);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   789
	CGImageRelease(image_ref);
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   790
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   791
	rwidth = __MKUINT( c_width );
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   792
	rheight = __MKUINT( c_height );
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   793
    }
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   794
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   795
    // the following is no longer supported by apple
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   796
    // CGDisplayBaseAddress is deprecated
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   797
    //
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   798
    //    uint32_t rowBytes, rowUInt32s, *screen;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   799
    //
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   800
    //    CGDirectDisplayID targetDisplay = 0;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   801
    //
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   802
    //    screen = (uint32_t *)CGDisplayBaseAddress(targetDisplay);
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   803
    //    rowBytes = CGDisplayBytesPerRow(targetDisplay);
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   804
    //    rowUInt32s = rowBytes / 4;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   805
    //    rwidth = __MKUINT( CGDisplayPixelsWide(targetDisplay) );
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   806
    //    rheight = __MKUINT( CGDisplayPixelsHigh(targetDisplay) );
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   807
    //
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   808
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   809
#endif // NO_COCOA
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   810
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   811
%}.
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   812
    (ok not or:[rwidth isNil]) ifTrue:[
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   813
	^ self primitiveFailed
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   814
    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   815
    depth := bytesPerPixel * 8.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   816
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   817
    "/ Transcript printf:'w:%d h:%d bpp:%d depth:%d bpr: %d\n'
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   818
    "/            withAll:{ rwidth . rheight . bytesPerPixel . depth . bytesPerRow}.
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   819
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   820
    ( #(24) includes:depth) ifFalse:[
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   821
	"/ check what we get here...
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   822
	^ self primitiveFailed:'unsupported depth'
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   823
    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   824
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   825
    img := Image extent:(rwidth @ rheight) depth:depth bits:pixels.
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   826
    depth == 24 ifTrue:[
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   827
	img bitsPerSample:#[8 8 8].
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   828
	img samplesPerPixel:3.
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   829
	img photometric:#rgb.
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   830
    ] ifFalse:[
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   831
	depth == 16 ifTrue:[
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   832
	    "/ to be determined...
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   833
	    img bitsPerSample:#[5 5 5].
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   834
	    img samplesPerPixel:3.
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   835
	    img photometric:#rgb.
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   836
	].
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   837
    ].
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   838
    ^ img
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   839
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   840
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   841
     self getFrameBufferImage:0 in:nil
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   842
     self getFrameBufferImage:0 in:(100@100 corner:301@303)
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   843
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   844
     Delay waitFor:3 seconds. self getFrameBufferImage:0 in:nil
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   845
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   846
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   847
    "Created: / 25-02-2017 / 09:49:07 / cg"
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   848
    "Modified (comment): / 28-02-2017 / 15:22:17 / cg"
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   849
!
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   850
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   851
getScreenBounds:displayNr
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   852
    "returns the bounds of the screen.
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   853
     This is needed, because the dimension of the XQuartz screen does not include the dock."
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   854
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   855
    |rx ry rwidth rheight|
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   856
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   857
%{
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   858
#ifndef NO_COCOA
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   859
    CGDirectDisplayID targetDisplay = 0;
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   860
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   861
    rx = ry = __MKSMALLINT(0);
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   862
    rwidth = __MKUINT( CGDisplayPixelsWide(targetDisplay) );
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   863
    rheight = __MKUINT( CGDisplayPixelsHigh(targetDisplay) );
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   864
#endif // NO_COCOA
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   865
%}.
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   866
    (rwidth isNil) ifTrue:[
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   867
	^ self primitiveFailed
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   868
    ].
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   869
    ^ rx@ry extent:(rwidth@rheight)
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   870
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   871
    "
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   872
     self getScreenBounds:0
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   873
    "
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   874
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   875
    "Created: / 05-03-2017 / 11:10:08 / cg"
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   876
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   877
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   878
!OSXOperatingSystem class methodsFor:'sound & voice'!
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   879
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   880
playSound:soundFile
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   881
    "use 'say ...'"
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   882
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   883
    ^ self executeCommand:('afplay "%1"' bindWith:soundFile asFilename pathName)
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   884
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   885
    "
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   886
     self speak:'hello world'
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   887
    "
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   888
!
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   889
22970
ff49ded84d3a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22966
diff changeset
   890
voiceCommandSpec
ff49ded84d3a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22966
diff changeset
   891
    ^ #(
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   892
	"/ triples are:
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   893
	"/      -command
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   894
	"/      -commandline for default voice
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   895
	"/      -commandline for specific voice
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   896
	(
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   897
	    'say'
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   898
		'say "%2"'
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   899
		'say -v "%1" "%2"'
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   900
	)
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   901
    )
22966
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   902
!
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   903
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   904
voiceInfo
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   905
    "return a list of available voices plus info:
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   906
     for each available voice, a triple is returned, containing:
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   907
	voiceName language_territory comment/description
22966
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   908
    "
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   909
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   910
    ^ (PipeStream outputFromCommand:'say -v ?')
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   911
	asCollectionOfLines
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   912
	    collect:[:l |
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   913
		|s name lang comment|
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   914
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   915
		s := l readStream.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   916
		"/ skip forward for two separators
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   917
		[
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   918
		    [s next isLetterOrDigit] whileTrue:[].
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   919
		    s peek isLetterOrDigit
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   920
		] whileTrue.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   921
		name := l copyFrom:1 to:s position - 1.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   922
		s skipSeparators.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   923
		lang := s upToSeparator.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   924
		s skipSeparators.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   925
		s next == $# ifTrue:[
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   926
		    s skipSeparators.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   927
		    comment := s upToEnd utf8Decoded.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   928
		].
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   929
		{ name . lang . comment }
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   930
	    ]
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   931
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   932
    "
22966
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   933
     OperatingSystem voiceInfo
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   934
    "
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   935
! !
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   936
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   937
!OSXOperatingSystem class methodsFor:'time and date'!
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   938
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   939
getOSTimeWithNanos
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   940
    "This returns the OS time as a 2-element vector with milliseconds (as before)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   941
     plus nanoseconds.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   942
     The base of the returned value is not consistent across
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   943
     different OS's - some return the number of nanoseconds since jan, 1st 1970;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   944
     others since 1900. The Time classes are prepared for this, and
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   945
     convert as appropriate (by using my fromOSTime: conversion methods).
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   946
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   947
     Don't use this method in application code since it is an internal (private)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   948
     interface. For compatibility use instances of Time, Date or Timestamp to work with."
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   949
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   950
    |seconds millis nanos|
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   951
%{
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   952
// all of the experiments below only return 1us resolution
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   953
// on my machine. Not sure if that has to do with the OSX version (high sierra)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   954
// therefore, it is disabled, and we fall back to the inherited method,
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   955
// which returns microsecond resolution nanos anyway.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   956
#if 0
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   957
    unsigned long _secs, _millis, _nanos;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   958
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   959
# if defined(CLOCK_REALTIME) && !defined(NO_CLOCK_GETTIME)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   960
    struct timespec ts;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   961
    static int has_clock_gettime = 1;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   962
    unsigned long _secs, _millis, _nanos;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   963
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   964
    if (has_clock_gettime) {
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   965
	if (clock_gettime(CLOCK_REALTIME, &ts) != -1) {
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   966
	    _secs = ts.tv_sec;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   967
	    _millis = ts.tv_nsec / 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   968
	    _nanos = ts.tv_nsec % 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   969
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   970
	    seconds = __MKUINT(_secs);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   971
	    millis = __MKUINT(_millis);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   972
	    nanos = __MKUINT(_nanos);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   973
	} else {
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   974
	    /*
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   975
	     * clock_gettime is not implemented in the kernel
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   976
	     * fall through to alternative implementation
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   977
	     */
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   978
	    has_clock_gettime = 0;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   979
	}
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   980
    }
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   981
# else
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   982
#  if 0
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   983
    // althoug documented, my osx doesn't have it...
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   984
    uint32_t secpart;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   985
    uint32_t nsecpart;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   986
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   987
    clock_get_calendar_nanotime(&secpart, &nsecpart);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   988
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   989
    _secs = secpart;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   990
    _millis = nsecpart / 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   991
    _nanos = nsecpart % 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   992
#  else
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   993
    // OS X does not have clock_gettime, use host_get_clock_service
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   994
    clock_serv_t cclock;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   995
    mach_timespec_t mts;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   996
    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   997
    clock_get_time(cclock, &mts);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   998
    mach_port_deallocate(mach_task_self(), cclock);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   999
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1000
    _secs = mts.tv_sec;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1001
    _millis = mts.tv_nsec / 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1002
    _nanos = mts.tv_nsec % 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1003
#  endif
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1004
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1005
    seconds = __MKUINT(_secs);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1006
    millis = __MKUINT(_millis);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1007
    nanos = __MKUINT(_nanos);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1008
# endif
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1009
#endif
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1010
%}.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1011
    seconds notNil ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1012
	^ { ((seconds * 1000) + millis) . nanos }
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1013
    ].
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1014
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1015
    ^ super getOSTimeWithNanos.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1016
! !
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1017
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
!OSXOperatingSystem class methodsFor:'documentation'!
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
version
19817
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
  1021
    ^ '$Header$'
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
!
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
version_CVS
19817
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
  1025
    ^ '$Header$'
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
! !