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