ctkRangeWidget.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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. this->GridLayout->removeWidget(this->MinimumSpinBox);
  108. this->GridLayout->removeWidget(this->MaximumSpinBox);
  109. this->GridLayout->removeWidget(this->Slider);
  110. if (this->SpinBoxAlignment & Qt::AlignTop)
  111. {
  112. this->GridLayout->addWidget(this->MinimumSpinBox,0,0);
  113. this->GridLayout->addWidget(this->MaximumSpinBox,0,2);
  114. this->GridLayout->addWidget(this->Slider,1,0,1,3);
  115. }
  116. else if (this->SpinBoxAlignment & Qt::AlignVCenter)
  117. {
  118. this->GridLayout->addWidget(this->MinimumSpinBox,0,0);
  119. this->GridLayout->addWidget(this->Slider,0,1);
  120. this->GridLayout->addWidget(this->MaximumSpinBox,0,2);
  121. }
  122. else if (this->SpinBoxAlignment & Qt::AlignBottom)
  123. {
  124. this->GridLayout->addWidget(this->MinimumSpinBox,1,0);
  125. this->GridLayout->addWidget(this->MaximumSpinBox,1,2);
  126. this->GridLayout->addWidget(this->Slider,0, 0, 1, 3);
  127. }
  128. }
  129. // --------------------------------------------------------------------------
  130. ctkRangeWidget::ctkRangeWidget(QWidget* _parent) : Superclass(_parent)
  131. {
  132. CTK_INIT_PRIVATE(ctkRangeWidget);
  133. CTK_D(ctkRangeWidget);
  134. d->setupUi(this);
  135. d->MinimumSpinBox->setMinimum(d->Slider->minimum());
  136. d->MinimumSpinBox->setMaximum(d->Slider->maximum());
  137. d->MaximumSpinBox->setMinimum(d->Slider->minimum());
  138. d->MaximumSpinBox->setMaximum(d->Slider->maximum());
  139. d->MinimumSpinBox->setValue(d->Slider->minimumValue());
  140. d->MaximumSpinBox->setValue(d->Slider->maximumValue());
  141. //this->connect(d->Slider, SIGNAL(minimumValueChanged(double)), d->MinimumSpinBox, SLOT(setValue(double)));
  142. //this->connect(d->Slider, SIGNAL(maximumValueChanged(double)), d->MaximumSpinBox, SLOT(setValue(double)));
  143. this->connect(d->Slider, SIGNAL(valuesChanged(double, double)), this, SLOT(changeValues(double,double)));
  144. this->connect(d->Slider, SIGNAL(minimumValueChanged(double)), this, SLOT(changeMinimumValue(double)));
  145. this->connect(d->Slider, SIGNAL(maximumValueChanged(double)), this, SLOT(changeMaximumValue(double)));
  146. this->connect(d->MinimumSpinBox, SIGNAL(valueChanged(double)), d->Slider, SLOT(setMinimumValue(double)));
  147. this->connect(d->MaximumSpinBox, SIGNAL(valueChanged(double)), d->Slider, SLOT(setMaximumValue(double)));
  148. this->connect(d->MinimumSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMinimumToMaximumSpinBox(double)));
  149. this->connect(d->MaximumSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setMaximumToMinimumSpinBox(double)));
  150. this->connect(d->Slider, SIGNAL(sliderPressed()), this, SLOT(startChanging()));
  151. this->connect(d->Slider, SIGNAL(sliderReleased()), this, SLOT(stopChanging()));
  152. d->MinimumSpinBox->installEventFilter(this);
  153. d->MaximumSpinBox->installEventFilter(this);
  154. }
  155. // --------------------------------------------------------------------------
  156. double ctkRangeWidget::minimum()const
  157. {
  158. CTK_D(const ctkRangeWidget);
  159. Q_ASSERT(d->equal(d->MinimumSpinBox->minimum(),d->Slider->minimum()));
  160. return d->Slider->minimum();
  161. }
  162. // --------------------------------------------------------------------------
  163. double ctkRangeWidget::maximum()const
  164. {
  165. CTK_D(const ctkRangeWidget);
  166. Q_ASSERT(d->equal(d->MaximumSpinBox->maximum(), d->Slider->maximum()));
  167. return d->Slider->maximum();
  168. }
  169. // --------------------------------------------------------------------------
  170. void ctkRangeWidget::setMinimum(double min)
  171. {
  172. CTK_D(ctkRangeWidget);
  173. d->MinimumSpinBox->setMinimum(min);
  174. // SpinBox can truncate min (depending on decimals).
  175. // use Spinbox's min to set Slider's min
  176. d->Slider->setMinimum(d->MinimumSpinBox->minimum());
  177. Q_ASSERT(d->equal(d->MinimumSpinBox->minimum(),d->Slider->minimum()));
  178. d->updateSpinBoxWidth();
  179. }
  180. // --------------------------------------------------------------------------
  181. void ctkRangeWidget::setMaximum(double max)
  182. {
  183. CTK_D(ctkRangeWidget);
  184. d->MaximumSpinBox->setMaximum(max);
  185. // SpinBox can truncate max (depending on decimals).
  186. // use Spinbox's max to set Slider's max
  187. d->Slider->setMaximum(d->MaximumSpinBox->maximum());
  188. Q_ASSERT(d->equal(d->MaximumSpinBox->maximum(), d->Slider->maximum()));
  189. d->updateSpinBoxWidth();
  190. }
  191. // --------------------------------------------------------------------------
  192. void ctkRangeWidget::setRange(double min, double max)
  193. {
  194. CTK_D(ctkRangeWidget);
  195. d->MinimumSpinBox->setMinimum(qMin(min,max));
  196. d->MaximumSpinBox->setMaximum(qMax(min,max));
  197. // SpinBox can truncate the range (depending on decimals).
  198. // use Spinbox's range to set Slider's range
  199. d->Slider->setRange(d->MinimumSpinBox->minimum(), d->MaximumSpinBox->maximum());
  200. Q_ASSERT(d->equal(d->MinimumSpinBox->minimum(), d->Slider->minimum()));
  201. Q_ASSERT(d->equal(d->MaximumSpinBox->maximum(), d->Slider->maximum()));
  202. d->updateSpinBoxWidth();
  203. }
  204. /*
  205. // --------------------------------------------------------------------------
  206. double ctkRangeWidget::sliderPosition()const
  207. {
  208. return ctk_d()->Slider->sliderPosition();
  209. }
  210. // --------------------------------------------------------------------------
  211. void ctkRangeWidget::setSliderPosition(double position)
  212. {
  213. ctk_d()->Slider->setSliderPosition(position);
  214. }
  215. */
  216. /*
  217. // --------------------------------------------------------------------------
  218. double ctkRangeWidget::previousSliderPosition()
  219. {
  220. return ctk_d()->Slider->previousSliderPosition();
  221. }
  222. */
  223. // --------------------------------------------------------------------------
  224. double ctkRangeWidget::minimumValue()const
  225. {
  226. CTK_D(const ctkRangeWidget);
  227. Q_ASSERT(d->equal(d->Slider->minimumValue(), d->MinimumSpinBox->value()));
  228. return d->Changing ? d->MinimumValueBeforeChange : d->Slider->minimumValue();
  229. }
  230. // --------------------------------------------------------------------------
  231. double ctkRangeWidget::maximumValue()const
  232. {
  233. CTK_D(const ctkRangeWidget);
  234. Q_ASSERT(d->equal(d->Slider->maximumValue(), d->MaximumSpinBox->value()));
  235. return d->Changing ? d->MaximumValueBeforeChange : d->Slider->maximumValue();
  236. }
  237. // --------------------------------------------------------------------------
  238. void ctkRangeWidget::setMinimumValue(double _value)
  239. {
  240. CTK_D(ctkRangeWidget);
  241. // disable the tracking temporally to emit the
  242. // signal valueChanged if changeValue() is called
  243. bool isChanging = d->Changing;
  244. d->Changing = false;
  245. d->MinimumSpinBox->setValue(_value);
  246. // Why do we need to set the value to the slider ?
  247. //d->Slider->setValue(d->SpinBox->value());
  248. Q_ASSERT(d->equal(d->Slider->minimumValue(), d->MinimumSpinBox->value()));
  249. // restore the prop
  250. d->Changing = isChanging;
  251. }
  252. // --------------------------------------------------------------------------
  253. void ctkRangeWidget::setMaximumValue(double _value)
  254. {
  255. CTK_D(ctkRangeWidget);
  256. // disable the tracking temporally to emit the
  257. // signal valueChanged if changeValue() is called
  258. bool isChanging = d->Changing;
  259. d->Changing = false;
  260. d->MaximumSpinBox->setValue(_value);
  261. // Why do we need to set the value to the slider ?
  262. //d->Slider->setValue(d->SpinBox->value());
  263. Q_ASSERT(d->equal(d->Slider->maximumValue(), d->MaximumSpinBox->value()));
  264. // restore the prop
  265. d->Changing = isChanging;
  266. }
  267. // --------------------------------------------------------------------------
  268. void ctkRangeWidget::setValues(double newMinimumValue, double newMaximumValue)
  269. {
  270. CTK_D(ctkRangeWidget);
  271. // disable the tracking temporally to emit the
  272. // signal valueChanged if changeValue() is called
  273. bool isChanging = d->Changing;
  274. d->Changing = false;
  275. d->MinimumSpinBox->setValue(newMinimumValue);
  276. d->MaximumSpinBox->setValue(newMaximumValue);
  277. // Why do we need to set the value to the slider ?
  278. //d->Slider->setValue(d->SpinBox->value());
  279. Q_ASSERT(d->equal(d->Slider->minimumValue(), d->MinimumSpinBox->value()));
  280. Q_ASSERT(d->equal(d->Slider->maximumValue(), d->MaximumSpinBox->value()));
  281. // restore the prop
  282. d->Changing = isChanging;
  283. }
  284. // --------------------------------------------------------------------------
  285. void ctkRangeWidget::setMinimumToMaximumSpinBox(double minimum)
  286. {
  287. ctk_d()->MaximumSpinBox->setMinimum(minimum);
  288. }
  289. // --------------------------------------------------------------------------
  290. void ctkRangeWidget::setMaximumToMinimumSpinBox(double maximum)
  291. {
  292. ctk_d()->MinimumSpinBox->setMaximum(maximum);
  293. }
  294. // --------------------------------------------------------------------------
  295. void ctkRangeWidget::startChanging()
  296. {
  297. CTK_D(ctkRangeWidget);
  298. if (d->Tracking)
  299. {
  300. return;
  301. }
  302. d->Changing = true;
  303. d->MinimumValueBeforeChange = this->minimumValue();
  304. d->MaximumValueBeforeChange = this->maximumValue();
  305. }
  306. // --------------------------------------------------------------------------
  307. void ctkRangeWidget::stopChanging()
  308. {
  309. CTK_D(ctkRangeWidget);
  310. if (d->Tracking)
  311. {
  312. return;
  313. }
  314. d->Changing = false;
  315. if (qAbs(this->minimumValue() - d->MinimumValueBeforeChange) > (this->singleStep() * 0.000000001))
  316. {
  317. emit this->minimumValueChanged(this->minimumValue());
  318. }
  319. if (qAbs(this->maximumValue() - d->MaximumValueBeforeChange) > (this->singleStep() * 0.000000001))
  320. {
  321. emit this->maximumValueChanged(this->maximumValue());
  322. }
  323. }
  324. // --------------------------------------------------------------------------
  325. void ctkRangeWidget::changeMinimumValue(double newValue)
  326. {
  327. CTK_D(ctkRangeWidget);
  328. //if (d->Tracking)
  329. {
  330. emit this->minimumValueIsChanging(newValue);
  331. }
  332. if (!d->Changing)
  333. {
  334. emit this->minimumValueChanged(newValue);
  335. }
  336. }
  337. // --------------------------------------------------------------------------
  338. void ctkRangeWidget::changeMaximumValue(double newValue)
  339. {
  340. CTK_D(ctkRangeWidget);
  341. //if (d->Tracking)
  342. {
  343. emit this->maximumValueIsChanging(newValue);
  344. }
  345. if (!d->Changing)
  346. {
  347. emit this->maximumValueChanged(newValue);
  348. }
  349. }
  350. // --------------------------------------------------------------------------
  351. void ctkRangeWidget::changeValues(double newMinValue, double newMaxValue)
  352. {
  353. CTK_D(ctkRangeWidget);
  354. d->MinimumSpinBox->setValue(newMinValue);
  355. d->MaximumSpinBox->setValue(newMaxValue);
  356. }
  357. // --------------------------------------------------------------------------
  358. bool ctkRangeWidget::eventFilter(QObject *obj, QEvent *event)
  359. {
  360. if (event->type() == QEvent::MouseButtonPress)
  361. {
  362. QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
  363. if (mouseEvent->button() & Qt::LeftButton)
  364. {
  365. this->startChanging();
  366. }
  367. }
  368. else if (event->type() == QEvent::MouseButtonRelease)
  369. {
  370. QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
  371. if (mouseEvent->button() & Qt::LeftButton)
  372. {
  373. // here we might prevent ctkRangeWidget::stopChanging
  374. // from sending a valueChanged() event as the spinbox might
  375. // send a valueChanged() after eventFilter() is done.
  376. this->stopChanging();
  377. }
  378. }
  379. // standard event processing
  380. return this->Superclass::eventFilter(obj, event);
  381. }
  382. // --------------------------------------------------------------------------
  383. double ctkRangeWidget::singleStep()const
  384. {
  385. CTK_D(const ctkRangeWidget);
  386. Q_ASSERT(d->equal(d->Slider->singleStep(), d->MinimumSpinBox->singleStep()) &&
  387. d->equal(d->Slider->singleStep(), d->MaximumSpinBox->singleStep()));
  388. return d->Slider->singleStep();
  389. }
  390. // --------------------------------------------------------------------------
  391. void ctkRangeWidget::setSingleStep(double step)
  392. {
  393. CTK_D(ctkRangeWidget);
  394. d->MinimumSpinBox->setSingleStep(step);
  395. d->MaximumSpinBox->setSingleStep(step);
  396. d->Slider->setSingleStep(d->MinimumSpinBox->singleStep());
  397. Q_ASSERT(d->equal(d->Slider->singleStep(), d->MinimumSpinBox->singleStep()) &&
  398. d->equal(d->Slider->singleStep(), d->MaximumSpinBox->singleStep()));
  399. }
  400. // --------------------------------------------------------------------------
  401. int ctkRangeWidget::decimals()const
  402. {
  403. CTK_D(const ctkRangeWidget);
  404. Q_ASSERT(d->MinimumSpinBox->decimals() == d->MaximumSpinBox->decimals());
  405. return d->MinimumSpinBox->decimals();
  406. }
  407. // --------------------------------------------------------------------------
  408. void ctkRangeWidget::setDecimals(int newDecimals)
  409. {
  410. CTK_D(ctkRangeWidget);
  411. d->MinimumSpinBox->setDecimals(newDecimals);
  412. d->MaximumSpinBox->setDecimals(newDecimals);
  413. // The number of decimals can change the range values
  414. // i.e. 50.55 with 2 decimals -> 51 with 0 decimals
  415. // As the SpinBox range change doesn't fire signals,
  416. // we have to do the synchronization manually here
  417. d->Slider->setMinimum(d->MinimumSpinBox->minimum());
  418. d->Slider->setMaximum(d->MaximumSpinBox->maximum());
  419. }
  420. // --------------------------------------------------------------------------
  421. QString ctkRangeWidget::prefix()const
  422. {
  423. CTK_D(const ctkRangeWidget);
  424. Q_ASSERT(d->MinimumSpinBox->prefix() == d->MaximumSpinBox->prefix());
  425. return d->MinimumSpinBox->prefix();
  426. }
  427. // --------------------------------------------------------------------------
  428. void ctkRangeWidget::setPrefix(const QString& newPrefix)
  429. {
  430. CTK_D(ctkRangeWidget);
  431. d->MinimumSpinBox->setPrefix(newPrefix);
  432. d->MaximumSpinBox->setPrefix(newPrefix);
  433. }
  434. // --------------------------------------------------------------------------
  435. QString ctkRangeWidget::suffix()const
  436. {
  437. CTK_D(const ctkRangeWidget);
  438. Q_ASSERT(d->MinimumSpinBox->suffix() == d->MaximumSpinBox->suffix());
  439. return d->MinimumSpinBox->suffix();
  440. }
  441. // --------------------------------------------------------------------------
  442. void ctkRangeWidget::setSuffix(const QString& newSuffix)
  443. {
  444. CTK_D(ctkRangeWidget);
  445. d->MinimumSpinBox->setSuffix(newSuffix);
  446. d->MaximumSpinBox->setSuffix(newSuffix);
  447. }
  448. // --------------------------------------------------------------------------
  449. double ctkRangeWidget::tickInterval()const
  450. {
  451. CTK_D(const ctkRangeWidget);
  452. return d->Slider->tickInterval();
  453. }
  454. // --------------------------------------------------------------------------
  455. void ctkRangeWidget::setTickInterval(double ti)
  456. {
  457. CTK_D(ctkRangeWidget);
  458. d->Slider->setTickInterval(ti);
  459. }
  460. // -------------------------------------------------------------------------
  461. void ctkRangeWidget::reset()
  462. {
  463. this->setMinimumValue(this->minimum());
  464. this->setMaximumValue(this->maximum());
  465. }
  466. // -------------------------------------------------------------------------
  467. void ctkRangeWidget::setSpinBoxAlignment(Qt::Alignment alignment)
  468. {
  469. CTK_D(ctkRangeWidget);
  470. if (d->SpinBoxAlignment == alignment)
  471. {
  472. return;
  473. }
  474. d->SpinBoxAlignment = alignment;
  475. d->relayout();
  476. }
  477. // -------------------------------------------------------------------------
  478. Qt::Alignment ctkRangeWidget::spinBoxAlignment()const
  479. {
  480. CTK_D(const ctkRangeWidget);
  481. return d->SpinBoxAlignment;
  482. }
  483. // -------------------------------------------------------------------------
  484. void ctkRangeWidget::setSpinBoxTextAlignment(Qt::Alignment alignment)
  485. {
  486. CTK_D(ctkRangeWidget);
  487. d->MinimumSpinBox->setAlignment(alignment);
  488. d->MaximumSpinBox->setAlignment(alignment);
  489. }
  490. // -------------------------------------------------------------------------
  491. Qt::Alignment ctkRangeWidget::spinBoxTextAlignment()const
  492. {
  493. CTK_D(const ctkRangeWidget);
  494. Q_ASSERT(d->MinimumSpinBox->alignment() == d->MaximumSpinBox->alignment());
  495. return d->MinimumSpinBox->alignment();
  496. }
  497. // -------------------------------------------------------------------------
  498. void ctkRangeWidget::setTracking(bool enable)
  499. {
  500. CTK_D(ctkRangeWidget);
  501. d->Tracking = enable;
  502. }
  503. // -------------------------------------------------------------------------
  504. bool ctkRangeWidget::hasTracking()const
  505. {
  506. CTK_D(const ctkRangeWidget);
  507. return d->Tracking;
  508. }
  509. // -------------------------------------------------------------------------
  510. bool ctkRangeWidget::isAutoSpinBoxWidth()const
  511. {
  512. CTK_D(const ctkRangeWidget);
  513. return d->AutoSpinBoxWidth;
  514. }
  515. // -------------------------------------------------------------------------
  516. void ctkRangeWidget::setAutoSpinBoxWidth(bool autoWidth)
  517. {
  518. CTK_D(ctkRangeWidget);
  519. d->AutoSpinBoxWidth = autoWidth;
  520. d->updateSpinBoxWidth();
  521. }