KWWidgets
vtkKWSplitFrame.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWSplitFrame.h,v $
00004 
00005   Copyright (c) Kitware, Inc.
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 // .NAME vtkKWSplitFrame - A Frame that contains two adjustable sub frames.
00015 // .SECTION Description
00016 // The split frame allows the use to select the size of the two frames.
00017 // It uses a separator that can be dragged interactively.
00018 
00019 
00020 #ifndef __vtkKWSplitFrame_h
00021 #define __vtkKWSplitFrame_h
00022 
00023 #include "vtkKWCompositeWidget.h"
00024 
00025 class vtkKWFrame;
00026 class vtkKWPushButton;
00027 
00028 class KWWidgets_EXPORT vtkKWSplitFrame : public vtkKWCompositeWidget
00029 {
00030 public:
00031   static vtkKWSplitFrame* New();
00032   vtkTypeRevisionMacro(vtkKWSplitFrame,vtkKWCompositeWidget);
00033   void PrintSelf(ostream& os, vtkIndent indent);
00034 
00035   // Description:
00036   // Get Frame1. In horizontal orientation, this is the one on the left of the
00037   // separator. In vertical orientation, the one at the bottom.
00038   // Both Frame1 and Frame2 position can be swapped using the SetFrameLayout
00039   // method.
00040   vtkKWFrame *GetFrame1() {return this->Frame1;};
00041 
00042   // Description:
00043   // Get Frame2. In horizontal orientation, this is the one on the right of the
00044   // separator. In vertical orientation, the one at the top.
00045   // Both Frame1 and Frame2 position can be swapped using the SetFrameLayout
00046   // method.
00047   vtkKWFrame *GetFrame2() {return this->Frame2;};
00048 
00049   // Description:
00050   // Set/Get the orientation of the split frame.
00051   // If horizontal, Frame1 is on the left of the separator, Frame2 on the
00052   // right. If Vertical, Frame1 is below the separator, Frame2 is on top.
00053   // Both Frame1 and Frame2 position can be swapped using the SetFrameLayout
00054   // method.
00055   //BTX
00056   enum 
00057   {
00058     OrientationHorizontal = 0,
00059     OrientationVertical
00060   };
00061   //ETX
00062   virtual void SetOrientation(int);
00063   vtkGetMacro(Orientation, int);
00064   virtual void SetOrientationToHorizontal()
00065     { this->SetOrientation(vtkKWSplitFrame::OrientationHorizontal); };
00066   virtual void SetOrientationToVertical()
00067     { this->SetOrientation(vtkKWSplitFrame::OrientationVertical); };
00068 
00069   // Description:
00070   // Set/Get the frame layout.
00071   // If set to Default, depending on the orientation, Frame1 is on the left
00072   // (respectively bottom) of the separator, Frame2 on the right (top).
00073   // If set to Swapped, Frame1 and Frame2 position are exchanged.
00074   //BTX
00075   enum 
00076   {
00077     FrameLayoutDefault = 0,
00078     FrameLayoutSwapped
00079   };
00080   //ETX
00081   virtual void SetFrameLayout(int);
00082   vtkGetMacro(FrameLayout, int);
00083   virtual void SetFrameLayoutToDefault()
00084     { this->SetFrameLayout(vtkKWSplitFrame::FrameLayoutDefault); };
00085   virtual void SetFrameLayoutToSwapped()
00086     { this->SetFrameLayout(vtkKWSplitFrame::FrameLayoutSwapped); };
00087 
00088   // Description:
00089   // Set/Get which frame is automatically expanded when the whole widget
00090   // is resized. By default, Frame2 (i.e. right or top frame)
00091   //BTX
00092   enum 
00093   {
00094     ExpandableFrame1 = 0,
00095     ExpandableFrame2,
00096     ExpandableFrameBoth
00097   };
00098   //ETX
00099   vtkSetClampMacro(ExpandableFrame, int, 
00100                    vtkKWSplitFrame::ExpandableFrame1, 
00101                    vtkKWSplitFrame::ExpandableFrameBoth);
00102   vtkGetMacro(ExpandableFrame, int);
00103   virtual void SetExpandableFrameToFrame1()
00104     { this->SetExpandableFrame(vtkKWSplitFrame::ExpandableFrame1); };
00105   virtual void SetExpandableFrameToFrame2()
00106     { this->SetExpandableFrame(vtkKWSplitFrame::ExpandableFrame2); };
00107   virtual void SetExpandableFrameToBothFrames()
00108     { this->SetExpandableFrame(vtkKWSplitFrame::ExpandableFrameBoth); };
00109 
00110   // Description:
00111   // Set/Get The minimum size, size and visibility of Frame1.
00112   vtkGetMacro(Frame1MinimumSize, int);
00113   virtual void SetFrame1MinimumSize(int minSize);
00114   vtkGetMacro(Frame1Size, int);
00115   virtual void SetFrame1Size(int size);
00116   vtkGetMacro(Frame1Visibility, int);
00117   virtual void SetFrame1Visibility(int flag);
00118   vtkBooleanMacro(Frame1Visibility, int);  
00119 
00120   // Description:
00121   // Set/Get The minimum size, size and visibility of Frame2.
00122   vtkGetMacro(Frame2MinimumSize, int);
00123   virtual void SetFrame2MinimumSize(int minSize);
00124   vtkGetMacro(Frame2Size, int);
00125   virtual void SetFrame2Size(int size);
00126   vtkGetMacro(Frame2Visibility, int);
00127   virtual void SetFrame2Visibility(int flag);
00128   vtkBooleanMacro(Frame2Visibility, int);  
00129 
00130   // Description:
00131   // Set the size of both frames by setting the relative position of the
00132   // separator. This will not work until the widget has been mapped on screen.
00133   virtual void SetSeparatorPosition(double pos);
00134   virtual double GetSeparatorPosition();
00135 
00136   // Description:
00137   // Set/Get the separator narrow dimension.
00138   // If the size is 0, then the two frames cannot be adjusted by the user.
00139   virtual void SetSeparatorSize(int size);
00140   vtkGetMacro(SeparatorSize, int);
00141 
00142   // Description:
00143   // Set/Get the separator narrow margin, i.e. the empty space around the
00144   // separator itself.
00145   virtual void SetSeparatorMargin(int size);
00146   vtkGetMacro(SeparatorMargin, int);
00147 
00148   // Description:
00149   // Set/Get the visibility of the separator.  
00150   virtual void SetSeparatorVisibility(int flag);
00151   vtkGetMacro(SeparatorVisibility, int);
00152   vtkBooleanMacro(SeparatorVisibility, int);  
00153 
00154   // Description:
00155   // Update the "enable" state of the object and its internal parts.
00156   // Depending on different Ivars (this->Enabled, the application's 
00157   // Limited Edition Mode, etc.), the "enable" state of the object is updated
00158   // and propagated to its internal parts/subwidgets. This will, for example,
00159   // enable/disable parts of the widget UI, enable/disable the visibility
00160   // of 3D widgets, etc.
00161   virtual void UpdateEnableState();
00162 
00163   // Description:
00164   // Callbacks. Internal, do not use.
00165   virtual void DragCallback();
00166   virtual void ConfigureCallback();
00167   virtual void Expand1ButtonCallback();
00168   virtual void Expand2ButtonCallback();
00169 
00170   // Description:
00171   // Events. Frame1VisibilityChangedEvent (respectively 
00172   // Frame2VisibilityChangedEvent) is invoked when the visibility
00173   // status of frame 1 (respectively frame 2) is changed.
00174   // FrameVisibilityChangedEvent in both cases.
00175   //BTX
00176   enum
00177   {
00178     FrameVisibilityChangedEvent = 10000,
00179     Frame1VisibilityChangedEvent,
00180     Frame2VisibilityChangedEvent
00181   };
00182   //ETX
00183 
00184 protected:
00185   vtkKWSplitFrame();
00186   ~vtkKWSplitFrame();
00187 
00188   // Description:
00189   // Create the widget.
00190   virtual void CreateWidget();
00191   
00192   virtual int GetTotalSeparatorSize();
00193   virtual void UpdateExpandButtonsEnableState();
00194 
00195   vtkKWFrame *Frame1;
00196   vtkKWFrame *Frame2;
00197 
00198   vtkKWFrame *SeparatorFrame;
00199   vtkKWFrame *Separator;
00200   vtkKWPushButton *Expand1Button;
00201   vtkKWPushButton *Expand2Button;
00202 
00203   int Size;
00204   int Frame1Size;
00205   int Frame2Size;
00206 
00207   int SeparatorSize;
00208   int SeparatorMargin;
00209   int SeparatorVisibility;
00210 
00211   int Frame1Visibility;
00212   int Frame2Visibility;
00213 
00214   int Frame1MinimumSize;
00215   int Frame2MinimumSize;
00216 
00217   int Orientation;
00218   int FrameLayout;
00219   int ExpandableFrame;
00220 
00221   // Reset the actual windows to match our size IVars.
00222 
00223   virtual void Pack();
00224   virtual void AddBindings();
00225   virtual void RemoveBindings();
00226   virtual void AddSeparatorBindings();
00227   virtual void RemoveSeparatorBindings();
00228   virtual void ReConfigure();
00229   virtual int GetInternalMarginHorizontal();
00230   virtual int GetInternalMarginVertical();
00231   virtual void ConfigureSeparator();
00232   virtual void ConfigureExpandButtons();
00233 
00234 private:
00235   vtkKWSplitFrame(const vtkKWSplitFrame&); // Not implemented
00236   void operator=(const vtkKWSplitFrame&); // Not implemented
00237 };
00238 
00239 
00240 #endif
00241 
00242 
00243