| //+------------------------------------------------------------------+
|
| //| HorLine.mqh |
|
| //| Copyright 2025, Niquel Mendoza. |
|
| //| https://www.mql5.com/es/users/nique_372/news |
|
| //+------------------------------------------------------------------+
|
| #property copyright "Copyright 2025, Niquel Mendoza."
|
| #property link "https://www.mql5.com/es/users/nique_372/news"
|
| #property strict
|
|
|
|
|
|
|
| #ifndef GRAPICHSBYLEO_GENERAL_HORLINE_MQH
|
| #define GRAPICHSBYLEO_GENERAL_HORLINE_MQH
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| #include "Base.mqh"
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| #define CCanvasHorLine_CompleteClean m_canvas.LineHorizontal(m_c1, m_c2, m_ci, m_clr_clean)
|
| #define CCanvasHorLine_DrawComplete m_canvas.LineHorizontal(m_c1, m_c2, m_ci, m_clr)
|
|
|
| //---
|
| class CCanvasHorLine : public CCanvasLineSimpleBase
|
| {
|
| public:
|
| CCanvasHorLine(int ci, int c1, int c2, uint clr, uint clr_clean, CCanvasCustom* c)
|
| : CCanvasLineSimpleBase(ci, c1, ci, c2, clr, clr_clean, c) {}
|
| ~CCanvasHorLine(void) {}
|
|
|
| //---
|
| void CleanPx() override { CCanvasHorLine_CompleteClean; }
|
| void Draw() override { CCanvasHorLine_DrawComplete; }
|
|
|
| //--- Getters y setters
|
| // C1
|
| void C1(int new_value) override;
|
|
|
| // C2
|
| void C2(int new_value) override;
|
|
|
| // Ce
|
| void Ce(int new_value) override { Ci(new_value); }
|
| };
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CCanvasHorLine::C1(int new_value)
|
| {
|
| const int change = (new_value - m_c1);
|
| if(change > 0)
|
| {
|
| const int xclean = fmin(new_value, m_c2);
|
| m_canvas.LineHorizontal(m_c1, xclean - 1, m_ci, m_clr_clean);
|
| m_c1 = xclean;
|
| }
|
| else
|
| if(change < 0)
|
| {
|
| m_canvas.LineHorizontal(new_value, m_c1 - 1, m_ci, m_clr);
|
| m_c1 = new_value;
|
| }
|
| }
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CCanvasHorLine::C2(int new_value)
|
| {
|
| const int change = (new_value - m_c2);
|
| if(change > 0)
|
| {
|
| m_canvas.LineHorizontal(m_c2 + 1, new_value, m_ci, m_clr);
|
| m_c2 = new_value;
|
| }
|
| else
|
| if(change < 0)
|
| {
|
| const int xin = fmax(new_value, m_c1);
|
| m_canvas.LineHorizontal(xin + 1, m_c2, m_ci, m_clr_clean);
|
| m_c2 = xin;
|
| }
|
| }
|
|
|
| #undef CCanvasHorLine_CompleteClean
|
| #undef CCanvasHorLine_DrawComplete
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| #define CCanvasHorLine_CompleteClean m_canvas.LineAA(m_c1, m_ci, m_c2, m_ci, m_clr_clean, m_style)
|
| #define CCanvasHorLine_DrawComplete m_canvas.LineAA(m_c1, m_ci, m_c2, m_ci, m_clr, m_style)
|
|
|
| //---
|
| class CCanvasHorLineAA : public CCanvasLineAASimple
|
| {
|
| public:
|
| CCanvasHorLineAA(int ci, int c1, int c2, uint clr, uint clr_clean, CCanvasCustom* c, uint style)
|
| : CCanvasLineAASimple(ci, c1, ci, c2, clr, clr_clean, c, style) {}
|
| ~CCanvasHorLineAA(void) {}
|
|
|
| //---
|
| void CleanPx() override { CCanvasHorLine_CompleteClean; }
|
| void Draw() override { CCanvasHorLine_DrawComplete; }
|
|
|
| //--- Getters y setters
|
| // C1
|
| void C1(int new_value) override;
|
|
|
| // C2
|
| void C2(int new_value) override;
|
|
|
| // Ce
|
| void Ce(int new_value) override { Ci(new_value); }
|
| };
|
|
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CCanvasHorLineAA::C1(int new_value)
|
| {
|
| const int change = (new_value - m_c1);
|
| if(change > 0)
|
| {
|
| const int xclean = fmin(new_value, m_c2);
|
| m_canvas.LineAA(m_c1, m_ci, xclean - 1, m_ci, m_clr_clean, m_style);
|
| m_c1 = xclean;
|
| }
|
| else
|
| if(change < 0)
|
| {
|
| m_canvas.LineAA(new_value, m_ci, m_c1 - 1, m_ci, m_clr, m_style);
|
| m_c1 = new_value;
|
| }
|
| }
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CCanvasHorLineAA::C2(int new_value)
|
| {
|
| const int change = (new_value - m_c2);
|
| if(change > 0)
|
| {
|
| m_canvas.LineAA(m_c2 + 1, m_ci, new_value, m_ci, m_clr, m_style);
|
| m_c2 = new_value;
|
| }
|
| else
|
| if(change < 0)
|
| {
|
| const int xin = fmax(new_value, m_c1);
|
| m_canvas.LineAA(xin + 1, m_ci, m_c2, m_ci, m_clr_clean, m_style);
|
| m_c2 = xin;
|
| }
|
| }
|
|
|
| #undef CCanvasHorLine_CompleteClean
|
| #undef CCanvasHorLine_DrawComplete
|
|
|
| //+------------------------------------------------------------------+
|
| #endif
|
|
|
| //+------------------------------------------------------------------+
|