"
COPYRIGHT (c) 2005 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libbasic' }"
Object subclass:#PluginSupport
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'System-Support'
!
!PluginSupport class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2005 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
Provides support functions to run stx in a browser window as a plugin.
(actually, it could be started from any other application just the same...)
[author:]
Claus Gittinger
[see also:]
Smalltalk
"
! !
!PluginSupport class methodsFor:'startup'!
showPluginWarning:message inWindowWithID:windowID
|messageView|
messageView := Label new.
messageView label:message.
self
start:messageView
inWindowWithID:windowID
parameters:#()
!
start:anApplicationOrView inWindowWithID:windowID parameters:parameters
"open up an application or view in the external browserWindow"
|v browserWindow|
browserWindow := ExternalTopView newWithID:windowID.
browserWindow viewBackground:(Color red).
browserWindow clear.
browserWindow width:self getBrowserWindowWidth.
browserWindow height:self getBrowserWindowHeight.
(anApplicationOrView isKindOf:ApplicationModel) ifTrue:[
v := anApplicationOrView window.
] ifFalse:[
v := anApplicationOrView.
].
browserWindow becomeParentOf:v.
self setPluginWindowHandle:(v id).
!
startClass:anApplicationClass inWindowWithID:windowID parameters:parameters
"open up a new instance of an application- or view-class in the external browserWindow"
|applicationOrView|
(anApplicationClass isSubclassOf:ApplicationModel) ifTrue:[
applicationOrView := anApplicationClass new.
applicationOrView allButOpen.
] ifFalse:[
applicationOrView := anApplicationClass new.
].
self
start:applicationOrView
inWindowWithID:windowID
parameters:parameters
!
startInBrowserWithWindowID:windowID parameters:parameters
"take application-info from the browser-parameters,
and open up a new instance of it in the external browserWindow"
|appClassName appClass src|
appClassName := parameters at:'application' ifAbsent:nil.
appClassName notNil ifTrue:[
appClass := Smalltalk classNamed:appClassName.
appClass notNil ifTrue:[
self
startClass:appClass
inWindowWithID:windowID
parameters:parameters.
^ self.
].
self
showPluginWarning:'Missing Application Class: ', appClassName
inWindowWithID:windowID.
^ self.
].
src := parameters at:'src' ifAbsent:nil.
src notNil ifTrue:[
self halt:'src argument expected'.
^ self.
].
self
start:NewLauncher
inWindowWithID:windowID
parameters:parameters.
"
|v|
v := StandardSystemView new.
v openAndWait.
self startInBrowserWithWindowID:v id parameters:#().
"
"
|v app|
v := StandardSystemView new.
v create.
app := WorkspaceApplication new.
app window:v.
app allButOpen.
app openWindow.
"
! !
!PluginSupport class methodsFor:'support'!
getBrowserWindowHeight
%{
extern int __pluginGetBrowserWindowHeight();
RETURN (__mkSmallInteger(__pluginGetBrowserWindowHeight()));
%}.
!
getBrowserWindowWidth
%{
extern int __pluginGetBrowserWindowWidth();
RETURN (__mkSmallInteger(__pluginGetBrowserWindowWidth()));
%}.
!
setPluginWindowHandle:windowId
%{
extern void __pluginSetWindow();
# define HWND void *
# define _HWNDVal(o) (HWND)(__MKCP(o))
if (__isExternalAddress(windowId)) {
HWND hWnd = _HWNDVal(windowId);
__pluginSetWindow(hWnd);
}
%}.
! !
!PluginSupport class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libbasic/PluginSupport.st,v 1.12 2008-10-21 22:20:11 cg Exp $'
! !