summaryrefslogtreecommitdiff
path: root/libs/cassowary/cassowary/ClPoint.h
blob: 15139aa73b99bce01f329e4a31cd2755f05d3d9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// $Id$
//
// Cassowary Incremental Constraint Solver
// Original Smalltalk Implementation by Alan Borning
// This C++ Implementation by Greg J. Badros, <gjb@cs.washington.edu>
// http://www.cs.washington.edu/homes/gjb
// (C) 1998, 1999 Greg J. Badros and Alan Borning
// See ../LICENSE for legal details regarding this software
//
// ClPoint.h

#ifndef ClPoint_H
#define ClPoint_H

#if defined(HAVE_CONFIG_H) && !defined(CONFIG_H_INCLUDED) && !defined(CONFIG_INLINE_H_INCLUDED)
#include <cassowary/config-inline.h>
#define CONFIG_INLINE_H_INCLUDED
#endif

#include "Cassowary.h"
#include "ClVariable.h"

// ClPoint is just a convenience class for pairs of
// ClVariables -- often useful for coordinate pairs in 2-space
class ClPoint {
 public:
  ClPoint(Number x, Number y)
    : _clv_x(x), _clv_y(y)
    { }

  ClPoint()
    { }

  ClVariable X()
    { return _clv_x; }

  ClVariable Y()
    { return _clv_y; }

  const ClVariable X() const
    { return _clv_x; }

  const ClVariable Y() const
    { return _clv_y; }

  void SetXY(Number x, Number y)
    { _clv_x.SetValue(x); _clv_y.SetValue(y); }

  Number Xvalue() const
    { return X().Value(); }

  Number Yvalue() const
    { return Y().Value(); }

 private:
  ClVariable _clv_x;
  ClVariable _clv_y;

#ifndef CL_NO_IO
  friend ostream &operator<<(ostream &xo, const ClPoint &clp);
#endif
  
};

#ifndef CL_NO_IO
inline ostream &
operator<<(ostream &xo, const ClPoint &clp)
{
  xo << "(" << clp._clv_x << ", " << clp._clv_y << ")";
  return xo;
}
#endif

#endif