| 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 |
|
---|
| 20 | using std::string;
|
---|
| 21 |
|
---|
| 22 | namespace flair { namespace gui {
|
---|
| 23 |
|
---|
| 24 | SpinBox::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 |
|
---|
| 39 | SpinBox::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 |
|
---|
| 54 | SpinBox::~SpinBox() {
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | int SpinBox::Value(void) const {
|
---|
| 58 | int tmp;
|
---|
| 59 |
|
---|
| 60 | GetMutex();
|
---|
| 61 | tmp=box_value;
|
---|
| 62 | ReleaseMutex();
|
---|
| 63 |
|
---|
| 64 | return tmp;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | void SpinBox::XmlEvent(void) {
|
---|
| 68 | GetMutex();
|
---|
| 69 | if(GetPersistentXmlProp("value",box_value)) SetValueChanged();
|
---|
| 70 | ReleaseMutex();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | } // end namespace gui
|
---|
| 74 | } // end namespace flair
|
---|