Start Developing GUI Panel ...
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCButton
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
// a Button Creation Class ...
|
||||
class XCButton : XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCButton()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCButton()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Create an Instance of Class Object ...
|
||||
*
|
||||
* @param name: Object Name
|
||||
* @param xDis: X Distance
|
||||
* @param yDis: Y Distance
|
||||
* @param xSize: X Size
|
||||
* @param ySize: Y Size
|
||||
*/
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Object creation and property settings
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_BUTTON, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
/**
|
||||
* Set Object Border Color ...
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBorderColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BORDER_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object Background Color ...
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBGColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BGCOLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object Text ...
|
||||
*
|
||||
* @param value: text
|
||||
*/
|
||||
void SetText(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
int mlbDownY;
|
||||
int mlbDownXDistance;
|
||||
int mlbDownYDistance;
|
||||
int mPreviousMouseState;
|
||||
|
||||
//
|
||||
bool mMovingState; // State for whether the object is moving
|
||||
|
||||
//
|
||||
string mAddedNames[]; // Array of added names
|
||||
long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCEdit
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
// a Label Creation Class ...
|
||||
class XCEdit : XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCEdit()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCEdit()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Create an Instance of Class Object ...
|
||||
*
|
||||
* @param name: Object Name
|
||||
* @param xDis: X Distance
|
||||
* @param yDis: Y Distance
|
||||
* @param xSize: X Size
|
||||
* @param ySize: Y Size
|
||||
*/
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Object creation and property settings
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_EDIT, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
/**
|
||||
* Set Object Border Color ...
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBorderColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BORDER_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Background Color of Object ...
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBGColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BGCOLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object Text Color ...
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetTextColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text of Object ...
|
||||
*
|
||||
* @param value: text
|
||||
*/
|
||||
void SetText(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Current Text of Object ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetText()
|
||||
{
|
||||
return ObjectGetString(0, mName, OBJPROP_TEXT);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
int mlbDownY;
|
||||
int mlbDownXDistance;
|
||||
int mlbDownYDistance;
|
||||
int mPreviousMouseState;
|
||||
|
||||
//
|
||||
bool mMovingState; // State for whether the object is moving
|
||||
|
||||
//
|
||||
string mAddedNames[]; // Array of added names
|
||||
long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
};
|
||||
@@ -0,0 +1,176 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCLabel
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
// a Label Creation Class ...
|
||||
class XCLabel : XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCLabel()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCLabel()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Create an Instance of Class Object ...
|
||||
*
|
||||
* @param name: Object Name
|
||||
* @param xDis: X Distance
|
||||
* @param yDis: Y Distance
|
||||
*/
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Object creation and property settings
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
/**
|
||||
* Set Text Color ...
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetTextColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text of Object ...
|
||||
*
|
||||
* @param value: text
|
||||
*/
|
||||
void SetText(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text Of Object ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetText()
|
||||
{
|
||||
return ObjectGetString(0, mName, OBJPROP_TEXT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Font Size of Object ...
|
||||
*
|
||||
* @param value: size
|
||||
*/
|
||||
void SetFontSize(int value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_FONTSIZE, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Font Name Of Object ...
|
||||
*
|
||||
* @param value: font name
|
||||
*/
|
||||
void SetFont(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_FONT, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
int mlbDownY;
|
||||
int mlbDownXDistance;
|
||||
int mlbDownYDistance;
|
||||
int mPreviousMouseState;
|
||||
|
||||
//
|
||||
bool mMovingState; // State for whether the object is moving
|
||||
|
||||
//
|
||||
string mAddedNames[]; // Array of added names
|
||||
long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
//
|
||||
};
|
||||
@@ -0,0 +1,268 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCRectangleLabel
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
// a Rectangle Label Creation Class ...
|
||||
class XCRectangleLabel : XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCRectangleLabel()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCRectangleLabel()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
// Handlers ...
|
||||
|
||||
/**
|
||||
* 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 //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Handle mouse movement events for dragging the rectangle label
|
||||
if (id == CHARTEVENT_MOUSE_MOVE)
|
||||
{
|
||||
//
|
||||
int X = (int)lparam;
|
||||
int Y = (int)dparam;
|
||||
int MouseState = (int)sparam;
|
||||
|
||||
//
|
||||
string name = mName;
|
||||
int XSize = (int)ObjectGetInteger(0, name, OBJPROP_XSIZE);
|
||||
int YSize = (int)ObjectGetInteger(0, name, OBJPROP_YSIZE);
|
||||
int XDistance = (int)ObjectGetInteger(0, name, OBJPROP_XDISTANCE);
|
||||
int YDistance = (int)ObjectGetInteger(0, name, OBJPROP_YDISTANCE);
|
||||
|
||||
//
|
||||
if (MouseState == 1 &&
|
||||
mPreviousMouseState == 0)
|
||||
{
|
||||
//
|
||||
mlbDownX = X;
|
||||
mlbDownY = Y;
|
||||
mlbDownXDistance = XDistance;
|
||||
mlbDownYDistance = YDistance;
|
||||
|
||||
//
|
||||
if (X >= XDistance &&
|
||||
Y >= YDistance &&
|
||||
X <= XDistance + XSize &&
|
||||
Y <= YDistance + YSize)
|
||||
{
|
||||
mMovingState = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (mMovingState)
|
||||
{
|
||||
//
|
||||
ChartSetInteger(0, CHART_MOUSE_SCROLL, false);
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, mlbDownXDistance + X - mlbDownX);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, mlbDownYDistance + Y - mlbDownY);
|
||||
|
||||
//
|
||||
for (int i = 0; i < ArraySize(mAddedNames); i++)
|
||||
{
|
||||
//
|
||||
ObjectSetInteger(0, mAddedNames[i], OBJPROP_XDISTANCE, mlbDownXDistance + X - mlbDownX - mAddedXDisDiffrence[i]);
|
||||
ObjectSetInteger(0, mAddedNames[i], OBJPROP_YDISTANCE, mlbDownYDistance + Y - mlbDownY - mAddedYDisDiffrence[i]);
|
||||
}
|
||||
|
||||
//
|
||||
ChartRedraw(0);
|
||||
}
|
||||
|
||||
//
|
||||
if (MouseState == 0)
|
||||
{
|
||||
//
|
||||
mMovingState = false;
|
||||
ChartSetInteger(0, CHART_MOUSE_SCROLL, true);
|
||||
}
|
||||
|
||||
//
|
||||
mPreviousMouseState = MouseState;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Create an Instance of Class Object ...
|
||||
*
|
||||
* @param name: Object Name
|
||||
* @param xDis: X Distance
|
||||
* @param yDis: Y Distance
|
||||
* @param xSize: X Size
|
||||
* @param ySize: Y Size
|
||||
*/
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Object creation and property settings
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_RECTANGLE_LABEL, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object Border Type ...
|
||||
*
|
||||
* @param borderType: Specified border type
|
||||
*/
|
||||
void SetBorderType(ENUM_BORDER_TYPE borderType)
|
||||
{
|
||||
//
|
||||
ObjectSetInteger(
|
||||
0,
|
||||
mName,
|
||||
OBJPROP_BORDER_TYPE,
|
||||
borderType //
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object Background Color
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBGColor(color value)
|
||||
{
|
||||
//
|
||||
ObjectSetInteger(
|
||||
0,
|
||||
mName,
|
||||
OBJPROP_BGCOLOR,
|
||||
value //
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Name to Object
|
||||
* @param name: name
|
||||
*/
|
||||
void Add(string name)
|
||||
{
|
||||
//
|
||||
// Add a new object by name to the rectangle label and track distances
|
||||
ArrayResize(mAddedNames, ArraySize(mAddedNames) + 1);
|
||||
ArrayResize(mAddedXDisDiffrence, ArraySize(mAddedXDisDiffrence) + 1);
|
||||
ArrayResize(mAddedYDisDiffrence, ArraySize(mAddedYDisDiffrence) + 1);
|
||||
|
||||
//
|
||||
mAddedNames[ArraySize(mAddedNames) - 1] = name;
|
||||
mAddedXDisDiffrence[ArraySize(mAddedXDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_XDISTANCE) - ObjectGetInteger(0, name, OBJPROP_XDISTANCE);
|
||||
mAddedYDisDiffrence[ArraySize(mAddedYDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_YDISTANCE) - ObjectGetInteger(0, name, OBJPROP_YDISTANCE);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
int mlbDownY;
|
||||
int mlbDownXDistance;
|
||||
int mlbDownYDistance;
|
||||
int mPreviousMouseState;
|
||||
|
||||
//
|
||||
bool mMovingState; // State for whether the object is moving
|
||||
|
||||
//
|
||||
string mAddedNames[]; // Array of added names
|
||||
long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
};
|
||||
@@ -1,162 +0,0 @@
|
||||
// ///////////////////////////////////////////////////////
|
||||
// //
|
||||
// // SaherElm IT Center MQL5 Class Library
|
||||
// // --------------------------------------
|
||||
// // Name: XCButton
|
||||
// // 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
|
||||
|
||||
// //
|
||||
// #include "../x-saherelm.base.class.mq5"
|
||||
|
||||
// //
|
||||
// // Definitions ...
|
||||
|
||||
// //
|
||||
// // Implementation ...
|
||||
|
||||
// //
|
||||
// // a Button Creation Class ...
|
||||
// class XCButton : XSCBase
|
||||
// {
|
||||
// //
|
||||
// // Public ...
|
||||
// public:
|
||||
// //
|
||||
// // Constructor(s) ...
|
||||
// void XCButton()
|
||||
// {
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Deconstructor ...
|
||||
// void ~XCButton()
|
||||
// {
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Actions ...
|
||||
|
||||
// /**
|
||||
// * Create an Instance of Class Object ...
|
||||
// *
|
||||
// * @param name: Object Name
|
||||
// * @param xDis: X Distance
|
||||
// * @param yDis: Y Distance
|
||||
// * @param xSize: X Size
|
||||
// * @param ySize: Y Size
|
||||
// */
|
||||
// bool Create(
|
||||
// string name,
|
||||
// int xDis,
|
||||
// int yDis,
|
||||
// int xSize,
|
||||
// int ySize //
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// // Object creation and property settings
|
||||
// bool result = false;
|
||||
|
||||
// //
|
||||
// result = ObjectCreate(0, name, OBJ_BUTTON, 0, 0, 0);
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //
|
||||
// ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
// ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
// ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
// ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
// //
|
||||
// mName = name;
|
||||
|
||||
// //
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Destroy Class Instance ...
|
||||
// */
|
||||
// void Destroy()
|
||||
// {
|
||||
// ObjectDelete(0, mName);
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Getter(s) / Setter(s) ...
|
||||
|
||||
// /**
|
||||
// * Set Object Border Color ...
|
||||
// *
|
||||
// * @param value: color
|
||||
// */
|
||||
// void SetBorderColor(color value)
|
||||
// {
|
||||
// ObjectSetInteger(0, mName, OBJPROP_BORDER_COLOR, value);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Set Object Background Color ...
|
||||
// *
|
||||
// * @param value: color
|
||||
// */
|
||||
// void SetBGColor(color value)
|
||||
// {
|
||||
// ObjectSetInteger(0, mName, OBJPROP_BGCOLOR, value);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Set Object Text ...
|
||||
// *
|
||||
// * @param value: text
|
||||
// */
|
||||
// void SetText(string value)
|
||||
// {
|
||||
// ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Protected ...
|
||||
// protected:
|
||||
// //
|
||||
// // Private ...
|
||||
// private:
|
||||
// //
|
||||
// // Props ...
|
||||
|
||||
// //
|
||||
// string mName; // Name of Object
|
||||
|
||||
// //
|
||||
// // Mouse state tracking variables ...
|
||||
// int mlbDownX;
|
||||
// int mlbDownY;
|
||||
// int mlbDownXDistance;
|
||||
// int mlbDownYDistance;
|
||||
// int mPreviousMouseState;
|
||||
|
||||
// //
|
||||
// bool mMovingState; // State for whether the object is moving
|
||||
|
||||
// //
|
||||
// string mAddedNames[]; // Array of added names
|
||||
// long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
// long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
// };
|
||||
@@ -1,176 +0,0 @@
|
||||
// ///////////////////////////////////////////////////////
|
||||
// //
|
||||
// // SaherElm IT Center MQL5 Class Library
|
||||
// // --------------------------------------
|
||||
// // Name: XCLabel
|
||||
// // 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
|
||||
|
||||
// //
|
||||
// #include "../x-saherelm.base.class.mq5"
|
||||
|
||||
// //
|
||||
// // Definitions ...
|
||||
|
||||
// //
|
||||
// // Implementation ...
|
||||
|
||||
// //
|
||||
// // a Label Creation Class ...
|
||||
// class XCLabel : XSCBase
|
||||
// {
|
||||
// //
|
||||
// // Public ...
|
||||
// public:
|
||||
// //
|
||||
// // Constructor(s) ...
|
||||
// void XCLabel()
|
||||
// {
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Deconstructor ...
|
||||
// void ~XCLabel()
|
||||
// {
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Actions ...
|
||||
|
||||
// /**
|
||||
// * Create an Instance of Class Object ...
|
||||
// *
|
||||
// * @param name: Object Name
|
||||
// * @param xDis: X Distance
|
||||
// * @param yDis: Y Distance
|
||||
// */
|
||||
// bool Create(
|
||||
// string name,
|
||||
// int xDis,
|
||||
// int yDis //
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// // Object creation and property settings
|
||||
// bool result = false;
|
||||
|
||||
// //
|
||||
// result = ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //
|
||||
// ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
// ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
|
||||
// //
|
||||
// mName = name;
|
||||
|
||||
// //
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Destroy Class Instance ...
|
||||
// */
|
||||
// void Destroy()
|
||||
// {
|
||||
// ObjectDelete(0, mName);
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Getter(s) / Setter(s) ...
|
||||
|
||||
// /**
|
||||
// * Set Text Color ...
|
||||
// *
|
||||
// * @param value: color
|
||||
// */
|
||||
// void SetTextColor(color value)
|
||||
// {
|
||||
// ObjectSetInteger(0, mName, OBJPROP_COLOR, value);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Set Text of Object ...
|
||||
// *
|
||||
// * @param value: text
|
||||
// */
|
||||
// void SetText(string value)
|
||||
// {
|
||||
// ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Get Text Of Object ...
|
||||
// *
|
||||
// * @return ( string )
|
||||
// */
|
||||
// string GetText()
|
||||
// {
|
||||
// return ObjectGetString(0, mName, OBJPROP_TEXT);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Set Font Size of Object ...
|
||||
// *
|
||||
// * @param value: size
|
||||
// */
|
||||
// void SetFontSize(int value)
|
||||
// {
|
||||
// ObjectSetInteger(0, mName, OBJPROP_FONTSIZE, value);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Set Font Name Of Object ...
|
||||
// *
|
||||
// * @param value: font name
|
||||
// */
|
||||
// void SetFont(string value)
|
||||
// {
|
||||
// ObjectSetString(0, mName, OBJPROP_FONT, value);
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Protected ...
|
||||
// protected:
|
||||
// //
|
||||
// // Private ...
|
||||
// private:
|
||||
// //
|
||||
// // Props ...
|
||||
|
||||
// //
|
||||
// string mName; // Name of Object
|
||||
|
||||
// //
|
||||
// // Mouse state tracking variables ...
|
||||
// int mlbDownX;
|
||||
// int mlbDownY;
|
||||
// int mlbDownXDistance;
|
||||
// int mlbDownYDistance;
|
||||
// int mPreviousMouseState;
|
||||
|
||||
// //
|
||||
// bool mMovingState; // State for whether the object is moving
|
||||
|
||||
// //
|
||||
// string mAddedNames[]; // Array of added names
|
||||
// long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
// long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
// };
|
||||
@@ -1,268 +0,0 @@
|
||||
// ///////////////////////////////////////////////////////
|
||||
// //
|
||||
// // SaherElm IT Center MQL5 Class Library
|
||||
// // --------------------------------------
|
||||
// // Name: XCRectangleLabel
|
||||
// // 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
|
||||
|
||||
// //
|
||||
// #include "../x-saherelm.base.class.mq5"
|
||||
|
||||
// //
|
||||
// // Definitions ...
|
||||
|
||||
// //
|
||||
// // Implementation ...
|
||||
|
||||
// //
|
||||
// // a Rectangle Label Creation Class ...
|
||||
// class XCRectangleLabel : XSCBase
|
||||
// {
|
||||
// //
|
||||
// // Public ...
|
||||
// public:
|
||||
// //
|
||||
// // Constructor(s) ...
|
||||
// void XCRectangleLabel()
|
||||
// {
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Deconstructor ...
|
||||
// void ~XCRectangleLabel()
|
||||
// {
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Getter(s) / Setter(s) ...
|
||||
|
||||
// //
|
||||
// // Handlers ...
|
||||
|
||||
// /**
|
||||
// * 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 //
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// // Handle mouse movement events for dragging the rectangle label
|
||||
// if (id == CHARTEVENT_MOUSE_MOVE)
|
||||
// {
|
||||
// //
|
||||
// int X = (int)lparam;
|
||||
// int Y = (int)dparam;
|
||||
// int MouseState = (int)sparam;
|
||||
|
||||
// //
|
||||
// string name = mName;
|
||||
// int XSize = (int)ObjectGetInteger(0, name, OBJPROP_XSIZE);
|
||||
// int YSize = (int)ObjectGetInteger(0, name, OBJPROP_YSIZE);
|
||||
// int XDistance = (int)ObjectGetInteger(0, name, OBJPROP_XDISTANCE);
|
||||
// int YDistance = (int)ObjectGetInteger(0, name, OBJPROP_YDISTANCE);
|
||||
|
||||
// //
|
||||
// if (MouseState == 1 &&
|
||||
// mPreviousMouseState == 0)
|
||||
// {
|
||||
// //
|
||||
// mlbDownX = X;
|
||||
// mlbDownY = Y;
|
||||
// mlbDownXDistance = XDistance;
|
||||
// mlbDownYDistance = YDistance;
|
||||
|
||||
// //
|
||||
// if (X >= XDistance &&
|
||||
// Y >= YDistance &&
|
||||
// X <= XDistance + XSize &&
|
||||
// Y <= YDistance + YSize)
|
||||
// {
|
||||
// mMovingState = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (mMovingState)
|
||||
// {
|
||||
// //
|
||||
// ChartSetInteger(0, CHART_MOUSE_SCROLL, false);
|
||||
// ObjectSetInteger(0, name, OBJPROP_XDISTANCE, mlbDownXDistance + X - mlbDownX);
|
||||
// ObjectSetInteger(0, name, OBJPROP_YDISTANCE, mlbDownYDistance + Y - mlbDownY);
|
||||
|
||||
// //
|
||||
// for (int i = 0; i < ArraySize(mAddedNames); i++)
|
||||
// {
|
||||
// //
|
||||
// ObjectSetInteger(0, mAddedNames[i], OBJPROP_XDISTANCE, mlbDownXDistance + X - mlbDownX - mAddedXDisDiffrence[i]);
|
||||
// ObjectSetInteger(0, mAddedNames[i], OBJPROP_YDISTANCE, mlbDownYDistance + Y - mlbDownY - mAddedYDisDiffrence[i]);
|
||||
// }
|
||||
|
||||
// //
|
||||
// ChartRedraw(0);
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (MouseState == 0)
|
||||
// {
|
||||
// //
|
||||
// mMovingState = false;
|
||||
// ChartSetInteger(0, CHART_MOUSE_SCROLL, true);
|
||||
// }
|
||||
|
||||
// //
|
||||
// mPreviousMouseState = MouseState;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Actions ...
|
||||
|
||||
// /**
|
||||
// * Create an Instance of Class Object ...
|
||||
// *
|
||||
// * @param name: Object Name
|
||||
// * @param xDis: X Distance
|
||||
// * @param yDis: Y Distance
|
||||
// * @param xSize: X Size
|
||||
// * @param ySize: Y Size
|
||||
// */
|
||||
// bool Create(
|
||||
// string name,
|
||||
// int xDis,
|
||||
// int yDis,
|
||||
// int xSize,
|
||||
// int ySize //
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// // Object creation and property settings
|
||||
// bool result = false;
|
||||
|
||||
// //
|
||||
// result = ObjectCreate(0, name, OBJ_RECTANGLE_LABEL, 0, 0, 0);
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //
|
||||
// ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
// ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
// ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
// ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
// //
|
||||
// mName = name;
|
||||
|
||||
// //
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Destroy Class Instance ...
|
||||
// */
|
||||
// void Destroy()
|
||||
// {
|
||||
// ObjectDelete(0, mName);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Set Object Border Type ...
|
||||
// *
|
||||
// * @param borderType: Specified border type
|
||||
// */
|
||||
// void SetBorderType(ENUM_BORDER_TYPE borderType)
|
||||
// {
|
||||
// //
|
||||
// ObjectSetInteger(
|
||||
// 0,
|
||||
// mName,
|
||||
// OBJPROP_BORDER_TYPE,
|
||||
// borderType //
|
||||
// );
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Set Object Background Color
|
||||
// *
|
||||
// * @param value: color
|
||||
// */
|
||||
// void SetBGColor(color value)
|
||||
// {
|
||||
// //
|
||||
// ObjectSetInteger(
|
||||
// 0,
|
||||
// mName,
|
||||
// OBJPROP_BGCOLOR,
|
||||
// value //
|
||||
// );
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Add a Name to Object
|
||||
// * @param name: name
|
||||
// */
|
||||
// void Add(string name)
|
||||
// {
|
||||
// //
|
||||
// // Add a new object by name to the rectangle label and track distances
|
||||
// ArrayResize(mAddedNames, ArraySize(mAddedNames) + 1);
|
||||
// ArrayResize(mAddedXDisDiffrence, ArraySize(mAddedXDisDiffrence) + 1);
|
||||
// ArrayResize(mAddedYDisDiffrence, ArraySize(mAddedYDisDiffrence) + 1);
|
||||
|
||||
// //
|
||||
// mAddedNames[ArraySize(mAddedNames) - 1] = name;
|
||||
// mAddedXDisDiffrence[ArraySize(mAddedXDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_XDISTANCE) - ObjectGetInteger(0, name, OBJPROP_XDISTANCE);
|
||||
// mAddedYDisDiffrence[ArraySize(mAddedYDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_YDISTANCE) - ObjectGetInteger(0, name, OBJPROP_YDISTANCE);
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Protected ...
|
||||
// protected:
|
||||
// //
|
||||
// // Private ...
|
||||
// private:
|
||||
// //
|
||||
// // Props ...
|
||||
|
||||
// //
|
||||
// string mName; // Name of Object
|
||||
|
||||
// //
|
||||
// // Mouse state tracking variables ...
|
||||
// int mlbDownX;
|
||||
// int mlbDownY;
|
||||
// int mlbDownXDistance;
|
||||
// int mlbDownYDistance;
|
||||
// int mPreviousMouseState;
|
||||
|
||||
// //
|
||||
// bool mMovingState; // State for whether the object is moving
|
||||
|
||||
// //
|
||||
// string mAddedNames[]; // Array of added names
|
||||
// long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
// long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
// };
|
||||
@@ -0,0 +1,118 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ProjectName |
|
||||
//| Copyright 2020, CompanyName |
|
||||
//| http://www.companyname.net |
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/XCObjects/x-saherelm.x-panel.class.mq5"
|
||||
#include <Trade/Trade.mqh>
|
||||
|
||||
//
|
||||
CTrade trade;
|
||||
|
||||
//
|
||||
XCPanel panel;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
panel.Create("XPanel", 100, 100, 200, 100);
|
||||
|
||||
//
|
||||
// Enables mouse move events on the chart
|
||||
// ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true);
|
||||
|
||||
// Initialize and set properties for Title bar, main dashboard, and all other elements
|
||||
// TitleBar.Create("TitleBar", 100, 100, 200, 20);
|
||||
// TitleBar.SetBorderType(BORDER_FLAT);
|
||||
// TitleBar.SetBGColor(C'27, 59, 146');
|
||||
|
||||
// MainDashboardBody.Create("MainDashboardBody", 100, 119, 200, 100);
|
||||
// MainDashboardBody.SetBorderType(BORDER_FLAT);
|
||||
// MainDashboardBody.SetBGColor(C'102, 152, 250');
|
||||
|
||||
// TitleText.Create("TitleText", 110, 101);
|
||||
// TitleText.SetText("Simple Trading EA V1.0");
|
||||
// TitleText.SetFontSize(10);
|
||||
// TitleText.SetTextColor(clrWhite);
|
||||
|
||||
// LotSizeText.Create("LotSizeText", 110, 140);
|
||||
// LotSizeText.SetText("Lot Size:");
|
||||
// LotSizeText.SetFontSize(12);
|
||||
// LotSizeText.SetTextColor(clrWhite);
|
||||
|
||||
// LotSize.Create("LotSize", 220, 140, 50, 20);
|
||||
// LotSize.SetBorderColor(clrBlack);
|
||||
// LotSize.SetBGColor(clrWhiteSmoke);
|
||||
// LotSize.SetText("0.01");
|
||||
// LotSize.SetTextColor(clrBlack);
|
||||
|
||||
// BuyButton.Create("BuyButton", 110, 180, 80, 25);
|
||||
// BuyButton.SetBorderColor(clrBlack);
|
||||
// BuyButton.SetText("Buy");
|
||||
// BuyButton.SetBGColor(clrLime);
|
||||
|
||||
// SellButton.Create("SellButton", 210, 180, 80, 25);
|
||||
// SellButton.SetBorderColor(clrBlack);
|
||||
// SellButton.SetText("Sell");
|
||||
// SellButton.SetBGColor(clrRed);
|
||||
|
||||
// Add the other elements to the Central Element i.e. TitleBar object in this case
|
||||
// TitleBar.Add("MainDashboardBody");
|
||||
// TitleBar.Add("TitleText");
|
||||
// TitleBar.Add("LotSizeText");
|
||||
// TitleBar.Add("LotSize");
|
||||
// TitleBar.Add("BuyButton");
|
||||
// TitleBar.Add("SellButton");
|
||||
|
||||
ChartRedraw(0); // Redraws the chart
|
||||
return (INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert deinitialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
// Destroys all GUI objects
|
||||
// TitleBar.Destroy();
|
||||
// MainDashboardBody.Destroy();
|
||||
// TitleText.Destroy();
|
||||
// LotSizeText.Destroy();
|
||||
// LotSize.Destroy();
|
||||
// BuyButton.Destroy();
|
||||
// SellButton.Destroy();
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//|Chart event handling function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
|
||||
{
|
||||
// Handles click events for Buy and Sell buttons and opens corresponding positions
|
||||
// if (id == CHARTEVENT_OBJECT_CLICK)
|
||||
// {
|
||||
// double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||||
// double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||||
// if (sparam == "BuyButton")
|
||||
// {
|
||||
// trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, (double)LotSize.GetText(), ask, 0, 0);
|
||||
// }
|
||||
// if (sparam == "SellButton")
|
||||
// {
|
||||
// trade.PositionOpen(_Symbol, ORDER_TYPE_SELL, (double)LotSize.GetText(), bid, 0, 0);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Passes events to the TitleBar object
|
||||
// TitleBar.OnEvent(id, lparam, dparam, sparam);
|
||||
|
||||
//
|
||||
panel.OnEvent(id, lparam, dparam, sparam);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user