Ejemplo n.º 1
0
void TaskDialog::GetDialogData()
{
    m_bottask->ResetTimeData();
    m_bottask->SetTaskName(m_textCtrl_taskname->GetValue());
    m_bottask->SetTaskType(m_choice_tasktype->GetCurrentSelection());

    switch(m_choice_tasktype->GetCurrentSelection())
    {
        case TASK_INTERVAL:
            m_bottask->GetTaskTimeData()->SetIntervalSeconds(m_spinCtrl_interval->GetValue());
            break;

        case TASK_SPECIFY:
            m_bottask->GetTaskTimeData()->SetSpecifiedTime(m_datePicker_once->GetValue().GetTicks());//.SetHour(m_spinCtrl_once_hour->GetValue()).SetMinute(m_spinCtrl_once_minute->GetValue()).SetSecond(m_spinCtrl_once_second->GetValue()).GetTicks());
            m_bottask->GetTaskTimeData()->SetSpecifiedHours(m_spinCtrl_once_hour->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedMinutes(m_spinCtrl_once_minute->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedSeconds(m_spinCtrl_once_second->GetValue());
            break;

        case TASK_DAILY_INTERVAL:
            m_bottask->GetTaskTimeData()->SetSpecifiedHours(m_spinCtrl_daliy_hour->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedMinutes(m_spinCtrl_daliy_minute->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedSeconds(m_spinCtrl_daliy_second->GetValue());
            break;

        case TASK_WEEKLY_INTERVAL:
            m_bottask->GetTaskTimeData()->SetSpecifiedHours(m_spinCtrl_weekly_hour->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedMinutes(m_spinCtrl_weekly_minute->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedSeconds(m_spinCtrl_weekly_second->GetValue());

            m_bottask->GetTaskTimeData()->GetSpecifiedDate()->Clear();
            for(size_t index = 0; index < 7; index++)
            {
                if(((wxCheckBox *)FindWindowByName(wxT("m_checkBox_week_") + wxString::Format(wxT("%i"), index)))->GetValue()) m_bottask->GetTaskTimeData()->GetSpecifiedDate()->Add(index);
            }
            break;

        case TASK_MONTHLY_INTERVAL:
            m_bottask->GetTaskTimeData()->SetSpecifiedHours(m_spinCtrl_monthly_hour->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedMinutes(m_spinCtrl_monthly_minute->GetValue());
            m_bottask->GetTaskTimeData()->SetSpecifiedSeconds(m_spinCtrl_monthly_second->GetValue());

            m_bottask->GetTaskTimeData()->GetSpecifiedDate()->Clear();
            for(size_t index = 0; index < 31; index++)
            {
                if(((wxCheckBox *)FindWindowByName(wxT("m_checkBox_month_") + wxString::Format(wxT("%i"), index + 1)))->GetValue()) m_bottask->GetTaskTimeData()->GetSpecifiedDate()->Add(index + 1);
            }
            break;
    }
}
Ejemplo n.º 2
0
void MiscControlPage::InitJoystickOrPrinterPort(wxString connector, wxString control, wxString connectorClass)
{
	const wxArrayString& classes = m_controller.GetPluggableClasses();
	if (classes.IsEmpty()) return;

	auto* box = (wxComboBox*)FindWindowByName(control);
	box->Enable(true);
	wxString currentval = box->GetValue();
	box->Clear();
	box->Append(wxT("--empty--"));

	const wxArrayString& pluggables = m_controller.GetPluggables();
	for (unsigned i = 0; i < pluggables.GetCount(); ++i) {
		if (classes[i] == connectorClass) {
			box->Append(pluggables[i]);
		}
	}
	if (m_controller.IsRelaunching()) {
		// if relaunching, then just update the values
		wxString currentlyPlugged = m_controller.GetConnectorPlugged(connector);
		box->SetValue(currentlyPlugged.IsEmpty() ? wxT("--empty--") : currentlyPlugged);
	} else {
		// Initializing (initial launch)
		if (box->FindString(currentval) == wxNOT_FOUND) {
			currentval = box->GetString(0);
		}
		box->SetValue(currentval);
		if (currentval != wxT("--empty--")) {
			m_controller.WriteCommand(wxT("plug ") + connector + wxT(" ") + currentval);
		} else {
			m_controller.WriteCommand(wxT("unplug ") + connector);
		}
	}
}
Ejemplo n.º 3
0
void MiscControlPage::InitConnectorPanel()
{
	// first disable them all, for cases where we don't have that whole connector present
	FindWindowByName(wxT("PrinterportSelector"))->Enable(false);
	FindWindowByName(wxT("Joyport1Selector"))->Enable(false);
	FindWindowByName(wxT("Joyport2Selector"))->Enable(false);
	for (auto& connector : m_controller.GetConnectors()) {
		wxString currentClass = m_controller.GetConnectorClass(connector);
		if (connector == wxT("joyporta")) {
			InitJoystickOrPrinterPort(connector, wxT("Joyport1Selector"), currentClass);
		} else if (connector == wxT("joyportb")) {
			InitJoystickOrPrinterPort(connector, wxT("Joyport2Selector"), currentClass);
		} else if (connector == wxT("printerport")) {
			InitJoystickOrPrinterPort(connector, wxT("PrinterportSelector"), currentClass);
		}
	}
}
Ejemplo n.º 4
0
void MiscControlPage::FillInitialJoystickPortValues()
{
	//  temporary hardcoded joystick port devices (not for BSD)
#if wxUSE_JOYSTICK
	wxJoystick joy(wxJOYSTICK1);
#endif
	int JoySaveID[] = {
		ConfigurationData::CD_JOYPORT1,
		ConfigurationData::CD_JOYPORT2
	};
	wxComboBox* box[2];
	box[0] = (wxComboBox*)FindWindowByName(wxT("Joyport1Selector"));
	box[1] = (wxComboBox*)FindWindowByName(wxT("Joyport2Selector"));
	for (int i = 0; i < 2; ++i) {
		box[i]->Clear();
		box[i]->Append(wxT("--empty--"));
		box[i]->Append(wxT("mouse"));
		box[i]->Append(wxT("tetris2-protection"));
		box[i]->Append(wxT("magic-key"));
		box[i]->Append(wxT("keyjoystick1"));
		box[i]->Append(wxT("keyjoystick2"));

#if wxUSE_JOYSTICK
		for (int j = 1; j <= joy.GetNumberJoysticks(); ++j) {
			box[i]->Append(wxString::Format(wxT("joystick%d"), j));
		}
#endif
		wxString current;
		ConfigurationData::instance().GetParameter(JoySaveID[i], current);
		int pos = box[i]->FindString(current);
		if (pos != wxNOT_FOUND) {
			box[i]->SetSelection(pos);
		} else {
			box[i]->SetSelection(0);
		}
	}
	m_oldJoy1 = box[0]->GetValue();
	m_oldJoy2 = box[1]->GetValue();
}
Ejemplo n.º 5
0
void	ShowObjectInspector (void)
{
	long f = FindWindowByName (objectInspectorTitle);
	if (f>=0)
	{
		gtk_window_present(GTK_WINDOW(windowPtrs(f)));	
	}
	else
	{
		_HYObjectInspector* newOI = new _HYObjectInspector ();
		newOI->BringToFront		  ( );
	}
}
Ejemplo n.º 6
0
void TaskDialog::InitTaskDialog()
{
    if(!m_bottask->GetConfigFileName().Len())
    {
        m_bottask->SetConfigFileName(wxT("task_") + wxDateTime::Now().Format(wxT("%Y%m%d%H%M%S%l")) + wxT(".xml"));
    }

    wxCheckBox * target_checkbox = NULL;
    size_t task_type = m_bottask->GetTaskType();

    m_textCtrl_taskname->SetValue(m_bottask->GetTaskName());
    m_choice_tasktype->SetSelection(task_type);

    m_panel_baseinterval->Show(false);
    m_panel_baseonce->Show(false);
    m_panel_basedaliy->Show(false);
    m_panel_baseweekly->Show(false);
    m_panel_basemonthly->Show(false);

    size_t date_num = 0;
    size_t date_data = 0;

    switch(task_type)
    {
        case TASK_INTERVAL:
            m_panel_baseinterval->Show(true);
            m_spinCtrl_interval->SetValue(m_bottask->GetTaskTimeData()->GetIntervalSeconds());
            break;

        case TASK_SPECIFY:
            m_panel_baseonce->Show(true);
            m_datePicker_once->SetValue(wxDateTime(m_bottask->GetTaskTimeData()->GetSpecifiedTime()));
            m_spinCtrl_once_hour->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedHours());
            m_spinCtrl_once_minute->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedMinutes());
            m_spinCtrl_once_second->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedSeconds());
            break;

        case TASK_DAILY_INTERVAL:
            m_panel_basedaliy->Show(true);
            m_spinCtrl_daliy_hour->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedHours());
            m_spinCtrl_daliy_minute->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedMinutes());
            m_spinCtrl_daliy_second->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedSeconds());
            break;

        case TASK_WEEKLY_INTERVAL:
            m_panel_baseweekly->Show(true);
            m_spinCtrl_weekly_hour->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedHours());
            m_spinCtrl_weekly_minute->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedMinutes());
            m_spinCtrl_weekly_second->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedSeconds());

            date_num = m_bottask->GetTaskTimeData()->GetSpecifiedDate()->GetCount();
            for(size_t index = 0; index < date_num; index++)
            {
                date_data = m_bottask->GetTaskTimeData()->GetSpecifiedDate()->Item(index);
                //((wxCheckBox *)FindWindowByName(wxT("m_checkBox_week_") + wxString::Format(wxT("%i"), date_data)))->SetValue(true);
                target_checkbox = (wxCheckBox *)FindWindowByName(wxT("m_checkBox_week_") + wxString::Format(wxT("%i"), date_data));
                if(target_checkbox) target_checkbox->SetValue(true);
            }
            break;

        case TASK_MONTHLY_INTERVAL:
            m_panel_basemonthly->Show(true);
            m_spinCtrl_monthly_hour->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedHours());
            m_spinCtrl_monthly_minute->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedMinutes());
            m_spinCtrl_monthly_second->SetValue(m_bottask->GetTaskTimeData()->GetSpecifiedSeconds());

            date_num = m_bottask->GetTaskTimeData()->GetSpecifiedDate()->GetCount();
            for(size_t index = 0; index < date_num; index++)
            {
                date_data = m_bottask->GetTaskTimeData()->GetSpecifiedDate()->Item(index);
                //((wxCheckBox *)FindWindowByName(wxT("m_checkBox_month_") + wxString::Format(wxT("%i"), date_data)))->SetValue(true);
                target_checkbox = (wxCheckBox *)FindWindowByName(wxT("m_checkBox_month_") + wxString::Format(wxT("%i"), date_data));
                if(target_checkbox) target_checkbox->SetValue(true);
            }
            break;
    }
}
Ejemplo n.º 7
0
void MiscControlPage::OnJoystickChanged()
{
	static bool MessageActive = false;
	wxComboBox* box = m_lastUpdatedCombo;
	if (!box || MessageActive) {
		return;
	}
	wxComboBox* box2 = nullptr;
	wxString* oldValue1 = nullptr; // this port
	wxString* oldValue2 = nullptr; // the other port
	wxString cmd = wxT("unplug ");
	wxString connector;
	wxString connector2;
	if (box->GetName() == wxT("Joyport1Selector")) {
		connector = wxT("joyporta ");
		connector2 = wxT("joyportb");
		box2 = (wxComboBox*)FindWindowByName(wxT("Joyport2Selector"));
		oldValue1 = &m_oldJoy1;
		oldValue2 = &m_oldJoy2;
	} else if (box->GetName() == wxT("Joyport2Selector")) {
		connector = wxT("joyportb ");
		connector2 = wxT("joyporta");
		box2 = (wxComboBox*)FindWindowByName(wxT("Joyport1Selector"));
		oldValue1 = &m_oldJoy2;
		oldValue2 = &m_oldJoy1;
	}

	wxString value;
	if (box->GetValue() != wxT("--empty--")) {
		value = box->GetValue();
		cmd = wxT("plug ");
	}

	bool sameDevicePluggedInTwoPorts = false;
	if (box->GetValue() != wxT("--empty--")) {
		assert(box2 != 0);
		if (!box2) throw "box2 must not be null, but it is null.";

		if (box->GetValue() == box2->GetValue()) {
			sameDevicePluggedInTwoPorts = true;
			assert(oldValue1 != 0);
			if (!oldValue1) throw "oldValue1 must not be null, but it is null.";
			MessageActive = true;
			int result = wxMessageBox(wxT("Unable to plug a device in more than one port!\n\nDo you still want to plug it into this port?\nThis device will then be removed from any other port(s)."),
				wxT("Warning"),
				wxOK | wxCANCEL);
			MessageActive = false;
			if (result == wxOK) {
				assert(oldValue2 != 0);
				if (!oldValue2) throw "oldValue2 must not be null, but it is null.";

				box2->SetSelection(0);
				*oldValue2 = wxT("--empty--");
				*oldValue1 = box->GetValue();
				m_controller.WriteCommand(wxT("unplug ") + connector2);
				m_controller.WriteCommand(cmd + connector + value);
			} else {
				// cancel
				box->SetSelection(box->FindString(*oldValue1));
			}
		}
	}
	if (!sameDevicePluggedInTwoPorts) {
		// no collision
		m_controller.WriteCommand(cmd + connector + value);
		assert(oldValue1!=0);
		if(!oldValue1)throw "oldValue1 must not be null, but it is null.";
		*oldValue1 = box->GetValue();
	}
	auto* joy1 = (wxComboBox*)FindWindowByName(wxT("Joyport1Selector"));
	auto* joy2 = (wxComboBox*)FindWindowByName(wxT("Joyport2Selector"));
	ConfigurationData::instance().SetParameter(ConfigurationData::CD_JOYPORT1, joy1->GetValue());
	ConfigurationData::instance().SetParameter(ConfigurationData::CD_JOYPORT2, joy2->GetValue());
	ConfigurationData::instance().SaveData();
}
Ejemplo n.º 8
0
MiscControlPage::MiscControlPage(wxWindow* parent, openMSXController& controller)
	: m_controller(controller)
{
#ifdef __UNIX__
	m_joystick_update_timer.SetOwner(this, -1);
#endif
	wxXmlResource::Get()->LoadPanel(this, parent, wxT("MiscControlPage"));
	m_powerButton = (wxToggleButton*)FindWindowByName(wxT("PowerButton"));
	m_pauseButton = (wxToggleButton*)FindWindowByName(wxT("PauseButton"));
	m_resetButton = (wxButton*)FindWindowByName(wxT("ResetButton"));
	m_firmwareButton = (wxToggleButton*)FindWindowByName(wxT("FirmwareButton"));
	m_speedIndicator = (wxTextCtrl*)FindWindowByName(wxT("SpeedIndicator"));
	m_speedSlider = (wxSlider*)FindWindowByName(wxT("SpeedSlider"));
	m_speedNormalButton = (wxButton*)FindWindowByName (wxT("NormalSpeedButton"));
	m_speedMaxButton = (wxToggleButton*)FindWindowByName (wxT("MaxSpeedButton"));
	m_minFrameSkipIndicator = (wxTextCtrl*)FindWindowByName(wxT("MinFrameSkipIndicator"));
	m_maxFrameSkipIndicator = (wxTextCtrl*)FindWindowByName(wxT("MaxFrameSkipIndicator"));
	m_maxFrameSkipSlider = (wxSlider*)FindWindowByName(wxT("MaxFrameSkipSlider"));
	m_minFrameSkipSlider = (wxSlider*)FindWindowByName(wxT("MinFrameSkipSlider"));
	m_renshaTurboSlider  = (wxSlider*)FindWindowByName(wxT("RenshaTurboSlider"));
	m_browsePrinterLog = (wxBitmapButton*)FindWindowByName(wxT("BrowsePrinterLog"));
	m_printerLogFile = (wxTextCtrl*)FindWindowByName(wxT("PrinterLogFile"));
	m_printerportSelector = (wxComboBox*)FindWindowByName(wxT("PrinterportSelector"));

	m_defaultMaxFrameSkipButton = (wxButton*)FindWindowByName(wxT("DefaultMaxFrameSkipButton"));
	m_defaultMinFrameSkipButton = (wxButton*)FindWindowByName(wxT("DefaultMinFrameSkipButton"));

	m_speedSlider->SetTickFreq(25, 1);
	m_maxFrameSkipSlider->SetTickFreq(5, 1);
	m_minFrameSkipSlider->SetTickFreq(5, 1);
	m_renshaTurboSlider->SetTickFreq(5, 1);

	m_printerportFileLabel = (wxStaticText*)FindWindowByName(wxT("PrinterLogFileLabel"));
	m_printerportLabel     = (wxStaticText*)FindWindowByName(wxT("PrinterLabel"));
	m_renshaLabel          = (wxStaticText*)FindWindowByName(wxT("RenShaTurboLabel"));
	m_frameskipLabel       = (wxStaticText*)FindWindowByName(wxT("FrameSkipLabel"));
	m_frameskipMaxLabel    = (wxStaticText*)FindWindowByName(wxT("FrameSkipMaxLabel"));
	m_frameskipMinLabel    = (wxStaticText*)FindWindowByName(wxT("FrameSkipMinLabel"));
	m_emulationSpeedLabel  = (wxStaticText*)FindWindowByName(wxT("EmulationSpeedLabel"));

	auto* box = (wxComboBox*)FindWindowByName(wxT("PrinterportSelector"));
	box->Clear();
	box->Append(wxT("--empty--"));
	box->Append(wxT("logger"));
	box->Append(wxT("simpl"));
	box->Append(wxT("msx-printer"));
	box->Append(wxT("epson-printer"));

	/* This doesn't do anything, because it is "disabled" according to a comment in ConfigurationData
	wxString filename;
	auto* text = (wxTextCtrl*)FindWindowByName(wxT("PrinterLogFile"));
	wxString current;
	ConfigurationData::instance().GetParameter(ConfigurationData::CD_PRINTERPORT, current);
	ConfigurationData::instance().GetParameter(ConfigurationData::CD_PRINTERFILE, filename);
	text->SetValue(filename);

	int pos = box->FindString(current);
	if (pos != wxNOT_FOUND) {
		box->SetSelection(pos);
	} else {
		box->SetSelection(0);
	}
	OnPrinterportChanged(false); */
}
Ejemplo n.º 9
0
void    _HYObjectInspector::OpenObjectWindow (void)
{
    _HYTable*       dl = (_HYTable*)GetCellObject (HY_OBJECT_INSPECTOR_TABLE_ROW,0);
    _HYButtonBar*   b1 = (_HYButtonBar*)GetCellObject (0,0);
    _HYPullDown*    p1 = (_HYPullDown*)GetCellObject (0,2);

    _SimpleList     sel;
    dl->GetSelection (sel);
    if (sel.lLength) {
        b1->EnableButton (0,true);
        for (long k = 0; k<sel.lLength; k+=2) {
            _String          windowTitle (*(_String*)dl->GetCellData (0,sel.lData[k]/2));
            long f;
            switch (p1->GetSelection()) {
            case 0: {
                _String winTitle (windowTitle);
                windowTitle = _String ("Tree ")&windowTitle;
                f = FindWindowByName (windowTitle);
                if (f<0) {
                    _HYTreePanel* newTreePanel = new _HYTreePanel (winTitle,winTitle);
                    newTreePanel->_Zoom(true);
                    newTreePanel->BringToFront();
                    //newTreePanel->Show();
                } else {
                    _HYPlatformWindow* thisWindow = (_HYPlatformWindow*)windowObjects(f);
                    thisWindow->_Activate();
                }
                break;
            }
            case 1: {
                _String winTitle (windowTitle);
                windowTitle = _String ("DataSet ")&windowTitle;
                f = FindWindowByName (windowTitle);
                if (f<0) {
                    _HYDataPanel* newDataPanel = new _HYDataPanel (winTitle,winTitle);
                    newDataPanel->BringToFront();
                } else {
                    _HYPlatformWindow* thisWindow = (_HYPlatformWindow*)windowObjects(f);
                    thisWindow->_Activate();
                }
                break;
            }
            case 2: {
                _String winTitle (windowTitle);
                windowTitle = _String ("Model ")&windowTitle;
                f = FindWindowByName (windowTitle);
                if (f<0) {
                    if (dl->cellTypes.lData[sel.lData[k]] & HY_TABLE_ITALIC) {
                        if (!warnModelOpen) {
                            windowTitle = _String ("Model \"") & winTitle & "\" is a template model, and it can't be opened. You can open a new model based on it, though.";
                            if (!warnModelOpen) {
                                if (!ProceedPromptWithCheck (windowTitle, donotWarnAgain, warnModelOpen)) {
                                    break;
                                }
                            }
                            NewObject ();
                            break;

                        }
                    } else {
                        if (sel.lData[k]/2<modelTemplates.lLength) {
                            _List* modelSpec = FindModelTemplate (&winTitle);
                            if (modelSpec) {
                                OpenModelFromFile(*(_String*)(*modelSpec)(2));
                            }
                        } else {
                            OpenModelFromMatrix (winTitle);
                        }
                    }
                } else {
                    _HYWindow* thisWindow = (_HYWindow*)windowObjectRefs(f);
                    thisWindow->BringToFront();
                }
                break;
            }
            case 3: {
                _String winTitle (windowTitle);
                windowTitle = _String ("Likelihood Function ")&windowTitle;
                f = FindWindowByName (windowTitle);
                if (f<0) {
                    f = likeFuncNamesList.Find(&winTitle);
                    if (f>=0) {
                        _HYParameterTable* newParameterTable = new _HYParameterTable (windowTitle,f);
                        newParameterTable->_Zoom(true);
                        newParameterTable->BringToFront();
                    }
                } else {
                    _HYPlatformWindow* thisWindow = (_HYPlatformWindow*)windowObjects(f);
                    thisWindow->_Activate();
                }
                break;
            }
            }
        }
    }
}