1 #include "Progress_i.h"
3 #include <FL/Fl_Slider.H>
4 #include <FL/Fl_Button.H>
6 Progress_i::Progress_i (Progress_Window
*window
)
12 Progress_i::sent_request (CORBA::Long id
)
14 //ACE_DEBUG ((LM_DEBUG, "Progress (%t) - sent request %d\n", id));
15 this->window_
->sent_request (id
);
19 Progress_i::recv_reply (CORBA::Long id
)
21 this->window_
->recv_reply (id
);
25 Progress_i::bind (Peer_ptr a_peer
)
27 ACE_DEBUG ((LM_DEBUG
, "Progress (%t) - peer bound\n"));
28 return this->window_
->bind (a_peer
);
31 // ****************************************************************
33 Progress_Window::Progress_Window (int n_peers
,
38 : Fl_Box (x
, y
, w
, h
, l
),
41 n_iterations_ (n_iterations
)
43 ACE_NEW (this->request_progress_
, Fl_Widget
*[this->n_peers_
]);
44 ACE_NEW (this->reply_progress_
, Fl_Widget
*[this->n_peers_
]);
47 Fl_Widget
*button
= new Fl_Button (x
+ 5, y
+ 5,
50 button
->callback (Progress_Window::start_callback
, this);
52 // Compute the slider height, leaving a little margin...
53 int sh
= h
/ ( 2 * this->n_peers_
);
56 // The initial position, with margin...
59 // Set the width of the sliders...
62 int max
= this->n_peers_
* this->n_iterations_
;
63 for (int i
= 0; i
< this->n_peers_
; ++i
)
67 this->request_progress_
[i
] = obj
=
68 new Fl_Slider (FL_HOR_FILL_SLIDER
, sx
, sy
, sw
, sh
, "");
69 obj
->color (FL_BLACK
);
70 obj
->selection_color (FL_RED
);
76 this->reply_progress_
[i
] = obj
=
77 new Fl_Slider (FL_HOR_FILL_SLIDER
, sx
, sy
, sw
, sh
, "");
78 obj
->color (FL_BLACK
);
79 obj
->selection_color (FL_GREEN
);
88 Progress_Window::sent_request (CORBA::Long id
)
90 if (id
< 0 || id
>= this->n_peers_
)
93 dynamic_cast<Fl_Slider
*> (this->request_progress_
[id
]);
94 obj
->value (obj
->value () + 1);
97 int i
= static_cast<int> (obj
->value ());
99 ACE_DEBUG ((LM_DEBUG
, "Progress (%t) - recv reply %d\n", i
));
103 Progress_Window::recv_reply (CORBA::Long id
)
105 if (id
< 0 || id
>= this->n_peers_
)
108 dynamic_cast<Fl_Slider
*> (this->reply_progress_
[id
]);
109 obj
->value (obj
->value () + 1);
112 int i
= static_cast<int> (obj
->value ());
114 ACE_DEBUG ((LM_DEBUG
, "Progress (%t) - recv reply %d\n", i
));
118 Progress_Window::bind (Peer_ptr a_peer
)
120 CORBA::ULong l
= this->peers_
.length ();
121 this->peers_
.length (l
+ 1);
122 this->peers_
[l
] = Peer::_duplicate (a_peer
);
128 Progress_Window::start_callback (Fl_Widget
* /* widget */,
131 Progress_Window
*self
= static_cast<Progress_Window
*> (data
);
136 Progress_Window::start ()
138 if (this->peers_
.length () < CORBA::ULong (this->n_peers_
))
141 for (CORBA::ULong i
= 0; i
!= this->peers_
.length (); ++i
)
145 this->peers_
[i
]->start (this->peers_
,
146 this->n_iterations_
);
148 catch (const CORBA::Exception
& ex
)