OBJ_Label_Example

Author: Copyright 2013, MetaQuotes Software Corp.
0 Views
0 Downloads
0 Favorites
OBJ_Label_Example
ÿþ//+------------------------------------------------------------------+

//|                                            OBJ_LABEL_Example.mq5 |

//|                        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

//+------------------------------------------------------------------+

//| "8?K :=>?>:                                                      |

//+------------------------------------------------------------------+

enum ENUM_BUTTON_TYPE

  {

   ANCHOR_BUTTON=1,

   CORNER_BUTTON=2,

   COORD_BUTTON=3

  };

//+------------------------------------------------------------------+

//| !B@C:BC@0 4;O >?8A0=8O ?>2>@>B0                                  |

//+------------------------------------------------------------------+

struct Degrees

  {

   double            degrees;     // C3>; ?>2>@>B0

   uchar             symbol_code; // :>4 A8<2>;0 (G0AK 2 Wingdings)

  };

//---

input string            InpName="OBJ_Label_1";     // <O <5B:8

input int               InpX=150;                  //  0AAB>O=85 ?> >A8 X

input int               InpY=250;                  //  0AAB>O=85 ?> >A8 Y

input string            InpFont="Arial";           // (@8DB

input int               InpFontSize=20;            //  07<5@ H@8DB0

input color             InpColor=clrLightSeaGreen; // &25B

input double            InpAngle=0.0;              // #3>; =0:;>=0 2 3@04CA0E

input ENUM_ANCHOR_POINT InpAnchor=ANCHOR_CENTER;   // !?>A>1 ?@82O7:8

input bool              InpBack=false;             // 1J5:B =0 704=5< ?;0=5

input bool              InpSelection=true;         // K45;8BL 4;O ?5@5<5I5=89

input bool              InpHidden=true;            // !:@KB 2 A?8A:5 >1J5:B>2

input long              InpZOrder=0;               // @8>@8B5B =0 =060B85 <KHLN

//---

#include <ChartObjects\ChartObjectsTxtControls.mqh>

//--- :=>?:8 C?@02;5=8O A?>A>1>< ?@82O7:8

CChartObjectButton ExtAnchorLUButton;

CChartObjectButton ExtAnchorLButton;

CChartObjectButton ExtAnchorLLButton;

CChartObjectButton ExtAnchorUCButton;

CChartObjectButton ExtAnchorCCButton;

CChartObjectButton ExtAnchorLCButton;

CChartObjectButton ExtAnchorRUButton;

CChartObjectButton ExtAnchorRButton;

CChartObjectButton ExtAnchorRLButton;

//--- :=>?:8 C?@02;5=8O C3;>< ?@82O7:8

CChartObjectButton ExtCornerLUButton;

CChartObjectButton ExtCornerLLButton;

CChartObjectButton ExtCornerRUButton;

CChartObjectButton ExtCornerRLButton;

//--- :=>?:8 +- 4;O :>>@48=0B x 8 y

CChartObjectButton ExtCoordIncXButton;

CChartObjectButton ExtCoordDecXButton;

CChartObjectButton ExtCoordIncYButton;

CChartObjectButton ExtCoordDecYButton;

CChartObjectButton ExtCoordIncAngleButton;

//--- 8=D>@<0F8>==K5 ?>;O

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()

  {

//--- CAB0=>2:0 ?0@0<5B@>2 2@0I5=8O 8 A>>B25BAB2CNH8E C3;0< G0A>2 H@8DB0 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);

     }

//--- >?@545;8< @07<5@K >:=0

   if(!ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0,ExtChartWidth))

     {

      Print("5 C40;>AL ?>;CG8BL H8@8=C 3@0D8:0! >4 >H81:8 = ",GetLastError());

      return(INIT_FAILED);

     }

   if(!ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0,ExtChartHeight))

     {

      Print("5 C40;>AL ?>;CG8BL 2KA>BC 3@0D8:0! >4 >H81:8 = ",GetLastError());

      return(INIT_FAILED);

     }

//--- A>74048< B5:AB>2CN <5B:C =0 3@0D8:5

   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);

     }

//--- ?>43>B02;8205< :=>?:8

   PrepareButtons();

   ExtInitialized=true;

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//--- C40;O5< <5B:C A 3@0D8:0

   ObjectDelete(0,InpName);

//--- C40;O5< 8=D>@<0F8>==K5 ?>;O

   ObjectDelete(0,"edt_xcoord");

   ObjectDelete(0,"edt_ycoord");

   ObjectDelete(0,"edt_corner");

   ObjectDelete(0,"edt_anchor");

   ObjectDelete(0,"edt_angle");

//--- C40;O5< :=>?:8 C?@02;5=8O A?>A>1>< ?@82O7:8

   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");

//--- C40;O5< :=>?:8 C?@02;5=8O C3;>< ?@82O7:8

   ObjectDelete(0,"btn_corner_left_upper");

   ObjectDelete(0,"btn_corner_left_lower");

   ObjectDelete(0,"btn_corner_right_upper");

   ObjectDelete(0,"btn_corner_right_lower");

//--- C40;O5< :=>?:8 C?@02;5=8O :>>@48=0B0<8

   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;

//--- A?>A>1 ?@8@0I5=8O :>>@48=0B ?@8 7040==>< C3;5 ?@82O7:8

   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;

        }

     }

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- ?@>25@:0 A>1KB8O =060B8O =0 :=>?:C <KH8

   if(id==CHARTEVENT_OBJECT_CLICK)

     {

      Comment("CHARTEVENT_CLICK: "+sparam);



      //--- :=>?:0 C?@02;5=8O C3;>< >1J5:B0 Label

      if(sparam=="btn_inc_angle")

        {

         ButtonPressed(ExtCoordIncAngleButton,COORD_BUTTON);

         //--- C25;8G8205< 8=45:A (C3>; ?>2>@>B0)

         ExtCurrentAngleIndex++;

         if(ExtCurrentAngleIndex>ArraySize(ExtAngleParameters)-1) ExtCurrentAngleIndex=0;

         //--- CAB0=02;8205< C3>; ?>2>@>B0

         double angle=ExtAngleParameters[ExtCurrentAngleIndex].degrees;

         ExtCoordIncAngleButton.Description(CharToString(ExtAngleParameters[ExtCurrentAngleIndex].symbol_code));

         //---

         res=ObjectSetDouble(0,InpName,OBJPROP_ANGLE,angle);

         UnSelectButton(ExtCoordIncAngleButton);

        }

      //--- :=>?:8 C?@02;5=8O :>>@48=0B0<8 >1J5:B0 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);

        }

      //--- :=>?:8 C?@02;5=8O A?>A>1>< ?@82O7:8 <5B:8 (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);

        }

      //--- :=>?:8 C?@02;5=8O C3;>< 3@0D8:0 4;O ?@82O7:8 <5B:8 (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("5 C40;>AL 87<5=8BL ?0@0<5B@! >4 >H81:8 = ",GetLastError());

      else

        {

         ShowLabelInfo(0,InpName);

         ChartRedraw();

        }

     }

  }

//+------------------------------------------------------------------+

//| !>7405B B5:AB>2CN <5B:C                                          |

//+------------------------------------------------------------------+

bool LabelCreate(const long              chart_ID=0,               // ID 3@0D8:0

                 const string            name="Label",             // 8<O <5B:8

                 const int               sub_window=0,             // =><5@ ?>4>:=0

                 const int               x=0,                      // :>>@48=0B0 ?> >A8 X

                 const int               y=0,                      // :>>@48=0B0 ?> >A8 Y

                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8

                 const string            text="Label",             // B5:AB

                 const string            font="Arial",             // H@8DB

                 const int               font_size=10,             // @07<5@ H@8DB0

                 const color             clr=clrRed,               // F25B

                 const double            angle=0.0,                // =0:;>= B5:AB0

                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // A?>A>1 ?@82O7:8

                 const bool              back=false,               // =0 704=5< ?;0=5

                 const bool              selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

                 const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2

                 const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- A>74048< B5:AB>2CN <5B:C

   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))

     {

      Print(__FUNCTION__,": =5 C40;>AL A>740BL B5:AB>2CN <5B:C! >4 >H81:8 = ",GetLastError());

      return(false);

     }

//--- CAB0=>28< :>>@48=0BK <5B:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

//--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- CAB0=>28< B5:AB

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

//--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

//--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

//--- CAB0=>28< C3>; =0:;>=0 B5:AB0

   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);

//--- CAB0=>28< A?>A>1 ?@82O7:8

   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);

//--- CAB0=>28< F25B

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O <5B:8 <KHLN

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//+------------------------------------------------------------------+

//| !>7405B :=>?:8                                                   |

//+------------------------------------------------------------------+

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));

//--- ?>:07K205< B5:CI85 A2>9AB20 <5B:8 A 8<5=5< InpName

   ShowLabelInfo(0,InpName);

  }

//+------------------------------------------------------------------+

//| >:07K205B 8=D>@<0F8N > :>>@48=0B0E 8 A2>9AB20E ?@82O7:8 <5B:8   |

//+------------------------------------------------------------------+

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>7405B :=>?:C (>1J5:B B8?0 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>7405B >1J5:B B8?0 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