Pruned some of txrc.tex; removed redundant helpxlp files.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13921 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2002-01-29 23:08:49 +00:00
parent 2f2f3e2ab7
commit 88bed4b484
4 changed files with 1 additions and 454 deletions

View File

@ -128,46 +128,10 @@ For example:
This is the C++ source file (xrcdemo.cpp) for the XRC sample.
\begin{verbatim}
/////////////////////////////////////////////////////////////////////////////
// Name: xmldemo.cpp
// Purpose: XML resources sample
// Author: Vaclav Slavik
// RCS-ID: $Id$
// Copyright: (c) Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "xrcdemo.cpp"
#pragma interface "xrcdemo.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/wx.h"
#include "wx/image.h"
#include "wx/xrc/xmlres.h"
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------
// the application icon
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#include "rc/appicon.xpm"
@ -212,9 +176,6 @@ private:
// 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_MENU(XRCID("menu_quit"), MyFrame::OnQuit)
EVT_MENU(XRCID("menu_about"), MyFrame::OnAbout)
@ -222,17 +183,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XRCID("menu_dlg2"), MyFrame::OnDlg2)
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. MyApp and
// not wxApp)
IMPLEMENT_APP(MyApp)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------
@ -264,9 +216,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
SetToolBar(wxXmlResource::Get()->LoadToolBar(this, "toolbar"));
}
// event handlers
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
// TRUE is to force the frame to close
@ -289,7 +239,6 @@ void MyFrame::OnDlg1(wxCommandEvent& WXUNUSED(event))
dlg.ShowModal();
}
void MyFrame::OnDlg2(wxCommandEvent& WXUNUSED(event))
{
wxDialog dlg;

View File

@ -1,130 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: helpxlp.h
// Purpose: Help system: wxHelp implementation
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __HELPXLPH__
#define __HELPXLPH__
#ifdef __GNUG__
#pragma interface "helpxlp.h"
#endif
#include "wx/defs.h"
#if wxUSE_HELP
#include "wx/helpbase.h"
#ifdef __WXMSW__
#include "wx/dde.h"
#else
#include "wx/sckipc.h"
#endif
class WXDLLEXPORT wxXLPHelpController;
// Connection class for implementing the connection between the
// wxHelp process and the application
class WXDLLEXPORT wxXLPHelpConnection: public
#ifdef __WXMSW__
wxDDEConnection
#else
wxTCPConnection
#endif
{
friend class wxXLPHelpController;
DECLARE_DYNAMIC_CLASS(wxXLPHelpConnection)
public:
wxXLPHelpConnection(wxXLPHelpController *instance);
bool OnDisconnect(void);
private:
wxXLPHelpController *helpInstance;
};
// Connection class for implementing the client process
// controlling the wxHelp process
class WXDLLEXPORT wxXLPHelpClient: public
#ifdef __WXMSW__
wxDDEClient
#else
wxTCPClient
#endif
{
DECLARE_CLASS(wxXLPHelpClient)
friend class WXDLLEXPORT wxXLPHelpController;
public:
wxXLPHelpClient(wxXLPHelpController* c) { m_controller = c; }
wxConnectionBase *OnMakeConnection(void)
{ return new wxXLPHelpConnection(m_controller);
}
protected:
wxXLPHelpController* m_controller;
};
// An application can have one or more instances of wxHelp,
// represented by an object of this class.
// Nothing happens on initial creation; the application
// must call a member function to display help.
// If the instance of wxHelp is already active, that instance
// will be used for subsequent help.
class WXDLLEXPORT wxXLPHelpController: public wxHelpControllerBase
{
friend class WXDLLEXPORT wxXLPHelpConnection;
DECLARE_CLASS(wxXLPHelpController)
public:
wxXLPHelpController(void);
~wxXLPHelpController(void);
// Must call this to set the filename and server name
virtual bool Initialize(const wxString& file, int server = -1);
// If file is "", reloads file given in Initialize
virtual bool LoadFile(const wxString& file = "");
virtual bool DisplayContents(void);
virtual bool DisplaySection(int sectionNo);
virtual bool DisplayBlock(long blockNo);
virtual bool KeywordSearch(const wxString& k);
virtual bool DisplaySection(const wxString& section)
{
return wxHelpControllerBase::DisplaySection(section);
}
virtual bool Quit(void);
virtual void OnQuit(void);
// Private
bool Run(void);
protected:
wxString helpFile;
wxString helpHost;
int helpServer;
bool helpRunning;
wxXLPHelpConnection* helpConnection;
wxXLPHelpClient helpClient;
private:
virtual bool Initialize(const wxString& file) { return(wxHelpControllerBase::Initialize(file)); };
};
#endif // wxUSE_HELP
#endif
// __HELPXLPH__

View File

@ -1,7 +0,0 @@
#ifndef _WX_HELPXLP_H_BASE_
#define _WX_HELPXLP_H_BASE_
#include "wx/generic/helpxlp.h"
#endif
// _WX_HELPXLP_H_BASE_

View File

@ -1,265 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: helpxlp.cpp
// Purpose: Help system: wxHelp implementation
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "helpxlp.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/defs.h"
#endif
#include "wx/generic/helpxlp.h"
#include "wx/intl.h"
#include "wx/msgdlg.h"
#if wxUSE_HELP
#include <time.h>
#ifdef __X__
#include <netdb.h>
#ifdef SUN_CC
#include <sysent.h>
#endif // SUN_CC
#ifdef ____HPUX__
#include <sys/unistd.h>
#endif // ____HPUX__
#endif // __X__
#include <string.h>
// Timeout in seconds
#define WX_HELP_TIMEOUT 15 /* was 30 */
// MAX path length
#define _MAXPATHLEN 500
// MAX length of Help descriptor
#define _MAX_HELP_LEN 500
#include "wx/generic/helpxlp.h"
#ifdef __WXMSW__
IMPLEMENT_CLASS(wxXLPHelpClient, wxDDEClient)
IMPLEMENT_CLASS(wxXLPHelpConnection, wxDDEConnection)
#else
IMPLEMENT_CLASS(wxXLPHelpClient, wxTCPClient)
IMPLEMENT_CLASS(wxXLPHelpConnection, wxTCPConnection)
#endif
IMPLEMENT_CLASS(wxXLPHelpController, wxHelpControllerBase)
// suppress annoying warning "'this' used in base member init list" (so what?)
#ifdef __VISUALC__
#pragma warning(disable: 4355)
#endif // Visual C++
wxXLPHelpController::wxXLPHelpController(void)
: helpClient(this)
{
helpFile = ""; helpServer = -1; helpHost = "";
helpRunning = FALSE; helpConnection = NULL;
}
#ifdef __VISUALC__
#pragma warning(default: 4355)
#endif // Visual C++
wxXLPHelpController::~wxXLPHelpController(void)
{
}
bool wxXLPHelpController::Initialize(const wxString& filename, int server)
{
#ifdef __X__
char host_buf[255];
if (wxGetHostName(host_buf, sizeof(host_buf)))
helpHost = host_buf;
else helpHost = "";
#endif
helpFile = filename;
helpServer = server;
return TRUE;
}
bool wxXLPHelpController::LoadFile(const wxString& file)
{
helpFile = file;
if (!helpRunning)
{
if (!Run())
return FALSE;
}
char buf[_MAX_HELP_LEN];
sprintf(buf, "f %s", (const char*) file);
if (helpConnection)
return helpConnection->Execute(buf);
else return FALSE;
}
bool wxXLPHelpController::DisplayContents(void)
{
if (!helpRunning)
{
if (!Run())
return FALSE;
}
if (helpConnection)
return helpConnection->Execute("s -1");
else
return FALSE;
}
bool wxXLPHelpController::DisplaySection(int section)
{
if (!helpRunning)
{
if (!Run())
return FALSE;
}
char buf[_MAX_HELP_LEN];
sprintf(buf, "s %d", section);
if (helpConnection)
return helpConnection->Execute(buf);
else return FALSE;
}
bool wxXLPHelpController::DisplayBlock(long block)
{
if (!helpRunning)
{
if (!Run())
return FALSE;
}
char buf[_MAX_HELP_LEN];
sprintf(buf, "b %ld", block);
if (helpConnection)
return helpConnection->Execute(buf);
else return FALSE;
}
bool wxXLPHelpController::KeywordSearch(const wxString& k)
{
if (!helpRunning)
{
if (!Run())
return FALSE;
}
char buf[500];
sprintf(buf, "k %s", (const char*) k);
if (helpConnection)
return helpConnection->Execute(buf);
else return FALSE;
}
bool wxXLPHelpController::Quit(void)
{
if (helpConnection)
return helpConnection->Disconnect(); // Calls OnQuit via OnDisconnect
else return TRUE;
}
void wxXLPHelpController::OnQuit(void)
{
}
bool wxXLPHelpController::Run(void)
{
#ifdef __X__
if (!helpFile || !helpHost || helpRunning)
return FALSE;
#endif
#ifdef __WXMSW__
if (!helpFile || helpRunning)
return FALSE;
#endif
time_t current_time;
#ifdef __X__
// Invent a server name that's likely to be unique but different from
// last time
(void)time(&current_time);
if (helpServer == -1)
helpServer = (int)(4000 + (current_time % 4000));
#else
// Only one instance of wxHelp at a time
helpServer = 4000;
#endif
char server[32];
sprintf(server, "%d", helpServer);
#ifdef __WXMSW__
// Only one instance of wxHelp under Windows.
// See if there's already an instance of wxHelp
if ((helpConnection = (wxXLPHelpConnection *)helpClient.MakeConnection(helpHost, server, "WXHELP")))
{
helpRunning = TRUE;
return TRUE;
}
#endif
// Start help process in server modus
// char *argv[] = {"wxhelp", "-server", server, NULL}; // HP compiler complains
char *argv[4];
argv[0] = "wxhelp";
argv[1] = "-server";
argv[2] = server;
argv[3] = NULL;
if (wxExecute((char **)argv) == FALSE)
return FALSE; // Maybe we should print a message?
time_t start_time;
(void)time(&start_time);
// Give it some time to respond
do {
wxSleep(1);
helpConnection = (wxXLPHelpConnection *)helpClient.MakeConnection(helpHost, server, "WXHELP");
(void)time(&current_time);
} while (!helpConnection && ((current_time - start_time) < WX_HELP_TIMEOUT));
if (helpConnection == NULL) {
char buf[100];
sprintf(buf, (const char *) _("Connection to wxHelp timed out in %d seconds"), WX_HELP_TIMEOUT);
(void)wxMessageBox(buf, _("Error"));
return FALSE;
}
helpRunning = TRUE;
return TRUE;
}
wxXLPHelpConnection::wxXLPHelpConnection(wxXLPHelpController *instance)
{
helpInstance = instance;
}
bool wxXLPHelpConnection::OnDisconnect(void)
{
helpInstance->OnQuit();
helpInstance->helpRunning = FALSE;
helpInstance->helpConnection = NULL;
helpInstance->helpServer = -1;
delete this;
return TRUE;
}
#endif // wxUSE_HELP