Files
xMQL5/BKPS/14030823/BKPs/14030802-X121/Classes/XCObjects/x-saherelm.x-panel.class.mq5
T
2024-11-15 10:50:11 +03:30

299 lines
6.2 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XCPanel
// Description: provides all based classes for use ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// Imports ...
#include "../XCObjects/x-saherelm.x-button.class.mq5"
#include "../XCObjects/x-saherelm.x-edit.class.mq5"
#include "../XCObjects/x-saherelm.x-label.class.mq5"
#include "../XCObjects/x-saherelm.x-rectangle.label.class.mq5"
//
// Implementation ...
//
class XCPanel : XCObject
{
public:
//
// Constructor(s) ...
void XCPanel()
{
}
//
// Deconstructor ...
void ~XCPanel()
{
Destroy();
}
//
// Action ...
/**
* Create an instance of Panel Object ...
*
* @param name: Object name
* @param xDis: X Distance
* @param yDis: Y Distance
* @param xSize: X Size
* @param ySize: Y Size
* @param titleBarBorderType: Border Type of Panel TitleBar
* @param titleBarBGColor: Background Color of Panel TitleBar
* @param caption: Caption Text of Panel TitleBar
* @param captionontSize: Font Size of Panel Caption
* @param captionColor: Text Color of Panel Caption
* @param captionAnchor: Anchor Point of Panel Caption
* @param bodyBorderType: Border Type of Panel Body
* @param bodyBGColor: Background Color of Panel Body
*
* @return ( bool )
*/
bool Create(
string name,
int xDis,
int yDis,
int xSize,
int ySize,
//
long chartID = 0,
//
// Title Bar ...
ENUM_BORDER_TYPE titleBarBorderType = BORDER_FLAT,
color titleBarBGColor = clrBlueViolet,
//
// Caption ...
string caption = "",
int captionontSize = 9,
color captionColor = clrWhite,
ENUM_ANCHOR_POINT captionAnchor = ANCHOR_LEFT_UPPER,
//
// Body ...
ENUM_BORDER_TYPE bodyBorderType = BORDER_FLAT,
color bodyBGColor = clrMediumSlateBlue //
)
{
//
bool result = false;
//
// Enables mouse move events on the chart
ChartSetInteger(chartID, CHART_EVENT_MOUSE_MOVE, true);
//
result = IsValid(name);
if (!result)
{
//
Destroy();
return result;
}
//
mTitleBarName = name + "_TITLE_BAR";
mCaptionLblName = name + "_CAPTION";
mBodyName = name + "_BODY";
//
if (!IsValid(caption))
{
caption = name;
}
//
// Title Bar ...
int titleBarHeight = 20;
result = mTitleBar.Create(
mTitleBarName,
xDis,
yDis,
xSize,
titleBarHeight //
);
if (!result)
{
//
Destroy();
return result;
}
mTitleBar.BorderType(titleBarBorderType);
mTitleBar.BGColor(titleBarBGColor);
//
// Body ...
result = mBody.Create(
mBodyName,
xDis,
yDis + titleBarHeight - 1,
xSize,
ySize //
);
if (!result)
{
//
Destroy();
return result;
}
mBody.BorderType(bodyBorderType);
mBody.BGColor(bodyBGColor);
mBody.AsBackGround(true);
//
// Caption ...
result = mCaptionLbl.Create(mCaptionLblName, xDis, yDis);
if (!result)
{
//
Destroy();
return result;
}
mCaptionLbl.Text(caption);
mCaptionLbl.Color(captionColor);
mCaptionLbl.Anchor(captionAnchor);
mCaptionLbl.FontSize(captionontSize);
//
// Adding Child Objects ...
mTitleBar.Add(mBodyName);
mTitleBar.Add(mCaptionLblName);
//
return result;
}
/**
* Destroy Panel Object and all of it's Child
*/
void Destroy()
{
//
mBodyName = NULL;
mTitleBarName = NULL;
mCaptionLblName = NULL;
//
mBody.Destroy();
mTitleBar.Destroy();
mCaptionLbl.Destroy();
}
/**
* Event Handling for Mouse Movement ...
* @param id: Event ID
* @param lparam: Event parameter of long type
* @param dparam: Event parameter of double type
* @param sparam: Event parameter of string type
*/
void OnEvent(
int id,
long lparam,
double dparam,
string sparam //
)
{
//
mTitleBar.OnEvent(
id,
lparam,
dparam,
sparam //
);
}
/**
* Add Specific Child Object ...
*
* @param name: object name
*/
void Add(string name)
{
mTitleBar.Add(name);
}
/**
* Retrieve Panel Caption ...
*
* @return ( string )
*/
string Caption()
{
return mCaptionLbl.Text();
}
/**
* Set Panel Caption ...
*
* @param value: Caption
*/
void Caption(string value)
{
mCaptionLbl.Text(value);
}
/**
* Set Caption Color ...
*
* @param value: Color
*/
void CptionColor(color value)
{
mCaptionLbl.Color(value);
}
/**
* Set Panel Body BG Color ...
*
* @param value: Color
*/
void BodyColor(color value)
{
mBody.BGColor(value);
}
/**
* Set Panel Titlebar BG Color ...
*
* @param value: Color
*/
void TitleBarBGColor(color value)
{
mTitleBar.BGColor(value);
}
//
protected:
private:
//
// Props ...
//
string mBodyName;
string mTitleBarName;
string mCaptionLblName;
//
XCLabel mCaptionLbl;
XCRectangleLabel mBody;
XCRectangleLabel mTitleBar;
//
};