void ClangCodeCompletion::OnFileLoaded(wxCommandEvent& e)
{
    e.Skip();
    CHECK_CLANG_ENABLED_RET();

    if(TagsManagerST::Get()->GetCtagsOptions().GetClangCachePolicy() == TagsOptionsData::CLANG_CACHE_ON_FILE_LOAD) {
        CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() START"));
        if(m_clang.IsBusy() || m_allEditorsAreClosing) {
            CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() ENDED"));
            return;
        }
        if(e.GetClientData()) {
            IEditor *editor = (IEditor*)e.GetClientData();
            // sanity
            if(editor->GetProjectName().IsEmpty() || editor->GetFileName().GetFullName().IsEmpty())
                return;

            if(!TagsManagerST::Get()->IsValidCtagsFile(editor->GetFileName()))
                return;

            m_clang.SetContext(CTX_CachePCH);
            m_clang.CodeCompletion(editor);
        }
        CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() ENDED"));
    }
}
Example #2
0
void MainFrame::OnUpdateReceived(wxCommandEvent& event) 
{
	std::string data = *(std::string*)event.GetClientData();
	delete (std::string*)event.GetClientData();
	size_t first_colon = data.find(':');
	size_t second_colon = data.find(':', first_colon+1);

	if(first_colon == std::string::npos || second_colon == std::string::npos) 
		return;

	std::string update = data.substr(0, first_colon);
	std::string verstr = data.substr(first_colon+1, second_colon-first_colon-1);
	std::string url = (second_colon == data.size()? "" : data.substr(second_colon+1));

	if(update == "yes") 
	{
		int ret = gui.PopupDialog(
			wxT("Update Notice"),
			wxString(wxT("There is a newd update available (")) << wxstr(verstr) << 
			wxT("). Do you want to go to the website and download it?"),
			wxYES | wxNO,
			wxT("I don't want any update notices"),
			Config::AUTOCHECK_FOR_UPDATES
			);
		if(ret == wxID_YES)
			::wxLaunchDefaultBrowser(wxstr(url),  wxBROWSER_NEW_WINDOW);
	}
}
void console::ted_cmd::OnGUInput(wxCommandEvent& evt) {
   switch (evt.GetInt()) {
      case -4: _translation.FlipY();break;
      case -3: _translation.Rotate(90.0);break;
      case -2: cancelLastPoint();break;
      case -1:   // abort current  mouse input
         Disconnect(-1, wxEVT_COMMAND_ENTER);
         delete puc; puc = NULL;
         _mouseIN_OK = false;
         tell_log(MT_WARNING, "input aborted");
         tell_log(MT_EOL);
         // wake-up the thread expecting this data
         threadWaits4->Signal();
         break;
      case  0:  {// left mouse button
         telldata::ttpnt* p = static_cast<telldata::ttpnt*>(evt.GetClientData());
         mouseLB(*p);
         delete p;
         break;
         }
      case  2: {
         telldata::ttpnt* p = static_cast<telldata::ttpnt*>(evt.GetClientData());
         mouseRB(); 
         delete p;
         break;
         }
      default: assert(false);
   }
}
Example #4
0
/*!
 * Handle events from SessionList
 */
void SessionAdmin::OnSessionList(wxCommandEvent& event)
{
    long idx;
    MySession *s;
    switch (event.GetInt()) {
        case SessionList::SessionAdded:
            s = wxDynamicCast((void *)event.GetClientData(), MySession);
            // Hostname
            idx = m_SessionListCtrl->InsertItem(0, s->sGetHost(), 0);
            m_SessionListCtrl->SetItemData(idx, (long)s);
            // Port
            m_SessionListCtrl->SetItem(idx, 1, s->sGetPort());
            // Session ID
            m_SessionListCtrl->SetItem(idx, 2, s->sGetMd5());
            // Creation Time
            m_SessionListCtrl->SetItem(idx, 3, s->sGetCreationTime());
            // PID
            m_SessionListCtrl->SetItem(idx, 4, s->sGetPID());
            // Status
            m_SessionListCtrl->SetItem(idx, 5, s->sGetSessionStatus());
            // Type
            m_SessionListCtrl->SetItem(idx, 6, s->sGetSessionType());
            break;
        case SessionList::SessionChanged:
            s = wxDynamicCast((void *)event.GetClientData(), MySession);
            idx = m_SessionListCtrl->FindItem(-1, (long)s);
            ::myLogTrace(MYTRACETAG, wxT("state changed: %d"), idx);
            if (idx != -1) {
                m_SessionListCtrl->SetItem(idx, 3, s->sGetCreationTime());
                m_SessionListCtrl->SetItem(idx, 4, s->sGetPID());
                m_SessionListCtrl->SetItem(idx, 5, s->sGetSessionStatus());
                if (m_SessionListCtrl->GetItemState(idx, wxLIST_STATE_SELECTED)) {
                    bool running = (s->eGetSessionStatus() == MySession::Running);
                    SessionToolsEnable(true, running);
                }
            }
            break;
        case SessionList::SessionRemoved:
            idx = m_SessionListCtrl->FindItem(-1, (long)event.GetClientData());
            if (idx != -1) {
                m_SessionListCtrl->DeleteItem(idx);
            }
            break;
        case SessionList::UpdateList:
#ifndef __WXMAC__ // On OSX, this messes up column headers
            {
                int width = m_SessionListCtrl->GetItemCount() ?
                    wxLIST_AUTOSIZE : wxLIST_AUTOSIZE_USEHEADER;
                for (int i = 0; i < m_SessionListCtrl->GetColumnCount(); i++) 
                    m_SessionListCtrl->SetColumnWidth(i, width);
            }
#endif
            m_SessionListCtrl->Update();
            break;
    }
}
Example #5
0
void browsers::browserTAB::OnCommand(wxCommandEvent& event) {
   int command = event.GetInt();
   switch (command) {
      case BT_ADDTDT_TAB:OnTELLaddTDTtab(event.GetString(), 
                            (laydata::TDTHierTree*)event.GetClientData());break;
      case BT_ADDGDS_TAB:OnTELLaddGDStab(event.GetString(), 
                            (GDSin::GDSHierTree*)event.GetClientData());break;
      case BT_CLEARGDS_TAB:OnTELLclearGDStab(); break;
   }
}
Example #6
0
void browsers::TDTbrowser::OnCommand(wxCommandEvent& event) {
   switch (event.GetInt()) {
      case BT_CELL_OPEN:OnTELLopencell(event.GetString());break;
      case BT_CELL_HIGHLIGHT:OnTELLhighlightcell(event.GetString());break;
      case BT_CELL_ADD :OnTELLaddcell(event.GetString(), 
          *((wxString*)event.GetClientData()), (int)event.GetExtraLong());
          delete ((wxString*)event.GetClientData()); break;
      case BT_CELL_REMOVE:OnTELLremovecell(event.GetString(), 
          *((wxString*)event.GetClientData()), (0 != event.GetExtraLong()));
          delete ((wxString*)event.GetClientData()); break;

   }   
}
Example #7
0
void SearchResultWindow::OnClickResult(wxCommandEvent& event)
{
	Position* pos = reinterpret_cast<Position*>(event.GetClientData());
	if(pos) {
		gui.CenterOnPosition(*pos);
	}
}
Example #8
0
	void HandleCommand(wxCommandEvent& event)
	{
		event.Skip();

		switch(event.GetId())
		{
		case DID_STOP_EMU:
			m_btn_run->SetLabel("Run");
		break;

		case DID_PAUSE_EMU:
			m_btn_run->SetLabel("Resume");
		break;

		case DID_START_EMU:
		case DID_RESUME_EMU:
			m_btn_run->SetLabel("Pause");
		break;

		case DID_EXIT_THR_SYSCALL:
			Emu.GetCPU().RemoveThread(((PPCThread*)event.GetClientData())->GetId());
		break;
		}

		UpdateUI();
	}
Example #9
0
void wxJADFrame::OnNewEntry( wxCommandEvent & event )
{
	wprintf( wxT( "New entry received...\n" ) );
	JadEntry * pEntry = ( JadEntry * ) event.GetClientData();
	if( pEntry != NULL )
		tree->AddEntry( pEntry );
}
Example #10
0
void dlgDirectDbg::OnTargetComplete( wxCommandEvent &event )
{
	// Extract the result set handle from the event and log the status info

	PGresult    *result = (PGresult *)event.GetClientData();

	wxLogInfo( wxT( "OnTargetComplete() called\n" ));
	wxLogInfo( wxT( "%s\n" ), wxString(PQresStatus( PQresultStatus( result )), wxConvUTF8).c_str());

	// If the query failed, write the error message to the status line, otherwise, copy the result set into the grid
	if(( PQresultStatus( result ) == PGRES_NONFATAL_ERROR ) || ( PQresultStatus( result ) == PGRES_FATAL_ERROR ))
	{
		wxString    message( PQresultErrorMessage( result ), wxConvUTF8 );

		message.Replace( wxT( "\n" ), wxT( " " ));

		m_parent->getStatusBar()->SetStatusText( message, 1 );
		char *state = PQresultErrorField(result, PG_DIAG_SQLSTATE);

		// Don't bother telling the user that he aborted - he already knows!
		// Depending on the stage, m_conn might not be set all! so check for
		// that first
		if (m_conn)
		{
			if (state != NULL && strcmp(state, "57014"))
				wxLogError( wxT( "%s\n" ), wxString(PQerrorMessage(m_conn->getConnection()), wxConvUTF8).c_str());
			else
				wxLogInfo( wxT( "%s\n" ), wxString(PQerrorMessage(m_conn->getConnection()), wxConvUTF8).c_str());
		}
	}
	else
	{
		wxString message( PQcmdStatus( result ), wxConvUTF8 );

		message.Replace( wxT( "\r" ), wxT( "" ));
		message.Replace( wxT( "\n" ), wxT( " " ));

		m_parent->getStatusBar()->SetStatusText( message, 1 );

		// If this result set has any columns, add a result grid to the code window so
		// we can show the results to the user

		if( m_codeWindow && PQnfields( result ))
		{
			m_codeWindow->OnResultSet( result );
		}
	}

	if (m_codeWindow)
	{
		m_codeWindow->m_targetComplete = true;
		m_codeWindow->disableTools( );
	}

	// Do not show if aborted
	if ( m_codeWindow && m_codeWindow->m_targetAborted )
		return;

	this->Show( true );
}
Example #11
0
void InterpreterDisAsmFrame::OnSelectUnit(wxCommandEvent& event)
{
	m_disasm.reset();

	if (cpu = (cpu_thread*)event.GetClientData())
	{
		switch (cpu->type)
		{
		case cpu_type::ppu:
		{
			m_disasm = std::make_unique<PPUDisAsm>(CPUDisAsm_InterpreterMode);
			break;
		}

		case cpu_type::spu:
		{
			m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
			break;
		}

		case cpu_type::arm:
		{
			m_disasm = std::make_unique<ARMv7DisAsm>(CPUDisAsm_InterpreterMode);
			break;
		}
		}
	}

	DoUpdate();
}
Example #12
0
void ApiHandler::OnIpcClosed(wxCommandEvent& event) {
	IConnection* conn = (IConnection*)event.GetClientData();
	if (!conn) return;

	// Remove all notifiers from closed connection
	map<unsigned int, IConnection*>::iterator p = m_notifiers.begin();
	while (p != m_notifiers.end()) {
		if (p->second == conn) m_notifiers.erase(p++);
		else ++p;
	}

	boost::ptr_map<IConnection*, ConnectionState>::const_iterator c = m_connStates.find(conn);
	if (c != m_connStates.end()) {
		// If any editors are still in a change group, we have to release them
		const set<int>& editorsInChange = c->second->editorsInChange;
		if (!editorsInChange.empty()) {
			for (set<int>::const_iterator e = editorsInChange.begin(); e != editorsInChange.end(); ++e) {
				EditorCtrl* editor = m_app.GetEditorCtrl(*e);
				if (editor) editor->EndChange();
			}
		}
	}

	// Clear any associated state
	m_connStates.erase(conn);
}
void ClangMacroHandler::OnClangProcessTerminated(wxCommandEvent& e)
{
    ProcessEventData *ped = (ProcessEventData *)e.GetClientData();
    delete ped;
    if( m_process ) {
        delete m_process;
        m_process = NULL;
    }

    wxString macrosAsString;
    wxArrayString lines = ::wxStringTokenize(m_output, wxT("\n\r"), wxTOKEN_STRTOK);
    for(size_t i=0; i<lines.GetCount(); i++) {
        wxString rest;
        if(lines.Item(i).StartsWith(wxT("MACRO:"), &rest)) {
            rest.Trim().Trim(false);
            macrosAsString << wxT(" ") << rest;
        }
    }

    // Process the output here...
    CL_DEBUG(wxT("ClangMacroHandler: Macros collected: %s"), macrosAsString.c_str());

    if(m_editor) {
        // Scintilla preprocessor management
        m_editor->GetSTC()->SetProperty(wxT("lexer.cpp.track.preprocessor"),  wxT("1"));
        m_editor->GetSTC()->SetProperty(wxT("lexer.cpp.update.preprocessor"), wxT("1"));
        m_editor->GetSTC()->SetKeyWords(4, macrosAsString);
        m_editor->GetSTC()->Colourise(0, wxSTC_INVALID_POSITION);
    }

    wxCommandEvent evt(wxEVT_CMD_CLANG_MACRO_HADNLER_DELETE);
    evt.SetClientData(this);
    EventNotifier::Get()->AddPendingEvent(evt);
}
Example #14
0
void InterpreterDisAsmFrame::OnSelectUnit(wxCommandEvent& event)
{
	CPU = (PPCThread*)event.GetClientData();

	delete decoder;
	//delete disasm;
	decoder = nullptr;
	disasm = nullptr;

	if(CPU)
	{
		if(CPU->GetType() != PPC_THREAD_PPU)
		{
			SPU_DisAsm& dis_asm = *new SPU_DisAsm(*CPU, InterpreterMode);
			decoder = new SPU_Decoder(dis_asm);
			disasm = &dis_asm;
		}
		else
		{
			PPU_DisAsm& dis_asm = *new PPU_DisAsm(*CPU, InterpreterMode);
			decoder = new PPU_Decoder(dis_asm);
			disasm = &dis_asm;
		}
	}

	DoUpdate();
}
Example #15
0
void CompareDlg::OnViewInComparisonDB(wxCommandEvent& evt)
{
  ContextMenuData* menuContext = reinterpret_cast<ContextMenuData*>(evt.GetClientData());
  const ComparisonGridTable& table = *wxDynamicCast(menuContext->cdata->grid->GetTable(), ComparisonGridTable);
  const pws_os::CUUID& uuid = table[menuContext->selectedRows[0]].uuid1;
  wxCHECK_RET(ViewEditEntry(m_otherCore, uuid, true) == false, wxT("Should not need to refresh grid for just viewing entry"));
}
Example #16
0
void FindResultsTab::OnSearchStart(wxCommandEvent& e)
{
    m_searchInProgress = true;
    SearchData* data = (SearchData*)e.GetClientData();
    wxString label = data ? data->GetFindString() : wxT("");

    if(e.GetInt() != 0 || m_sci == NULL) {
        if(m_book) {
            clWindowUpdateLocker locker(this);
            MySTC* sci = new MySTC(m_book);
            SetStyles(sci);
            sci->Connect(wxEVT_STC_STYLENEEDED, wxStyledTextEventHandler(FindResultsTab::OnStyleNeeded), NULL, this);
            m_book->AddPage(sci, label, true);
#ifdef __WXMAC__
            m_book->GetSizer()->Layout();
#endif
            size_t where = m_book->GetPageCount() - 1;

            // keep the search data used for this tab
            wxWindow* tab = m_book->GetPage(where);
            if(tab) {
                tab->SetClientData(data);
            }

            m_matchInfo.push_back(MatchInfo());
            m_sci = sci;
        }
    } else if(m_book) {
        // using current tab, update the tab title and the search data
        int where = m_book->GetPageIndex(m_sci);
        if(where != wxNOT_FOUND) {
            m_book->SetPageText(where, label);
            // delete the old search data
            wxWindow* tab = m_book->GetPage(where);
            SearchData* oldData = (SearchData*)tab->GetClientData();
            if(oldData) {
                delete oldData;
            }
            // set the new search data
            tab->SetClientData(data);
        }
    }

    // This is needed in >=wxGTK-2.9, otherwise the 'Search' pane doesn't fully expand
    SendSizeEvent(wxSEND_EVENT_POST);

    m_recv = m_sci;
    Clear();

    if(data) {
        m_searchData = *data;

        wxString message;
        message << _("====== Searching for: '") << data->GetFindString() << _("'; Match case: ")
                << (data->IsMatchCase() ? _("true") : _("false")) << _(" ; Match whole word: ")
                << (data->IsMatchWholeWord() ? _("true") : _("false")) << _(" ; Regular expression: ")
                << (data->IsRegularExpression() ? _("true") : _("false")) << wxT(" ======\n");
        AppendText(message);
    }
}
void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
{
    VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );

    m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
    m_viaDrill.ChangeValue( viaDimension->m_Drill );
}
Example #18
0
void SvnConsole::OnReadProcessOutput(wxCommandEvent& event)
{
    ProcessEventData *ped = (ProcessEventData *)event.GetClientData();
    if (ped) {
        m_output.Append(ped->GetData().c_str());
    }

    wxString s (ped->GetData());
    s.MakeLower();

    if (m_currCmd.printProcessOutput)
        AppendText( ped->GetData() );
    
    static wxRegEx reUsername("username[ \t]*:", wxRE_DEFAULT|wxRE_ICASE);
    wxArrayString lines = wxStringTokenize(s, wxT("\n"), wxTOKEN_STRTOK);
    if( !lines.IsEmpty() && lines.Last().StartsWith(wxT("password for '")) ) {
        m_output.Clear();
        wxString pass = wxGetPasswordFromUser(ped->GetData(), wxT("Subversion"));
        if(!pass.IsEmpty() && m_process) {
            m_process->WriteToConsole(pass);
        }
    } else if ( !lines.IsEmpty() && reUsername.IsValid() && reUsername.Matches( lines.Last() ) ) {
        // Prompt the user for "Username:"******"Subversion");
        if ( !username.IsEmpty() && m_process ) {
            m_process->Write(username + "\n");
        }
    }
    delete ped;
}
Example #19
0
void SvnConsole::OnProcessEnd(wxCommandEvent& event)
{
    ProcessEventData *ped = (ProcessEventData *)event.GetClientData();
    delete ped;

    if ( m_process ) {
        delete m_process;
        m_process = NULL;
    }

    if(m_currCmd.handler) {
        // command ended successfully, invoke the "success" callback
        m_currCmd.handler->Process(m_output);
        AppendText(wxT("-----\n"));
        delete m_currCmd.handler;
    }

    // do we have more commands to process?
    if(!m_queue.empty()) {
        DoProcessNextCommand();

    } else {
        // Do some cleanup
        m_output.Clear();
        m_url.Clear();
        m_currCmd.clean();
    }
}
void tui::LayoutCanvas::OnZoom(wxCommandEvent& evt) {
   DBbox* box = NULL;
   switch (evt.GetInt())
   {
      case ZOOM_WINDOW : box = static_cast<DBbox*>(evt.GetClientData());break;
      case ZOOM_WINDOWM: box = DEBUG_NEW DBbox(presspoint.x(),presspoint.y(),
                                             ScrMARK.x(),ScrMARK.y());break;
      case ZOOM_IN     : box = DEBUG_NEW DBbox( (3*lp_BL.x() + lp_TR.x())/4, //in
                                                (3*lp_BL.y() + lp_TR.y())/4,
                                                (3*lp_TR.x() + lp_BL.x())/4,
                                                (3*lp_TR.y() + lp_BL.y())/4);
                        break;
      case ZOOM_OUT    : box = DEBUG_NEW DBbox( (5*lp_BL.x() - lp_TR.x())/4, //out
                                                (5*lp_BL.y() - lp_TR.y())/4,
                                                (5*lp_TR.x() - lp_BL.x())/4,
                                                (5*lp_TR.y() - lp_BL.y())/4);
                        break;
      case ZOOM_LEFT   : box = DEBUG_NEW DBbox( (  lp_TR.x() + lp_BL.x())/2, //left
                                                   lp_BL.y()               ,
                                                (3*lp_BL.x() - lp_TR.x())/2,
                                                   lp_TR.y()               );
                        break;
      case ZOOM_RIGHT  : box = DEBUG_NEW DBbox( (3*lp_TR.x() - lp_BL.x())/2, // right
                                                   lp_BL.y()               ,
                                                (  lp_TR.x() + lp_BL.x())/2,
                                                   lp_TR.y()               );
                        break;
      case ZOOM_UP     : box = DEBUG_NEW DBbox(    lp_BL.x()               , // up
                                                (3*lp_BL.y() - lp_TR.y())/2,
                                                   lp_TR.x()               ,
                                                (  lp_TR.y() + lp_BL.y())/2);
                        break;
      case ZOOM_DOWN   : box = DEBUG_NEW DBbox(    lp_BL.x()               , // down
                                                (  lp_TR.y() + lp_BL.y())/2,
                                                   lp_TR.x()               ,
                                                (3*lp_TR.y() - lp_BL.y())/2);
                        break;
      case ZOOM_EMPTY  : box = DEBUG_NEW DBbox(-10,-10,90,90);
                        break;
      case ZOOM_REFRESH: invalid_window = true; Refresh(); return;
      default: assert(false);
   }
   int Wcl, Hcl;
   GetClientSize(&Wcl,&Hcl);
   // To prevent a loss of precision in the following lines - don't use
   // integer variables (Wcl & Hcl) directly
   double W = Wcl;
   double H = Hcl;
   double w = abs(box->p1().x() - box->p2().x());
   double h = abs(box->p1().y() - box->p2().y());
   double sc =  ((W/H < w/h) ? w/W : h/H);
   double tx = ((box->p1().x() + box->p2().x()) - W*sc) / 2;
   double ty = ((box->p1().y() + box->p2().y()) - H*sc) / 2;
   _LayCTM.setCTM( sc, 0.0, 0.0, sc, tx, ty);
   _LayCTM.FlipX((box->p1().y() + box->p2().y())/2);  // flip Y coord towards the center
   DATC->setScrCTM(_LayCTM.Reversed());
   delete box;
   invalid_window = true;
   Refresh();
}
Example #21
0
void SvnCommand::OnProcessTerminated(wxCommandEvent& event)
{
	ProcessEventData *ped = (ProcessEventData*)event.GetClientData();
	if( ped ) {
		delete ped;
	}

	if (m_handler) {

		if(m_handler->TestLoginRequired(m_output)) {
			// re-issue the last command but this time with login dialog
			m_handler->GetPlugin()->GetConsole()->AppendText(wxT("Authentication failed. Retrying...\n"));
			m_handler->ProcessLoginRequired(m_workingDirectory);

		} else if(m_handler->TestVerificationFailed(m_output)) {
			m_handler->GetPlugin()->GetConsole()->AppendText(wxT("Server certificate verification failed. Retrying...\n"));
			m_handler->ProcessVerificationRequired();

		} else {
			// command ended successfully, invoke the "success" callback
			m_handler->Process(m_output);
		}

		delete m_handler;
		m_handler = NULL;
	}

	if (m_process) {
		delete m_process;
		m_process = NULL;
	}
}
Example #22
0
void clCommandProcessor::OnProcessTerminated(wxCommandEvent& event)
{
    ProcessEventData* ped = (ProcessEventData*)event.GetClientData();
    wxDELETE(ped);
    if(m_obj && m_postExecCallback) {
        // Call the user callback, if the user returns false
        // stop the processor
        if(!(m_obj->*m_postExecCallback)(this)) {
            clCommandEvent eventEnd(wxEVT_COMMAND_PROCESSOR_ENDED);
            GetFirst()->ProcessEvent(eventEnd);
            DeleteChain();
            return;
        }
    }

    if(m_next) {
        wxDELETE(m_process);
        // more commands, don't report an 'END' event
        m_next->ExecuteCommand();

    } else {
        // no more commands to execute, delete the entire chain
        clCommandEvent eventEnd(wxEVT_COMMAND_PROCESSOR_ENDED);
        GetFirst()->ProcessEvent(eventEnd);
        DeleteChain();
    }
}
void WindowLevelToolPanel::OnWindowLevelToolChange( wxCommandEvent& event )
{
  WindowLevelToolChangeStruct *info =
    (WindowLevelToolChangeStruct *)event.GetClientData();

  minval_ = info->minval;
  maxval_ = info->maxval;
  mMinValue->Clear(); *mMinValue << info->minval;
  mMaxValue->Clear(); *mMaxValue << info->maxval;
  mWindowValue->Clear(); *mWindowValue << info->window;
  mLevelValue->Clear(); *mLevelValue << info->level;

  // Update the slider
  double window = (info->window) / (maxval_ - minval_);
  if (window < 0.0) window = 0.0;
  if (window > 1.0) window = 1.0;
  mWindowSlider->SetValue((int)(1000.0 * window));

  double level = (info->level - minval_) / (maxval_ - minval_);
  if (level < 0.0) level = 0.0;
  if (level > 1.0) level = 1.0;
  mLevelSlider->SetValue((int)(1000.0 * level));

#ifndef _WIN32
  if( info->histogram.size() == nbins_ ) {
    histogram_ = info->histogram;
    CreateHistogramImage();
  }
#endif
  delete info;
}
Example #24
0
void PlaylistManager::AppendItem( wxCommandEvent& event )
{
    playlist_add_t *p_add = (playlist_add_t *)event.GetClientData();
    playlist_item_t *p_item = NULL;
    wxTreeItemId item, node;

    i_items_to_append--;

    /* No need to do anything if the playlist is going to be rebuilt */
    if( b_need_update ) return;

    //if( p_add->i_view != i_current_view ) goto update;

    node = FindItem( treectrl->GetRootItem(), p_add->i_node );
    if( !node.IsOk() ) goto update;

    p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
    if( !p_item ) goto update;

    item = FindItem( treectrl->GetRootItem(), p_add->i_item );
    if( item.IsOk() ) goto update;

    item = treectrl->AppendItem( node, wxL2U( p_item->input.psz_name ), -1,-1,
                                 new PlaylistItem( p_item ) );
    treectrl->SetItemImage( item, p_item->input.i_type );

    if( item.IsOk() && p_item->i_children == -1 ) UpdateTreeItem( item );

update:
    return;
}
Example #25
0
void CompareDlg::OnEditInCurrentDB(wxCommandEvent& evt)
{
  ContextMenuData* menuContext = reinterpret_cast<ContextMenuData*>(evt.GetClientData());
  const ComparisonGridTable& table = *wxDynamicCast(menuContext->cdata->grid->GetTable(), ComparisonGridTable);
  const pws_os::CUUID& uuid = table[menuContext->selectedRows[0]].uuid0;
  if (ViewEditEntry(m_currentCore, uuid, false)) {
    int idx = menuContext->selectedRows[0];
    if (menuContext->cdata == m_conflicts)
      idx = idx/2;
    ItemListIter itr = m_currentCore->Find(uuid);
    if (itr != m_currentCore->GetEntryEndIter()) {
      const CItemData& item = itr->second;
      //we update these in the grid directly from st_CompareData, so keep track
      if (item.IsGroupSet())
        menuContext->cdata->data[idx].group = item.GetGroup();
      else
        menuContext->cdata->data[idx].group.clear();
      if (item.IsTitleSet())
        menuContext->cdata->data[idx].title = item.GetTitle();
      else
        menuContext->cdata->data[idx].title.clear();
      if (item.IsUserSet())
        menuContext->cdata->data[idx].user = item.GetUser();
      else
        menuContext->cdata->data[idx].user.clear();
      table.RefreshRow(table.GetItemRow(uuid));
    }
    else {
      wxFAIL_MSG(wxT("Could not find entry in core after editing it"));
    }
  }
}
Example #26
0
/**
 * @function OnSlider
 * @brief Handle slider changes
 */
void PlannerTab::OnSlider(wxCommandEvent &evt) {

    /*
    if ( selectedTreeNode == NULL ) {
        return;
    } */ /// Do I need this now? - AHQ: Dec 6th, 2012

    int slnum = evt.GetId();
    double pos = *(double*) evt.GetClientData();
    char numBuf[1000];

    switch (slnum) {

    case slider_Alpha:
      mAlpha = pos;
      break;

    case slider_NumPaths:
      mNumPaths = (int) pos;
      break;
      
    default:
      return;
    }

    //world->updateCollision(o);
    //viewer->UpdateCamera();

    if (frame != NULL)
        frame->SetStatusText(wxString(numBuf, wxConvUTF8));
}
Example #27
0
void CompareDlg::OnCopyFieldsToCurrentDB(wxCommandEvent& evt)
{
  ContextMenuData* menuContext = reinterpret_cast<ContextMenuData*>(evt.GetClientData());
  wxCHECK_RET(menuContext, wxT("No menu context available"));
  ComparisonGridTable* ptable = wxDynamicCast(menuContext->cdata->grid->GetTable(), ComparisonGridTable);
  wxCHECK_RET(ptable, wxT("Could not find ComparisonGridTable derived object in comparison grid"));
  const ComparisonGridTable& table = *ptable;
  MultiCommandsPtr pmulticmds(MultiCommands::Create(m_currentCore));
  for( size_t idx = 0; idx < menuContext->selectedRows.Count(); ++idx) {
    const int row = menuContext->selectedRows[idx];
    ItemListIter itrOther = m_otherCore->Find(table[row].uuid1);
    wxCHECK_RET( itrOther != m_otherCore->GetEntryEndIter(), wxT("Could not find item to be modified in current core"));
    const CItemData& otherItem = itrOther->second;
    ItemListIter itrCurrent = m_currentCore->Find(table[row].uuid0);
    wxCHECK_RET(itrCurrent != m_currentCore->GetEntryEndIter(), wxT("Could not find item to be modified in current core"));
    const CItemData& currentItem = itrCurrent->second;
    UpdateEntryCommand* cmd = UpdateEntryCommand::Create(m_currentCore, currentItem,
                                                        menuContext->field,
                                                        otherItem.GetFieldValue(menuContext->field));
    pmulticmds->Add(cmd);
  }
  if (pmulticmds->GetSize() > 0) {
    m_currentCore->Execute(pmulticmds.release());
    for( size_t idx = 0; idx < menuContext->selectedRows.Count(); ++idx) {
      //refresh the row just above the selected one
      table.RefreshRow(menuContext->selectedRows[idx]-1);
    }
  }
}
Example #28
0
void DebuggerPanel::HandleCommand(wxCommandEvent& event)
{
	PPCThread* thr = (PPCThread*)event.GetClientData();

	switch(event.GetId())
	{
	case DID_CREATE_THREAD:
		m_nb->AddPage(new InterpreterDisAsmFrame(m_nb, thr), thr->GetFName());
	break;

	case DID_REMOVE_THREAD:
		for(uint i=0; i<m_nb->GetPageCount(); ++i)
		{
			InterpreterDisAsmFrame* page = (InterpreterDisAsmFrame*)m_nb->GetPage(i);

			if(page->CPU.GetId() == thr->GetId())
			{
				m_nb->DeletePage(i);
				break;
			}
		}
	break;
	}

	event.Skip();
}
Example #29
0
void RenderCanvas::OnNewPixel( wxCommandEvent& event )
{
   //set up double buffered device context
   wxClientDC cdc(this);
   DoPrepareDC(cdc);
   wxBufferedDC bufferedDC(&cdc, *m_image);
   
   //iterate over all pixels in the event
   vector<RenderPixel*> *pixelsUpdate =
                        (vector<RenderPixel*> *)event.GetClientData();
   
   for(vector<RenderPixel*>::iterator itr = pixelsUpdate->begin();
                        itr != pixelsUpdate->end(); itr++)
   {
      RenderPixel* pixel = *itr;
      
      wxPen pen(wxColour(pixel->red, pixel->green, pixel->blue));
      bufferedDC.SetPen(pen);
      bufferedDC.DrawPoint(pixel->x, pixel->y);
     
      pixelsRendered++;
      delete pixel;
   }
   
   pixelsUpdate->clear();
   delete pixelsUpdate;
}
Example #30
0
void QMakePlugin::OnOpenFile(wxCommandEvent &event)
{
    wxString *fn = (wxString*)event.GetClientData();
    if ( fn ) {
        // launch it with the default application
        wxFileName fullpath ( *fn );
        if ( fullpath.GetExt().MakeLower() != wxT("ui") ) {
            event.Skip();
            return;
        }

        wxMimeTypesManager *mgr = wxTheMimeTypesManager;
        wxFileType *type = mgr->GetFileTypeFromExtension(fullpath.GetExt());
        if ( type ) {
            wxString cmd = type->GetOpenCommand(fullpath.GetFullPath());
            delete type;

            if ( cmd.IsEmpty() == false ) {
                wxExecute(cmd);
                return;
            }
        }
    }
    // we failed, call event.Skip()
    event.Skip();
}