//+------------------------------------------------------------------+//| Creating a canvas for drawing an element |//+------------------------------------------------------------------+bool CElement::CreateCanvas(conststring name,constint x,constint y,
constint x_size,constint y_size,ENUM_COLOR_FORMAT clr_format=COLOR_FORMAT_ARGB_NORMALIZE)
{
//--- Size adjustmentint xsize =(x_size<1)? 50 : x_size;
int ysize =(y_size<1)? 20 : y_size;
//--- Reset last error
::ResetLastError();
//--- Creating an objectif(!m_canvas.CreateBitmapLabel(m_chart_id,m_subwin,name,x,y,xsize,ysize,clr_format))
{
::Print(__FUNCTION__," > Failed to create a canvas to draw the item (""+m_class_name+"): ",::GetLastError());
return(false);
}
//--- Reset last error
::ResetLastError();
//--- Get a pointer to the base classif(!m_canvas.Attach(m_chart_id,name,clr_format))
{
::Print(__FUNCTION__," > Failed to attach a drawing canvas to the chart: ",::GetLastError());
return(false);
}
//--- Properties
::ObjectSetString(m_chart_id,m_canvas.ChartObjectName(),OBJPROP_TOOLTIP,"\n");
::ObjectSetInteger(m_chart_id,m_canvas.ChartObjectName(),OBJPROP_CORNER,m_corner);
::ObjectSetInteger(m_chart_id,m_canvas.ChartObjectName(),OBJPROP_SELECTABLE,false);
//--- All elements except the form have a higher priority than the main element
Z_Order((dynamic_cast<CWindow*>(&this)!=NULL)? 0 : m_main.Z_Order()+1);
//--- Coordinates
m_canvas.X(x);
m_canvas.Y(y);
//--- Dimensions
m_canvas.XSize(x_size);
m_canvas.YSize(y_size);
//--- Indents from the end point
m_canvas.XGap(CalculateXGap(x));
m_canvas.YGap(CalculateYGap(y));
return(true);
}
CreateBitmapLabel - create a graphic resource
Attach - read the same resource and write to the same resource again.
class CMouse
{
...............
//--- (1) Returns the number of the window where the cursor is located, (2) the time corresponding to the X coordinate, // (3) level (price) corresponding to the Y coordinateint SubWindowNumber(void) const { return(m_subwin); }
datetimeTime(void) const { return(m_time); }
double Level(void) const { return(m_level); }
Is Time and Level even used anywhere? Couldn't find it anywhere...
What is SubWindowNumber used for?
My point is that ChartXYToTimePrice is quite a costly operation to perform on every mouse movement...
There is the code of the CCanvas::Attach() method:
Yes, and above CreateBitmapLabel. I've been looking at them. And as far as I understood, CreateBitmapLabel creates an empty resource, and Attach reads the resource (any) and writes it to m_pixels. And as I wrote above, we create a resource (CreateBitmapLabel) with the name name, then read the same resource (Attach) and again write the read into the same m_pixels
Or do I understand something wrong?
PS Experimentally without Attach everything works :)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello.
CreateBitmapLabel - create a graphic resource
Attach - read the same resource and write to the same resource again.
Or do I understand something wrong?
Hello again :)
Is Time and Level even used anywhere? Couldn't find it anywhere...
What is SubWindowNumber used for?
My point is that ChartXYToTimePrice is quite a costly operation to perform on every mouse movement...
It's all in the comments. There's nothing to add.
It's all in the comments. There is nothing to add.
If you mean comments in the code, everything is clear there, but that's not what the questions are about :)
...
My point is that ChartXYToTimePrice is quite a costly operation to perform on every mouse movement...
To get the relative coordinate if the GUI is not in the main window.
To get relative coordinate when GUI is not in main window.
I'm more interested in why Attach? As far as I understand, it repeats the actions of CreateBitmapLabel
So maybe only calculate when the GUI is not in the main window? :)
There are also variants when the main GUI window is in the subwindow of the chart, and the dialogues are in the main window.
I'm more interested in why Attach? As far as I understand, it repeats the actions of CreateBitmapLabel
There is a code of CCanvas::Attach() method:
There is the code of the CCanvas::Attach() method:
Yes, and above CreateBitmapLabel. I've been looking at them. And as far as I understood, CreateBitmapLabel creates an empty resource, and Attach reads the resource (any) and writes it to m_pixels. And as I wrote above, we create a resource (CreateBitmapLabel) with the name name, then read the same resource (Attach) and again write the read into the same m_pixels
Or do I understand something wrong?
PS Experimentally without Attach everything works :)
...
PS Experimentally without Attach everything works :)
Really? So there's been some changes again. Something didn't work before for sure.
And after deleting GUI from the chart objects are deleted?
Really? So there's been another change. Something definitely wasn't working before.
And after removing the GUI from the graph, are the objects deleted?
Everything seems to be clean :)