Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > ed1483a4d9709d82850bb84cf25535e7 > files > 170

sfml-1.5-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="tabs.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="logo">
            <img src="./logo.jpg" width="770" height="200" title="SFML home" alt="SFML logo" />
        </div>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.htm"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.htm"><span>Namespaces</span></a></li>
      <li><a href="annotated.htm"><span>Classes</span></a></li>
      <li class="current"><a href="files.htm"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.htm"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>WindowController.mm</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// SFML - Simple and Fast Multimedia Library</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007-2008 Lucas Soltic (elmerod@gmail.com) and Laurent Gomila (laurent.gom@gmail.com)</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// This software is provided 'as-is', without any express or implied warranty.</span>
<a name="l00007"></a>00007 <span class="comment">// In no event will the authors be held liable for any damages arising from the use of this software.</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// Permission is granted to anyone to use this software for any purpose,</span>
<a name="l00010"></a>00010 <span class="comment">// including commercial applications, and to alter it and redistribute it freely,</span>
<a name="l00011"></a>00011 <span class="comment">// subject to the following restrictions:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// 1. The origin of this software must not be misrepresented;</span>
<a name="l00014"></a>00014 <span class="comment">//    you must not claim that you wrote the original software.</span>
<a name="l00015"></a>00015 <span class="comment">//    If you use this software in a product, an acknowledgment</span>
<a name="l00016"></a>00016 <span class="comment">//    in the product documentation would be appreciated but is not required.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// 2. Altered source versions must be plainly marked as such,</span>
<a name="l00019"></a>00019 <span class="comment">//    and must not be misrepresented as being the original software.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// 3. This notice may not be removed or altered from any source distribution.</span>
<a name="l00022"></a>00022 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment"></span>
<a name="l00025"></a>00025 
<a name="l00027"></a>00027 <span class="comment">// Headers</span>
<a name="l00029"></a>00029 <span class="comment"></span><span class="preprocessor">#import &lt;SFML/Window/Cocoa/WindowController.h&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#import &lt;SFML/Window/Cocoa/WindowImplCocoa.hpp&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#import &lt;SFML/Window/Cocoa/AppController.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#import &lt;OpenGL/gl.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#import &lt;iostream&gt;</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="keyword">@implementation </span><a class="code" href="interfaceWindowController.htm" title="WindowController is a Cocoa notification receiver.">WindowController</a>
<a name="l00036"></a>00036 
<a name="l00040"></a>00040 - (id)init
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042     <span class="keywordflow">return</span> [<span class="keyword">self</span> initWithWindow:NULL];
<a name="l00043"></a>00043 }
<a name="l00044"></a>00044 
<a name="l00049"></a><a class="code" href="interfaceWindowController.htm#98ad1e38fe4de9572470fe2d5cb92d6d">00049</a> - (<a class="code" href="interfaceWindowController.htm" title="WindowController is a Cocoa notification receiver.">WindowController</a> *)initWithWindow:(sf::priv::WindowImplCocoa *)window
<a name="l00050"></a>00050 {
<a name="l00051"></a>00051     <span class="keywordflow">if</span> (window == NULL) {
<a name="l00052"></a>00052         std::cerr &lt;&lt; <span class="stringliteral">"-[WindowController initWithWindow:NULL] -- initialization without any linked window is forbidden ; nil returned"</span> &lt;&lt; std::endl;
<a name="l00053"></a>00053         [<span class="keyword">self</span> release];
<a name="l00054"></a>00054         <span class="keywordflow">return</span> nil;
<a name="l00055"></a>00055     }
<a name="l00056"></a>00056     
<a name="l00057"></a>00057     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00058"></a>00058     
<a name="l00059"></a>00059     <span class="keywordflow">if</span> (<span class="keyword">self</span> != nil) {
<a name="l00060"></a>00060         parentWindow = window;
<a name="l00061"></a>00061     }
<a name="l00062"></a>00062     
<a name="l00063"></a>00063     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065 
<a name="l00070"></a><a class="code" href="interfaceWindowController.htm#1b4f0eb89b8ea32da4561549e1739333">00070</a> + (<a class="code" href="interfaceWindowController.htm" title="WindowController is a Cocoa notification receiver.">WindowController</a> *)controllerWithWindow:(sf::priv::WindowImplCocoa *)window
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072     <a class="code" href="interfaceWindowController.htm" title="WindowController is a Cocoa notification receiver.">WindowController</a> *ctrl = 
<a name="l00073"></a>00073     massert([<a class="code" href="interfaceWindowController.htm" title="WindowController is a Cocoa notification receiver.">WindowController</a> alloc]);
<a name="l00074"></a>00074     <span class="keywordflow">return</span> [[ctrl <a class="code" href="interfaceWindowController.htm#98ad1e38fe4de9572470fe2d5cb92d6d" title="Initialize a new WindowController object and link it to the &amp;#39;window&amp;#39; object...">initWithWindow</a>:window] autorelease];
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 
<a name="l00080"></a>00080 - (void)pushEvent:(sf::Event)sfEvent
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082     <span class="keywordflow">if</span> (parentWindow != NULL) {
<a name="l00083"></a>00083         parentWindow-&gt;HandleNotifiedEvent(sfEvent);
<a name="l00084"></a>00084     }
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 
<a name="l00090"></a><a class="code" href="interfaceWindowController.htm#400fba3ac695c72dfbc7a11d7dac601d">00090</a> - (void)viewFrameDidChange:(NSNotification *)notification
<a name="l00091"></a>00091 {
<a name="l00092"></a>00092     NSOpenGLView *glView = [notification object];
<a name="l00093"></a>00093     [[glView openGLContext] update];
<a name="l00094"></a>00094     
<a name="l00095"></a>00095     <a class="code" href="classsf_1_1Event.htm" title="Event defines a system event and its parameters.">sf::Event</a> ev;
<a name="l00096"></a>00096     ev.<a class="code" href="classsf_1_1Event.htm#90d5da29dd2f49d13dc10e7a402c0b65" title="Type of the event.">Type</a> = sf::Event::Resized;
<a name="l00097"></a>00097     ev.<a class="code" href="classsf_1_1Event.htm#bf98a968c19a31f9719ff40839c28f9e">Size</a>.Width = (unsigned) [glView frame].size.width;
<a name="l00098"></a>00098     ev.<a class="code" href="classsf_1_1Event.htm#bf98a968c19a31f9719ff40839c28f9e">Size</a>.Height = (<span class="keywordtype">unsigned</span>) [glView frame].size.height;
<a name="l00099"></a>00099     
<a name="l00100"></a>00100     [<span class="keyword">self</span> pushEvent:ev];
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 
<a name="l00106"></a><a class="code" href="interfaceWindowController.htm#6ce6c07813059e414b4498b66c628a4d">00106</a> - (void)windowDidBecomeMain:(NSNotification *)notification
<a name="l00107"></a>00107 {
<a name="l00108"></a>00108     <a class="code" href="classsf_1_1Event.htm" title="Event defines a system event and its parameters.">sf::Event</a> ev;
<a name="l00109"></a>00109     ev.<a class="code" href="classsf_1_1Event.htm#90d5da29dd2f49d13dc10e7a402c0b65" title="Type of the event.">Type</a> = sf::Event::GainedFocus;
<a name="l00110"></a>00110     
<a name="l00111"></a>00111     [<span class="keyword">self</span> pushEvent:ev];
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113 
<a name="l00117"></a><a class="code" href="interfaceWindowController.htm#4e6f6e31f3192512f08e0756ea99fea6">00117</a> - (void)windowDidResignMain:(NSNotification *)notification
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119     <a class="code" href="classsf_1_1Event.htm" title="Event defines a system event and its parameters.">sf::Event</a> ev;
<a name="l00120"></a>00120     ev.<a class="code" href="classsf_1_1Event.htm#90d5da29dd2f49d13dc10e7a402c0b65" title="Type of the event.">Type</a> = sf::Event::LostFocus;
<a name="l00121"></a>00121     
<a name="l00122"></a>00122     [<span class="keyword">self</span> pushEvent:ev];
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124 
<a name="l00128"></a><a class="code" href="interfaceWindowController.htm#01d1957f341704d1c00cdbe8fc96029d">00128</a> - (void)windowWillClose:(NSNotification *)notification
<a name="l00129"></a>00129 {
<a name="l00130"></a>00130     <a class="code" href="classsf_1_1Event.htm" title="Event defines a system event and its parameters.">sf::Event</a> ev;
<a name="l00131"></a>00131     ev.<a class="code" href="classsf_1_1Event.htm#90d5da29dd2f49d13dc10e7a402c0b65" title="Type of the event.">Type</a> = sf::Event::Closed;
<a name="l00132"></a>00132     
<a name="l00133"></a>00133     [<span class="keyword">self</span> pushEvent:ev];
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135 
<a name="l00136"></a>00136 - (void)windowDidMove:(NSNotification *)notification
<a name="l00137"></a>00137 {
<a name="l00138"></a>00138     NSWindow *sender = [notification object];
<a name="l00139"></a>00139     
<a name="l00140"></a>00140     <span class="keywordflow">if</span> (!([sender styleMask] &amp; NSTitledWindowMask))
<a name="l00141"></a>00141         [sender center];
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143 
<a name="l00144"></a>00144 <span class="keyword">@end</span>
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 
<a name="l00147"></a>00147 <span class="keyword">@implementation </span>SFWindow
<a name="l00148"></a>00148 - (BOOL)canBecomeKeyWindow
<a name="l00149"></a>00149 {
<a name="l00150"></a>00150     <span class="keywordflow">return</span> YES;
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152 
<a name="l00153"></a>00153 - (BOOL)canBecomeMainWindow
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155     <span class="keywordflow">return</span> YES;
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157 <span class="keyword">@end</span>
</pre></div></div>

        <p id="footer">
            &nbsp;::&nbsp; Copyright &copy; 2007-2008 Laurent Gomila, all rights reserved &nbsp;::&nbsp;
            Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.5.2</a> &nbsp;::&nbsp;
        </p>

    </body>
</html>