1
/***************************************************************************
3
Handle dialog factory element : Aspect Ratio
5
***************************************************************************/
7
/***************************************************************************
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
14
***************************************************************************/
20
#include <QGridLayout>
24
#include "ADM_commonUI/DIA_factory.h"
25
#include "ADM_assert.h"
26
#include "dialogFactoryQt4.h"
28
extern const char *shortkey(const char *);
30
diaElemAspectRatio::diaElemAspectRatio(uint32_t *num, uint32_t *den, const char *title, const char *tip) : diaElem(ELEM_TOGGLE)
34
paramTitle = shortkey(title);
38
diaElemAspectRatio::~diaElemAspectRatio()
44
void diaElemAspectRatio::setMe(void *dialog, void *opaque, uint32_t line)
46
QLabel *text = new QLabel(QString::fromUtf8(paramTitle));
47
QSpinBox *numBox = new QSpinBox();
48
QLabel *label = new QLabel(":");
49
QSpinBox *denBox = new QSpinBox();
50
QGridLayout *layout = (QGridLayout*) opaque;
51
QHBoxLayout *hboxLayout = new QHBoxLayout();
53
myWidget = (void*)numBox;
54
this->label = (void*)label;
55
this->denControl = (void*)denBox;
57
text->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
58
text->setBuddy(numBox);
60
numBox->setMinimum(1);
61
numBox->setMaximum(255);
63
denBox->setMinimum(1);
64
denBox->setMaximum(255);
66
numBox->setValue(*(uint32_t*)param);
67
denBox->setValue(*(uint32_t*)den);
69
QSpacerItem *spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
71
hboxLayout->addWidget(numBox);
72
hboxLayout->addWidget(label);
73
hboxLayout->addWidget(denBox);
74
hboxLayout->addItem(spacer);
76
layout->addWidget(text,line,0);
77
layout->addLayout(hboxLayout,line,1);
80
void diaElemAspectRatio::getMe(void)
82
*(uint32_t*)param = ((QSpinBox*)myWidget)->value();
83
*(uint32_t*)den = ((QSpinBox*)denControl)->value();
86
void diaElemAspectRatio::enable(uint32_t onoff)
88
QSpinBox *numBox = (QSpinBox*)myWidget;
89
QSpinBox *denBox = (QSpinBox*)denControl;
90
QLabel *label = (QLabel*)this->label;
92
numBox->setEnabled(onoff);
93
denBox->setEnabled(onoff);
94
label->setEnabled(onoff);
97
int diaElemAspectRatio::getRequiredLayout(void) { return FAC_QT_GRIDLAYOUT; }