1 #include "tao/FlResource/FlResource_Loader.h"
3 #include "ace/Get_Opt.h"
6 #include <FL/Fl_Window.H>
7 #include <FL/Fl_Roller.H>
12 // Run the client thread
15 // Use the ACE_Task_Base class to run the client threads.
18 Client (CORBA::ORB_ptr orb
,
25 // Call show on all the window objects
27 void parse_args (int argc
, ACE_TCHAR
*argv
[]);
30 static void x_cb (Fl_Widget
*widget
, void* cookie
);
31 static void y_cb (Fl_Widget
*widget
, void* cookie
);
36 // The methods for the callbacks
46 Simple_Server_var server_
;
50 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
52 TAO::FlResource_Loader fl_loader
;
57 CORBA::ORB_init (argc
, argv
);
59 Fl_Window
window (300, 100);
61 Client
client (orb
.in (), &window
);
69 client
.parse_args (argc
, argv
);
73 catch (const CORBA::Exception
& ex
)
75 ex
._tao_print_exception ("Caught exception:");
81 Client::Client (CORBA::ORB_ptr orb
,
83 : orb_ (CORBA::ORB::_duplicate (orb
))
86 new Fl_Roller (10, parent
->h () / 2 - 20,
87 parent
->w () / 2 - 10, 40);
88 this->x_roller_
->type (FL_HORIZONTAL
);
89 this->x_roller_
->callback (Client::x_cb
, this);
90 this->x_roller_
->range (-360, 360);
91 this->x_roller_
->step (1);
94 new Fl_Roller (3 * parent
->w () / 4 - 20, 10,
95 40, parent
->h () - 20);
96 this->y_roller_
->type (FL_VERTICAL
);
97 this->y_roller_
->callback (Client::y_cb
, this);
98 this->y_roller_
->range (-360, 360);
99 this->y_roller_
->step (1);
111 this->x_roller_
->show ();
112 this->y_roller_
->show ();
116 Client::x_cb (Fl_Widget
*, void* cookie
)
118 Client
*self
= static_cast<Client
*> (cookie
);
123 Client::y_cb (Fl_Widget
*, void* cookie
)
125 Client
*self
= static_cast<Client
*> (cookie
);
134 CORBA::Long x
= CORBA::Long (this->x_roller_
->value ());
135 this->server_
->set_x_angle (x
);
137 catch (const CORBA::Exception
& ex
)
139 ex
._tao_print_exception ("Client::x_changed");
148 CORBA::Long y
= CORBA::Long (this->y_roller_
->value ());
149 this->server_
->set_y_angle (y
);
151 catch (const CORBA::Exception
& ex
)
153 ex
._tao_print_exception ("Client::x_changed");
158 Client::parse_args (int argc
, ACE_TCHAR
*argv
[])
160 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
162 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
165 while ((c
= get_opts ()) != -1)
169 ior
= get_opts
.opt_arg ();
173 ACE_ERROR ((LM_ERROR
,
180 CORBA::Object_var object
=
181 this->orb_
->string_to_object (ior
);
184 Simple_Server::_narrow (object
.in ());