source: flair-src/trunk/lib/FlairCore/src/SpinBox.cpp@ 407

Last change on this file since 407 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

File size: 1.9 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2011/10/07
6// filename: SpinBox.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class displaying a QSpinBox on the ground station
14//
15//
16/*********************************************************************/
17
18#include "SpinBox.h"
19
20using std::string;
21
22namespace flair {
23namespace gui {
24
25SpinBox::SpinBox(const LayoutPosition *position, string name, int min, int max,
26 int step, int default_value)
27 : Box(position, name, "SpinBox") {
28 // update value from xml file
29 if (default_value < min)
30 default_value = min;
31 if (default_value > max)
32 default_value = max;
33 box_value = default_value;
34
35 SetVolatileXmlProp("min", min);
36 SetVolatileXmlProp("max", max);
37 SetVolatileXmlProp("step", step);
38 GetPersistentXmlProp("value", box_value);
39 SetPersistentXmlProp("value", box_value);
40
41 SendXml();
42}
43
44SpinBox::SpinBox(const LayoutPosition *position, string name, string suffix,
45 int min, int max, int step, int default_value)
46 : Box(position, name, "SpinBox") {
47 // update value from xml file
48 if (default_value < min)
49 default_value = min;
50 if (default_value > max)
51 default_value = max;
52 box_value = default_value;
53
54 SetVolatileXmlProp("suffix", suffix);
55 SetVolatileXmlProp("min", min);
56 SetVolatileXmlProp("max", max);
57 SetVolatileXmlProp("step", step);
58 GetPersistentXmlProp("value", box_value);
59 SetPersistentXmlProp("value", box_value);
60 SendXml();
61}
62
63SpinBox::~SpinBox() {}
64
65int SpinBox::Value(void) const {
66 int tmp;
67
68 GetMutex();
69 tmp = box_value;
70 ReleaseMutex();
71
72 return tmp;
73}
74
75void SpinBox::XmlEvent(void) {
76 GetMutex();
77 if (GetPersistentXmlProp("value", box_value))
78 SetValueChanged();
79 ReleaseMutex();
80}
81
82} // end namespace gui
83} // end namespace flair
Note: See TracBrowser for help on using the repository browser.