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