Start Developing GUI Panel ...
This commit is contained in:
@@ -0,0 +1,213 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 : XSCBase
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCPanel()
|
||||
{
|
||||
//
|
||||
// Enables mouse move events on the chart
|
||||
ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true);
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCPanel()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
//
|
||||
// Action ...
|
||||
|
||||
//
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize,
|
||||
//
|
||||
// Title Bar ...
|
||||
ENUM_BORDER_TYPE titleBarBorderType = BORDER_FLAT,
|
||||
color titleBarBGColor = clrBlueViolet,
|
||||
//
|
||||
// Caption ...
|
||||
string caption = "",
|
||||
int captionontSize = 9,
|
||||
color captionColor = clrWhite,
|
||||
//
|
||||
// Body ...
|
||||
ENUM_BORDER_TYPE bodyBorderType = BORDER_FLAT,
|
||||
color bodyBGColor = clrMediumSlateBlue //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(name);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Destroy();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mTitleBarName = name + "_TITLE_BAR";
|
||||
mTitleTextName = name + "_CAPTION";
|
||||
mBodyName = name + "_BODY";
|
||||
|
||||
//
|
||||
if (!IsValid(caption))
|
||||
{
|
||||
caption = name;
|
||||
}
|
||||
|
||||
//
|
||||
// Title Bar ...
|
||||
int titleBarHeight = ySize / 5;
|
||||
result = mTitleBar.Create(
|
||||
mTitleBarName,
|
||||
xDis,
|
||||
yDis,
|
||||
xSize,
|
||||
titleBarHeight //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Destroy();
|
||||
return result;
|
||||
}
|
||||
mTitleBar.SetBorderType(titleBarBorderType);
|
||||
mTitleBar.SetBGColor(titleBarBGColor);
|
||||
|
||||
//
|
||||
// Body ...
|
||||
result = mBody.Create(
|
||||
mBodyName,
|
||||
xDis,
|
||||
yDis + titleBarHeight - 1,
|
||||
xSize,
|
||||
ySize //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Destroy();
|
||||
return result;
|
||||
}
|
||||
mBody.SetBorderType(bodyBorderType);
|
||||
mBody.SetBGColor(bodyBGColor);
|
||||
|
||||
//
|
||||
// Caption ...
|
||||
result = mTitleText.Create(mTitleTextName, xDis, yDis);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Destroy();
|
||||
return result;
|
||||
}
|
||||
mTitleText.SetText(caption);
|
||||
mTitleText.SetTextColor(captionColor);
|
||||
mTitleText.SetFontSize(captionontSize);
|
||||
|
||||
//
|
||||
// Adding Child Objects ...
|
||||
mTitleBar.Add(mBodyName);
|
||||
mTitleBar.Add(mTitleTextName);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void Destroy()
|
||||
{
|
||||
//
|
||||
mBodyName = NULL;
|
||||
mTitleBarName = NULL;
|
||||
mTitleTextName = NULL;
|
||||
|
||||
//
|
||||
mBody.Destroy();
|
||||
mTitleBar.Destroy();
|
||||
mTitleText.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 //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mBodyName;
|
||||
string mTitleBarName;
|
||||
string mTitleTextName;
|
||||
|
||||
//
|
||||
XCLabel mTitleText;
|
||||
XCRectangleLabel mBody;
|
||||
XCRectangleLabel mTitleBar;
|
||||
|
||||
//
|
||||
};
|
||||
Reference in New Issue
Block a user