]> git.saurik.com Git - wxWidgets.git/blame - samples/ipc/client.h
added never_empty hint on WX_DIR option
[wxWidgets.git] / samples / ipc / client.h
CommitLineData
7921cf2b
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: client.h
3// Purpose: DDE sample: client
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_STARTADVISE 10002
15#define ID_LOG 10003
16#define ID_SERVERNAME 10004
17#define ID_STOPADVISE 10005
18#define ID_POKE 10006
19#define ID_REQUEST 10007
20#define ID_EXECUTE 10008
21#define ID_TOPIC 10009
22#define ID_HOSTNAME 10010
23
7921cf2b 24// Define a new application
9d860992
JS
25class MyClient;
26class MyConnection;
27class MyFrame;
28
7921cf2b
JS
29class MyApp: public wxApp
30{
4b89c618
VZ
31public:
32 virtual bool OnInit();
33 virtual int OnExit();
9d860992
JS
34 MyFrame *GetFrame() { return m_frame; };
35
36protected:
37 MyFrame *m_frame;
7921cf2b
JS
38};
39
40// Define a new frame
41class MyFrame: public wxFrame
42{
4b89c618
VZ
43public:
44 MyFrame(wxFrame *frame, const wxString& title);
7921cf2b 45
7921cf2b 46 void OnExit(wxCommandEvent& event);
9d860992 47 void OnClose(wxCloseEvent& event);
81ba6107 48 void EnableControls();
9d860992
JS
49 void Disconnect();
50
51protected:
52 wxButton* GetStart() { return (wxButton*) FindWindow( ID_START ); }
53 wxChoice* GetServername() { return (wxChoice*) FindWindow( ID_SERVERNAME ); }
54 wxChoice* GetHostname() { return (wxChoice*) FindWindow( ID_HOSTNAME ); }
55 wxChoice* GetTopic() { return (wxChoice*) FindWindow( ID_TOPIC ); }
56 wxButton* GetDisconnect() { return (wxButton*) FindWindow( ID_DISCONNECT ); }
57 wxButton* GetStartAdvise() { return (wxButton*) FindWindow( ID_STARTADVISE ); }
58 wxButton* GetStopAdvise() { return (wxButton*) FindWindow( ID_STOPADVISE ); }
59 wxButton* GetRequest() { return (wxButton*) FindWindow( ID_REQUEST ); }
60 wxButton* GetPoke() { return (wxButton*) FindWindow( ID_POKE ); }
61 wxButton* GetExecute() { return (wxButton*) FindWindow( ID_EXECUTE ); }
62 wxTextCtrl* GetLog() { return (wxTextCtrl*) FindWindow( ID_LOG ); }
63
64 MyClient *m_client;
65
66 void OnStart( wxCommandEvent &event );
67 void OnServername( wxCommandEvent &event );
68 void OnHostname( wxCommandEvent &event );
69 void OnTopic( wxCommandEvent &event );
70 void OnDisconnect( wxCommandEvent &event );
71 void OnStartAdvise( wxCommandEvent &event );
72 void OnStopAdvise( wxCommandEvent &event );
7921cf2b
JS
73 void OnExecute(wxCommandEvent& event);
74 void OnPoke(wxCommandEvent& event);
75 void OnRequest(wxCommandEvent& event);
4b89c618 76
9d860992 77protected:
4b89c618 78 DECLARE_EVENT_TABLE()
7921cf2b
JS
79};
80
81class MyConnection: public wxConnection
82{
4b89c618 83public:
50c549b9
VZ
84 virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
85 virtual const void *Request(const wxString& item, size_t *size = NULL, wxIPCFormat format = wxIPC_TEXT);
86 virtual bool DoPoke(const wxString& item, const void* data, size_t size, wxIPCFormat format);
87 virtual bool OnAdvise(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
9d860992 88 virtual bool OnDisconnect();
81ba6107 89protected:
1fbfc5ed 90 void Log(const wxString& command, const wxString& topic,
50c549b9 91 const wxString& item, const void *data, size_t size, wxIPCFormat format);
7921cf2b
JS
92};
93
94class MyClient: public wxClient
95{
4b89c618 96public:
9d860992
JS
97 MyClient();
98 ~MyClient();
99 bool Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic);
100 void Disconnect();
4b89c618 101 wxConnectionBase *OnMakeConnection();
9d860992
JS
102 bool IsConnected() { return m_connection != NULL; };
103 MyConnection *GetConnection() { return m_connection; };
104
105protected:
106 MyConnection *m_connection;
7921cf2b 107};