量化軟件下載:赫茲股票期貨量化之改進(jìn)擴展標(biāo)準(zhǔn)圖形對象的處理
進(jìn)庫類
如果圖表里因創(chuàng)建 GUI 元素而包含任何附于畫布上的圖形對象 — 元素、形狀、窗口(尚未實現(xiàn))或其它類似控件元素,安置在圖表上的標(biāo)準(zhǔn)圖形對象、以及基于它們的其它函數(shù)庫對象(手動或編程),都會導(dǎo)致這些對象繪制在控件之上,這很不方便。 故此,我們需要開發(fā)一種機制來跟蹤圖表上的新圖形對象,并將所有 GUI 元素移動到前景。 為了實現(xiàn)這一點,我們可以使用 ZOrder 圖形對象屬性(圖形對象接收單擊圖表事件的優(yōu)先級(CHARTEVENT_CLICK))。
創(chuàng)建對象時會設(shè)置默認(rèn)的零值,但如有必要,可以增加優(yōu)先級。 當(dāng)應(yīng)用一個對象覆蓋另一個對象時,只有其中具有最高優(yōu)先級的那個對象會將收到 CHARTEVENT_CLICK 事件。
但我將更廣泛地使用此屬性 — 此屬性的值作為指示 GUI 元素相對于彼此、以及相對于其它圖形對象的排列順序。
在 \MQL5\Include\DoEasy\ 中,并在基于畫布的圖形對象整數(shù)型枚舉里,加入新的屬性,并增加整數(shù)型屬性的數(shù)量,從 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 //+------------------------------------------------------------------+