]> git.saurik.com Git - wxWidgets.git/blame - samples/ipc/server.h
use kind, not id, of a menu item to test whether it's a separator: this allows having...
[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
9d860992
JS
14#define ID_START 10000
15#define ID_DISCONNECT 10001
16#define ID_ADVISE 10002
17#define ID_LOG 10003
18#define ID_SERVERNAME 10004
19
7921cf2b 20// Define a new application
4b89c618 21class MyServer;
9d860992
JS
22class MyFrame;
23
4b89c618 24class MyApp : public wxApp
7921cf2b 25{
4b89c618
VZ
26public:
27 virtual bool OnInit();
28 virtual int OnExit();
9d860992 29 MyFrame *GetFrame() { return m_frame; };
4b89c618 30
9d860992
JS
31protected:
32 MyFrame *m_frame;
7921cf2b
JS
33};
34
35DECLARE_APP(MyApp)
36
37// Define a new frame
4b89c618 38class MyFrame : public wxFrame
7921cf2b 39{
4b89c618
VZ
40public:
41 MyFrame(wxFrame *frame, const wxString& title);
7921cf2b 42
f6bcfd97 43 void OnExit(wxCommandEvent& event);
9d860992
JS
44 void OnClose(wxCloseEvent& event);
45
46 void Enable();
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 ); }
54 wxTextCtrl* GetLog() { return (wxTextCtrl*) FindWindow( ID_LOG ); }
4b89c618 55
9d860992
JS
56
57 MyServer *m_server;
58
59 void OnStart( wxCommandEvent &event );
60 void OnServerName( wxCommandEvent &event );
61 void OnDisconnect( wxCommandEvent &event );
62 void OnAdvise( wxCommandEvent &event );
4b89c618
VZ
63
64 DECLARE_EVENT_TABLE()
7921cf2b
JS
65};
66
521d3436 67class MyConnection : public MyConnectionBase
7921cf2b 68{
4b89c618 69public:
50c549b9
VZ
70 virtual bool OnExecute(const wxString& topic, const void *data, size_t size, wxIPCFormat format);
71 virtual const void *OnRequest(const wxString& topic, const wxString& item, size_t *size, wxIPCFormat format);
72 virtual bool OnPoke(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
9d860992
JS
73 virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
74 virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
50c549b9 75 virtual bool DoAdvise(const wxString& item, const void *data, size_t size, wxIPCFormat format);
9d860992 76 virtual bool OnDisconnect();
521d3436 77
9d860992 78 wxString m_sAdvise;
521d3436 79
9d860992
JS
80protected:
81 wxString m_sRequestDate;
50c549b9 82 char m_achRequestBytes[3];
7921cf2b
JS
83};
84
85class MyServer: public wxServer
86{
87public:
9d860992
JS
88 MyServer();
89 ~MyServer();
90 void Disconnect();
91 bool IsConnected() { return m_connection != NULL; };
92 MyConnection *GetConnection() { return m_connection; };
93 void Advise();
94 bool CanAdvise() { return m_connection != NULL && !m_connection->m_sAdvise.IsEmpty(); };
7921cf2b 95 wxConnectionBase *OnAcceptConnection(const wxString& topic);
7921cf2b 96
9d860992
JS
97protected:
98 MyConnection *m_connection;
7921cf2b
JS
99};
100