void DlgEditMusic::s_EditEndPos(QTime NewValue) { if (StopMaj) return; MusicObject->EndPos=NewValue; ui->EndPosEd->setTime(MusicObject->EndPos); SetCurrentPos(MusicObject->EndPos); RefreshControls(); }
void CSoundFile::SetCurrentOrder(UINT nPos) //----------------------------------------- { while ((nPos < MAX_ORDERS) && (Order[nPos] == 0xFE)) nPos++; if ((nPos >= MAX_ORDERS) || (Order[nPos] >= MAX_PATTERNS)) return; for (UINT j=0; j<MAX_CHANNELS; j++) { Chn[j].nPeriod = 0; Chn[j].nNote = 0; Chn[j].nPortamentoDest = 0; Chn[j].nCommand = 0; Chn[j].nPatternLoopCount = 0; Chn[j].nPatternLoop = 0; Chn[j].nTremorCount = 0; } if (!nPos) { SetCurrentPos(0); } else { m_nNextPattern = nPos; m_nRow = m_nNextRow = 0; m_nPattern = 0; m_nTickCount = m_nMusicSpeed; m_nBufferCount = 0; m_nTotalCount = 0; m_nPatternDelay = 0; m_nFrameDelay = 0; } m_dwSongFlags &= ~(SONG_PATTERNLOOP|SONG_CPUVERYHIGH|SONG_FADINGSONG|SONG_ENDREACHED|SONG_GLOBALFADE); }
/* ================ sdPhysics_GeneralMover::ApplyNetworkState ================ */ void sdPhysics_GeneralMover::ApplyNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& newState ) { if ( mode == NSM_VISIBLE ) { NET_GET_NEW( sdGeneralMoverPhysicsNetworkData ); SetCurrentPos( newData.currentFraction ); UpdateClipModel(); } }
/* TextEditor::onJumpToChoiceSelected * Called when the 'Jump To' dropdown is changed *******************************************************************/ void TextEditor::onJumpToChoiceSelected(wxCommandEvent& e) { // Move to line int line = jump_to_lines[choice_jump_to->GetSelection()]; int pos = GetLineEndPosition(line); SetCurrentPos(pos); SetSelection(pos, pos); SetFirstVisibleLine(line); SetFocus(); choice_jump_to->SetSelection(-1); }
void ZoomText::UpdateText(IEditor* editor) { if(!editor) { DoClear(); } else { SetReadOnly(false); SetText(editor->GetEditorText()); SetReadOnly(true); SetCurrentPos(editor->GetCurrentPosition()); } }
/* ================ sdPhysics_GeneralMover::SetInitialPosition ================ */ void sdPhysics_GeneralMover::SetInitialPosition( const idVec3& org, const idMat3& axes ) { move.startPos = org; move.endPos = org; move.startAngles = axes.ToAngles(); move.endAngles = axes.ToAngles(); SetCurrentPos( 1.f, true ); rate = 0.f; UpdateClipModel(); }
void DlgEditMusic::DoInitDialog() { ui->SeekLeftBt->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward)); ui->SeekRightBt->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward)); ui->StartPosEd->setCurrentSection(QDateTimeEdit::MSecSection); ui->StartPosEd->setCurrentSectionIndex(3); ui->StartPosEd->MsecStep=1;//MusicObject->GetFPSDuration(); ui->EndPosEd->setCurrentSection(QDateTimeEdit::MSecSection); ui->EndPosEd->setCurrentSectionIndex(3); ui->EndPosEd->MsecStep =1;//MusicObject->GetFPSDuration(); Music.SetFPS(double(1000)/ApplicationConfig->PreviewFPS,2,ApplicationConfig->PreviewSamplingRate,AV_SAMPLE_FMT_S16); ui->CustomRuler->EditStartEnd =true; ui->CustomRuler->setSingleStep(25); // Disable all during sound analyse ui->CustomRuler->setEnabled(false); ui->DefStartPosBT->setEnabled(false); ui->DefEndPosBT->setEnabled(false); ui->SeekLeftBt->setEnabled(false); ui->SeekRightBt->setEnabled(false); ui->StartPosEd->setEnabled(false); ui->EndPosEd->setEnabled(false); ui->VideoPlayerPlayPauseBT->setEnabled(false); SetCurrentPos(MusicObject->StartPos); RefreshControls(); connect(&Timer,SIGNAL(timeout()),this,SLOT(s_TimerEvent())); connect(ui->VideoPlayerPlayPauseBT,SIGNAL(clicked()),this,SLOT(s_VideoPlayerPlayPauseBT())); // Slider controls connect(ui->CustomRuler,SIGNAL(sliderPressed()),this,SLOT(s_SliderPressed())); connect(ui->CustomRuler,SIGNAL(sliderReleased()),this,SLOT(s_SliderReleased())); connect(ui->CustomRuler,SIGNAL(valueChanged(int)),this,SLOT(s_SliderMoved(int))); connect(ui->CustomRuler,SIGNAL(PositionChangeByUser()),this,SLOT(s_PositionChangeByUser())); connect(ui->CustomRuler,SIGNAL(StartEndChangeByUser()),this,SLOT(s_StartEndChangeByUser())); connect(ui->CustomRuler,SIGNAL(StartEndChangeByUser()),this,SLOT(s_StartEndChangeByUser())); // Edit controls connect(ui->DefStartPosBT,SIGNAL(clicked()),this,SLOT(s_DefStartPos())); connect(ui->DefEndPosBT,SIGNAL(clicked()),this,SLOT(s_DefEndPos())); connect(ui->SeekLeftBt,SIGNAL(clicked()),this,SLOT(s_SeekLeft())); connect(ui->SeekRightBt,SIGNAL(clicked()),this,SLOT(s_SeekRight())); connect(ui->StartPosEd,SIGNAL(timeChanged(QTime)),this,SLOT(s_EditStartPos(QTime))); connect(ui->EndPosEd,SIGNAL(timeChanged(QTime)),this,SLOT(s_EditEndPos(QTime))); audio_outputStream->setBufferSize(MixedMusic.NbrPacketForFPS*MixedMusic.SoundPacketSize*BUFFERING_NBR_AUDIO_FRAME); audio_outputDevice=audio_outputStream->start(); #if QT_VERSION >= 0x050000 audio_outputStream->setVolume(ApplicationConfig->PreviewSoundVolume); #endif audio_outputStream->suspend(); }
void PythonCodeCtrl::OnCharAdded(wxScintillaEvent& ke) { //User has pressed enter //if the cursor is at the end of a completed statement, submit the statement to the interpreter //otherwise, do auto-indentation if (ke.GetKey() == _T('\n')) { //int pos = GetCurrentPos(); int line = LineFromPosition(GetCurrentPos()); if(line>0) { wxString prevlinetext = GetLine(line-1).Trim(); int indentation = GetLineIndentation(line-1); if((indentation==0) //submit a return pressed on an unindented line || (indentation>0 && prevlinetext==wxEmptyString)) // or an indented block where the previous line was empty { long rs,re; GetSelection(&rs,&re); //if(rs==re && GetLastPosition()==rs) if(rs==re && GetLength()==rs) // only submit if the cursor is at the end of the control (and there is no selection) { m_pyctrl->DispatchCode(GetValue()); ke.Skip(); } } // Otherwise indent the code if necessary if (GetLine(line-1).Trim().EndsWith(_T(":"))) { if(GetStyleAt(GetLineEndPosition(line-1)-1) == wxSCI_P_OPERATOR) indentation+=GetIndent(); } if (indentation>0) { SetLineIndentation(line,indentation); SetCurrentPos(PositionFromLine(line)+indentation); SetAnchor(PositionFromLine(line)+indentation); } } } ke.Skip(); }
/* ================ sdPhysics_GeneralMover::Evaluate ================ */ bool sdPhysics_GeneralMover::Evaluate( int timeStepMSec, int endTimeMSec ) { if ( IsAtRest() ) { return false; } float oldPos = currentFraction; float diff = MS2SEC( timeStepMSec ) * rate; float newPos = currentFraction + diff; if ( newPos > 1.f ) { newPos = 1.f; } float distance = newPos - oldPos; self->OnMoveStarted(); idVec3 startPos = Lerp( move.startPos, move.endPos, oldPos ); idVec3 endPos = Lerp( move.startPos, move.endPos, newPos ); idMat3 startAxis = Lerp( move.startAngles, move.endAngles, oldPos ).ToMat3(); idMat3 endAxis = Lerp( move.startAngles, move.endAngles, newPos ).ToMat3(); bool collision = false; trace_t pushResults; gameLocal.push.ClipPush( pushResults, self, 0, startPos, startAxis, endPos, endAxis, GetClipModel( 0 ) ); if ( pushResults.fraction < 1.0f ) { collision = true; } self->OnMoveFinished(); if ( collision ) { self->OnTeamBlocked( self, gameLocal.entities[ pushResults.c.entityNum ] ); } else { SetCurrentPos( newPos ); } return currentFraction != oldPos; }
/* ================ sdPhysics_GeneralMover::StartMove ================ */ void sdPhysics_GeneralMover::StartMove( const idVec3& startPos, const idVec3& endPos, const idAngles& startAngles, const idAngles& endAngles, int startTime, int length ) { move.startPos = startPos; move.endPos = endPos; move.startAngles = startAngles; move.endAngles = endAngles; float newFraction; if ( length == 0 ) { rate = 0.f; newFraction = 1.f; } else { newFraction = ( gameLocal.time - startTime ) / ( float )length; if ( newFraction > 1.f ) { newFraction = 1.f; } rate = 1.f / MS2SEC( length ); } SetCurrentPos( newFraction, true ); UpdateClipModel(); }
/* TextEditor::jumpToLine * Prompts the user for a line number and moves the cursor to the end * of the entered line *******************************************************************/ void TextEditor::jumpToLine() { int numlines = GetNumberOfLines(); // Prompt for line number long line = wxGetNumberFromUser( "Enter a line number to jump to", S_FMT("Line number (1-%d):", numlines), "Jump To Line", GetCurrentLine() + 1, 1, numlines, this); if (line >= 1) { // Move to line int pos = GetLineEndPosition(line - 1); SetCurrentPos(pos); SetSelection(pos, pos); EnsureCaretVisible(); SetFocus(); } }
void ctlSQLBox::OnKeyDown(wxKeyEvent &event) { #ifdef __WXGTK__ event.m_metaDown = false; #endif // Get the line ending type wxString lineEnd; switch (GetEOLMode()) { case wxSTC_EOL_LF: lineEnd = wxT("\n"); break; case wxSTC_EOL_CRLF: lineEnd = wxT("\r\n"); break; case wxSTC_EOL_CR: lineEnd = wxT("\r"); break; } // Block comment/uncomment if (event.GetKeyCode() == 'K') { // Comment (Ctrl+k) if (event.GetModifiers() == wxMOD_CONTROL) { if (BlockComment(false)) return; } // Uncomment (Ctrl+Shift+K) else if (event.GetModifiers() == (wxMOD_CONTROL | wxMOD_SHIFT)) { if (BlockComment(true)) return; } } // Autoindent if (m_autoIndent && event.GetKeyCode() == WXK_RETURN) { wxString indent, line; line = GetLine(GetCurrentLine()); // Get the offset for the current line - basically, whether // or not it ends with a \r\n, \n or \r, and if so, the length int offset = 0; if (line.EndsWith(wxT("\r\n"))) offset = 2; else if (line.EndsWith(wxT("\n"))) offset = 1; else if (line.EndsWith(wxT("\r"))) offset = 1; // Get the indent. This is every leading space or tab on the // line, up until the current cursor position. int x = 0; int max = line.Length() - (GetLineEndPosition(GetCurrentLine()) - GetCurrentPos()) - offset; if(line != wxEmptyString) { while ((line[x] == '\t' || line[x] == ' ') && x < max) indent += line[x++]; } // Select any indent in front of the cursor to be removed. If // the cursor is positioned after any non-indent characters, // we don't remove anything. If there is already some selected, // don't select anything new at all. if (indent.Length() != 0 && (unsigned int)GetCurrentPos() <= ((GetLineEndPosition(GetCurrentLine()) - line.Length()) + indent.Length() + offset) && GetSelectedText() == wxEmptyString) SetSelection(GetLineEndPosition(GetCurrentLine()) - line.Length() + offset, GetLineEndPosition(GetCurrentLine()) - line.Length() + indent.Length() + offset); // Lose any selected text. ReplaceSelection(wxEmptyString); // Insert a replacement \n (or whatever), and the indent at the insertion point. InsertText(GetCurrentPos(), lineEnd + indent); // Now, reset the position, and clear the selection SetCurrentPos(GetCurrentPos() + indent.Length() + lineEnd.Length()); SetSelection(GetCurrentPos(), GetCurrentPos()); } else if (m_dlgFindReplace && event.GetKeyCode() == WXK_F3) { m_dlgFindReplace->FindNext(); } else event.Skip(); }
bool ctlSQLBox::DoFind(const wxString &find, const wxString &replace, bool doReplace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse) { int flags = 0; int startPos = GetSelectionStart(); int endPos = GetTextLength(); // Setup flags if (wholeWord) flags |= wxSTC_FIND_WHOLEWORD; if (matchCase) flags |= wxSTC_FIND_MATCHCASE; // Replace the current selection, if there is one and it matches the find param. wxString current = GetSelectedText(); if (doReplace) { if (useRegexps) { CharacterRange cr = RegexFindText(GetSelectionStart(), GetSelectionEnd(), find); if (GetSelectionStart() == cr.cpMin && GetSelectionEnd() == cr.cpMax) { if (cr.cpMin == cr.cpMax) // Must be finding a special char, such as $ (line end) { InsertText(cr.cpMax, replace); SetSelection(cr.cpMax, cr.cpMax + replace.Length()); SetCurrentPos(cr.cpMax + replace.Length()); // Stop if we've got to the end. This is important for the $ // case where it'll just keep finding the end of the line!! if ((int)(cr.cpMin + replace.Length()) == GetLength()) return false; } else { ReplaceSelection(replace); SetSelection(startPos, startPos + replace.Length()); SetCurrentPos(startPos + replace.Length()); } } } else if ((matchCase && current == find) || (!matchCase && current.Upper() == find.Upper())) { ReplaceSelection(replace); if (!reverse) { SetSelection(startPos, startPos + replace.Length()); SetCurrentPos(startPos + replace.Length()); } else { SetSelection(startPos + replace.Length(), startPos); SetCurrentPos(startPos); } } } //////////////////////////////////////////////////////////////////////// // Figure out the starting position for the next search //////////////////////////////////////////////////////////////////////// if (startAtTop) { startPos = 0; endPos = GetTextLength(); } else { if (reverse) { endPos = 0; startPos = GetCurrentPos(); } else { endPos = GetTextLength(); startPos = GetCurrentPos(); } } size_t selStart = 0, selEnd = 0; if (useRegexps) { CharacterRange cr = RegexFindText(startPos, endPos, find); selStart = cr.cpMin; selEnd = cr.cpMax; } else { selStart = FindText(startPos, endPos, find, flags); selEnd = selStart + find.Length(); } if (selStart >= 0 && selStart != (size_t)(-1)) { if (reverse) { SetCurrentPos(selStart); SetSelection(selEnd, selStart); } else { SetCurrentPos(selEnd); SetSelection(selStart, selEnd); } EnsureCaretVisible(); return true; } else return false; }
bool ModPlugin::audioSetSample( long sample, int ) { float position = ( sample / s_frequency ) * m_maxPosition / m_songTime; SetCurrentPos( (int)position ); return true; }
void DlgEditMusic::s_EditStartPos(QTime NewValue) { if (StopMaj) return; MusicObject->StartPos=NewValue; SetCurrentPos(MusicObject->StartPos); RefreshControls(); }
/* TextEditor::openJumpToDialog * Initialises and opens the 'Jump To' dialog *******************************************************************/ void TextEditor::openJumpToDialog() { // Can't do this without a language definition or defined blocks if (!language || language->nJumpBlocks() == 0) return; // --- Scan for functions/scripts --- Tokenizer tz; vector<jp_t> jump_points; tz.openString(GetText()); string token = tz.getToken(); while (!token.IsEmpty()) { if (token == "{") { // Skip block while (!token.IsEmpty() && token != "}") token = tz.getToken(); } for (unsigned a = 0; a < language->nJumpBlocks(); a++) { // Get jump block keyword string block = language->jumpBlock(a); long skip = 0; if (block.Contains(":")) { wxArrayString sp = wxSplit(block, ':'); sp.back().ToLong(&skip); block = sp[0]; } if (S_CMPNOCASE(token, block)) { string name = tz.getToken(); for (int s = 0; s < skip; s++) name = tz.getToken(); for (unsigned i = 0; i < language->nJBIgnore(); ++i) if (S_CMPNOCASE(name, language->jBIgnore(i))) name = tz.getToken(); // Numbered block, add block name if (name.IsNumber()) name = S_FMT("%s %s", language->jumpBlock(a), name); // Unnamed block, use block name if (name == "{" || name == ";") name = language->jumpBlock(a); // Create jump point jp_t jp; jp.name = name; jp.line = tz.lineNo() - 1; jump_points.push_back(jp); } } token = tz.getToken(); } // Do nothing if no jump points if (jump_points.size() == 0) return; // --- Setup/show dialog --- wxDialog dlg(this, -1, "Jump To..."); wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); dlg.SetSizer(sizer); // Add Jump to dropdown wxChoice* choice_jump_to = new wxChoice(&dlg, -1); sizer->Add(choice_jump_to, 0, wxEXPAND|wxALL, 4); for (unsigned a = 0; a < jump_points.size(); a++) choice_jump_to->Append(jump_points[a].name); choice_jump_to->SetSelection(0); // Add dialog buttons sizer->Add(dlg.CreateButtonSizer(wxOK|wxCANCEL), 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 4); // Show dialog dlg.SetInitialSize(wxSize(250, -1)); dlg.CenterOnParent(); if (dlg.ShowModal() == wxID_OK) { int selection = choice_jump_to->GetSelection(); if (selection >= 0 && selection < (int)jump_points.size()) { // Get line number int line = jump_points[selection].line; // Move to line int pos = GetLineEndPosition(line); SetCurrentPos(pos); SetSelection(pos, pos); SetFirstVisibleLine(line); SetFocus(); } } }
void OutputCtrl::AppendText( const wxString& text ) { SetReadOnly( false ); bool scrollEnd = false; int pos = GetLength(); if ( GetCurrentPos() == pos && GetAnchor() == pos ) scrollEnd = true; // For each line... const wxChar* ptr = text.c_str(); const wxChar* const end = ptr + text.Length(); const wxChar* next; wxString line; bool isError = false; bool isWarn = false; //wxTextAttr errorStyle( *wxRED, *wxWHITE ); //wxTextAttr warnStyle( *wxRED, *wxWHITE ); //wxColour( 255, 128, 0 ), *wxWHITE ); long lnumb; while( ptr != end ) { wxASSERT( ptr < end ); next = std::find( ptr, end, '\n' ); if ( next != end ) ++next; line.assign( ptr, next ); ptr = next; // Look for error lines and highlight them... // // TODO: I need to optimize the regex here... maybe i // shouldn't use a regex, but use my own logic to spot // errors... could be much faster. // if ( m_ErrorExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isError = true; else if ( m_WarnExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isWarn = true; pos = GetLength(); SetTargetStart( pos ); SetTargetEnd( pos ); ReplaceTarget( line ); if ( isError ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, errorStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_ErrorExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_ErrorExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_ErrorExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = false; AddError( error ); isError = false; } else if ( isWarn ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, warnStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_WarnExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_WarnExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_WarnExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = true; AddError( error ); isWarn = false; } } if ( scrollEnd ) { const int endPos = GetLength(); SetAnchor( endPos ); SetCurrentPos( endPos ); ShowLine( LineFromPosition( endPos ) ); } EmptyUndoBuffer(); SetReadOnly( true ); }