File: MacintoshUtils.tcl

package info (click to toggle)
coccinella 0.96.20-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 13,184 kB
  • sloc: tcl: 124,744; xml: 206; makefile: 66; sh: 62
file content (130 lines) | stat: -rw-r--r-- 3,361 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#  MacintoshUtils.tcl ---
#  
#      This file is part of The Coccinella application. It implements things
#      that are mac only, like a glue to mac only packages.
#      
#  Copyright (c) 2002  Mats Bengtsson
#  
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#   
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#  
# $Id: MacintoshUtils.tcl,v 1.15 2008-05-08 12:24:01 matben Exp $

package provide MacintoshUtils 1.0

namespace eval ::Mac:: {

}

namespace eval ::Mac::Printer:: {

}

proc ::Mac::Printer::PageSetup {w} {
    ::Mac::MacCarbonPrint::PageSetup $w
}

proc ::Mac::Printer::Print {w} {
    ::Mac::MacCarbonPrint::PrintCanvas $w
}

namespace eval ::Mac::MacCarbonPrint:: {
    
}

proc ::Mac::MacCarbonPrint::PageSetup {w} {
    global  prefs this
    variable cache
        
    if {$this(package,MacCarbonPrint)} {
	set pageFormat [maccarbonprint::pagesetup -parent $w]
	if {$pageFormat ne ""} {
	    set cache($w,pageFormat) $pageFormat
	}
    } else {
	::UI::MessageBox -icon error -title [mc "Error"] \
	  -message [mc "Cannot find necessary Tcl extension."]
    }
}

proc ::Mac::MacCarbonPrint::PrintCanvas {w} {
    global  prefs this
    variable cache

    set wcan [::WB::GetCanvasFromWtop $w]

    if {$this(package,MacCarbonPrint)} {
	set opts [list -parent $w]
	if {[info exists cache($w,pageFormat)]} {
	    lappend opts -pageformat $cache($w,pageFormat)
	}
	set ans [eval {maccarbonprint::print} $opts]
	if {$ans ne ""} {
	    lassign $ans type printObject
	    eval {maccarbonprint::printcanvas $wcan $printObject}
	}
    } else {
	::UI::MessageBox -icon error -title [mc "Error"] \
	  -message [mc "Cannot find necessary Tcl extension."]
    }	    
}

proc ::Mac::MacCarbonPrint::PrintText {wtext args} {
    global  prefs this
    variable cache
    
    set w [winfo toplevel $wtext]

    if {$this(package,MacCarbonPrint)} {
	set opts [list -parent $w]
	if {[info exists cache($w,pageFormat)]} {
	    lappend opts -pageformat $cache($w,pageFormat)
	}
	set ans [eval {maccarbonprint::print} $opts]
	if {$ans ne ""} {
	    lassign $ans type printObject
	    eval {maccarbonprint::easytextprint $wtext $printObject} $args
	}
    } else {
	::UI::MessageBox -icon error -title [mc "Error"] \
	  -message [mc "Cannot find necessary Tcl extension."]
    }	    
}

# Synthetic Speech .............................................................
# Important: version 2.0 only

namespace eval ::Mac::Speech:: {

}

proc ::Mac::Speech::Init { } {
        
}

proc ::Mac::Speech::Speak {msg {theVoice {}}} {
        
    if {$theVoice eq ""} {
	speech::speak $msg
    } else {
	speech::speak $msg -voice $theVoice
    }
}

proc ::Mac::Speech::GetVoices { } {

    return [speech::speakers]
}

#-------------------------------------------------------------------------------