// Return number of selections and an array of selected integers int wxListBox::GetSelections(wxArrayInt& aSelections) const { aSelections.Empty(); if ( HasMultipleSelection() ) { int countSel = ListBox_GetSelCount(GetHwnd()); if ( countSel == LB_ERR ) { wxLogDebug(wxT("ListBox_GetSelCount failed")); } else if ( countSel != 0 ) { int *selections = new int[countSel]; if ( ListBox_GetSelItems(GetHwnd(), countSel, selections) == LB_ERR ) { wxLogDebug(wxT("ListBox_GetSelItems failed")); countSel = -1; } else { aSelections.Alloc(countSel); for ( int n = 0; n < countSel; n++ ) aSelections.Add(selections[n]); } delete [] selections; } return countSel; } else // single-selection listbox { if (ListBox_GetCurSel(GetHwnd()) > -1) aSelections.Add(ListBox_GetCurSel(GetHwnd())); return aSelections.Count(); } }
// -------------------------------------------------------------------------------- // bool ReadEQPresets( const wxString &value, wxArrayInt &preset ) { long CurVal; int index; int count; wxArrayString Values = wxStringTokenize( value, wxT( "," ), wxTOKEN_RET_EMPTY_ALL ); if( ( count = Values.Count() ) == guEQUALIZER_BAND_COUNT ) { for( index = 0; index < count; index++ ) { if( Values[ index ].ToLong( &CurVal ) ) { preset.Add( CurVal ); } else break; } return ( preset.Count() == guEQUALIZER_BAND_COUNT ); } return false; }
void ctlSQLGrid::AppendColumnHeader(wxString &str, wxArrayInt columns) { if(settings->GetColumnNames()) { bool CopyQuoting = (settings->GetCopyQuoting() == 1 || settings->GetCopyQuoting() == 2); size_t i; for(i = 0; i < columns.Count() ; i++) { long columnPos = columns.Item(i); if(i > 0) str.Append(settings->GetCopyColSeparator()); if(CopyQuoting) str.Append(settings->GetCopyQuoteChar()); str.Append(GetColumnName(columnPos)); if(CopyQuoting) str.Append(settings->GetCopyQuoteChar()); } str.Append(END_OF_LINE); } }
// -------------------------------------------------------------------------------- // void guDbRadios::GetRadioGenresList( const int source, const wxArrayInt &ids, guListItems * listitems, wxArrayInt * radioflags ) { wxString query; wxSQLite3ResultSet dbRes; if( ids.Count() ) { query = wxT( "SELECT radiogenre_id, radiogenre_name, radiogenre_flags FROM radiogenres WHERE " ); query += wxString::Format( wxT( "radiogenre_source = %i AND " ), source ); query += ArrayToFilter( ids, wxT( "radiogenre_id" ) ); query += wxT( " ORDER BY radiogenre_name COLLATE NOCASE;" ); //guLogMessage( query ); dbRes = ExecuteQuery( query ); while( dbRes.NextRow() ) { listitems->Add( new guListItem( dbRes.GetInt( 0 ), dbRes.GetString( 1 ) ) ); if( radioflags ) radioflags->Add( dbRes.GetInt( 2 ) ); } dbRes.Finalize(); } }
// -------------------------------------------------------------------------------- // void guJamendoDownloadThread::AddAlbums( const wxArrayInt &albumids, const bool iscover ) { int Index; int Count = albumids.Count(); if( iscover ) { m_CoversMutex.Lock(); for( Index = 0; Index < Count; Index++ ) { m_Covers.Add( albumids[ Index ] ); } m_CoversMutex.Unlock(); } else { m_AlbumsMutex.Lock(); for( Index = 0; Index < Count; Index++ ) { m_Albums.Add( albumids[ Index ] ); } m_AlbumsMutex.Unlock(); } }
wxString ddDatabaseDesign::generateList(wxArrayString tables, wxArrayInt options, pgConn *connection, wxString schemaName) { int i; // Validate if(tables.Count() != options.Count()) { // shouldn't it be a WXASSERT? wxMessageBox(_("Invalid number of arguments in call of function generate tables of list"), _("Error at generation process"), wxICON_ERROR); return wxEmptyString; } int tablesCount = tables.Count(); for(i = 0; i < tablesCount; i++) { ddTableFigure *table = getTable(tables[i]); if(table == NULL) { // shouldn't it be a WXASSERT? wxMessageBox(_("Metadata of table to be generated not found at database designer model"), _("Error at generation process"), wxICON_ERROR); return wxEmptyString; } } // Start building of CREATE + ALTER PK(s) + ALTER UK(s) + ALTER FK(s) wxString out; out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Create sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); if(options[i] == DDGENDROPCRE) { out += wxT(" \n"); out += wxT("DROP TABLE \"") + table->getTableName() + wxT("\";"); out += wxT(" \n"); } out += wxT(" \n"); out += table->generateSQLCreate(schemaName); out += wxT(" \n"); } } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Pk sentence for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); out += table->generateSQLAlterPks(schemaName); } } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Uk sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); out += table->generateSQLAlterUks(schemaName); } } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Fk sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENCREATE || options[i] == DDGENDROPCRE) { ddTableFigure *table = getTable(tables[i]); out += table->generateSQLAlterFks(schemaName); } } //Start generation of alter table instead of create //Check there is some int countAlter = 0; for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENALTER) { countAlter++; } } if(countAlter > 0 && connection == NULL) { wxMessageBox(_("No connection found when building ALTER objects DDL."), _("Error at generation process"), wxICON_ERROR); return out; } else if(countAlter > 0 && connection != NULL) { if(schemaName.IsEmpty()) { wxMessageBox(_("Schema defined when building ALTER TABLE DDL"), _("Error at generation process"), wxICON_ERROR); return out; } out += wxT(" \n"); out += wxT(" \n"); out += wxT(" \n"); out += wxT("--\n-- "); out += _("Generating Alter table sentence(s) for table(s) "); out += wxT(" \n--\n"); out += wxT(" \n"); out += wxT(" \n"); for(i = 0; i < tablesCount; i++) { if(options[i] == DDGENALTER) { ddTableFigure *table = getTable(tables[i]); out += table->generateAltersTable(connection, schemaName, this); out += wxT(" \n"); } } } return out; }
// called on each Timer tick while Test dialog is open void xLightsFrame::OnTimerTest(long curtime) { static int LastNotebookSelection = -1; static int LastBgIntensity,LastFgIntensity,LastBgColor[3],LastFgColor[3],*ShimColor,ShimIntensity; static int LastSequenceSpeed; static int LastAutomatedTest; static long NextSequenceStart = -1; static TestFunctions LastFunc = OFF; static unsigned int interval, rgbCycle, TestSeqIdx; static wxArrayInt chArray,TwinkleState; static float frequency; int v,BgIntensity,FgIntensity,BgColor[3],FgColor[3]; unsigned int i; bool ColorChange; if (!xout) return; xout->TimerStart(curtime); int NotebookSelection = NotebookTest->GetSelection(); if (NotebookSelection != LastNotebookSelection) { LastNotebookSelection = NotebookSelection; CheckChannelList = true; TestSeqIdx=0; TestButtonsOff(); } if (TestFunc != LastFunc) { LastFunc = TestFunc; rgbCycle=0; CheckChannelList = true; NextSequenceStart = -1; } if (CheckChannelList) { // get list of checked channels xout->alloff(); GetCheckedItems(chArray); LastSequenceSpeed=-1; LastBgIntensity=-1; LastFgIntensity=-1; LastAutomatedTest=-1; for (i=0; i < 3; i++) { LastBgColor[i] = -1; LastFgColor[i] = -1; } if (!CheckBoxLightOutput->IsChecked()) { StatusBar1->SetStatusText(_("Testing disabled - Output to Lights is not checked")); } else if (TestFunc == OFF) { StatusBar1->SetStatusText(_("Testing off")); } else { StatusBar1->SetStatusText(wxString::Format(_("Testing %ld channels"),static_cast<long>(chArray.Count()))); } CheckChannelList = false; } if (TestFunc != OFF && chArray.Count() > 0) switch (NotebookSelection) { case 0: // standard tests v=SliderChaseSpeed->GetValue(); // 0-100 BgIntensity = SliderBgIntensity->GetValue(); FgIntensity = SliderFgIntensity->GetValue(); ColorChange = BgIntensity != LastBgIntensity || FgIntensity != LastFgIntensity; LastBgIntensity = BgIntensity; LastFgIntensity = FgIntensity; interval = 1600 - v*15; switch (TestFunc) { case DIM: if (ColorChange) { for (i=0; i < chArray.Count(); i++) { xout->SetIntensity(chArray[i], BgIntensity); } } break; case TWINKLE: if (LastSequenceSpeed < 0) { LastSequenceSpeed=0; TwinkleState.Clear(); for (i=0; i < chArray.Count(); i++) { TestSeqIdx = static_cast<int>(rand01()*TwinkleRatio); TwinkleState.Add(TestSeqIdx == 0 ? -1 : 1); } } for (i=0; i < TwinkleState.Count(); i++) { if (TwinkleState[i] < -1) { // background TwinkleState[i]++; } else if (TwinkleState[i] > 1) { // highlight TwinkleState[i]--; } else if (TwinkleState[i] == -1) { // was background, now highlight for random period TwinkleState[i]=static_cast<int>(rand01()*interval+100) / XTIMER_INTERVAL; xout->SetIntensity(chArray[i], FgIntensity); } else { // was on, now go to bg color for random period TwinkleState[i]=-static_cast<int>(rand01()*interval+100) / XTIMER_INTERVAL * (TwinkleRatio - 1); xout->SetIntensity(chArray[i], BgIntensity); } } break; case SHIMMER: if (ColorChange || curtime >= NextSequenceStart) { ShimIntensity = (ShimIntensity == FgIntensity) ? BgIntensity : FgIntensity; for (i=0; i < chArray.Count(); i++) { xout->SetIntensity(chArray[i], ShimIntensity); } } if (curtime >= NextSequenceStart) { NextSequenceStart = curtime + interval/2; } break; case CHASE: //StatusBar1->SetStatusText(wxString::Format(_("chase curtime=%ld, NextSequenceStart=%ld"),curtime,NextSequenceStart)); if (ColorChange || curtime >= NextSequenceStart) { for (i=0; i < chArray.Count(); i++) { v = (i % ChaseGrouping) == TestSeqIdx ? FgIntensity : BgIntensity; xout->SetIntensity(chArray[i], v); } } if (curtime >= NextSequenceStart) { NextSequenceStart = curtime + interval; TestSeqIdx = (TestSeqIdx + 1) % ChaseGrouping; if (TestSeqIdx >= chArray.Count()) TestSeqIdx=0; } StatusBar1->SetStatusText(wxString::Format(_("Testing %ld channels; chase now at ch# %d"),static_cast<long>(chArray.Count()), TestSeqIdx)); //show current ch# -DJ break; default: break; } break; case 1: // RGB tests v=SliderRgbChaseSpeed->GetValue(); // 0-100 BgColor[0] = SliderBgColorA->GetValue(); BgColor[1] = SliderBgColorB->GetValue(); BgColor[2] = SliderBgColorC->GetValue(); FgColor[0] = SliderFgColorA->GetValue(); FgColor[1] = SliderFgColorB->GetValue(); FgColor[2] = SliderFgColorC->GetValue(); interval = 1600 - v*15; for (ColorChange=false,i=0; i < 3; i++) { ColorChange |= (BgColor[i] != LastBgColor[i]); ColorChange |= (FgColor[i] != LastFgColor[i]); LastBgColor[i] = BgColor[i]; LastFgColor[i] = FgColor[i]; } switch (TestFunc) { case DIM: if (ColorChange) { for (i=0; i < chArray.Count(); i++) { xout->SetIntensity(chArray[i], BgColor[i % 3]); } } break; case TWINKLE: if (LastSequenceSpeed < 0) { LastSequenceSpeed=0; TwinkleState.Clear(); for (i=0; i < chArray.Count()-2; i+=3) { TestSeqIdx = static_cast<int>(rand01()*TwinkleRatio); TwinkleState.Add(TestSeqIdx == 0 ? -1 : 1); } } for (i=0; i < TwinkleState.Count(); i++) { if (TwinkleState[i] < -1) { // background TwinkleState[i]++; } else if (TwinkleState[i] > 1) { // highlight TwinkleState[i]--; } else if (TwinkleState[i] == -1) { // was background, now highlight for random period TwinkleState[i]=static_cast<int>(rand01()*interval+100) / XTIMER_INTERVAL; TestSeqIdx = i * 3; xout->SetIntensity(chArray[TestSeqIdx], FgColor[0]); xout->SetIntensity(chArray[TestSeqIdx+1], FgColor[1]); xout->SetIntensity(chArray[TestSeqIdx+2], FgColor[2]); } else { // was on, now go to bg color for random period TwinkleState[i]=-static_cast<int>(rand01()*interval+100) / XTIMER_INTERVAL * (TwinkleRatio - 1); TestSeqIdx = i * 3; xout->SetIntensity(chArray[TestSeqIdx], BgColor[0]); xout->SetIntensity(chArray[TestSeqIdx+1], BgColor[1]); xout->SetIntensity(chArray[TestSeqIdx+2], BgColor[2]); } } break; case SHIMMER: if (ColorChange || curtime >= NextSequenceStart) { ShimColor = (ShimColor == FgColor) ? BgColor : FgColor; for (i=0; i < chArray.Count(); i++) { xout->SetIntensity(chArray[i], ShimColor[i % 3]); } } if (curtime >= NextSequenceStart) { NextSequenceStart = curtime + interval/2; } break; case CHASE: if (ColorChange || curtime >= NextSequenceStart) { for (i=0; i < chArray.Count(); i++) { v = (i / 3 % ChaseGrouping) == TestSeqIdx ? FgColor[i % 3] : BgColor[i % 3]; xout->SetIntensity(chArray[i], v); } } if (curtime >= NextSequenceStart) { NextSequenceStart = curtime + interval; TestSeqIdx = (TestSeqIdx + 1) % ChaseGrouping; if (TestSeqIdx >= (chArray.Count()+2) / 3) TestSeqIdx=0; } StatusBar1->SetStatusText(wxString::Format(_("Testing %ld channels; chase now at ch# %d"),static_cast<long>(chArray.Count()), TestSeqIdx)); //show current ch# -DJ break; default: break; } break; case 2: // RGB Cycle v=SliderRgbCycleSpeed->GetValue(); // 0-100 if (TestFunc == DIM) { // color mixing if (v != LastSequenceSpeed) { frequency=v/1000.0 + 0.05; LastSequenceSpeed = v; } BgColor[0] = sin(frequency*TestSeqIdx + 0.0) * 127 + 128; BgColor[1] = sin(frequency*TestSeqIdx + 2.0) * 127 + 128; BgColor[2] = sin(frequency*TestSeqIdx + 4.0) * 127 + 128; TestSeqIdx++; for (i=0; i < chArray.Count(); i++) { xout->SetIntensity(chArray[i], BgColor[i % 3]); } } else { // RGB cycle if (v != LastSequenceSpeed) { interval = (101-v)*50; NextSequenceStart = curtime + interval; LastSequenceSpeed = v; } if (curtime >= NextSequenceStart) { for (i=0; i < chArray.Count(); i++) { switch (rgbCycle) { case 3: v=255; break; default: v = (i % 3) == rgbCycle ? 255 : 0; break; } xout->SetIntensity(chArray[i], v); } rgbCycle=(rgbCycle + 1) % ChaseGrouping; NextSequenceStart += interval; } } break; } xout->TimerEnd(); }