//+------------------------------------------------------------------+ //| MainTab.mqh | //| Copyright 2025, Niquel Mendoza. | //| https://www.mql5.com/es/users/nique_372 | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, Niquel Mendoza." #property link "https://www.mql5.com/es/users/nique_372" #property strict #ifndef AIDATATASKRUNER_UI_TRAINING_MAINTAB_MQH #define AIDATATASKRUNER_UI_TRAINING_MAINTAB_MQH //+------------------------------------------------------------------+ //| Include | //+------------------------------------------------------------------+ #include "ResVisualizer.mqh" //+------------------------------------------------------------------+ //| Defines \ Enums \ Struct | //+------------------------------------------------------------------+ #define AIDATATASRUNER_TRAINING_TABS_TOTAL (2) #define AIDATATASRUNER_TRAINING_TAB_CONFIG (0) #define AIDATATASRUNER_TRAINING_TAB_RES (1) /* // Creo que algunos aqui debera de requerir seteo externos en especial los path dado que estos los decide el usuario o en base al main folder dinamico?¿ CFeaturesCodeEditor: Tab de edicion espidica para el DSL de features └── Setrtes extra para botton compiular:m_sec_features_editor.CreateExtra(main_window) CTrainingTabConfig: Tab de configraucion del runner de py | Manda eventos al visualizer y resultrs └── Setters externos: m_sec_config.SetExtra() CTrainingTabResults: Tab de resultados └── Setters externos: m_sec_visualizer.SetExtra(new CTrainingPyVisualizer()); */ //--- struct TrainingTabConfig { // Base bool proyect_common_flag; // Archivos para la comouncion con puy string config_py_path_json_file; string config_py_path_lock_bin_file; // Archivpo para el lancuhjer ea string config_path_to_ea_launcher; }; /* [CTrainingTab] m_tabs="Editor de features|Configuracion py|Resultados" */ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CTrainingTab : public CGuiBaseComponent { private: CTabs m_tabs; CTrainingTabResults m_sec_visualizer; CTrainingTabConfig m_sec_config; public: CTrainingTab(void) : CGuiBaseComponent("CTrainingTab") {} ~CTrainingTab(void) {} //--- CTrainingTabResults* Visualizer() { return &m_sec_visualizer; } CTrainingTabConfig* Config() { return &m_sec_config; } //--- Eventos // Botones (Run py | Table de results | Editor) bool OnClickButtom(const long lparam, const string& sparam); __forceinline bool OnTextEdit(const long lparam) { return m_sec_config.OnTextEdit(lparam); } void OnLenguajeChange() override final; //--- Creacion bool Create(CWndCreate* p, CWindow& main_window, int top_gap, int left_gap, int right_gap, int bottom_gap, const TrainingTabConfig& config); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTrainingTab::Create(CWndCreate *p, CWindow &main_window, int top_gap, int left_gap, int right_gap, int bottom_gap, const TrainingTabConfig& config) { //--- top_gap += 24; left_gap += 4; right_gap += 4; bottom_gap += 4; //--- Creacion del control tabs // header string tab_header[]; const string str_header = m_language[AIDATATASKRUNNERL_COMPONENT_NAME(m_tabs)]; if(!StrTo::CstArray(tab_header, str_header, '|', true)) { FastLog(FUNCION_ACTUAL, ERROR_TEXT, "Fallo al hacer str to array str"); return false; } ArrayResize(tab_header, AIDATATASRUNER_TRAINING_TABS_TOTAL); // trim // Colores color clrs_tab_label[AIDATATASRUNER_TRAINING_TABS_TOTAL] = { AIDATATASKRUNER_COLOR_TEXT_SECONDARY, AIDATATASKRUNER_COLOR_TEXT_SECONDARY }; color clrs_tab_label_pressed[AIDATATASRUNER_TRAINING_TABS_TOTAL] = { AIDATATASKRUNER_COLOR_ACCENT, AIDATATASKRUNER_COLOR_ACCENT }; //--- int width[AIDATATASRUNER_TRAINING_TABS_TOTAL] = { 90, 80 }; m_tabs.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB); m_tabs.BackColorHover(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_HOVER); m_tabs.BackColorPressed(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED); m_tabs.BackColorLocked(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_LOCKED); m_tabs.BorderColor(AIDATATASKRUNER_COLOR_BORDER); m_tabs.BorderColorHover(AIDATATASKRUNER_COLOR_BORDER_HOVER); m_tabs.BorderColorPressed(AIDATATASKRUNER_COLOR_BORDER_HOVER); m_tabs.BorderColorLocked(AIDATATASKRUNER_COLOR_BORDER); // m_tabs.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY); // m_tabs.LabelColorLocked(AIDATATASKRUNER_COLOR_TEXT_LOCKED); // Creacion if(!p.CreateTabs(m_tabs, main_window, 0, m_base_tab, m_base_tab_idx, left_gap, top_gap, 0, 0, tab_header, width, clrs_tab_label, clrs_tab_label_pressed, TABS_TOP, true, true, right_gap, bottom_gap)) { AIDATATASKRUNER_ERROR_CREATION(m_tabs); return false; } //--- //top_gap += 5; //--- m_sec_config.AddLogFlags(LogFlags()); m_sec_config.SetExtra(config.proyect_common_flag, config.config_py_path_json_file, config.config_py_path_lock_bin_file, config.config_path_to_ea_launcher); m_sec_config.SetInitValues(m_language, &m_tabs, AIDATATASRUNER_TRAINING_TAB_CONFIG); if(!m_sec_config.Create(p, main_window, top_gap, left_gap, right_gap, bottom_gap)) { AIDATATASKRUNER_ERROR_CREATION(m_sec_config); return false; } //--- CTrainingPyVisualizer* vis = new CTrainingPyVisualizer(); vis.SetInitValues(m_language, &m_tabs, AIDATATASRUNER_TRAINING_TAB_RES); // visuzlaidor va con los mismo valores que donde esta m_sec_config.AddRunnerPy(vis); m_sec_visualizer.AddLogFlags(LogFlags()); // Por defecto usaremos el que trae la lib?¿ // Nota esto se peude cambiar si es mas espific peor del de la lib es suficente en la matoia de casos m_sec_visualizer.SetExtra(vis); m_sec_visualizer.SetInitValues(m_language, &m_tabs, AIDATATASRUNER_TRAINING_TAB_RES); if(!m_sec_visualizer.Create(p, main_window, top_gap, left_gap, right_gap, bottom_gap)) { AIDATATASKRUNER_ERROR_CREATION(m_sec_visualizer); return false; } else { m_sec_config.AddRunnerPy(&m_sec_visualizer); } //--- return true; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CTrainingTab::OnLenguajeChange(void) { //--- Actualizacion de las tabs string tab_header[]; const string str_header = m_language[AIDATATASKRUNNERL_COMPONENT_NAME(m_tabs)]; if(!StrTo::CstArray(tab_header, str_header, '|', true)) { FastLog(FUNCION_ACTUAL, ERROR_TEXT, "Fallo al hacer str to array str"); return; } const int t = m_tabs.TabsTotal(); // Solo iteramos sobre las que ya existen (es el total real si hay mas tamñao se omite) for(int i = 0; i < t; i++) m_tabs.Text(i, tab_header[i]); m_tabs.Update(); //--- m_sec_config.OnLenguajeChange(); m_sec_visualizer.OnLenguajeChange(); // cambio llamamo tambien dado que ahora el header lo puede necesiutar } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTrainingTab::OnClickButtom(const long lparam, const string &sparam) { switch(m_tabs.SelectedTab()) { case AIDATATASRUNER_TRAINING_TAB_CONFIG: return m_sec_config.OnClickBottom(lparam); case AIDATATASRUNER_TRAINING_TAB_RES: return m_sec_visualizer.OnClickButtom(lparam, sparam); } return false; } //+------------------------------------------------------------------+ #endif // AIDATATASKRUNER_UI_TRAINING_MAINTAB_MQH