KWWidgets
vtkKWSpinButtons.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWSpinButtons.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWSpinButtons - A set of spin-buttons.
15 // .SECTION Description
16 // This widget implements a small set of two buttons that can be used
17 // to switch to the next or previous value of an external variable through
18 // callbacks.
19 // The buttons can be set to display up/down or left/right arrows, and laid
20 // out vertically or horizontally.
21 // The 'previous' button is mapped to the up/left arrow, the 'next' button
22 // is mapped to the 'down/right' arrow.
23 // .SECTION Thanks
24 // This work is part of the National Alliance for Medical Image
25 // Computing (NAMIC), funded by the National Institutes of Health
26 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
27 // Information on the National Centers for Biomedical Computing
28 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
29 
30 #ifndef __vtkKWSpinButtons_h
31 #define __vtkKWSpinButtons_h
32 
33 #include "vtkKWCompositeWidget.h"
34 
35 class vtkKWPushButton;
36 
38 {
39 public:
40  static vtkKWSpinButtons* New();
41  vtkTypeRevisionMacro(vtkKWSpinButtons,vtkKWCompositeWidget);
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
44  // Description:
45  // Get the buttons
46  vtkGetObjectMacro(PreviousButton, vtkKWPushButton);
47  vtkGetObjectMacro(NextButton, vtkKWPushButton);
48 
49  // Description:
50  // Specifies the commands to associate to the next and previous
51  // buttons.
52  // The 'object' argument is the object that will have the method called on
53  // it. The 'method' argument is the name of the method to be called and any
54  // arguments in string form. If the object is NULL, the method is still
55  // evaluated as a simple command.
56  virtual void SetPreviousCommand(vtkObject *object, const char *method);
57  virtual void SetNextCommand(vtkObject *object, const char *method);
58 
59  // Description:
60  // Set/Get the arrow orientation of the spin buttons.
61  // If set to horizontal, left/right arrows will be used. If set to
62  // vertical, up/down arrows will be used.
63  //BTX
64  enum
65  {
66  ArrowOrientationHorizontal = 0,
67  ArrowOrientationVertical
68  };
69  //ETX
70  virtual void SetArrowOrientation(int);
71  vtkGetMacro(ArrowOrientation, int);
72  virtual void SetArrowOrientationToHorizontal()
73  { this->SetArrowOrientation(
75  virtual void SetArrowOrientationToVertical()
76  { this->SetArrowOrientation(
78 
79  // Description:
80  // Set/Get the layout of the spin buttons.
81  // If set to horizontal, the 'previous' button is packed to the
82  // left of the 'next' button. If set to vertical, the 'previous' button
83  // is packed on top of the 'next' button.
84  //BTX
85  enum
86  {
87  LayoutOrientationHorizontal = 0,
88  LayoutOrientationVertical
89  };
90  //ETX
91  virtual void SetLayoutOrientation(int);
92  vtkGetMacro(LayoutOrientation, int);
93  virtual void SetLayoutOrientationToHorizontal()
94  { this->SetLayoutOrientation(
96  virtual void SetLayoutOrientationToVertical()
97  { this->SetLayoutOrientation(
99 
100  // Description:
101  // Set/Get the padding that will be applied around each buttons.
102  // (default to 0).
103  virtual void SetButtonsPadX(int);
104  vtkGetMacro(ButtonsPadX, int);
105  virtual void SetButtonsPadY(int);
106  vtkGetMacro(ButtonsPadY, int);
107 
108  // Description:
109  // Set the buttons width/height.
110  // No effects if called before Create()
111  virtual void SetButtonsWidth(int w);
112  virtual int GetButtonsWidth();
113  virtual void SetButtonsHeight(int h);
114  virtual int GetButtonsHeight();
115 
116  // Description:
117  // Update the "enable" state of the object and its internal parts.
118  // Depending on different Ivars (this->Enabled, the application's
119  // Limited Edition Mode, etc.), the "enable" state of the object is updated
120  // and propagated to its internal parts/subwidgets. This will, for example,
121  // enable/disable parts of the widget UI, enable/disable the visibility
122  // of 3D widgets, etc.
123  virtual void UpdateEnableState();
124 
125 protected:
127  ~vtkKWSpinButtons();
128 
129  // Description:
130  // Create the widget.
131  virtual void CreateWidget();
132 
133  vtkKWPushButton *PreviousButton;
134  vtkKWPushButton *NextButton;
135 
136  int ArrowOrientation;
137  int LayoutOrientation;
138 
139  int ButtonsPadX;
140  int ButtonsPadY;
141 
142  virtual void Pack();
143  virtual void UpdateArrowOrientation();
144 
145 private:
146  vtkKWSpinButtons(const vtkKWSpinButtons&); // Not implemented
147  void operator=(const vtkKWSpinButtons&); // Not implemented
148 };
149 
150 
151 #endif
152 
153 
154