TVector3 StereoEnd(Double_t alpha, TVector3 CircleCenter, Double_t CircleRadius, TVector3 LineStart) { Double_t yend = CircleRadius*1.1; Double_t xend = yend*TMath::Tan(TMath::DegToRad()*alpha); TVector3 LineEnd(xend, yend, 0); TVector3 rend = LineCrossesCircle(CircleCenter, CircleRadius, LineStart, LineEnd); return rend; }
TVector3 StereoPosition(Double_t alpha, TVector3 CircleCenter, Double_t CircleRadius, TVector3 LineStart) { Double_t yend = CircleRadius*1.1; Double_t xend = yend*TMath::Tan(TMath::DegToRad()*alpha); TVector3 LineEnd(xend, yend, 0); TVector3 rend = LineCrossesCircle(CircleCenter, CircleRadius, LineStart, LineEnd); if (rend != LineStart) { TVector3 res = rend + LineStart; return res*0.5; } return LineStart; }
Double_t LineLength(Double_t alpha, TVector3 CircleCenter, Double_t CircleRadius, TVector3 LineStart) { Double_t yend = CircleRadius*1.1; Double_t xend = yend*TMath::Tan(TMath::DegToRad()*alpha); TVector3 LineEnd(xend, yend, 0); TVector3 rend = LineCrossesCircle(CircleCenter, CircleRadius, LineStart, LineEnd); if (rend != LineStart) { TVector3 llen = rend - LineStart; return llen.Mag(); } return 0; }
void Graphics3DExtrude::drawTextUnderline(const Pnt2f& Position, const std::string& Text, const UIFontUnrecPtr TheFont, const Color4f& Color, const Real32& Opacity) const { Pnt2f TextTopLeft, TextBottomRight; TheFont->getBounds(Text, TextTopLeft, TextBottomRight); Pnt2f CharacterTopLeft, CharacterBottomRight; TheFont->getBounds("A", CharacterTopLeft, CharacterBottomRight); //Line Start Point Pnt2f LineStart(Position.x() + TextTopLeft.x(), Position.y() + CharacterBottomRight.y()-1); //Line End Point Pnt2f LineEnd(LineStart + Vec2f(TextBottomRight.x()-TextTopLeft.x(),1)); drawRect(LineStart, LineEnd, Color, Opacity); }
HTMLEventStatus WebEditBox::Event (HTMLEvent *e) { WEBC_DEBUG_ReceiveEvent(this, e); switch (e->type) { #if (WEBC_SUPPORT_TOUCHSCREEN) case HTML_EVENT_MOUSEDOWN: if (!(mFlags & DISPLAY_FLAG_DISABLED)) { PopUpKeyPad((HTMLBrowser *)webc_GetBrowserWithFocus(), this->miNumLines, (void *) this, GetText(), EditBoxKeyboardcloseFn); return (HTML_EVENT_STATUS_DONE); } // case HTML_EVENT_MOUSEDOWN: // GetText(); #endif case HTML_EVENT_KEYDOWN: if (!(mFlags & DISPLAY_FLAG_DISABLED)) { switch (e->data.key) { case WGK_PGUP: case WGK_PGDN: case WGK_HOME: case WGK_END: case WGK_LNUP: case WGK_LNDN: { WEBC_BOOL selecting = 0; if (e->flags & HTML_EVENT_FLAG_SHIFT_DOWN) { selecting = 1; BeginSelect(); } switch (e->data.key) { case WGK_PGUP: break; case WGK_PGDN: break; case WGK_HOME: if (e->flags & HTML_EVENT_FLAG_CTRL_DOWN) { Home(); } else { LineHome(); } break; case WGK_END: if (e->flags & HTML_EVENT_FLAG_CTRL_DOWN) { End(); } else { LineEnd(); } break; case WGK_LNUP: LineUp(); break; case WGK_LNDN: LineDown(); break; } if (selecting) { EndSelect(); } break; } case WGK_ESC: SelectAll(); break; case WGK_CR: InsertChar((WebChar) '\n'); break; default: WebEditString::Event(e); break; } } break; default: WebEditString::Event(e); break; } return (HTML_EVENT_STATUS_CONTINUE); }
/* TextEditor::onKeyDown * Called when a key is pressed *******************************************************************/ void TextEditor::onKeyDown(wxKeyEvent& e) { // Check if keypress matches any keybinds wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers())); // Go through matching binds bool handled = false; for (unsigned a = 0; a < binds.size(); a++) { string name = binds[a]; // Open/update calltip if (name == "ted_calltip") { updateCalltip(); handled = true; } // Autocomplete else if (name == "ted_autocomplete") { // Get word before cursor string word = GetTextRange(WordStartPosition(GetCurrentPos(), true), GetCurrentPos()); // If a language is loaded, bring up autocompletion list if (language) { autocomp_list = language->getAutocompletionList(word); AutoCompShow(word.size(), autocomp_list); } handled = true; } // Find/replace else if (name == "ted_findreplace") { showFindReplaceDialog(); handled = true; } // Find next else if (name == "ted_findnext") { wxCommandEvent e; onFRDBtnFindNext(e); handled = true; } // Jump to else if (name == "ted_jumpto") { openJumpToDialog(); handled = true; } } #ifdef __WXMSW__ Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine())); #endif #ifdef __APPLE__ if (!handled) { const int keyCode = e.GetKeyCode(); const bool shiftDown = e.ShiftDown(); if (e.ControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { HomeExtend(); } else { Home(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { LineEndExtend(); } else { LineEnd(); } handled = true; } else if (WXK_UP == keyCode) { if (shiftDown) { DocumentStartExtend(); } else { DocumentStart(); } handled = true; } else if (WXK_DOWN == keyCode) { if (shiftDown) { DocumentEndExtend(); } else { DocumentEnd(); } handled = true; } } else if (e.RawControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { WordLeftExtend(); } else { WordLeft(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { WordRightExtend(); } else { WordRight(); } handled = true; } } } #endif // __APPLE__ if (!handled) e.Skip(); }
/* TextEditor::onKeyDown * Called when a key is pressed *******************************************************************/ void TextEditor::onKeyDown(wxKeyEvent& e) { // Check if keypress matches any keybinds wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers())); // Go through matching binds bool handled = false; for (unsigned a = 0; a < binds.size(); a++) { string name = binds[a]; // Open/update calltip if (name == "ted_calltip") { updateCalltip(); handled = true; } // Autocomplete else if (name == "ted_autocomplete") { // Get word before cursor string word = GetTextRange(WordStartPosition(GetCurrentPos(), true), GetCurrentPos()); // If a language is loaded, bring up autocompletion list if (language) { autocomp_list = language->getAutocompletionList(word); AutoCompShow(word.size(), autocomp_list); } handled = true; } // Find/replace else if (name == "ted_findreplace") { showFindReplacePanel(); handled = true; } // Find next else if (name == "ted_findnext") { if (panel_fr && panel_fr->IsShown()) findNext(panel_fr->getFindText(), panel_fr->getFindFlags()); handled = true; } // Find previous else if (name == "ted_findprev") { if (panel_fr && panel_fr->IsShown()) findPrev(panel_fr->getFindText(), panel_fr->getFindFlags()); handled = true; } // Replace next else if (name == "ted_replacenext") { if (panel_fr && panel_fr->IsShown()) replaceCurrent(panel_fr->getFindText(), panel_fr->getReplaceText(), panel_fr->getFindFlags()); handled = true; } // Replace all else if (name == "ted_replaceall") { if (panel_fr && panel_fr->IsShown()) replaceAll(panel_fr->getFindText(), panel_fr->getReplaceText(), panel_fr->getFindFlags()); handled = true; } // Fold all else if (name == "ted_fold_foldall") { foldAll(true); handled = true; } // Unfold all else if (name == "ted_fold_unfoldall") { foldAll(false); handled = true; } // Jump to line else if (name == "ted_jumptoline") { jumpToLine(); handled = true; } } // Check for esc key if (!handled && e.GetKeyCode() == WXK_ESCAPE) { // Hide call tip if showing if (call_tip->IsShown()) call_tip->Show(false); // Hide F+R panel if showing else if (panel_fr && panel_fr->IsShown()) showFindReplacePanel(false); } // Check for up/down keys while calltip with multiple arg sets is open if (call_tip->IsShown() && ct_function && ct_function->nArgSets() > 1 && !ct_dwell) { if (e.GetKeyCode() == WXK_UP) { call_tip->prevArgSet(); handled = true; } else if (e.GetKeyCode() == WXK_DOWN) { call_tip->nextArgSet(); handled = true; } } #ifdef __WXMSW__ Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine())); #endif #ifdef __APPLE__ if (!handled) { const int keyCode = e.GetKeyCode(); const bool shiftDown = e.ShiftDown(); if (e.ControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { HomeExtend(); } else { Home(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { LineEndExtend(); } else { LineEnd(); } handled = true; } else if (WXK_UP == keyCode) { if (shiftDown) { DocumentStartExtend(); } else { DocumentStart(); } handled = true; } else if (WXK_DOWN == keyCode) { if (shiftDown) { DocumentEndExtend(); } else { DocumentEnd(); } handled = true; } } else if (e.RawControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { WordLeftExtend(); } else { WordLeft(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { WordRightExtend(); } else { WordRight(); } handled = true; } } } #endif // __APPLE__ if (!handled) e.Skip(); }
void wxSTEditorShell::OnKeyDown(wxKeyEvent &event) { event.Skip(false); CheckReadOnly(true); switch (event.GetKeyCode()) { case WXK_UP : case WXK_NUMPAD_UP : { // you can scroll up through multiline entry int current_line = GetCurrentLine(); int prompt_line = GetPromptLine(); if ((current_line < prompt_line) || (current_line > prompt_line)) break; // up/down arrows go through the history buffer wxString promptText = GetPromptText(); SetPromptText(GetNextHistoryLine(event.GetKeyCode() == WXK_DOWN, promptText)); return; } case WXK_DOWN : case WXK_NUMPAD_DOWN : { // you can scroll down through multiline entry int total_lines = GetLineCount(); total_lines = wxMax(0, total_lines - 1); int current_line = GetCurrentLine(); if (current_line < total_lines) break; // up/down arrows go through the history buffer if ((int)GetHistoryIndex() < (int)GetHistoryCount()-1) { wxString promptText = GetPromptText(); SetPromptText(GetNextHistoryLine(event.GetKeyCode() == WXK_DOWN, promptText)); } return; } case WXK_LEFT : case WXK_NUMPAD_LEFT : { int current_line = GetCurrentLine(); int prompt_line = GetPromptLine(); if (current_line >= prompt_line) { int caret_pos = 0; GetCurLine(&caret_pos); if (caret_pos < 1) return; } break; } case WXK_PRIOR : case WXK_NUMPAD_PRIOR : //case WXK_NUMPAD_PAGEUP : case WXK_NEXT : case WXK_NUMPAD_NEXT : //case WXK_NUMPAD_PAGEDOWN : case WXK_END : case WXK_NUMPAD_END : case WXK_HOME : case WXK_NUMPAD_HOME : case WXK_RIGHT : case WXK_NUMPAD_RIGHT : case WXK_SHIFT : case WXK_CONTROL : case WXK_ALT : { // default processing for these keys event.Skip(); return; } case WXK_RETURN : case WXK_NUMPAD_ENTER : { // put cursor at end if not already on the last line if (!CaretOnPromptLine(STE_CARET_MOVE_NONE)) { GotoPos(GetLength()); return; } int current_line = GetCurrentLine(); int prompt_line = GetPromptLine(); // allow multiline entry for shift+enter if ((current_line >= prompt_line) && event.ShiftDown()) { event.Skip(); return; } wxString promptText = GetPromptText(); // goto the end of the line and store the line for the history LineEnd(); if (!promptText.IsEmpty()) AddHistoryLine(promptText, true); // just send the event, the receiver can do what they like SendEvent(wxEVT_STESHELL_ENTER, 0, GetState(), promptText); return; } case WXK_BACK : { // go to the end of the last line if not on last line if (!CaretOnPromptLine(STE_CARET_MOVE_NONE)) { GotoPos(GetLength()); return; } // don't let them backspace into previous line int caret_pos = 0; GetCurLine(&caret_pos); if (caret_pos < 1) return; break; } default : // move cursor to end if not already there { CaretOnPromptLine(STE_CARET_MOVE_ENDTEXT); break; } } event.Skip(); }