AiDataTaskRuner/UI/TabUtil/General.mqh
Nique_372 b2142ea9b4
2026-03-29 11:06:50 -05:00

219 lines
9.3 KiB
MQL5

//+------------------------------------------------------------------+
//| General.mqh |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com/es/users/nique_372"
#property strict
#ifndef AIDATATASKRUNER_UI_TABUTIL_GENERAL_MQH
#define AIDATATASKRUNER_UI_TABUTIL_GENERAL_MQH
//+------------------------------------------------------------------+
//| Include |
//+------------------------------------------------------------------+
#include "..\\Defines.mqh"
//---
string g_tabuils_arr_type_folder[2] =
{
"MQL5\\Files folder",
"Common folder"
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CTabUtilsGeneral : public CGuiBaseComponent<CLoggerBase>
{
private:
//-- Titulo
CTextLabel m_label_tit_general_config; // General
// Sobre que trabaja
CComboBox m_combox_common_or_files;
int m_common_flag;
bool m_common_flag_val;
// Archivo main folder
CTextLabel m_label_file_main;
CTextLabel m_label_file_main_val;
CButton m_btn_browse_file_main;
string m_main_folder;
public:
CTabUtilsGeneral(void) : CGuiBaseComponent<CLoggerBase>("CTabUtilsGeneral"), m_common_flag_val(false), m_common_flag(0) {}
~CTabUtilsGeneral(void) {}
//---
bool Create(CWndCreate* p, CWindow& main_window, int top_gap, int left_gap, int right_gap, int bottom_gap);
//---
bool OnClickButtom(const long lparam);
void OnLenguajeChange() override final;
bool OnComboxItemClick(const long lparam);
//---
__forceinline string MainFolder() const { return m_main_folder; }
__forceinline bool ComonFlagVal() const { return m_common_flag_val; }
__forceinline int ComonFlag() const { return m_common_flag; }
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CTabUtilsGeneral::Create(CWndCreate* p, CWindow& main_window, int top_gap, int left_gap, int right_gap, int bottom_gap)
{
//---
int x = left_gap + 5;
int y = top_gap + 10;
const int inital_x = x;
//--- Titulo general
m_label_tit_general_config.FontSize(14);
m_label_tit_general_config.Font("Arial");
m_label_tit_general_config.LabelColor(AIDATATASKRUNER_COLOR_TEXT_PRIMARY);
m_label_tit_general_config.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
if(!p.CreateTextLabel(m_label_tit_general_config, m_language[GUIBASE_COMPONENT_NAME(m_label_tit_general_config)],
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 200))
{
GUIBASE_ERROR_CREATION(m_label_tit_general_config);
return false;
}
y += m_label_tit_general_config.YSize() + 10;
//--- ComboBox common/files
m_combox_common_or_files.FontSize(10);
m_combox_common_or_files.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_combox_common_or_files.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
m_combox_common_or_files.GetListViewPointer().BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_combox_common_or_files.GetListViewPointer().BorderColor(AIDATATASKRUNER_COLOR_EDIT_BORDER);
m_combox_common_or_files.GetListViewPointer().LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_combox_common_or_files.GetButtonPointer().LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_combox_common_or_files.GetButtonPointer().BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_combox_common_or_files.GetButtonPointer().BorderColor(AIDATATASKRUNER_COLOR_EDIT_BORDER);
m_combox_common_or_files.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_combox_common_or_files)));
if(!p.CreateCombobox(m_combox_common_or_files, m_language[GUIBASE_COMPONENT_NAME(m_combox_common_or_files)],
main_window, 0, m_base_tab, m_base_tab_idx, false, x, y, 125 + 10 + 110, 125,
g_tabuils_arr_type_folder, 150))
{
GUIBASE_ERROR_CREATION(m_combox_common_or_files);
return false;
}
m_combox_common_or_files.m_button.IconFile(RESOURCE_DOWN_THIN_WHITE);
m_combox_common_or_files.m_button.IconFileLocked(RESOURCE_DOWN_THIN_WHITE);
m_combox_common_or_files.m_button.CElement::IconFilePressed(RESOURCE_UP_THIN_WHITE);
m_combox_common_or_files.m_button.CElement::IconFilePressedLocked(RESOURCE_UP_THIN_WHITE);
//---
y += m_combox_common_or_files.YSize() + 10;
//--- Label main folder
m_label_file_main.FontSize(10);
m_label_file_main.Font("Arial");
m_label_file_main.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_label_file_main.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
if(!p.CreateTextLabel(m_label_file_main, m_language[GUIBASE_COMPONENT_NAME(m_label_file_main)],
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 80, 25))
{
GUIBASE_ERROR_CREATION(m_label_file_main);
return false;
}
x += m_label_file_main.XSize() + 5;
//--- Label val main folder
m_label_file_main_val.FontSize(10);
m_label_file_main_val.Font("Arial");
m_label_file_main_val.LabelColor(AIDATATASKRUNER_COLOR_TEXT_PRIMARY);
m_label_file_main_val.BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_label_file_main_val.LabelXGap(5);
m_label_file_main_val.LabelYGap(3);
m_label_file_main_val.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_label_file_main_val)));
if(!p.CreateTextLabel(m_label_file_main_val, "",
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 350, 25))
{
GUIBASE_ERROR_CREATION(m_label_file_main_val);
return false;
}
x = inital_x;
y += m_label_file_main_val.YSize() + 8;
//--- Browse main folder
m_btn_browse_file_main.AddImagesGroup(5, 2, g_eafmod_ic_arr_folderw10_image);
m_btn_browse_file_main.ChangeImage(0, 0);
m_btn_browse_file_main.LabelXGap(22);
m_btn_browse_file_main.FontSize(10);
m_btn_browse_file_main.Font("Arial");
m_btn_browse_file_main.BackColor(AIDATATASKRUNER_COLOR_BTN_BACK);
m_btn_browse_file_main.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_btn_browse_file_main.BorderColor(AIDATATASKRUNER_COLOR_BTN_BORDER);
m_btn_browse_file_main.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_browse_file_main)));
if(!p.CreateButton(m_btn_browse_file_main, m_language[GUIBASE_COMPONENT_NAME(m_btn_browse_file_main)],
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 100))
{
GUIBASE_ERROR_CREATION(m_btn_browse_file_main);
return false;
}
//x = inital_x;
//y += m_btn_browse_file_main.YSize() + 20; // gap mayor al final de seccion
//---
return true;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CTabUtilsGeneral::OnLenguajeChange(void)
{
UpdateTBasic(m_label_tit_general_config, GUIBASE_COMPONENT_NAME(m_label_tit_general_config), false);
ResizeTElement(m_combox_common_or_files, GUIBASE_COMPONENT_NAME(m_combox_common_or_files), 125, 10);
UpdateTBasic(m_label_file_main, GUIBASE_COMPONENT_NAME(m_label_file_main), false);
UpdateTBasic(m_btn_browse_file_main, GUIBASE_COMPONENT_NAME(m_btn_browse_file_main), true);
m_label_file_main_val.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_label_file_main_val)));
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CTabUtilsGeneral::OnComboxItemClick(const long lparam)
{
if(m_combox_common_or_files.Id() == lparam)
{
m_common_flag = m_combox_common_or_files.GetListViewPointer().SelectedItemIndex() * FILE_COMMON;
m_common_flag_val = m_common_flag == FILE_COMMON;
return true;
}
return false;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CTabUtilsGeneral::OnClickButtom(const long lparam)
{
//--- Main folder
if(m_btn_browse_file_main.Id() == lparam)
{
//---
string arr[];
if(FileSelectDialog(GUIBASE_MSG("flselect_main_folder"), NULL, NULL, (m_common_flag_val ? FILE_COMMON : 0) | FSD_SELECT_FOLDER,
arr, NULL) != 1)
{
MessageBox(GUIBASE_MSG("error_select_file"), GUIBASE_COMMON("error"), MB_ICONERROR | MB_OK);
return true;
}
//---
arr[0] += "\\";
m_label_file_main_val.LabelText(arr[0]); // ruta completa aqui
m_label_file_main_val.Update(true);
m_main_folder = arr[0];
return true;
}
//---
return false;
}
//+------------------------------------------------------------------+
#endif // AIDATATASKRUNER_UI_TABUTIL_GENERAL_MQH