Added IPC server capability to helpview, if you compile
with hvUSE_IPC Added client demo using raw IPC classes (not yet using a kind of help controller, as we eventually should) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17483 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
309
utils/helpview/src/client.cpp
Normal file
309
utils/helpview/src/client.cpp
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: client.cpp
|
||||||
|
// Purpose: Tests helpview in server mode.
|
||||||
|
// Author: Julian Smart
|
||||||
|
// Modified by:
|
||||||
|
// Created: 2002-10-08
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Julian Smart
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||||
|
#pragma implementation "client.cpp"
|
||||||
|
#pragma interface "client.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 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/ipc.h"
|
||||||
|
#include "wx/process.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class MyConnection: public wxConnection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyConnection();
|
||||||
|
~MyConnection();
|
||||||
|
|
||||||
|
bool OnAdvise(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format);
|
||||||
|
bool OnDisconnect();
|
||||||
|
};
|
||||||
|
|
||||||
|
class MyClient: public wxClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxConnectionBase *OnMakeConnection();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define a new application type, each program should derive a class from wxApp
|
||||||
|
class HelpClientApp : 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 HelpClientFrame : public wxFrame
|
||||||
|
{
|
||||||
|
friend MyClient;
|
||||||
|
friend MyConnection;
|
||||||
|
public:
|
||||||
|
// ctor(s)
|
||||||
|
HelpClientFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnHelpPage(wxCommandEvent& event);
|
||||||
|
void OnHelpContents(wxCommandEvent& event);
|
||||||
|
void OnClose(wxCloseEvent& event);
|
||||||
|
|
||||||
|
bool CreateConnection();
|
||||||
|
private:
|
||||||
|
MyConnection* m_connection;
|
||||||
|
MyClient* m_client;
|
||||||
|
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpClientFrame* g_MainFrame = NULL;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
HelpClient_Quit = 1,
|
||||||
|
HelpClient_HelpPage,
|
||||||
|
HelpClient_HelpContents,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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(HelpClientFrame, wxFrame)
|
||||||
|
EVT_MENU(HelpClient_Quit, HelpClientFrame::OnQuit)
|
||||||
|
EVT_MENU(HelpClient_HelpPage, HelpClientFrame::OnHelpPage)
|
||||||
|
EVT_MENU(HelpClient_HelpContents, HelpClientFrame::OnHelpContents)
|
||||||
|
EVT_CLOSE(HelpClientFrame::OnClose)
|
||||||
|
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 declares the accessor function
|
||||||
|
// wxGetApp() which will return the reference of the right type (i.e. HelpClientApp and
|
||||||
|
// not wxApp)
|
||||||
|
IMPLEMENT_APP(HelpClientApp)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// the application class
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// `Main program' equivalent: the program execution "starts" here
|
||||||
|
bool HelpClientApp::OnInit()
|
||||||
|
{
|
||||||
|
SetVendorName("wxWindows");
|
||||||
|
SetAppName("Help Client Demo");
|
||||||
|
|
||||||
|
// Create the main application window
|
||||||
|
HelpClientFrame *frame = new HelpClientFrame("Help Client Demo",
|
||||||
|
wxPoint(50, 50), wxSize(150, 50));
|
||||||
|
|
||||||
|
// Show it and tell the application that it's our main window
|
||||||
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// main frame
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
HelpClientFrame::HelpClientFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||||
|
{
|
||||||
|
g_MainFrame = this;
|
||||||
|
|
||||||
|
// create a menu bar
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
|
||||||
|
menuFile->Append(HelpClient_HelpContents, "&Help Contents");
|
||||||
|
menuFile->Append(HelpClient_HelpPage, "Help Page");
|
||||||
|
menuFile->AppendSeparator();
|
||||||
|
menuFile->Append(HelpClient_Quit, "E&xit");
|
||||||
|
|
||||||
|
// now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
m_connection = NULL;
|
||||||
|
m_client = new MyClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
|
||||||
|
void HelpClientFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// TRUE is to force the frame to close
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpClientFrame::OnHelpPage(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (CreateConnection())
|
||||||
|
{
|
||||||
|
m_connection->Execute(wxT("Book 1"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpClientFrame::OnHelpContents(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (CreateConnection())
|
||||||
|
{
|
||||||
|
m_connection->Execute(wxT("test.zip"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpClientFrame::OnClose(wxCloseEvent& event)
|
||||||
|
{
|
||||||
|
if (m_connection)
|
||||||
|
{
|
||||||
|
m_connection->Disconnect();
|
||||||
|
delete m_connection;
|
||||||
|
m_connection = NULL;
|
||||||
|
}
|
||||||
|
delete m_client;
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HelpClientFrame::CreateConnection()
|
||||||
|
{
|
||||||
|
if (m_connection)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
wxString cmd;
|
||||||
|
|
||||||
|
#if defined(__WXMSW__)
|
||||||
|
cmd = "helpview.exe --server test.zip";
|
||||||
|
#else
|
||||||
|
cmd = "./helpview --server test.zip";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxProcess *process = new wxProcess(this);
|
||||||
|
int pid = wxExecute( cmd, FALSE, process );
|
||||||
|
if( pid <= 0 ) {
|
||||||
|
wxMessageBox( "Failed to start server" );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// service name (DDE classes) or port number (TCP/IP based classes)
|
||||||
|
wxString service = wxT("4242");
|
||||||
|
|
||||||
|
// ignored under DDE, host name in TCP/IP based classes
|
||||||
|
wxString hostName = wxT("localhost");
|
||||||
|
|
||||||
|
int nsleep = 0;
|
||||||
|
|
||||||
|
// suppress the log messages from MakeConnection()
|
||||||
|
{
|
||||||
|
|
||||||
|
wxLogNull nolog;
|
||||||
|
m_connection = (MyConnection *)m_client->MakeConnection(hostName, service, wxT("HELP"));
|
||||||
|
|
||||||
|
while ( !m_connection)
|
||||||
|
{
|
||||||
|
//try every second for a while
|
||||||
|
wxSleep(1);
|
||||||
|
if( nsleep > 4 ) {
|
||||||
|
if ( wxMessageBox("Failed to make connection to server.\nRetry?",
|
||||||
|
"Client Demo Error",
|
||||||
|
wxICON_ERROR | wxYES_NO | wxCANCEL ) != wxYES )
|
||||||
|
{
|
||||||
|
// no server
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nsleep++;
|
||||||
|
|
||||||
|
m_connection = (MyConnection *)m_client->MakeConnection(hostName, service, "HELP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (m_connection != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxConnectionBase *MyClient::OnMakeConnection()
|
||||||
|
{
|
||||||
|
return new MyConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyConnection::MyConnection()
|
||||||
|
: wxConnection()
|
||||||
|
{
|
||||||
|
g_MainFrame->m_connection = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyConnection::~MyConnection()
|
||||||
|
{
|
||||||
|
g_MainFrame->m_connection = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyConnection::OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyConnection::OnDisconnect()
|
||||||
|
{
|
||||||
|
g_MainFrame->m_connection = NULL;
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
154
utils/helpview/src/client.dsp
Normal file
154
utils/helpview/src/client.dsp
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
# Microsoft Developer Studio Project File - Name="htmlclient" - Package Owner=<4>
|
||||||
|
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||||
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
|
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||||
|
|
||||||
|
CFG=htmlclient - Win32 Debug
|
||||||
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
|
!MESSAGE use the Export Makefile command and run
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "client.mak".
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "client.mak" CFG="htmlclient - Win32 Debug"
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE Possible choices for configuration are:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE "htmlclient - Win32 Release DLL" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE "htmlclient - Win32 Debug DLL" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE "htmlclient - Win32 Release" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE "htmlclient - Win32 Debug" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE
|
||||||
|
|
||||||
|
# Begin Project
|
||||||
|
# PROP Scc_ProjName ""
|
||||||
|
# PROP Scc_LocalPath ""
|
||||||
|
CPP=cl.exe
|
||||||
|
MTL=midl.exe
|
||||||
|
RSC=rc.exe
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "htmlclient - Win32 Release DLL"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "ReleaseDll"
|
||||||
|
# PROP BASE Intermediate_Dir "ReleaseDll"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "ReleaseDll"
|
||||||
|
# PROP Intermediate_Dir "ReleaseDll"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /O2 /I "../../../include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MD /D WXUSINGDLL /I../../..\lib\mswdll
|
||||||
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG" /I "../../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG" /I "../../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386 ../../..\lib\wxmsw233.lib
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "htmlclient - Win32 Debug DLL"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "DebugDll"
|
||||||
|
# PROP BASE Intermediate_Dir "DebugDll"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "DebugDll"
|
||||||
|
# PROP Intermediate_Dir "DebugDll"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /Zi /Od /I "../../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MDd /D "__WXDEBUG__" /D "WXDEBUG=1" /D WXUSINGDLL /I../../..\lib\mswdlld
|
||||||
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG" /I "../../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG" /I "../../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept ../../..\lib\wxmsw233d.lib
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "htmlclient - Win32 Release"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "Release"
|
||||||
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "Release"
|
||||||
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /O2 /I "../../../include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MD /I../../..\lib\msw
|
||||||
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG" /I "../../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG" /I "../../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386 ../../..\lib\zlib.lib ../../..\lib\regex.lib ../../..\lib\png.lib ../../..\lib\jpeg.lib ../../..\lib\tiff.lib ../../..\lib\wxmsw.lib
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "htmlclient - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "Debug"
|
||||||
|
# PROP BASE Intermediate_Dir "Debug"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "Debug"
|
||||||
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /Zi /Od /I "../../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MDd /D "__WXDEBUG__" /D "WXDEBUG=1" /I../../..\lib\mswd
|
||||||
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG" /I "../../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG" /I "../../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept ../../..\lib\zlibd.lib ../../..\lib\regexd.lib ../../..\lib\pngd.lib ../../..\lib\jpegd.lib ../../..\lib\tiffd.lib ../../..\lib\wxmswd.lib
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
# Begin Target
|
||||||
|
|
||||||
|
# Name "htmlclient - Win32 Release DLL"
|
||||||
|
# Name "htmlclient - Win32 Debug DLL"
|
||||||
|
# Name "htmlclient - Win32 Release"
|
||||||
|
# Name "htmlclient - Win32 Debug"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\client.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\client.rc
|
||||||
|
# End Source File
|
||||||
|
# End Target
|
||||||
|
# End Project
|
1
utils/helpview/src/client.rc
Normal file
1
utils/helpview/src/client.rc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
@@ -43,13 +43,15 @@ protected:
|
|||||||
const wxSize& size);
|
const wxSize& size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// private classes
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_APP(hvApp)
|
IMPLEMENT_APP(hvApp)
|
||||||
|
|
||||||
|
hvApp::hvApp()
|
||||||
|
{
|
||||||
|
#if hvUSE_IPC
|
||||||
|
m_server = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool hvApp::OnInit()
|
bool hvApp::OnInit()
|
||||||
{
|
{
|
||||||
@@ -66,24 +68,40 @@ bool hvApp::OnInit()
|
|||||||
SetAppName("wxHTMLHelp");
|
SetAppName("wxHTMLHelp");
|
||||||
wxConfig::Get(); // create an instance
|
wxConfig::Get(); // create an instance
|
||||||
|
|
||||||
help = new wxHtmlHelpController(
|
m_helpController = new wxHtmlHelpController(
|
||||||
wxHF_DEFAULT_STYLE|wxHF_FLAT_TOOLBAR|wxHF_OPEN_FILES
|
wxHF_DEFAULT_STYLE|wxHF_FLAT_TOOLBAR|wxHF_OPEN_FILES
|
||||||
);
|
);
|
||||||
|
|
||||||
help->SetTitleFormat(wxT("%s"));
|
m_helpController->SetTitleFormat(wxT("%s"));
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
if (!OpenBook(help))
|
if (!OpenBook(m_helpController))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool useAsServer = FALSE;
|
||||||
|
|
||||||
|
// If started with --server, use as help server.
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
help -> AddBook(argv[i]);
|
{
|
||||||
|
if (wxString(wxT("--server")) == argv[i])
|
||||||
|
useAsServer = TRUE;
|
||||||
|
else
|
||||||
|
m_helpController -> AddBook(argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __WXMOTIF__
|
#ifdef __WXMOTIF__
|
||||||
delete wxLog::SetActiveTarget(new wxLogGui);
|
delete wxLog::SetActiveTarget(new wxLogGui);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
help -> DisplayContents();
|
m_helpController -> DisplayContents();
|
||||||
|
|
||||||
|
#if hvUSE_IPC
|
||||||
|
if (useAsServer)
|
||||||
|
{
|
||||||
|
m_server = new hvServer;
|
||||||
|
m_server->Create(wxT("4242"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -91,7 +109,26 @@ bool hvApp::OnInit()
|
|||||||
|
|
||||||
int hvApp::OnExit()
|
int hvApp::OnExit()
|
||||||
{
|
{
|
||||||
delete help;
|
#if hvUSE_IPC
|
||||||
|
wxNode* node = m_connections.First();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxNode* next = node->Next();
|
||||||
|
hvConnection* connection = (hvConnection*) node->Data();
|
||||||
|
connection->Disconnect();
|
||||||
|
delete connection;
|
||||||
|
node = next;
|
||||||
|
}
|
||||||
|
m_connections.Clear();
|
||||||
|
|
||||||
|
if (m_server)
|
||||||
|
{
|
||||||
|
delete m_server;
|
||||||
|
m_server = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
delete m_helpController;
|
||||||
delete wxConfig::Set(NULL);
|
delete wxConfig::Set(NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -228,3 +265,67 @@ wxBitmap AlternateArtProvider::CreateBitmap(const wxArtID& id,
|
|||||||
// will be provided by the default art provider.
|
// will be provided by the default art provider.
|
||||||
return wxNullBitmap;
|
return wxNullBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if hvUSE_IPC
|
||||||
|
|
||||||
|
wxConnectionBase *hvServer::OnAcceptConnection(const wxString& topic)
|
||||||
|
{
|
||||||
|
if (topic == "HELP")
|
||||||
|
return new hvConnection();
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// hvConnection
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
hvConnection::hvConnection()
|
||||||
|
: wxConnection()
|
||||||
|
{
|
||||||
|
wxGetApp().GetConnections().Append(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
hvConnection::~hvConnection()
|
||||||
|
{
|
||||||
|
wxGetApp().GetConnections().DeleteObject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hvConnection::OnExecute(const wxString& WXUNUSED(topic),
|
||||||
|
wxChar *data,
|
||||||
|
int WXUNUSED(size),
|
||||||
|
wxIPCFormat WXUNUSED(format))
|
||||||
|
{
|
||||||
|
// wxLogStatus("Execute command: %s", data);
|
||||||
|
|
||||||
|
wxGetApp().GetHelpController()->Display(data);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hvConnection::OnPoke(const wxString& WXUNUSED(topic),
|
||||||
|
const wxString& item,
|
||||||
|
wxChar *data,
|
||||||
|
int WXUNUSED(size),
|
||||||
|
wxIPCFormat WXUNUSED(format))
|
||||||
|
{
|
||||||
|
// wxLogStatus("Poke command: %s = %s", item.c_str(), data);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxChar *hvConnection::OnRequest(const wxString& WXUNUSED(topic),
|
||||||
|
const wxString& WXUNUSED(item),
|
||||||
|
int * WXUNUSED(size),
|
||||||
|
wxIPCFormat WXUNUSED(format))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hvConnection::OnStartAdvise(const wxString& WXUNUSED(topic),
|
||||||
|
const wxString& WXUNUSED(item))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// hvUSE_IPC
|
@@ -16,27 +16,77 @@
|
|||||||
#pragma interface "help.cpp"
|
#pragma interface "help.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Define a new application type, each program should derive a class from wxApp
|
// If 1, start a server to allow this to be used
|
||||||
|
// as an external help viewer.
|
||||||
|
#define hvUSE_IPC 1
|
||||||
|
|
||||||
|
#if hvUSE_IPC
|
||||||
|
#include <wx/ipc.h>
|
||||||
|
|
||||||
|
class hvConnection;
|
||||||
|
class hvServer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The helpview application class.
|
||||||
|
*/
|
||||||
|
|
||||||
class hvApp : public wxApp
|
class hvApp : public wxApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// override base class virtuals
|
hvApp();
|
||||||
// ----------------------------
|
|
||||||
|
|
||||||
// this one is called on application startup and is a good place for the app
|
/// Initialise the application.
|
||||||
// initialization (doing it here and not in the ctor allows to have an error
|
virtual bool OnInit();
|
||||||
// return: if OnInit() returns false, the application terminates)
|
|
||||||
|
|
||||||
virtual bool OnInit();
|
/// Clean up the application's data.
|
||||||
virtual int OnExit();
|
virtual int OnExit();
|
||||||
|
|
||||||
|
/// Prompt the user for a book to open
|
||||||
|
bool OpenBook(wxHtmlHelpController* controller);
|
||||||
|
|
||||||
// Prompt the user for a book to open
|
/// Returns the help controller.
|
||||||
bool OpenBook(wxHtmlHelpController* controller);
|
wxHtmlHelpController* GetHelpController() { return m_helpController; }
|
||||||
|
|
||||||
private:
|
#if hvUSE_IPC
|
||||||
wxHtmlHelpController *help;
|
/// Returns the list of connections.
|
||||||
|
wxList& GetConnections() { return m_connections; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxHtmlHelpController* m_helpController;
|
||||||
|
|
||||||
|
#if hvUSE_IPC
|
||||||
|
wxList m_connections;
|
||||||
|
hvServer* m_server;
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if hvUSE_IPC
|
||||||
|
class hvConnection : public wxConnection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
hvConnection();
|
||||||
|
~hvConnection();
|
||||||
|
|
||||||
|
bool OnExecute(const wxString& topic, wxChar*data, int size, wxIPCFormat format);
|
||||||
|
wxChar *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format);
|
||||||
|
bool OnPoke(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format);
|
||||||
|
bool OnStartAdvise(const wxString& topic, const wxString& item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
class hvServer: public wxServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxConnectionBase *OnAcceptConnection(const wxString& topic);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_HELPVIEW_H_
|
// _WX_HELPVIEW_H_
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user