author | Claus Gittinger <cg@exept.de> |
Mon, 16 Dec 2019 16:00:23 +0100 | |
changeset 25135 | 98f799af1e48 |
parent 14299 | d9b1c2cc3779 |
child 18011 | deb0c3355881 |
permissions | -rw-r--r-- |
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 |
||
13490 | 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 |
" |
|
13490 | 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:] |
|
13490 | 50 |
Claus Gittinger |
9031 | 51 |
|
52 |
[see also:] |
|
13490 | 53 |
Smalltalk |
9031 | 54 |
" |
55 |
! ! |
|
56 |
||
57 |
!PluginSupport class methodsFor:'startup'! |
|
58 |
||
13490 | 59 |
embedView:aView inWindowWithID:windowID |
60 |
"embed a view in the external (web-browser-) window" |
|
9052 | 61 |
|
13490 | 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 |
|
13490 | 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 |
||
13490 | 85 |
|applicationOrView view| |
9052 | 86 |
|
13490 | 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. |
|
14299
d9b1c2cc3779
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
13490
diff
changeset
|
94 |
applicationOrView isView ifTrue:[ |
13490 | 95 |
view := applicationOrView |
96 |
] ifFalse:[ |
|
97 |
view := applicationOrView window. |
|
98 |
]. |
|
99 |
]. |
|
9031 | 100 |
]. |
101 |
||
13490 | 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 |
||
13059
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
111 |
src := parameters at:'src' ifAbsent:nil. |
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
112 |
src notNil ifTrue:[ |
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
113 |
"/ fetch this document from the browser... |
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
114 |
self |
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
115 |
showPluginWarning:'Cannot (yet) load Application code' |
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
116 |
inWindowWithID:windowID. |
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
117 |
]. |
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
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 |
13490 | 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. |
13490 | 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 |
" |
|
13059
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
158 |
|
4d63f8d1f57c
changed: #startInBrowserWithWindowID:parameters:
Claus Gittinger <cg@exept.de>
parents:
12676
diff
changeset
|
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)) { |
|
12676
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
186 |
HWND hWnd = (HWND)__externalAddressVal(windowId); |
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
187 |
__pluginSetWindow(hWnd); |
9047 | 188 |
} |
189 |
%}. |
|
190 |
! ! |
|
191 |
||
9031 | 192 |
!PluginSupport class methodsFor:'documentation'! |
193 |
||
12676
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
194 |
version_CVS |
14299
d9b1c2cc3779
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
13490
diff
changeset
|
195 |
^ '$Header: /cvs/stx/stx/libbasic/PluginSupport.st,v 1.16 2012-08-03 20:26:00 stefan Exp $' |
9031 | 196 |
! ! |