Files
MQL5Data/Classes/XCObjects/x-saherelm.x-button.class.mq5
T
2024-09-25 03:55:35 +03:30

183 lines
3.4 KiB
Plaintext

///////////////////////////////////////////////////////
//
// 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);
}
/**
* 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);
}
//
// 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
};