//+------------------------------------------------------------------+ //| 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 (50) // 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; CTFEdit m_edit_strategie; string s_Strategie; string s_Strategie_Name; int i_String_Len; 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 Strategie(const string aText) {s_Strategie=aText;} virtual string Strategie(void) {return(s_Strategie);} virtual void StrategieName(const string aText) {s_Strategie_Name=aText;} virtual string StrategieName(void) {return(s_Strategie_Name);} virtual void SetStringLen(const int aValue) {i_String_Len=aValue;} virtual int GetStringLen(void) {return(i_String_Len);} protected: //--- bool CreateLabelStrategie(void); bool CreateEditStrategie(void); //--- handlers of the dependent controls events void OnEndEditStrategie(void); }; //+------------------------------------------------------------------+ //| Event Handling | //+------------------------------------------------------------------+ EVENT_MAP_BEGIN(CTFGUIDialog) ON_EVENT(ON_END_EDIT, m_edit_strategie, OnEndEditStrategie) EVENT_MAP_END(CAppDialog) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ CTFGUIDialog::CTFGUIDialog() { //--- s_Strategie=""; s_Strategie_Name=""; i_String_Len=0; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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(!CreateLabelStrategie()) return(false); if(!CreateEditStrategie()) return(false); //--- //CDialog::m_button_close.Hi//--- //de(); //--- succeed return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CTFGUIDialog::Destroy(const int aReason=0) { //--- CAppDialog::Destroy(aReason); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTFGUIDialog::CreateLabelStrategie(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.Create(m_chart_id, m_name+GetFunctionsName(__FUNCTION__), m_subwin, x1, y1, x2, y2)) return(false); if(!m_label_strategie.Color(clrBlue)) return(false); if(!m_label_strategie.Text(s_Strategie_Name+" = "+s_Strategie)) return(false); if(!Add(m_label_strategie)) return(false); //--- succeed return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTFGUIDialog::CreateEditStrategie(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.Create(m_chart_id, m_name+GetFunctionsName(__FUNCTION__), m_subwin, x1, y1, x2, y2)) return(false); if(!m_edit_strategie.Color(clrBlue)) return(false); if(!m_edit_strategie.Text(s_Strategie)) return(false); if(!Add(m_edit_strategie)) return(false); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Event handler | //+------------------------------------------------------------------+ void CTFGUIDialog::OnEndEditStrategie(void) { //--- int aValue=(int)StringToInteger(m_edit_strategie.Text()); if(aValue>=0 && StringLen((string)aValue)<=i_String_Len) Strategie((string)aValue); else PrintLogInfo(StringFormat(s_Strategie_Name+" darf nicht kleiner als 0 und größer als %s sein. (0-%s)", StringSubstr("99999", 0, i_String_Len), StringSubstr("99999", 0, i_String_Len))); //--- m_label_strategie.Text(s_Strategie_Name+" = "+s_Strategie); m_edit_strategie.Text(Strategie()); //--- ChartRedraw(); } //+------------------------------------------------------------------+