| //+------------------------------------------------------------------+
|
| //| Ver.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 GRAPHICS_HISTOGRAM_EJES_HIST_VER_MQH_BY_LEO
|
| #define GRAPHICS_HISTOGRAM_EJES_HIST_VER_MQH_BY_LEO
|
|
|
| #include "Base.mqh"
|
|
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| class CHistogramEjeVertical : public CHistogramEje
|
| {
|
| public:
|
| void Init(CCanvasCustom *c, int x1, int x2, int y1, int y2, int mode,
|
| uint clr_line_eje_simple, uint clr_line_eje_fij, uint clr_clean, uint style, bool extendent_line) override;
|
| void CreateTituloEje2(int gap_eje, const string& txt, uint clr, int fontsize = 0, string font = NULL, uint flagtext = UINT_MAX) override;
|
|
|
| //--- SImple eje
|
| //- Color
|
| void EjeSimpleColor(uint new_value, bool redraw = false) override final;
|
|
|
|
|
| //--- Cordenadas
|
| void ChangeCordinates(int x1, int x2, int y1, int y2, bool redraw = false)override final;
|
| void ChangeAnclaje2(int x2, int y2, bool redraw = false) override final;
|
| void ChangeAnclaje1(int x1, int y1, bool redraw = false) override final;
|
| };
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CHistogramEjeVertical::Init(CCanvasCustom *c, int x1, int x2, int y1, int y2, int mode,
|
| uint clr_line_eje_simple, uint clr_line_eje_fij, uint clr_clean, uint style, bool extendent_line)
|
| {
|
| if(m_init)
|
| return;
|
|
|
| //---
|
| m_init = true;
|
|
|
| //---
|
| m_canvas = c;
|
| m_x1 = x1;
|
| m_y1 = y1;
|
| m_x2 = x2;
|
| m_y2 = y2;
|
|
|
| /*
|
| x1 x2
|
| y1 y1
|
|
|
|
|
|
|
| y2 x2
|
| x1 y2
|
| */
|
|
|
| //---
|
| m_histogram_eje_2.clr = clr_line_eje_fij;
|
|
|
| //---
|
| const int size_line = fabs(m_x2 - m_x1);
|
| m_histogram_eje = new CHistogramEjeLineVertical();
|
| m_mode_line = mode;
|
| if(mode == HIST_LINE_MODE_ARRIBA)
|
| {
|
| m_histogram_eje.Init(c, m_x1, m_y1, size_line, clr_line_eje_simple, mode, (extendent_line ? m_y2 : 0), style);
|
| }
|
| else
|
| {
|
| m_histogram_eje.Init(c, m_x1, m_y2, size_line, clr_line_eje_simple, mode, (extendent_line ? m_y1 : 0), style);
|
| }
|
| m_histogram_eje.CleanColor(clr_clean);
|
|
|
| //--- Eje simple
|
| // Cambiante
|
| m_histogram_eje_2.init = m_x1;
|
| m_histogram_eje_2.c1 = m_y1;
|
| m_histogram_eje_2.c2 = m_y2;
|
| m_canvas.LineVertical(m_histogram_eje_2.init, m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_histogram_eje_2.clr);
|
|
|
| // Eje arriba
|
| m_histogram_eje_arriba = new CCanvasHorLine((m_mode_line == HIST_LINE_MODE_ARRIBA ? m_y2 : m_y1), m_x1, m_x2, clr_line_eje_fij, clr_clean, m_canvas);
|
| m_histogram_eje_arriba.Draw();
|
|
|
| // Eje derecha
|
| m_histogram_eje_derecha = new CCanvasVerLine(m_x2, m_y1, m_y2, clr_line_eje_fij, m_clr_clean, m_canvas);
|
| m_histogram_eje_derecha.Draw();
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CHistogramEjeVertical::CreateTituloEje2(int gap_eje, const string &txt, uint clr, int fontsize = 0, string font = NULL, uint flagtext = UINT_MAX)
|
| {
|
| if(m_eje_2_text != NULL)
|
| return;
|
|
|
| m_eje_2_text = new CTextCanvas();
|
| int x = m_x1 - gap_eje;
|
| int y = m_y1 + ((m_y2 - m_y1) >> 1);
|
|
|
| m_eje_2_text.Create(m_canvas, x, y, txt, clr, TA_TOP | TA_CENTER, fontsize, font, flagtext, 900);
|
| m_eje_2_text.CleanColor(m_clr_clean);
|
| m_eje_2_text_gap = gap_eje;
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| // Solo mueve x1, y1, lo demas constante no se modifica
|
| void CHistogramEjeVertical::ChangeAnclaje1(int x1, int y1, bool redraw = false)
|
| {
|
| //---
|
| const bool aument = y1 > m_y1;
|
| if(aument)
|
| m_canvas.LineVertical(m_histogram_eje_2.init, m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_clr_clean);
|
|
|
| //---
|
| m_x1 = x1;
|
| m_y1 = y1;
|
|
|
| //---
|
| m_histogram_eje_2.init = m_x1;
|
| m_histogram_eje_2.c1 = m_y1;
|
| m_canvas.LineVertical(m_histogram_eje_2.init, m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_histogram_eje_2.clr);
|
|
|
| //---
|
| if(m_mode_line == HIST_LINE_MODE_ABAJO)
|
| m_histogram_eje_arriba.ChangeCordinatesAnc1(y1, x1);
|
| else
|
| m_histogram_eje_arriba.C1(x1);
|
|
|
| //---
|
| m_histogram_eje_derecha.C1(y1);
|
|
|
| //---
|
| const int y = m_y1 + ((m_y2 - m_y1) >> 1);
|
| const int x = m_x1 - m_eje_2_text_gap;
|
| m_eje_2_text.ChangeYAndX(x, y);
|
|
|
|
|
| //---
|
| const int size_line = fabs(m_x2 - m_x1);
|
| const int real_y = (m_mode_line == HIST_LINE_MODE_ARRIBA) ? m_y1 : m_y2; // Y Real
|
| m_histogram_eje.SetCordinates(m_x1, real_y, size_line, redraw); // Cambiamos
|
|
|
| //---
|
| if(redraw)
|
| m_canvas.Update();
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CHistogramEjeVertical::ChangeAnclaje2(int x2, int y2, bool redraw = false)
|
| {
|
| //---
|
| const bool reduce = y2 < m_y2;
|
| if(reduce)
|
| m_canvas.LineVertical(m_histogram_eje_2.init, m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_clr_clean);
|
|
|
| //---
|
| m_x2 = x2;
|
| m_y2 = y2;
|
|
|
| //---
|
| m_histogram_eje_2.c2 = m_y2;
|
| m_canvas.LineVertical(m_histogram_eje_2.init, m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_histogram_eje_2.clr);
|
|
|
| //---
|
| if(m_mode_line == HIST_LINE_MODE_ABAJO)
|
| m_histogram_eje_arriba.C2(m_x2);
|
| else
|
| m_histogram_eje_arriba.ChangeCordinates(m_y2, m_x1, m_x2);
|
|
|
| //---
|
| m_histogram_eje_derecha.ChangeCordinates(m_x2, m_y1, m_y2);
|
|
|
| //---
|
| const int y = m_y1 + ((m_y2 - m_y1) >> 1);
|
| m_eje_2_text.Y(y);
|
|
|
|
|
| //---
|
| const int size_line = fabs(m_x2 - m_x1);
|
| const int real_y = (m_mode_line == HIST_LINE_MODE_ARRIBA) ? m_y1 : m_y2; // Y Real
|
| m_histogram_eje.SetCordinates(m_x1, real_y, size_line, redraw); // Cambiamos
|
|
|
| //---
|
| if(redraw)
|
| m_canvas.Update();
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CHistogramEjeVertical::ChangeCordinates(int x1, int x2, int y1, int y2, bool redraw = false)
|
| {
|
| //---
|
| m_canvas.LineHorizontal(m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_histogram_eje_2.init, m_clr_clean);
|
|
|
| //---
|
| m_x1 = x1;
|
| m_y1 = y1;
|
| m_x2 = x2;
|
| m_y2 = y2;
|
|
|
| //--- Eje simple
|
| m_histogram_eje_2.init = m_x1;
|
| m_histogram_eje_2.c1 = m_y1;
|
| m_histogram_eje_2.c2 = m_y2;
|
| m_canvas.LineVertical(m_histogram_eje_2.init, m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_histogram_eje_2.clr);
|
|
|
| //---
|
| m_histogram_eje_derecha.ChangeCordinates(m_x2, m_y1, m_y2);
|
|
|
| //---
|
| m_histogram_eje_arriba.ChangeCordinates((m_mode_line == HIST_LINE_MODE_ARRIBA ? m_y2 : m_y1), m_x1, m_x2);
|
|
|
| //---
|
| const int y = m_y1 + ((m_y2 - m_y1) >> 1);
|
| const int x = m_x1 - m_eje_2_text_gap;
|
| m_eje_2_text.ChangeYAndX(x, y);
|
|
|
| //---
|
| const int size_line = fabs(m_x2 - m_x1);
|
| const int real_y = (m_mode_line == HIST_LINE_MODE_ARRIBA) ? m_y1 : m_y2; // Y Real
|
| m_histogram_eje.SetCordinates(m_x1, real_y, size_line, redraw); // Cambiamos
|
|
|
| //---
|
| if(redraw)
|
| m_canvas.Update();
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| void CHistogramEjeVertical::EjeSimpleColor(uint new_value, bool redraw = false)
|
| {
|
| //---
|
| m_histogram_eje_derecha.Color(new_value);
|
|
|
| //---
|
| m_histogram_eje_arriba.Color(new_value);
|
|
|
| //---
|
| m_histogram_eje_2.clr = new_value;
|
| m_canvas.LineVertical(m_histogram_eje_2.init, m_histogram_eje_2.c1, m_histogram_eje_2.c2, m_histogram_eje_2.clr);
|
|
|
| //---
|
| if(redraw)
|
| m_canvas.Update();
|
| }
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| /*
|
| x1
|
| c1
|
| |
|
| |
|
| |
|
| |
|
| |
|
| c2
|
| */
|
|
|
| //+------------------------------------------------------------------+
|
| #endif
|
| //+------------------------------------------------------------------+
|