📄 wg__editbox_8cpp-source.html
字号:
00434 <span class="keywordflow">if</span> (static_cast<unsigned int>(m_SelStart) <= sBuffer.length())00435 {00436 <span class="keywordflow">if</span> (pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m1">Modifiers</a> & KMOD_SHIFT)00437 {00438 <span class="keywordflow">if</span> (pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m1">Modifiers</a> & KMOD_CTRL)00439 {00440 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pos = static_cast<unsigned int>(sBuffer.find(<span class="stringliteral">" "</span>, <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> + <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a>));00441 <span class="keywordflow">if</span> (pos != std::string::npos)00442 {00443 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = (pos - <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>) + 1;00444 }00445 <span class="keywordflow">else</span>00446 {00447 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = static_cast<int>(sBuffer.length()) - <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>;00448 }00449 }00450 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> + <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> < sBuffer.length())00451 {00452 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a>++; <span class="comment">//Selecting, one character at a time, increase the selection length by one.</span>00453 }00454 }00455 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> == 0 && static_cast<unsigned int>(m_SelStart) < sBuffer.length())00456 {00457 <span class="comment">//With the ctrl modifier used, we look for the next instance of a space.</span>00458 <span class="comment">// If we find one, we set the cursor position to that location.</span>00459 <span class="comment">// If we can't find one, we set the cursor position to the end of the string.</span>00460 <span class="comment">// If we don't have the ctrl modifier, then we just incriment the cursor position by one character</span>00461 <span class="keywordflow">if</span> (pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m1">Modifiers</a> & KMOD_CTRL)00462 {00463 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pos = static_cast<unsigned int>(sBuffer.find(<span class="stringliteral">" "</span>, <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> + 1));00464 <span class="keywordflow">if</span> (pos != std::string::npos)00465 {00466 <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> = pos + 1;00467 }00468 <span class="keywordflow">else</span>00469 {00470 <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> = static_cast<unsigned int>(sBuffer.length());00471 }00472 }00473 <span class="keywordflow">else</span>00474 {00475 ++<a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>; <span class="comment">//We don't have anything selected, so we'll just incriment the start position</span>00476 }00477 }00478 <span class="keywordflow">else</span>00479 {00480 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> > 0)00481 {00482 <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> = <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> + <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a>; <span class="comment">//Reset cursor position to the end of the selection</span>00483 }00484 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = 0; <span class="comment">//Set selection length to zero</span>00485 }00486 }00487 <span class="keywordflow">break</span>;00488 <span class="keywordflow">case</span> SDLK_END:00489 <span class="keywordflow">if</span> (pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m1">Modifiers</a> & KMOD_SHIFT)00490 {00491 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = static_cast<unsigned int>(sBuffer.length()) - <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>;00492 }00493 <span class="keywordflow">else</span>00494 {00495 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = 0;00496 <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> = static_cast<unsigned int>(sBuffer.length());00497 }00498 <span class="keywordflow">break</span>;00499 <span class="keywordflow">case</span> SDLK_HOME:00500 <span class="keywordflow">if</span> (pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m1">Modifiers</a> & KMOD_SHIFT)00501 {00502 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>;00503 <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> = 0;00504 }00505 <span class="keywordflow">else</span>00506 {00507 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = 0;00508 <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a> = 0;00509 }00510 <span class="keywordflow">break</span>;00511 <span class="keywordflow">default</span>:00512 <span class="keywordflow">if</span> (pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m3">Unicode</a>)00513 {00514 <span class="keywordflow">if</span> ((pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m3">Unicode</a> & 0xFF80) == 0)00515 {00516 <a class="code" href="classwGui_1_1CEditBox.html#b0">SelDelete</a>(&sBuffer);00517 sBuffer.insert(<a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>++, 1, static_cast<char>(pKeyboardMessage-><a class="code" href="classwGui_1_1CKeyboardMessage.html#m3">Unicode</a> & 0x7F));00518 }00519 <span class="keywordflow">else</span>00520 {00521 Trace(<span class="stringliteral">"CEditBox::HandleMessage : CEditBox can't handle Unicode characters yet."</span>);00522 }00523 }00524 <span class="keywordflow">break</span>;00525 }00526 00527 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CWindow.html#n0">m_sWindowText</a> != sBuffer)00528 {00529 CMessageServer::Instance().QueueMessage(<span class="keyword">new</span> TStringMessage(CMessage::CTRL_VALUECHANGE, <a class="code" href="classwGui_1_1CWindow.html#n4">m_pParentWindow</a>, <span class="keyword">this</span>, sBuffer));00530 }00531 <a class="code" href="classwGui_1_1CWindow.html#n0">m_sWindowText</a> = sBuffer;00532 CWindow::SetWindowText(sBuffer);00533 00534 std::auto_ptr<CRenderedString> pRenderedString(<span class="keyword">new</span> <a class="code" href="classwGui_1_1CRenderedString.html">CRenderedString</a>(00535 <a class="code" href="classwGui_1_1CEditBox.html#n0">m_pFontEngine</a>, sBuffer, CRenderedString::VALIGN_NORMAL, CRenderedString::HALIGN_LEFT));00536 00537 <a class="code" href="classwGui_1_1CEditBox.html#n1">m_pRenderedString</a> = pRenderedString;00538 <a class="code" href="classwGui_1_1CWindow.html#a23">StartDrawProc</a>();00539 }00540 <span class="keywordflow">break</span>;00541 }00542 <span class="keywordflow">default</span> :00543 bHandled = CWindow::HandleMessage(pMessage);00544 <span class="keywordflow">break</span>;00545 }00546 }00547 00548 <span class="keywordflow">return</span> bHandled;00549 }00550 00551 <a name="l00552"></a><a class="code" href="classwGui_1_1CEditBox.html#b0">00552</a> <span class="keywordtype">void</span> CEditBox::SelDelete(std::string* psString)00553 {00554 <span class="comment">//This means we've selected something, therefore, should replace it</span>00555 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> > 0)00556 {00557 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SelStartNorm=0, SelLenNorm=0;00558 <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> < 0)00559 {00560 SelStartNorm = <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> + <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>;00561 SelLenNorm = abs(<a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a>);00562 }00563 <span class="keywordflow">else</span>00564 {00565 SelStartNorm = <a class="code" href="classwGui_1_1CEditBox.html#n3">m_SelStart</a>;00566 SelLenNorm = <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a>;00567 }00568 psString->erase(SelStartNorm, SelLenNorm);00569 <a class="code" href="classwGui_1_1CEditBox.html#n4">m_SelLength</a> = 0;00570 }00571 }00572 00573 }</pre></div><hr><address style="align: right;"><small>Generated on Sat Oct 25 12:43:22 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 + -