]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dde.h
Add NUM_CUSTOM
[wxWidgets.git] / interface / wx / dde.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dde.h
e54c96f1 3// Purpose: interface of wxDDEConnection
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxDDEConnection
7c913512 11
23324ae1 12 A wxDDEConnection object represents the connection between a client and a
1db8f1dc 13 server. It can be created by making a connection using a wxDDEClient
4ccf0566
FM
14 object, or by the acceptance of a connection by a wxDDEServer object.
15 The bulk of a DDE (Dynamic Data Exchange) conversation is controlled by calling
1db8f1dc 16 members in a wxDDEConnection object or by overriding its members.
7c913512 17
23324ae1 18 An application should normally derive a new connection class from
1db8f1dc
BP
19 wxDDEConnection, in order to override the communication event handlers to
20 do something interesting.
7c913512 21
1db8f1dc
BP
22 This DDE-based implementation is available on Windows only, but a
23 platform-independent, socket-based version of this API is available using
24 wxTCPConnection.
7c913512 25
23324ae1 26 @library{wxbase}
1db8f1dc 27 @category{ipc}
4ccf0566 28 @onlyfor{wxmsw}
7c913512 29
1db8f1dc 30 @see wxConnectionBase, wxDDEClient, wxDDEServer, @ref overview_ipc
23324ae1 31*/
1db8f1dc 32class wxDDEConnection : public wxConnectionBase
23324ae1
FM
33{
34public:
23324ae1
FM
35 /**
36 Constructs a connection object. If no user-defined connection object is
37 to be derived from wxDDEConnection, then the constructor should not be
1db8f1dc
BP
38 called directly, since the default connection object will be provided
39 on requesting (or accepting) a connection. However, if the user defines
40 his or her own derived connection object, the
41 wxDDEServer::OnAcceptConnection() and/or
42 wxDDEClient::OnMakeConnection() members should be replaced by functions
43 which construct the new connection object.
44
45 A default buffer will be associated with this connection.
23324ae1
FM
46 */
47 wxDDEConnection();
1db8f1dc
BP
48 /**
49 Constructs a connection object. If no user-defined connection object is
50 to be derived from wxDDEConnection, then the constructor should not be
51 called directly, since the default connection object will be provided
52 on requesting (or accepting) a connection. However, if the user defines
53 his or her own derived connection object, the
54 wxDDEServer::OnAcceptConnection() and/or
55 wxDDEClient::OnMakeConnection() members should be replaced by functions
56 which construct the new connection object.
57
58 @param buffer
59 Buffer for this connection object to use in transactions.
60 @param size
61 Size of the buffer given.
62 */
7c913512 63 wxDDEConnection(void* buffer, size_t size);
23324ae1
FM
64
65 //@{
66 /**
67 Called by the server application to advise the client of a change in
1db8f1dc
BP
68 the data associated with the given item. Causes the client connection's
69 OnAdvise() member to be called.
70
d29a9a8a 71 @return @true if successful.
23324ae1
FM
72 */
73 bool Advise(const wxString& item, const void* data, size_t size,
74 wxIPCFormat format = wxIPC_PRIVATE);
7c913512
FM
75 bool Advise(const wxString& item, const char* data);
76 bool Advise(const wxString& item, const wchar_t* data);
77 bool Advise(const wxString& item, const wxString data);
23324ae1
FM
78 //@}
79
80 /**
81 Called by the client or server application to disconnect from the other
1db8f1dc
BP
82 program; it causes the OnDisconnect() message to be sent to the
83 corresponding connection object in the other program. The default
84 behaviour of OnDisconnect() is to delete the connection, but the
85 calling application must explicitly delete its side of the connection
86 having called Disconnect().
87
d29a9a8a 88 @return @true if successful.
23324ae1
FM
89 */
90 bool Disconnect();
91
92 //@{
93 /**
1db8f1dc
BP
94 Called by the client application to execute a command on the server.
95 Can also be used to transfer arbitrary data to the server (similar to
96 Poke() in that respect). Causes the server connection's OnExecute()
97 member to be called.
98
d29a9a8a 99 @return @true if successful.
23324ae1
FM
100 */
101 bool Execute(const void* data, size_t size,
102 wxIPCFormat format = wxIPC_PRIVATE);
7c913512
FM
103 bool Execute(const char* data);
104 bool Execute(const wchar_t* data);
105 bool Execute(const wxString data);
23324ae1
FM
106 //@}
107
108 /**
109 Message sent to the client application when the server notifies it of a
110 change in the data associated with the given item.
111 */
1db8f1dc
BP
112 virtual bool OnAdvise(const wxString& topic, const wxString& item,
113 const void* data, size_t size, wxIPCFormat format);
23324ae1
FM
114
115 /**
116 Message sent to the client or server application when the other
117 application notifies it to delete the connection. Default behaviour is
118 to delete the connection object.
119 */
120 virtual bool OnDisconnect();
121
122 /**
123 Message sent to the server application when the client notifies it to
124 execute the given data. Note that there is no item associated with
125 this message.
126 */
127 virtual bool OnExecute(const wxString& topic, const void* data,
1db8f1dc 128 size_t size, wxIPCFormat format);
23324ae1
FM
129
130 /**
131 Message sent to the server application when the client notifies it to
132 accept the given data.
133 */
134 virtual bool OnPoke(const wxString& topic, const wxString& item,
1db8f1dc 135 const void* data, size_t size, wxIPCFormat format);
23324ae1
FM
136
137 /**
1db8f1dc
BP
138 Message sent to the server application when the client calls Request().
139 The server should respond by returning a character string from
140 OnRequest(), or @NULL to indicate no data.
23324ae1
FM
141 */
142 virtual const void* OnRequest(const wxString& topic,
1db8f1dc 143 const wxString& item, size_t* size,
23324ae1
FM
144 wxIPCFormat format);
145
146 /**
147 Message sent to the server application by the client, when the client
1db8f1dc 148 wishes to start an "advise loop" for the given topic and item. The
23324ae1
FM
149 server can refuse to participate by returning @false.
150 */
1db8f1dc 151 virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
23324ae1
FM
152
153 /**
154 Message sent to the server application by the client, when the client
1db8f1dc 155 wishes to stop an "advise loop" for the given topic and item. The
23324ae1
FM
156 server can refuse to stop the advise loop by returning @false, although
157 this doesn't have much meaning in practice.
158 */
1db8f1dc 159 virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
23324ae1
FM
160
161 //@{
162 /**
163 Called by the client application to poke data into the server. Can be
164 used to transfer arbitrary data to the server. Causes the server
1db8f1dc
BP
165 connection's OnPoke() member to be called.
166
d29a9a8a 167 @return @true if successful.
23324ae1
FM
168 */
169 bool Poke(const wxString& item, const void* data, size_t size,
170 wxIPCFormat format = wxIPC_PRIVATE);
7c913512
FM
171 bool Poke(const wxString& item, const char* data);
172 bool Poke(const wxString& item, const wchar_t* data);
173 bool Poke(const wxString& item, const wxString data);
23324ae1
FM
174 //@}
175
176 /**
1db8f1dc
BP
177 Called by the client application to request data from the server.
178 Causes the server connection's OnRequest() member to be called.
179
d29a9a8a 180 @return A character string (actually a pointer to the connection's
1db8f1dc 181 buffer) if successful, @NULL otherwise.
23324ae1 182 */
4cc4bfaf 183 const void* Request(const wxString& item, size_t* size,
23324ae1
FM
184 wxIPCFormat format = wxIPC_TEXT);
185
186 /**
1db8f1dc
BP
187 Called by the client application to ask if an advise loop can be
188 started with the server. Causes the server connection's OnStartAdvise()
189 member to be called.
190
d29a9a8a 191 @return @true if the server okays it, @false otherwise.
23324ae1
FM
192 */
193 bool StartAdvise(const wxString& item);
194
195 /**
196 Called by the client application to ask if an advise loop can be
1db8f1dc
BP
197 stopped. Causes the server connection's OnStopAdvise() member to be
198 called.
199
d29a9a8a 200 @return @true if the server okays it, @false otherwise.
23324ae1
FM
201 */
202 bool StopAdvise(const wxString& item);
203};
204
205
e54c96f1 206
23324ae1
FM
207/**
208 @class wxDDEClient
7c913512 209
23324ae1
FM
210 A wxDDEClient object represents the client part of a client-server DDE
211 (Dynamic Data Exchange) conversation.
7c913512 212
1db8f1dc
BP
213 To create a client which can communicate with a suitable server, you need
214 to derive a class from wxDDEConnection and another from wxDDEClient. The
215 custom wxDDEConnection class will intercept communications in a
216 "conversation" with a server, and the custom wxDDEServer is required so
217 that a user-overridden OnMakeConnection() member can return a
218 wxDDEConnection of the required class, when a connection is made.
7c913512 219
1db8f1dc
BP
220 This DDE-based implementation is available on Windows only, but a
221 platform-independent, socket-based version of this API is available using
222 wxTCPClient.
7c913512 223
23324ae1 224 @library{wxbase}
1db8f1dc 225 @category{ipc}
4ccf0566 226 @onlyfor{wxmsw}
7c913512 227
1db8f1dc 228 @see wxDDEServer, wxDDEConnection, @ref overview_ipc
23324ae1
FM
229*/
230class wxDDEClient : public wxObject
231{
232public:
233 /**
234 Constructs a client object.
235 */
236 wxDDEClient();
237
238 /**
1db8f1dc
BP
239 Tries to make a connection with a server specified by the host (machine
240 name under UNIX, ignored under Windows), service name (must contain an
241 integer port number under UNIX), and topic string. If the server allows
242 a connection, a wxDDEConnection object will be returned.
243
244 The type of wxDDEConnection returned can be altered by overriding the
245 OnMakeConnection() member to return your own derived connection object.
23324ae1 246 */
4cc4bfaf
FM
247 wxConnectionBase* MakeConnection(const wxString& host,
248 const wxString& service,
249 const wxString& topic);
23324ae1
FM
250
251 /**
252 The type of wxDDEConnection returned from a MakeConnection() call can
1db8f1dc
BP
253 be altered by deriving the OnMakeConnection() member to return your own
254 derived connection object. By default, a wxDDEConnection object is
255 returned.
256
23324ae1 257 The advantage of deriving your own connection class is that it will
1db8f1dc
BP
258 enable you to intercept messages initiated by the server, such as
259 wxDDEConnection::OnAdvise(). You may also want to store
260 application-specific data in instances of the new class.
23324ae1 261 */
4cc4bfaf 262 wxConnectionBase* OnMakeConnection();
23324ae1
FM
263
264 /**
1db8f1dc
BP
265 Returns @true if this is a valid host name, @false otherwise. This
266 always returns @true under MS Windows.
23324ae1
FM
267 */
268 bool ValidHost(const wxString& host);
269};
270
271
e54c96f1 272
23324ae1
FM
273/**
274 @class wxDDEServer
7c913512 275
23324ae1
FM
276 A wxDDEServer object represents the server part of a client-server DDE
277 (Dynamic Data Exchange) conversation.
7c913512 278
1db8f1dc
BP
279 This DDE-based implementation is available on Windows only, but a
280 platform-independent, socket-based version of this API is available using
281 wxTCPServer.
7c913512 282
23324ae1 283 @library{wxbase}
1db8f1dc 284 @category{ipc}
4ccf0566 285 @onlyfor{wxmsw}
7c913512 286
1db8f1dc 287 @see wxDDEClient, wxDDEConnection, @ref overview_ipc
23324ae1 288*/
7c913512 289class wxDDEServer
23324ae1
FM
290{
291public:
292 /**
293 Constructs a server object.
294 */
295 wxDDEServer();
296
297 /**
298 Registers the server using the given service name. Under UNIX, the
299 string must contain an integer id which is used as an Internet port
1db8f1dc 300 number. @false is returned if the call failed (for example, if the port
23324ae1
FM
301 number is already in use).
302 */
303 bool Create(const wxString& service);
304
305 /**
1db8f1dc
BP
306 When a client calls wxDDEClient::MakeConnection(), the server receives
307 the message and this member is called. The application should derive a
23324ae1 308 member to intercept this message and return a connection object of
1db8f1dc
BP
309 either the standard wxDDEConnection type, or of a user-derived type.
310
311 If the @a topic is "STDIO", the application may wish to refuse the
312 connection. Under UNIX, when a server is created the
313 OnAcceptConnection() message is always sent for standard input and
314 output, but in the context of DDE messages it doesn't make a lot of
315 sense.
23324ae1 316 */
4cc4bfaf 317 virtual wxConnectionBase* OnAcceptConnection(const wxString& topic);
23324ae1
FM
318};
319
320
e54c96f1 321
23324ae1
FM
322// ============================================================================
323// Global functions/macros
324// ============================================================================
325
b21126db 326/** @addtogroup group_funcmacro_misc */
7fa7088e
BP
327//@{
328
23324ae1 329/**
7fa7088e
BP
330 Called when wxWidgets exits, to clean up the DDE system. This no longer
331 needs to be called by the application.
332
333 @see wxDDEInitialize()
334
335 @header{wx/dde.h}
23324ae1
FM
336*/
337void wxDDECleanUp();
338
339/**
340 Initializes the DDE system. May be called multiple times without harm.
7fa7088e
BP
341
342 This no longer needs to be called by the application: it will be called by
343 wxWidgets if necessary.
344
345 @see wxDDEServer, wxDDEClient, wxDDEConnection, wxDDECleanUp()
346
347 @header{wx/dde.h}
23324ae1
FM
348*/
349void wxDDEInitialize();
350
7fa7088e
BP
351//@}
352