📄 wg__frame_8cpp-source.html
字号:
<a name="l00135"></a><a class="code" href="classwGui_1_1CFrame.html#a11">00135</a> <span class="keywordtype">void</span> CFrame::SetWindowText(<span class="keyword">const</span> std::string& sWindowText)00136 {00137 CWindow::SetWindowText(sWindowText);00138 std::auto_ptr<CRenderedString> pRenderedString(<span class="keyword">new</span> <a class="code" href="classwGui_1_1CRenderedString.html">CRenderedString</a>(<a class="code" href="classwGui_1_1CFrame.html#n4">m_pFontEngine</a>, sWindowText, CRenderedString::VALIGN_CENTER));00139 <a class="code" href="classwGui_1_1CFrame.html#n5">m_pRenderedString</a> = pRenderedString;00140 <a class="code" href="classwGui_1_1CWindow.html#a23">StartDrawProc</a>();00141 }00142 00143 <a name="l00144"></a><a class="code" href="classwGui_1_1CFrame.html#a12">00144</a> <span class="keywordtype">bool</span> CFrame::OnMouseButtonDown(<a class="code" href="classwGui_1_1CPoint.html">CPoint</a> Point, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Button)00145 {00146 <span class="keywordtype">bool</span> bResult = <span class="keyword">false</span>;00147 00148 <span class="keywordflow">if</span> (! CWindow::OnMouseButtonDown(Point, Button) && <a class="code" href="classwGui_1_1CWindow.html#n7">m_bVisible</a> && (<a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a32">HitTest</a>(Point) == CRect::RELPOS_INSIDE))00149 {00150 <span class="keywordflow">if</span> (m_TitleBarRect.<a class="code" href="classwGui_1_1CRect.html#a32">HitTest</a>(Point) == CRect::RELPOS_INSIDE)00151 {00152 m_bDragMode = <span class="keyword">true</span>;00153 m_DragPointerStart = Point;00154 }00155 <a class="code" href="classwGui_1_1CWindow.html#a24">SetNewParent</a>(<a class="code" href="classwGui_1_1CWindow.html#n4">m_pParentWindow</a>); <span class="comment">// This moves the window to the top</span>00156 bResult = <span class="keyword">true</span>;00157 }00158 00159 <span class="keywordflow">return</span> bResult;00160 }00161 00162 <a name="l00163"></a><a class="code" href="classwGui_1_1CFrame.html#a13">00163</a> <span class="keywordtype">bool</span> CFrame::HandleMessage(<a class="code" href="classwGui_1_1CMessage.html">CMessage</a>* pMessage)00164 {00165 <span class="keywordtype">bool</span> bHandled = <span class="keyword">false</span>;00166 00167 <span class="keywordflow">if</span> (pMessage)00168 {00169 <span class="keywordflow">switch</span>(pMessage-><a class="code" href="classwGui_1_1CMessage.html#a2">MessageType</a>())00170 {00171 <span class="keywordflow">case</span> CMessage::MOUSE_BUTTONUP:00172 {00173 <a class="code" href="classwGui_1_1CMouseMessage.html">CMouseMessage</a>* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);00174 <span class="keywordflow">if</span> (pMouseMessage && m_bDragMode)00175 {00176 m_bDragMode = <span class="keyword">false</span>;00177 <a class="code" href="classwGui_1_1CPoint.html">CPoint</a> MoveDistance = pMouseMessage-><a class="code" href="classwGui_1_1CMouseMessage.html#m0">Point</a> - m_DragPointerStart;00178 <a class="code" href="classwGui_1_1CRect.html">CRect</a> Bounds = <a class="code" href="classwGui_1_1CWindow.html#n4">m_pParentWindow</a>-><a class="code" href="classwGui_1_1CWindow.html#a5">GetClientRect</a>();00179 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>() + MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a6">XPos</a>() > Bounds.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>())00180 {00181 MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a4">SetX</a>(Bounds.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>() - <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>());00182 }00183 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a10">Left</a>() + MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a6">XPos</a>() < Bounds.<a class="code" href="classwGui_1_1CRect.html#a10">Left</a>())00184 {00185 MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a4">SetX</a>(Bounds.<a class="code" href="classwGui_1_1CRect.html#a10">Left</a>() - <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a10">Left</a>());00186 }00187 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a12">Bottom</a>() + MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a7">YPos</a>() > Bounds.<a class="code" href="classwGui_1_1CRect.html#a12">Bottom</a>())00188 {00189 MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a5">SetY</a>(Bounds.<a class="code" href="classwGui_1_1CRect.html#a12">Bottom</a>() - <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a12">Bottom</a>());00190 }00191 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>() + MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a7">YPos</a>() < Bounds.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>())00192 {00193 MoveDistance.<a class="code" href="classwGui_1_1CPoint.html#a5">SetY</a>(Bounds.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>() - <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>());00194 }00195 <a class="code" href="classwGui_1_1CFrame.html#a10">MoveWindow</a>(MoveDistance);00196 <span class="keywordflow">if</span> (m_pSavedSurface)00197 {00198 SDL_Rect SourceRect = m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a22">SDLRect</a>();00199 SourceRect.x = 0;00200 SourceRect.y = 0;00201 SDL_Rect DestRect = m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a22">SDLRect</a>();00202 SDL_BlitSurface(m_pSavedSurface, &SourceRect, <a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a>, &DestRect);00203 SDL_FreeSurface(m_pSavedSurface);00204 m_pSavedSurface = 0;00205 }00206 CMessageServer::Instance().QueueMessage(<span class="keyword">new</span> <a class="code" href="classwGui_1_1CMessage.html">CMessage</a>(CMessage::APP_PAINT, 0, <span class="keyword">this</span>));00207 bHandled = <span class="keyword">true</span>;00208 }00209 <span class="keywordflow">break</span>;00210 }00211 <span class="keywordflow">case</span> CMessage::MOUSE_MOVE:00212 {00213 <a class="code" href="classwGui_1_1CMouseMessage.html">CMouseMessage</a>* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);00214 <span class="keywordflow">if</span> (pMouseMessage && m_bDragMode)00215 {00216 <span class="keywordflow">if</span> (m_pSavedSurface)00217 {00218 SDL_Rect SourceRect = m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a22">SDLRect</a>();00219 SourceRect.x = 0;00220 SourceRect.y = 0;00221 SDL_Rect DestRect = m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a22">SDLRect</a>();00222 SDL_BlitSurface(m_pSavedSurface, &SourceRect, <a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a>, &DestRect);00223 SDL_UpdateRect(<a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a>, m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a10">Left</a>(), m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>(), m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a23">Width</a>(), m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a24">Height</a>());00224 }00225 <span class="keywordflow">else</span>00226 {00227 m_pSavedSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a23">Width</a>(), <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a24">Height</a>(), 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);00228 }00229 m_SavedSurfaceRect = <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a> + pMouseMessage-><a class="code" href="classwGui_1_1CMouseMessage.html#m0">Point</a> - m_DragPointerStart;00230 SDL_Rect DestRect = m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a22">SDLRect</a>();00231 DestRect.x = 0;00232 DestRect.y = 0;00233 SDL_Rect SourceRect = m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a22">SDLRect</a>();00234 SDL_BlitSurface(<a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a>, &SourceRect, m_pSavedSurface, &DestRect);00235 00236 <a class="code" href="classwGui_1_1CPainter.html">CPainter</a> Painter(<a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a>);00237 Painter.<a class="code" href="classwGui_1_1CPainter.html#a5">DrawRect</a>(m_SavedSurfaceRect, <span class="keyword">false</span>, COLOR_LIGHTGRAY);00238 00239 SDL_UpdateRect(<a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a>, m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a10">Left</a>(), m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>(), m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a23">Width</a>(), m_SavedSurfaceRect.<a class="code" href="classwGui_1_1CRect.html#a24">Height</a>());00240 }00241 <span class="keywordflow">break</span>;00242 }00243 <span class="keywordflow">case</span> CMessage::CTRL_LCLICK:00244 {00245 <span class="keywordflow">if</span> (pMessage-><a class="code" href="classwGui_1_1CMessage.html#a3">Destination</a>() == <span class="keyword">this</span>)00246 {00247 <span class="keywordflow">if</span> (pMessage-><a class="code" href="classwGui_1_1CMessage.html#a4">Source</a>() == <a class="code" href="classwGui_1_1CFrame.html#n0">m_pFrameCloseButton</a>)00248 {00249 <span class="comment">// suicide the frame by detaching it from it's parent, queing up an APP_PAINT message, then deleting itself</span>00250 <a class="code" href="classwGui_1_1CWindow.html#a24">SetNewParent</a>(0);00251 CMessageServer::Instance().QueueMessage(<span class="keyword">new</span> <a class="code" href="classwGui_1_1CMessage.html">CMessage</a>(CMessage::APP_PAINT, 0, <span class="keyword">this</span>));00252 <span class="keyword">delete</span> <span class="keyword">this</span>;00253 bHandled = <span class="keyword">true</span>;00254 }00255 }00256 <span class="keywordflow">break</span>;00257 }00258 <span class="keywordflow">default</span> :00259 bHandled = CWindow::HandleMessage(pMessage);00260 <span class="keywordflow">break</span>;00261 }00262 }00263 00264 <span class="keywordflow">return</span> bHandled;00265 }00266 00267 }00268 </pre></div><hr><address style="align: right;"><small>Generated on Sat Oct 25 12:43:23 2003 for wGui by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -