Rev | 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: 2012/08/17
|
---|
| 6 | // filename: Label.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Class displaying a QLabel on the ground station
|
---|
| 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 |
|
---|
| 18 | #include "Label.h"
|
---|
| 19 | #include "Layout.h"
|
---|
| 20 | #include "LayoutPosition.h"
|
---|
| 21 |
|
---|
| 22 | using std::string;
|
---|
| 23 |
|
---|
| 24 | namespace flair
|
---|
| 25 | {
|
---|
| 26 | namespace gui
|
---|
| 27 | {
|
---|
| 28 |
|
---|
| 29 | Label::Label(const LayoutPosition* position,string name,size_t buf_size): Widget(position->getLayout(),name,"Label")
|
---|
| 30 | {
|
---|
| 31 | SetVolatileXmlProp("row",position->Row());
|
---|
| 32 | SetVolatileXmlProp("col",position->Col());
|
---|
| 33 |
|
---|
| 34 | SendXml();
|
---|
| 35 |
|
---|
| 36 | printf_buffer=(char*)malloc(buf_size);
|
---|
| 37 | if(printf_buffer==NULL) Err("erreur malloc\n");
|
---|
| 38 |
|
---|
| 39 | delete position;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | Label::~Label()
|
---|
| 43 | {
|
---|
| 44 | if(printf_buffer!=NULL) free(printf_buffer);
|
---|
| 45 | printf_buffer=NULL;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | void Label::SetText(const char * format, ...)
|
---|
| 50 | {
|
---|
| 51 | int n;
|
---|
| 52 |
|
---|
| 53 | va_list args;
|
---|
| 54 | va_start (args, format);
|
---|
| 55 | n = vsprintf(printf_buffer,format, args);
|
---|
| 56 | va_end (args);
|
---|
| 57 | if (n<=0) return;
|
---|
| 58 |
|
---|
| 59 | SetVolatileXmlProp("value",printf_buffer);
|
---|
| 60 | SendXml();
|
---|
| 61 |
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | } // end namespace gui
|
---|
| 65 | } // end namespace flair
|
---|
Note:
See
TracBrowser
for help on using the repository browser.