184 lines
16 KiB
MQL5
184 lines
16 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| TFGUIDialog.mqh |
|
|
//| Thorsten Fischer Copyright 2020 |
|
|
//| https://mql5.tfsystem.de |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Thorsten Fischer Copyright 2020"
|
|
#property link "https://mql5.tfsystem.de"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//---
|
|
#include "..\..\TF-Dateien\TF-Class\TFLog.mqh"
|
|
#include "..\..\TF-Dateien\TF-Class\TFAppDialog.mqh"
|
|
#include "..\..\TF-Dateien\TF-Class\TFEdit.mqh"
|
|
#include "..\..\TF-Dateien\TF-Class\TFLabel.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| defines |
|
|
//+------------------------------------------------------------------+
|
|
//--- indents and gaps
|
|
#define INDENT_LEFT (5) // indent from left (with allowance for border width)
|
|
#define INDENT_TOP (5) // indent from top (with allowance for border width)
|
|
#define INDENT_RIGHT (5) // indent from right (with allowance for border width)
|
|
#define INDENT_BOTTOM (5) // indent from bottom (with allowance for border width)
|
|
#define CONTROLS_GAP_X (5) // gap by X coordinate
|
|
#define CONTROLS_GAP_Y (5) // gap by Y coordinate
|
|
#define CONTROLS_GAP_LABEL_EDIT (45) // gap by X coordinate
|
|
//--- for buttons
|
|
#define BUTTON_WIDTH (100) // size by X coordinate
|
|
#define BUTTON_HEIGHT (20) // size by Y coordinate
|
|
//--- for the indication area
|
|
#define LABEL_WIDTH (140) // size by X coordinate
|
|
#define LABEL_HEIGHT (20) // size by Y coordinate
|
|
//--- for the indication area
|
|
#define EDIT_WIDTH (30) // size by X coordinate
|
|
#define EDIT_HEIGHT (20) // size by Y coordinate
|
|
//--- for checkbox
|
|
#define CHECK_WIDTH (180) // size by x coordinate
|
|
#define CHECK_HEIGHT (20) // size by Y coordinate
|
|
//--- for group controls
|
|
#define GROUP_CONTROLS_GAP_Y (0) // gap by Y coordinate
|
|
#define GROUP_WIDTH (150) // size by X coordinate
|
|
#define LIST_HEIGHT (179) // size by Y coordinate
|
|
#define RADIO_HEIGHT (56) // size by Y coordinate
|
|
#define GROUP_CHECK_HEIGHT (93) // size by Y coordinate
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CTFGUIDialog : public CTFAppDialog
|
|
{
|
|
private:
|
|
//---
|
|
CTFLabel m_label_strategie_o;
|
|
CTFEdit m_edit_strategie_o;
|
|
string c_Strategie_Open;
|
|
|
|
public:
|
|
CTFGUIDialog();
|
|
~CTFGUIDialog();
|
|
//---
|
|
virtual bool Create(const long chart, const string name, const int subwin, const int x1, const int y1, const int x2, const int y2);
|
|
virtual void Destroy(const int aReason=0);
|
|
virtual bool OnEvent(const int id, const long &lparam, const double &dparam, const string &sparam);
|
|
//---
|
|
virtual void StrategieOpen(const string aText) {c_Strategie_Open=aText;}
|
|
virtual string StrategieOpen(void) {return(c_Strategie_Open);}
|
|
|
|
protected:
|
|
|
|
bool CreateLabelStrategieO(void);
|
|
bool CreateEditStrategieO(void);
|
|
|
|
//--- handlers of the dependent controls events
|
|
void OnEndEditStrategieO(void);
|
|
|
|
};
|
|
//+------------------------------------------------------------------+
|
|
//| Event Handling |
|
|
//+------------------------------------------------------------------+
|
|
EVENT_MAP_BEGIN(CTFGUIDialog)
|
|
ON_EVENT(ON_END_EDIT, m_edit_strategie_o, OnEndEditStrategieO)
|
|
EVENT_MAP_END(CAppDialog)
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
CTFGUIDialog::CTFGUIDialog()
|
|
{
|
|
//---
|
|
c_Strategie_Open="000";
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
CTFGUIDialog::~CTFGUIDialog()
|
|
{
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CTFGUIDialog::Create(const long chart, const string name, const int subwin, const int x1, const int y1, const int x2, const int y2)
|
|
{
|
|
//---
|
|
if(!CTFAppDialog::Create(chart, name, subwin, x1, y1, x2, y2))
|
|
return(false);
|
|
//--- create dependent controls
|
|
if(!CreateLabelStrategieO())
|
|
return(false);
|
|
if(!CreateEditStrategieO())
|
|
return(false);
|
|
//--- succeed
|
|
return(true);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
void CTFGUIDialog::Destroy(const int aReason=0)
|
|
{
|
|
//---
|
|
CAppDialog::Destroy(aReason);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CTFGUIDialog::CreateLabelStrategieO(void)
|
|
{
|
|
//--- coordinates
|
|
int x1=INDENT_LEFT+EDIT_WIDTH+CONTROLS_GAP_X;
|
|
int y1=INDENT_TOP ;
|
|
int x2=x1+LABEL_WIDTH;
|
|
int y2=y1+LABEL_HEIGHT;
|
|
//--- create
|
|
if(!m_label_strategie_o.Create(m_chart_id, m_name+"LabelStrategieO", m_subwin, x1, y1, x2, y2))
|
|
return(false);
|
|
if(!m_label_strategie_o.Color(clrBlue))
|
|
return(false);
|
|
if(!m_label_strategie_o.Text("Strategie Open = "+c_Strategie_Open))
|
|
return(false);
|
|
if(!Add(m_label_strategie_o))
|
|
return(false);
|
|
//--- succeed
|
|
return(true);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CTFGUIDialog::CreateEditStrategieO(void)
|
|
{
|
|
//--- coordinates
|
|
int x1=INDENT_LEFT;
|
|
int y1=INDENT_TOP ;
|
|
int x2=x1+EDIT_WIDTH;
|
|
int y2=y1+EDIT_HEIGHT;
|
|
//--- create
|
|
if(!m_edit_strategie_o.Create(m_chart_id, m_name+"EditStrategieO", m_subwin, x1, y1, x2, y2))
|
|
return(false);
|
|
if(!m_edit_strategie_o.Color(clrBlue))
|
|
return(false);
|
|
if(!m_edit_strategie_o.Text((string)c_Strategie_Open))
|
|
return(false);
|
|
if(!Add(m_edit_strategie_o))
|
|
return(false);
|
|
//--- succeed
|
|
return(true);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Event handler |
|
|
//+------------------------------------------------------------------+
|
|
void CTFGUIDialog::OnEndEditStrategieO(void)
|
|
{
|
|
//---
|
|
int aValue=(int)StringToInteger(m_edit_strategie_o.Text());
|
|
if(aValue>=0 && aValue<1000)
|
|
StrategieOpen((string)aValue);
|
|
else
|
|
PrintLogInfo("Strategie Open darf nicht kleiner als 0 und größer als 999 sein. (0-999)");
|
|
//---
|
|
m_label_strategie_o.Text("Strategie Open = "+StrategieOpen());
|
|
m_edit_strategie_o.Text(StrategieOpen());
|
|
|
|
//---
|
|
ChartRedraw();
|
|
}
|
|
//+------------------------------------------------------------------+
|