EasyAndFastMod/Controls/Frame.mqh

193 lines
14 KiB
MQL5
Raw Permalink Normal View History

2026-01-15 07:23:17 -05:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| Frame.mqh |
//| Copyright 2018, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#include "..\Element.mqh"
#include "TextLabel.mqh"
//+------------------------------------------------------------------+
//| ;0AA 4;O A>740=8O >1;0AB8 4;O 3@C??8@>20=8O M;5<5=B>2 |
//+------------------------------------------------------------------+
class CFrame : public CElement
{
private:
//--- -:75<?;O@K 4;O A>740=8O M;5<5=B0
CTextLabel m_text_label;
//---
public:
CFrame(void);
~CFrame(void);
//--- >72@0I05B C:070B5;L B5:AB>2>9 <5B:8
CTextLabel *GetTextLabelPointer(void) { return(::GetPointer(m_text_label)); }
//--- 5B>4K 4;O A>740=8O >1;0AB8
bool CreateFrame(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);
bool CreateTextLabel(void);
//---
public:
//--- 8AC5B M;5<5=B
virtual void Draw(void);
//---
private:
//--- 7<5=8BL H8@8=C ?> ?@02><C :@0N >:=0
virtual void ChangeWidthByRightWindowSide(void);
//--- 7<5=8BL 2KA>BC ?> =86=5<C :@0N >:=0
virtual void ChangeHeightByBottomWindowSide(void);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CFrame::CFrame(void)
{
//--- !>E@0=8< 8<O :;0AA0 M;5<5=B0 2 107>2>< :;0AA5
CElementBase::ClassName(CLASS_NAME);
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CFrame::~CFrame(void)
{
}
//+------------------------------------------------------------------+
//| !>740QB 3@C??C >1J5:B>2 B5:AB>2>3> ?>;O 22>40 |
//+------------------------------------------------------------------+
bool CFrame::CreateFrame(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);
if(!CreateTextLabel())
return(false);
//---
return(true);
}
//+------------------------------------------------------------------+
//| =8F80;870F8O A2>9AB2 |
//+------------------------------------------------------------------+
void CFrame::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 || m_auto_xresize_mode)? m_main.X2()-m_x-m_auto_xresize_right_offset : m_x_size;
m_y_size =(m_y_size<1 || m_auto_yresize_mode)? m_main.Y2()-m_y-m_auto_yresize_bottom_offset : 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 CFrame::CreateCanvas(void)
{
//--- $>@<8@>20=85 8<5=8 >1J5:B0
string name=CElementBase::ElementName("frame");
//--- !>740=85 >1J5:B0
if(!CElement::CreateCanvas(name,m_x,m_y,m_x_size,m_y_size))
return(false);
//---
ShowTooltip(true);
return(true);
}
//+------------------------------------------------------------------+
//| !>740QB B5:AB>2CN <5B:C |
//+------------------------------------------------------------------+
bool CFrame::CreateTextLabel(void)
{
//--- !>E@0=8< C:070B5;L =0 @>48B5;LA:89 M;5<5=B
m_text_label.MainPointer(this);
//--- >>@48=0B+
int x=12;
int y=-6;
//--- !2>9AB20
if(m_label_text=="")
{
y=1;
m_text_label.YSize(1);
m_border_color=m_back_color;
}
//---
m_text_label.LabelXGap(5);
m_text_label.Font(CElement::Font());
m_text_label.FontSize(CElement::FontSize());
//--- !>740=85 >1J5:B0
if(!m_text_label.CreateTextLabel(m_label_text,x,y))
return(false);
//--- >1028BL M;5<5=B 2 <0AA82
CElement::AddToArray(m_text_label);
return(true);
}
//+------------------------------------------------------------------+
//| 7<5=8BL H8@8=C ?> ?@02><C :@0N D>@<K |
//+------------------------------------------------------------------+
void CFrame::ChangeWidthByRightWindowSide(void)
{
//--- K9B8, 5A;8 2:;NG5= @568< ?@82O7:8 : ?@02>9 G0AB8 >:=0
if(m_anchor_right_window_side)
return;
//--- 07<5@K
int x_size=0;
//--- 0AAG8B0BL 8 CAB0=>28BL =>2K9 @07<5@ D>=C M;5<5=B0
x_size=m_main.X2()-m_canvas.X()-m_auto_xresize_right_offset;
//--- 5 87<5=OBL @07<5@, 5A;8 <5=LH5 CAB0=>2;5==>3> >3@0=8G5=8O
if(x_size==m_x_size)
return;
//---
CElementBase::XSize(x_size);
m_canvas.XSize(x_size);
m_canvas.Resize(x_size,m_y_size);
//--- 5@5@8A>20BL M;5<5=B
Draw();
//--- 1=>28BL ?>;>65=85 >1J5:B>2
Moving();
}
//+------------------------------------------------------------------+
//| 7<5=8BL 2KA>BC ?> =86=5<C :@0N >:=0 |
//+------------------------------------------------------------------+
void CFrame::ChangeHeightByBottomWindowSide(void)
{
//--- K9B8, 5A;8 2:;NG5= @568< ?@82O7:8 : =86=59 G0AB8 >:=0
if(m_anchor_bottom_window_side)
return;
//--- 07<5@K
int y_size=0;
//--- 0AAG8B0BL 8 CAB0=>28BL =>2K9 @07<5@ D>=C M;5<5=B0
y_size=m_main.Y2()-m_canvas.Y()-m_auto_yresize_bottom_offset;
//--- 5 87<5=OBL @07<5@, 5A;8 <5=LH5 CAB0=>2;5==>3> >3@0=8G5=8O
if(y_size==m_y_size)
return;
//---
CElementBase::YSize(y_size);
m_canvas.YSize(y_size);
m_canvas.Resize(m_x_size,y_size);
//--- 5@5@8A>20BL M;5<5=B
Draw();
//--- 1=>28BL ?>;>65=85 >1J5:B>2
Moving();
}
//+------------------------------------------------------------------+
//| 8AC5B M;5<5=B |
//+------------------------------------------------------------------+
void CFrame::Draw(void)
{
//--- 0@8A>20BL D>=
CElement::DrawBackground();
//--- 0@8A>20BL @0<:C
CElement::DrawBorder();
}
//+------------------------------------------------------------------+