//+------------------------------------------------------------------+
//| OBJ_LABEL_Example.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
#property description "The Expert Advisor creates and controls the Label object"
#property strict
//+------------------------------------------------------------------+
//| Òèïû êíîïîê |
//+------------------------------------------------------------------+
enum ENUM_BUTTON_TYPE
{
ANCHOR_BUTTON=1,
CORNER_BUTTON=2,
COORD_BUTTON=3
};
//+------------------------------------------------------------------+
//| Ñòðóêòóðà äëÿ îïèñàíèÿ ïîâîðîòà |
//+------------------------------------------------------------------+
struct Degrees
{
double degrees; // óãîë ïîâîðîòà
uchar symbol_code; // êîä ñèìâîëà (÷àñû â Wingdings)
};
//---
input string InpName="OBJ_Label_1"; // Èìÿ ìåòêè
input int InpX=150; // Ðàññòîÿíèå ïî îñè X
input int InpY=250; // Ðàññòîÿíèå ïî îñè Y
input string InpFont="Arial"; // Øðèôò
input int InpFontSize=20; // Ðàçìåð øðèôòà
input color InpColor=clrLightSeaGreen; // Öâåò
input double InpAngle=0.0; // Óãîë íàêëîíà â ãðàäóñàõ
input ENUM_ANCHOR_POINT InpAnchor=ANCHOR_CENTER; // Ñïîñîá ïðèâÿçêè
input bool InpBack=false; // Îáúåêò íà çàäíåì ïëàíå
input bool InpSelection=true; // Âûäåëèòü äëÿ ïåðåìåùåíèé
input bool InpHidden=true; // Ñêðûò â ñïèñêå îáúåêòîâ
input long InpZOrder=0; // Ïðèîðèòåò íà íàæàòèå ìûøüþ
//---
#include <ChartObjects\ChartObjectsTxtControls.mqh>
//--- êíîïêè óïðàâëåíèÿ ñïîñîáîì ïðèâÿçêè
CChartObjectButton ExtAnchorLUButton;
CChartObjectButton ExtAnchorLButton;
CChartObjectButton ExtAnchorLLButton;
CChartObjectButton ExtAnchorUCButton;
CChartObjectButton ExtAnchorCCButton;
CChartObjectButton ExtAnchorLCButton;
CChartObjectButton ExtAnchorRUButton;
CChartObjectButton ExtAnchorRButton;
CChartObjectButton ExtAnchorRLButton;
//--- êíîïêè óïðàâëåíèÿ óãëîì ïðèâÿçêè
CChartObjectButton ExtCornerLUButton;
CChartObjectButton ExtCornerLLButton;
CChartObjectButton ExtCornerRUButton;
CChartObjectButton ExtCornerRLButton;
//--- êíîïêè +- äëÿ êîîðäèíàò x è y
CChartObjectButton ExtCoordIncXButton;
CChartObjectButton ExtCoordDecXButton;
CChartObjectButton ExtCoordIncYButton;
CChartObjectButton ExtCoordDecYButton;
CChartObjectButton ExtCoordIncAngleButton;
//--- èíôîðìàöèîííûå ïîëÿ
CChartObjectEdit ExtXCoordinateInfo;
CChartObjectEdit ExtYCoordinateInfo;
CChartObjectEdit ExtAngleInfo;
CChartObjectEdit ExtCornerInfo;
CChartObjectEdit ExtAnchorInfo;
//---
bool ExtInitialized=false;
long ExtChartWidth=0;
long ExtChartHeight=0;
int ExtCurrentAngleIndex=0;
Degrees ExtAngleParameters[12];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- óñòàíîâêà ïàðàìåòðîâ âðàùåíèÿ è ñîîòâåòñòâóþøèõ óãëàì ÷àñîâ øðèôòà Wingdings
for(int i=0; i<12; i++)
{
ExtAngleParameters[i].degrees=i*(360/12);
if(i<3) ExtAngleParameters[i].symbol_code=uchar(185-i);
else
ExtAngleParameters[i].symbol_code=uchar(197-i);
}
//--- îïðåäåëèì ðàçìåðû îêíà
if(!ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0,ExtChartWidth))
{
Print("Íå óäàëîñü ïîëó÷èòü øèðèíó ãðàôèêà! Êîä îøèáêè = ",GetLastError());
return(INIT_FAILED);
}
if(!ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0,ExtChartHeight))
{
Print("Íå óäàëîñü ïîëó÷èòü âûñîòó ãðàôèêà! Êîä îøèáêè = ",GetLastError());
return(INIT_FAILED);
}
//--- ñîçäàäèì òåêñòîâóþ ìåòêó íà ãðàôèêå
if(!LabelCreate(0,InpName,0,InpX,InpY,CORNER_LEFT_UPPER,"Simple text",InpFont,InpFontSize,
InpColor,InpAngle,ANCHOR_CENTER,InpBack,InpSelection,InpHidden,InpZOrder))
{
return(INIT_FAILED);
}
//--- ïîäãîòàâëèâàåì êíîïêè
PrepareButtons();
ExtInitialized=true;
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- óäàëÿåì ìåòêó ñ ãðàôèêà
ObjectDelete(0,InpName);
//--- óäàëÿåì èíôîðìàöèîííûå ïîëÿ
ObjectDelete(0,"edt_xcoord");
ObjectDelete(0,"edt_ycoord");
ObjectDelete(0,"edt_corner");
ObjectDelete(0,"edt_anchor");
ObjectDelete(0,"edt_angle");
//--- óäàëÿåì êíîïêè óïðàâëåíèÿ ñïîñîáîì ïðèâÿçêè
ObjectDelete(0,"btn_anchor_left_upper");
ObjectDelete(0,"btn_anchor_left");
ObjectDelete(0,"btn_anchor_left_lower");
ObjectDelete(0,"btn_anchor_upper");
ObjectDelete(0,"btn_anchor_center");
ObjectDelete(0,"btn_anchor_lower");
ObjectDelete(0,"btn_anchor_right_upper");
ObjectDelete(0,"btn_anchor_right");
ObjectDelete(0,"btn_anchor_right_lower");
//--- óäàëÿåì êíîïêè óïðàâëåíèÿ óãëîì ïðèâÿçêè
ObjectDelete(0,"btn_corner_left_upper");
ObjectDelete(0,"btn_corner_left_lower");
ObjectDelete(0,"btn_corner_right_upper");
ObjectDelete(0,"btn_corner_right_lower");
//--- óäàëÿåì êíîïêè óïðàâëåíèÿ êîîðäèíàòàìè
ObjectDelete(0,"btn_dec_y");
ObjectDelete(0,"btn_inc_y");
ObjectDelete(0,"btn_inc_x");
ObjectDelete(0,"btn_dec_x");
ObjectDelete(0,"btn_inc_angle");
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
int x=0,y=0;
bool res=true;
//---
if(!ExtInitialized)
return;
//---
int current_corner=(int)ObjectGetInteger(0,InpName,OBJPROP_CORNER);
bool inv_coord_corner_mode_x=false;
bool inv_coord_corner_mode_y=false;
//--- ñïîñîá ïðèðàùåíèÿ êîîðäèíàò ïðè çàäàííîì óãëå ïðèâÿçêè
switch(current_corner)
{
case CORNER_LEFT_LOWER: {inv_coord_corner_mode_y=true; break;}
case CORNER_RIGHT_UPPER: {inv_coord_corner_mode_x=true; break;}
case CORNER_RIGHT_LOWER: {inv_coord_corner_mode_x=true;
inv_coord_corner_mode_y=true; break;}
}
//--- ñáðîñèì çíà÷åíèå îøèáêè
ResetLastError();
//--- ïðîâåðêà ñîáûòèÿ íàæàòèÿ íà êíîïêó ìûøè
if(id==CHARTEVENT_OBJECT_CLICK)
{
Comment("CHARTEVENT_CLICK: "+sparam);
//--- êíîïêà óïðàâëåíèÿ óãëîì îáúåêòà Label
if(sparam=="btn_inc_angle")
{
ButtonPressed(ExtCoordIncAngleButton,COORD_BUTTON);
//--- óâåëè÷èâàåì èíäåêñ (óãîë ïîâîðîòà)
ExtCurrentAngleIndex++;
if(ExtCurrentAngleIndex>ArraySize(ExtAngleParameters)-1) ExtCurrentAngleIndex=0;
//--- óñòàíàâëèâàåì óãîë ïîâîðîòà
double angle=ExtAngleParameters[ExtCurrentAngleIndex].degrees;
ExtCoordIncAngleButton.Description(CharToString(ExtAngleParameters[ExtCurrentAngleIndex].symbol_code));
//---
res=ObjectSetDouble(0,InpName,OBJPROP_ANGLE,angle);
UnSelectButton(ExtCoordIncAngleButton);
}
//--- êíîïêè óïðàâëåíèÿ êîîðäèíàòàìè îáúåêòà Label
if(sparam=="btn_inc_x")
{
ButtonPressed(ExtCoordIncXButton,COORD_BUTTON);
x=(int)ObjectGetInteger(0,InpName,OBJPROP_XDISTANCE);
if(!inv_coord_corner_mode_x) x+=20; else x-=20;
if(x>ExtChartWidth) x=(int)ExtChartWidth;
if(x<0) x=0;
res=ObjectSetInteger(0,InpName,OBJPROP_XDISTANCE,x);
UnSelectButton(ExtCoordIncXButton);
}
if(sparam=="btn_dec_x")
{
ButtonPressed(ExtCoordDecXButton,COORD_BUTTON);
x=(int)ObjectGetInteger(0,InpName,OBJPROP_XDISTANCE);
if(!inv_coord_corner_mode_x) x-=20; else x+=20;
if(x<0) x=0;
res=ObjectSetInteger(0,InpName,OBJPROP_XDISTANCE,x);
UnSelectButton(ExtCoordDecXButton);
}
if(sparam=="btn_inc_y")
{
ButtonPressed(ExtCoordIncYButton,COORD_BUTTON);
y=(int)ObjectGetInteger(0,InpName,OBJPROP_YDISTANCE);
if(!inv_coord_corner_mode_y) y+=20; else y-=20;
if(y<0) y=0;
if(y>ExtChartHeight) y=(int)ExtChartHeight;
res=ObjectSetInteger(0,InpName,OBJPROP_YDISTANCE,y);
UnSelectButton(ExtCoordIncYButton);
}
if(sparam=="btn_dec_y")
{
ButtonPressed(ExtCoordDecYButton,COORD_BUTTON);
y=(int)ObjectGetInteger(0,InpName,OBJPROP_YDISTANCE);
// y-=20;
if(!inv_coord_corner_mode_y) y-=20; else y+=20;
if(y<0) y=0;
if(y>ExtChartHeight) y=(int)ExtChartHeight;
res=ObjectSetInteger(0,InpName,OBJPROP_YDISTANCE,y);
UnSelectButton(ExtCoordDecYButton);
}
//--- êíîïêè óïðàâëåíèÿ ñïîñîáîì ïðèâÿçêè ìåòêè (OBJPROP_ANCHOR)
if(sparam=="btn_anchor_left_upper")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_LEFT_UPPER);
}
if(sparam=="btn_anchor_left")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_LEFT);
}
if(sparam=="btn_anchor_left_lower")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_LEFT_LOWER);
}
if(sparam=="btn_anchor_upper")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_UPPER);
}
if(sparam=="btn_anchor_center")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_CENTER);
}
if(sparam=="btn_anchor_lower")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_LOWER);
}
if(sparam=="btn_anchor_right_upper")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
}
if(sparam=="btn_anchor_right")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_RIGHT);
}
if(sparam=="btn_anchor_right_lower")
{
res=ObjectSetInteger(0,InpName,OBJPROP_ANCHOR,ANCHOR_RIGHT_LOWER);
}
//--- êíîïêè óïðàâëåíèÿ óãëîì ãðàôèêà äëÿ ïðèâÿçêè ìåòêè (OBJPROP_CORNER)
if(sparam=="btn_corner_left_upper")
{
res=ObjectSetInteger(0,InpName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
}
if(sparam=="btn_corner_left_lower")
{
res=ObjectSetInteger(0,InpName,OBJPROP_CORNER,CORNER_LEFT_LOWER);
}
if(sparam=="btn_corner_right_upper")
{
res=ObjectSetInteger(0,InpName,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
}
if(sparam=="btn_corner_right_lower")
{
res=ObjectSetInteger(0,InpName,OBJPROP_CORNER,CORNER_RIGHT_LOWER);
}
if(!res)
Print("Íå óäàëîñü èçìåíèòü ïàðàìåòð! Êîä îøèáêè = ",GetLastError());
else
{
ShowLabelInfo(0,InpName);
ChartRedraw();
}
}
}
//+------------------------------------------------------------------+
//| Ñîçäàåò òåêñòîâóþ ìåòêó |
//+------------------------------------------------------------------+
bool LabelCreate(const long chart_ID=0, // ID ãðàôèêà
const string name="Label", // èìÿ ìåòêè
const int sub_window=0, // íîìåð ïîäîêíà
const int x=0, // êîîðäèíàòà ïî îñè X
const int y=0, // êîîðäèíàòà ïî îñè Y
const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // óãîë ãðàôèêà äëÿ ïðèâÿçêè
const string text="Label", // òåêñò
const string font="Arial", // øðèôò
const int font_size=10, // ðàçìåð øðèôòà
const color clr=clrRed, // öâåò
const double angle=0.0, // íàêëîí òåêñòà
const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // ñïîñîá ïðèâÿçêè
const bool back=false, // íà çàäíåì ïëàíå
const bool selection=false, // âûäåëèòü äëÿ ïåðåìåùåíèé
const bool hidden=true, // ñêðûò â ñïèñêå îáúåêòîâ
const long z_order=0) // ïðèîðèòåò íà íàæàòèå ìûøüþ
{
//--- ñáðîñèì çíà÷åíèå îøèáêè
ResetLastError();
//--- ñîçäàäèì òåêñòîâóþ ìåòêó
if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
{
Print(__FUNCTION__,": íå óäàëîñü ñîçäàòü òåêñòîâóþ ìåòêó! Êîä îøèáêè = ",GetLastError());
return(false);
}
//--- óñòàíîâèì êîîðäèíàòû ìåòêè
ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- óñòàíîâèì óãîë ãðàôèêà, îòíîñèòåëüíî êîòîðîãî áóäóò îïðåäåëÿòüñÿ êîîðäèíàòû òî÷êè
ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
//--- óñòàíîâèì òåêñò
ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
//--- óñòàíîâèì øðèôò òåêñòà
ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
//--- óñòàíîâèì ðàçìåð øðèôòà
ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
//--- óñòàíîâèì óãîë íàêëîíà òåêñòà
ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
//--- óñòàíîâèì ñïîñîá ïðèâÿçêè
ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- óñòàíîâèì öâåò
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- îòîáðàçèì íà ïåðåäíåì (false) èëè çàäíåì (true) ïëàíå
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- âêëþ÷èì (true) èëè îòêëþ÷èì (false) ðåæèì ïåðåìåùåíèÿ ìåòêè ìûøüþ
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- ñêðîåì (true) èëè îòîáðàçèì (false) èìÿ ãðàôè÷åñêîãî îáúåêòà â ñïèñêå îáúåêòîâ
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- óñòàíîâèì ïðèîðèòåò íà ïîëó÷åíèå ñîáûòèÿ íàæàòèÿ ìûøè íà ãðàôèêå
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- óñïåøíîå âûïîëíåíèå
return(true);
}
//+------------------------------------------------------------------+
//| Ñîçäàåò êíîïêè |
//+------------------------------------------------------------------+
void PrepareButtons()
{
//---
int x0=0;
int y0=0;
//---
CreateEdit("xcoord",ExtXCoordinateInfo,x0+8,y0+34,70,20);
CreateEdit("ycoord",ExtYCoordinateInfo,x0+78,y0+34,70,20);
CreateEdit("corner",ExtCornerInfo,x0+8,y0+54,200,20);
CreateEdit("anchor",ExtAnchorInfo,x0+8,y0+74,200,20);
CreateEdit("angle",ExtAngleInfo,x0+148,y0+34,60,20);
//---
CreateButton("anchor_left_upper",ExtAnchorLUButton,x0+10,y0+150,150,20);
CreateButton("anchor_left",ExtAnchorLButton,x0+10,y0+173,150,20);
CreateButton("anchor_left_lower",ExtAnchorLLButton,x0+10,y0+196,150,20);
//---
CreateButton("anchor_upper",ExtAnchorUCButton,x0+163,y0+150,150,20);
CreateButton("anchor_center",ExtAnchorCCButton,x0+163,y0+173,150,20);
CreateButton("anchor_lower",ExtAnchorLCButton,x0+163,y0+196,150,20);
//---
CreateButton("anchor_right_upper",ExtAnchorRUButton,+x0+16+2*150,y0+150,150,20);
CreateButton("anchor_right",ExtAnchorRButton,+x0+316,y0+173,150,20);
CreateButton("anchor_right_lower",ExtAnchorRLButton,+x0+316,y0+196,150,20);
//---
CreateButton("corner_left_upper",ExtCornerLUButton,x0+10,y0+100,150,20);
CreateButton("corner_left_lower",ExtCornerLLButton,x0+10,y0+123,150,20);
CreateButton("corner_right_upper",ExtCornerRUButton,x0+163,y0+100,150,20);
CreateButton("corner_right_lower",ExtCornerRLButton,x0+163,y0+123,150,20);
//---
CreateButton("dec_y",ExtCoordDecYButton,x0+413,y0+36,25,25);
CreateButton("inc_y",ExtCoordIncYButton,x0+413,y0+92,25,25);
CreateButton("inc_x",ExtCoordIncXButton,x0+441,y0+64,25,25);
CreateButton("dec_x",ExtCoordDecXButton,x0+385,y0+64,25,25);
CreateButton("inc_angle",ExtCoordIncAngleButton,x0+413,y0+64,25,25);
//---
ExtCoordIncXButton.FontSize(15);
ExtCoordDecXButton.FontSize(15);
ExtCoordIncYButton.FontSize(15);
ExtCoordDecYButton.FontSize(15);
//---
ExtCoordIncXButton.Font("Wingdings");
ExtCoordDecXButton.Font("Wingdings");
ExtCoordIncYButton.Font("Wingdings");
ExtCoordDecYButton.Font("Wingdings");
ExtCoordIncAngleButton.Font("Wingdings");
ExtCoordIncAngleButton.FontSize(20);
//---
ExtCoordIncXButton.Description(CharToString(240));
ExtCoordDecXButton.Description(CharToString(239));
ExtCoordIncYButton.Description(CharToString(242));
ExtCoordDecYButton.Description(CharToString(241));
//---
ExtCoordIncAngleButton.Description(CharToString(ExtAngleParameters[ExtCurrentAngleIndex].symbol_code));
//--- ïîêàçûâàåì òåêóùèå ñâîéñòâà ìåòêè ñ èìåíåì InpName
ShowLabelInfo(0,InpName);
}
//+------------------------------------------------------------------+
//| Ïîêàçûâàåò èíôîðìàöèþ î êîîðäèíàòàõ è ñâîéñòâàõ ïðèâÿçêè ìåòêè |
//+------------------------------------------------------------------+
void ShowLabelInfo(const long chart_ID,const string name)
{
//---
int current_corner=(int)ObjectGetInteger(chart_ID,name,OBJPROP_CORNER);
int current_anchor=(int)ObjectGetInteger(chart_ID,name,OBJPROP_ANCHOR);
//---
switch(current_corner)
{
case CORNER_LEFT_UPPER: ButtonPressed(ExtCornerLUButton,CORNER_BUTTON); break;
case CORNER_LEFT_LOWER: ButtonPressed(ExtCornerLLButton,CORNER_BUTTON); break;
case CORNER_RIGHT_LOWER: ButtonPressed(ExtCornerRLButton,CORNER_BUTTON); break;
case CORNER_RIGHT_UPPER: ButtonPressed(ExtCornerRUButton,CORNER_BUTTON); break;
}
//---
switch(current_anchor)
{
case ANCHOR_LEFT_UPPER: ButtonPressed(ExtAnchorLUButton,ANCHOR_BUTTON); break;
case ANCHOR_LEFT: ButtonPressed(ExtAnchorLButton,ANCHOR_BUTTON); break;
case ANCHOR_LEFT_LOWER: ButtonPressed(ExtAnchorLLButton,ANCHOR_BUTTON); break;
case ANCHOR_UPPER: ButtonPressed(ExtAnchorUCButton,ANCHOR_BUTTON); break;
case ANCHOR_CENTER: ButtonPressed(ExtAnchorCCButton,ANCHOR_BUTTON); break;
case ANCHOR_LOWER: ButtonPressed(ExtAnchorLCButton,ANCHOR_BUTTON); break;
case ANCHOR_RIGHT_UPPER: ButtonPressed(ExtAnchorRUButton,ANCHOR_BUTTON); break;
case ANCHOR_RIGHT: ButtonPressed(ExtAnchorRButton,ANCHOR_BUTTON); break;
case ANCHOR_RIGHT_LOWER: ButtonPressed(ExtAnchorRLButton,ANCHOR_BUTTON); break;
}
//---
int x=(int)ObjectGetInteger(chart_ID,name,OBJPROP_XDISTANCE);
int y=(int)ObjectGetInteger(chart_ID,name,OBJPROP_YDISTANCE);
double angle=ObjectGetDouble(chart_ID,name,OBJPROP_ANGLE);
//---
ExtXCoordinateInfo.Description(IntegerToString(x));
ExtYCoordinateInfo.Description(IntegerToString(y));
ExtAngleInfo.Description(DoubleToString(angle,2));
//---
ExtCornerInfo.Description(EnumToString(ENUM_BASE_CORNER(current_corner)));
ExtAnchorInfo.Description(EnumToString(ENUM_ANCHOR_POINT(current_anchor)));
}
//+------------------------------------------------------------------+
//| UnSelectButton |
//+------------------------------------------------------------------+
void UnSelectButton(CChartObjectButton &btn)
{
btn.State(false);
btn.BackColor(clrAliceBlue);
}
//+------------------------------------------------------------------+
//| Cîçäàåò êíîïêó (îáúåêò òèïà CChartObjectButton) |
//+------------------------------------------------------------------+
bool CreateButton(string text,CChartObjectButton &btn,int x0,int y0,int width,int height)
{
if(!btn.Create(0,"btn_"+text,0,x0,y0,width,height))
return(false);
btn.Font("Verdana");
btn.FontSize(7);
StringToUpper(text);
btn.Description(text);
btn.State(false);
UnSelectButton(btn);
//---
return(true);
}
//+------------------------------------------------------------------+
//| Cîçäàåò îáúåêò òèïà CChartObjectEdit |
//+------------------------------------------------------------------+
bool CreateEdit(string name,CChartObjectEdit &edit,int x0,int y0,int width,int height)
{
if(!edit.Create(0,"edt_"+name,0,x0,y0,width,height))
return(false);
edit.Font("Verdana");
edit.FontSize(7);
edit.BackColor(clrIvory);
edit.Description("");
edit.ReadOnly(true);
//---
return(true);
}
//+------------------------------------------------------------------+
//| UnselectButtons |
//+------------------------------------------------------------------+
void UnselectButtons(ENUM_BUTTON_TYPE buttontype)
{
switch(buttontype)
{
case ANCHOR_BUTTON:
{
UnSelectButton(ExtAnchorLUButton);
UnSelectButton(ExtAnchorLButton);
UnSelectButton(ExtAnchorLLButton);
//---
UnSelectButton(ExtAnchorUCButton);
UnSelectButton(ExtAnchorCCButton);
UnSelectButton(ExtAnchorLCButton);
//---
UnSelectButton(ExtAnchorRUButton);
UnSelectButton(ExtAnchorRButton);
UnSelectButton(ExtAnchorRLButton);
break;
}
case CORNER_BUTTON:
{
UnSelectButton(ExtCornerLUButton);
UnSelectButton(ExtCornerLLButton);
UnSelectButton(ExtCornerRUButton);
UnSelectButton(ExtCornerRLButton);
break;
}
case COORD_BUTTON:
{
UnSelectButton(ExtCoordIncXButton);
UnSelectButton(ExtCoordDecXButton);
UnSelectButton(ExtCoordIncYButton);
UnSelectButton(ExtCoordDecYButton);
UnSelectButton(ExtCoordIncAngleButton);
break;
}
}
}
//+------------------------------------------------------------------+
//| ButtonPressed |
//+------------------------------------------------------------------+
bool ButtonPressed(CChartObjectButton &btn,ENUM_BUTTON_TYPE buttontype)
{
UnselectButtons(buttontype);
//---
bool state=!btn.State();
btn.State(state);
if(state)
btn.BackColor(clrHoneydew);
else
btn.BackColor(clrAliceBlue);
//---
return(true);
}
//+------------------------------------------------------------------+
Comments