home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / LAYOUTWI.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  4.6 KB  |  150 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   include\owl\layoutwi.h
  4. //   Declarations of classes TLayoutMetrics & TLayoutWindow
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_LAYOUTWI_H)
  7. #define __OWL_LAYOUTWI_H
  8.  
  9. #if !defined(__OWL_WINDOW_H)
  10.   #include <owl\window.h>
  11. #endif
  12. #if !defined(__OWL_LAYOUTCO_H)
  13.   #include <owl\layoutco.h>
  14. #endif
  15.  
  16. //
  17. //  class TLayoutMetrics
  18. //  ----- --------------
  19. //
  20. //  when specifying the layout metrics for a window you specify four layout
  21. //  constraints
  22. //
  23. class _OWLCLASS TLayoutMetrics {
  24.   public:
  25.     TEdgeConstraint         X;      // Horz1 can be lmLeft, lmCenter, lmRight
  26.     TEdgeConstraint         Y;      // Vert1 can be lmTop, lmCenter, lmBottom
  27.     TEdgeOrWidthConstraint  Width;  // Horz2 can be lmWidth, lmCenter, lmRight
  28.     TEdgeOrHeightConstraint Height; // Vert2 can be lmHeight, lmCenter, lmBottom
  29.  
  30.     //
  31.     // defaults each co: RelWin=0, MyEdge=(1st from above), Relationship=AsIs
  32.     //
  33.     TLayoutMetrics();
  34.   
  35.     void SetMeasurementUnits(TMeasurementUnits units);
  36. };
  37.  
  38. //
  39. // private structs used by TLayoutWindow
  40. //
  41. struct TChildMetrics;
  42. struct TConstraint;
  43. struct TVariable;
  44.  
  45. //
  46. //  class TLayoutWindow
  47. //  ----- -------------
  48. //
  49. // when specifying the layout metrics for a window, there are several options:
  50. //   e.g. in the horizontal direction,
  51. //
  52. //   Two Edge Constraints in X and Width
  53. //    1. left edge and right edge
  54. //    2. center edge and right edge
  55. //    3. left edge and center edge
  56. //
  57. //   Edge Constraint and Size constraint in X and Width
  58. //    4. left edge and size
  59. //    5. right edge and size
  60. //    6. center edge and size
  61. //
  62. // the same holds true in the vertical direction for Y and Height
  63. //
  64. // it is also possible to specify "lmAsIs" in which case we use the windows
  65. // current value
  66. //
  67. // specifying "lmAbsolute" means that we will use whatever is in data member
  68. // "Value"
  69. //
  70. // we just name the fields "X" and "Width" and "Y" and "Height",
  71. // although its okay to place a right or center edge constraint in the
  72. // "Width" field and its also okay to place a right edge constraint in
  73. // the "X" field (i.e. option #3)
  74. //
  75. // however, it's NOT okay to place a width constraint in the "X" or
  76. // "Height" fields or a height constraint in the "Y" or "Width" fields.
  77. //
  78. class _OWLCLASS TLayoutWindow : virtual public TWindow {
  79.   public:
  80.     TLayoutWindow(TWindow*        parent,
  81.                   const char far* title = 0,
  82.                   TModule*        module = 0);
  83.  
  84.    ~TLayoutWindow();
  85.  
  86.     //
  87.     // causes the receiver to size/position its children according to the
  88.     // specified layout metrics
  89.     //
  90.     // if you change the layout metrics for a child window call Layout()
  91.     // to have the changes take effect
  92.     //
  93.     void            Layout();
  94.  
  95.     void            SetChildLayoutMetrics(TWindow& child, TLayoutMetrics& metrics);
  96.     BOOL            GetChildLayoutMetrics(TWindow& child, TLayoutMetrics& metrics);
  97.     BOOL            RemoveChildLayoutMetrics(TWindow& child);
  98.  
  99.   protected:
  100.     TSize           ClientSize;
  101.  
  102.     //
  103.     // responds to a change in size by calling Layout()
  104.     //
  105.     void            EvSize(UINT sizeType, TSize& size);
  106.  
  107.     //
  108.     // Override TWindow virtuals
  109.     //
  110.     void            RemoveChild(TWindow* child);
  111.  
  112.   private:
  113.     enum TWhichConstraint {XConstraint,     YConstraint,
  114.                            WidthConstraint, HeightConstraint};
  115.  
  116.     TChildMetrics*  ChildMetrics;
  117.     TConstraint*    Constraints;
  118.     TConstraint*    Plan;
  119.     TVariable*      Variables;
  120.     BOOL            PlanIsDirty;
  121.     int             NumChildMetrics;
  122.     int             FontHeight;
  123.  
  124.     TChildMetrics*  GetChildMetrics(TWindow& child);
  125.  
  126.     void            AddConstraint(TChildMetrics&     metrics,
  127.                                   TLayoutConstraint* c,
  128.                                   TWhichConstraint   whichContraint);
  129.     void            BuildConstraints(TChildMetrics& childMetrics);
  130.     void            RemoveConstraints(TChildMetrics& childMetrics);
  131.  
  132.     void            BuildPlan();
  133.     void            ExecutePlan();
  134.     void            ClearPlan();
  135.  
  136.     int             LayoutUnitsToPixels(int);
  137.     void            GetFontHeight();
  138.  
  139.     //
  140.     // hidden to prevent accidental copying or assignment
  141.     //
  142.     TLayoutWindow(const TLayoutWindow&);
  143.     TLayoutWindow& operator =(const TLayoutWindow&);
  144.  
  145.   DECLARE_RESPONSE_TABLE(TLayoutWindow);
  146.   DECLARE_CASTABLE;
  147. };
  148.  
  149. #endif  // __OWL_LAYOUTWIN_H
  150.