build NSIS Menu from source (requires wxWidgets)
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4958 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1a7016361c
commit
b8bf22affb
20 changed files with 792 additions and 3060 deletions
|
@ -1,11 +0,0 @@
|
|||
NSIS Menu - by Joost Verburg
|
||||
----------------------------
|
||||
|
||||
Based on wxWindows 2.4.2 / wxHtml
|
||||
|
||||
Compile using the wxWindows framework: http://www.wxwindows.org/
|
||||
|
||||
Modified wxWindows / wxHtml sources included, copy the data from this folder to the wxWindows folder.
|
||||
You have to compile wxWindows and the libraries with the Multi-threaded (/MT) option.
|
||||
|
||||
The NSIS Menu binary is compressed using UPX: http://upx.sourceforge.net/
|
|
@ -1,39 +1,25 @@
|
|||
target = "NSIS"
|
||||
|
||||
files = Split("""
|
||||
nsismenu.cpp
|
||||
nsismenu/nsismenu.cpp
|
||||
nsismenu/nslinks.cpp
|
||||
""")
|
||||
|
||||
resources = Split("""
|
||||
nsisicon.ico
|
||||
nsismenu/nsisicon.ico
|
||||
""")
|
||||
|
||||
rc = 'nsismenu.rc'
|
||||
rc = 'nsismenu/nsismenu.rc'
|
||||
|
||||
libs = Split("""
|
||||
user32
|
||||
gdi32
|
||||
advapi32
|
||||
ole32
|
||||
comctl32
|
||||
comdlg32
|
||||
uuid
|
||||
rpcrt4
|
||||
gdi32
|
||||
shell32
|
||||
wxbase26
|
||||
wxbase26_net
|
||||
wxbase26_xml
|
||||
wxexpat
|
||||
wxjpeg
|
||||
wxmsw26_adv
|
||||
wxmsw26_core
|
||||
wxmsw26_html
|
||||
wxmsw26_media
|
||||
wxmsw26_xrc
|
||||
wxpng
|
||||
wxregex
|
||||
wxtiff
|
||||
wxzlib
|
||||
user32
|
||||
wxbase28
|
||||
wxmsw28_core
|
||||
wxmsw28_html
|
||||
""")
|
||||
|
||||
html = Split("""
|
||||
|
@ -58,21 +44,42 @@ images = Split("""
|
|||
Import('BuildUtil env')
|
||||
|
||||
import os
|
||||
from os.path import join
|
||||
|
||||
#wxlib = [os.environ['WXWIN'] + os.sep + 'lib' + os.sep + 'vc_lib']
|
||||
#wxinc = [os.environ['WXWIN'] + os.sep + 'include', os.environ['WXWIN'] + os.sep + 'lib' + os.sep + 'vc_lib' + os.sep + 'msw']
|
||||
if os.environ.has_key('WXWIN'):
|
||||
# directories
|
||||
|
||||
#BuildUtil(target, files, libs, libpath = wxlib, cpppath = wxinc, res = rc, resources = resources, install = '', flags = ['/MD'])
|
||||
wxlib = [join(os.environ['WXWIN'], 'lib', 'vc_libnsis')]
|
||||
wxinc = [
|
||||
join(os.environ['WXWIN'], 'include'),
|
||||
join(os.environ['WXWIN'], 'lib', 'vc_libnsis', 'msw')
|
||||
]
|
||||
|
||||
# build
|
||||
|
||||
BuildUtil(
|
||||
target,
|
||||
files,
|
||||
libs,
|
||||
res = rc,
|
||||
resources = resources,
|
||||
flags = ['/MD', '$EXCEPTION_FLAG'],
|
||||
libpath = wxlib,
|
||||
incpath = wxinc,
|
||||
root_util = True
|
||||
)
|
||||
|
||||
# install menu files
|
||||
|
||||
env.DistributeMenu(html, alias='install-utils')
|
||||
env.DistributeMenu(images, path='images', alias='install-utils')
|
||||
|
||||
# install pre-built NSIS.exe
|
||||
if env['PLATFORM'] == 'win32':
|
||||
ins = env.DistributeBin('#NSIS.exe')
|
||||
else:
|
||||
ins = env.DistributeW32Bin('#NSIS.exe')
|
||||
|
||||
# no wxWidgets
|
||||
def err(target, source, env):
|
||||
print '*** error: WXWIN must be set to build NSIS Menu!'
|
||||
return 1
|
||||
|
||||
env.Alias('install-utils', ins)
|
||||
|
||||
# install menu files
|
||||
|
||||
env.DistributeMenu(html, alias='install-utils')
|
||||
env.DistributeMenu(images, path='images', alias='install-utils')
|
||||
cmd = env.Command(target, files, Action(err, ''))
|
||||
env.Alias('NSIS Menu', cmd)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
|
@ -12,12 +12,16 @@
|
|||
// 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"
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "wx/html/htmlwin.h"
|
||||
#include "wx/html/htmlproc.h"
|
||||
#include <wx/event.h>
|
||||
#include <wx/filefn.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/html/htmlproc.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/utils.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
|
@ -42,6 +46,9 @@ class MyFrame : public wxFrame
|
|||
public:
|
||||
// ctor(s)
|
||||
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
// event handler(s)
|
||||
void OnLink(wxHtmlLinkEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
||||
private:
|
||||
wxHtmlWindow *m_Html;
|
||||
|
@ -58,7 +65,7 @@ private:
|
|||
enum
|
||||
{
|
||||
// controls start here (the numbers are, of course, arbitrary)
|
||||
Minimal_Text = 1000
|
||||
HtmlControl = 1000
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -69,6 +76,7 @@ private:
|
|||
// 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_HTML_LINK_CLICKED(HtmlControl, OnLink)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Create a new application object: this macro will allow wxWindows to create
|
||||
|
@ -90,19 +98,19 @@ private:
|
|||
{
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
// Create the main application window
|
||||
MyFrame *frame = new MyFrame(_("NSIS Menu"),
|
||||
wxPoint(50, 50), wxSize(612 + (GetSystemMetrics(SM_CXEDGE) * 2), 353 + GetSystemMetrics(SM_CYSIZE) + (GetSystemMetrics(SM_CXEDGE) * 2)));
|
||||
// Create the main application window
|
||||
MyFrame *frame = new MyFrame(_("NSIS Menu"),
|
||||
wxPoint(50, 50), wxSize(600 + GetSystemMetrics(SM_CXDLGFRAME), 382 + GetSystemMetrics(SM_CYDLGFRAME)));
|
||||
|
||||
// Show it and tell the application that it's our main window
|
||||
// Show it and tell the application that it's our main window
|
||||
|
||||
frame->Show(TRUE);
|
||||
SetTopWindow(frame);
|
||||
frame->Show(TRUE);
|
||||
SetTopWindow(frame);
|
||||
|
||||
// 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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -112,23 +120,54 @@ private:
|
|||
|
||||
// frame constructor
|
||||
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame((wxFrame *)NULL, -1, title, pos, size, wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION,
|
||||
: wxFrame((wxFrame *)NULL, -1, title, pos, size, wxCLOSE_BOX | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION,
|
||||
wxT("nsis_menu"))
|
||||
{
|
||||
m_Html = new wxHtmlWindow(this);
|
||||
m_Html = new wxHtmlWindow(this, HtmlControl);
|
||||
m_Html->SetRelatedFrame(this, _("NSIS Menu"));
|
||||
m_Html->SetBorders(0);
|
||||
|
||||
// Set font size
|
||||
wxWindow UnitConvert;
|
||||
wxSize DialogSize(1000, 1000);
|
||||
DialogSize = UnitConvert.ConvertDialogToPixels(DialogSize);
|
||||
int fonts[7] = {0, 0, 20000 / (DialogSize.GetWidth()), 25000 / (DialogSize.GetWidth()), 0, 0, 0};
|
||||
m_Html->SetFonts("", "", fonts);
|
||||
|
||||
m_Html->LoadPage(wxT("Menu/index.html"));
|
||||
|
||||
this->Centre(wxBOTH);
|
||||
this->SetIcon(wxICON(nsisicon));
|
||||
m_Html->SetBorders(0);
|
||||
m_Html->EnableScrolling(false, false);
|
||||
|
||||
// Set font size
|
||||
wxWindow UnitConvert;
|
||||
wxSize DialogSize(1000, 1000);
|
||||
DialogSize = UnitConvert.ConvertDialogToPixels(DialogSize);
|
||||
int fonts[7] = {0, 0, 14000 / (DialogSize.GetWidth()), 19000 / (DialogSize.GetWidth()), 0, 0, 0};
|
||||
m_Html->SetFonts("", "", fonts);
|
||||
|
||||
m_Html->LoadPage(wxT("Menu/index.html"));
|
||||
|
||||
this->Centre(wxBOTH);
|
||||
this->SetIcon(wxICON(nsisicon));
|
||||
}
|
||||
|
||||
}
|
||||
// event handler
|
||||
|
||||
void MyFrame::OnLink(wxHtmlLinkEvent& event)
|
||||
{
|
||||
const wxMouseEvent *e = event.GetLinkInfo().GetEvent();
|
||||
if (e == NULL || e->LeftUp())
|
||||
{
|
||||
const wxString href = event.GetLinkInfo().GetHref();
|
||||
if (href.Left(3).IsSameAs("EX:", false))
|
||||
{
|
||||
wxString url = href.Mid(3);
|
||||
if (url.Left(7).IsSameAs("http://", false) || url.Left(6).IsSameAs("irc://", false))
|
||||
{
|
||||
::wxLaunchDefaultBrowser(url);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString exePath = wxStandardPaths::Get().GetExecutablePath();
|
||||
wxString path = ::wxPathOnly(exePath);
|
||||
path.Append(wxFileName::GetPathSeparators()[0]);
|
||||
path.Append(url);
|
||||
::wxLaunchDefaultBrowser(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nsismenu", "nsismenu.vcproj", "{598BB726-F3FC-43A4-9E39-A1F9AD153F05}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Debug.ActiveCfg = Debug|Win32
|
||||
{598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Debug.Build.0 = Debug|Win32
|
||||
{598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Release.ActiveCfg = Release|Win32
|
||||
{598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,164 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="nsismenu"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/I..\lib\msw "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="NDEBUG,WIN32,_WINDOWS,WINVER=0x400,_MT,wxUSE_GUI=1"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Release/nsismenu.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib ..\lib\zlib.lib ..\lib\wxmsw.lib"
|
||||
OutputFile=".\Release\NSIS.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\Release/nsismenu.pdb"
|
||||
SubSystem="2"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/nsismenu.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
AdditionalIncludeDirectories="../include"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/I..\lib\mswd "
|
||||
Optimization="1"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="_DEBUG,WIN32,_WINDOWS,WINVER=0x400,_MT,wxUSE_GUI=1,__WXDEBUG__,WXDEBUG=1"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/nsismenu.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib ..\lib\zlibd.lib ..\lib\wxmswd.lib"
|
||||
OutputFile=".\Debug\NSIS.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/nsismenu.pdb"
|
||||
SubSystem="2"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/nsismenu.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
AdditionalIncludeDirectories="../include"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="wx\msw\hand.cur">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="nsisicon.ico">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="nsismenu.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="nsismenu.rc">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="resource.h">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
109
Contrib/NSIS Menu/nsismenu/nslinks.cpp
Normal file
109
Contrib/NSIS Menu/nsismenu/nslinks.cpp
Normal file
|
@ -0,0 +1,109 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/html/m_links.cpp
|
||||
// Purpose: wxHtml module for links & anchors
|
||||
// Author: Vaclav Slavik
|
||||
// RCS-ID: $Id: m_links.cpp,v 1.18 2006/04/18 08:11:25 ABX Exp $
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_HTML && wxUSE_STREAMS
|
||||
|
||||
#ifndef WXPRECOMP
|
||||
#endif
|
||||
|
||||
#include "wx/html/forcelnk.h"
|
||||
#include "wx/html/m_templ.h"
|
||||
|
||||
#include <wx/filefn.h>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
FORCE_LINK_ME(nslinks)
|
||||
|
||||
class wxHtmlAnchorCell : public wxHtmlCell
|
||||
{
|
||||
private:
|
||||
wxString m_AnchorName;
|
||||
|
||||
public:
|
||||
wxHtmlAnchorCell(const wxString& name) : wxHtmlCell()
|
||||
{ m_AnchorName = name; }
|
||||
void Draw(wxDC& WXUNUSED(dc),
|
||||
int WXUNUSED(x), int WXUNUSED(y),
|
||||
int WXUNUSED(view_y1), int WXUNUSED(view_y2),
|
||||
wxHtmlRenderingInfo& WXUNUSED(info)) {}
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell)
|
||||
};
|
||||
|
||||
|
||||
|
||||
TAG_HANDLER_BEGIN(A, "A")
|
||||
TAG_HANDLER_CONSTR(A) { }
|
||||
|
||||
TAG_HANDLER_PROC(tag)
|
||||
{
|
||||
if (tag.HasParam( wxT("HREF") ))
|
||||
{
|
||||
wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
|
||||
wxColour oldclr = m_WParser->GetActualColor();
|
||||
wxString name(tag.GetParam( wxT("HREF") )), target;
|
||||
|
||||
if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
|
||||
|
||||
wxColour colour = m_WParser->GetLinkColor();
|
||||
wxHtmlLinkInfo linkInfo(name, target);
|
||||
|
||||
if (name.Left(3).IsSameAs("EX:", false))
|
||||
{
|
||||
wxString url = name.Mid(3);
|
||||
if (!url.Left(7).IsSameAs("http://", false) && !url.Left(6).IsSameAs("irc://", false))
|
||||
{
|
||||
wxString exePath = wxStandardPaths::Get().GetExecutablePath();
|
||||
wxString path = ::wxPathOnly(exePath);
|
||||
path.Append(wxFileName::GetPathSeparators()[0]);
|
||||
path.Append(url);
|
||||
|
||||
if (!::wxFileExists(path) && !::wxDirExists(path))
|
||||
{
|
||||
colour = wxColour(0x80, 0x80, 0x80);
|
||||
linkInfo = wxHtmlLinkInfo("notinstalled.html", target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_WParser->SetActualColor(colour);
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(colour));
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
|
||||
m_WParser->SetLink(linkInfo);
|
||||
|
||||
ParseInner(tag);
|
||||
|
||||
m_WParser->SetLink(oldlnk);
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
|
||||
m_WParser->SetActualColor(oldclr);
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
|
||||
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
TAG_HANDLER_END(A)
|
||||
|
||||
|
||||
|
||||
TAGS_MODULE_BEGIN(CustomLinks)
|
||||
|
||||
TAGS_MODULE_ADD(A)
|
||||
|
||||
TAGS_MODULE_END(CustomLinks)
|
||||
|
||||
|
||||
#endif
|
|
@ -1,830 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: htmlwin.cpp
|
||||
// Purpose: wxHtmlWindow class for parsing & displaying HTML (implementation)
|
||||
// Author: Vaclav Slavik
|
||||
// RCS-ID: $Id: htmlwin.cpp,v 1.62.2.3 2003/04/09 16:02:31 VS Exp $
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "htmlwin.h"
|
||||
#pragma implementation "htmlproc.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/defs.h"
|
||||
#if wxUSE_HTML && wxUSE_STREAMS
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WXPRECOMP
|
||||
#include "wx/log.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/frame.h"
|
||||
#endif
|
||||
|
||||
#include "wx/html/htmlwin.h"
|
||||
#include "wx/html/htmlproc.h"
|
||||
#include "wx/list.h"
|
||||
|
||||
#include "wx/arrimpl.cpp"
|
||||
#include "wx/listimpl.cpp"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxHtmlHistoryItem
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// item of history list
|
||||
class WXDLLEXPORT wxHtmlHistoryItem
|
||||
{
|
||||
public:
|
||||
wxHtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;}
|
||||
int GetPos() const {return m_Pos;}
|
||||
void SetPos(int p) {m_Pos = p;}
|
||||
const wxString& GetPage() const {return m_Page;}
|
||||
const wxString& GetAnchor() const {return m_Anchor;}
|
||||
|
||||
private:
|
||||
wxString m_Page;
|
||||
wxString m_Anchor;
|
||||
int m_Pos;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// our private arrays:
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
WX_DECLARE_OBJARRAY(wxHtmlHistoryItem, wxHtmlHistoryArray);
|
||||
WX_DEFINE_OBJARRAY(wxHtmlHistoryArray);
|
||||
|
||||
WX_DECLARE_LIST(wxHtmlProcessor, wxHtmlProcessorList);
|
||||
WX_DEFINE_LIST(wxHtmlProcessorList);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxHtmlWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void wxHtmlWindow::Init()
|
||||
{
|
||||
m_tmpMouseMoved = FALSE;
|
||||
m_tmpLastLink = NULL;
|
||||
m_tmpLastCell = NULL;
|
||||
m_tmpCanDrawLocks = 0;
|
||||
m_FS = new wxFileSystem();
|
||||
m_RelatedStatusBar = -1;
|
||||
m_RelatedFrame = NULL;
|
||||
m_TitleFormat = wxT("%s");
|
||||
m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
|
||||
m_Cell = NULL;
|
||||
m_Parser = new wxHtmlWinParser(this);
|
||||
m_Parser->SetFS(m_FS);
|
||||
m_HistoryPos = -1;
|
||||
m_HistoryOn = TRUE;
|
||||
m_History = new wxHtmlHistoryArray;
|
||||
m_Processors = NULL;
|
||||
m_Style = 0;
|
||||
SetBorders(10);
|
||||
}
|
||||
|
||||
bool wxHtmlWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name)
|
||||
{
|
||||
if (!wxScrolledWindow::Create(parent, id, pos, size,
|
||||
style | wxVSCROLL | wxHSCROLL, name))
|
||||
return FALSE;
|
||||
|
||||
m_Style = style;
|
||||
SetPage(wxT("<html><body></body></html>"));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
wxHtmlWindow::~wxHtmlWindow()
|
||||
{
|
||||
HistoryClear();
|
||||
|
||||
if (m_Cell) delete m_Cell;
|
||||
|
||||
delete m_Parser;
|
||||
delete m_FS;
|
||||
delete m_History;
|
||||
delete m_Processors;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::SetRelatedFrame(wxFrame* frame, const wxString& format)
|
||||
{
|
||||
m_RelatedFrame = frame;
|
||||
m_TitleFormat = format;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::SetRelatedStatusBar(int bar)
|
||||
{
|
||||
m_RelatedStatusBar = bar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::SetFonts(wxString normal_face, wxString fixed_face, const int *sizes)
|
||||
{
|
||||
wxString op = m_OpenedPage;
|
||||
|
||||
m_Parser->SetFonts(normal_face, fixed_face, sizes);
|
||||
// fonts changed => contents invalid, so reload the page:
|
||||
SetPage(wxT("<html><body></body></html>"));
|
||||
if (!op.IsEmpty()) LoadPage(op);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool wxHtmlWindow::SetPage(const wxString& source)
|
||||
{
|
||||
wxString newsrc(source);
|
||||
|
||||
// pass HTML through registered processors:
|
||||
if (m_Processors || m_GlobalProcessors)
|
||||
{
|
||||
wxHtmlProcessorList::Node *nodeL, *nodeG;
|
||||
int prL, prG;
|
||||
|
||||
nodeL = (m_Processors) ? m_Processors->GetFirst() : NULL;
|
||||
nodeG = (m_GlobalProcessors) ? m_GlobalProcessors->GetFirst() : NULL;
|
||||
|
||||
// VS: there are two lists, global and local, both of them sorted by
|
||||
// priority. Since we have to go through _both_ lists with
|
||||
// decreasing priority, we "merge-sort" the lists on-line by
|
||||
// processing that one of the two heads that has higher priority
|
||||
// in every iteration
|
||||
while (nodeL || nodeG)
|
||||
{
|
||||
prL = (nodeL) ? nodeL->GetData()->GetPriority() : -1;
|
||||
prG = (nodeG) ? nodeG->GetData()->GetPriority() : -1;
|
||||
if (prL > prG)
|
||||
{
|
||||
if (nodeL->GetData()->IsEnabled())
|
||||
newsrc = nodeL->GetData()->Process(newsrc);
|
||||
nodeL = nodeL->GetNext();
|
||||
}
|
||||
else // prL <= prG
|
||||
{
|
||||
if (nodeG->GetData()->IsEnabled())
|
||||
newsrc = nodeG->GetData()->Process(newsrc);
|
||||
nodeG = nodeG->GetNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ...and run the parser on it:
|
||||
wxClientDC *dc = new wxClientDC(this);
|
||||
dc->SetMapMode(wxMM_TEXT);
|
||||
SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
|
||||
m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
|
||||
m_Parser->SetDC(dc);
|
||||
if (m_Cell)
|
||||
{
|
||||
delete m_Cell;
|
||||
m_Cell = NULL;
|
||||
}
|
||||
m_Cell = (wxHtmlContainerCell*) m_Parser->Parse(newsrc);
|
||||
delete dc;
|
||||
m_Cell->SetIndent(m_Borders, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
|
||||
m_Cell->SetAlignHor(wxHTML_ALIGN_CENTER);
|
||||
CreateLayout();
|
||||
if (m_tmpCanDrawLocks == 0)
|
||||
Refresh();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxHtmlWindow::AppendToPage(const wxString& source)
|
||||
{
|
||||
return SetPage(*(GetParser()->GetSource()) + source);
|
||||
}
|
||||
|
||||
bool wxHtmlWindow::LoadPage(const wxString& location)
|
||||
{
|
||||
wxBusyCursor busyCursor;
|
||||
|
||||
wxFSFile *f;
|
||||
bool rt_val;
|
||||
bool needs_refresh = FALSE;
|
||||
|
||||
m_tmpCanDrawLocks++;
|
||||
if (m_HistoryOn && (m_HistoryPos != -1))
|
||||
{
|
||||
// store scroll position into history item:
|
||||
int x, y;
|
||||
GetViewStart(&x, &y);
|
||||
(*m_History)[m_HistoryPos].SetPos(y);
|
||||
}
|
||||
|
||||
if (location[0] == wxT('#'))
|
||||
{
|
||||
// local anchor:
|
||||
wxString anch = location.Mid(1) /*1 to end*/;
|
||||
m_tmpCanDrawLocks--;
|
||||
rt_val = ScrollToAnchor(anch);
|
||||
m_tmpCanDrawLocks++;
|
||||
}
|
||||
else if (location.Find(wxT('#')) != wxNOT_FOUND && location.BeforeFirst(wxT('#')) == m_OpenedPage)
|
||||
{
|
||||
wxString anch = location.AfterFirst(wxT('#'));
|
||||
m_tmpCanDrawLocks--;
|
||||
rt_val = ScrollToAnchor(anch);
|
||||
m_tmpCanDrawLocks++;
|
||||
}
|
||||
else if (location.Find(wxT('#')) != wxNOT_FOUND &&
|
||||
(m_FS->GetPath() + location.BeforeFirst(wxT('#'))) == m_OpenedPage)
|
||||
{
|
||||
wxString anch = location.AfterFirst(wxT('#'));
|
||||
m_tmpCanDrawLocks--;
|
||||
rt_val = ScrollToAnchor(anch);
|
||||
m_tmpCanDrawLocks++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
needs_refresh = TRUE;
|
||||
// load&display it:
|
||||
if (m_RelatedStatusBar != -1)
|
||||
{
|
||||
m_RelatedFrame->SetStatusText(_("Connecting..."), m_RelatedStatusBar);
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
f = m_Parser->OpenURL(wxHTML_URL_PAGE, location);
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
wxLogError(_("Unable to open requested HTML document: %s"), location.c_str());
|
||||
m_tmpCanDrawLocks--;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
wxNode *node;
|
||||
wxString src = wxEmptyString;
|
||||
|
||||
if (m_RelatedStatusBar != -1)
|
||||
{
|
||||
wxString msg = _("Loading : ") + location;
|
||||
m_RelatedFrame->SetStatusText(msg, m_RelatedStatusBar);
|
||||
Refresh(FALSE);
|
||||
}
|
||||
|
||||
node = m_Filters.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxHtmlFilter *h = (wxHtmlFilter*) node->GetData();
|
||||
if (h->CanRead(*f))
|
||||
{
|
||||
src = h->ReadFile(*f);
|
||||
break;
|
||||
}
|
||||
node = node->GetNext();
|
||||
}
|
||||
if (src == wxEmptyString)
|
||||
{
|
||||
if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter();
|
||||
src = m_DefaultFilter->ReadFile(*f);
|
||||
}
|
||||
|
||||
m_FS->ChangePathTo(f->GetLocation());
|
||||
rt_val = SetPage(src);
|
||||
m_OpenedPage = f->GetLocation();
|
||||
if (f->GetAnchor() != wxEmptyString)
|
||||
{
|
||||
ScrollToAnchor(f->GetAnchor());
|
||||
}
|
||||
|
||||
delete f;
|
||||
|
||||
if (m_RelatedStatusBar != -1) m_RelatedFrame->SetStatusText(_("Done"), m_RelatedStatusBar);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_HistoryOn) // add this page to history there:
|
||||
{
|
||||
int c = m_History->GetCount() - (m_HistoryPos + 1);
|
||||
|
||||
if (m_HistoryPos < 0 ||
|
||||
(*m_History)[m_HistoryPos].GetPage() != m_OpenedPage ||
|
||||
(*m_History)[m_HistoryPos].GetAnchor() != m_OpenedAnchor)
|
||||
{
|
||||
m_HistoryPos++;
|
||||
for (int i = 0; i < c; i++)
|
||||
m_History->RemoveAt(m_HistoryPos);
|
||||
m_History->Add(new wxHtmlHistoryItem(m_OpenedPage, m_OpenedAnchor));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_OpenedPageTitle == wxEmptyString)
|
||||
OnSetTitle(wxFileNameFromPath(m_OpenedPage));
|
||||
|
||||
if (needs_refresh)
|
||||
{
|
||||
m_tmpCanDrawLocks--;
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
m_tmpCanDrawLocks--;
|
||||
|
||||
return rt_val;
|
||||
}
|
||||
|
||||
|
||||
bool wxHtmlWindow::LoadFile(const wxFileName& filename)
|
||||
{
|
||||
wxString url = wxFileSystem::FileNameToURL(filename);
|
||||
return LoadPage(url);
|
||||
}
|
||||
|
||||
|
||||
bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor)
|
||||
{
|
||||
const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor);
|
||||
if (!c)
|
||||
{
|
||||
wxLogWarning(_("HTML anchor %s does not exist."), anchor.c_str());
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int y;
|
||||
|
||||
for (y = 0; c != NULL; c = c->GetParent()) y += c->GetPosY();
|
||||
Scroll(-1, y / wxHTML_SCROLL_STEP);
|
||||
m_OpenedAnchor = anchor;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxHtmlWindow::OnSetTitle(const wxString& title)
|
||||
{
|
||||
if (m_RelatedFrame)
|
||||
{
|
||||
wxString tit;
|
||||
tit.Printf(m_TitleFormat, title.c_str());
|
||||
m_RelatedFrame->SetTitle(tit);
|
||||
}
|
||||
m_OpenedPageTitle = title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::CreateLayout()
|
||||
{
|
||||
int ClientWidth, ClientHeight;
|
||||
|
||||
if (!m_Cell) return;
|
||||
|
||||
if (m_Style & wxHW_SCROLLBAR_NEVER)
|
||||
{
|
||||
SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // always off
|
||||
GetClientSize(&ClientWidth, &ClientHeight);
|
||||
m_Cell->Layout(ClientWidth);
|
||||
}
|
||||
|
||||
else {
|
||||
GetClientSize(&ClientWidth, &ClientHeight);
|
||||
m_Cell->Layout(ClientWidth);
|
||||
if (ClientHeight < m_Cell->GetHeight() + GetCharHeight())
|
||||
{
|
||||
SetScrollbars(
|
||||
wxHTML_SCROLL_STEP, wxHTML_SCROLL_STEP,
|
||||
m_Cell->GetWidth() / wxHTML_SCROLL_STEP,
|
||||
(m_Cell->GetHeight() + GetCharHeight()) / wxHTML_SCROLL_STEP
|
||||
/*cheat: top-level frag is always container*/);
|
||||
}
|
||||
else /* we fit into window, no need for scrollbars */
|
||||
{
|
||||
SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // disable...
|
||||
GetClientSize(&ClientWidth, &ClientHeight);
|
||||
m_Cell->Layout(ClientWidth); // ...and relayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path)
|
||||
{
|
||||
wxString oldpath;
|
||||
wxString tmp;
|
||||
int p_fontsizes[7];
|
||||
wxString p_fff, p_ffn;
|
||||
|
||||
if (path != wxEmptyString)
|
||||
{
|
||||
oldpath = cfg->GetPath();
|
||||
cfg->SetPath(path);
|
||||
}
|
||||
|
||||
m_Borders = cfg->Read(wxT("wxHtmlWindow/Borders"), m_Borders);
|
||||
p_fff = cfg->Read(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser->m_FontFaceFixed);
|
||||
p_ffn = cfg->Read(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser->m_FontFaceNormal);
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
|
||||
p_fontsizes[i] = cfg->Read(tmp, m_Parser->m_FontsSizes[i]);
|
||||
}
|
||||
SetFonts(p_ffn, p_fff, p_fontsizes);
|
||||
|
||||
if (path != wxEmptyString)
|
||||
cfg->SetPath(oldpath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::WriteCustomization(wxConfigBase *cfg, wxString path)
|
||||
{
|
||||
wxString oldpath;
|
||||
wxString tmp;
|
||||
|
||||
if (path != wxEmptyString)
|
||||
{
|
||||
oldpath = cfg->GetPath();
|
||||
cfg->SetPath(path);
|
||||
}
|
||||
|
||||
cfg->Write(wxT("wxHtmlWindow/Borders"), (long) m_Borders);
|
||||
cfg->Write(wxT("wxHtmlWindow/FontFaceFixed"), m_Parser->m_FontFaceFixed);
|
||||
cfg->Write(wxT("wxHtmlWindow/FontFaceNormal"), m_Parser->m_FontFaceNormal);
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
|
||||
cfg->Write(tmp, (long) m_Parser->m_FontsSizes[i]);
|
||||
}
|
||||
|
||||
if (path != wxEmptyString)
|
||||
cfg->SetPath(oldpath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool wxHtmlWindow::HistoryBack()
|
||||
{
|
||||
wxString a, l;
|
||||
|
||||
if (m_HistoryPos < 1) return FALSE;
|
||||
|
||||
// store scroll position into history item:
|
||||
int x, y;
|
||||
GetViewStart(&x, &y);
|
||||
(*m_History)[m_HistoryPos].SetPos(y);
|
||||
|
||||
// go to previous position:
|
||||
m_HistoryPos--;
|
||||
|
||||
l = (*m_History)[m_HistoryPos].GetPage();
|
||||
a = (*m_History)[m_HistoryPos].GetAnchor();
|
||||
m_HistoryOn = FALSE;
|
||||
m_tmpCanDrawLocks++;
|
||||
if (a == wxEmptyString) LoadPage(l);
|
||||
else LoadPage(l + wxT("#") + a);
|
||||
m_HistoryOn = TRUE;
|
||||
m_tmpCanDrawLocks--;
|
||||
Scroll(0, (*m_History)[m_HistoryPos].GetPos());
|
||||
Refresh();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxHtmlWindow::HistoryCanBack()
|
||||
{
|
||||
if (m_HistoryPos < 1) return FALSE;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
bool wxHtmlWindow::HistoryForward()
|
||||
{
|
||||
wxString a, l;
|
||||
|
||||
if (m_HistoryPos == -1) return FALSE;
|
||||
if (m_HistoryPos >= (int)m_History->GetCount() - 1)return FALSE;
|
||||
|
||||
m_OpenedPage = wxEmptyString; // this will disable adding new entry into history in LoadPage()
|
||||
|
||||
m_HistoryPos++;
|
||||
l = (*m_History)[m_HistoryPos].GetPage();
|
||||
a = (*m_History)[m_HistoryPos].GetAnchor();
|
||||
m_HistoryOn = FALSE;
|
||||
m_tmpCanDrawLocks++;
|
||||
if (a == wxEmptyString) LoadPage(l);
|
||||
else LoadPage(l + wxT("#") + a);
|
||||
m_HistoryOn = TRUE;
|
||||
m_tmpCanDrawLocks--;
|
||||
Scroll(0, (*m_History)[m_HistoryPos].GetPos());
|
||||
Refresh();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxHtmlWindow::HistoryCanForward()
|
||||
{
|
||||
if (m_HistoryPos == -1) return FALSE;
|
||||
if (m_HistoryPos >= (int)m_History->GetCount() - 1)return FALSE;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
void wxHtmlWindow::HistoryClear()
|
||||
{
|
||||
m_History->Empty();
|
||||
m_HistoryPos = -1;
|
||||
}
|
||||
|
||||
void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor)
|
||||
{
|
||||
if (!m_Processors)
|
||||
{
|
||||
m_Processors = new wxHtmlProcessorList;
|
||||
m_Processors->DeleteContents(TRUE);
|
||||
}
|
||||
wxHtmlProcessorList::Node *node;
|
||||
|
||||
for (node = m_Processors->GetFirst(); node; node = node->GetNext())
|
||||
{
|
||||
if (processor->GetPriority() > node->GetData()->GetPriority())
|
||||
{
|
||||
m_Processors->Insert(node, processor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_Processors->Append(processor);
|
||||
}
|
||||
|
||||
/*static */ void wxHtmlWindow::AddGlobalProcessor(wxHtmlProcessor *processor)
|
||||
{
|
||||
if (!m_GlobalProcessors)
|
||||
{
|
||||
m_GlobalProcessors = new wxHtmlProcessorList;
|
||||
m_GlobalProcessors->DeleteContents(TRUE);
|
||||
}
|
||||
wxHtmlProcessorList::Node *node;
|
||||
|
||||
for (node = m_GlobalProcessors->GetFirst(); node; node = node->GetNext())
|
||||
{
|
||||
if (processor->GetPriority() > node->GetData()->GetPriority())
|
||||
{
|
||||
m_GlobalProcessors->Insert(node, processor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_GlobalProcessors->Append(processor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxList wxHtmlWindow::m_Filters;
|
||||
wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
|
||||
wxCursor *wxHtmlWindow::s_cur_hand = NULL;
|
||||
wxCursor *wxHtmlWindow::s_cur_arrow = NULL;
|
||||
wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL;
|
||||
|
||||
void wxHtmlWindow::CleanUpStatics()
|
||||
{
|
||||
wxDELETE(m_DefaultFilter);
|
||||
m_Filters.DeleteContents(TRUE);
|
||||
m_Filters.Clear();
|
||||
wxDELETE(m_GlobalProcessors);
|
||||
wxDELETE(s_cur_hand);
|
||||
wxDELETE(s_cur_arrow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
|
||||
{
|
||||
m_Filters.Append(filter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
|
||||
{
|
||||
char apppath[MAX_PATH],*temp;
|
||||
GetModuleFileName(NULL,apppath,sizeof(apppath));
|
||||
temp=strrchr(apppath,'\\');
|
||||
if(temp!=NULL) *temp=0;
|
||||
|
||||
char fullpath[MAX_PATH];
|
||||
|
||||
if (link.GetHref().Left(3).Cmp("EX:") == 0)
|
||||
{
|
||||
// External
|
||||
|
||||
if ((link.GetHref().Left(10).Cmp("EX:http://") == 0) || (link.GetHref().Left(9).Cmp("EX:irc://") == 0))
|
||||
{
|
||||
// Internet
|
||||
ShellExecute(0, "open", link.GetHref().Mid(3), NULL, NULL, SW_SHOW);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_snprintf(fullpath,sizeof(fullpath),"%s\\%s",apppath,link.GetHref().Mid(3));
|
||||
|
||||
if (wxFileExists(fullpath) || wxDirExists(fullpath))
|
||||
{
|
||||
ShellExecute(0, "open", fullpath, NULL, NULL, SW_SHOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Feature not installed
|
||||
_snprintf(fullpath,sizeof(fullpath),"%s\\Menu\\notinstalled.html",apppath,link.GetHref());
|
||||
LoadPage(fullpath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_snprintf(fullpath,sizeof(fullpath),"%s\\Menu\\%s",apppath,link.GetHref());
|
||||
LoadPage(fullpath);
|
||||
}
|
||||
}
|
||||
|
||||
void wxHtmlWindow::OnCellClicked(wxHtmlCell *cell,
|
||||
wxCoord x, wxCoord y,
|
||||
const wxMouseEvent& event)
|
||||
{
|
||||
wxCHECK_RET( cell, _T("can't be called with NULL cell") );
|
||||
|
||||
cell->OnMouseClick(this, x, y, event);
|
||||
}
|
||||
|
||||
void wxHtmlWindow::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell),
|
||||
wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
|
||||
{
|
||||
// do nothing here
|
||||
}
|
||||
|
||||
void wxHtmlWindow::OnDraw(wxDC& dc)
|
||||
{
|
||||
if (m_tmpCanDrawLocks > 0 || m_Cell == NULL) return;
|
||||
|
||||
int x, y;
|
||||
wxRect rect = GetUpdateRegion().GetBox();
|
||||
|
||||
dc.SetMapMode(wxMM_TEXT);
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
GetViewStart(&x, &y);
|
||||
|
||||
m_Cell->Draw(dc, 0, 0,
|
||||
y * wxHTML_SCROLL_STEP + rect.GetTop(),
|
||||
y * wxHTML_SCROLL_STEP + rect.GetBottom());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
wxScrolledWindow::OnSize(event);
|
||||
CreateLayout();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void wxHtmlWindow::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
m_tmpMouseMoved = TRUE;
|
||||
|
||||
if (event.ButtonDown())
|
||||
{
|
||||
SetFocus();
|
||||
if ( m_Cell )
|
||||
{
|
||||
int sx, sy;
|
||||
GetViewStart(&sx, &sy);
|
||||
sx *= wxHTML_SCROLL_STEP;
|
||||
sy *= wxHTML_SCROLL_STEP;
|
||||
|
||||
wxPoint pos = event.GetPosition();
|
||||
pos.x += sx;
|
||||
pos.y += sy;
|
||||
|
||||
wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y);
|
||||
|
||||
// VZ: is it possible that we don't find anything at all?
|
||||
// VS: yes. FindCellByPos returns terminal cell and
|
||||
// containers may have empty borders
|
||||
if ( cell )
|
||||
OnCellClicked(cell, pos.x, pos.y, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
|
||||
{
|
||||
if (s_cur_hand == NULL)
|
||||
{
|
||||
s_cur_hand = new wxCursor(wxCURSOR_HAND);
|
||||
s_cur_arrow = new wxCursor(wxCURSOR_ARROW);
|
||||
}
|
||||
|
||||
if (m_tmpMouseMoved && (m_Cell != NULL))
|
||||
{
|
||||
int sx, sy;
|
||||
GetViewStart(&sx, &sy);
|
||||
sx *= wxHTML_SCROLL_STEP;
|
||||
sy *= wxHTML_SCROLL_STEP;
|
||||
|
||||
int x, y;
|
||||
wxGetMousePosition(&x, &y);
|
||||
ScreenToClient(&x, &y);
|
||||
x += sx;
|
||||
y += sy;
|
||||
|
||||
wxHtmlCell *cell = m_Cell->FindCellByPos(x, y);
|
||||
if ( cell != m_tmpLastCell )
|
||||
{
|
||||
wxHtmlLinkInfo *lnk = cell ? cell->GetLink(x, y) : NULL;
|
||||
|
||||
if (lnk != m_tmpLastLink)
|
||||
{
|
||||
if (lnk == NULL)
|
||||
{
|
||||
SetCursor(*s_cur_arrow);
|
||||
if (m_RelatedStatusBar != -1)
|
||||
m_RelatedFrame->SetStatusText(wxEmptyString, m_RelatedStatusBar);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCursor(*s_cur_hand);
|
||||
if (m_RelatedStatusBar != -1)
|
||||
m_RelatedFrame->SetStatusText(lnk->GetHref(), m_RelatedStatusBar);
|
||||
}
|
||||
m_tmpLastLink = lnk;
|
||||
}
|
||||
|
||||
m_tmpLastCell = cell;
|
||||
}
|
||||
else // mouse moved but stayed in the same cell
|
||||
{
|
||||
if ( cell )
|
||||
OnCellMouseHover(cell, x, y);
|
||||
}
|
||||
|
||||
m_tmpMouseMoved = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxHtmlProcessor,wxObject)
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow)
|
||||
EVT_SIZE(wxHtmlWindow::OnSize)
|
||||
EVT_LEFT_DOWN(wxHtmlWindow::OnMouseEvent)
|
||||
EVT_RIGHT_DOWN(wxHtmlWindow::OnMouseEvent)
|
||||
EVT_MOTION(wxHtmlWindow::OnMouseEvent)
|
||||
EVT_IDLE(wxHtmlWindow::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// A module to allow initialization/cleanup
|
||||
// without calling these functions from app.cpp or from
|
||||
// the user's application.
|
||||
|
||||
class wxHtmlWinModule: public wxModule
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxHtmlWinModule)
|
||||
public:
|
||||
wxHtmlWinModule() : wxModule() {}
|
||||
bool OnInit() { return TRUE; }
|
||||
void OnExit() { wxHtmlWindow::CleanUpStatics(); }
|
||||
};
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinModule, wxModule)
|
||||
|
||||
|
||||
// This hack forces the linker to always link in m_* files
|
||||
// (wxHTML doesn't work without handlers from these files)
|
||||
#include "wx/html/forcelnk.h"
|
||||
FORCE_WXHTML_MODULES()
|
||||
|
||||
#endif
|
|
@ -1,138 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: m_links.cpp
|
||||
// Purpose: wxHtml module for links & anchors
|
||||
// Author: Vaclav Slavik
|
||||
// RCS-ID: $Id: m_links.cpp,v 1.2 2003/09/22 19:28:09 joostverburg Exp $
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/defs.h"
|
||||
#if wxUSE_HTML && wxUSE_STREAMS
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WXPRECOMP
|
||||
#endif
|
||||
|
||||
#include "wx/html/forcelnk.h"
|
||||
#include "wx/html/m_templ.h"
|
||||
|
||||
|
||||
FORCE_LINK_ME(m_links)
|
||||
|
||||
|
||||
class wxHtmlAnchorCell : public wxHtmlCell
|
||||
{
|
||||
private:
|
||||
wxString m_AnchorName;
|
||||
|
||||
public:
|
||||
wxHtmlAnchorCell(const wxString& name) : wxHtmlCell() {m_AnchorName = name;}
|
||||
virtual const wxHtmlCell* Find(int condition, const void* param) const
|
||||
{
|
||||
if ((condition == wxHTML_COND_ISANCHOR) && (m_AnchorName == (*((const wxString*)param))))
|
||||
return this;
|
||||
else
|
||||
return wxHtmlCell::Find(condition, param);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
TAG_HANDLER_BEGIN(A, "A")
|
||||
|
||||
TAG_HANDLER_PROC(tag)
|
||||
{
|
||||
if (tag.HasParam( wxT("NAME") ))
|
||||
{
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
|
||||
}
|
||||
|
||||
if (tag.HasParam( wxT("HREF") ))
|
||||
{
|
||||
wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
|
||||
wxColour oldclr = m_WParser->GetActualColor();
|
||||
int oldund = m_WParser->GetFontUnderlined();
|
||||
wxString name(tag.GetParam( wxT("HREF") )), target;
|
||||
|
||||
wxColor LinkColor;
|
||||
LinkColor.Set(0x0C, 0x6E, 0x97);
|
||||
|
||||
char apppath[MAX_PATH],*temp;
|
||||
GetModuleFileName(NULL,apppath,sizeof(apppath));
|
||||
temp=strrchr(apppath,'\\');
|
||||
if(temp!=NULL) *temp=0;
|
||||
|
||||
char fullpath[MAX_PATH];
|
||||
|
||||
if (name.Left(3).Cmp("EX:") == 0)
|
||||
{
|
||||
// External
|
||||
|
||||
if ((name.Left(10).Cmp("EX:http://") == 0) || (name.Left(9).Cmp("EX:irc://") == 0))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_snprintf(fullpath,sizeof(fullpath),"%s\\%s",apppath,name.Mid(3));
|
||||
|
||||
if (wxFileExists(fullpath) || wxDirExists(fullpath))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Feature not installed
|
||||
LinkColor.Set(0x80, 0x80, 0x80);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
|
||||
m_WParser->SetActualColor(LinkColor);
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(LinkColor));
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
|
||||
m_WParser->SetLink(wxHtmlLinkInfo(name, target));
|
||||
|
||||
ParseInner(tag);
|
||||
|
||||
m_WParser->SetLink(oldlnk);
|
||||
m_WParser->SetFontUnderlined(oldund);
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
|
||||
m_WParser->SetActualColor(oldclr);
|
||||
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
TAG_HANDLER_END(A)
|
||||
|
||||
|
||||
|
||||
TAGS_MODULE_BEGIN(Links)
|
||||
|
||||
TAGS_MODULE_ADD(A)
|
||||
|
||||
TAGS_MODULE_END(Links)
|
||||
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
4
Contrib/NSIS Menu/wx/build.txt
Normal file
4
Contrib/NSIS Menu/wx/build.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
1. Install wxWidgets 2.8
|
||||
2. Set WXWIN environment variable
|
||||
3. Run wxbuild.bat
|
||||
4. Build NSIS happily
|
File diff suppressed because it is too large
Load diff
14
Contrib/NSIS Menu/wx/wxbuild.bat
Normal file
14
Contrib/NSIS Menu/wx/wxbuild.bat
Normal file
|
@ -0,0 +1,14 @@
|
|||
if not exist %WXWIN%\build\msw\makefile.vc goto error
|
||||
set OLDCD=%CD%
|
||||
cd %WXWIN%
|
||||
copy /y %WXWIN%\include\wx\msw\setup.h %OLDCD%\old_setup.h
|
||||
copy /y %OLDCD%\setup.h %WXWIN%\include\wx\msw\setup.h
|
||||
rd /S ..\..\lib\vc_libnsis
|
||||
rd /S vc_mswnsis
|
||||
nmake -f makefile.vc CFG=nsis BUILD=release RUNTIME_LIBS=dynamic SHARED=0 UNICODE=0 WXUNIV=0 USE_OPENGL=0 USE_ODBC=0 USE_HTML=1 USE_XRC=0
|
||||
copy /y %OLDCD%\old_setup.h %WXWIN%\include\wx\msw\setup.h
|
||||
cd %OLDCD%
|
||||
goto done
|
||||
:error
|
||||
echo WXWIN is not properly set
|
||||
:done
|
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<body link="#0C6E97">
|
||||
<div><img src="images/header.gif" width="598" height="45"></div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<body link="#0C6E97">
|
||||
<div><img src="images/header.gif" width="598" height="45"></div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<html>
|
||||
<body>
|
||||
<body link="#0C6E97">
|
||||
<div><img src="images/header.gif" width="598" height="45"></div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td width="170">
|
||||
<p><img src="images/clear.gif" width="170" height="3">
|
||||
<a href="#"><img src="images/menud.gif" width="30" height="18"><font size="+1" color="#808080"><b>Quick Launch</b></font></a></p>
|
||||
<p><a href="#"><img src="images/menud.gif" width="30" height="18"><font size="+1" color="#808080"><b>Quick Launch</b></font></a></p>
|
||||
<p><a href="intro.html"><img src="images/menu.gif" width="30" height="18"><font size="+1" color="#0C6E97"><b>Introduction</b></font></a></p>
|
||||
<p><a href="compiler.html"><img src="images/menu.gif" width="30" height="18"><font size="+1" color="#0C6E97"><b>Compiler</b></font></a></p>
|
||||
<p><a href="docs.html"><img src="images/menu.gif" width="30" height="18"><font size="+1" color="#0C6E97"><b>Documentation</b></font></a></p>
|
||||
|
@ -41,7 +40,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p><img src="images/clear.gif" width="598" height="3">
|
||||
<p><img src="images/clear.gif" width="598" height="1">
|
||||
<img src="images/line.gif" width="598" height="3"></p>
|
||||
<div align="right"><a href="EX:http://nsis.sourceforge.net/"><img src="images/site.gif" width="200" height="25"></a></div>
|
||||
</body>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<body link="#0C6E97">
|
||||
<div><img src="images/header.gif" width="598" height="45"></div>
|
||||
<img src="images/clear.gif" width="1" height="3">
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td width="170">
|
||||
|
@ -26,7 +27,8 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p><img src="images/line.gif" width="598" height="3"></p>
|
||||
<p><img src="images/clear.gif" width="598" height="4">
|
||||
<img src="images/line.gif" width="598" height="3"></p>
|
||||
<div align="right"><a href="EX:http://nsis.sourceforge.net/"><img src="images/site.gif" width="200" height="25"></a></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<body link="#0C6E97">
|
||||
<div><img src="images/header.gif" width="598" height="45"></div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
|
@ -20,7 +20,8 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p><img src="images/line.gif" width="598" height="3"></p>
|
||||
<p><img src="images/clear.gif" width="598" height="3">
|
||||
<img src="images/line.gif" width="598" height="3"></p>
|
||||
<div align="right"><a href="EX:http://nsis.sourceforge.net/"><img src="images/site.gif" width="200" height="25"></a></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<body link="#0C6E97">
|
||||
<div><img src="images/header.gif" width="598" height="45"></div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<body link="#0C6E97">
|
||||
<div><img src="images/header.gif" width="598" height="45"></div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
|
|
13
SConstruct
13
SConstruct
|
@ -1,11 +1,3 @@
|
|||
## TODO
|
||||
#
|
||||
# * Write SConscript for NSIS Menu
|
||||
# - Use inheritance instead of current wxWidgets patches
|
||||
# - Compile for POSIX too? wxWidgets is cross platform after all...
|
||||
#
|
||||
##
|
||||
|
||||
EnsurePythonVersion(1,6)
|
||||
|
||||
try:
|
||||
|
@ -510,12 +502,15 @@ def BuildUtil(target, source, libs, entry = None, res = None,
|
|||
resources = None, defines = None, flags = None,
|
||||
nodeflib = False, file_name = '', path='', contrib = False,
|
||||
examples = None, docs = None, cross_platform = False,
|
||||
root_util = False):
|
||||
root_util = False, libpath = [], incpath = []):
|
||||
if not cross_platform:
|
||||
env = util_env.Clone()
|
||||
else:
|
||||
env = cp_util_env.Clone()
|
||||
|
||||
env.Append(CPPPATH = incpath)
|
||||
env.Append(LIBPATH = libpath)
|
||||
|
||||
AddEnvStandardFlags(env, defines, flags, entry, nodeflib)
|
||||
|
||||
AppendRES(env, source, res, resources)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue