diff --git a/Classes/XCObjects/x-saherelm.x-button.class.mq5 b/Classes/XCObjects/x-saherelm.x-button.class.mq5 index 4fb47d9e..a573deda 100644 --- a/Classes/XCObjects/x-saherelm.x-button.class.mq5 +++ b/Classes/XCObjects/x-saherelm.x-button.class.mq5 @@ -134,14 +134,24 @@ class XCButton : XSCBase /** * Set Object ZOrder ... - * - * @param value: z order + * + * @param value: z order */ void SetZOrder(int value) { ObjectSetInteger(0, mName, OBJPROP_ZORDER, value); } + /** + * Set Object as Background ... + * + * @param value: boolean value + */ + void SetAsBackGround(bool value) + { + ObjectSetInteger(0, mName, OBJPROP_BACK, value); + } + // // Protected ... protected: diff --git a/Classes/XCObjects/x-saherelm.x-edit.class.mq5 b/Classes/XCObjects/x-saherelm.x-edit.class.mq5 index d04852e0..abfba4a7 100644 --- a/Classes/XCObjects/x-saherelm.x-edit.class.mq5 +++ b/Classes/XCObjects/x-saherelm.x-edit.class.mq5 @@ -104,7 +104,7 @@ class XCEdit : XSCBase /** * Set Object Border Color ... - * + * * @param value: color */ void SetBorderColor(color value) @@ -154,14 +154,24 @@ class XCEdit : XSCBase /** * Set Object ZOrder ... - * - * @param value: z order + * + * @param value: z order */ void SetZOrder(int value) { ObjectSetInteger(0, mName, OBJPROP_ZORDER, value); } + /** + * Set Object as Background ... + * + * @param value: boolean value + */ + void SetAsBackGround(bool value) + { + ObjectSetInteger(0, mName, OBJPROP_BACK, value); + } + // // Protected ... protected: diff --git a/Classes/XCObjects/x-saherelm.x-label.class.mq5 b/Classes/XCObjects/x-saherelm.x-label.class.mq5 index ea5b27b6..0ccc0bb4 100644 --- a/Classes/XCObjects/x-saherelm.x-label.class.mq5 +++ b/Classes/XCObjects/x-saherelm.x-label.class.mq5 @@ -148,23 +148,34 @@ class XCLabel : XSCBase /** * Set Object Anchor ... - * + * * @param value: anchor */ - void SetAnchor(ENUM_ANCHOR_POINT value) { + void SetAnchor(ENUM_ANCHOR_POINT value) + { ObjectSetInteger(0, mName, OBJPROP_ANCHOR, value); } /** * Set Object ZOrder ... - * - * @param value: z order + * + * @param value: z order */ void SetZOrder(int value) { ObjectSetInteger(0, mName, OBJPROP_ZORDER, value); } + /** + * Set Object as Background ... + * + * @param value: boolean value + */ + void SetAsBackGround(bool value) + { + ObjectSetInteger(0, mName, OBJPROP_BACK, value); + } + // // Protected ... protected: diff --git a/Classes/XCObjects/x-saherelm.x-panel.class.mq5 b/Classes/XCObjects/x-saherelm.x-panel.class.mq5 index ea5a1787..4f0198b6 100644 --- a/Classes/XCObjects/x-saherelm.x-panel.class.mq5 +++ b/Classes/XCObjects/x-saherelm.x-panel.class.mq5 @@ -152,6 +152,7 @@ class XCPanel : XSCBase } mBody.SetBorderType(bodyBorderType); mBody.SetBGColor(bodyBGColor); + mBody.SetAsBackGround(true); // // Caption ... diff --git a/Classes/XCObjects/x-saherelm.x-rectangle.label.class.mq5 b/Classes/XCObjects/x-saherelm.x-rectangle.label.class.mq5 index c7b2351f..e115ef31 100644 --- a/Classes/XCObjects/x-saherelm.x-rectangle.label.class.mq5 +++ b/Classes/XCObjects/x-saherelm.x-rectangle.label.class.mq5 @@ -220,6 +220,26 @@ class XCRectangleLabel : XSCBase ); } + /** + * Set Object ZOrder ... + * + * @param value: z order + */ + void SetZOrder(int value) + { + ObjectSetInteger(0, mName, OBJPROP_ZORDER, value); + } + + /** + * Set Object as Background ... + * + * @param value: boolean value + */ + void SetAsBackGround(bool value) + { + ObjectSetInteger(0, mName, OBJPROP_BACK, value); + } + /** * Add a Name to Object * @param name: name diff --git a/Experts/x-saherelm.test-panel.ea.mq5 b/Experts/x-saherelm.test-panel.ea.mq5 index e45d3039..374c090e 100644 --- a/Experts/x-saherelm.test-panel.ea.mq5 +++ b/Experts/x-saherelm.test-panel.ea.mq5 @@ -17,6 +17,10 @@ string mTag; XCPanel eaPanel; XCButton eaStateBtn; string eaStateBtnName; +XCButton eaLongStateBtn; +string eaLongStateBtnName; +XCButton eaShortStateBtn; +string eaShortStateBtnName; bool eaEnableLongs = true; bool eaEnableShorts = true; @@ -25,60 +29,13 @@ bool eaEnableShorts = true; //+------------------------------------------------------------------+ int OnInit() { - // - // panel.Create("XPanel", 100, 100, 300, 200); - - // - // Enables mouse move events on the chart - // ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true); - - // Initialize and set properties for Title bar, main dashboard, and all other elements - // TitleBar.Create("TitleBar", 100, 100, 200, 20); - // TitleBar.SetBorderType(BORDER_FLAT); - // TitleBar.SetBGColor(C'27, 59, 146'); - - // MainDashboardBody.Create("MainDashboardBody", 100, 119, 200, 100); - // MainDashboardBody.SetBorderType(BORDER_FLAT); - // MainDashboardBody.SetBGColor(C'102, 152, 250'); - - // TitleText.Create("TitleText", 110, 101); - // TitleText.SetText("Simple Trading EA V1.0"); - // TitleText.SetFontSize(10); - // TitleText.SetTextColor(clrWhite); - - // LotSizeText.Create("LotSizeText", 110, 140); - // LotSizeText.SetText("Lot Size:"); - // LotSizeText.SetFontSize(12); - // LotSizeText.SetTextColor(clrWhite); - - // LotSize.Create("LotSize", 220, 140, 50, 20); - // LotSize.SetBorderColor(clrBlack); - // LotSize.SetBGColor(clrWhiteSmoke); - // LotSize.SetText("0.01"); - // LotSize.SetTextColor(clrBlack); - - // BuyButton.Create("BuyButton", 110, 180, 80, 25); - // BuyButton.SetBorderColor(clrBlack); - // BuyButton.SetText("Buy"); - // BuyButton.SetBGColor(clrLime); - - // SellButton.Create("SellButton", 210, 180, 80, 25); - // SellButton.SetBorderColor(clrBlack); - // SellButton.SetText("Sell"); - // SellButton.SetBGColor(clrRed); - - // Add the other elements to the Central Element i.e. TitleBar object in this case - // TitleBar.Add("MainDashboardBody"); - // TitleBar.Add("TitleText"); - // TitleBar.Add("LotSizeText"); - // TitleBar.Add("LotSize"); - // TitleBar.Add("BuyButton"); - // TitleBar.Add("SellButton"); - // mTag = "XPanel"; - InitialPanel(); - ChartRedraw(0); // Redraws the chart + if (!InitialGUI()) { + return INIT_FAILED; + } + + // return (INIT_SUCCEEDED); } @@ -87,17 +44,7 @@ int OnInit() //+------------------------------------------------------------------+ void OnDeinit(const int reason) { - // Destroys all GUI objects - // TitleBar.Destroy(); - // MainDashboardBody.Destroy(); - // TitleText.Destroy(); - // LotSizeText.Destroy(); - // LotSize.Destroy(); - // BuyButton.Destroy(); - // SellButton.Destroy(); - - // - eaPanel.Destroy(); + DestroyGUI(); } //+------------------------------------------------------------------+ @@ -105,31 +52,25 @@ void OnDeinit(const int reason) //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { - // Handles click events for Buy and Sell buttons and opens corresponding positions - // if (id == CHARTEVENT_OBJECT_CLICK) - // { - // double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); - // double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID); - // if (sparam == "BuyButton") - // { - // trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, (double)LotSize.GetText(), ask, 0, 0); - // } - // if (sparam == "SellButton") - // { - // trade.PositionOpen(_Symbol, ORDER_TYPE_SELL, (double)LotSize.GetText(), bid, 0, 0); - // } - // } - - // // Passes events to the TitleBar object - // TitleBar.OnEvent(id, lparam, dparam, sparam); + // + // Handle Object Movement ... + eaPanel.OnEvent(id, lparam, dparam, sparam); // - eaPanel.OnEvent(id, lparam, dparam, sparam); + // Handle OnClick Event ... + if (id == CHARTEVENT_OBJECT_CLICK) + { + HandleOnClickEvent(sparam); + } } //+------------------------------------------------------------------+ -// -bool InitialPanel() +/** + * Initial GUI ... + * + * @return ( bool ) + */ +bool InitialGUI() { // bool result = false; @@ -151,23 +92,111 @@ bool InitialPanel() // // Create Activation Button ... string eaStatePrefix = mTag + "_State_"; - eaStateBtnName = eaStatePrefix + "lbl"; + + // + // Signalling ... + eaStateBtnName = eaStatePrefix + "btn"; result = eaStateBtn.Create( eaStateBtnName, 100, 120, - 100, + 300, 25 // ); if (!result) { return result; } - eaStateBtn.SetZOrder(100); - - // eaPanel.Add(eaStateBtnName); + // + // Long Signalling ... + eaLongStateBtnName = eaStatePrefix + "_Long_btn"; + result = eaLongStateBtn.Create( + eaLongStateBtnName, + 100, + 145, + 150, + 25 // + ); + if (!result) + { + return result; + } + eaPanel.Add(eaLongStateBtnName); + + // + // Short Signalling ... + eaShortStateBtnName = eaStatePrefix + "_Short_btn"; + result = eaShortStateBtn.Create( + eaShortStateBtnName, + 250, + 145, + 150, + 25 // + ); + if (!result) + { + return result; + } + eaPanel.Add(eaShortStateBtnName); + + // + ChartRedraw(0); + // return result; -} \ No newline at end of file +} + +/** + * Destroy GUI ... + */ +void DestroyGUI() +{ + // + eaStateBtnName = NULL; + eaLongStateBtnName = NULL; + eaShortStateBtnName = NULL; + + // + eaPanel.Destroy(); + eaStateBtn.Destroy(); + eaLongStateBtn.Destroy(); + eaShortStateBtn.Destroy(); +} + +/** + * Handle Object's Click Events ... + * + * @param name: Clicked Object Name + */ +void HandleOnClickEvent(string name) +{ + // + if (!IsValid(name)) + { + return; + } + + // + // State Button ... + if (name == eaStateBtnName) + { + // + Print("State Button Clicked ..."); + } + // + else if (name == eaLongStateBtnName) + { + // + Print("Long State Button Clicked ..."); + } + // + else if (name == eaShortStateBtnName) + { + // + Print("Short State Button Clicked ..."); + } +} + +// \ No newline at end of file