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