Last Works ...
This commit is contained in:
@@ -0,0 +1,274 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCPanel
|
||||
// Description: provides all based classes for use ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
|
||||
//
|
||||
#include <Controls/Dialog.mqh>
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Extentions ...
|
||||
|
||||
/**
|
||||
* Check a Qery Contains in a Content or not ...
|
||||
*
|
||||
* @param mQuery: String ...
|
||||
* @param mContent: String ...
|
||||
* @param ignoreCase: Boolean ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool XContains(
|
||||
string mQuery, // Search String
|
||||
string mContent, // Search Content
|
||||
bool ignoreCase = true // Ignore Case
|
||||
)
|
||||
{
|
||||
return Contains(
|
||||
mQuery,
|
||||
mContent,
|
||||
ignoreCase //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
// a Base App Dialog Class ...
|
||||
class XCAppDialog : public CAppDialog
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Action ...
|
||||
|
||||
//
|
||||
// Virual ...
|
||||
|
||||
/**
|
||||
* Override Close Button Click Action ...
|
||||
*/
|
||||
void OnClickButtonClose()
|
||||
{
|
||||
//
|
||||
bool isClosed = ConfirmDialog("Close EA ?");
|
||||
|
||||
//
|
||||
if (isClosed)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Configuration Actions ...
|
||||
|
||||
/**
|
||||
* Show or Hide Minimize Button ...
|
||||
*
|
||||
* @param show: boolean
|
||||
*/
|
||||
void MinimizeButton(bool show)
|
||||
{
|
||||
//
|
||||
int controlIDX = ControlFind("MinMax");
|
||||
if (!IsValidIndex(controlIDX))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if (show)
|
||||
{
|
||||
Control(controlIDX).Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Control(controlIDX).Hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or Hide Close Button ...
|
||||
*
|
||||
* @param show: boolean
|
||||
*/
|
||||
void CloseButton(bool show)
|
||||
{
|
||||
//
|
||||
int controlIDX = ControlFind("Close");
|
||||
if (!IsValidIndex(controlIDX))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if (show)
|
||||
{
|
||||
Control(controlIDX).Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Control(controlIDX).Hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimize Functionality Implementation ...
|
||||
*/
|
||||
void Minimize()
|
||||
{
|
||||
//
|
||||
m_minimized = true;
|
||||
Rebound(m_min_rect);
|
||||
ClientAreaVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Background Color ...
|
||||
*
|
||||
* @param clr: Color ...
|
||||
*/
|
||||
void BackgroundColor(color clr)
|
||||
{
|
||||
//
|
||||
int controlIDX = ControlFind("Client");
|
||||
if (!IsValidIndex(controlIDX))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
CWnd *obj = Control(controlIDX);
|
||||
CWndClient *wndclient = (CWndClient *)obj;
|
||||
|
||||
//
|
||||
wndclient.ColorBackground(clr);
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
|
||||
/**
|
||||
* Find Specific Control in Dialog ...
|
||||
*
|
||||
* @param name: String to Search
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int ControlFind(string name)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!IsValid(name))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ControlsTotal();
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
string iName = Control(i).Name();
|
||||
|
||||
//
|
||||
bool isContains = XContains(
|
||||
name,
|
||||
iName,
|
||||
true // Ignore Case ...
|
||||
);
|
||||
if (isContains)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and Run Confirm Dialog ...
|
||||
*
|
||||
* @param message: message for Message Box ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ConfirmDialog(string message = NULL)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (!IsValid(message)) {
|
||||
message = "Confirm ?";
|
||||
}
|
||||
|
||||
//
|
||||
int dialogResult = MessageBox(message, NULL, MB_YESNO);
|
||||
|
||||
//
|
||||
// use 'switch' or 'if' as needed
|
||||
switch (dialogResult)
|
||||
{
|
||||
//
|
||||
// Yes ...
|
||||
case IDYES:
|
||||
result = true;
|
||||
break;
|
||||
//
|
||||
// No ...
|
||||
case IDNO:
|
||||
result = false;
|
||||
break;
|
||||
//
|
||||
// Cancel ...
|
||||
case IDCANCEL:
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
|
||||
//
|
||||
};
|
||||
Reference in New Issue
Block a user