EasyAndFastMod/Controls/TextLabel.mqh

103 lines
8.4 KiB
MQL5
Raw Permalink Normal View History

2026-01-15 07:23:17 -05:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| TextLabel.mqh |
//| Copyright 2016, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#include "..\Element.mqh"
//+------------------------------------------------------------------+
//| ;0AA 4;O A>740=8O B5:AB>2>9 <5B:8 |
//+------------------------------------------------------------------+
class CTextLabel : public CElement
{
public:
CTextLabel(void);
~CTextLabel(void);
//--- 5B>4K 4;O A>740=8O B5:AB2>9 <5B:8
bool CreateTextLabel(const string text,const int x_gap,const int y_gap);
//---
private:
void InitializeProperties(const string text,const int x_gap,const int y_gap);
bool CreateCanvas(void);
//---
public:
//--- 8AC5B M;5<5=B
virtual void Draw(void);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CTextLabel::CTextLabel(void)
{
//--- !>E@0=8< 8<O :;0AA0 M;5<5=B0 2 107>2>< :;0AA5
CElementBase::ClassName(CLASS_NAME);
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CTextLabel::~CTextLabel(void)
{
}
//+------------------------------------------------------------------+
//| !>740QB 3@C??C >1J5:B>2 B5:AB>2>3> ?>;O 22>40 |
//+------------------------------------------------------------------+
bool CTextLabel::CreateTextLabel(const string text,const int x_gap,const int y_gap)
{
//--- K9B8, 5A;8 =5B C:070B5;O =0 3;02=K9 M;5<5=B
if(!CElement::CheckMainPointer())
return(false);
//--- =8F80;870F8O A2>9AB2
InitializeProperties(text,x_gap,y_gap);
//--- !>740=85 M;5<5=B0
if(!CreateCanvas())
return(false);
//---
return(true);
}
//+------------------------------------------------------------------+
//| =8F80;870F8O A2>9AB2 |
//+------------------------------------------------------------------+
void CTextLabel::InitializeProperties(const string text,const int x_gap,const int y_gap)
{
m_x =CElement::CalculateX(x_gap);
m_y =CElement::CalculateY(y_gap);
m_x_size =(m_x_size<1)? 100 : m_x_size;
m_y_size =(m_y_size<1)? 20 : m_y_size;
m_label_text =text;
//--- &25B D>=0 ?> C<>;G0=8N
m_back_color=(m_back_color!=clrNONE)? m_back_color : m_main.BackColor();
//--- BABC?K 8 F25B B5:AB>2>9 <5B:8
m_label_color =(m_label_color!=clrNONE)? m_label_color : clrBlack;
m_label_x_gap =(m_label_x_gap!=WRONG_VALUE)? m_label_x_gap : 0;
m_label_y_gap =(m_label_y_gap!=WRONG_VALUE)? m_label_y_gap : 0;
//--- BABC?K >B :@09=59 B>G:8
CElementBase::XGap(x_gap);
CElementBase::YGap(y_gap);
}
//+------------------------------------------------------------------+
//| !>740QB >1J5:B 4;O @8A>20=8O |
//+------------------------------------------------------------------+
bool CTextLabel::CreateCanvas(void)
{
//--- $>@<8@>20=85 8<5=8 >1J5:B0
string name=CElementBase::ElementName("text_label");
//--- !>740=85 >1J5:B0
if(!CElement::CreateCanvas(name,m_x,m_y,m_x_size,m_y_size))
return(false);
//---
ShowTooltip(true);
return(true);
}
//+------------------------------------------------------------------+
//| 8AC5B M;5<5=B |
//+------------------------------------------------------------------+
void CTextLabel::Draw(void)
{
//--- 0@8A>20BL D>=
CElement::DrawBackground();
//--- 0@8A>20BL :0@B8=:C
CElement::DrawImage();
//--- 0@8A>20BL B5:AB
CElement::DrawText();
}
//+------------------------------------------------------------------+