author | Claus Gittinger <cg@exept.de> |
Mon, 26 Jul 2010 12:27:12 +0200 | |
changeset 12966 | 396518f8f526 |
parent 12676 | 18527baaa343 |
child 13059 | 4d63f8d1f57c |
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 |
||
107 |
appClassName := parameters at:'application' ifAbsent:nil. |
|
108 |
appClassName notNil ifTrue:[ |
|
109 |
appClass := Smalltalk classNamed:appClassName. |
|
110 |
appClass notNil ifTrue:[ |
|
111 |
self |
|
9052 | 112 |
startClass:appClass |
9048 | 113 |
inWindowWithID:windowID |
114 |
parameters:parameters. |
|
115 |
^ self. |
|
116 |
]. |
|
9052 | 117 |
self |
118 |
showPluginWarning:'Missing Application Class: ', appClassName |
|
119 |
inWindowWithID:windowID. |
|
120 |
^ self. |
|
9048 | 121 |
]. |
122 |
||
123 |
src := parameters at:'src' ifAbsent:nil. |
|
124 |
src notNil ifTrue:[ |
|
11260 | 125 |
self halt:'src argument expected'. |
9048 | 126 |
^ self. |
127 |
]. |
|
9047 | 128 |
|
9045 | 129 |
self |
9048 | 130 |
start:NewLauncher |
9047 | 131 |
inWindowWithID:windowID |
9048 | 132 |
parameters:parameters. |
9037 | 133 |
|
134 |
" |
|
9039 | 135 |
|v| |
136 |
||
137 |
v := StandardSystemView new. |
|
9040 | 138 |
v openAndWait. |
139 |
self startInBrowserWithWindowID:v id parameters:#(). |
|
9039 | 140 |
" |
141 |
||
142 |
" |
|
9037 | 143 |
|v app| |
144 |
||
145 |
v := StandardSystemView new. |
|
146 |
v create. |
|
147 |
app := WorkspaceApplication new. |
|
148 |
app window:v. |
|
149 |
app allButOpen. |
|
150 |
app openWindow. |
|
151 |
" |
|
9031 | 152 |
! ! |
153 |
||
9047 | 154 |
!PluginSupport class methodsFor:'support'! |
155 |
||
156 |
getBrowserWindowHeight |
|
157 |
%{ |
|
158 |
extern int __pluginGetBrowserWindowHeight(); |
|
159 |
||
160 |
RETURN (__mkSmallInteger(__pluginGetBrowserWindowHeight())); |
|
161 |
%}. |
|
162 |
! |
|
163 |
||
164 |
getBrowserWindowWidth |
|
165 |
%{ |
|
166 |
extern int __pluginGetBrowserWindowWidth(); |
|
167 |
||
168 |
RETURN (__mkSmallInteger(__pluginGetBrowserWindowWidth())); |
|
169 |
%}. |
|
170 |
! |
|
171 |
||
172 |
setPluginWindowHandle:windowId |
|
173 |
%{ |
|
174 |
extern void __pluginSetWindow(); |
|
175 |
# define HWND void * |
|
176 |
||
177 |
if (__isExternalAddress(windowId)) { |
|
12676
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
178 |
HWND hWnd = (HWND)__externalAddressVal(windowId); |
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
179 |
__pluginSetWindow(hWnd); |
9047 | 180 |
} |
181 |
%}. |
|
182 |
! ! |
|
183 |
||
9031 | 184 |
!PluginSupport class methodsFor:'documentation'! |
185 |
||
186 |
version |
|
12676
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
187 |
^ '$Header: /cvs/stx/stx/libbasic/PluginSupport.st,v 1.13 2010-02-01 18:20:21 stefan Exp $' |
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
188 |
! |
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
189 |
|
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
190 |
version_CVS |
18527baaa343
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
11260
diff
changeset
|
191 |
^ '$Header: /cvs/stx/stx/libbasic/PluginSupport.st,v 1.13 2010-02-01 18:20:21 stefan Exp $' |
9031 | 192 |
! ! |