Initial import of wxWebKitCtrl sources and htmlctrl (right now wxWebKit) sample.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27349 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2004-05-19 02:20:53 +00:00
parent a1ae1090ee
commit 2c990ba6d4
5 changed files with 892 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
# =========================================================================
# This makefile was generated by
# Bakefile 0.1.4 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
@MAKE_SET@
prefix = @prefix@
exec_prefix = @exec_prefix@
INSTALL = @INSTALL@
EXEEXT = @EXEEXT@
RESCOMP = @RESCOMP@
SETFILE = @SETFILE@
NM = @NM@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
LDFLAGS_GUI = @LDFLAGS_GUI@
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
TOOLKIT = @TOOLKIT@
TOOLKIT_LOWERCASE = @TOOLKIT_LOWERCASE@
TOOLKIT_VERSION = @TOOLKIT_VERSION@
TOOLCHAIN_NAME = @TOOLCHAIN_NAME@
EXTRALIBS = @EXTRALIBS@
EXTRALIBS_GUI = @EXTRALIBS_GUI@
HOST_SUFFIX = @HOST_SUFFIX@
SAMPLES_RPATH_FLAG = @SAMPLES_RPATH_FLAG@
SAMPLES_RPATH_POSTLINK = @SAMPLES_RPATH_POSTLINK@
### Variables: ###
DESTDIR =
WX_VERSION = 2.5.1
LIBDIRNAME = $(top_builddir)lib
HTMLCTRL_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) -I$(srcdir) \
$(__DLLFLAG_p) -I$(srcdir)/../../../samples $(CPPFLAGS) $(CXXFLAGS)
HTMLCTRL_OBJECTS = \
$(__htmlctrl___win32rc) \
$(__htmlctrl_os2_lib_res) \
htmlctrl_htmlctrl.o
### Conditionally set variables: ###
@COND_DEPS_TRACKING_0@CXXC = $(CXX)
@COND_DEPS_TRACKING_1@CXXC = $(top_builddir)./bk-deps $(CXX)
@COND_USE_GUI_0@PORTNAME = base
@COND_USE_GUI_1@PORTNAME = $(TOOLKIT_LOWERCASE)$(TOOLKIT_VERSION)
@COND_TOOLKIT_MAC@WXBASEPORT = _carbon
@COND_BUILD_DEBUG_DEBUG_FLAG_DEFAULT@WXDEBUGFLAG = d
@COND_DEBUG_FLAG_1@WXDEBUGFLAG = d
@COND_UNICODE_1@WXUNICODEFLAG = u
@COND_WXUNIV_1@WXUNIVNAME = univ
@COND_PLATFORM_MAC_1@__htmlctrl___mac_setfilecmd = \
@COND_PLATFORM_MAC_1@ $(SETFILE) -a C htmlctrl$(EXEEXT)
@COND_PLATFORM_MAC_1@__htmlctrl___mac_rezcmd = $(__MACOSX_RESOURCES_p_1)
@COND_WXUNIV_1@__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
@COND_WXUNIV_1@__WXUNIV_DEFINE_p_1 = -d __WXUNIVERSAL__
@COND_WXUNIV_1@__WXUNIV_DEFINE_p_2 = --define __WXUNIVERSAL__
@COND_SHARED_1@__DLLFLAG_p = -DWXUSINGDLL
@COND_SHARED_1@__DLLFLAG_p_1 = -d WXUSINGDLL
@COND_SHARED_1@__DLLFLAG_p_2 = --define WXUSINGDLL
COND_PLATFORM_OS2_1___htmlctrl___os2_emxbindcmd = $(NM) htmlctrl$(EXEEXT) | if \
grep -q pmwin.763 ; then emxbind -ep htmlctrl$(EXEEXT) ; fi
@COND_PLATFORM_OS2_1@__htmlctrl___os2_emxbindcmd = $(COND_PLATFORM_OS2_1___htmlctrl___os2_emxbindcmd)
@COND_PLATFORM_WIN32_1@__htmlctrl___win32rc = htmlctrl_sample_rc.o
@COND_PLATFORM_OS2_1@__htmlctrl_os2_lib_res = \
@COND_PLATFORM_OS2_1@ $(top_srcdir)/include/wx/os2/wx.res
@COND_PLATFORM_MACOSX_1@__htmlctrl_bundle___depname = htmlctrl_bundle
@COND_TOOLKIT_COCOA@____htmlctrl_BUNDLE_TGT_REF_DEP = \
@COND_TOOLKIT_COCOA@ htmlctrl.app/Contents/PkgInfo
@COND_TOOLKIT_MAC@____htmlctrl_BUNDLE_TGT_REF_DEP = \
@COND_TOOLKIT_MAC@ htmlctrl.app/Contents/PkgInfo
COND_MONOLITHIC_0___WXLIB_CORE_p = \
-lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)_core-2.5$(HOST_SUFFIX)
@COND_MONOLITHIC_0@__WXLIB_CORE_p = $(COND_MONOLITHIC_0___WXLIB_CORE_p)
@COND_MONOLITHIC_0@__WXLIB_BASE_p = \
@COND_MONOLITHIC_0@ -lwx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)-2.5$(HOST_SUFFIX)
COND_MONOLITHIC_1___WXLIB_MONO_p = \
-lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)-2.5$(HOST_SUFFIX)
@COND_MONOLITHIC_1@__WXLIB_MONO_p = $(COND_MONOLITHIC_1___WXLIB_MONO_p)
@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@__LIB_TIFF_p \
@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@ = \
@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@ -lwxtiff$(WXDEBUGFLAG)$(HOST_SUFFIX)
@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@__LIB_JPEG_p \
@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@ = \
@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@ -lwxjpeg$(WXDEBUGFLAG)$(HOST_SUFFIX)
@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@__LIB_PNG_p \
@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@ = \
@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@ -lwxpng$(WXDEBUGFLAG)$(HOST_SUFFIX)
@COND_WXUSE_ZLIB_BUILTIN@__LIB_ZLIB_p = \
@COND_WXUSE_ZLIB_BUILTIN@ -lwxzlib$(WXDEBUGFLAG)$(HOST_SUFFIX)
@COND_WXUSE_ODBC_BUILTIN@__LIB_ODBC_p = \
@COND_WXUSE_ODBC_BUILTIN@ -lwxodbc$(WXDEBUGFLAG)$(HOST_SUFFIX)
@COND_WXUSE_REGEX_BUILTIN@__LIB_REGEX_p = \
@COND_WXUSE_REGEX_BUILTIN@ -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(HOST_SUFFIX)
@COND_WXUSE_EXPAT_BUILTIN@__LIB_EXPAT_p = \
@COND_WXUSE_EXPAT_BUILTIN@ -lwxexpat$(WXDEBUGFLAG)$(HOST_SUFFIX)
COND_TOOLKIT_MAC___MACOSX_RESOURCES_p_1 = $(RESCOMP) -d __DARWIN__ -t APPL -d \
__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_1) -i $(srcdir) $(__DLLFLAG_p_1) -i \
$(srcdir)/../../../samples -i $(top_srcdir)/include -o htmlctrl$(EXEEXT) \
Carbon.r $(LIBDIRNAME)/libwx_$(TOOLCHAIN_NAME).1.r sample.r
@COND_TOOLKIT_MAC@__MACOSX_RESOURCES_p_1 = $(COND_TOOLKIT_MAC___MACOSX_RESOURCES_p_1)
### Targets: ###
all: htmlctrl$(EXEEXT) $(__htmlctrl_bundle___depname)
install: all
uninstall:
install-strip: install
clean:
rm -rf ./.deps ./.pch
rm -f ./*.o
rm -f htmlctrl$(EXEEXT)
rm -rf htmlctrl.app
distclean: clean
rm -f configure config.cache config.log config.status bk-deps bk-make-pch shared-ld-sh Makefile
htmlctrl$(EXEEXT): $(HTMLCTRL_OBJECTS) $(__htmlctrl___win32rc)
$(CXX) -o $@ $(HTMLCTRL_OBJECTS) $(LDFLAGS) -L$(LIBDIRNAME) $(LDFLAGS_GUI) $(SAMPLES_RPATH_FLAG) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_ZLIB_p) $(__LIB_ODBC_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS) $(EXTRALIBS_GUI)
$(__htmlctrl___mac_rezcmd)
$(__htmlctrl___mac_setfilecmd)
$(__htmlctrl___os2_emxbindcmd)
$(SAMPLES_RPATH_POSTLINK)
htmlctrl.app/Contents/PkgInfo: htmlctrl$(EXEEXT) $(top_srcdir)/src/mac/carbon/Info.plist.in $(LIBDIRNAME)/libwx_$(TOOLCHAIN_NAME).1.rsrc $(top_srcdir)/src/mac/carbon/wxmac.icns
mkdir -p htmlctrl.app/Contents
mkdir -p htmlctrl.app/Contents/MacOS
mkdir -p htmlctrl.app/Contents/Resources
sed -e "s/IDENTIFIER/`echo $(srcdir) | sed -e 's,\.\./,,g' | sed -e 's,/,.,g'`/" \
-e "s/EXECUTABLE/htmlctrl/" \
-e "s/VERSION/$(WX_VERSION)/" \
$(top_srcdir)/src/mac/carbon/Info.plist.in >htmlctrl.app/Contents/Info.plist
echo -n "APPL????" >htmlctrl.app/Contents/PkgInfo
ln -f htmlctrl$(EXEEXT) htmlctrl.app/Contents/MacOS/htmlctrl
cp -f $(LIBDIRNAME)/libwx_$(TOOLCHAIN_NAME).1.rsrc htmlctrl.app/Contents/Resources/htmlctrl.rsrc
cp -f $(top_srcdir)/src/mac/carbon/wxmac.icns htmlctrl.app/Contents/Resources/wxmac.icns
@COND_PLATFORM_MACOSX_1@htmlctrl_bundle: $(____htmlctrl_BUNDLE_TGT_REF_DEP)
htmlctrl_sample_rc.o: $(srcdir)/../../../samples/sample.rc
$(RESCOMP) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_2) --include-dir $(srcdir) $(__DLLFLAG_p_2) --include-dir $(srcdir)/../../../samples --include-dir $(top_srcdir)/include
htmlctrl_htmlctrl.o: $(srcdir)/htmlctrl.cpp
$(CXXC) -c -o $@ $(HTMLCTRL_CXXFLAGS) $<
# Include dependency info, if present:
@IF_GNU_MAKE@-include .deps/*.d
.PHONY: all install uninstall clean distclean htmlctrl_bundle

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<!-- $Id$ -->
<makefile>
<include file="../../../build/bakefiles/common_samples.bkl"/>
<exe id="htmlctrl" template="wx_sample" template_append="wx_append">
<sources>htmlctrl.cpp</sources>
<wx-lib>core</wx-lib>
<wx-lib>base</wx-lib>
</exe>
</makefile>

View File

@@ -0,0 +1,247 @@
/////////////////////////////////////////////////////////////////////////////
// Name: htmlctrl.cpp
// Purpose: HtmlCtrl sample
// Author: Julian Smart / Kevin Ollivier
// Modified by:
// Created: 04/16/2004
// RCS-ID: $Id$
// Copyright: (c) Julian Smart / Kevin Ollivier
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/html/wxWebKit.h"
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------
// the application icon (under Windows and OS/2 it is in resources and even
// though we could still include the XPM here it would be unused)
#if !defined(__WXMSW__) && !defined(__WXPM__)
#include "../../sample.xpm"
#endif
enum {
ID_BACK = wxID_HIGHEST + 1,
ID_NEXT = wxID_HIGHEST + 2,
ID_RELOAD = wxID_HIGHEST + 3,
ID_URLLIST = wxID_HIGHEST + 4,
ID_STOP = wxID_HIGHEST + 5,
ID_WEBKIT = wxID_HIGHEST + 6,
ID_VIEW_SOURCE = wxID_HIGHEST + 7,
ID_OPEN = wxID_HIGHEST + 8,
ID_SAVE = wxID_HIGHEST + 9,
ID_SET_SOURCE = wxID_HIGHEST + 10
};
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
// override base class virtuals
// ----------------------------
// this one is called on application startup and is a good place for the app
// initialization (doing it here and not in the ctor allows to have an error
// return: if OnInit() returns false, the application terminates)
virtual bool OnInit();
};
// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
// ctor(s)
MyFrame(const wxString& title);
void OnBackButton(wxCommandEvent& myEvent);
void OnNextButton(wxCommandEvent& myEvent);
void OnURLEnter(wxCommandEvent& myEvent);
void OnStopButton(wxCommandEvent& myEvent);
void OnReloadButton(wxCommandEvent& myEvent);
void OnViewSource(wxCommandEvent& myEvent);
void OnSetSource(wxCommandEvent& myEvent);
void OnStateChanged(wxWebKitStateChangedEvent& myEvent);
wxWebKitControl* mySafari;
wxTextCtrl* urlText;
private:
// any class wishing to process wxWindows events must use this macro
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// event tables and other macros for wxWindows
// ----------------------------------------------------------------------------
// the event tables connect the wxWindows events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_BUTTON(ID_BACK, MyFrame::OnBackButton)
EVT_BUTTON(ID_NEXT, MyFrame::OnNextButton)
EVT_BUTTON(ID_STOP, MyFrame::OnStopButton)
EVT_BUTTON(ID_RELOAD, MyFrame::OnReloadButton)
EVT_MENU(ID_VIEW_SOURCE, MyFrame::OnViewSource)
EVT_MENU(ID_SET_SOURCE, MyFrame::OnSetSource)
EVT_TEXT_ENTER(ID_URLLIST, MyFrame::OnURLEnter)
EVT_WEBKIT_STATE_CHANGED(MyFrame::OnStateChanged)
//EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
//EVT_MENU(Minimal_About, MyFrame::OnAbout)
END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWindows to create
// the application object during program execution (it's better than using a
// static object for many reasons) and also implements the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// not wxApp)
IMPLEMENT_APP(MyApp)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------
// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
// create the main application window
MyFrame *frame = new MyFrame(_T("wxWebKit Sample"));
// and show it (the frames, unlike simple controls, are not shown when
// created initially)
frame->Show(true);
// success: wxApp::OnRun() will be called which will enter the main message
// loop and the application will run. If we returned false here, the
// application would exit immediately.
return true;
}
// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------
// frame constructor
MyFrame::MyFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(500,500))
{
wxMenuBar* myBar = new wxMenuBar();
wxMenu* fileMenu = new wxMenu(_("&File"));
fileMenu->Append(ID_OPEN, _("Open"));
fileMenu->Append(ID_SAVE, _("Save"));
myBar->Append(fileMenu, _("File"));
wxMenu* editMenu = new wxMenu(_("Edit"));
editMenu->Append(ID_SET_SOURCE, _("Set Page Source"));
myBar->Append(editMenu, _("Edit"));
//wxMenu* viewMenu = new wxMenu(_("View"));
//viewMenu->Append(ID_VIEW_SOURCE, _("View Source"));
//myBar->Append(viewMenu, _("View"));
SetMenuBar(myBar);
wxToolBar* myToolbar = CreateToolBar();
wxButton* btnBack = new wxButton(myToolbar, ID_BACK, _("Back"));
myToolbar->AddControl(btnBack);
myToolbar->AddSeparator();
wxButton* btnNext = new wxButton(myToolbar, ID_NEXT, _("Next"));
myToolbar->AddControl(btnNext);
myToolbar->AddSeparator();
wxButton* btnStop = new wxButton(myToolbar, ID_STOP, _("Stop"));
myToolbar->AddControl(btnStop);
myToolbar->AddSeparator();
wxButton* btnReload = new wxButton(myToolbar, ID_RELOAD, _("Reload"));
myToolbar->AddControl(btnReload);
myToolbar->AddSeparator();
urlText = new wxTextCtrl(myToolbar, ID_URLLIST, _T("http://www.wxwidgets.org"), wxDefaultPosition, wxSize(220, -1), wxTE_PROCESS_ENTER);
myToolbar->AddControl(urlText);
myToolbar->AddSeparator();
myToolbar->Realize();
mySafari = new wxWebKitControl(this, ID_WEBKIT, _T("http://www.wxwidgets.org"), wxDefaultPosition, wxSize(200, 200));
#if wxUSE_STATUSBAR
CreateStatusBar(2);
#endif // wxUSE_STATUSBAR
}
void MyFrame::OnBackButton(wxCommandEvent& myEvent){
if (mySafari->CanGoBack())
mySafari->GoBack();
}
void MyFrame::OnNextButton(wxCommandEvent& myEvent){
if (mySafari->CanGoForward())
mySafari->GoForward();
}
void MyFrame::OnStopButton(wxCommandEvent& myEvent){
mySafari->Stop();
}
void MyFrame::OnReloadButton(wxCommandEvent& myEvent){
mySafari->Reload();
}
void MyFrame::OnURLEnter(wxCommandEvent& myEvent){
mySafari->LoadURL(urlText->GetValue());
}
void MyFrame::OnStateChanged(wxWebKitStateChangedEvent& myEvent){
if (GetStatusBar() != NULL){
if (myEvent.GetState() == wxWEBKIT_STATE_NEGOTIATING){
GetStatusBar()->SetStatusText(_("Contacting ") + myEvent.GetURL());
}
else if (myEvent.GetState() == wxWEBKIT_STATE_TRANSFERRING){
GetStatusBar()->SetStatusText(_("Loading ") + myEvent.GetURL());
}
else if (myEvent.GetState() == wxWEBKIT_STATE_STOP){
GetStatusBar()->SetStatusText(_("Load complete."));
SetTitle(mySafari->GetTitle());
}
else if (myEvent.GetState() == wxWEBKIT_STATE_FAILED){
GetStatusBar()->SetStatusText(_("Failed to load ") + myEvent.GetURL());
}
}
}
void MyFrame::OnViewSource(wxCommandEvent& myEvent){
if (mySafari->CanGetPageSource())
wxMessageBox(mySafari->GetPageSource());
}
void MyFrame::OnSetSource(wxCommandEvent& myEvent){
if (mySafari){
wxString myText = wxString("<HTML><HEAD></HEAD><BODY><P>Hello world!</P></BODY></HTML>");
mySafari->SetPageSource(myText);
}
}