2 * Experimental code to use operators for constraint specification.
3 * In the end, the syntax didn't look much clearer than
4 * the original, so abandoned.
8 wxConstrain(frame->panel,
10 ( leftOf (frame->panel) = leftOf (frame),
11 topOf (frame->panel) = topOf (frame),
12 rightOf (frame->panel) = rightOf (frame),
13 heightOf (frame->panel) = 50 % heightOf (frame)
18 // Operator experiments
19 #define wxCONSTRAINT_OP_REL 1
20 #define wxCONSTRAINT_OP_PERCENT 2
21 #define wxCONSTRAINT_OP_EDGE 3
22 #define wxCONSTRAINT_OP_ABS 4
23 #define wxCONSTRAINT_OP_AND 5
25 class wxConstraintOp
: public wxObject
30 wxRelationship relationship
;
36 wxConstraintOp(int typ
)
43 relationship
= wxSameAs
;
46 wxConstraintOp(const wxConstraintOp
& op
)
50 relationship
= op
.relationship
;
55 lhs
= new wxConstraintOp(*op
.lhs
);
59 rhs
= new wxConstraintOp(*op
.rhs
);
71 wxConstraintOp
operator = (const wxConstraintOp
& arg2
);
72 wxConstraintOp
operator = (const int value
);
74 friend wxConstraintOp
operator % (const int perCent
, const wxConstraintOp
& arg2
);
75 friend wxConstraintOp
operator + (wxConstraintOp
& arg1
, int margin
);
76 friend wxConstraintOp
operator - (wxConstraintOp
& arg1
, int margin
);
77 friend wxConstraintOp
operator , (const wxConstraintOp
& arg1
, const wxConstraintOp
& arg2
);
80 wxConstraintOp
leftOf(wxWindow
*win
)
82 wxConstraintOp
thing(wxCONSTRAINT_OP_EDGE
);
88 wxConstraintOp
topOf(wxWindow
*win
)
90 wxConstraintOp
thing(wxCONSTRAINT_OP_EDGE
);
96 wxConstraintOp
widthOf(wxWindow
*win
)
98 wxConstraintOp
thing(wxCONSTRAINT_OP_EDGE
);
100 thing
.edge
= wxWidth
;
104 wxConstraintOp
wxConstraintOp::operator = (const wxConstraintOp
& arg2
)
106 wxConstraintOp
op3(wxCONSTRAINT_OP_REL
);
107 op3
.relationship
= wxPercentOf
;
109 if ((op3
.relationship
== wxPercentOf
) && (op3
.value
> 0))
110 op3
.value
= this->value
;
111 op3
.lhs
= new wxConstraintOp(*this);
112 op3
.rhs
= new wxConstraintOp(arg2
);
117 wxConstraintOp
wxConstraintOp::operator = (const int value
)
119 wxConstraintOp
op3(wxCONSTRAINT_OP_REL
);
120 op3
.relationship
= wxAbsolute
;
122 op3
.lhs
= new wxConstraintOp(*this);
123 op3
.rhs
= new wxConstraintOp(wxCONSTRAINT_OP_ABS
);
129 wxConstraintOp
operator % (const int perCent
, const wxConstraintOp
& arg2
)
131 wxConstraintOp
op3(arg2
);
132 op3
.opType
= wxCONSTRAINT_OP_EDGE
;
135 op3
.value
= arg2
.value
;
140 wxConstraintOp
operator + (wxConstraintOp
& arg1
, int margin
)
142 wxConstraintOp
op3(arg1
);
147 wxConstraintOp
operator - (wxConstraintOp
& arg1
, int margin
)
149 wxConstraintOp
op3(arg1
);
150 op3
.margin
= - margin
;
154 wxConstraintOp
operator , (const wxConstraintOp
& arg1
, const wxConstraintOp
& arg2
)
156 wxConstraintOp
op3(wxCONSTRAINT_OP_AND
);
157 op3
.lhs
= new wxConstraintOp(arg1
);
158 op3
.rhs
= new wxConstraintOp(arg2
);