[SCRIPTER]

* BUG: Make it compile again.

[GB.QT4.WEBKIT]
* NEW: WebFrame is a new class that recursively describes WebView frames.
* NEW: WebView.Frame is a new property that returns the WebView main frame.
* NEW: WebView.Current is a new property that returns the WebView current
  frame.


git-svn-id: svn://localhost/gambas/trunk@2159 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2009-07-24 13:05:24 +00:00
parent e9b2023b8e
commit a510b0b4d1
16 changed files with 257 additions and 16 deletions

View file

@ -850,7 +850,7 @@ Private Sub Signal()
Try FDebugExpr.RefreshAll
FMain.Show
'FMain.Show
'Command("e", TRUE)

View file

@ -1,13 +1,13 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r1601)
# Compiled with Gambas 2.99.0 (r2152)
Title=gbs2
Startup=MMain
Icon=icon.png
Version=2.99.90
Version=2.99.0
VersionProgram=gbx3 -V
Component=gb.eval
Description=Gambas Script
Authors=Fabien Bodard, Benoit Minisini
Description="Gambas Script"
Authors="Fabien Bodard, Benoit Minisini"
Arguments="/home/fabien/Desktop/ram.g"
TabSize=2
KeepDebugInfo=1

View file

@ -42,14 +42,14 @@ SearchComment=False
SearchString=True
[OpenFile]
Active=1
File[1]="MMain.module:0.0"
File[1]="/home/benoit/gambas/3.0/trunk/app/src/gbs3/.src/MMain.module:0.0"
Fold[1]=[]
File[2]="CComponent.class:169.37"
File[2]="/home/benoit/gambas/3.0/trunk/app/src/gbs3/.src/CComponent.class:169.37"
Fold[2]=[]
File[3]="MServerPage.module:134.0"
Active=3
File[3]="/home/benoit/gambas/3.0/trunk/app/src/gbs3/.src/MServerPage.module:14.19"
Fold[3]=[]
File[4]="helptext:8.11"
File[4]="/home/benoit/gambas/3.0/trunk/app/src/gbs3/helptext:8.11"
Count=4
[Watches]

View file

@ -12,7 +12,7 @@ Private Sub PrintHTML(sStr As String)
If $iLenPrint > 32000 Then $bLastPrint = False
If Not $bLastPrint Then
$iLenPrint = Len(sStr)
Print #$hOut "PRINT ";
Print #$hOut, "PRINT ";
Else
Print #$hOut, " ";
Endif

View file

@ -79,11 +79,19 @@ End
Public Sub WebView_Load()
Dim iInd As Integer
GetView().Status = ""
If Not IsLastCurrentView() Then Return
lblStatus.Text = ""
txtURL.Text = GetView().Url
pgbLoad.Hide
' Debug GetView().Frame
' For iInd = 0 To GetView().Frame.Children.Count - 1
' Debug "["; iInd; "] "; GetView().Frame.Children[iInd]
' Next
End
@ -157,6 +165,7 @@ End
Public Sub WebView_Icon()
Dim hView As WebView = Last
Debug
tabBrowser[hView.Tag].Picture = hView.Icon
If Not IsLastCurrentView() Then Return
Me.Icon = hView.Icon

View file

@ -126,6 +126,8 @@ typedef
bool (*Notify)(void *, bool);
void *(*GetDrawInterface)();
int (*Alignment)(int, int, bool);
void (*Link)(QObject *, void *);
void *(*GetLink)(QObject *);
void *_null;
}
QT_INTERFACE;

View file

@ -135,6 +135,8 @@ static bool _check_quit_posted = false;
static void (*_x11_event_filter)(XEvent *) = 0;
#endif
static QHash<void *, void *> _link_map;
//static MyApplication *myApp;
/***************************************************************************
@ -834,6 +836,26 @@ static void *QT_GetDrawInterface()
return (void *)&DRAW_Interface;
}
void MyApplication::linkDestroyed(QObject *qobject)
{
void *object = _link_map.value(qobject, 0);
_link_map.remove(qobject);
if (object)
GB.Unref(POINTER(&object));
}
void QT_Link(QObject *qobject, void *object)
{
_link_map.insert(qobject, object);
QObject::connect(qobject, SIGNAL(destroyed(QObject *)), qApp, SLOT(linkDestroyed(QObject *)));
GB.Ref(object);
}
void *QT_GetLink(QObject *qobject)
{
return _link_map.value(qobject, 0);
}
extern "C" {
GB_DESC *GB_CLASSES[] EXPORT =
@ -897,6 +919,8 @@ void *GB_QT4_1[] EXPORT = {
(void *)QT_Notify,
(void *)QT_GetDrawInterface,
(void *)CCONST_alignment,
(void *)QT_Link,
(void *)QT_GetLink,
NULL
};

View file

@ -79,6 +79,10 @@ public:
static void setTooltipEnabled(bool b);
static QEventLoop *eventLoop;
public slots:
void linkDestroyed(QObject *);
private:
static bool _tooltip_disable;
@ -114,5 +118,7 @@ const char *QT_ToUTF8(const QString &str);
void QT_RegisterAction(void *object, const char *key, int on);
void QT_RaiseAction(const char *key);
void *QT_GetObject(QWidget *);
void QT_Link(QObject *, void *);
void *QT_GetLink(QObject *);
#endif

View file

@ -11,4 +11,5 @@ gb_qt4_webkit_la_LDFLAGS = -module @LD_FLAGS@ @QTWEBKIT_LDFLAGS@
gb_qt4_webkit_la_SOURCES = \
main.h main.cpp \
cwebframe.h cwebframe.cpp cwebframe_moc.cpp \
cwebview.h cwebview.cpp cwebview_moc.cpp

View file

@ -0,0 +1,125 @@
/***************************************************************************
cwebframe.cpp
(c) 2000-2009 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#define __CWEBFRAME_CPP
#include <QUrl>
#include <QWebPage>
#include <QWebFrame>
#include "cwebframe.h"
CWEBFRAME *CWEBFRAME_get(QWebFrame *frame)
{
void *_object;
if (!frame) return 0;
_object = QT.GetLink(frame);
if (!_object)
{
GB.New(POINTER(&_object), GB.FindClass("WebFrame"), 0, 0);
//qDebug("create WebFrame %p", _object);
QT.Link(frame, _object);
THIS->frame = frame;
}
return (CWEBFRAME *)_object;
}
BEGIN_METHOD_VOID(WebFrame_free)
//qDebug("WebFrame_free: %p", THIS);
END_METHOD
BEGIN_PROPERTY(WebFrame_Name)
GB.ReturnNewZeroString(TO_UTF8(FRAME->frameName()));
END_PROPERTY
BEGIN_PROPERTY(WebFrame_Parent)
GB.ReturnObject(CWEBFRAME_get(FRAME->parentFrame()));
END_PROPERTY
BEGIN_PROPERTY(WebFrame_Url)
if (READ_PROPERTY)
GB.ReturnNewZeroString(TO_UTF8(FRAME->url().toString()));
else
FRAME->setUrl(QUrl(QSTRING_PROP()));
END_PROPERTY
BEGIN_PROPERTY(WebFrameChildren_Count)
GB.ReturnInteger(FRAME->childFrames().count());
END_PROPERTY
BEGIN_METHOD(WebFrameChildren_get, GB_INTEGER index)
int index = VARG(index);
QList<QWebFrame *> children = FRAME->childFrames();
if (index < 0 || index >= children.count())
{
GB.Error(GB_ERR_BOUND);
return;
}
GB.ReturnObject(CWEBFRAME_get(children.at(index)));
END_METHOD
GB_DESC CWebFrameChildrenDesc[] =
{
GB_DECLARE(".WebFrameChildren", sizeof(CWEBFRAME)), GB_VIRTUAL_CLASS(),
GB_PROPERTY_READ("Count", "i", WebFrameChildren_Count),
GB_METHOD("_get", "WebFrame", WebFrameChildren_get, "(Index)i"),
GB_END_DECLARE
};
GB_DESC CWebFrameDesc[] =
{
GB_DECLARE("WebFrame", sizeof(CWEBFRAME)),
GB_METHOD("_free", NULL, WebFrame_free, NULL),
GB_PROPERTY_READ("Name", "s", WebFrame_Name),
GB_PROPERTY_SELF("Children", ".WebFrameChildren"),
GB_PROPERTY_READ("Parent", "WebFrame", WebFrame_Parent),
GB_PROPERTY("Url", "s", WebFrame_Url),
GB_END_DECLARE
};
/***************************************************************************/

View file

@ -0,0 +1,54 @@
/***************************************************************************
cwebframe.h
(c) 2000-2009 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#ifndef __CWEBFRAME_H
#define __CWEBFRAME_H
#include "main.h"
#include <QUrl>
#include <QWebFrame>
#include <QWebPage>
#ifndef __CWEBFRAME_CPP
extern GB_DESC CWebFrameChildrenDesc[];
extern GB_DESC CWebFrameDesc[];
#else
#define THIS ((CWEBFRAME *)_object)
#define FRAME (THIS->frame)
#endif
typedef
struct
{
GB_BASE ob;
QWebFrame *frame;
}
CWEBFRAME;
CWEBFRAME *CWEBFRAME_get(QWebFrame *frame);
#endif

View file

@ -26,6 +26,7 @@
#include <QWebPage>
#include <QWebFrame>
#include "cwebframe.h"
#include "cwebview.h"
DECLARE_EVENT(EVENT_CLICK);
@ -62,6 +63,7 @@ END_METHOD
BEGIN_METHOD_VOID(WebView_free)
GB.FreeString(&THIS->status);
GB.Unref(POINTER(&THIS->icon));
END_METHOD
@ -88,11 +90,7 @@ END_PROPERTY
BEGIN_PROPERTY(WebView_Icon)
QIcon icon = WIDGET->icon();
if (icon.isNull())
GB.ReturnNull();
else
GB.ReturnObject(QT.CreatePicture(icon.pixmap(32, 32)));
GB.ReturnObject(THIS->icon);
END_PROPERTY
@ -176,6 +174,18 @@ BEGIN_PROPERTY(WebView_Status)
END_PROPERTY
BEGIN_PROPERTY(WebView_Frame)
GB.ReturnObject(CWEBFRAME_get(WIDGET->page()->mainFrame()));
END_PROPERTY
BEGIN_PROPERTY(WebView_Current)
GB.ReturnObject(CWEBFRAME_get(WIDGET->page()->currentFrame()));
END_PROPERTY
GB_DESC CWebViewDesc[] =
{
GB_DECLARE("WebView", sizeof(CWEBVIEW)), GB_INHERITS("Control"),
@ -199,6 +209,9 @@ GB_DESC CWebViewDesc[] =
GB_PROPERTY("TextZoom", "f", WebView_TextZoom),
GB_PROPERTY_READ("Title", "s", WebView_Title),
GB_PROPERTY_READ("Frame", "WebFrame", WebView_Frame),
GB_PROPERTY_READ("Current", "WebFrame", WebView_Current),
GB_METHOD("Back", NULL, WebView_Back, NULL),
GB_METHOD("Forward", NULL, WebView_Forward, NULL),
GB_METHOD("Reload", NULL, WebView_Reload, NULL),
@ -251,6 +264,9 @@ CWebView CWebView::manager;
void CWebView::iconChanged()
{
GET_SENDER();
QIcon icon = WIDGET->icon();
GB.Unref(POINTER(&THIS->icon));
THIS->icon = QT.CreatePicture(icon.pixmap(32, 32));
GB.Raise(THIS, EVENT_ICON, 0);
}

View file

@ -59,6 +59,7 @@ typedef
void *new_view;
double progress;
char *status;
QT_PICTURE icon;
}
CWEBVIEW;

View file

@ -27,6 +27,7 @@
#include <stdarg.h>
#include <string.h>
#include "cwebframe.h"
#include "cwebview.h"
#include "main.h"
@ -37,6 +38,8 @@ QT_INTERFACE QT;
GB_DESC *GB_CLASSES[] EXPORT =
{
CWebFrameChildrenDesc,
CWebFrameDesc,
CWebViewDesc,
NULL
};