//+------------------------------------------------------------------+ //| TFWndFrame.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 "..\..\Include\TF-Class\TFApp.mqh" #include #include #include #include #include //+------------------------------------------------------------------+ //| Resources | //+------------------------------------------------------------------+ #resource "\\Images\\TFGUI\\Close.bmp" #resource "\\Images\\TFGUI\\Right.bmp" #resource "\\Images\\TFGUI\\Left.bmp" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CTFWndFrame :CWndContainer //: public CTFApp //CWndContainer { private: CTFApp tfapp; CPanel m_frame_border; // Frame Rahmen CPanel m_frame_background; // Frame Hintergrund CEdit m_frame_caption; // Frame Kopfzeile CBmpButton m_frame_button_minmax; // Frame Button minmax CBmpButton m_frame_button_close; // Frame Button close CWndClient m_frame_client_area; // Frame Benutzerbereich //--- Koordinaten CRect m_frame_normal; // Frame Koordinaten normales Fenster CRect m_frame_minimized; // Frame Koordinaten minimiertes Fenster //--- Variablen string m_frame_name; // Name des Frames int ControlsBorderWidth; // Controls Rahmen Breite Standard 1 int ControlsButtonSize; // Controls Button weite Standard 16 int ControlsDialogButtonOff; // Controls Dialog Button offset Standard 3 int ControlsDialogCaptionHeight; // Controls Dialog Caption Kopf höhe 22 int ControlsDialogClientOff; // Controls Dialog Client offset Standard 2 color ControlsFrameBorderColorBorder; // Controls Frame Border Color Border C'0xF0,0xF0,0xF0' color ControlsFrameBorderColorBG; // Controls Frame Border Color BG C'0xF0,0xF0,0xF0' color ControlsFrameBGColorBorder; // Controls Frame BG Color Border C'0xF0,0xF0,0xF0' color ControlsFrameBGColorBG; // Controls Frame BG Color BG C'0xF0,0xF0,0xF0' //--- Flags bool m_panel_flag; // Frame integriertes Fenster flag bool m_minimized; // Frame minimiert flag protected: //--- create frame controls virtual bool CreateFrameBorder(void); virtual bool CreateFrameBackground(void); virtual bool CreateFrameCaption(void); virtual bool CreateFrameButtonMinMax(void); virtual bool CreateFrameButtonClose(void); virtual bool CreateFrameClientArea(void); void CaptionAlignment(const int flags,const int left,const int top,const int right,const int bottom) { m_frame_caption.Alignment(flags,left,top,right,bottom); } public: CTFWndFrame(); ~CTFWndFrame(); virtual bool Create(const long chart=0,const string name="Hauptfenster",const int subwin=0,const int x1=20,const int y1=20,const int x2=200,const int y2=100); // Frame erstellen virtual bool Load(const int file_handle); // Load Data virtual bool Save(const int file_handle); // Save Data virtual string FrameName(void) const { return(m_frame_name); } // Frame Namen auslesen virtual void FrameName(const string name) { m_frame_name=name; } // Frame Namen setzen virtual bool FrameNormalPosition(const int l=0,const int t=0,const int r=100,const int b=100); // virtual bool FrameMinimizedPosition(const int l=0,const int t=0,const int r=10,const int b=10); // }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ CTFWndFrame::CTFWndFrame() : m_panel_flag(false), m_minimized(false), ControlsBorderWidth(1), ControlsButtonSize(16), ControlsDialogButtonOff(3), ControlsDialogCaptionHeight(22), ControlsDialogClientOff(2), ControlsFrameBorderColorBorder(clrWhite), ControlsFrameBorderColorBG(clrBlue), ControlsFrameBGColorBorder(clrGray), ControlsFrameBGColorBorder(clrGreen) { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ CTFWndFrame::~CTFWndFrame() { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTFWndFrame::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2) { //--- call method of parent class tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); if(!CWndContainer::Create(chart,name,subwin,x1,y1,x2,y2)) return(false); //--- create frame controls tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); tfapp.Test(); if(!m_panel_flag && !CreateFrameBorder()) return(false); //Test(); //if(!CreateFrameBackground()) // return(false); ////Test(); // if(!CreateFrameCaption()) // return(false); ////Test(); // if(!CreateFrameClientArea()) // return(false); ////Test(); // if(!CreateFrameButtonMinMax()) // return(false); ////Test(); // if(!CreateFrameButtonClose()) // return(false); //Test(); //--- set up additional areas //Redraw(); //m_frame_normal.SetBound(m_rect); //DPrint("vor Disable"); //Test(); //m_frame_border.Disable(); tfapp.DPrint("vor Hide"); tfapp.Test(); m_frame_border.Hide(); tfapp.DPrint("vor Show"); tfapp.Test(); m_frame_border.Show(); // DPrint("vor Enable"); // Test(); ////m_frame_border.Enable(); ////DPrint("vor Hide Nach Enable"); ////Test(); // m_frame_background.Hide(); // DPrint("vor Show nach Enable"); // Test(); // m_frame_background.Show(); //DPrint("vor m_frame_minimized"); //Test(); //m_frame_border.Align(m_frame_minimized); //DPrint("vor m_frame_normal"); //Test(); //m_frame_border.Align(m_frame_normal); //Test(); //m_frame_border.Enable(); //int i; //for(i=1;i<11;i++) // { // m_frame_border.BorderType(BORDER_FLAT); // Test(); // m_frame_border.BorderType(BORDER_RAISED); // Test(); // m_frame_border.BorderType(BORDER_SUNKEN); // Test(); // } //--- fertig return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTFWndFrame::CreateFrameBorder(void) { //--- coordinates int x1=0; int y1=0; int x2=Width(); int y2=Height(); //--- create tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); if(!m_frame_border.Create(m_chart_id,m_name+"_Border",m_subwin,x1,y1,x2,y2)) return(false); tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); tfapp.Test(); if(!m_frame_border.ColorBorder(ControlsFrameBorderColorBorder)) return(false); tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); tfapp.Test(); if(!m_frame_border.ColorBackground(ControlsFrameBorderColorBG)) return(false); tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); tfapp.Test(); if(!Add(m_frame_border)) return(false); tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); tfapp.Test(); m_frame_border.Alignment(WND_ALIGN_CLIENT,0,0,0,0); tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); tfapp.Test(); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Create background | //+------------------------------------------------------------------+ bool CTFWndFrame::CreateFrameBackground(void) { int off=(m_panel_flag) ? 0:ControlsBorderWidth; //--- coordinates int x1=off; int y1=off; int x2=Width()-off; int y2=Height()-off; //--- create tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); if(!m_frame_background.Create(m_chart_id,m_name+"_BackGround",m_subwin,x1,y1,x2,y2)) return(false); tfapp.Test(); color border=(m_panel_flag) ? ControlsFrameBGColorBG : ControlsFrameBGColorBorder; if(!m_frame_background.ColorBorder(border)) return(false); tfapp.Test(); if(!m_frame_background.ColorBackground(ControlsFrameBGColorBG)) return(false); tfapp.Test(); if(!Add(m_frame_background)) return(false); tfapp.Test(); m_frame_background.Alignment(WND_ALIGN_CLIENT,off,off,off,off); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Create window title | //+------------------------------------------------------------------+ bool CTFWndFrame::CreateFrameCaption(void) { int off=(m_panel_flag) ? 0:2*ControlsBorderWidth; //--- coordinates int x1=off; int y1=off; int x2=Width()-off; int y2=y1+ControlsDialogCaptionHeight; //--- create tfapp.CAusgabe(ControlsFrameCaptionColorBG); tfapp.CAusgabe(ControlsFrameCaptionColorBorder); tfapp.CAusgabe(ControlsFrameCaptionColorText); tfapp. DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); if(!m_frame_caption.Create(m_chart_id,m_name+"_Caption",m_subwin,x1,y1,x2,y2)) return(false); if(!m_frame_caption.ColorBorder(ControlsFrameCaptionColorBorder)) return(false); if(!m_frame_caption.ColorBackground(ControlsFrameCaptionColorBG)) return(false); if(!m_frame_caption.Color(ControlsFrameCaptionColorText)) return(false); if(!m_frame_caption.ReadOnly(true)) return(false); if(!m_frame_caption.Text(m_name)) return(false); if(!CWndContainer::Add(m_frame_caption)) return(false); m_frame_caption.Alignment(WND_ALIGN_WIDTH,off,0,off,0); if(!m_panel_flag) m_frame_caption.PropFlags(WND_PROP_FLAG_CAN_DRAG); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Create client area | //+------------------------------------------------------------------+ bool CTFWndFrame::CreateFrameClientArea(void) { int off=(m_panel_flag) ? 0:2*ControlsBorderWidth; //--- coordinates int x1=off+ControlsDialogClientOff; int y1=off+ControlsDialogCaptionHeight; int x2=Width()-(off+ControlsDialogClientOff); int y2=Height()-(off+ControlsDialogClientOff); //--- create tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); if(!m_frame_client_area.Create(m_chart_id,m_name+"_ClientArea",m_subwin,x1,y1,x2,y2)) return(false); if(!m_frame_client_area.ColorBackground(ControlsFrameCAColorBG)) return(false); if(!m_frame_client_area.ColorBorder(ControlsFrameCAColorBorder)) return(false); if(!CWndContainer::Add(m_frame_client_area)) return(false); m_frame_client_area.Alignment(WND_ALIGN_CLIENT,x1,y1,x1,x1); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Create the "MinMax" button | //+------------------------------------------------------------------+ bool CTFWndFrame::CreateFrameButtonMinMax(void) { int off=(m_panel_flag) ? 0 : 2*ControlsBorderWidth; //--- coordinates int x1=Width()-off-2*(ControlsButtonSize+ControlsDialogButtonOff); int y1=off+ControlsDialogButtonOff; int x2=x1+ControlsButtonSize; int y2=y1+ControlsButtonSize; //--- create tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); if(!m_frame_button_minmax.Create(m_chart_id,m_name+"_ButtonMinMax",m_subwin,x1,y1,x2,y2)) return(false); if(!m_frame_button_minmax.BmpNames("\\Images\\TFGUI\\Right.bmp","\\Images\\TFGUI\\Left.bmp")) return(false); if(!CWndContainer::Add(m_frame_button_minmax)) return(false); m_frame_button_minmax.Locking(true); m_frame_button_minmax.Alignment(WND_ALIGN_RIGHT,0,0,off+ControlsButtonSize+2*ControlsDialogButtonOff,0); //--- change caption CaptionAlignment(WND_ALIGN_WIDTH,off,0,off+2*(ControlsButtonSize+ControlsDialogButtonOff),0); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Create the "Close" button | //+------------------------------------------------------------------+ bool CTFWndFrame::CreateFrameButtonClose(void) { int off=(m_panel_flag) ? 0 : 2*ControlsBorderWidth; //--- coordinates int x1=Width()-off-(ControlsButtonSize+ControlsDialogButtonOff); int y1=off+ControlsDialogButtonOff; int x2=x1+ControlsButtonSize; int y2=y1+ControlsButtonSize; //--- create tfapp.DPrint(__FUNCTION__+", m_chart_id = "+(string) m_chart_id); if(!m_frame_button_close.Create(m_chart_id,m_name+"_ButtonClose",m_subwin,x1,y1,x2,y2)) return(false); if(!m_frame_button_close.BmpNames("\\Images\\TFGUI\\Close.bmp")) return(false); if(!CWndContainer::Add(m_frame_button_close)) return(false); m_frame_button_close.Alignment(WND_ALIGN_RIGHT,0,0,off+ControlsDialogButtonOff,0); //--- change caption CaptionAlignment(WND_ALIGN_WIDTH,off,0,off+(ControlsButtonSize+ControlsDialogButtonOff),0); //--- succeed return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTFWndFrame::FrameNormalPosition(const int l,const int t,const int r,const int b) { m_frame_normal.left=l; m_frame_normal.top=t; m_frame_normal.right=r; m_frame_normal.bottom=b; return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool CTFWndFrame::FrameMinimizedPosition(const int l,const int t,const int r,const int b) { m_frame_minimized.left=l; m_frame_minimized.top=t; m_frame_minimized.right=r; m_frame_minimized.bottom=b; return(true); } //+------------------------------------------------------------------+ //| Load Data | //+------------------------------------------------------------------+ bool CTFWndFrame::Load(const int file_handle) { //--- tfapp.DPrint(__FUNCTION__+" durchlaufen"); //--- return(true); } //+------------------------------------------------------------------+ //| Save Data | //+------------------------------------------------------------------+ bool CTFWndFrame::Save(const int file_handle) { //--- tfapp.DPrint(__FUNCTION__+" durchlaufen"); //--- return(true); } //+------------------------------------------------------------------+