]> git.saurik.com Git - wxWidgets.git/blame - samples/ipc/server.h
Move menu messages handling from wxFrame to wxTLW in wxMSW.
[wxWidgets.git] / samples / ipc / server.h
CommitLineData
7921cf2b
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: server.h
3// Purpose: DDE sample: server
4// Author: Julian Smart
5// Modified by:
6// Created: 25/01/99
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
521d3436
VZ
12#include "connection.h"
13
589c1174
VZ
14enum
15{
16 ID_START = 10000,
17 ID_DISCONNECT,
18 ID_ADVISE,
19 ID_SERVERNAME,
20};
9d860992 21
7921cf2b 22// Define a new application
4b89c618 23class MyServer;
9d860992
JS
24class MyFrame;
25
4b89c618 26class MyApp : public wxApp
7921cf2b 27{
4b89c618
VZ
28public:
29 virtual bool OnInit();
589c1174 30 MyFrame *GetFrame() { return m_frame; }
4b89c618 31
9d860992 32protected:
589c1174 33 MyFrame *m_frame;
7921cf2b
JS
34};
35
36DECLARE_APP(MyApp)
37
38// Define a new frame
4b89c618 39class MyFrame : public wxFrame
7921cf2b 40{
4b89c618
VZ
41public:
42 MyFrame(wxFrame *frame, const wxString& title);
7921cf2b 43
9d860992
JS
44 void OnClose(wxCloseEvent& event);
45
589c1174 46 void UpdateUI();
9d860992
JS
47 void Disconnect();
48
49protected:
50 wxButton* GetStart() { return (wxButton*) FindWindow( ID_START ); }
51 wxChoice* GetServername() { return (wxChoice*) FindWindow( ID_SERVERNAME ); }
52 wxButton* GetDisconnect() { return (wxButton*) FindWindow( ID_DISCONNECT ); }
53 wxButton* GetAdvise() { return (wxButton*) FindWindow( ID_ADVISE ); }
4b89c618 54
9d860992 55
589c1174 56 MyServer *m_server;
9d860992
JS
57
58 void OnStart( wxCommandEvent &event );
59 void OnServerName( wxCommandEvent &event );
60 void OnDisconnect( wxCommandEvent &event );
61 void OnAdvise( wxCommandEvent &event );
4b89c618
VZ
62
63 DECLARE_EVENT_TABLE()
7921cf2b
JS
64};
65
521d3436 66class MyConnection : public MyConnectionBase
7921cf2b 67{
4b89c618 68public:
50c549b9
VZ
69 virtual bool OnExecute(const wxString& topic, const void *data, size_t size, wxIPCFormat format);
70 virtual const void *OnRequest(const wxString& topic, const wxString& item, size_t *size, wxIPCFormat format);
71 virtual bool OnPoke(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
9d860992
JS
72 virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
73 virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
50c549b9 74 virtual bool DoAdvise(const wxString& item, const void *data, size_t size, wxIPCFormat format);
9d860992 75 virtual bool OnDisconnect();
521d3436 76
589c1174
VZ
77 // topic for which we advise the client or empty if none
78 wxString m_advise;
521d3436 79
9d860992 80protected:
e536b750 81 // the data returned by last OnRequest(): we keep it in this buffer to
589c1174 82 // ensure that the pointer we return from OnRequest() stays valid
e536b750 83 wxCharBuffer m_requestData;
7921cf2b
JS
84};
85
589c1174 86class MyServer : public wxServer
7921cf2b
JS
87{
88public:
9d860992 89 MyServer();
589c1174
VZ
90 virtual ~MyServer();
91
9d860992 92 void Disconnect();
589c1174
VZ
93 bool IsConnected() { return m_connection != NULL; }
94 MyConnection *GetConnection() { return m_connection; }
95
9d860992 96 void Advise();
589c1174
VZ
97 bool CanAdvise() { return m_connection && !m_connection->m_advise.empty(); }
98
99 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
7921cf2b 100
9d860992 101protected:
589c1174 102 MyConnection *m_connection;
7921cf2b
JS
103};
104