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

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 8 years ago

flaircore

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 { namespace gui {
23
24SpinBox::SpinBox(const LayoutPosition* position,string name,int min,int max,int step,int default_value):Box(position,name,"SpinBox") {
25 //update value from xml file
26 if(default_value<min) default_value=min;
27 if(default_value>max) default_value=max;
28 box_value=default_value;
29
30 SetVolatileXmlProp("min",min);
31 SetVolatileXmlProp("max",max);
32 SetVolatileXmlProp("step",step);
33 GetPersistentXmlProp("value",box_value);
34 SetPersistentXmlProp("value",box_value);
35
36 SendXml();
37}
38
39SpinBox::SpinBox(const LayoutPosition* position,string name,string suffix,int min,int max,int step,int default_value):Box(position,name,"SpinBox") {
40 //update value from xml file
41 if(default_value<min) default_value=min;
42 if(default_value>max) default_value=max;
43 box_value=default_value;
44
45 SetVolatileXmlProp("suffix",suffix);
46 SetVolatileXmlProp("min",min);
47 SetVolatileXmlProp("max",max);
48 SetVolatileXmlProp("step",step);
49 GetPersistentXmlProp("value",box_value);
50 SetPersistentXmlProp("value",box_value);
51 SendXml();
52}
53
54SpinBox::~SpinBox() {
55}
56
57int SpinBox::Value(void) const {
58 int tmp;
59
60 GetMutex();
61 tmp=box_value;
62 ReleaseMutex();
63
64 return tmp;
65}
66
67void SpinBox::XmlEvent(void) {
68 GetMutex();
69 if(GetPersistentXmlProp("value",box_value)) SetValueChanged();
70 ReleaseMutex();
71}
72
73} // end namespace gui
74} // end namespace flair
Note: See TracBrowser for help on using the repository browser.