705cc8989e499078c8d6d35ed41b85f6b447b14f
[chessclock] / www / html / clockswidget_8cpp_source.html
1 <!-- This comment will put IE 6, 7 and 8 in quirks mode -->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6 <title>Chess Clock: /holvi/arto/ohjelmointi/ChessClock/chessclock/classes/clockswidget.cpp Source File</title>
7 <link href="tabs.css" rel="stylesheet" type="text/css"/>
8 <link href="search/search.css" rel="stylesheet" type="text/css"/>
9 <script type="text/javaScript" src="search/search.js"></script>
10 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
11 </head>
12 <body onload='searchBox.OnSelectItem(0);'>
13 <!-- Generated by Doxygen 1.6.3 -->
14 <script type="text/javascript"><!--
15 var searchBox = new SearchBox("searchBox", "search",false,'Search');
16 --></script>
17 <div class="navigation" id="top">
18   <div class="tabs">
19     <ul>
20       <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
21       <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
22       <li><a href="annotated.html"><span>Classes</span></a></li>
23       <li class="current"><a href="files.html"><span>Files</span></a></li>
24       <li>
25         <div id="MSearchBox" class="MSearchBoxInactive">
26         <img id="MSearchSelect" src="search/search.png"
27              onmouseover="return searchBox.OnSearchSelectShow()"
28              onmouseout="return searchBox.OnSearchSelectHide()"
29              alt=""/>
30         <input type="text" id="MSearchField" value="Search" accesskey="S"
31              onfocus="searchBox.OnSearchFieldFocus(true)" 
32              onblur="searchBox.OnSearchFieldFocus(false)" 
33              onkeyup="searchBox.OnSearchFieldChange(event)"/>
34         <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
35         </div>
36       </li>
37     </ul>
38   </div>
39   <div class="tabs">
40     <ul>
41       <li><a href="files.html"><span>File&nbsp;List</span></a></li>
42       <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
43     </ul>
44   </div>
45 <h1>/holvi/arto/ohjelmointi/ChessClock/chessclock/classes/clockswidget.cpp</h1><a href="clockswidget_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001  <span class="comment">/**************************************************************************</span>
46 <a name="l00002"></a>00002 <span class="comment"></span>
47 <a name="l00003"></a>00003 <span class="comment">    Chess Clock</span>
48 <a name="l00004"></a>00004 <span class="comment"></span>
49 <a name="l00005"></a>00005 <span class="comment">    Copyright (c) Arto Hyvättinen 2010</span>
50 <a name="l00006"></a>00006 <span class="comment"></span>
51 <a name="l00007"></a>00007 <span class="comment">    This file is part of Chess Clock software.</span>
52 <a name="l00008"></a>00008 <span class="comment"></span>
53 <a name="l00009"></a>00009 <span class="comment">    Chess Clock is free software: you can redistribute it and/or modify</span>
54 <a name="l00010"></a>00010 <span class="comment">    it under the terms of the GNU General Public License as published by</span>
55 <a name="l00011"></a>00011 <span class="comment">    the Free Software Foundation, either version 3 of the License, or</span>
56 <a name="l00012"></a>00012 <span class="comment">    (at your option) any later version.</span>
57 <a name="l00013"></a>00013 <span class="comment"></span>
58 <a name="l00014"></a>00014 <span class="comment">    Chess Clock is distributed in the hope that it will be useful,</span>
59 <a name="l00015"></a>00015 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
60 <a name="l00016"></a>00016 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
61 <a name="l00017"></a>00017 <span class="comment">    GNU General Public License for more details.</span>
62 <a name="l00018"></a>00018 <span class="comment"></span>
63 <a name="l00019"></a>00019 <span class="comment"></span>
64 <a name="l00020"></a>00020 <span class="comment">**************************************************************************/</span>
65 <a name="l00021"></a>00021 
66 <a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="clockswidget_8h.html">clockswidget.h</a>&quot;</span>
67 <a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="chessclock_8h.html">chessclock.h</a>&quot;</span>
68 <a name="l00024"></a>00024 
69 <a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="screenlitkeeper_8h.html">screenlitkeeper.h</a>&quot;</span>
70 <a name="l00026"></a>00026 
71 <a name="l00027"></a>00027 <span class="preprocessor">#include &lt;QLabel&gt;</span>
72 <a name="l00028"></a>00028 <span class="preprocessor">#include &lt;QPixmap&gt;</span>
73 <a name="l00029"></a>00029 <span class="preprocessor">#include &lt;QApplication&gt;</span>
74 <a name="l00030"></a>00030 <span class="preprocessor">#include &lt;QHBoxLayout&gt;</span>
75 <a name="l00031"></a>00031 <span class="preprocessor">#include &lt;QVBoxLayout&gt;</span>
76 <a name="l00032"></a>00032 <span class="preprocessor">#include &lt;QFont&gt;</span>
77 <a name="l00033"></a>00033 <span class="preprocessor">#include &lt;cstdlib&gt;</span>
78 <a name="l00034"></a>00034 <span class="preprocessor">#include &lt;QMouseEvent&gt;</span>
79 <a name="l00035"></a>00035 <span class="preprocessor">#include &lt;QToolButton&gt;</span>
80 <a name="l00036"></a>00036 <span class="preprocessor">#include &lt;QSize&gt;</span>
81 <a name="l00037"></a>00037 <span class="preprocessor">#include &lt;QWidget&gt;</span>
82 <a name="l00038"></a>00038 
83 <a name="l00039"></a><a class="code" href="class_clocks_widget.html#aa279b067c41def73aeaf62af3b486079">00039</a> <a class="code" href="class_clocks_widget.html#aa279b067c41def73aeaf62af3b486079">ClocksWidget::ClocksWidget</a>(<a class="code" href="class_chess_clock.html" title="Clock of a individual player.">ChessClock</a> *white, <a class="code" href="class_chess_clock.html" title="Clock of a individual player.">ChessClock</a> *black, QWidget *parent):
84 <a name="l00040"></a>00040     QWidget(parent)
85 <a name="l00041"></a>00041 {
86 <a name="l00042"></a>00042     <span class="comment">// Set up clocks</span>
87 <a name="l00043"></a>00043     <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a> = white;
88 <a name="l00044"></a>00044     <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a> = black;
89 <a name="l00045"></a>00045 
90 <a name="l00046"></a>00046     <span class="comment">// SET UP UI</span>
91 <a name="l00047"></a>00047     <span class="comment">// Make layout for clocks</span>
92 <a name="l00048"></a>00048     QHBoxLayout* clockLayout = <span class="keyword">new</span> QHBoxLayout;
93 <a name="l00049"></a>00049     clockLayout-&gt;addWidget(<a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a> );
94 <a name="l00050"></a>00050     clockLayout-&gt;addWidget( <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a> );
95 <a name="l00051"></a>00051 
96 <a name="l00052"></a>00052     <span class="comment">// Pause information label</span>
97 <a name="l00053"></a>00053     <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a> = <span class="keyword">new</span> QLabel( tr(<span class="stringliteral">&quot;&lt;font color=yellow&gt;Paused. Touch to continue.&lt;/font&gt;&quot;</span>),<span class="keyword">this</span>);
98 <a name="l00054"></a>00054     <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;setFont( QFont(<span class="stringliteral">&quot;Helvetica&quot;</span>,25));
99 <a name="l00055"></a>00055     <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;setAlignment( Qt::AlignCenter);
100 <a name="l00056"></a>00056     <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;setVisible( <span class="keyword">false</span> );
101 <a name="l00057"></a>00057 
102 <a name="l00058"></a>00058     <span class="comment">// Welcome label for first touch</span>
103 <a name="l00059"></a>00059     <a class="code" href="class_clocks_widget.html#a0af8f4235b2b5363173b067cfb54a73b">welcomeLabel_</a> = <span class="keyword">new</span> QLabel( tr(<span class="stringliteral">&quot;&lt;font color=green&gt;Welcome! Please touch to start game.&lt;br&gt;&quot;</span>
104 <a name="l00060"></a>00060                                    <span class="stringliteral">&quot;Then touch to end turn.&lt;/font&gt;&quot;</span>),<span class="keyword">this</span>);
105 <a name="l00061"></a>00061     <a class="code" href="class_clocks_widget.html#a0af8f4235b2b5363173b067cfb54a73b">welcomeLabel_</a>-&gt;setFont( QFont(<span class="stringliteral">&quot;Helvetica&quot;</span>,25));
106 <a name="l00062"></a>00062     <a class="code" href="class_clocks_widget.html#a0af8f4235b2b5363173b067cfb54a73b">welcomeLabel_</a>-&gt;setAlignment( Qt::AlignCenter);
107 <a name="l00063"></a>00063     <a class="code" href="class_clocks_widget.html#a0af8f4235b2b5363173b067cfb54a73b">welcomeLabel_</a>-&gt;setVisible( <span class="keyword">true</span> );  <span class="comment">// Show welcome message</span>
108 <a name="l00064"></a>00064 
109 <a name="l00065"></a>00065     <span class="comment">// Pause button</span>
110 <a name="l00066"></a>00066     <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a> = <span class="keyword">new</span> QToolButton;
111 <a name="l00067"></a>00067     <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setIcon( QIcon(<span class="stringliteral">&quot;:/rc/pic/pausebutton.png&quot;</span>));
112 <a name="l00068"></a>00068     <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setIconSize(QSize(75,75));
113 <a name="l00069"></a>00069     connect(<a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>, SIGNAL(clicked()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_clocks_widget.html#a609a11fc15904a1700f5b82ae2b63228" title="Pause game.">pause</a>()));
114 <a name="l00070"></a>00070     <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setVisible(<span class="keyword">false</span>);
115 <a name="l00071"></a>00071 
116 <a name="l00072"></a>00072     <span class="comment">// Put all in layout</span>
117 <a name="l00073"></a>00073     QVBoxLayout* mainLayout = <span class="keyword">new</span> QVBoxLayout;
118 <a name="l00074"></a>00074     mainLayout-&gt;addLayout(clockLayout);
119 <a name="l00075"></a>00075 
120 <a name="l00076"></a>00076     <span class="comment">// Extra layout and widget for information</span>
121 <a name="l00077"></a>00077     QVBoxLayout* extraLayout = <span class="keyword">new</span> QVBoxLayout;
122 <a name="l00078"></a>00078     extraLayout-&gt;addWidget(<a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>);
123 <a name="l00079"></a>00079     extraLayout-&gt;addWidget(<a class="code" href="class_clocks_widget.html#a0af8f4235b2b5363173b067cfb54a73b">welcomeLabel_</a>);
124 <a name="l00080"></a>00080 
125 <a name="l00081"></a>00081     QHBoxLayout* pbLayout = <span class="keyword">new</span> QHBoxLayout;
126 <a name="l00082"></a>00082     pbLayout-&gt;addStretch();
127 <a name="l00083"></a>00083     pbLayout-&gt;addWidget(<a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>);
128 <a name="l00084"></a>00084     pbLayout-&gt;addStretch();
129 <a name="l00085"></a>00085     extraLayout-&gt;addLayout(pbLayout);
130 <a name="l00086"></a>00086 
131 <a name="l00087"></a>00087     QWidget* extraWidget = <span class="keyword">new</span> QWidget(<span class="keyword">this</span>);
132 <a name="l00088"></a>00088     extraWidget-&gt;setLayout(extraLayout);
133 <a name="l00089"></a>00089     <span class="comment">// Some fun event filtering to grap clicking welcome and pause labels...</span>
134 <a name="l00090"></a>00090     extraWidget-&gt;installEventFilter(<span class="keyword">this</span>);
135 <a name="l00091"></a>00091     <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;installEventFilter(<span class="keyword">this</span>);
136 <a name="l00092"></a>00092     <a class="code" href="class_clocks_widget.html#a0af8f4235b2b5363173b067cfb54a73b">welcomeLabel_</a>-&gt;installEventFilter(<span class="keyword">this</span>);
137 <a name="l00093"></a>00093 
138 <a name="l00094"></a>00094     mainLayout-&gt;addWidget(extraWidget);
139 <a name="l00095"></a>00095     setLayout( mainLayout);
140 <a name="l00096"></a>00096     <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> = <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a6aef315e9e32ab9962b237bd3ddab0ab">Welcome</a>;
141 <a name="l00097"></a>00097 
142 <a name="l00098"></a>00098     <span class="comment">// First paint</span>
143 <a name="l00099"></a>00099     <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#a349c7c108551649a9885651c5470e2dd" title="Refresh clock information.">repaintClock</a>();
144 <a name="l00100"></a>00100     <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>-&gt;<a class="code" href="class_chess_clock.html#a349c7c108551649a9885651c5470e2dd" title="Refresh clock information.">repaintClock</a>();
145 <a name="l00101"></a>00101 
146 <a name="l00102"></a>00102     <span class="comment">// Set up others</span>
147 <a name="l00103"></a>00103     <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#aa19330404a35872591d45d24fb52572e" title="Set another chess clock for connecting.">setAnother</a>(<a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>);
148 <a name="l00104"></a>00104     <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>-&gt;<a class="code" href="class_chess_clock.html#aa19330404a35872591d45d24fb52572e" title="Set another chess clock for connecting.">setAnother</a>(<a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>);
149 <a name="l00105"></a>00105 
150 <a name="l00106"></a>00106     <a class="code" href="class_clocks_widget.html#ab86d99a5709a6fd0444f10aec5ede01a">delayTimer_</a>.start(); <span class="comment">// Initial start</span>
151 <a name="l00107"></a>00107 
152 <a name="l00108"></a>00108     <a class="code" href="class_clocks_widget.html#a5ea90a0fddcda7d4d2fcc0ba41b0d315" title="To avoid double clicks.">recentX</a> = <a class="code" href="class_clocks_widget.html#ab95b8bc6920bcb45f81f8f04a494df25">recentY</a> = -1;
153 <a name="l00109"></a>00109 
154 <a name="l00110"></a>00110     <span class="comment">// ScreenLitKeeper to keep screen lit when playing</span>
155 <a name="l00111"></a>00111     <a class="code" href="class_clocks_widget.html#a6816c555a8d407402e753f2e7466ed60">keeper_</a> = <span class="keyword">new</span> <a class="code" href="class_screen_lit_keeper.html" title="Allows keeping the sreen lit by disabling the screensaver.">ScreenLitKeeper</a>(<span class="keyword">this</span>);
156 <a name="l00112"></a>00112 }
157 <a name="l00113"></a>00113 
158 <a name="l00114"></a><a class="code" href="class_clocks_widget.html#ad57363f5d471bff742d422f19f3077c3">00114</a> <a class="code" href="class_clocks_widget.html#ad57363f5d471bff742d422f19f3077c3">ClocksWidget::~ClocksWidget</a>()
159 <a name="l00115"></a>00115 {
160 <a name="l00116"></a>00116     <span class="keyword">delete</span> <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>;
161 <a name="l00117"></a>00117     <span class="keyword">delete</span> <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>;
162 <a name="l00118"></a>00118 }
163 <a name="l00119"></a>00119 
164 <a name="l00120"></a><a class="code" href="class_clocks_widget.html#a609a11fc15904a1700f5b82ae2b63228">00120</a> <span class="keywordtype">void</span> <a class="code" href="class_clocks_widget.html#a609a11fc15904a1700f5b82ae2b63228" title="Pause game.">ClocksWidget::pause</a>()
165 <a name="l00121"></a>00121 {
166 <a name="l00122"></a>00122     <span class="keywordflow">if</span>(<a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> == <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ae515f8820df31a265e7a09b885367021">WhiteTurn</a>)
167 <a name="l00123"></a>00123     {
168 <a name="l00124"></a>00124         <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a>= <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326af5c73b5ef2a4289e4c72e37d9524aad3">WhitePause</a>;
169 <a name="l00125"></a>00125         <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#a461145515ab3854c079937143026a047" title="Pause clock.">pauseTurn</a>();
170 <a name="l00126"></a>00126         <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;setVisible(<span class="keyword">true</span>);
171 <a name="l00127"></a>00127         <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setVisible(<span class="keyword">false</span>);
172 <a name="l00128"></a>00128         <a class="code" href="class_clocks_widget.html#a6816c555a8d407402e753f2e7466ed60">keeper_</a>-&gt;<a class="code" href="class_screen_lit_keeper.html#a41cc193e58d9b4b5c09eda79bbb095c8" title="Sets whether the screen is to be kept lit.">keepScreenLit</a>(<span class="keyword">false</span>);
173 <a name="l00129"></a>00129 
174 <a name="l00130"></a>00130     }
175 <a name="l00131"></a>00131     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> == <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a54e428aae4bef65f8a66e7619778c190">BlackTurn</a>)
176 <a name="l00132"></a>00132     {
177 <a name="l00133"></a>00133         <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> = <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ac176eeb3fa09dc34152e89c97155806a">BlackPause</a>;
178 <a name="l00134"></a>00134         <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>-&gt;<a class="code" href="class_chess_clock.html#a461145515ab3854c079937143026a047" title="Pause clock.">pauseTurn</a>();
179 <a name="l00135"></a>00135         <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;setVisible(<span class="keyword">true</span>);
180 <a name="l00136"></a>00136         <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setVisible(<span class="keyword">false</span>);
181 <a name="l00137"></a>00137         <a class="code" href="class_clocks_widget.html#a6816c555a8d407402e753f2e7466ed60">keeper_</a>-&gt;<a class="code" href="class_screen_lit_keeper.html#a41cc193e58d9b4b5c09eda79bbb095c8" title="Sets whether the screen is to be kept lit.">keepScreenLit</a>(<span class="keyword">false</span>);
182 <a name="l00138"></a>00138     }
183 <a name="l00139"></a>00139 }
184 <a name="l00140"></a>00140 
185 <a name="l00141"></a><a class="code" href="class_clocks_widget.html#a13cdf39b9f06ef714a65aaff2111380d">00141</a> <span class="keywordtype">void</span> <a class="code" href="class_clocks_widget.html#a13cdf39b9f06ef714a65aaff2111380d" title="End the game.">ClocksWidget::stopPlay</a>()
186 <a name="l00142"></a>00142 {
187 <a name="l00143"></a>00143     <span class="keywordflow">if</span>( <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> == <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a54e428aae4bef65f8a66e7619778c190">BlackTurn</a> || <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> == <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ac176eeb3fa09dc34152e89c97155806a">BlackPause</a> )
188 <a name="l00144"></a>00144        emit <a class="code" href="class_clocks_widget.html#a59d64c0755ff2e19c851108472d48865">TurnFinished</a>( <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>-&gt;<a class="code" href="class_chess_clock.html#a2383619532d2e9e6557961616c722531" title="End this turn.">endTurn</a>());
189 <a name="l00145"></a>00145     <span class="keywordflow">else</span> <span class="keywordflow">if</span>( <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> == <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ae515f8820df31a265e7a09b885367021">WhiteTurn</a> || <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> == <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326af5c73b5ef2a4289e4c72e37d9524aad3">WhitePause</a> )
190 <a name="l00146"></a>00146         emit <a class="code" href="class_clocks_widget.html#a59d64c0755ff2e19c851108472d48865">TurnFinished</a>( <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#a2383619532d2e9e6557961616c722531" title="End this turn.">endTurn</a>());
191 <a name="l00147"></a>00147     <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> = <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a53acf9aec5f412ddac980ff0019b6062" title="Not running.">Stopped</a>;
192 <a name="l00148"></a>00148 }
193 <a name="l00149"></a>00149 
194 <a name="l00150"></a>00150 
195 <a name="l00151"></a><a class="code" href="class_clocks_widget.html#a1a000c1a617951942ee3b1669a2b026e">00151</a> <span class="keywordtype">void</span> <a class="code" href="class_clocks_widget.html#a1a000c1a617951942ee3b1669a2b026e">ClocksWidget::mouseReleaseEvent</a>(QMouseEvent *event)
196 <a name="l00152"></a>00152 {
197 <a name="l00153"></a>00153 
198 <a name="l00154"></a>00154     <span class="comment">// To avoid double clicks</span>
199 <a name="l00155"></a>00155     <span class="comment">// a) delay (default 1,2 secs) OR</span>
200 <a name="l00156"></a>00156     <span class="comment">// b) distance more than 90 pixels in axis.</span>
201 <a name="l00157"></a>00157     <span class="keywordflow">if</span>( <a class="code" href="class_clocks_widget.html#ab86d99a5709a6fd0444f10aec5ede01a">delayTimer_</a>.elapsed() &gt; <a class="code" href="class_clocks_widget.html#a51af7bacc14bc1f276df31a404823e3d">CLICKDELAY</a> ||
202 <a name="l00158"></a>00158         std::abs( event-&gt;x() - <a class="code" href="class_clocks_widget.html#a5ea90a0fddcda7d4d2fcc0ba41b0d315" title="To avoid double clicks.">recentX</a> ) &gt; 90 ||
203 <a name="l00159"></a>00159         std::abs( event-&gt;y() - <a class="code" href="class_clocks_widget.html#ab95b8bc6920bcb45f81f8f04a494df25">recentY</a> ) &gt; 90
204 <a name="l00160"></a>00160         )
205 <a name="l00161"></a>00161     {
206 <a name="l00162"></a>00162         <a class="code" href="class_clocks_widget.html#ab86d99a5709a6fd0444f10aec5ede01a">delayTimer_</a>.start();    <span class="comment">// to reset delay timer!</span>
207 <a name="l00163"></a>00163         <span class="keywordflow">switch</span>( <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a>)
208 <a name="l00164"></a>00164         {
209 <a name="l00165"></a>00165         <span class="keywordflow">case</span> <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a6aef315e9e32ab9962b237bd3ddab0ab">Welcome</a> :
210 <a name="l00166"></a>00166             <span class="comment">// Start game!</span>
211 <a name="l00167"></a>00167             <a class="code" href="class_clocks_widget.html#a0af8f4235b2b5363173b067cfb54a73b">welcomeLabel_</a>-&gt;setVisible(<span class="keyword">false</span>);
212 <a name="l00168"></a>00168             <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setVisible(<span class="keyword">true</span>);
213 <a name="l00169"></a>00169             <a class="code" href="class_clocks_widget.html#a6816c555a8d407402e753f2e7466ed60">keeper_</a>-&gt;<a class="code" href="class_screen_lit_keeper.html#a41cc193e58d9b4b5c09eda79bbb095c8" title="Sets whether the screen is to be kept lit.">keepScreenLit</a>(<span class="keyword">true</span>);
214 <a name="l00170"></a>00170             <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#a49504d86896ef3f724b2aa481c85435a" title="Start new turn.">startTurn</a>();
215 <a name="l00171"></a>00171             <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a> = <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ae515f8820df31a265e7a09b885367021">WhiteTurn</a>;
216 <a name="l00172"></a>00172             <span class="keywordflow">break</span>;
217 <a name="l00173"></a>00173         <span class="keywordflow">case</span> <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ae515f8820df31a265e7a09b885367021">WhiteTurn</a>:
218 <a name="l00174"></a>00174             <span class="comment">// White turn finished, then black</span>
219 <a name="l00175"></a>00175             emit <a class="code" href="class_clocks_widget.html#a59d64c0755ff2e19c851108472d48865">TurnFinished</a>( <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#a2383619532d2e9e6557961616c722531" title="End this turn.">endTurn</a>());
220 <a name="l00176"></a>00176             <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>-&gt;<a class="code" href="class_chess_clock.html#a49504d86896ef3f724b2aa481c85435a" title="Start new turn.">startTurn</a>();
221 <a name="l00177"></a>00177             <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a>=<a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a54e428aae4bef65f8a66e7619778c190">BlackTurn</a>;
222 <a name="l00178"></a>00178             <span class="keywordflow">break</span>;
223 <a name="l00179"></a>00179         <span class="keywordflow">case</span> <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a54e428aae4bef65f8a66e7619778c190">BlackTurn</a>:
224 <a name="l00180"></a>00180             <span class="comment">// Black finished, then white</span>
225 <a name="l00181"></a>00181             emit <a class="code" href="class_clocks_widget.html#a59d64c0755ff2e19c851108472d48865">TurnFinished</a>( <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>-&gt;<a class="code" href="class_chess_clock.html#a2383619532d2e9e6557961616c722531" title="End this turn.">endTurn</a>());
226 <a name="l00182"></a>00182             <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#a49504d86896ef3f724b2aa481c85435a" title="Start new turn.">startTurn</a>();
227 <a name="l00183"></a>00183             <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a>=<a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ae515f8820df31a265e7a09b885367021">WhiteTurn</a>;
228 <a name="l00184"></a>00184             <span class="keywordflow">break</span>;
229 <a name="l00185"></a>00185         <span class="keywordflow">case</span> <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326af5c73b5ef2a4289e4c72e37d9524aad3">WhitePause</a>:
230 <a name="l00186"></a>00186             <span class="comment">// Continue play</span>
231 <a name="l00187"></a>00187             <a class="code" href="class_clocks_widget.html#a6816c555a8d407402e753f2e7466ed60">keeper_</a>-&gt;<a class="code" href="class_screen_lit_keeper.html#a41cc193e58d9b4b5c09eda79bbb095c8" title="Sets whether the screen is to be kept lit.">keepScreenLit</a>(<span class="keyword">true</span>);
232 <a name="l00188"></a>00188             <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;setVisible(<span class="keyword">false</span>);
233 <a name="l00189"></a>00189             <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setVisible(<span class="keyword">true</span>);
234 <a name="l00190"></a>00190             <a class="code" href="class_clocks_widget.html#a657afdf1f48be188451ebd712350cdc3">white_</a>-&gt;<a class="code" href="class_chess_clock.html#ae0686cb1be507be4c7c411898ba52495" title="Continue paused game.">continueTurn</a>();
235 <a name="l00191"></a>00191             <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a>=<a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ae515f8820df31a265e7a09b885367021">WhiteTurn</a>;
236 <a name="l00192"></a>00192             <span class="keywordflow">break</span>;
237 <a name="l00193"></a>00193         <span class="keywordflow">case</span> <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326ac176eeb3fa09dc34152e89c97155806a">BlackPause</a>:
238 <a name="l00194"></a>00194             <span class="comment">// Continue play</span>
239 <a name="l00195"></a>00195             <a class="code" href="class_clocks_widget.html#a6816c555a8d407402e753f2e7466ed60">keeper_</a>-&gt;<a class="code" href="class_screen_lit_keeper.html#a41cc193e58d9b4b5c09eda79bbb095c8" title="Sets whether the screen is to be kept lit.">keepScreenLit</a>(<span class="keyword">false</span>);
240 <a name="l00196"></a>00196             <a class="code" href="class_clocks_widget.html#a2e65f80ea1b3d56189f8c94d6b0a972c">pauseLabel_</a>-&gt;setVisible(<span class="keyword">false</span>);
241 <a name="l00197"></a>00197             <a class="code" href="class_clocks_widget.html#ac260495699eda4c14abd77978bcc146c">pauseButton_</a>-&gt;setVisible(<span class="keyword">true</span>);
242 <a name="l00198"></a>00198             <a class="code" href="class_clocks_widget.html#a61a8a254c9a879b0950cde008a825447">black_</a>-&gt;<a class="code" href="class_chess_clock.html#ae0686cb1be507be4c7c411898ba52495" title="Continue paused game.">continueTurn</a>();
243 <a name="l00199"></a>00199             <a class="code" href="class_clocks_widget.html#a74cd72e41c4c797c4b97027f513752c4">status_</a>=<a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a54e428aae4bef65f8a66e7619778c190">BlackTurn</a>;
244 <a name="l00200"></a>00200             <span class="keywordflow">break</span>;
245 <a name="l00201"></a>00201         <span class="keywordflow">case</span> <a class="code" href="class_clocks_widget.html#abe19ddcf3d29ca31914819a969af4326a53acf9aec5f412ddac980ff0019b6062" title="Not running.">Stopped</a>:
246 <a name="l00202"></a>00202             emit <a class="code" href="class_clocks_widget.html#ab5e341e33db43c93cb4fdb1dc59b1a62">ClickedWhenStopped</a>();
247 <a name="l00203"></a>00203 
248 <a name="l00204"></a>00204 
249 <a name="l00205"></a>00205         }
250 <a name="l00206"></a>00206     }
251 <a name="l00207"></a>00207     <a class="code" href="class_clocks_widget.html#a5ea90a0fddcda7d4d2fcc0ba41b0d315" title="To avoid double clicks.">recentX</a> = <span class="keyword">event</span>-&gt;x();
252 <a name="l00208"></a>00208     <a class="code" href="class_clocks_widget.html#ab95b8bc6920bcb45f81f8f04a494df25">recentY</a> = <span class="keyword">event</span>-&gt;y();
253 <a name="l00209"></a>00209 }
254 <a name="l00210"></a>00210 
255 <a name="l00211"></a>00211 <span class="comment">// to grap clicking pause or welcome label</span>
256 <a name="l00212"></a><a class="code" href="class_clocks_widget.html#a00be7b731e6ef45d411f236b257d9503">00212</a> <span class="keywordtype">bool</span> <a class="code" href="class_clocks_widget.html#a00be7b731e6ef45d411f236b257d9503">ClocksWidget::eventFilter</a>(QObject *obj, QEvent *event)
257 <a name="l00213"></a>00213 {
258 <a name="l00214"></a>00214     <span class="keywordflow">if</span> (event-&gt;type() == QEvent::MouseButtonRelease) {
259 <a name="l00215"></a>00215         QMouseEvent *mEvent = <span class="keyword">static_cast&lt;</span>QMouseEvent *<span class="keyword">&gt;</span>(event);
260 <a name="l00216"></a>00216         <a class="code" href="class_clocks_widget.html#a1a000c1a617951942ee3b1669a2b026e">mouseReleaseEvent</a>( mEvent );
261 <a name="l00217"></a>00217         <span class="keywordflow">return</span> <span class="keyword">true</span>;
262 <a name="l00218"></a>00218     } <span class="keywordflow">else</span> {
263 <a name="l00219"></a>00219         <span class="comment">// standard event processing</span>
264 <a name="l00220"></a>00220         <span class="keywordflow">return</span> <a class="code" href="class_clocks_widget.html#a00be7b731e6ef45d411f236b257d9503">QObject::eventFilter</a>(obj, event);
265 <a name="l00221"></a>00221     }
266 <a name="l00222"></a>00222 }
267 <a name="l00223"></a>00223 
268 <a name="l00224"></a>00224 
269 <a name="l00225"></a>00225 <span class="keywordtype">int</span> <span class="keyword">const</span> <a class="code" href="class_clocks_widget.html#a51af7bacc14bc1f276df31a404823e3d">ClocksWidget::CLICKDELAY</a>;
270 </pre></div></div>
271 <!--- window showing the filter options -->
272 <div id="MSearchSelectWindow"
273      onmouseover="return searchBox.OnSearchSelectShow()"
274      onmouseout="return searchBox.OnSearchSelectHide()"
275      onkeydown="return searchBox.OnSearchSelectKey(event)">
276 <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Enumerator</a></div>
277
278 <!-- iframe showing the search results (closed by default) -->
279 <div id="MSearchResultsWindow">
280 <iframe src="" frameborder="0" 
281         name="MSearchResults" id="MSearchResults">
282 </iframe>
283 </div>
284
285 <hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Sep 27 18:30:33 2010 for Chess Clock by&nbsp;
286 <a href="http://www.doxygen.org/index.html">
287 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
288 </body>
289 </html>