164 行
5.5 KiB
MQL5
164 行
5.5 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| VerticalLine.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_VERTICALLINE_MQH
|
|
#define GRAPICHSBYLEO_GENERAL_VERTICALLINE_MQH
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "Base.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#define CCanvasVerLine_CompleteClean m_canvas.LineVertical(m_ci, m_c1, m_c2, m_clr_clean)
|
|
#define CCanvasVerLine_DrawComplete m_canvas.LineVertical(m_ci, m_c1, m_c2, m_clr)
|
|
|
|
//---
|
|
class CCanvasVerLine : public CCanvasLineSimpleBase
|
|
{
|
|
public:
|
|
CCanvasVerLine(int ci, int c1, int c2, uint clr, uint clr_clean, CCanvasCustom* c)
|
|
: CCanvasLineSimpleBase(ci, c1, ci, c2, clr, clr_clean, c) {}
|
|
~CCanvasVerLine(void) {}
|
|
|
|
//---
|
|
void CleanPx() override { CCanvasVerLine_CompleteClean; }
|
|
void Draw() override { CCanvasVerLine_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 CCanvasVerLine::C1(int new_value)
|
|
{
|
|
const int change = (new_value - m_c1);
|
|
if(change > 0)
|
|
{
|
|
const int yclean = fmin(new_value, m_c2);
|
|
m_canvas.LineVertical(m_ci, m_c1, yclean - 1, m_clr_clean);
|
|
m_c1 = yclean;
|
|
}
|
|
else
|
|
if(change < 0)
|
|
{
|
|
m_canvas.LineVertical(m_ci, new_value, m_c1 - 1, m_clr);
|
|
m_c1 = new_value;
|
|
}
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
void CCanvasVerLine::C2(int new_value)
|
|
{
|
|
const int change = (new_value - m_c2);
|
|
if(change > 0)
|
|
{
|
|
m_canvas.LineVertical(m_ci, m_c2 + 1, new_value, m_clr);
|
|
m_c2 = new_value;
|
|
}
|
|
else
|
|
if(change < 0)
|
|
{
|
|
const int yin = fmax(new_value, m_c1);
|
|
m_canvas.LineVertical(m_ci, yin + 1, m_c2, m_clr_clean);
|
|
m_c2 = yin;
|
|
}
|
|
}
|
|
|
|
#undef CCanvasVerLine_CompleteClean
|
|
#undef CCanvasVerLine_DrawComplete
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#define CCanvasVerLine_CompleteClean m_canvas.LineAA(m_ci, m_c1, m_ci, m_c2, m_clr_clean, m_style)
|
|
#define CCanvasVerLine_DrawComplete m_canvas.LineAA(m_ci, m_c1, m_ci, m_c2, m_clr, m_style)
|
|
|
|
//---
|
|
class CCanvasVerLineAA : public CCanvasLineAASimple
|
|
{
|
|
public:
|
|
CCanvasVerLineAA(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) {}
|
|
~CCanvasVerLineAA(void) {}
|
|
|
|
//---
|
|
void CleanPx() override { CCanvasVerLine_CompleteClean; }
|
|
void Draw() override { CCanvasVerLine_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 CCanvasVerLineAA::C1(int new_value)
|
|
{
|
|
const int change = (new_value - m_c1);
|
|
if(change > 0)
|
|
{
|
|
const int yclean = fmin(new_value, m_c2);
|
|
m_canvas.LineAA(m_ci, m_c1, m_ci, yclean - 1, m_clr_clean, m_style);
|
|
m_c1 = yclean;
|
|
}
|
|
else
|
|
if(change < 0)
|
|
{
|
|
m_canvas.LineAA(m_ci, new_value, m_ci, m_c1 - 1, m_clr, m_style);
|
|
m_c1 = new_value;
|
|
}
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
void CCanvasVerLineAA::C2(int new_value)
|
|
{
|
|
const int change = (new_value - m_c2);
|
|
if(change > 0)
|
|
{
|
|
m_canvas.LineAA(m_ci, m_c2 + 1, m_ci, new_value, m_clr, m_style);
|
|
m_c2 = new_value;
|
|
}
|
|
else
|
|
if(change < 0)
|
|
{
|
|
const int yin = fmax(new_value, m_c1);
|
|
m_canvas.LineAA(m_ci, yin + 1, m_ci, m_c2, m_clr_clean, m_style);
|
|
m_c2 = yin;
|
|
}
|
|
}
|
|
|
|
|
|
#undef CCanvasVerLine_CompleteClean
|
|
#undef CCanvasVerLine_DrawComplete
|
|
//+------------------------------------------------------------------+
|
|
#endif
|
|
//+------------------------------------------------------------------+
|