9031
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2005 by Claus Gittinger
|
9045
|
3 |
All Rights Reserved
|
9031
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libbasic' }"
|
|
13 |
|
|
14 |
Object subclass:#PluginSupport
|
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'System-Support'
|
|
19 |
!
|
|
20 |
|
17845
|
21 |
Query subclass:#StartParameterQuery
|
|
22 |
instanceVariableNames:''
|
|
23 |
classVariableNames:''
|
|
24 |
poolDictionaries:''
|
|
25 |
privateIn:PluginSupport
|
|
26 |
!
|
|
27 |
|
9031
|
28 |
!PluginSupport class methodsFor:'documentation'!
|
|
29 |
|
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 2005 by Claus Gittinger
|
9045
|
33 |
All Rights Reserved
|
9031
|
34 |
|
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
!
|
|
43 |
|
|
44 |
documentation
|
|
45 |
"
|
17845
|
46 |
Provides support functions to run ST/X in an external (web-browser) window as a plugin.
|
9031
|
47 |
(actually, it could be started from any other application just the same...)
|
|
48 |
|
|
49 |
[author:]
|
17845
|
50 |
Claus Gittinger
|
9031
|
51 |
|
|
52 |
[see also:]
|
17845
|
53 |
Smalltalk
|
9031
|
54 |
"
|
|
55 |
! !
|
|
56 |
|
|
57 |
!PluginSupport class methodsFor:'startup'!
|
|
58 |
|
17845
|
59 |
embedView:aView inWindowWithID:windowID
|
|
60 |
"embed a view in the external (web-browser-) window"
|
9052
|
61 |
|
17845
|
62 |
|browserWindow|
|
9031
|
63 |
|
|
64 |
browserWindow := ExternalTopView newWithID:windowID.
|
|
65 |
browserWindow viewBackground:(Color red).
|
|
66 |
browserWindow clear.
|
9046
|
67 |
browserWindow width:self getBrowserWindowWidth.
|
|
68 |
browserWindow height:self getBrowserWindowHeight.
|
9031
|
69 |
|
17845
|
70 |
browserWindow becomeParentOf:aView.
|
|
71 |
self setPluginWindowHandle:(aView id).
|
|
72 |
!
|
|
73 |
|
|
74 |
showPluginWarning:message inWindowWithID:windowID
|
|
75 |
|messageView|
|
|
76 |
|
|
77 |
messageView := Label new.
|
|
78 |
messageView label:message.
|
|
79 |
self embedView:messageView inWindowWithID:windowID
|
9052
|
80 |
!
|
|
81 |
|
|
82 |
startClass:anApplicationClass inWindowWithID:windowID parameters:parameters
|
|
83 |
"open up a new instance of an application- or view-class in the external browserWindow"
|
|
84 |
|
17845
|
85 |
|applicationOrView view|
|
9052
|
86 |
|
17845
|
87 |
StartParameterQuery answer:parameters do:[
|
|
88 |
(anApplicationClass isSubclassOf:ApplicationModel) ifTrue:[
|
|
89 |
applicationOrView := anApplicationClass new.
|
|
90 |
applicationOrView allButOpen.
|
|
91 |
view := applicationOrView window.
|
|
92 |
] ifFalse:[
|
|
93 |
applicationOrView := anApplicationClass new.
|
|
94 |
(applicationOrView isKindOf:View) ifTrue:[
|
|
95 |
view := applicationOrView
|
|
96 |
] ifFalse:[
|
|
97 |
view := applicationOrView window.
|
|
98 |
].
|
|
99 |
].
|
9031
|
100 |
].
|
|
101 |
|
17845
|
102 |
self embedView:view inWindowWithID:windowID
|
9031
|
103 |
!
|
|
104 |
|
|
105 |
startInBrowserWithWindowID:windowID parameters:parameters
|
9052
|
106 |
"take application-info from the browser-parameters,
|
|
107 |
and open up a new instance of it in the external browserWindow"
|
|
108 |
|
9048
|
109 |
|appClassName appClass src|
|
|
110 |
|
17807
|
111 |
src := parameters at:'src' ifAbsent:nil.
|
|
112 |
src notNil ifTrue:[
|
|
113 |
"/ fetch this document from the browser...
|
|
114 |
self
|
|
115 |
showPluginWarning:'Cannot (yet) load Application code'
|
|
116 |
inWindowWithID:windowID.
|
|
117 |
].
|
|
118 |
|
9048
|
119 |
appClassName := parameters at:'application' ifAbsent:nil.
|
|
120 |
appClassName notNil ifTrue:[
|
|
121 |
appClass := Smalltalk classNamed:appClassName.
|
|
122 |
appClass notNil ifTrue:[
|
|
123 |
self
|
9052
|
124 |
startClass:appClass
|
9048
|
125 |
inWindowWithID:windowID
|
|
126 |
parameters:parameters.
|
|
127 |
^ self.
|
|
128 |
].
|
9052
|
129 |
self
|
|
130 |
showPluginWarning:'Missing Application Class: ', appClassName
|
|
131 |
inWindowWithID:windowID.
|
|
132 |
^ self.
|
9048
|
133 |
].
|
|
134 |
|
9045
|
135 |
self
|
17845
|
136 |
startClass:NewLauncher
|
9047
|
137 |
inWindowWithID:windowID
|
9048
|
138 |
parameters:parameters.
|
9037
|
139 |
|
|
140 |
"
|
9039
|
141 |
|v|
|
|
142 |
|
|
143 |
v := StandardSystemView new.
|
9040
|
144 |
v openAndWait.
|
17845
|
145 |
self startInBrowserWithWindowID:v id parameters:(Dictionary new).
|
9039
|
146 |
"
|
|
147 |
|
|
148 |
"
|
9037
|
149 |
|v app|
|
|
150 |
|
|
151 |
v := StandardSystemView new.
|
|
152 |
v create.
|
|
153 |
app := WorkspaceApplication new.
|
|
154 |
app window:v.
|
|
155 |
app allButOpen.
|
|
156 |
app openWindow.
|
|
157 |
"
|
17807
|
158 |
|
|
159 |
"Modified: / 14-09-2010 / 16:07:42 / cg"
|
9031
|
160 |
! !
|
|
161 |
|
9047
|
162 |
!PluginSupport class methodsFor:'support'!
|
|
163 |
|
|
164 |
getBrowserWindowHeight
|
|
165 |
%{
|
|
166 |
extern int __pluginGetBrowserWindowHeight();
|
|
167 |
|
|
168 |
RETURN (__mkSmallInteger(__pluginGetBrowserWindowHeight()));
|
|
169 |
%}.
|
|
170 |
!
|
|
171 |
|
|
172 |
getBrowserWindowWidth
|
|
173 |
%{
|
|
174 |
extern int __pluginGetBrowserWindowWidth();
|
|
175 |
|
|
176 |
RETURN (__mkSmallInteger(__pluginGetBrowserWindowWidth()));
|
|
177 |
%}.
|
|
178 |
!
|
|
179 |
|
|
180 |
setPluginWindowHandle:windowId
|
|
181 |
%{
|
|
182 |
extern void __pluginSetWindow();
|
|
183 |
# define HWND void *
|
|
184 |
|
|
185 |
if (__isExternalAddress(windowId)) {
|
17751
|
186 |
HWND hWnd = (HWND)__externalAddressVal(windowId);
|
|
187 |
__pluginSetWindow(hWnd);
|
9047
|
188 |
}
|
|
189 |
%}.
|
|
190 |
! !
|
|
191 |
|
9031
|
192 |
!PluginSupport class methodsFor:'documentation'!
|
|
193 |
|
17751
|
194 |
version_CVS
|
17845
|
195 |
^ '§Header: /cvs/stx/stx/libbasic/PluginSupport.st,v 1.15 2011/07/04 13:00:52 cg Exp §'
|
17865
|
196 |
!
|
|
197 |
|
|
198 |
version_SVN
|
|
199 |
^ '$Id: PluginSupport.st 10695 2011-09-28 19:07:49Z vranyj1 $'
|
17846
|
200 |
! !
|