Exemplo n.º 1
0
void tui::LayoutCanvas::OnMouseIN(wxCommandEvent& evt)
{
   wxCommandEvent eventABORTEN(wxEVT_CANVAS_STATUS);
   if (1 == evt.GetExtraLong())
   { // start mouse input
      mouse_input = true;
      console::ACTIVE_OP actop;
      if (evt.GetInt() > 0) actop = console::op_dwire;
      else                  actop = (console::ACTIVE_OP)evt.GetInt();
      DATC->setCurrentOp(actop);
      //restricted_move will be true for wire and polygon
      restricted_move = (DATC->marker_angle() != 0) &&
            ((actop > 0) || (actop == console::op_dpoly));
      eventABORTEN.SetInt(CNVS_ABORTENABLE);
      reperX = (console::op_flipX == actop) || (long_cursor && (console::op_flipY != actop));
      reperY = (console::op_flipY == actop) || (long_cursor && (console::op_flipX != actop));
      if (  (console::op_flipX  == actop)
          ||(console::op_flipY  == actop)
          ||(console::op_rotate == actop)
          ||(console::op_cbind  == actop)
          ||(console::op_abind  == actop)
          ||(console::op_tbind  == actop) )
         rubber_band = true;
      releasepoint = TP(0,0);
   }
   else
   { // stop mouse input
      mouse_input = false;
      rubber_band = false;
      restricted_move = false;
      reperX = long_cursor;
      reperY = long_cursor;
      DATC->setCurrentOp(console::op_none);
      wxCommandEvent eventPOSITION(wxEVT_CANVAS_STATUS);
      eventPOSITION.SetString(wxT(""));
      eventPOSITION.SetInt(CNVS_DEL_Y);
      wxPostEvent(this, eventPOSITION);
      eventPOSITION.SetInt(CNVS_DEL_X);
      wxPostEvent(this, eventPOSITION);
      eventABORTEN.SetInt(CNVS_ABORTDISABLE);
   }
   wxPostEvent(this, eventABORTEN);
}
Exemplo n.º 2
0
void tui::LayoutCanvas::OnMouseIN(wxCommandEvent& evt) {
   wxCommandEvent eventABORTEN(wxEVT_CNVSSTATUSLINE);
   if (1 == evt.GetExtraLong()) {
      mouse_input = true;
      Properties->setCurrentOp(evt.GetInt());
      restricted_move = (Properties->marker_angle() != 0) && 
                              ((evt.GetInt() > 0) || (evt.GetInt() == -1));
      eventABORTEN.SetInt(STS_ABORTENABLE);
   }
   else {
      mouse_input = false;
      rubber_band = false;
      restricted_move = false;
      Properties->setCurrentOp(layprop::op_none);
      wxCommandEvent eventPOSITION(wxEVT_MARKERPOSITION);
      eventPOSITION.SetString(wxT(""));
      eventPOSITION.SetInt(DEL_Y);
      wxPostEvent(this, eventPOSITION);
      eventPOSITION.SetInt(DEL_X);
      wxPostEvent(this, eventPOSITION);
      eventABORTEN.SetInt(STS_ABORTDISABLE);
   }
   wxPostEvent(this, eventABORTEN);
}
Exemplo n.º 3
0
void browsers::LayerPanel::OnCommand(wxCommandEvent& event)
{
   int command = event.GetInt();
   
   switch (command) 
   {

      case BT_LAYER_DEFAULT:
         {
            word *oldlay = static_cast<word*>(event.GetClientData());
            word layno = event.GetExtraLong();
            _buttonMap[*oldlay]->unselect();
            _buttonMap[layno]->select();
            //_layerlist->defaultLayer((word)event.GetExtraLong(), (word)event.GetInt());
				delete (static_cast<word*>(oldlay));
            break;
         }
      case    BT_LAYER_HIDE:
         {
            word *layno = static_cast<word*>(event.GetClientData());
            bool status = event.GetExtraLong();
            //_buttonMap[layno]->hideLayer(event.IsChecked());
            _buttonMap[*layno]->hideLayer(status);
				delete (static_cast<word*>(layno));
            break;
         }
         //_layerlist->hideLayer((word)event.GetExtraLong(),event.IsChecked());break;
      case    BT_LAYER_LOCK:
         {
            //_layerlist->lockLayer((word)event.GetExtraLong(),event.IsChecked());
            word *layno = static_cast<word*>(event.GetClientData());
            bool status = event.GetExtraLong();
            _buttonMap[*layno]->lockLayer(status);
				delete (static_cast<word*>(layno));
            break;
         }
      case     BT_LAYER_SELECT:
         {
            word layno = event.GetExtraLong();
            _selectedButton->unselect();
            _selectedButton = _buttonMap[layno];
         
            break;
         }

      case     BT_LAYER_ADD:
         {
            LayerInfo* layer = static_cast<LayerInfo*>(event.GetClientData());

            LayerButton *layerButton;
				
            layerButtonMap::iterator it;
				int szx, szy;

            //Remove selection from current button
            if (_selectedButton!=NULL) _selectedButton->unselect();

            it = _buttonMap.find(layer->layno());
            if (it!= _buttonMap.end())
            {
               //Button already exists, replace it
               LayerButton *tempButton = it->second;
               
               //layerButton = DEBUG_NEW LayerButton(this, tui::TMDUMMY_LAYER+_buttonCount, wxPoint (0, _buttonCount*30), wxSize(200, 30),
               //wxBU_AUTODRAW, wxDefaultValidator, _T("TTT"), layer);
               int x, y;
               
               int ID;
               tempButton->GetPosition(&x, &y);
               tempButton->GetSize(&szx, &szy);
               ID = tempButton->GetId();
               layerButton = DEBUG_NEW LayerButton(this, ID, wxPoint (x, y), wxSize(szx, szy),
               wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("button"), layer);
               _buttonMap[layer->layno()] = layerButton;
               delete tempButton;

            }
            else
            {
               //Button doesn't exist, create new button
//               int szx, szy;
					GetClientSize(&szx, &szy);
               layerButton = DEBUG_NEW LayerButton(this, tui::TMDUMMY_LAYER+_buttonCount,
                                             wxPoint (0, _buttonCount*buttonHeight), wxSize(szx, buttonHeight),
               wxBU_AUTODRAW, wxDefaultValidator, _T("button"), layer);
               _buttonMap[layer->layno()] = layerButton;

               _buttonCount++; 
               this->SetScrollbars(0, buttonHeight, 0, _buttonCount);
            }
            
            //Restore selection
            if ((it = _buttonMap.find(DATC->curlay()))!= _buttonMap.end())
            {
               _selectedButton = it->second;
               _selectedButton->select();
            }
            //_selectedButton = (_buttonMap.begin())->second;
            //_selectedButton->select();
				delete (static_cast<LayerInfo*>(layer));
            break;
         }
   }
}
Exemplo n.º 4
0
void wxListBoxBase::Command(wxCommandEvent& event)
{
    SetSelection(event.GetInt(), event.GetExtraLong() != 0);
    (void)GetEventHandler()->ProcessEvent(event);
}
Exemplo n.º 5
0
void
TreeviewSample::OnFolderChanged( wxCommandEvent& event )
{
  m_activeFolder = (int) event.GetExtraLong();
  RefreshProjectList();
}
Exemplo n.º 6
0
void logevt_handler::OnThreadLogMsg(wxCommandEvent &event) {
	LogMsg(flag_wrap<LOGT>(event.GetExtraLong()), stdstrwx(event.GetString()));
}
Exemplo n.º 7
0
void ctrlUpdate::eventThreadMessage( wxCommandEvent &event )
{
	int write_pointer,checksum16;
	unsigned long intflash_blocksize,max_intflash_blocknumber,extflash_blocksize,max_extflash_blocknumber;
	int block_number;
	int i = event.GetInt();
	int id = i & 0xFFFF;
	int type = (i >> 16) & 0xFFFF;
	CDeviceNode* pNode = m_plistNode->GetNodeByNickName(id);
	wxString strData = event.GetString();
	vscpEvent* pVscp = new vscpEvent;
	getVscpDataFromString( pVscp, strData );

	if(pNode != NULL)
	{
		if(event.GetExtraLong()==0)
		{
			switch(type)
			{
				case VSCP_TYPE_PROTOCOL_ACK_BOOT_LOADER:
					// pVscp->pdata[ 0 ] = 2;	MSB internal flash block size
					// pVscp->pdata[ 1 ] = 2;	MSB spi flash block size
					// pVscp->pdata[ 2 ] = 0;	LSB spi flash block size
					// pVscp->pdata[ 3 ] = 0;	LSB internal flash block size
					// pVscp->pdata[ 4 ] = 1;	MSB internal flash number of block avalaible
					// pVscp->pdata[ 5 ] = 4;	MSB spi flash number of block avalaible
					// pVscp->pdata[ 6 ] = 0;	LSB spi flash number of block avalaible
					// pVscp->pdata[ 7 ] = 0;	LSB internal flash number of block avalaible
					intflash_blocksize = (pVscp->pdata[0] << 8) | pVscp->pdata[3];
					extflash_blocksize = (pVscp->pdata[1] << 8) | pVscp->pdata[2];
					max_intflash_blocknumber = (pVscp->pdata[4] << 8) | pVscp->pdata[7];
					max_extflash_blocknumber = (pVscp->pdata[5] << 8) | pVscp->pdata[6];

					if((intflash_blocksize == BLOCKDATA_SIZE)	&&
				       (extflash_blocksize == BLOCKDATA_SIZE)	&&
					   (max_intflash_blocknumber >= (m_IntFlashBinaryLength/BLOCKDATA_SIZE))&&
					   (max_extflash_blocknumber >= (m_ExtFlashBinaryLength/BLOCKDATA_SIZE))
					  )
					{
						crcInit();
						m_nTotalChecksum = 0;
						m_nCurrentBlockNumber = 0;
						m_nCurrentFlashType = INT_FLASH;	// internal flash
						// attenzione: questo messaggio (VSCP_TYPE_PROTOCOL_ACK_BOOT_LOADER) è l'ultimo arrivato dal 
						// programma user, ora ha preso il controllo il bootloader; è probabile che sia necessario
						// un delay prima di trasmettere il messaggio di "start block transfer"
						wxMilliSleep( 2000 );//wxMilliSleep( 500 );//wxMilliSleep( 200 );
						StartBlockTransferMsg( pNode->GetNickName(), m_nCurrentBlockNumber, m_nCurrentFlashType );
					}
					else
					{
						UpdateError(pNode);
					}

					//::wxGetApp().logMsg ( _("event ack bootloader"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_START_BLOCK_ACK:
					// pVscp->pdata[0] MSB block number
					// pVscp->pdata[1] INTERNAL_FLASH/SPI_FLASH
					// pVscp->pdata[2]
					// pVscp->pdata[3] LSB block number
					if(m_nCurrentFlashType == pVscp->pdata[1])
					{
						switch(m_nCurrentFlashType)
						{
							case INT_FLASH:
								DataBlockTransferMsg();
								m_nChecksum = crcFast( &m_pIntFlashBinaryContent[USER_PROGRAM_ADDRESS + m_nCurrentBlockNumber*BLOCKDATA_SIZE], BLOCKDATA_SIZE );//crcFast( &m_pIntFlashBinaryContent[30208], BLOCKDATA_SIZE );//crcFast( &m_pIntFlashBinaryContent[USER_PROGRAM_ADDRESS + m_nCurrentBlockNumber*BLOCKDATA_SIZE], BLOCKDATA_SIZE );
								//m_nTotalChecksum += m_nChecksum;
								break;
							case EXT_FLASH:

								DataBlockTransferMsg();
								m_nChecksum = crcFast( &m_pExtFlashBinaryContent[m_nCurrentBlockNumber*BLOCKDATA_SIZE], BLOCKDATA_SIZE );
								break;
						}
					}
					else
					{
						UpdateError(pNode);
					}
					//::wxGetApp().logMsg ( _("event ack data block"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK:
					// pVscp->pdata[0] = (checksum16 >> 8) & 0xFF;		MSB 16 bit CRC for block
					// pVscp->pdata[1] = checksum16 & 0xFF;				LSB 16 bit CRC for block
					// pVscp->pdata[2] = (write_pointer >> 8) & 0xFF;	MSB of block number 
					// pVscp->pdata[3] = 0;
					// pVscp->pdata[4] = 0;
					// pVscp->pdata[5] = write_pointer & 0xFF;			LSB of block number
					checksum16 = (pVscp->pdata[0] << 8) | pVscp->pdata[1];
					write_pointer = (pVscp->pdata[2] << 8) | pVscp->pdata[5];
					if((checksum16 == m_nChecksum) && (write_pointer == m_nCurrentBlockNumber))
						BlockProgramMsg( m_nCurrentBlockNumber, m_nCurrentFlashType );
					else
					{
						// in questo caso di errore si ritrasmette il blocco
						StartBlockTransferMsg( pNode->GetNickName(), m_nCurrentBlockNumber, m_nCurrentFlashType );
						//UpdateError(pNode);
					}

					//::wxGetApp().logMsg ( _("event ack data block"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK:
					// pVscp->pdata[0] MSB block number
					// pVscp->pdata[1] INTERNAL_FLASH/SPI_FLASH
					// pVscp->pdata[2]
					// pVscp->pdata[3] LSB block number
					block_number = (pVscp->pdata[0] << 8) | pVscp->pdata[3];
					if((block_number == m_nCurrentBlockNumber) && (pVscp->pdata[1] == m_nCurrentFlashType))
					{
						switch(m_nCurrentFlashType)
						{
							case INT_FLASH:
								m_nCurrentBlockNumber++;
								//::wxGetApp().logMsg ( _("event PROGRAM ACK"), DAEMON_LOGMSG_CRITICAL );
								m_nTotalChecksum += m_nChecksum;
								if(m_nCurrentBlockNumber == (int)((m_IntFlashBinaryLength - USER_PROGRAM_ADDRESS)/BLOCKDATA_SIZE))
								{
									m_nCurrentBlockNumber = 0;
									m_nCurrentFlashType = EXT_FLASH;
									
							//ActivateNewImageMsg();	// DEBUG!!
								}
							//else // DEBUG!!
							//{// DEBUG!!
								// avanzamento progress control della dialog
								pNode->FirmwareProgressStep();
								wxGetApp().Yield();
								StartBlockTransferMsg( pNode->GetNickName(), m_nCurrentBlockNumber, m_nCurrentFlashType );
							//}// DEBUG!!
								break;
							case EXT_FLASH:
								m_nCurrentBlockNumber++;
								if(m_nCurrentBlockNumber == (int)(m_ExtFlashBinaryLength/BLOCKDATA_SIZE))
								{
									ActivateNewImageMsg();
								}
								else
								{
									// avanzamento progress control della dialog
									pNode->FirmwareProgressStep();
									wxGetApp().Yield();
									StartBlockTransferMsg( pNode->GetNickName(), m_nCurrentBlockNumber, m_nCurrentFlashType );
								}
								break;
						}
					}
					else
					{
						UpdateError(pNode);
					}

					//::wxGetApp().logMsg ( _("event ack program block"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_ACTIVATENEWIMAGE_ACK:
					// delay per attendere che il nodo remoto abbia finito la fase di 
					// inizializzazione altrimenti quando l'utente chiude la dialog di update
					// c'e' il rischio che il gestore dell' heartbeat non rilevi il nuovo stato (stato user)
					// del nodo
					wxMilliSleep( 8000 );

					m_tDoneUpgrade = wxDateTime::Now();
					::wxGetApp().logMsg ( wxT("Upgrade Finished... taking: ") + (m_tDoneUpgrade - m_tStartUpgrade).Format(), DAEMON_LOGMSG_CRITICAL );

					// avvisa la dialog che è finito il processo di update
					pNode->EndFirmwareProgress(FIRMWAREUPDATEOK);
					break;

				case VSCP_TYPE_PROTOCOL_NACK_BOOT_LOADER:
					UpdateError(pNode);
					::wxGetApp().logMsg ( _("event NACK bootloader"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_START_BLOCK_NACK:
					UpdateError(pNode);
					::wxGetApp().logMsg ( _("event NACK start block"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_BLOCK_DATA_NACK:
					UpdateError(pNode);
					::wxGetApp().logMsg ( _("event NACK data block"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_NACK:
					UpdateError(pNode);
					::wxGetApp().logMsg ( _("event NACK program block"), DAEMON_LOGMSG_CRITICAL );
					break;
				case VSCP_TYPE_PROTOCOL_ACTIVATENEWIMAGE_NACK:
					UpdateError(pNode);
					::wxGetApp().logMsg ( _("event NACK activate new image"), DAEMON_LOGMSG_CRITICAL );
					break;
			}
		}
		else
		{
			UpdateError(pNode);
		}
	}

	deleteVSCPevent( pVscp );
}
Exemplo n.º 8
0
//------------------------------------------------------------------//
//--- an progress thread event was caught, figure out what to do ---//
//------------------------------------------------------------------//
void MusikTagFrame::OnTagThreadProg( wxCommandEvent& event )
{
	gProgress->SetValue( event.GetExtraLong() );
}