ctkWorkflowStackedWidget.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef __ctkWorkflowStackedWidget_h
  15. #define __ctkWorkflowStackedWidget_h
  16. // Qt includes
  17. #include <QStackedWidget>
  18. // CTK includes
  19. #include "ctkWorkflowAbstractPagedWidget.h"
  20. #include "ctkPimpl.h"
  21. #include "CTKWidgetsExport.h"
  22. class ctkWorkflowStackedWidgetPrivate;
  23. ///
  24. /// \brief ctkWorkflowStackedWidget is the basis for a workflow with a user
  25. /// interface containing a QStackedWidget.
  26. ///
  27. /// The client area is a QStackedWidget, onto which
  28. /// step-specific widgets can be placed.
  29. ///
  30. /// Multiple workflow steps can correspond to the same page of the
  31. /// QStackedWidget. The main widget can be inserted directly inside
  32. /// another user interface.
  33. class CTK_WIDGETS_EXPORT ctkWorkflowStackedWidget : public ctkWorkflowAbstractPagedWidget
  34. {
  35. Q_OBJECT
  36. public:
  37. typedef ctkWorkflowAbstractPagedWidget Superclass;
  38. explicit ctkWorkflowStackedWidget(QWidget* newParent = 0);
  39. virtual ~ctkWorkflowStackedWidget(){}
  40. /// Provided for advanced customization: get the client area.
  41. /// A workflow containing a user interface is made up of steps
  42. /// (ctkWorkflowWidgetStep).
  43. ///
  44. /// Each step should either:
  45. /// 1) reimplement ctkWorkflowWidgetStep::populateStepWidgetsList or
  46. /// set its populateStepWidgetsListCommand to point to a method that
  47. /// will add the custom-step's widgets to the list; or
  48. /// 2) reimplement ctkWorkflowWidgetStep::showUserInterface or set
  49. /// its showUserInterfaceCommand to point to a method that will
  50. /// display the step's user interface. Within that method, each of
  51. /// the custom step's widgets should be added to the workflow
  52. /// widget's clientArea using the addWidget() function.
  53. /// If you do not associate a layout manager with the clientArea,
  54. /// the default layout manager is a QBoxLayout with direction
  55. /// QBoxLayout::TopToBottom. Use the function
  56. /// setClientAreaDirection() to change the direction.
  57. /// For additional customization of layouts, note that
  58. /// ctkWorkflowStackedWidget()->clientArea()->setLayout() will likely
  59. /// not allow you to customize the client area layout. Customize
  60. /// specific pages instead using
  61. /// ctkWorkflowStackedWidget::getWidgetFromIndex(index)->setLayout()
  62. virtual QStackedWidget* clientArea();
  63. /// Provided for advanced customization: get the widget
  64. /// corresponding to the page of the given index
  65. virtual QWidget* getWidgetFromIndex(int index);
  66. protected:
  67. /// Add a widget to a new page of the client area.
  68. /// The label is not considered by this class.
  69. virtual void addWidgetToClientArea(QWidget* widget, const QString& label);
  70. /// Set the current widget to that of the page containing the given widget
  71. virtual void setCurrentWidget(QWidget* widget) ;
  72. private:
  73. CTK_DECLARE_PRIVATE(ctkWorkflowStackedWidget);
  74. };
  75. #endif