]> git.saurik.com Git - wxWidgets.git/blame_incremental - samples/ipc/server.h
use a different method to prevent an early size_allocate,
[wxWidgets.git] / samples / ipc / server.h
... / ...
CommitLineData
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
12#include "connection.h"
13
14#define ID_START 10000
15#define ID_DISCONNECT 10001
16#define ID_ADVISE 10002
17#define ID_LOG 10003
18#define ID_SERVERNAME 10004
19
20// Define a new application
21class MyServer;
22class MyFrame;
23
24class MyApp : public wxApp
25{
26public:
27 virtual bool OnInit();
28 virtual int OnExit();
29 MyFrame *GetFrame() { return m_frame; };
30
31protected:
32 MyFrame *m_frame;
33};
34
35DECLARE_APP(MyApp)
36
37// Define a new frame
38class MyFrame : public wxFrame
39{
40public:
41 MyFrame(wxFrame *frame, const wxString& title);
42
43 void OnExit(wxCommandEvent& event);
44 void OnClose(wxCloseEvent& event);
45
46 void Enable();
47 void Disconnect();
48
49protected:
50 wxButton* GetStart() { return (wxButton*) FindWindow( ID_START ); }
51 wxChoice* GetServername() { return (wxChoice*) FindWindow( ID_SERVERNAME ); }
52 wxButton* GetDisconnect() { return (wxButton*) FindWindow( ID_DISCONNECT ); }
53 wxButton* GetAdvise() { return (wxButton*) FindWindow( ID_ADVISE ); }
54 wxTextCtrl* GetLog() { return (wxTextCtrl*) FindWindow( ID_LOG ); }
55
56
57 MyServer *m_server;
58
59 void OnStart( wxCommandEvent &event );
60 void OnServerName( wxCommandEvent &event );
61 void OnDisconnect( wxCommandEvent &event );
62 void OnAdvise( wxCommandEvent &event );
63
64 DECLARE_EVENT_TABLE()
65};
66
67class MyConnection : public MyConnectionBase
68{
69public:
70 virtual bool OnExecute(const wxString& topic, const void *data, size_t size, wxIPCFormat format);
71 virtual const void *OnRequest(const wxString& topic, const wxString& item, size_t *size, wxIPCFormat format);
72 virtual bool OnPoke(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
73 virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
74 virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
75 virtual bool DoAdvise(const wxString& item, const void *data, size_t size, wxIPCFormat format);
76 virtual bool OnDisconnect();
77
78 wxString m_sAdvise;
79
80protected:
81 wxString m_sRequestDate;
82 char m_achRequestBytes[3];
83};
84
85class MyServer: public wxServer
86{
87public:
88 MyServer();
89 ~MyServer();
90 void Disconnect();
91 bool IsConnected() { return m_connection != NULL; };
92 MyConnection *GetConnection() { return m_connection; };
93 void Advise();
94 bool CanAdvise() { return m_connection != NULL && !m_connection->m_sAdvise.IsEmpty(); };
95 wxConnectionBase *OnAcceptConnection(const wxString& topic);
96
97protected:
98 MyConnection *m_connection;
99};
100