last works on GUI ...
This commit is contained in:
@@ -134,14 +134,24 @@ class XCButton : XSCBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Object ZOrder ...
|
* Set Object ZOrder ...
|
||||||
*
|
*
|
||||||
* @param value: z order
|
* @param value: z order
|
||||||
*/
|
*/
|
||||||
void SetZOrder(int value)
|
void SetZOrder(int value)
|
||||||
{
|
{
|
||||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, 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 ...
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class XCEdit : XSCBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Object Border Color ...
|
* Set Object Border Color ...
|
||||||
*
|
*
|
||||||
* @param value: color
|
* @param value: color
|
||||||
*/
|
*/
|
||||||
void SetBorderColor(color value)
|
void SetBorderColor(color value)
|
||||||
@@ -154,14 +154,24 @@ class XCEdit : XSCBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Object ZOrder ...
|
* Set Object ZOrder ...
|
||||||
*
|
*
|
||||||
* @param value: z order
|
* @param value: z order
|
||||||
*/
|
*/
|
||||||
void SetZOrder(int value)
|
void SetZOrder(int value)
|
||||||
{
|
{
|
||||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, 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 ...
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -148,23 +148,34 @@ class XCLabel : XSCBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Object Anchor ...
|
* Set Object Anchor ...
|
||||||
*
|
*
|
||||||
* @param value: anchor
|
* @param value: anchor
|
||||||
*/
|
*/
|
||||||
void SetAnchor(ENUM_ANCHOR_POINT value) {
|
void SetAnchor(ENUM_ANCHOR_POINT value)
|
||||||
|
{
|
||||||
ObjectSetInteger(0, mName, OBJPROP_ANCHOR, value);
|
ObjectSetInteger(0, mName, OBJPROP_ANCHOR, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Object ZOrder ...
|
* Set Object ZOrder ...
|
||||||
*
|
*
|
||||||
* @param value: z order
|
* @param value: z order
|
||||||
*/
|
*/
|
||||||
void SetZOrder(int value)
|
void SetZOrder(int value)
|
||||||
{
|
{
|
||||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, 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 ...
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class XCPanel : XSCBase
|
|||||||
}
|
}
|
||||||
mBody.SetBorderType(bodyBorderType);
|
mBody.SetBorderType(bodyBorderType);
|
||||||
mBody.SetBGColor(bodyBGColor);
|
mBody.SetBGColor(bodyBGColor);
|
||||||
|
mBody.SetAsBackGround(true);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Caption ...
|
// Caption ...
|
||||||
|
|||||||
@@ -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
|
* Add a Name to Object
|
||||||
* @param name: name
|
* @param name: name
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ string mTag;
|
|||||||
XCPanel eaPanel;
|
XCPanel eaPanel;
|
||||||
XCButton eaStateBtn;
|
XCButton eaStateBtn;
|
||||||
string eaStateBtnName;
|
string eaStateBtnName;
|
||||||
|
XCButton eaLongStateBtn;
|
||||||
|
string eaLongStateBtnName;
|
||||||
|
XCButton eaShortStateBtn;
|
||||||
|
string eaShortStateBtnName;
|
||||||
bool eaEnableLongs = true;
|
bool eaEnableLongs = true;
|
||||||
bool eaEnableShorts = true;
|
bool eaEnableShorts = true;
|
||||||
|
|
||||||
@@ -25,60 +29,13 @@ bool eaEnableShorts = true;
|
|||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
int OnInit()
|
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";
|
mTag = "XPanel";
|
||||||
InitialPanel();
|
if (!InitialGUI()) {
|
||||||
ChartRedraw(0); // Redraws the chart
|
return INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
return (INIT_SUCCEEDED);
|
return (INIT_SUCCEEDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,17 +44,7 @@ int OnInit()
|
|||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
void OnDeinit(const int reason)
|
void OnDeinit(const int reason)
|
||||||
{
|
{
|
||||||
// Destroys all GUI objects
|
DestroyGUI();
|
||||||
// TitleBar.Destroy();
|
|
||||||
// MainDashboardBody.Destroy();
|
|
||||||
// TitleText.Destroy();
|
|
||||||
// LotSizeText.Destroy();
|
|
||||||
// LotSize.Destroy();
|
|
||||||
// BuyButton.Destroy();
|
|
||||||
// SellButton.Destroy();
|
|
||||||
|
|
||||||
//
|
|
||||||
eaPanel.Destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
@@ -105,31 +52,25 @@ void OnDeinit(const int reason)
|
|||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
|
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)
|
// Handle Object Movement ...
|
||||||
// {
|
eaPanel.OnEvent(id, lparam, dparam, sparam);
|
||||||
// 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);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
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;
|
bool result = false;
|
||||||
@@ -151,23 +92,111 @@ bool InitialPanel()
|
|||||||
//
|
//
|
||||||
// Create Activation Button ...
|
// Create Activation Button ...
|
||||||
string eaStatePrefix = mTag + "_State_";
|
string eaStatePrefix = mTag + "_State_";
|
||||||
eaStateBtnName = eaStatePrefix + "lbl";
|
|
||||||
|
//
|
||||||
|
// Signalling ...
|
||||||
|
eaStateBtnName = eaStatePrefix + "btn";
|
||||||
result = eaStateBtn.Create(
|
result = eaStateBtn.Create(
|
||||||
eaStateBtnName,
|
eaStateBtnName,
|
||||||
100,
|
100,
|
||||||
120,
|
120,
|
||||||
100,
|
300,
|
||||||
25 //
|
25 //
|
||||||
);
|
);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
eaStateBtn.SetZOrder(100);
|
|
||||||
|
|
||||||
//
|
|
||||||
eaPanel.Add(eaStateBtnName);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
Reference in New Issue
Block a user