last works on GUI Panel Developing ...

This commit is contained in:
2024-09-24 18:02:10 +03:30
parent a36e78254d
commit 2cca497b62
6 changed files with 242 additions and 9 deletions
@@ -132,6 +132,16 @@ class XCButton : XSCBase
ObjectSetString(0, mName, OBJPROP_TEXT, value);
}
/**
* Set Object ZOrder ...
*
* @param value: z order
*/
void SetZOrder(int value)
{
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
}
//
// Protected ...
protected:
@@ -152,6 +152,16 @@ class XCEdit : XSCBase
return ObjectGetString(0, mName, OBJPROP_TEXT);
}
/**
* Set Object ZOrder ...
*
* @param value: z order
*/
void SetZOrder(int value)
{
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
}
//
// Protected ...
protected:
@@ -146,6 +146,25 @@ class XCLabel : XSCBase
ObjectSetString(0, mName, OBJPROP_FONT, value);
}
/**
* Set Object Anchor ...
*
* @param value: anchor
*/
void SetAnchor(ENUM_ANCHOR_POINT value) {
ObjectSetInteger(0, mName, OBJPROP_ANCHOR, value);
}
/**
* Set Object ZOrder ...
*
* @param value: z order
*/
void SetZOrder(int value)
{
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
}
//
// Protected ...
protected:
+35 -3
View File
@@ -52,7 +52,25 @@ class XCPanel : XSCBase
//
// Action ...
//
/**
* Create an instance of Panel Object ...
*
* @param name: Object name
* @param xDis: X Distance
* @param yDis: Y Distance
* @param xSize: X Size
* @param ySize: Y Size
* @param titleBarBorderType: Border Type of Panel TitleBar
* @param titleBarBGColor: Background Color of Panel TitleBar
* @param caption: Caption Text of Panel TitleBar
* @param captionontSize: Font Size of Panel Caption
* @param captionColor: Text Color of Panel Caption
* @param captionAnchor: Anchor Point of Panel Caption
* @param bodyBorderType: Border Type of Panel Body
* @param bodyBGColor: Background Color of Panel Body
*
* @return ( bool )
*/
bool Create(
string name,
int xDis,
@@ -68,6 +86,7 @@ class XCPanel : XSCBase
string caption = "",
int captionontSize = 9,
color captionColor = clrWhite,
ENUM_ANCHOR_POINT captionAnchor = ANCHOR_LEFT_UPPER,
//
// Body ...
ENUM_BORDER_TYPE bodyBorderType = BORDER_FLAT,
@@ -99,7 +118,7 @@ class XCPanel : XSCBase
//
// Title Bar ...
int titleBarHeight = ySize / 5;
int titleBarHeight = 20;
result = mTitleBar.Create(
mTitleBarName,
xDis,
@@ -144,6 +163,7 @@ class XCPanel : XSCBase
return result;
}
mTitleText.SetText(caption);
mTitleText.SetAnchor(captionAnchor);
mTitleText.SetTextColor(captionColor);
mTitleText.SetFontSize(captionontSize);
@@ -156,7 +176,9 @@ class XCPanel : XSCBase
return result;
}
//
/**
* Destroy Panel Object and all of it's Child
*/
void Destroy()
{
//
@@ -193,6 +215,16 @@ class XCPanel : XSCBase
);
}
/**
* Add Specific Child Object ...
*
* @param name: object name
*/
void Add(string name)
{
mTitleBar.Add(name);
}
//
protected:
private:
+58 -3
View File
@@ -13,7 +13,12 @@
CTrade trade;
//
XCPanel panel;
string mTag;
XCPanel eaPanel;
XCButton eaStateBtn;
string eaStateBtnName;
bool eaEnableLongs = true;
bool eaEnableShorts = true;
//+------------------------------------------------------------------+
//| Expert initialization function |
@@ -21,7 +26,7 @@ XCPanel panel;
int OnInit()
{
//
panel.Create("XPanel", 100, 100, 200, 100);
// panel.Create("XPanel", 100, 100, 300, 200);
//
// Enables mouse move events on the chart
@@ -70,6 +75,9 @@ int OnInit()
// TitleBar.Add("BuyButton");
// TitleBar.Add("SellButton");
//
mTag = "XPanel";
InitialPanel();
ChartRedraw(0); // Redraws the chart
return (INIT_SUCCEEDED);
}
@@ -87,6 +95,9 @@ void OnDeinit(const int reason)
// LotSize.Destroy();
// BuyButton.Destroy();
// SellButton.Destroy();
//
eaPanel.Destroy();
}
//+------------------------------------------------------------------+
@@ -113,6 +124,50 @@ void OnChartEvent(const int id, const long &lparam, const double &dparam, const
// TitleBar.OnEvent(id, lparam, dparam, sparam);
//
panel.OnEvent(id, lparam, dparam, sparam);
eaPanel.OnEvent(id, lparam, dparam, sparam);
}
//+------------------------------------------------------------------+
//
bool InitialPanel()
{
//
bool result = false;
//
// Create a Panel ...
result = eaPanel.Create(
mTag,
100,
100,
300,
200 //
);
if (!result)
{
return result;
}
//
// Create Activation Button ...
string eaStatePrefix = mTag + "_State_";
eaStateBtnName = eaStatePrefix + "lbl";
result = eaStateBtn.Create(
eaStateBtnName,
100,
120,
100,
25 //
);
if (!result)
{
return result;
}
eaStateBtn.SetZOrder(100);
//
eaPanel.Add(eaStateBtnName);
//
return result;
}
+107
View File
@@ -36,6 +36,9 @@
#include "../Parsers/x-saherelm.xch.che.parser.mq5"
#include "../Strategies/x-saherelm.xch.che.strategy.mq5"
//
#include "../Classes/XCObjects/x-saherelm.x-panel.class.mq5"
//
// Inputs ...
@@ -190,6 +193,14 @@ XTimeTracker eaTimeTracker;
// Trade Handler Instance Class ...
X121SCTradeHandler *eaTradeHandler;
//
// Panel of EA ...
XCPanel eaPanel;
XCButton eaStateButton;
string eaStateButtonTitle;
bool eaEnableLongs = true;
bool eaEnableShorts = true;
//
string mTag = "";
@@ -230,6 +241,13 @@ int OnInit()
// EventSetTimer(1);
// EventSetMillisecondTimer(100);
//
// Create Panel for EA Data ...
if (!InitialPanel())
{
return INIT_FAILED;
}
//
// Alert Initialization ...
string msg = "Initialized Successfully ...";
@@ -271,6 +289,9 @@ void OnDeinit(const int reason)
delete eaTrader;
delete eaTradeHandler;
//
eaPanel.Destroy();
//
Clean(strategies);
}
@@ -282,6 +303,7 @@ void OnTick()
//
HandleTradeState();
HandleTimeReport();
HandlePanelUpdate();
HandleStrategiesOnTick();
}
@@ -302,6 +324,24 @@ void OnTimer()
// HandleStrategiesOnTick();
}
//
// Chart Event Handler ...
void OnChartEvent(
const int id,
const long &lparam,
const double &dparam,
const string &sparam //
)
{
//
eaPanel.OnEvent(
id,
lparam,
dparam,
sparam //
);
}
//
// Custom Functions ...
@@ -418,6 +458,42 @@ bool ValidateInputs()
return result;
}
//
bool InitialPanel()
{
//
bool result = false;
//
// Create a Panel ...
result = eaPanel.Create(
mTag,
100,
100,
300,
200 //
);
if (!result)
{
return result;
}
//
// Create Activation Button ...
string eaStatePrefix = mTag + "_State_";
eaStateButtonTitle = eaStatePrefix + "lbl";
result = eaStateButton.Create(
eaStateButtonTitle,
100,
120,
100,
25 //
);
//
return result;
}
//
// Initialize all Requirements ...
bool InitialEA()
@@ -885,6 +961,19 @@ void HandleTimeReport()
}
}
//
// Update Panel ...
void HandlePanelUpdate()
{
//
// Prepare State ...
bool isEnable = eaEnableLongs ||
eaEnableShorts;
//
string stateStr = isEnable ? "Active" : "Inactive";
}
//
// SIGNAL EVENT Handlers ...
//
@@ -912,6 +1001,9 @@ void OnSignalRecieved(
return;
}
//
bool isLong = IsLong(signal.type);
//
// Notify When a Raw (Unfiltered) Signal Recieved
// if it's Provided ...
@@ -949,6 +1041,21 @@ void OnSignalRecieved(
//
eaTradeHandler.UpdateSignal(signal);
}
else
{
signal.volume = eaVolume;
}
//
// Chekc Signalling Enable or not ...
bool canContinue =
isLong
? eaEnableLongs
: eaEnableShorts;
if (!canContinue)
{
return;
}
//
// Since Signal Filtering done based on