forked from nique_372/AiDataTaskRuner
298 lines
9.9 KiB
MQL5
298 lines
9.9 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Main.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_MAIN_MQH
|
|
#define AIDATATASKRUNER_UI_MAIN_MQH
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "AllTabs.mqh"
|
|
|
|
|
|
//---
|
|
#define TASKRUNERAIMAINTAB_TAB_DGEN (0)
|
|
#define TASKRUNERAIMAINTAB_TAB_ABOUT (1)
|
|
#define TASKRUNERAIMAINTAB_TAB_CONFIG (2)
|
|
#define TASKRUNERAIMAINTAB_TAB_TOTAL (3)
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CProgram : public CWndCreate
|
|
{
|
|
private:
|
|
//---
|
|
CLanguageConfigurator m_lenguaje;
|
|
const string m_class_name;
|
|
|
|
//--- Tabb principal
|
|
CTabs m_tabs;
|
|
CWindow m_window;
|
|
|
|
//--- Secciones
|
|
CTaskRunerAiTabDGenMain m_sec_generation_data;
|
|
CTaskRunerAiTabAbout m_sec_about;
|
|
CTaskRunerAiTabConfig m_sec_config;
|
|
|
|
//--- Eventos
|
|
bool OnClickBottom(const long lparam);
|
|
bool OnChangeDate(const long lparam, const double dparam); //dparm = date
|
|
bool OnTextEdit(const long lparam);
|
|
bool OnChangeComBox(const long lparam);
|
|
|
|
|
|
public:
|
|
CProgram(void) : m_class_name("CProgram") { }
|
|
~CProgram(void) {}
|
|
|
|
//---
|
|
CTaskRunerAiTabDGenMain* GetSecTaskRunerAiDGenPtr() { return &m_sec_generation_data; }
|
|
CTaskRunerAiTabAbout* GetSecAbout() { return &m_sec_about; }
|
|
|
|
//--- Funcion principal de creacion
|
|
// Se supone que top_gatp ya viene con el offset del tab
|
|
bool CreateGUI(int WIDTH_PANEL, int HEIGHT_PANEL, uchar log_flags);
|
|
|
|
//---
|
|
void OnEvent(const int id, const long &lparam, const double &dparam, const string &sparam) override;
|
|
void OnDeinitEvent(const int reason) { CWndEvents::Destroy(); }
|
|
void OnLenguajeChange();
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CProgram::CreateGUI(int WIDTH_PANEL, int HEIGHT_PANEL, uchar log_flags)
|
|
{
|
|
//---
|
|
if(!CPanelAiDataTaskRunnerIns::Downlad())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//---
|
|
m_lenguaje.AddLogFlags(log_flags);
|
|
if(!m_lenguaje.Init())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//---
|
|
int width_panel = fmax(WIDTH_PANEL, 300);
|
|
m_window.CaptionColor(AIDATATASKRUNER_WIN_COLOR_CAPTION);
|
|
m_window.CaptionColorHover(AIDATATASKRUNER_WIN_COLOR_CAPTION_HOVER);
|
|
m_window.CaptionColorLocked(AIDATATASKRUNER_WIN_COLOR_CAPTION_LOCKED);
|
|
m_window.BorderColor(AIDATATASKRUNER_COLOR_FONDO_WIN);
|
|
m_window.BackColor(AIDATATASKRUNER_COLOR_FONDO_WIN);
|
|
m_window.BackColorPressed(clrBlue);
|
|
m_window.Font("Arial Black");
|
|
if(!CWndCreate::CreateWindow(m_window, AIDATATASKRUNER_CAPTION, 0, 0, width_panel, HEIGHT_PANEL, true, false, true, true))
|
|
{
|
|
AIDATATASKRUNER_ERROR_CREATION_F(m_window);
|
|
return false;
|
|
}
|
|
|
|
//---
|
|
int left_gap = 2;
|
|
int top_gap = m_window.CaptionHeight() + 4;
|
|
int right_gap = 4;
|
|
int bottom_gap = 4;
|
|
//Print(top_gap); // Para tabs el y debe de inlcuir ya la cabezera
|
|
|
|
//---
|
|
int x = left_gap + 1;
|
|
int y = top_gap + 1;
|
|
|
|
//--- Creacion del control tabs
|
|
// header
|
|
string tab_header[];
|
|
const string str_header = m_lenguaje[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, TASKRUNERAIMAINTAB_TAB_TOTAL); // trim
|
|
|
|
// Propiedades
|
|
color clrs_tab_label[TASKRUNERAIMAINTAB_TAB_TOTAL] = {AIDATATASKRUNER_COLOR_TEXT_SECONDARY, AIDATATASKRUNER_COLOR_TEXT_SECONDARY, AIDATATASKRUNER_COLOR_TEXT_SECONDARY};
|
|
color clrs_tab_label_pressed[TASKRUNERAIMAINTAB_TAB_TOTAL] = {AIDATATASKRUNER_COLOR_ACCENT, AIDATATASKRUNER_COLOR_ACCENT, AIDATATASKRUNER_COLOR_ACCENT};
|
|
|
|
|
|
int widts[TASKRUNERAIMAINTAB_TAB_TOTAL];
|
|
ArrayInitialize(widts, 65);
|
|
x += 65;
|
|
|
|
m_tabs.BackColor(AIDATATASKRUNER_COLOR_FONDO_TAB);
|
|
m_tabs.BackColorHover(AIDATATASKRUNER_COLOR_FONDO_TAB_HOVER);
|
|
m_tabs.BackColorPressed(AIDATATASKRUNER_COLOR_FONDO_TAB_PRESSED);
|
|
m_tabs.BackColorLocked(AIDATATASKRUNER_COLOR_FONDO_TAB_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);
|
|
|
|
// Offset
|
|
right_gap += 2;
|
|
bottom_gap += 2;
|
|
|
|
// Creacion
|
|
if(!CWndCreate::CreateTabs(m_tabs, m_window, 0, x, y, 0, 0, tab_header, widts, clrs_tab_label, clrs_tab_label_pressed,
|
|
TABS_LEFT, true, true, right_gap, bottom_gap))
|
|
{
|
|
AIDATATASKRUNER_ERROR_CREATION_F(m_tabs);
|
|
return false;
|
|
}
|
|
|
|
//---
|
|
left_gap += m_tabs.SumWidthTabs() + 1;
|
|
top_gap += 1;
|
|
|
|
|
|
//--- Seccion generacino de datos
|
|
m_sec_generation_data.AddLogFlags(log_flags);
|
|
m_sec_generation_data.SetInitValues(&m_lenguaje, &m_tabs, TASKRUNERAIMAINTAB_TAB_DGEN);
|
|
if(!m_sec_generation_data.Create(&this, m_window, top_gap, left_gap, right_gap, bottom_gap))
|
|
{
|
|
AIDATATASKRUNER_ERROR_CREATION_F(m_sec_generation_data);
|
|
return false;
|
|
}
|
|
|
|
//--- Seccion About
|
|
m_sec_about.AddLogFlags(log_flags);
|
|
m_sec_about.SetInitValues(&m_lenguaje, &m_tabs, TASKRUNERAIMAINTAB_TAB_ABOUT);
|
|
if(!m_sec_about.Create(&this, m_window, top_gap, left_gap, right_gap, bottom_gap))
|
|
{
|
|
AIDATATASKRUNER_ERROR_CREATION_F(m_sec_about);
|
|
return false;
|
|
}
|
|
|
|
//--- Seccion About
|
|
m_sec_config.AddLogFlags(log_flags);
|
|
m_sec_config.SetInitValues(&m_lenguaje, &m_tabs, TASKRUNERAIMAINTAB_TAB_CONFIG);
|
|
if(!m_sec_config.Create(&this, m_window, top_gap, left_gap, right_gap, bottom_gap))
|
|
{
|
|
AIDATATASKRUNER_ERROR_CREATION_F(m_sec_about);
|
|
return false;
|
|
}
|
|
// agregamos las tabs restantes
|
|
m_sec_config.AddTab(&m_sec_about);
|
|
m_sec_config.AddTab(&m_sec_generation_data);
|
|
m_sec_config.SetBaseProgram(&this);
|
|
|
|
//---
|
|
CWndEvents::CompletedGUI();
|
|
|
|
//---
|
|
return true;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
void CProgram::OnEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
|
|
{
|
|
if(id == CHARTEVENT_CUSTOM + ON_END_EDIT)
|
|
{
|
|
OnTextEdit(lparam);
|
|
return;
|
|
}
|
|
if(id == CHARTEVENT_CUSTOM + ON_CLICK_BUTTON)
|
|
{
|
|
OnClickBottom(lparam);
|
|
return;
|
|
}
|
|
if(id == CHARTEVENT_CUSTOM + ON_CHANGE_DATE)
|
|
{
|
|
OnChangeDate(lparam, dparam);
|
|
return;
|
|
}
|
|
if(id == CHARTEVENT_CUSTOM + ON_CLICK_COMBOBOX_ITEM)
|
|
{
|
|
OnChangeComBox(lparam);
|
|
return;
|
|
}
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CProgram::OnChangeComBox(const long lparam)
|
|
{
|
|
if(m_tabs.SelectedTab() == TASKRUNERAIMAINTAB_TAB_DGEN)
|
|
return m_sec_generation_data.OnChangeComBox(lparam);
|
|
else
|
|
if(m_tabs.SelectedTab() == TASKRUNERAIMAINTAB_TAB_CONFIG)
|
|
m_sec_config.OnChangeComBox(lparam);
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CProgram::OnClickBottom(const long lparam)
|
|
{
|
|
if(m_tabs.SelectedTab() == TASKRUNERAIMAINTAB_TAB_DGEN)
|
|
return m_sec_generation_data.OnClickBottom(lparam);
|
|
else
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CProgram::OnChangeDate(const long lparam, const double dparam)
|
|
{
|
|
if(m_tabs.SelectedTab() == TASKRUNERAIMAINTAB_TAB_DGEN)
|
|
return m_sec_generation_data.OnChangeDate(lparam, dparam);
|
|
else
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CProgram::OnTextEdit(const long lparam)
|
|
{
|
|
if(m_tabs.SelectedTab() == TASKRUNERAIMAINTAB_TAB_DGEN)
|
|
return m_sec_generation_data.OnTextEdit(lparam);
|
|
else
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
void CProgram::OnLenguajeChange(void)
|
|
{
|
|
string tab_header[];
|
|
const string str_header = m_lenguaje[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;
|
|
}
|
|
ArrayResize(tab_header, TASKRUNERAIMAINTAB_TAB_TOTAL);
|
|
const int t = m_tabs.TabsTotal();
|
|
for(int i = 0; i < t; i++)
|
|
m_tabs.Text(i, tab_header[i]);
|
|
|
|
m_tabs.Update();
|
|
}
|
|
|
|
//---
|
|
#endif // AIDATATASKRUNER_UI_MAIN_MQH
|