00001 // This code is a part of the NanoSoft NSViews C++ Library. 00002 // Copyright (C) 1996 NanoSoft Corporation. All rights reserved. 00003 00004 #ifndef __NSFlexConstraints_h__ 00005 #define __NSFlexConstraints_h__ 00006 00007 #include "NSViewsAfxExt.h" 00008 00009 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00010 00011 // CNSFlexHorizontalConstraint defines a horizontal position constraint for 00012 // a control. The class includes virtual functions for constructing more 00013 // complex derived constraint types. 00014 00015 class AFX_EXT_NSVIEWS CNSFlexHorizontalConstraint 00016 { 00017 00018 // -------------------------------------------------------------------------- 00019 00020 public: 00021 00022 // Constructors. 00023 CNSFlexHorizontalConstraint(float fLeft = 0.0f, float fRight = 0.0f); 00024 CNSFlexHorizontalConstraint(const CNSFlexHorizontalConstraint& ref); 00025 // fLeft - Position value associated with the left edge of a control. 00026 // Value should be in the range of 0.0f to 1.0f. 00027 // fRight - Position value associated with the right edge of a control. 00028 // Value should be in the range of 0.0f to 1.0f. 00029 // ref - Reference object for copy constructor. 00030 00031 // Assignment operator. 00032 const CNSFlexHorizontalConstraint& operator=( 00033 CNSFlexHorizontalConstraint& ref); 00034 // ref - Reference object. 00035 00036 // Return a copy of me. Override for derived types. 00037 virtual CNSFlexHorizontalConstraint* CopyMe() const; 00038 00039 // Destructor. 00040 virtual ~CNSFlexHorizontalConstraint(); 00041 00042 // Set constraint values. Override for derived types. 00043 virtual void Init(const CWnd* pContainerWnd, int nWidth); 00044 // pContainerWnd - Pointer to window that contains controls associated 00045 // with this constraint. 00046 // nHeight - Height of window that contains controls associated with 00047 // this constraint 00048 00049 // Get the constraint values. 00050 float GetLeft() const { return m_fLeft; }; 00051 float GetRight() const { return m_fRight; }; 00052 00053 // -------------------------------------------------------------------------- 00054 00055 protected: 00056 00057 void SetLeft(float fLeft); 00058 void SetRight(float fRight); 00059 00060 private: 00061 00062 float m_fLeft; 00063 float m_fRight; 00064 00065 }; 00066 00067 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00068 00069 // Useful constants for horizontal constraints: 00070 00071 extern const AFX_EXT_NSVIEWS CNSFlexHorizontalConstraint 00072 NSFlexHorizontallyFixed; // (0.0, 0.0) 00073 00074 extern const AFX_EXT_NSVIEWS CNSFlexHorizontalConstraint 00075 NSFlexShiftRight; // (1.0, 1.0) 00076 00077 extern const AFX_EXT_NSVIEWS CNSFlexHorizontalConstraint 00078 NSFlexExpandRight; // (0.0, 1.0) 00079 00080 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00081 00082 // CNSFlexVerticalConstraint defines a vertical position constraint for 00083 // a control. The class includes virtual functions for constructing more 00084 // complex derived constraint types. 00085 00086 class AFX_EXT_NSVIEWS CNSFlexVerticalConstraint 00087 { 00088 00089 // -------------------------------------------------------------------------- 00090 00091 public: 00092 00093 // Constructors. 00094 CNSFlexVerticalConstraint(float fTop = 0.0f, float fBottom = 0.0f); 00095 CNSFlexVerticalConstraint(const CNSFlexVerticalConstraint& ref); 00096 // fTop - Position value associated with the top edge of a control. 00097 // Value should be in the range of 0.0f to 1.0f. 00098 // fBottom - Position value associated with the bottom edge of a control. 00099 // Value should be in the range of 0.0f to 1.0f. 00100 // ref - Reference object for copy constructor. 00101 00102 // Assignment operator. 00103 const CNSFlexVerticalConstraint& operator=( 00104 CNSFlexVerticalConstraint& ref); 00105 // ref - Reference object. 00106 00107 // Return a copy of me. Override for derived types. 00108 virtual CNSFlexVerticalConstraint* CopyMe() const; 00109 00110 // Destructor. 00111 virtual ~CNSFlexVerticalConstraint(); 00112 00113 // Set constraint values. Override for derived types. 00114 virtual void Init(const CWnd* pContainerWnd, int nHeight); 00115 // pContainerWnd - Pointer to window that contains controls associated 00116 // with this constraint. 00117 // nHeight - Height of window that contains controls associated with 00118 // this constraint 00119 00120 // Get the constraint values. 00121 float GetTop() const { return m_fTop; }; 00122 float GetBottom() const { return m_fBottom; }; 00123 00124 // -------------------------------------------------------------------------- 00125 00126 protected: 00127 00128 void SetTop(float fTop); 00129 void SetBottom(float fBottom); 00130 00131 private: 00132 00133 float m_fTop; 00134 float m_fBottom; 00135 }; 00136 00137 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00138 00139 // Useful constants for vertical constraints: 00140 00141 extern const AFX_EXT_NSVIEWS CNSFlexVerticalConstraint 00142 NSFlexVerticallyFixed; // (0.0, 0.0) 00143 00144 extern const AFX_EXT_NSVIEWS CNSFlexVerticalConstraint 00145 NSFlexShiftDown; // (1.0, 1.0) 00146 00147 extern const AFX_EXT_NSVIEWS CNSFlexVerticalConstraint 00148 NSFlexExpandDown; // (0.0, 1.0) 00149 00150 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00151 00152 #endif
1.5.1