2026-03-20 21:40:41 -05:00
//+------------------------------------------------------------------+
2026-02-24 10:16:05 -05:00
//| 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 "
2026-03-20 21:40:41 -05:00
# property strict
# ifndef AIDATATASKRUNER_UI_TRAINING_MAINTAB_MQH
# define AIDATATASKRUNER_UI_TRAINING_MAINTAB_MQH
//+------------------------------------------------------------------+
//| Include |
//+------------------------------------------------------------------+
# include "ResVisualizer.mqh"
//+------------------------------------------------------------------+
//| Defines \ Enums \ Struct |
//+------------------------------------------------------------------+
2026-03-21 12:50:21 -05:00
# define AIDATATASRUNER_TRAINING_TABS_TOTAL ( 2 )
# define AIDATATASRUNER_TRAINING_TAB_CONFIG ( 0 )
# define AIDATATASRUNER_TRAINING_TAB_RES ( 1 )
2026-03-20 21:40:41 -05:00
/*
// 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 ;
2026-03-24 10:39:38 -05:00
// Archivpo para el lancuhjer ea
string config_path_to_ea_launcher ;
2026-03-28 08:35:32 -05:00
// Archivo al path de py
string config_path_interpete_py ;
2026-03-28 10:58:12 -05:00
string config_path_py_env ;
2026-03-20 21:40:41 -05:00
} ;
2026-03-21 08:06:31 -05:00
/*
[ CTrainingTab ]
m_tabs = " Editor de features|Configuracion py|Resultados "
* /
2026-02-24 10:16:05 -05:00
//+------------------------------------------------------------------+
2026-03-20 21:40:41 -05:00
//| |
2026-02-24 10:16:05 -05:00
//+------------------------------------------------------------------+
2026-03-20 21:40:41 -05:00
class CTrainingTab : public CGuiBaseComponent < CLoggerBase >
{
private :
CTabs m_tabs ;
CTrainingTabResults m_sec_visualizer ;
CTrainingTabConfig m_sec_config ;
public :
CTrainingTab ( void ) : CGuiBaseComponent < CLoggerBase > ( " CTrainingTab " ) { }
~ CTrainingTab ( void ) { }
2026-03-21 08:15:18 -05:00
//---
CTrainingTabResults * Visualizer ( ) { return & m_sec_visualizer ; }
CTrainingTabConfig * Config ( ) { return & m_sec_config ; }
2026-03-20 21:40:41 -05:00
//--- Eventos
// Botones (Run py | Table de results | Editor)
bool OnClickButtom ( const long lparam , const string & sparam ) ;
2026-03-24 10:39:38 -05:00
__forceinline bool OnTextEdit ( const long lparam ) { return m_sec_config . OnTextEdit ( lparam ) ; }
2026-03-26 06:46:59 -05:00
__forceinline bool OnClickDec ( const long lparam ) { return m_sec_config . OnClickDec ( lparam ) ; }
__forceinline bool OnClickInc ( const long lparam ) { return m_sec_config . OnClickInc ( lparam ) ; }
2026-03-20 21:40:41 -05:00
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 ) ;
} ;
2026-02-24 10:16:05 -05:00
//+------------------------------------------------------------------+
2026-03-20 21:40:41 -05:00
//| |
2026-02-24 10:16:05 -05:00
//+------------------------------------------------------------------+
2026-03-20 21:40:41 -05:00
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
} ;
//---
2026-03-21 12:50:21 -05:00
int width [ AIDATATASRUNER_TRAINING_TABS_TOTAL ] = { 90 , 80 } ;
2026-03-20 21:40:41 -05:00
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);
2026-03-21 11:41:29 -05:00
2026-03-20 21:40:41 -05:00
// 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 ;
}
2026-03-21 11:41:29 -05:00
//---
2026-03-24 10:39:38 -05:00
//top_gap += 5;
2026-03-21 11:41:29 -05:00
2026-03-20 21:40:41 -05:00
//---
m_sec_config . AddLogFlags ( LogFlags ( ) ) ;
2026-03-28 10:58:12 -05:00
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 ,
config . config_path_interpete_py , config . config_path_py_env ) ;
2026-03-20 21:40:41 -05:00
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 ;
}
//---
2026-03-21 08:06:31 -05:00
CTrainingPyVisualizer * vis = new CTrainingPyVisualizer ( ) ;
2026-03-21 11:41:29 -05:00
vis . SetInitValues ( m_language , & m_tabs , AIDATATASRUNER_TRAINING_TAB_RES ) ; // visuzlaidor va con los mismo valores que donde esta
2026-03-21 08:06:31 -05:00
m_sec_config . AddRunnerPy ( vis ) ;
2026-03-20 21:40:41 -05:00
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
2026-03-21 08:06:31 -05:00
m_sec_visualizer . SetExtra ( vis ) ;
m_sec_visualizer . SetInitValues ( m_language , & m_tabs , AIDATATASRUNER_TRAINING_TAB_RES ) ;
2026-03-20 21:40:41 -05:00
if ( ! m_sec_visualizer . Create ( p , main_window , top_gap , left_gap , right_gap , bottom_gap ) )
{
AIDATATASKRUNER_ERROR_CREATION ( m_sec_visualizer ) ;
return false ;
}
2026-03-21 08:06:31 -05:00
else
{
m_sec_config . AddRunnerPy ( & m_sec_visualizer ) ;
}
2026-03-20 21:40:41 -05:00
//---
return true ;
}
2026-02-24 10:16:05 -05:00
//+------------------------------------------------------------------+
2026-03-20 21:40:41 -05:00
//| |
2026-02-24 10:16:05 -05:00
//+------------------------------------------------------------------+
2026-03-20 21:40:41 -05:00
void CTrainingTab : : OnLenguajeChange ( void )
{
2026-03-21 08:06:31 -05:00
//--- Actualizacion de las tabs
2026-03-20 21:40:41 -05:00
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 ;
}
2026-03-21 08:06:31 -05:00
const int t = m_tabs . TabsTotal ( ) ; // Solo iteramos sobre las que ya existen (es el total real si hay mas tamñao se omite)
2026-03-20 21:40:41 -05:00
for ( int i = 0 ; i < t ; i + + )
m_tabs . Text ( i , tab_header [ i ] ) ;
m_tabs . Update ( ) ;
//---
m_sec_config . OnLenguajeChange ( ) ;
2026-03-24 10:39:38 -05:00
m_sec_visualizer . OnLenguajeChange ( ) ; // cambio llamamo tambien dado que ahora el header lo puede necesiutar
2026-03-20 21:40:41 -05:00
}
2026-03-21 06:15:18 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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 ;
}
2026-02-24 10:16:05 -05:00
//+------------------------------------------------------------------+
2026-03-20 21:57:53 -05:00
# endif // AIDATATASKRUNER_UI_TRAINING_MAINTAB_MQH