Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1452 chris 1
#region License
2
//
3
// The Open Toolkit Library License
4
//
5
// Copyright (c) 2006 - 2009 the Open Toolkit library.
6
//
7
// Permission is hereby granted, free of charge, to any person obtaining a copy
8
// of this software and associated documentation files (the "Software"), to deal
9
// in the Software without restriction, including without limitation the rights to 
10
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11
// the Software, and to permit persons to whom the Software is furnished to do
12
// so, subject to the following conditions:
13
//
14
// The above copyright notice and this permission notice shall be included in all
15
// copies or substantial portions of the Software.
16
//
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
// OTHER DEALINGS IN THE SOFTWARE.
25
//
26
#endregion
27
 
28
using System;
29
using System.Collections.Generic;
30
using System.Diagnostics;
31
using System.Text;
32
 
33
namespace OpenTK.Platform.MacOS
34
{
35
    /// \internal
36
    /// <summary>
37
    /// Describes a Carbon window.
38
    /// </summary>
39
    sealed class CarbonWindowInfo : IWindowInfo
40
    {
41
        IntPtr windowRef;
42
        bool ownHandle = false;
43
        bool disposed = false;
44
        bool isControl = false;
45
                bool goFullScreenHack = false;
46
                bool goWindowedHack = false;
47
 
48
        #region Constructors
49
 
50
        /// <summary>
51
        /// Constructs a new instance with the specified parameters.
52
        /// </summary>
53
        /// <param name="windowRef">A valid Carbon window reference.</param>
54
        /// <param name="ownHandle"></param>
55
        /// <param name="isControl"></param>
56
        public CarbonWindowInfo(IntPtr windowRef, bool ownHandle, bool isControl)
57
        {
58
            this.windowRef = windowRef;
59
            this.ownHandle = ownHandle;
60
            this.isControl = isControl;
61
        }
62
 
63
        #endregion
64
 
65
        #region Public Members
66
 
67
        /// <summary>
68
        /// Gets the window reference for this instance.
69
        /// </summary>
70
        internal IntPtr WindowRef
71
        {
72
            get { return this.windowRef; }
73
        }
74
 
75
                internal bool GoFullScreenHack
76
                {
77
                        get { return goFullScreenHack; }
78
                        set { goFullScreenHack = value; }
79
                }
80
                internal bool GoWindowedHack
81
                {
82
                        get { return goWindowedHack; }
83
                        set { goWindowedHack = value; }
84
                }
85
 
86
 
87
        /// <summary>
88
        /// Gets a value indicating whether this instance refers to a System.Windows.Forms.Control.
89
        /// </summary>
90
        public bool IsControl
91
        {
92
            get { return isControl; }
93
        }
94
 
95
        /// <summary>Returns a System.String that represents the current window.</summary>
96
        /// <returns>A System.String that represents the current window.</returns>
97
        public override string ToString()
98
        {
99
            return String.Format("MacOS.CarbonWindowInfo: Handle {0}",
100
                this.WindowRef);
101
        }
102
 
103
        #endregion
104
 
105
        #region IDisposable Members
106
 
107
        public void Dispose()
108
        {
109
            Dispose(true);
110
        }
111
 
112
        void Dispose(bool disposing)
113
        {
114
            if (disposed)
115
                return;
116
 
117
            if (disposing)
118
            {
119
 
120
            }
121
 
122
            if (ownHandle)
123
            {
124
                Debug.Print("Disposing window {0}.", windowRef);
125
                Carbon.API.DisposeWindow(this.windowRef);
126
                windowRef = IntPtr.Zero;
127
            }
128
 
129
            disposed = true;
130
        }
131
 
132
        ~CarbonWindowInfo()
133
        {
134
            Dispose(false);
135
        }
136
 
137
        #endregion
138
    }
139
}