Rectangle Generic class support in C#
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / rectangle.i
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 %csmethodmodifiers Dali::Rect<int>::x "private";
18 %csmethodmodifiers Dali::Rect<int>::y "private";
19 %csmethodmodifiers Dali::Rect<int>::left "private";
20 %csmethodmodifiers Dali::Rect<int>::right "private";
21 %csmethodmodifiers Dali::Rect<int>::width "private";
22 %csmethodmodifiers Dali::Rect<int>::bottom "private";
23 %csmethodmodifiers Dali::Rect<int>::height "private";
24 %csmethodmodifiers Dali::Rect<int>::top "private";
25
26 %define DALI_RECTANGLE_PROPERTY_PARAM(NameSpace,ClassName)
27   %typemap(cscode) NameSpace::ClassName %{
28     public static bool operator ==(Rectangle a, Rectangle b)
29     {
30         // If both are null, or both are same instance, return true.
31         if (System.Object.ReferenceEquals(a, b))
32         {
33             return true;
34         }
35
36         // If one is null, but not both, return false.
37         if (((object)a == null) || ((object)b == null))
38         {
39             return false;
40         }
41
42         // Return true if the fields match:
43         return a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height;
44     }
45
46     public static bool operator !=(Rectangle a, Rectangle b)
47     {
48         return !(a == b);
49     }
50
51     ///< X position of the rectangle
52     public int X
53     {
54         set
55         {
56             x = value;
57         }
58         get
59         {
60             return x;
61         }
62     }
63
64     ///< Y position of the rectangle
65     public int Y
66     {
67         set
68         {
69             y = value;
70         }
71         get
72         {
73             return y;
74         }
75     }
76
77     ///< Width of the rectangle
78     public int Width
79     {
80         set
81         {
82             width = value;
83         }
84         get
85         {
86             return width;
87         }
88     }
89
90     ///< Height of the rectangle
91     public int Height
92     {
93         set
94         {
95             height = value;
96         }
97         get
98         {
99             return height;
100         }
101     }
102 %}
103
104 %enddef
105
106 namespace Dali
107 {
108   DALI_RECTANGLE_PROPERTY_PARAM( Dali, Rect<int>);
109 }