3 * Copyright (c) 2007-2010 SlimDX Group
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #include "Viewport10.h"
26 using namespace System;
27 using namespace System::Globalization;
33 Viewport::Viewport( int x, int y, int width, int height )
34 : m_X( x ), m_Y( y ), m_Width( width ), m_Height( height ),
35 m_MinZ( 0.0f ), m_MaxZ( 1.0f )
39 Viewport::Viewport( int x, int y, int width, int height, float minZ, float maxZ )
40 : m_X( x ), m_Y( y ), m_Width( width ), m_Height( height ),
41 m_MinZ( minZ ), m_MaxZ( maxZ )
45 int Viewport::X::get()
50 void Viewport::X::set( int value )
55 int Viewport::Y::get()
60 void Viewport::Y::set( int value )
65 int Viewport::Width::get()
70 void Viewport::Width::set( int value )
75 int Viewport::Height::get()
80 void Viewport::Height::set( int value )
85 float Viewport::MinZ::get()
90 void Viewport::MinZ::set( float value )
95 float Viewport::MaxZ::get()
100 void Viewport::MaxZ::set( float value )
105 bool Viewport::operator == ( Viewport left, Viewport right )
107 return Viewport::Equals( left, right );
110 bool Viewport::operator != ( Viewport left, Viewport right )
112 return !Viewport::Equals( left, right );
115 String^ Viewport::ToString()
117 return String::Format( CultureInfo::CurrentCulture, "X:{0} Y:{1} Width:{2} Height:{3} MinZ:{4} MaxZ:{5}",
118 X, Y, Width, Height, MinZ, MaxZ );
121 int Viewport::GetHashCode()
123 return m_X.GetHashCode() + m_Y.GetHashCode() + m_Width.GetHashCode()
124 + m_Height.GetHashCode() + m_MinZ.GetHashCode() + m_MaxZ.GetHashCode();
127 bool Viewport::Equals( Object^ value )
129 if( value == nullptr )
132 if( value->GetType() != GetType() )
135 return Equals( safe_cast<Viewport>( value ) );
138 bool Viewport::Equals( Viewport value )
140 return ( m_X == value.m_X && m_Y == value.m_Y && m_Width == value.m_Width
141 && m_Height == value.m_Height && m_MinZ == value.m_MinZ && m_MaxZ == value.m_MaxZ );
144 bool Viewport::Equals( Viewport% value1, Viewport% value2 )
146 return ( value1.m_X == value2.m_X && value1.m_Y == value2.m_Y && value1.m_Width == value2.m_Width
147 && value1.m_Height == value2.m_Height && value1.m_MinZ == value2.m_MinZ && value1.m_MaxZ == value2.m_MaxZ );