]>
Commit | Line | Data |
---|---|---|
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 | ||
9d860992 JS |
12 | #define ID_START 10000 |
13 | #define ID_DISCONNECT 10001 | |
14 | #define ID_ADVISE 10002 | |
15 | #define ID_LOG 10003 | |
16 | #define ID_SERVERNAME 10004 | |
17 | ||
7921cf2b | 18 | // Define a new application |
4b89c618 | 19 | class MyServer; |
9d860992 JS |
20 | class MyConnection; |
21 | class MyFrame; | |
22 | ||
4b89c618 | 23 | class MyApp : public wxApp |
7921cf2b | 24 | { |
4b89c618 VZ |
25 | public: |
26 | virtual bool OnInit(); | |
27 | virtual int OnExit(); | |
9d860992 | 28 | MyFrame *GetFrame() { return m_frame; }; |
4b89c618 | 29 | |
9d860992 JS |
30 | protected: |
31 | MyFrame *m_frame; | |
7921cf2b JS |
32 | }; |
33 | ||
34 | DECLARE_APP(MyApp) | |
35 | ||
36 | // Define a new frame | |
4b89c618 | 37 | class MyFrame : public wxFrame |
7921cf2b | 38 | { |
4b89c618 VZ |
39 | public: |
40 | MyFrame(wxFrame *frame, const wxString& title); | |
7921cf2b | 41 | |
f6bcfd97 | 42 | void OnExit(wxCommandEvent& event); |
9d860992 JS |
43 | void OnClose(wxCloseEvent& event); |
44 | ||
45 | void Enable(); | |
46 | void Disconnect(); | |
47 | ||
48 | protected: | |
49 | wxButton* GetStart() { return (wxButton*) FindWindow( ID_START ); } | |
50 | wxChoice* GetServername() { return (wxChoice*) FindWindow( ID_SERVERNAME ); } | |
51 | wxButton* GetDisconnect() { return (wxButton*) FindWindow( ID_DISCONNECT ); } | |
52 | wxButton* GetAdvise() { return (wxButton*) FindWindow( ID_ADVISE ); } | |
53 | wxTextCtrl* GetLog() { return (wxTextCtrl*) FindWindow( ID_LOG ); } | |
4b89c618 | 54 | |
9d860992 JS |
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 ); | |
4b89c618 VZ |
62 | |
63 | DECLARE_EVENT_TABLE() | |
7921cf2b JS |
64 | }; |
65 | ||
4b89c618 | 66 | class MyConnection : public wxConnection |
7921cf2b | 67 | { |
4b89c618 | 68 | public: |
f010ad48 | 69 | MyConnection(); |
4b89c618 | 70 | ~MyConnection(); |
7921cf2b | 71 | |
9d860992 | 72 | virtual bool OnExecute(const wxString& topic, wxChar *data, int size, wxIPCFormat format); |
1e0f0a90 | 73 | virtual const wxChar *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format); |
9d860992 JS |
74 | virtual bool OnPoke(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format); |
75 | virtual bool OnStartAdvise(const wxString& topic, const wxString& item); | |
76 | virtual bool OnStopAdvise(const wxString& topic, const wxString& item); | |
1e0f0a90 | 77 | virtual bool Advise(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT); |
9d860992 JS |
78 | virtual bool OnDisconnect(); |
79 | protected: | |
1e0f0a90 | 80 | void Log(const wxString& command, const wxString& topic, const wxString& item, const wxChar *data, int size, wxIPCFormat format); |
9d860992 JS |
81 | public: |
82 | wxString m_sAdvise; | |
83 | protected: | |
84 | wxString m_sRequestDate; | |
85 | char m_achRequestBytes[3]; | |
7921cf2b JS |
86 | }; |
87 | ||
88 | class MyServer: public wxServer | |
89 | { | |
90 | public: | |
9d860992 JS |
91 | MyServer(); |
92 | ~MyServer(); | |
93 | void Disconnect(); | |
94 | bool IsConnected() { return m_connection != NULL; }; | |
95 | MyConnection *GetConnection() { return m_connection; }; | |
96 | void Advise(); | |
97 | bool CanAdvise() { return m_connection != NULL && !m_connection->m_sAdvise.IsEmpty(); }; | |
7921cf2b | 98 | wxConnectionBase *OnAcceptConnection(const wxString& topic); |
7921cf2b | 99 | |
9d860992 JS |
100 | protected: |
101 | MyConnection *m_connection; | |
7921cf2b JS |
102 | }; |
103 |