JVM in widgets under Windows + Geogebra widget

preferencesAboutTextFull
Anatoly Mihalchenko 14 years ago
parent b4b5ecd86f
commit 25bf9810ee
  1. 12
      resources/library/interactive/Geogebra.wgt/config.xml
  2. BIN
      resources/library/interactive/Geogebra.wgt/icon.png
  3. BIN
      resources/library/interactive/Geogebra.wgt/images/loading.gif
  4. 71
      resources/library/interactive/Geogebra.wgt/index.html
  5. 43
      src/domain/UBAbstractWidget.cpp
  6. 25
      src/domain/UBAbstractWidget.h
  7. 13
      src/domain/UBGraphicsScene.cpp
  8. 50
      src/domain/UBW3CWidget.cpp
  9. 1
      src/gui/UBToolWidget.cpp

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:ub="http://uniboard.mnemis.com/widgets"
id="http://uniboard.mnemis.com/widgets/geogebra"
version="1.0"
width="800"
height="500"
ub:resizable="true"
ub:roles="tool cMAC cUNIX">
<name>Geogebra</name>
<content src="index.html"/>
</widget>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

@ -0,0 +1,71 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<BODY>
<DIV id=applet1></DIV>
<SCRIPT type=text/javascript>
function ggbOnInit()
{
alert("Geogebra applet is initialized");
}
var width=0;
var height=0;
setWidthHeight();
if (height < 500) height=500;
if (width < 800) width=800;
var applet1=document.getElementById('applet1');
applet1.innerHTML=geogebra_applet(0.95*width,height*0.95,"",true,true,true,false,true,true,true,true,true,true,true,true);
function geogebra_applet(width,height,filename,framePossible,enableRightClick,enableShiftDragZoom,showResetIcon,showMenuBar,showToolBar,showToolBarHelp,showAlgebraInput,enableLabelDrags,showSpreadsheet,showAlgebraView) {
ret = '<applet name="ggbApplet" code="geogebra.GeoGebraApplet" codebase="./bin/" archive="geogebra.jar" height="'+height+'" width="'+width+'">';
ret +='<param name="image" value="./images/loading.gif"/><param name="boxborder" value="false"/><param name="centerimage" value="true">';
ret +='<param name="java_arguments" value="-Xmx512m">';
if (filename != "") ret+='<param name="filename" value="'+filename+'">';
ret+='<param name="framePossible" value="'+framePossible+'">';
ret+='<param name="enableRightClick" value="'+enableRightClick+'">';
ret+='<param name="enableShiftDragZoom" value="'+enableShiftDragZoom+'">';
ret+='<param name="enableLabelDrags" value="'+enableLabelDrags+'">';
ret+='<param name="showSpreadsheet" value="'+showSpreadsheet+'">';
ret+='<param name="showAlgebraView" value="'+showAlgebraView+'">';
ret+='<param name="showResetIcon" value="'+showResetIcon+'">';
ret+='<param name="showMenuBar" value="'+showMenuBar+'">';
ret+='<param name="showToolBar" value="'+showToolBar+'">';
ret+='<param name="showToolBarHelp" value="'+showToolBarHelp+'">';
ret+='<param name="showAlgebraInput" value="'+showAlgebraInput+'">';
ret+='Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and activated.';
ret+='(<a href="http://java.sun.com/getjava">click here to install Java now</a>)';
ret+='</applet>';
return ret;
}
function setWidthHeight() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
//window.alert( 'Width = ' + myWidth );
//window.alert( 'Height = ' + myHeight );
width=myWidth;
height=myHeight;
}
</SCRIPT>
</BODY></HTML>

@ -44,8 +44,8 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
, mInitialLoadDone(false)
, mLoadIsErronous(false)
, mIsFreezable(true)
, mCanBeContent(true)
, mCanBeTool(true)
, mCanBeContent(0)
, mCanBeTool(0)
, mIsFrozen(false)
, mIsTakingSnapshot(false)
{
@ -74,12 +74,51 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
setMouseTracking(true);
}
bool UBAbstractWidget::canBeContent()
{
// if we under MAC OS
#if defined(Q_OS_MAC)
return mCanBeContent & OSType::type_MAC;
#endif
// if we under UNIX OS
#if defined(Q_OS_UNIX)
return mCanBeContent & OSType::type_UNIX;
#endif
// if we under WINDOWS OS
#if defined(Q_OS_WIN)
return mCanBeContent & OSType::type_WIN;
#endif
}
bool UBAbstractWidget::canBeTool()
{
// if we under MAC OS
#if defined(Q_OS_MAC)
return mCanBeTool & OSType::type_MAC;
#endif
// if we under UNIX OS
#if defined(Q_OS_UNIX)
return mCanBeTool & OSType::type_UNIX;
#endif
// if we under WINDOWS OS
#if defined(Q_OS_WIN)
return mCanBeTool & OSType::type_WIN;
#endif
}
UBAbstractWidget::~UBAbstractWidget()
{
// NOOP
}
void UBAbstractWidget::loadMainHtml()
{
QWebView::load(mMainHtmlUrl);
}
bool UBAbstractWidget::event(QEvent *event)
{

@ -39,6 +39,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0);
virtual ~UBAbstractWidget();
void loadMainHtml();
QUrl mainHtml()
{
return mMainHtmlUrl;
@ -64,15 +66,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
return mNominalSize;
}
bool canBeContent() const
{
return mCanBeContent;
}
bool canBeTool() const
{
return mCanBeTool;
}
bool canBeContent();
bool canBeTool();
bool hasLoadedSuccessfully() const
{
@ -123,8 +118,16 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
bool mLoadIsErronous;
bool mIsFreezable;
bool mCanBeContent;
bool mCanBeTool;
int mCanBeContent;
int mCanBeTool;
enum OSType
{
type_NONE = 0, // 0000
type_WIN = 1, // 0001
type_MAC = 2, // 0010
type_UNIX = 4, // 0100
type_ALL = 7, // 0111
};
virtual void injectInlineJavaScript();
virtual void paintEvent(QPaintEvent * event);

@ -1091,7 +1091,6 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
graphicsWidget->setFlag(QGraphicsItem::ItemIsSelectable, true);
graphicsWidget->setZValue(getNextObjectZIndex());
// QGraphicsScene::addWidget(graphicsWidget->widgetWebView());
addItem(graphicsWidget);
qreal ssf = 1 / UBApplication::boardController->systemScaleFactor();
@ -1103,21 +1102,13 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
if (graphicsWidget->widgetWebView()->canBeContent())
{
graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->setSelected(true);
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget);
UBApplication::undoStack->push(uc);
setDocumentUpdated();
// graphicsWidget->widgetWebView()->setParent(graphicsWidget->v));
// QObject *zz1= graphicsWidget->widgetWebView()->parent();
// QWidget *zz2= graphicsWidget->widgetWebView()->parentWidget();
//
// QObject *zz3= graphicsWidget->parent();
// QGraphicsWidget *zz4= graphicsWidget->parentWidget();
// graphicsWidget->widgetWebView()->loadUrl();
}
else
{

@ -86,8 +86,51 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
QString roles = widgetElement.attribute("ub:roles", "content tool").trimmed().toLower();
mCanBeTool = roles == "" || roles.contains("tool");
mCanBeContent = roles == "" || roles.contains("content");
//------------------------------//
if( roles == "" || roles.contains("tool") )
{
mCanBeTool = UBAbstractWidget::OSType::type_ALL;
}
if( roles.contains("twin") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_WIN;
}
if( roles.contains("tmac") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_MAC;
}
if( roles.contains("tunix") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_UNIX;
}
//---------//
if( roles == "" || roles.contains("content") )
{
mCanBeContent = UBAbstractWidget::OSType::type_ALL;
}
if( roles.contains("cwin") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_WIN;
}
if( roles.contains("cmac") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_MAC;
}
if( roles.contains("cunix") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_UNIX;
}
//------------------------------//
QDomNodeList contentDomList = widgetElement.elementsByTagName("content");
@ -159,8 +202,6 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared()));
QWebView::load(mMainHtmlUrl);
setFixedSize(QSize(width, height));
mNominalSize = QSize(width, height);
@ -171,7 +212,6 @@ UBW3CWidget::~UBW3CWidget()
// NOOP
}
void UBW3CWidget::javaScriptWindowObjectCleared()
{
UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), 0);

@ -72,6 +72,7 @@ UBToolWidget::UBToolWidget(UBAbstractWidget* pWidget, QWidget* pParent)
, mShouldMoveWidget(false)
{
mToolWidget->setParent(this);
mToolWidget->loadMainHtml();
initialize();

Loading…
Cancel
Save