]> git.saurik.com Git - wxWidgets.git/blob - utils/wxOLE/samples/servlet/servlet.cpp
don't compare bools with NULL
[wxWidgets.git] / utils / wxOLE / samples / servlet / servlet.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: servlet.cpp
3 // Purpose: Minimal wxWindows OLE server sample
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 20/04/99
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22
23 // For OLE stuff
24 #include "wxole.h"
25
26 #if defined(__WXGTK__) || defined(__WXMOTIF__)
27 #include "mondrian.xpm"
28 #endif
29
30 //----------------------------------------------------------------------------
31 // MyOleControl
32 //----------------------------------------------------------------------------
33
34 class MyOleControl : public wxOleControl
35 {
36 public:
37
38 MyOleControl();
39
40 void OnPaint( wxPaintEvent &event );
41
42 private:
43 DECLARE_EVENT_TABLE()
44 };
45
46 //----------------------------------------------------------------------------
47 // MyOleServer
48 //----------------------------------------------------------------------------
49
50 class MyOleServer : public wxOleServer
51 {
52 public:
53
54 MyOleServer() : wxOleServer( "servlet" ) { }
55
56 wxOleControl *CreateOleControl() { return new MyOleControl(); }
57 };
58
59 //----------------------------------------------------------------------------
60 // MyApp
61 //----------------------------------------------------------------------------
62
63 class MyApp : public wxApp
64 {
65 public:
66
67 MyApp();
68 ~MyApp();
69
70 virtual bool OnInit();
71
72 wxOleServerEnv *m_oleEnv;
73 MyOleServer *m_oleServer;
74 };
75
76 //----------------------------------------------------------------------------
77 // main
78 //----------------------------------------------------------------------------
79
80 IMPLEMENT_APP(MyApp)
81
82 //----------------------------------------------------------------------------
83 // MyApp
84 //----------------------------------------------------------------------------
85
86 MyApp::MyApp()
87 {
88 }
89
90 MyApp::~MyApp()
91 {
92 delete m_oleEnv;
93 delete m_oleServer;
94 }
95
96 #include "gtk/gtk.h"
97
98 bool MyApp::OnInit()
99 {
100 m_oleEnv = new wxOleServerEnv( "MyServer", "1.0" );
101 m_oleServer = new MyOleServer();
102
103 /* how do we get outta here ? */
104 for (;;) wxYield();
105
106 return TRUE;
107 }
108
109 //----------------------------------------------------------------------------
110 // MyOleControl
111 //----------------------------------------------------------------------------
112
113 BEGIN_EVENT_TABLE(MyOleControl, wxOleControl)
114 EVT_PAINT(MyOleControl::OnPaint)
115 END_EVENT_TABLE()
116
117 MyOleControl::MyOleControl() :
118 wxOleControl( -1 )
119 {
120 (void)new wxButton( this, -1, "Ole, Ole", wxPoint(5,40), wxSize(120,-1) );
121 (void)new wxButton( this, -1, "Greetings", wxPoint(5,70), wxSize(120,-1) );
122 }
123
124 void MyOleControl::OnPaint( wxPaintEvent &WXUNUSED(event) )
125 {
126 wxPaintDC dc(this);
127 dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL, FALSE, "charter" ) );
128 dc.DrawText( "wxWidgets rules!", 5, 5 );
129 }
130