Files
xMQL5/MQLTestWorkspace/BKPS/BKP/x121 old style indicators/x-saherelm.x121.chart.tools.lib.mq5
T

194 lines
3.8 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 X12 Draw Library
// ------------------------------------------
// Name: X121Draw
// Description: provides Draw Requirements ...
//
//
// 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 "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
//
// START Chart Tools Functions ...
//
//
string x121ToolsButtonName = "X121TOOLS";
//
// Calculate Button size ...
bool CalculateButtonSize(
XSize &result, // Holds Result ...
long chartID = 0, // Specified Chart ID ...
int step = 32 // Step Divider ...
)
{
//
bool mResult = false;
//
mResult = GetChartSize(
result,
chartID);
if (!mResult)
{
return mResult;
}
//
// define the step for changing the button size
int x_step = (int)result.width / step;
int y_step = (int)result.height / step;
//
// set the button coordinates and its size
int x = (int)result.width / step;
int y = (int)result.height / step;
//
// int width = (int)result.width * 15 / 32;
// int height = (int)result.height * 15 / 32;
int width = (int)result.width / 32;
int height = (int)result.height / 32;
//
result.x = x;
result.y = y;
result.w = width;
result.h = height;
result.wStep = x_step;
result.hStep = y_step;
//
return mResult;
}
//
// Draw Tools Button On Chart ...
bool DrawToolsButton(
long chartID = 0, // Specified Chart ID ...
int subWindow = 0, // Specified Chart's SubWindow ...
ENUM_BASE_CORNER corner = CORNER_LEFT_UPPER // Specified Corner to Draw Button ...
)
{
//
bool result = false;
//
XSize size;
result = CalculateButtonSize(
size,
chartID);
if (!result)
{
return result;
}
//
result = ButtonCreate(
chartID,
x121ToolsButtonName,
0,
size.x,
size.y,
size.w,
size.y,
corner,
"Press",
"Arial",
10,
clrBlack,
clrLightGray,
CLR_NONE,
false, // Pressed/Released ...
false,
false,
true,
0);
//
return result;
}
//
bool ToggleToolsButtonState(
long chartID = 0, // Specified Chart ID ...
int subWindow = 0 // Specified Chart's SubWindow ...
)
{
//
bool result = false;
//
return result;
}
//
// Prepare Chart Requirements ...
bool DrawTools(
long chartID = 0, // Specified Chart ID ...
int subWindow = 0 // Specified Chart's SubWindow ...
)
{
//
bool result = false;
//
result = DrawToolsButton(
chartID,
subWindow);
//
// redraw the chart
if (result)
{
ChartRedraw();
}
//
return result;
}
//
// Parse Chart Tools Events ...
void HandleToolsChartEvent(
long chartID, // Specified Chart ID ...
const int id, // event ID
const long &lparam, // long type event parameter
const double &dparam, // double type event parameter
const string &sparam // string type event parameter
)
{
//
// OnClick ...
if (id == CHARTEVENT_CLICK)
{
//
// Toolls Btton Clicked ...
if (sparam == x121ToolsButtonName)
{
LogMessage("Tools Button Clicked ...");
}
}
}
//
// END Chart Tools Functions ...
//