ctkRangeWidget.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QDebug>
  16. #include <QMouseEvent>
  17. // CTK includes
  18. #include "ctkRangeWidget.h"
  19. #include "ui_ctkRangeWidget.h"
  20. //-----------------------------------------------------------------------------
  21. class ctkRangeWidgetPrivate: public ctkPrivate<ctkRangeWidget>,
  22. public Ui_ctkRangeWidget
  23. {
  24. public:
  25. ctkRangeWidgetPrivate();
  26. void updateSpinBoxWidth();
  27. int synchronizedSpinBoxWidth()const;
  28. void synchronizeSiblingSpinBox(int newWidth);
  29. static bool equal(double v1, double v2);
  30. void relayout();
  31. bool Tracking;
  32. bool Changing;
  33. double MinimumValueBeforeChange;
  34. double MaximumValueBeforeChange;
  35. bool AutoSpinBoxWidth;
  36. Qt::Alignment SpinBoxAlignment;
  37. };
  38. // --------------------------------------------------------------------------
  39. bool ctkRangeWidgetPrivate::equal(double v1, double v2)
  40. {
  41. return qAbs(v1 - v2) < 0.0001;
  42. }
  43. // --------------------------------------------------------------------------
  44. ctkRangeWidgetPrivate::ctkRangeWidgetPrivate()
  45. {
  46. this->Tracking = true;
  47. this->Changing = false;
  48. this->MinimumValueBeforeChange = 0.;
  49. this->MaximumValueBeforeChange = 0.;
  50. this->AutoSpinBoxWidth = true;
  51. this->SpinBoxAlignment = Qt::AlignVCenter;
  52. }
  53. // --------------------------------------------------------------------------
  54. void ctkRangeWidgetPrivate::updateSpinBoxWidth()
  55. {
  56. int spinBoxWidth = this->synchronizedSpinBoxWidth();
  57. if (this->AutoSpinBoxWidth)
  58. {
  59. this->MinimumSpinBox->setMinimumWidth(spinBoxWidth);
  60. this->MaximumSpinBox->setMinimumWidth(spinBoxWidth);
  61. }
  62. else
  63. {
  64. this->MinimumSpinBox->setMinimumWidth(0);
  65. this->MaximumSpinBox->setMinimumWidth(0);
  66. }
  67. this->synchronizeSiblingSpinBox(spinBoxWidth);
  68. }
  69. // --------------------------------------------------------------------------
  70. int ctkRangeWidgetPrivate::synchronizedSpinBoxWidth()const
  71. {
  72. CTK_P(const ctkRangeWidget);
  73. //Q_ASSERT(this->MinimumSpinBox->sizeHint() == this->MaximumSpinBox->sizeHint());
  74. int maxWidth = qMax(this->MinimumSpinBox->sizeHint().width(),
  75. this->MaximumSpinBox->sizeHint().width());
  76. if (!p->parent())
  77. {
  78. return maxWidth;
  79. }
  80. QList<ctkRangeWidget*> siblings =
  81. p->parent()->findChildren<ctkRangeWidget*>();
  82. foreach(ctkRangeWidget* sibling, siblings)
  83. {
  84. maxWidth = qMax(maxWidth, qMax(sibling->ctk_d()->MaximumSpinBox->sizeHint().width(),
  85. sibling->ctk_d()->MaximumSpinBox->sizeHint().width()));
  86. }
  87. return maxWidth;
  88. }
  89. // --------------------------------------------------------------------------
  90. void ctkRangeWidgetPrivate::synchronizeSiblingSpinBox(int width)
  91. {
  92. CTK_P(const ctkRangeWidget);
  93. QList<ctkRangeWidget*> siblings =
  94. p->parent()->findChildren<ctkRangeWidget*>();
  95. foreach(ctkRangeWidget* sibling, siblings)
  96. {
  97. if (sibling != p && sibling->isAutoSpinBoxWidth())
  98. {
  99. sibling->ctk_d()->MinimumSpinBox->setMinimumWidth(width);
  100. sibling->ctk_d()->MaximumSpinBox->setMinimumWidth(width);
  101. }
  102. }
  103. }
  104. // --------------------------------------------------------------------------
  105. void ctkRangeWidgetPrivate::relayout()
  106. {
  107. CTK_P(ctkRangeWidget);
  108. this->GridLayout->removeWidget(this->MinimumSpinBox);
  109. this->GridLayout->removeWidget(this->MaximumSpinBox);
  110. this->GridLayout->removeWidget(this->Slider);
  111. if (this->SpinBoxAlignment & Qt::AlignTop)
  112. {
  113. this->GridLayout->addWidget(this->MinimumSpinBox,0,0);
  114. this->GridLayout->addWidget(this->MaximumSpinBox,0,2);
  115. this->GridLayout->addWidget(this->Slider,1,0,1,3);
  116. }
  117. else if (this->SpinBoxAlignment & Qt::AlignVCenter)
  118. {
  119. this->GridLayout->addWidget(this->MinimumSpinBox,0,0);
  120. this->GridLayout->addWidget(this->Slider,0,1);
  121. this->GridLayout->addWidget(this->MaximumSpinBox,0,2);
  122. }
  123. else if (this->SpinBoxAlignment & Qt::AlignBottom)
  124. {
  125. this->GridLayout->addWidget(this->MinimumSpinBox,1,0);
  126. this->GridLayout->addWidget(this->MaximumSpinBox,1,2);
  127. this->GridLayout->addWidget(this->Slider,0, 0, 1, 3);
  128. }
  129. }
  130. // --------------------------------------------------------------------------
  131. ctkRangeWidget::ctkRangeWidget(QWidget* _parent) : Superclass(_parent)
  132. {
  133. CTK_INIT_PRIVATE(ctkRangeWidget);
  134. CTK_D(ctkRangeWidget);
  135. d->setupUi(this);
  136. d->MinimumSpinBox->setMinimum(d->Slider->minimum());
  137. d->MinimumSpinBox->setMaximum(d->Slider->maximum());
  138. d->MaximumSpinBox->setMinimum(d->Slider->minimum());
  139. d->MaximumSpinBox->setMaximum(d->Slider->maximum());
  140. d->MinimumSpinBox->setValue(d->Slider->minimumValue());
  141. d->MaximumSpinBox->setValue(d->Slider->maximumValue());
  142. //this->connect(d->Slider, SIGNAL(minimumValueChanged(double)), d->MinimumSpinBox, SLOT(setValue(double)));
  143. //this->connect(d->Slider, SIGNAL(maximumValueChanged(double)), d->MaximumSpinBox, SLOT(setValue(double)));
  144. this->connect(d->Slider, SIGNAL(valuesChanged(double, double)), this, SLOT(changeValues(double,double)));
  145. this->connect(d->Slider, SIGNAL(minimumValueChanged(double)), this, SLOT(changeMinimumValue(double)));
  146. this->connect(d->Slider, SIGNAL(maximumValueChanged(double)), this, SLOT(changeMaximumValue(double)));
  147. this->connect(d->MinimumSpinBox, SIGNAL(valueChanged(double)), d->Slider, SLOT(setMinimumValue(double)));
  148. this->connect(d->MaximumSpinBox, SIGNAL(valueChanged(double)), d->Slider, SLOT(setMaximumValue(double)));
  149. this->connect(d->MinimumSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMinimumToMaximumSpinBox(double)));
  150. this->connect(d->MaximumSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMaximumToMinimumSpinBox(double)));
  151. this->connect(d->Slider, SIGNAL(sliderPressed()), this, SLOT(startChanging()));
  152. this->connect(d->Slider, SIGNAL(sliderReleased()), this, SLOT(stopChanging()));
  153. d->MinimumSpinBox->installEventFilter(this);
  154. d->MaximumSpinBox->installEventFilter(this);
  155. }
  156. // --------------------------------------------------------------------------
  157. double ctkRangeWidget::minimum()const
  158. {
  159. CTK_D(const ctkRangeWidget);
  160. Q_ASSERT(d->equal(d->MinimumSpinBox->minimum(),d->Slider->minimum()));
  161. return d->Slider->minimum();
  162. }
  163. // --------------------------------------------------------------------------
  164. double ctkRangeWidget::maximum()const
  165. {
  166. CTK_D(const ctkRangeWidget);
  167. Q_ASSERT(d->equal(d->MaximumSpinBox->maximum(), d->Slider->maximum()));
  168. return d->Slider->maximum();
  169. }
  170. // --------------------------------------------------------------------------
  171. void ctkRangeWidget::setMinimum(double min)
  172. {
  173. CTK_D(ctkRangeWidget);
  174. d->MinimumSpinBox->setMinimum(min);
  175. // SpinBox can truncate min (depending on decimals).
  176. // use Spinbox's min to set Slider's min
  177. d->Slider->setMinimum(d->MinimumSpinBox->minimum());
  178. Q_ASSERT(d->equal(d->MinimumSpinBox->minimum(),d->Slider->minimum()));
  179. d->updateSpinBoxWidth();
  180. }
  181. // --------------------------------------------------------------------------
  182. void ctkRangeWidget::setMaximum(double max)
  183. {
  184. CTK_D(ctkRangeWidget);
  185. d->MaximumSpinBox->setMaximum(max);
  186. // SpinBox can truncate max (depending on decimals).
  187. // use Spinbox's max to set Slider's max
  188. d->Slider->setMaximum(d->MaximumSpinBox->maximum());
  189. Q_ASSERT(d->equal(d->MaximumSpinBox->maximum(), d->Slider->maximum()));
  190. d->updateSpinBoxWidth();
  191. }
  192. // --------------------------------------------------------------------------
  193. void ctkRangeWidget::setRange(double min, double max)
  194. {
  195. CTK_D(ctkRangeWidget);
  196. d->MinimumSpinBox->setMinimum(qMin(min,max));
  197. d->MaximumSpinBox->setMaximum(qMax(min,max));
  198. // SpinBox can truncate the range (depending on decimals).
  199. // use Spinbox's range to set Slider's range
  200. d->Slider->setRange(d->MinimumSpinBox->minimum(), d->MaximumSpinBox->maximum());
  201. Q_ASSERT(d->equal(d->MinimumSpinBox->minimum(), d->Slider->minimum()));
  202. Q_ASSERT(d->equal(d->MaximumSpinBox->maximum(), d->Slider->maximum()));
  203. d->updateSpinBoxWidth();
  204. }
  205. /*
  206. // --------------------------------------------------------------------------
  207. double ctkRangeWidget::sliderPosition()const
  208. {
  209. return ctk_d()->Slider->sliderPosition();
  210. }
  211. // --------------------------------------------------------------------------
  212. void ctkRangeWidget::setSliderPosition(double position)
  213. {
  214. ctk_d()->Slider->setSliderPosition(position);
  215. }
  216. */
  217. /*
  218. // --------------------------------------------------------------------------
  219. double ctkRangeWidget::previousSliderPosition()
  220. {
  221. return ctk_d()->Slider->previousSliderPosition();
  222. }
  223. */
  224. // --------------------------------------------------------------------------
  225. double ctkRangeWidget::minimumValue()const
  226. {
  227. CTK_D(const ctkRangeWidget);
  228. Q_ASSERT(d->equal(d->Slider->minimumValue(), d->MinimumSpinBox->value()));
  229. return d->Changing ? d->MinimumValueBeforeChange : d->Slider->minimumValue();
  230. }
  231. // --------------------------------------------------------------------------
  232. double ctkRangeWidget::maximumValue()const
  233. {
  234. CTK_D(const ctkRangeWidget);
  235. Q_ASSERT(d->equal(d->Slider->maximumValue(), d->MaximumSpinBox->value()));
  236. return d->Changing ? d->MaximumValueBeforeChange : d->Slider->maximumValue();
  237. }
  238. // --------------------------------------------------------------------------
  239. void ctkRangeWidget::setMinimumValue(double _value)
  240. {
  241. CTK_D(ctkRangeWidget);
  242. // disable the tracking temporally to emit the
  243. // signal valueChanged if changeValue() is called
  244. bool isChanging = d->Changing;
  245. d->Changing = false;
  246. d->MinimumSpinBox->setValue(_value);
  247. // Why do we need to set the value to the slider ?
  248. //d->Slider->setValue(d->SpinBox->value());
  249. Q_ASSERT(d->equal(d->Slider->minimumValue(), d->MinimumSpinBox->value()));
  250. // restore the prop
  251. d->Changing = isChanging;
  252. }
  253. // --------------------------------------------------------------------------
  254. void ctkRangeWidget::setMaximumValue(double _value)
  255. {
  256. CTK_D(ctkRangeWidget);
  257. // disable the tracking temporally to emit the
  258. // signal valueChanged if changeValue() is called
  259. bool isChanging = d->Changing;
  260. d->Changing = false;
  261. d->MaximumSpinBox->setValue(_value);
  262. // Why do we need to set the value to the slider ?
  263. //d->Slider->setValue(d->SpinBox->value());
  264. Q_ASSERT(d->equal(d->Slider->maximumValue(), d->MaximumSpinBox->value()));
  265. // restore the prop
  266. d->Changing = isChanging;
  267. }
  268. // --------------------------------------------------------------------------
  269. void ctkRangeWidget::setValues(double newMinimumValue, double newMaximumValue)
  270. {
  271. CTK_D(ctkRangeWidget);
  272. // disable the tracking temporally to emit the
  273. // signal valueChanged if changeValue() is called
  274. bool isChanging = d->Changing;
  275. d->Changing = false;
  276. d->MinimumSpinBox->setValue(newMinimumValue);
  277. d->MaximumSpinBox->setValue(newMaximumValue);
  278. // Why do we need to set the value to the slider ?
  279. //d->Slider->setValue(d->SpinBox->value());
  280. Q_ASSERT(d->equal(d->Slider->minimumValue(), d->MinimumSpinBox->value()));
  281. Q_ASSERT(d->equal(d->Slider->maximumValue(), d->MaximumSpinBox->value()));
  282. // restore the prop
  283. d->Changing = isChanging;
  284. }
  285. // --------------------------------------------------------------------------
  286. void ctkRangeWidget::setMinimumToMaximumSpinBox(double minimum)
  287. {
  288. ctk_d()->MaximumSpinBox->setMinimum(minimum);
  289. }
  290. // --------------------------------------------------------------------------
  291. void ctkRangeWidget::setMaximumToMinimumSpinBox(double maximum)
  292. {
  293. ctk_d()->MinimumSpinBox->setMaximum(maximum);
  294. }
  295. // --------------------------------------------------------------------------
  296. void ctkRangeWidget::startChanging()
  297. {
  298. CTK_D(ctkRangeWidget);
  299. if (d->Tracking)
  300. {
  301. return;
  302. }
  303. d->Changing = true;
  304. d->MinimumValueBeforeChange = this->minimumValue();
  305. d->MaximumValueBeforeChange = this->maximumValue();
  306. }
  307. // --------------------------------------------------------------------------
  308. void ctkRangeWidget::stopChanging()
  309. {
  310. CTK_D(ctkRangeWidget);
  311. if (d->Tracking)
  312. {
  313. return;
  314. }
  315. d->Changing = false;
  316. if (qAbs(this->minimumValue() - d->MinimumValueBeforeChange) > (this->singleStep() * 0.000000001))
  317. {
  318. emit this->minimumValueChanged(this->minimumValue());
  319. }
  320. if (qAbs(this->maximumValue() - d->MaximumValueBeforeChange) > (this->singleStep() * 0.000000001))
  321. {
  322. emit this->maximumValueChanged(this->maximumValue());
  323. }
  324. }
  325. // --------------------------------------------------------------------------
  326. void ctkRangeWidget::changeMinimumValue(double newValue)
  327. {
  328. CTK_D(ctkRangeWidget);
  329. //if (d->Tracking)
  330. {
  331. emit this->minimumValueIsChanging(newValue);
  332. }
  333. if (!d->Changing)
  334. {
  335. emit this->minimumValueChanged(newValue);
  336. }
  337. }
  338. // --------------------------------------------------------------------------
  339. void ctkRangeWidget::changeMaximumValue(double newValue)
  340. {
  341. CTK_D(ctkRangeWidget);
  342. //if (d->Tracking)
  343. {
  344. emit this->maximumValueIsChanging(newValue);
  345. }
  346. if (!d->Changing)
  347. {
  348. emit this->maximumValueChanged(newValue);
  349. }
  350. }
  351. // --------------------------------------------------------------------------
  352. void ctkRangeWidget::changeValues(double newMinValue, double newMaxValue)
  353. {
  354. CTK_D(ctkRangeWidget);
  355. d->MinimumSpinBox->setValue(newMinValue);
  356. d->MaximumSpinBox->setValue(newMaxValue);
  357. }
  358. // --------------------------------------------------------------------------
  359. bool ctkRangeWidget::eventFilter(QObject *obj, QEvent *event)
  360. {
  361. if (event->type() == QEvent::MouseButtonPress)
  362. {
  363. QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
  364. if (mouseEvent->button() & Qt::LeftButton)
  365. {
  366. this->startChanging();
  367. }
  368. }
  369. else if (event->type() == QEvent::MouseButtonRelease)
  370. {
  371. QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
  372. if (mouseEvent->button() & Qt::LeftButton)
  373. {
  374. // here we might prevent ctkRangeWidget::stopChanging
  375. // from sending a valueChanged() event as the spinbox might
  376. // send a valueChanged() after eventFilter() is done.
  377. this->stopChanging();
  378. }
  379. }
  380. // standard event processing
  381. return this->Superclass::eventFilter(obj, event);
  382. }
  383. // --------------------------------------------------------------------------
  384. double ctkRangeWidget::singleStep()const
  385. {
  386. CTK_D(const ctkRangeWidget);
  387. Q_ASSERT(d->equal(d->Slider->singleStep(), d->MinimumSpinBox->singleStep()) &&
  388. d->equal(d->Slider->singleStep(), d->MaximumSpinBox->singleStep()));
  389. return d->Slider->singleStep();
  390. }
  391. // --------------------------------------------------------------------------
  392. void ctkRangeWidget::setSingleStep(double step)
  393. {
  394. CTK_D(ctkRangeWidget);
  395. d->MinimumSpinBox->setSingleStep(step);
  396. d->MaximumSpinBox->setSingleStep(step);
  397. d->Slider->setSingleStep(d->MinimumSpinBox->singleStep());
  398. Q_ASSERT(d->equal(d->Slider->singleStep(), d->MinimumSpinBox->singleStep()) &&
  399. d->equal(d->Slider->singleStep(), d->MaximumSpinBox->singleStep()));
  400. }
  401. // --------------------------------------------------------------------------
  402. int ctkRangeWidget::decimals()const
  403. {
  404. CTK_D(const ctkRangeWidget);
  405. Q_ASSERT(d->MinimumSpinBox->decimals() == d->MaximumSpinBox->decimals());
  406. return d->MinimumSpinBox->decimals();
  407. }
  408. // --------------------------------------------------------------------------
  409. void ctkRangeWidget::setDecimals(int newDecimals)
  410. {
  411. CTK_D(ctkRangeWidget);
  412. d->MinimumSpinBox->setDecimals(newDecimals);
  413. d->MaximumSpinBox->setDecimals(newDecimals);
  414. // The number of decimals can change the range values
  415. // i.e. 50.55 with 2 decimals -> 51 with 0 decimals
  416. // As the SpinBox range change doesn't fire signals,
  417. // we have to do the synchronization manually here
  418. d->Slider->setMinimum(d->MinimumSpinBox->minimum());
  419. d->Slider->setMaximum(d->MaximumSpinBox->maximum());
  420. }
  421. // --------------------------------------------------------------------------
  422. QString ctkRangeWidget::prefix()const
  423. {
  424. CTK_D(const ctkRangeWidget);
  425. Q_ASSERT(d->MinimumSpinBox->prefix() == d->MaximumSpinBox->prefix());
  426. return d->MinimumSpinBox->prefix();
  427. }
  428. // --------------------------------------------------------------------------
  429. void ctkRangeWidget::setPrefix(const QString& newPrefix)
  430. {
  431. CTK_D(ctkRangeWidget);
  432. d->MinimumSpinBox->setPrefix(newPrefix);
  433. d->MaximumSpinBox->setPrefix(newPrefix);
  434. }
  435. // --------------------------------------------------------------------------
  436. QString ctkRangeWidget::suffix()const
  437. {
  438. CTK_D(const ctkRangeWidget);
  439. Q_ASSERT(d->MinimumSpinBox->suffix() == d->MaximumSpinBox->suffix());
  440. return d->MinimumSpinBox->suffix();
  441. }
  442. // --------------------------------------------------------------------------
  443. void ctkRangeWidget::setSuffix(const QString& newSuffix)
  444. {
  445. CTK_D(ctkRangeWidget);
  446. d->MinimumSpinBox->setSuffix(newSuffix);
  447. d->MaximumSpinBox->setSuffix(newSuffix);
  448. }
  449. // --------------------------------------------------------------------------
  450. double ctkRangeWidget::tickInterval()const
  451. {
  452. CTK_D(const ctkRangeWidget);
  453. return d->Slider->tickInterval();
  454. }
  455. // --------------------------------------------------------------------------
  456. void ctkRangeWidget::setTickInterval(double ti)
  457. {
  458. CTK_D(ctkRangeWidget);
  459. d->Slider->setTickInterval(ti);
  460. }
  461. // -------------------------------------------------------------------------
  462. void ctkRangeWidget::reset()
  463. {
  464. this->setMinimumValue(this->minimum());
  465. this->setMaximumValue(this->maximum());
  466. }
  467. // -------------------------------------------------------------------------
  468. void ctkRangeWidget::setSpinBoxAlignment(Qt::Alignment alignment)
  469. {
  470. CTK_D(ctkRangeWidget);
  471. if (d->SpinBoxAlignment == alignment)
  472. {
  473. return;
  474. }
  475. d->SpinBoxAlignment = alignment;
  476. d->relayout();
  477. }
  478. // -------------------------------------------------------------------------
  479. Qt::Alignment ctkRangeWidget::spinBoxAlignment()const
  480. {
  481. CTK_D(const ctkRangeWidget);
  482. return d->SpinBoxAlignment;
  483. }
  484. // -------------------------------------------------------------------------
  485. void ctkRangeWidget::setSpinBoxTextAlignment(Qt::Alignment alignment)
  486. {
  487. CTK_D(ctkRangeWidget);
  488. d->MinimumSpinBox->setAlignment(alignment);
  489. d->MaximumSpinBox->setAlignment(alignment);
  490. }
  491. // -------------------------------------------------------------------------
  492. Qt::Alignment ctkRangeWidget::spinBoxTextAlignment()const
  493. {
  494. CTK_D(const ctkRangeWidget);
  495. Q_ASSERT(d->MinimumSpinBox->alignment() == d->MaximumSpinBox->alignment());
  496. return d->MinimumSpinBox->alignment();
  497. }
  498. // -------------------------------------------------------------------------
  499. void ctkRangeWidget::setTracking(bool enable)
  500. {
  501. CTK_D(ctkRangeWidget);
  502. d->Tracking = enable;
  503. }
  504. // -------------------------------------------------------------------------
  505. bool ctkRangeWidget::hasTracking()const
  506. {
  507. CTK_D(const ctkRangeWidget);
  508. return d->Tracking;
  509. }
  510. // -------------------------------------------------------------------------
  511. bool ctkRangeWidget::isAutoSpinBoxWidth()const
  512. {
  513. CTK_D(const ctkRangeWidget);
  514. return d->AutoSpinBoxWidth;
  515. }
  516. // -------------------------------------------------------------------------
  517. void ctkRangeWidget::setAutoSpinBoxWidth(bool autoWidth)
  518. {
  519. CTK_D(ctkRangeWidget);
  520. d->AutoSpinBoxWidth = autoWidth;
  521. d->updateSpinBoxWidth();
  522. }