量化软件下载:赫兹股票期货量化之改进扩展标准图形对象的处理
进库类
如果图表里因创建 GUI 元素而包含任何附于画布上的图形对象 — 元素、形状、窗口(尚未实现)或其它类似控件元素,安置在图表上的标准图形对象、以及基于它们的其它函数库对象(手动或编程),都会导致这些对象绘制在控件之上,这很不方便。 故此,我们需要开发一种机制来跟踪图表上的新图形对象,并将所有 GUI 元素移动到前景。 为了实现这一点,我们可以使用 ZOrder 图形对象属性(图形对象接收单击图表事件的优先级(CHARTEVENT_CLICK))。
创建对象时会设置默认的零值,但如有必要,可以增加优先级。 当应用一个对象覆盖另一个对象时,只有其中具有最高优先级的那个对象会将收到 CHARTEVENT_CLICK 事件。
但我将更广泛地使用此属性 — 此属性的值作为指示 GUI 元素相对于彼此、以及相对于其它图形对象的排列顺序。
在 \MQL5\Include\DoEasy\ 中,并在基于画布的图形对象整数型枚举里,加入新的属性,并增加整数型属性的数量,从 23 至 24:
//+------------------------------------------------------------------+ //| Integer properties of the graphical element on the canvas | //+------------------------------------------------------------------+ enum ENUM_CANV_ELEMENT_PROP_INTEGER { CANV_ELEMENT_PROP_ID = 0, // Element ID CANV_ELEMENT_PROP_TYPE, // Graphical element type CANV_ELEMENT_PROP_BELONG, // Graphical element affiliation CANV_ELEMENT_PROP_NUM, // Element index in the list CANV_ELEMENT_PROP_CHART_ID, // Chart ID CANV_ELEMENT_PROP_WND_NUM, // Chart subwindow index CANV_ELEMENT_PROP_COORD_X, // Form's X coordinate on the chart CANV_ELEMENT_PROP_COORD_Y, // Form's Y coordinate on the chart CANV_ELEMENT_PROP_WIDTH, // Element width CANV_ELEMENT_PROP_HEIGHT, // Element height CANV_ELEMENT_PROP_RIGHT, // Element right border CANV_ELEMENT_PROP_BOTTOM, // Element bottom border CANV_ELEMENT_PROP_ACT_SHIFT_LEFT, // Active area offset from the left edge of the element CANV_ELEMENT_PROP_ACT_SHIFT_TOP, // Active area offset from the upper edge of the element CANV_ELEMENT_PROP_ACT_SHIFT_RIGHT, // Active area offset from the right edge of the element CANV_ELEMENT_PROP_ACT_SHIFT_BOTTOM, // Active area offset from the bottom edge of the element CANV_ELEMENT_PROP_MOVABLE, // Element moveability flag CANV_ELEMENT_PROP_ACTIVE, // Element activity flag CANV_ELEMENT_PROP_INTERACTION, // Flag of interaction with the outside environment CANV_ELEMENT_PROP_COORD_ACT_X, // X coordinate of the element active area CANV_ELEMENT_PROP_COORD_ACT_Y, // Y coordinate of the element active area CANV_ELEMENT_PROP_ACT_RIGHT, // Right border of the element active area CANV_ELEMENT_PROP_ACT_BOTTOM, // Bottom border of the element active area CANV_ELEMENT_PROP_ZORDER, // Priority of a graphical object for receiving the event of clicking on a chart }; #define CANV_ELEMENT_PROP_INTEGER_TOTAL (24) // Total number of integer properties #define CANV_ELEMENT_PROP_INTEGER_SKIP (0) // Number of integer properties not used in sorting //+------------------------------------------------------------------+