Refactor XCObjects and Extends them from Base XCObject Class and also Implement GUI Features on EA Class and Refactor Inputs ...

This commit is contained in:
2024-09-28 19:30:51 +03:30
parent d91c7967c2
commit d3e0d74d31
7 changed files with 981 additions and 395 deletions
+20 -66
View File
@@ -20,7 +20,7 @@
#property strict
//
#include "../x-saherelm.base.class.mq5"
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
//
// Definitions ...
@@ -30,7 +30,7 @@
//
// a Button Creation Class ...
class XCButton : XSCBase
class XCButton : public XCObject
{
//
// Public ...
@@ -64,7 +64,8 @@ class XCButton : XSCBase
int xDis,
int yDis,
int xSize,
int ySize //
int ySize,
long chartID = 0 //
)
{
//
@@ -72,33 +73,26 @@ class XCButton : XSCBase
bool result = false;
//
result = ObjectCreate(0, name, OBJ_BUTTON, 0, 0, 0);
result = ObjectCreate(chartID, 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);
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize);
ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize);
//
mName = name;
mChartID = chartID;
//
return result;
}
/**
* Destroy Class Instance ...
*/
void Destroy()
{
ObjectDelete(0, mName);
}
//
// Getter(s) / Setter(s) ...
@@ -107,9 +101,9 @@ class XCButton : XSCBase
*
* @param value: color
*/
void SetBorderColor(color value)
void BorderColor(color value)
{
ObjectSetInteger(0, mName, OBJPROP_BORDER_COLOR, value);
ObjectSetInteger(mChartID, mName, OBJPROP_BORDER_COLOR, value);
}
/**
@@ -117,9 +111,9 @@ class XCButton : XSCBase
*
* @param value: color
*/
void SetBGColor(color value)
void BGColor(color value)
{
ObjectSetInteger(0, mName, OBJPROP_BGCOLOR, value);
ObjectSetInteger(mChartID, mName, OBJPROP_BGCOLOR, value);
}
/**
@@ -127,9 +121,9 @@ class XCButton : XSCBase
*
* @param value: Color
*/
void SetColor(color value)
void Color(color value)
{
ObjectSetInteger(0, mName, OBJPROP_COLOR, value);
ObjectSetInteger(mChartID, mName, OBJPROP_COLOR, value);
}
/**
@@ -137,29 +131,9 @@ class XCButton : XSCBase
*
* @param value: text
*/
void SetText(string value)
void Text(string value)
{
ObjectSetString(0, mName, OBJPROP_TEXT, value);
}
/**
* Set Object ZOrder ...
*
* @param value: z order
*/
void SetZOrder(int value)
{
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
}
/**
* Set Object as Background ...
*
* @param value: boolean value
*/
void SetAsBackGround(bool value)
{
ObjectSetInteger(0, mName, OBJPROP_BACK, value);
ObjectSetString(mChartID, mName, OBJPROP_TEXT, value);
}
/**
@@ -167,9 +141,9 @@ class XCButton : XSCBase
*
* @param value: state
*/
void SetState(bool value)
void State(bool value)
{
ObjectSetInteger(0, mName, OBJPROP_STATE, value);
ObjectSetInteger(mChartID, mName, OBJPROP_STATE, value);
}
//
@@ -179,24 +153,4 @@ class XCButton : XSCBase
// 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
};