//+------------------------------------------------------------------+ //| TCGUI.mqh | //| Thorsten Fischer Copyright 2019 | //| https://www.tfsystem.de | //+------------------------------------------------------------------+ #property copyright "Thorsten Fischer Copyright 2019" #property link "https://www.tfsystem.de" #property version "1.00" #include "TCParameter.mqh" //#include #include #include //#include //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CTCGUI : public CWndContainer { private: CTFWndFrame m_main_frame; // Hauptfenster CButton m_button1; CButton m_button2; long m_testchartid; color m_testcolor; public: CTCGUI(); ~CTCGUI(); //void ChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam); //virtual int OnInitEvent(void); void FensterAuslesen(void); virtual bool Create(void); // GUI erstellen virtual void Destroy(const int reason=REASON_PROGRAM); // GUI entfernen virtual bool OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam); virtual bool Load(const int file_handle); // Load Data virtual bool Save(const int file_handle); // Save Data protected: bool CreateButton1(void); void OnClickButton1(void); bool CreateButton2(void); void OnClickButton2(void); //CChart m_chart; // Übergeordneter Chart }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ EVENT_MAP_BEGIN(CTCGUI) ON_EVENT(ON_CLICK,m_button1,OnClickButton1) ON_EVENT(ON_CLICK,m_button2,OnClickButton2) EVENT_MAP_END(CTCGUI) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ CTCGUI::CTCGUI() { //--- initialisieren //GUIName(ProgrammName); m_main_frame.FrameName(MainFrameName); m_main_frame.FrameNormalPosition(MainFrameLeft,MainFrameTop,MainFrameRight,MainFrameBottom); m_main_frame.FrameMinimizedPosition(); //m_main_frame.Top(0); //m_main_frame.m_frame_normal.RightBottom((int)ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0),(int)ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0)); //m_main_frame.Bottom((int)ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0)); //m_main_frame.SetNormalPosition(ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0)-400,0,ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0),ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0)); //m_chart_window_height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0); //m_window_width=400; //m_window_height=m_chart_window_height; //m_window_x=m_chart_window_width-m_window_width; //m_window_y=0; //DPrint(__FUNCTION__+" ende"); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ CTCGUI::~CTCGUI() { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //int CTCGUI::OnInitEvent(void) // { ////--- // if(!Create()) // return(false); // //// DPrint(__FUNCTION__+" anfang"); //// m_program_name=MQLInfoString(MQL_PROGRAM_NAME); //// m_chart_window_width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0); //// m_chart_window_height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0); ////DPrint("Width vorher = "+m_window_width); ////m_window_width=200; ////DPrint("Width nachher = "+m_window_width); //// m_window_height=m_chart_window_height; //// m_window_x=m_chart_window_width-m_window_width; //// m_window_y=0; //// ////DPrint("Char-ID = "+ChartID()); ////DPrint("Window-ID = "+Window()); ////DPrint("Window-Name = "+Name()); ////--- // return(true); // } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTCGUI::Create(void) { //--- if(!m_main_frame.Create()) DPrint(__FUNCTION__+" > Fehler bei dem erstellen des Frames"); //--- ChartRedraw(); //--- succeed return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CTCGUI::Destroy(const int reason) { //--- destroyed already? //if(m_deinit_reason!=WRONG_VALUE) // return; //--- //m_deinit_reason=reason; //IniFileSave(); //--- detach chart object from chart //m_chart.Detach(); //--- call parent destroy //CDialog::Destroy(); //CWndContainer::Destroy(); //CTFWndFrame::Destroy(); m_main_frame.Destroy(reason); //--- //if(reason==REASON_PROGRAM) // { // if(m_program_type==PROGRAM_EXPERT) // ExpertRemove(); // if(m_program_type==PROGRAM_INDICATOR) // ChartIndicatorDelete(m_chart_id,m_subwin,m_indicator_name); // } //--- send message //EventChartCustom(CONTROLS_SELF_MESSAGE,ON_APP_CLOSE,m_subwin,0.0,m_program_name); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //void CTFGUI::ChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam) // { // } //+------------------------------------------------------------------+ //| Load Data | //+------------------------------------------------------------------+ bool CTCGUI::Load(const int file_handle) { //--- DPrint(__FUNCTION__+" durchlaufen"); //--- return(true); } //+------------------------------------------------------------------+ //| Save Data | //+------------------------------------------------------------------+ bool CTCGUI::Save(const int file_handle) { //--- DPrint(__FUNCTION__+" durchlaufen"); //--- return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Create the "Button1" button | //+------------------------------------------------------------------+ bool CTCGUI::CreateButton1(void) { //--- coordinates int x1=INDENT_LEFT; // x1 = 11 pixels int y1=INDENT_TOP; // y1 = 11 pixels int x2=x1+BUTTON_WIDTH; // x2 = 11 + 100 = 111 pixels int y2=y1+BUTTON_HEIGHT; // y2 = 11 + 20 = 32 pixels //--- create if(!m_button1.Create(0,"Button1",0,x1,y1,x2,y2)) return(false); if(!m_button1.Text("Client Color")) return(false); //if(!Add(m_button1)) // return(false); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Create the "Button2" button | //+------------------------------------------------------------------+ bool CTCGUI::CreateButton2(void) { //--- coordinates int x1=INDENT_LEFT+BUTTON_WIDTH+CONTROLS_GAP_X; // x1 = 11 + 100 + 5 = 116 pixels int y1=INDENT_TOP; // y1 = 11 pixels int x2=x1+BUTTON_WIDTH; // x2 = 11 + 100 = 111 pixels int y2=y1+BUTTON_HEIGHT; // y2 = 11 + 20 = 32 pixels //--- create if(!m_button2.Create(0,"Button2",0,x1,y1,x2,y2)) return(false); if(!m_button2.Text("Caption Color")) return(false); //if(!CWndContainer::Add(m_button2)) // return(false); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Event handler | //+------------------------------------------------------------------+ void CTCGUI::OnClickButton1(void) { // string prefix=Name(); // int total=testPanel.ControlsTotal(); // for(int i=0;i