Last change
on this file since 316 was 15, checked in by Bayard Gildas, 8 years ago |
sources reformatted with flair-format-dir script
|
File size:
1.3 KB
|
Rev | Line | |
---|
[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: 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 |
|
---|
[15] | 24 | namespace flair {
|
---|
| 25 | namespace gui {
|
---|
[2] | 26 |
|
---|
[15] | 27 | Label::Label(const LayoutPosition *position, string name, size_t buf_size)
|
---|
| 28 | : Widget(position->getLayout(), name, "Label") {
|
---|
| 29 | SetVolatileXmlProp("row", position->Row());
|
---|
| 30 | SetVolatileXmlProp("col", position->Col());
|
---|
[2] | 31 |
|
---|
[15] | 32 | SendXml();
|
---|
[2] | 33 |
|
---|
[15] | 34 | printf_buffer = (char *)malloc(buf_size);
|
---|
| 35 | if (printf_buffer == NULL)
|
---|
| 36 | Err("erreur malloc\n");
|
---|
[2] | 37 |
|
---|
[15] | 38 | delete position;
|
---|
[2] | 39 | }
|
---|
| 40 |
|
---|
[15] | 41 | Label::~Label() {
|
---|
| 42 | if (printf_buffer != NULL)
|
---|
| 43 | free(printf_buffer);
|
---|
| 44 | printf_buffer = NULL;
|
---|
[2] | 45 | }
|
---|
| 46 |
|
---|
[15] | 47 | void Label::SetText(const char *format, ...) {
|
---|
| 48 | int n;
|
---|
[2] | 49 |
|
---|
[15] | 50 | va_list args;
|
---|
| 51 | va_start(args, format);
|
---|
| 52 | n = vsprintf(printf_buffer, format, args);
|
---|
| 53 | va_end(args);
|
---|
| 54 | if (n <= 0)
|
---|
| 55 | return;
|
---|
[2] | 56 |
|
---|
[15] | 57 | SetVolatileXmlProp("value", printf_buffer);
|
---|
| 58 | SendXml();
|
---|
[2] | 59 | }
|
---|
| 60 |
|
---|
| 61 | } // end namespace gui
|
---|
| 62 | } // end namespace flair
|
---|
Note:
See
TracBrowser
for help on using the repository browser.