bool CStudio::EventProcess(const Event &event) { CWindow* pw; CEdit* edit; CSlider* slider; if ( m_dialog != SD_NULL ) // dialogue exists? { return EventDialog(event); } if ( event.type == EVENT_FRAME ) { EventFrame(event); } pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return false; edit = static_cast<CEdit*>(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == nullptr ) return false; if ( event.type == pw->GetEventTypeClose() ) { Event newEvent = event; newEvent.type = EVENT_STUDIO_OK; m_event->AddEvent(newEvent); } if ( event.type == EVENT_STUDIO_EDIT ) // text modifief? { ColorizeScript(edit); } if ( event.type == EVENT_STUDIO_LIST ) // list clicked? { m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes } if ( event.type == EVENT_STUDIO_NEW ) // new? { m_script->New(edit, ""); } if ( event.type == EVENT_STUDIO_OPEN ) // open? { StartDialog(SD_OPEN); } if ( event.type == EVENT_STUDIO_SAVE ) // save? { StartDialog(SD_SAVE); } if ( event.type == EVENT_STUDIO_UNDO ) // undo? { edit->Undo(); } if ( event.type == EVENT_STUDIO_CUT ) // cut? { edit->Cut(); } if ( event.type == EVENT_STUDIO_COPY ) // copy? { edit->Copy(); } if ( event.type == EVENT_STUDIO_PASTE ) // paste? { edit->Paste(); } if ( event.type == EVENT_STUDIO_SIZE ) // size? { slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider == nullptr ) return false; m_main->SetFontSize(9.0f+slider->GetVisibleValue()*12.0f); ViewEditScript(); } if ( event.type == EVENT_STUDIO_TOOL && // instructions? m_dialog == SD_NULL ) { m_main->StartDisplayInfo(SATCOM_HUSTON, false); } if ( event.type == EVENT_STUDIO_HELP && // help? m_dialog == SD_NULL ) { m_main->StartDisplayInfo(SATCOM_PROG, false); } if ( event.type == EVENT_STUDIO_COMPILE ) // compile? { if ( m_script->GetScript(edit) ) // compile { std::string res; GetResource(RES_TEXT, RT_STUDIO_COMPOK, res); SetInfoText(res, false); } else { std::string error; m_script->GetError(error); SetInfoText(error, false); } } if ( event.type == EVENT_STUDIO_RUN ) // run/stop? { if ( m_script->IsRunning() ) { Event newEvent = event; newEvent.type = EVENT_OBJECT_PROGSTOP; m_event->AddEvent(newEvent); // stop } else { if ( m_script->GetScript(edit) ) // compile { SetInfoText("", false); Event newEvent = event; newEvent.type = EVENT_OBJECT_PROGSTART; m_event->AddEvent(newEvent); // start } else { std::string error; m_script->GetError(error); SetInfoText(error, false); } } } if ( event.type == EVENT_STUDIO_REALTIME ) // real time? { m_bRealTime = !m_bRealTime; m_script->SetStepMode(!m_bRealTime); UpdateFlux(); UpdateButtons(); } if ( event.type == EVENT_STUDIO_STEP ) // step? { m_script->Step(event); } if ( event.type == EVENT_KEY_DOWN ) { if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).primary || event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).secondary ) { if ( m_helpFilename.length() > 0 ) { m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes } } } if ( event.type == EVENT_WINDOW3 ) // window is moved? { m_editActualPos = m_editFinalPos = pw->GetPos(); m_editActualDim = m_editFinalDim = pw->GetDim(); m_main->SetWindowPos(m_editActualPos); m_main->SetWindowDim(m_editActualDim); AdjustEditScript(); } if ( event.type == pw->GetEventTypeReduce() ) { if ( m_bEditMinimized ) { m_editFinalPos = m_main->GetWindowPos(); m_editFinalDim = m_main->GetWindowDim(); m_bEditMinimized = false; m_bEditMaximized = false; } else { m_editFinalPos.x = 0.00f; m_editFinalPos.y = -0.44f; m_editFinalDim.x = 1.00f; m_editFinalDim.y = 0.50f; m_bEditMinimized = true; m_bEditMaximized = false; } m_main->SetEditFull(m_bEditMaximized); pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) { pw->SetMaximized(m_bEditMaximized); pw->SetMinimized(m_bEditMinimized); } } if ( event.type == pw->GetEventTypeFull() ) { if ( m_bEditMaximized ) { m_editFinalPos = m_main->GetWindowPos(); m_editFinalDim = m_main->GetWindowDim(); m_bEditMinimized = false; m_bEditMaximized = false; } else { m_editFinalPos.x = 0.00f; m_editFinalPos.y = 0.00f; m_editFinalDim.x = 1.00f; m_editFinalDim.y = 1.00f; m_bEditMinimized = false; m_bEditMaximized = true; } m_main->SetEditFull(m_bEditMaximized); pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) { pw->SetMaximized(m_bEditMaximized); pw->SetMinimized(m_bEditMinimized); } } return true; }
void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim) { CWindow* pw; CEdit* edit; CButton* button; CSlider* slider; CGroup* group; Math::Point pos, dim; wpos.x = 50.0f / 640.0f; wpos.y = 30.0f / 480.0f; wdim.x = 540.0f / 640.0f; wdim.y = 420.0f / 480.0f; pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != 0 ) { pw->SetPos(wpos); pw->SetDim(wdim); wdim = pw->GetDim(); } pos.x = (50.0f + 10.0f) / 640.0f; pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f - 48.0f) / 480.0f; dim.x = 48.0f / 640.0f; dim.y = 48.0f / 480.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_HUSTON)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.y -= (48.0f + 4.0f) / 480.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SAT)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } //? pos.y -= (48.0f+4.0f)/480.0f; //? button = (CButton*)pw->SearchControl(EVENT_SATCOM_OBJECT); //? if ( button != 0 ) //? { //? button->SetPos(pos); //? button->SetDim(dim); //? } pos.y -= (48.0f + 4.0f) / 480.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_LOADING)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.y -= (48.0f + 4.0f) / 480.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_PROG)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.y -= (48.0f + 4.0f) / 480.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SOLUCE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = (50.0f + 10.0f + 5.0f) / 640.0f; pos.y = (30.0f + 10.0f + 4.0f) / 480.0f; dim.x = (48.0f - 10.0f) / 640.0f; dim.y = 24.0f / 480.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_OBJECT_INFOOK)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f; pos.y = (30.0f + 10.0f) / 480.0f; dim.x = 462.0f / 640.0f; dim.y = 358.0f / 480.0f; edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1)); if ( edit != 0 ) { edit->SetPos(pos); edit->SetDim(dim); } pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f; pos.y = (30.0f + 10.0f + 358.0f + 10.0f) / 480.0f; dim.x = 32.0f / 640.0f; dim.y = 32.0f / 480.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_PREV)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x += 35.0f / 640.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_NEXT)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x += 35.0f / 640.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_HOME)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x += 50.0f / 640.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE1)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x += 35.0f / 640.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE2)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x += 35.0f / 640.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE3)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x += 35.0f / 640.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE4)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x += 35.0f / 640.0f; dim.x = 18.0f / 640.0f; slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider != 0 ) { slider->SetPos(pos); slider->SetDim(dim); } pos.x += 50.0f / 640.0f; dim.x = 32.0f / 640.0f; button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_COPY)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = (50.0f + 10.0f) / 640.0f; pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f + 6.0f) / 480.0f; dim.x = 48.0f / 640.0f; dim.y = 40.0f / 480.0f; group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL2)); // symbol SatCom if ( group != 0 ) { group->SetPos(pos); group->SetDim(dim); } pos.x = (50.0f + 10.0f + 14.0f) / 640.0f; pos.y = (30.0f + 10.0f + 6.0f) / 480.0f; dim.x = 20.0f / 640.0f; dim.y = 20.0f / 480.0f; group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL3)); // symbol stand-by if ( group != 0 ) { group->SetPos(pos); group->SetDim(dim); } }