Is it possible to output text on multiple lines in an OBJ_TEXT object?

 

Hello all!

Is it possible to output text on multiple lines in an OBJ_TEXT object? If not, why not implement this feature, question to the developers?

 
Farkhat Guzairov:

Hello all!

Is it possible to output text on multiple lines in an OBJ_TEXT object? If not, why not implement this feature, question to the developers?

As far as I remember, you can't, only through a loop.

 
Evgeny Belyaev:

As far as I remember, you can't, only through a cycle.

About the loop, that's exactly what I'd like to avoid. Why couldn't this be done from the beginning, for example in Comment it works.

 
Farkhat Guzairov:

Hello all!

Is it possible to output text in multiple lines in an OBJ_TEXT object? If not, why not implement this feature, question for developers?

It's easier to use Kanvas with my iCanvas class:

#include <Canvas\iCanvas.mqh> //https://www.mql5.com/ru/code/22164

void OnStart()
  {
    // Значения по умолчанию:
    // "Courier New"                   - начальный шрифт с размером 18 
    // Canvas.TextPosX=20;             - начальная координата X
    // Canvas.TextPosY=100;            - начальная координата Y
    // Canvas.TextColor=clrDarkOrchid; - цвет текста с прозрачностью 1.0 (полностью непрозрачный)
    // Canvas.StepTextLine = 20;       - шаг между строками
    
    Canvas.Comm("В синем небе звезды блещут,");
    Canvas.Comm("В синем море волны хлещут;");
    Canvas.Comm("Туча по небу идет,");
    Canvas.Comm("Бочка по морю плывет.");
    
    Canvas.TextPosition(100,500);                       // Позиция X и Y. Если целое число то значение в пикселях. Если double, то в процентах от ширины и высоты
    Canvas.CurentFont("Arial",25,30,clrRed,0.7);        // 25 - размер, 30 - расстояние между строками, 0.7 - прозрачность
    Canvas.Comm("Словно горькая вдовица,");
    Canvas.Comm("Плачет, бьется в ней царица;");
    Canvas.Comm("И растет ребенок там");
    Canvas.Comm("Не по дням, а по часам.");
    
    Canvas.TextPosition(50.0,20.0);                     // Позиция X и Y в процентах от ширины и высоты (тип dounle)
    Canvas.CurentFont("Times New Roman",40,30,clrBlue); // 40 - размер, 30 - расстояние между строками, прозрачность - 1.0 (по умолчанию
    Canvas.Comm("День прошел, царица вопит...");
    Canvas.Comm("А дитя волну торопит:");
    Canvas.Comm("«Ты, волна моя, волна!");
    Canvas.Comm("Ты гульлива и вольна;");
    Canvas.TextPosY+=20;                                // увеличиваем Y координату на 20 пикселей
    Canvas.Comm("Плещешь ты, куда захочешь,");
    Canvas.TextPosX+=20;                                // увеличиваем X координату на 20 пикселей
    Canvas.Comm("Ты морские камни точишь,");
    Canvas.TextPosX+=20;                                // увеличиваем X координату на 20 пикселей
    Canvas.Comm("Топишь берег ты земли,");
    Canvas.TextPosX+=20;                                // увеличиваем X координату на 20 пикселей
    Canvas.Comm("Подымаешь корабли —");
    Canvas.StepTextLine+=30;                            // увеличиваем шаг между строками на 30 пикселей
    Canvas.Comm("Не губи ты нашу душу:");
    Canvas.Comm("Выплесни ты нас на сушу!»");
    Canvas.Update();
    Sleep(20000);  
  }


To display such a thing using objects, the code would be much bigger.

 
Nikolai Semko:

it's easier to use Kanvas with my iCanvas class:



To display this kind of thing using objects, the code would be much larger.

Is it possible to attach a filler to the back of it? So that the chart doesn't get in the way?
 
Leon:
Can a filler be attached to that at the back? So that the graphic doesn't get in the way?

In the beginning, you just need to fill the background with the right colour and transparency:

Canvas.Erase(ColorToARGB(clrGreen,150)); // где 150- прозрачность, меняющаяся от 0 до 255.  0 - абсолютная прозрачность. 255-абсолютная непрозрачность
 
Nikolai Semko:

In the beginning you just need to fill the background with the right colour and transparency:

Thanks for the solution. But what about scaling? For example, if I start widening or narrowing the chart by price, will the text overlap each other?

Or will this text be like a label?

 
It would have been ideal to have a text object with \n support, then the problem of text when scaling the graph would not have been so severe.
 
Farkhat Guzairov:

Thanks for the solution. But what about scaling? For example, if I widen or narrow the chart by price, will the text overlap each other?

Or will this text be like a label?

For this purpose, you need to save the coordinates of text start not in pixels, but in price and time. And every time the CHARTEVENT_CHART_CHANGE event should be redrawn using functions of iCanvas class:

double Y(double Price);
double X(datetime Time);
 
Nikolai Semko:

In the beginning you just need to fill the background with the right colour and transparency:

Thank you so much! I'll give it a try one of these days.

 
Nikolai Semko:

To do this, you need to save the coordinates of the beginning of the text not in pixels, but in price and time. And each time, redraw them at the CHARTEVENT_CHART_CHANGE event, using functions of iCanvas class:

Well that would be the same as with a normal text object. Anyway, I will use your solution for other purposes, thanks!

Reason: