summaryrefslogtreecommitdiff
path: root/TAO/tests/Xt_Stopwatch/Stopwatch_display.cpp
blob: 9f55249b27bb7b9cb14d34edd6d610b43ff1272f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// $Id$

#include "Stopwatch_display.h"


#include "ace/OS_NS_stdio.h"

ACE_RCSID (Xt_Stopwatch,
           Stopwatch_display,
           "$Id$")


Stopwatch_display::Stopwatch_display (Widget &parent)
{
  // Instantiate the  sub-components of the Stopwatch_display
  this->frame_ = XtCreateWidget ("frame",
                                 xmFrameWidgetClass,
                                 parent,
                                 0,
                                 0);

  this->label_ = XtCreateWidget ("label",
                                 xmLabelWidgetClass,
                                 this->frame_,
                                 0,
                                 0);
}

Stopwatch_display::~Stopwatch_display (void)
{
  //No-op
}

void
Stopwatch_display::manage (void)
{
  XtManageChild (this->frame_);
  XtManageChild (this->label_);
}

void
Stopwatch_display::set_time (CORBA::Float time)
{
  char buf[50];

  // Format value as a string
  ACE_OS::sprintf (buf, "%6.3f", time);

  // Convert to compound string
  XmString xmstr = XmStringCreateSimple (buf);

  // Display the string in the Label widget
  XtVaSetValues (this->label_, XmNlabelString, xmstr, NULL);
  //??Can use XtSetValues with ac and al values..

  // The compound string can be freed once passed to the widget
  XmStringFree (xmstr);
}