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

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

sources reformatted with flair-format-dir script

File size: 1.9 KB
RevLine 
[2]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[2]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
[15]22namespace flair {
23namespace gui {
[2]24
[15]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;
[2]34
[15]35 SetVolatileXmlProp("min", min);
36 SetVolatileXmlProp("max", max);
37 SetVolatileXmlProp("step", step);
38 GetPersistentXmlProp("value", box_value);
39 SetPersistentXmlProp("value", box_value);
[2]40
[15]41 SendXml();
[2]42}
43
[15]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;
[2]53
[15]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();
[2]61}
62
[15]63SpinBox::~SpinBox() {}
[2]64
65int SpinBox::Value(void) const {
[15]66 int tmp;
[2]67
[15]68 GetMutex();
69 tmp = box_value;
70 ReleaseMutex();
[2]71
[15]72 return tmp;
[2]73}
74
75void SpinBox::XmlEvent(void) {
[15]76 GetMutex();
77 if (GetPersistentXmlProp("value", box_value))
78 SetValueChanged();
79 ReleaseMutex();
[2]80}
81
82} // end namespace gui
83} // end namespace flair
Note: See TracBrowser for help on using the repository browser.