Add wxControl::GetSizeFromTextSize() to size the control to its text.
[wxWidgets.git] / samples / ipc / client.h
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
12 #include "connection.h"
13
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
26 // Define a new application
27 class MyClient;
28 class MyFrame;
29
30 class MyApp: public wxApp
31 {
32 public:
33 virtual bool OnInit();
34 virtual int OnExit();
35 MyFrame *GetFrame() { return m_frame; };
36
37 protected:
38 MyFrame *m_frame;
39 };
40
41 // Define a new frame
42 class MyFrame: public wxFrame
43 {
44 public:
45 MyFrame(wxFrame *frame, const wxString& title);
46
47 void OnExit(wxCommandEvent& event);
48 void OnClose(wxCloseEvent& event);
49 void EnableControls();
50 void Disconnect();
51
52 protected:
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 );
74 void OnExecute(wxCommandEvent& event);
75 void OnPoke(wxCommandEvent& event);
76 void OnRequest(wxCommandEvent& event);
77
78 protected:
79 DECLARE_EVENT_TABLE()
80 };
81
82 class MyConnection : public MyConnectionBase
83 {
84 public:
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);
89 virtual bool OnDisconnect();
90 };
91
92 class MyClient: public wxClient
93 {
94 public:
95 MyClient();
96 ~MyClient();
97 bool Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic);
98 void Disconnect();
99 wxConnectionBase *OnMakeConnection();
100 bool IsConnected() { return m_connection != NULL; };
101 MyConnection *GetConnection() { return m_connection; };
102
103 protected:
104 MyConnection *m_connection;
105 };