]> git.saurik.com Git - wxWidgets.git/blob - samples/ipc/server.h
Remove wxRTTI macro for wxComboBox from Motif port.
[wxWidgets.git] / samples / ipc / server.h
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
12 #include "connection.h"
13
14 enum
15 {
16 ID_START = 10000,
17 ID_DISCONNECT,
18 ID_ADVISE,
19 ID_SERVERNAME,
20 };
21
22 // Define a new application
23 class MyServer;
24 class MyFrame;
25
26 class MyApp : public wxApp
27 {
28 public:
29 virtual bool OnInit();
30 MyFrame *GetFrame() { return m_frame; }
31
32 protected:
33 MyFrame *m_frame;
34 };
35
36 DECLARE_APP(MyApp)
37
38 // Define a new frame
39 class MyFrame : public wxFrame
40 {
41 public:
42 MyFrame(wxFrame *frame, const wxString& title);
43
44 void OnClose(wxCloseEvent& event);
45
46 void UpdateUI();
47 void Disconnect();
48
49 protected:
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
55
56 MyServer *m_server;
57
58 void OnStart( wxCommandEvent &event );
59 void OnServerName( wxCommandEvent &event );
60 void OnDisconnect( wxCommandEvent &event );
61 void OnAdvise( wxCommandEvent &event );
62
63 DECLARE_EVENT_TABLE()
64 };
65
66 class MyConnection : public MyConnectionBase
67 {
68 public:
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);
72 virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
73 virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
74 virtual bool DoAdvise(const wxString& item, const void *data, size_t size, wxIPCFormat format);
75 virtual bool OnDisconnect();
76
77 // topic for which we advise the client or empty if none
78 wxString m_advise;
79
80 protected:
81 // the data returned by last OnRequest(): we keep it in this buffer to
82 // ensure that the pointer we return from OnRequest() stays valid
83 wxCharBuffer m_requestData;
84 };
85
86 class MyServer : public wxServer
87 {
88 public:
89 MyServer();
90 virtual ~MyServer();
91
92 void Disconnect();
93 bool IsConnected() { return m_connection != NULL; }
94 MyConnection *GetConnection() { return m_connection; }
95
96 void Advise();
97 bool CanAdvise() { return m_connection && !m_connection->m_advise.empty(); }
98
99 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
100
101 protected:
102 MyConnection *m_connection;
103 };
104