示例#1
0
bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
                                             wxWindow *WXUNUSED(parentWindow))
{
    // The item used for viewing the real number: should be a text item or a slider
    wxWindow *m_propertyWindow = property->GetWindow();
    if (!m_propertyWindow)
        return false;

    if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
    {
        wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());

        if (value.Length() == 0)
            return false;

        long i = wxAtol((const wxChar *)value);
        property->GetValue() = i;
    }
    else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))
    {
        property->GetValue() = (long)((wxSlider *)m_propertyWindow)->GetValue();
    }
    else
        return false;

    return true;
}
示例#2
0
bool ecRunOptionsDialog::TransferDataFromWindow()
{
    wxPanel::TransferDataFromWindow();

    if (m_downloadTimeoutString == _("None"))
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_NONE;
    else if (m_downloadTimeoutString == _("Specified"))
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_SPECIFIED;
    else
        wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType = TIMEOUT_AUTOMATIC;

    if (m_runtimeTimeoutString == _("None"))
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_NONE;
    else if (m_runtimeTimeoutString == _("Specified"))
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_SPECIFIED;
    else
        wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType = TIMEOUT_AUTOMATIC;

    wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud = (int) wxAtol(m_baudString);

    // Serial/TCPIP
    wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial = m_serialOn;

    return TRUE;
}
示例#3
0
bool wxFileConfig::Read(const wxString& key, long *pl) const
{
  wxString str;
  if ( !Read(key, & str) )
  {
    return FALSE;
  }

  *pl = wxAtol(str);
  return TRUE;
}
示例#4
0
bool XmlTestParser::LoadTest(lc3_test_suite& suite, wxXmlNode* root)
{
    wxXmlNode* child = root->GetChildren();

    lc3_test test;

    test.has_halted = false;
    test.executions = 0;
    test.has_max_executions = false;
    test.has_disable_plugins = false;
    test.disable_plugins = false;
    test.max_executions = 0;
    test.passed = false;
    test.randomize = false;
    test.true_traps = false;
    test.interrupt_enabled = false;
    test.warnings = false;
    test.points = 0;
    test.max_points = 0;

    while(child)
    {
        if (child->GetName() == "name")
            test.name = child->GetNodeContent();
        else if (child->GetName() == "true-traps")
            test.true_traps = wxAtoi(child->GetNodeContent()) != 0;
        else if (child->GetName() == "has-max-executions")
            test.has_max_executions = wxAtoi(child->GetNodeContent()) != 0;
        else if (child->GetName() == "has-disable-plugins")
            test.has_disable_plugins = wxAtoi(child->GetNodeContent()) != 0;
        else if (child->GetName() == "disable-plugins")
            test.disable_plugins = wxAtoi(child->GetNodeContent()) != 0;
        else if (child->GetName() == "max-executions")
            test.max_executions = wxAtol(child->GetNodeContent());
        else if (child->GetName() == "randomize")
            test.randomize = wxAtoi(child->GetNodeContent()) != 0;
        else if (child->GetName() == "interrupt-enabled")
            test.interrupt_enabled = wxAtoi(child->GetNodeContent()) != 0;
        else if (child->GetName() == "input")
        {
            if (!LoadTestInput(test, child)) throw "test-input improperly formatted";
        }
        else if (child->GetName() == "output")
        {
            if (!LoadTestOutput(test, child)) throw "test-output improperly formatted";
        }

        child = getNextNode(child);
    }

    suite.tests.push_back(test);
    return true;
}
示例#5
0
void VAutoDialog::DoInvokeOptionsDialog(void)
{
	wxString mountType = Properties::Instance().Get(MOUNT_TYPE);
	wxString mountPort = Properties::Instance().Get(MOUNT_PORT);
	wxString cameraType = Properties::Instance().Get(CAMERA_TYPE);
	wxString cameraPort = Properties::Instance().Get(CAMERA_PORT);
	wxString observationLogPath = Properties::Instance().Get (OBSERVATION_LOG_FOLDER);
	wxString isoSpeed = Properties::Instance().Get (CAMERA_ISO_SPEED);

	OptionsDialog *dlg = new OptionsDialog (this);
	int rv = dlg->ShowModal ();
	if (rv == wxID_OK) {
		Properties::Instance().Save(CONFIG_FILE);

		if (Properties::Instance().Get(MOUNT_TYPE) != mountType ||
			Properties::Instance().Get(MOUNT_PORT) != mountPort) {
			TelescopeFactory::Instance().ClearTelescope();
			m_telescope = TelescopeFactory::Instance().GetTelescope (
				Properties::Instance().Get(MOUNT_TYPE),
				Properties::Instance().Get(MOUNT_PORT));
			}

		bool newCamera = false;
		if (Properties::Instance().Get(CAMERA_TYPE) != cameraType ||
			Properties::Instance().Get(CAMERA_PORT) != cameraPort) {
//			CameraFactory::Instance().ClearCamera();
			wxDELETE (m_camera);
			m_camera = CameraFactory::Instance().GetCamera (
				Properties::Instance().Get(CAMERA_TYPE),
				Properties::Instance().Get(CAMERA_PORT));
			newCamera = true;
			}

		if (Properties::Instance().Get (OBSERVATION_LOG_FOLDER) != observationLogPath) {
			ObservationLog::Instance().SetPath (Properties::Instance().Get (OBSERVATION_LOG_FOLDER));
			}

		if (m_camera->HasFeature (Camera::DCP_CAN_SET_ISO_SPEED) && (newCamera || Properties::Instance().Get(CAMERA_ISO_SPEED) != isoSpeed)) {
			unsigned long iso = wxAtol (Properties::Instance().Get(CAMERA_ISO_SPEED));
			if (iso > 0)
				m_camera->SetIsoSpeed (iso);
			}

		SetDeviceText ();

		DoDisableControls (FALSE);

		m_LogWindow->Show (Properties::Instance().GetBool(DEBUG_LOG_WINDOW));
		}
}
void NetBuilderConnectivity_frame::Onbtn_conn_OKClick( wxCommandEvent& event )
{	
  MainFrame *myparent=(MainFrame *) GetParent();
  int error = 0;
  long val=0;
  for (unsigned int i=0; i<total_populations; i++)
  {   
     for (unsigned int j=0; j<total_populations; j++)
      { 
	if((conn_grid->GetCellValue(i,j)).ToLong(&val,10)==false)
	    {
	      myparent->text_status->SetForegroundColour( wxColour( 247, 22, 10 ) );
	      wxLogMessage(wxT(">> WARNING: connectivity value of population") +  wxString::Format(wxT("%i"),j) + wxT(" is invalid"));
	      myparent->text_status->SetForegroundColour( wxColour( 0, 0, 0 ) );
	      conn_values[i][j] = 0;
	      error=-1;
	    }
	else
	  {
	  conn_values[i][j]=wxAtol(conn_grid->GetCellValue(i,j));
	  }
      }
  }
  
  if (error == 0){ 
      myparent->Enable(true);
      this->Close();
      myparent->btn_conn_fdms->Enable( true );
      myparent->btn_conn_distributions->Enable( true );
      myparent->btn_syn_delays->Enable( true );
      myparent->btn_syn_conductances->Enable( true );
      myparent->btn_syn_plasticity->Enable( true );
      myparent->btn_createnet->Enable( true );
      wxLogMessage(wxT(">> Connectivity values (re)inserted."));
      if (summary_show==true)
	  {
	  Summary->Destroy();
	  Summary = new NetBuilderSummary_frame(this);
	  Summary->Show(true);
	  summary_show=true;
	  }
 }
}
示例#7
0
bool wxSpinCtrl::Create(wxWindow *parent,
                        wxWindowID id,
                        const wxString& value,
                        const wxPoint& pos,
                        const wxSize& size,
                        long style,
                        int min, int max, int initial,
                        const wxString& name)
{
    // this should be in ctor/init function but I don't want to add one to 2.8
    // to avoid problems with default ctor which can be inlined in the user
    // code and so might not get this fix without recompilation
    m_oldValue = INT_MIN;

    // before using DoGetBestSize(), have to set style to let the base class
    // know whether this is a horizontal or vertical control (we're always
    // vertical)
    style |= wxSP_VERTICAL;

    if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
#ifdef __WXWINCE__
        style |= wxBORDER_SIMPLE;
#else
        style |= wxBORDER_SUNKEN;
#endif

    SetWindowStyle(style);

    WXDWORD exStyle = 0;
    WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;

    // calculate the sizes: the size given is the toal size for both controls
    // and we need to fit them both in the given width (height is the same)
    wxSize sizeText(size), sizeBtn(size);
    sizeBtn.x = wxSpinButton::DoGetBestSize().x;
    if ( sizeText.x <= 0 )
    {
        // DEFAULT_ITEM_WIDTH is the default width for the text control
        sizeText.x = DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN + sizeBtn.x;
    }

    sizeText.x -= sizeBtn.x + MARGIN_BETWEEN;
    if ( sizeText.x <= 0 )
    {
        wxLogDebug(_T("not enough space for wxSpinCtrl!"));
    }

    wxPoint posBtn(pos);
    posBtn.x += sizeText.x + MARGIN_BETWEEN;

    // we must create the text control before the spin button for the purpose
    // of the dialog navigation: if there is a static text just before the spin
    // control, activating it by Alt-letter should give focus to the text
    // control, not the spin and the dialog navigation code will give focus to
    // the next control (at Windows level), not the one after it

    // create the text window

    m_hwndBuddy = (WXHWND)::CreateWindowEx
                    (
                     exStyle,                // sunken border
                     _T("EDIT"),             // window class
                     NULL,                   // no window title
                     msStyle,                // style (will be shown later)
                     pos.x, pos.y,           // position
                     0, 0,                   // size (will be set later)
                     GetHwndOf(parent),      // parent
                     (HMENU)-1,              // control id
                     wxGetInstance(),        // app instance
                     NULL                    // unused client data
                    );

    if ( !m_hwndBuddy )
    {
        wxLogLastError(wxT("CreateWindow(buddy text window)"));

        return false;
    }


    // create the spin button
    if ( !wxSpinButton::Create(parent, id, posBtn, sizeBtn, style, name) )
    {
        return false;
    }

    wxSpinButtonBase::SetRange(min, max);

    // subclass the text ctrl to be able to intercept some events
    wxSetWindowUserData(GetBuddyHwnd(), this);
    m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(),
                                                wxBuddyTextWndProc);

    // set up fonts and colours  (This is nomally done in MSWCreateControl)
    InheritAttributes();
    if (!m_hasFont)
        SetFont(GetDefaultAttributes().font);

    // set the size of the text window - can do it only now, because we
    // couldn't call DoGetBestSize() before as font wasn't set
    if ( sizeText.y <= 0 )
    {
        int cx, cy;
        wxGetCharSize(GetHWND(), &cx, &cy, GetFont());

        sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
    }

    SetInitialSize(size);

    (void)::ShowWindow(GetBuddyHwnd(), SW_SHOW);

    // associate the text window with the spin button
    (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);

    SetValue(initial);

    // Set the range in the native control
    SetRange(min, max);

    if ( !value.empty() )
    {
        SetValue(value);
        m_oldValue = (int) wxAtol(value);
    }
    else
    {
        SetValue(wxString::Format(wxT("%d"), initial));
        m_oldValue = initial;
    }

    // do it after finishing with m_hwndBuddy creation to avoid generating
    // initial wxEVT_COMMAND_TEXT_UPDATED message
    ms_allSpins.Add(this);

    return true;
}
示例#8
0
void wxGISTableView::OnSetPos(wxCommandEvent& event)
{
	long pos = wxAtol(event.GetString());
	m_grid->SetGridCursor(pos - 1,0);
	m_grid->MakeCellVisible(pos - 1,0);
}
示例#9
0
void VAutoDialog::OnInitDialog (wxInitDialogEvent& event)
{
	m_LogWindow = new wxLogWindow (this, "VAuto Log", false);
	wxLogDebug (wxString::Format ("%s, V%s", APP_NAME, APP_VERSION));
	wxLogDebug (wxString::Format ("%s", APP_COPYRIGHTS));

	m_Auto = false;
	SetState (STATE_READY);

	SetStatusCoords ("");

	m_HasPlan = false;

	wxStandardPaths sp;
	wxString logPath = sp.GetDataDir();
	wxString planPath = sp.GetDocumentsDir();

	/*
	** VAuto properties defaults and load
	*/
	Properties::Instance().Put (CAMERA_TYPE, "Canon EOS USB");	// Canon EOS on USB
	Properties::Instance().Put (MOUNT_TYPE, "NexStar");			// NexStar/GoTo mount
	Properties::Instance().Put (CAMERA_PORT, "COM1");
	Properties::Instance().Put (CAMERA_LOCKUP, true);
	Properties::Instance().Put (CAMERA_LOCKUP_DELAY, 5);
	Properties::Instance().Put (CAMERA_FRAME_DELAY, 5);
	Properties::Instance().Put (CAMERA_ISO_SPEED, "800");
	Properties::Instance().Put (CAMERA_BATTERY_MIN_LEVEL, 30);
	Properties::Instance().Put (MOUNT_PORT, "COM2");
	Properties::Instance().Put (MANUAL_GOTO, true);
	Properties::Instance().Put (STATION_LONGITUDE, "");
	Properties::Instance().Put (STATION_LATITUDE, "");
	Properties::Instance().Put (DEBUG_LOG_WINDOW, true);
	Properties::Instance().Put (NEXT_FRAMESTACK_ID, 1);
	Properties::Instance().Put (OBSERVATION_LOG_FOLDER, logPath);
	Properties::Instance().Put (PLAN_FOLDER, planPath);
	Properties::Instance().Load (CONFIG_FILE);

	/*
	** Create telescope
	*/
	m_telescope = TelescopeFactory::Instance().GetTelescope (
		Properties::Instance().Get(MOUNT_TYPE),
		Properties::Instance().Get(MOUNT_PORT));

	/*
	** Create camera
	*/
	m_camera = CameraFactory::Instance().GetCamera (
		Properties::Instance().Get (CAMERA_TYPE),
		Properties::Instance().Get (CAMERA_PORT));

	/*
	** TODO: Lehet hogy egszerûbb lenne, ha a kamera megkapná az egész Properties cuccot, és
	**	beállítaná magának, amit lehet. Ugyan ez az opciók módosításánál.
	*/
	if (m_camera != NULL)
	{
		if (m_camera->HasFeature (Camera::DCP_CAN_SET_ISO_SPEED)) {
			unsigned long isoSpeed = wxAtol (Properties::Instance().Get (CAMERA_ISO_SPEED));
			m_camera->SetIsoSpeed (isoSpeed);
			}
	}

	SetDeviceText ();

	/*
	** Create path for observation log files
	*/
//	wxStandardPaths sp;
//	wxString logPath = sp.GetDataDir();
//	if (logPath.Last () != '/' && logPath.Last() != '\\')
//		logPath += "/";
//	logPath += "logs";
//	if (!wxDirExists(logPath)) {
//		wxMkdir (logPath);
//		}
//	ObservationLog::Instance().SetPath (logPath);
	ObservationLog::Instance().SetPath (Properties::Instance().Get (OBSERVATION_LOG_FOLDER));

	/*
	** Load catalogs: GCVS, NSV, NGC/IC, Program
	*/
	wxString dataPath = sp.GetLocalDataDir () + "/catalogs";
	wxLogDebug ("Data Path: " + dataPath);

//	CatalogFactory::Instance().Add (CATALOG_NAME_GCVS, dataPath);
//	CatalogFactory::Instance().Add (CATALOG_NAME_NSV, dataPath);
//	CatalogFactory::Instance().Get (CATALOG_NAME_NSV, "").AddPrefix (CATALOG_NAME_NSV);
//	CatalogFactory::Instance().Add (CATALOG_NAME_NGC, dataPath);
//	CatalogFactory::Instance().Get (CATALOG_NAME_NGC, "").AddPrefix (CATALOG_NAME_NGC);
//	CatalogFactory::Instance().Get (CATALOG_NAME_NGC, "").AddPrefix (CATALOG_NAME_IC);
//	CatalogFactory::Instance().Add (CATALOG_NAME_PROGRAM, dataPath);

	CatalogFactory::Instance().AddAll (wxT("*.cat"), dataPath);

	/*
	** Clear current target info
	*/
	m_DisplayName->SetLabel (_("(no selected object)"));
	m_DisplayRa->SetLabel ("");
	m_DisplayDecl->SetLabel ("");

	DoDisableControls (FALSE);

	m_LogWindow->Show (Properties::Instance().GetBool(DEBUG_LOG_WINDOW));

	Refresh ();
}