Library of Visual functions

29 August 2016, 14:27
Sergiy Podolyak
0
65

This is an extract from production version of EAs "Ocean Breeze" and "Graalino-Pro".

This is a library of functions to show text lines on chart (with proper scaling).

It is PUBLIC DOMAIN (and free).

Example:

//_____________________________________________________________________________________
//                                                                                                                                      |
//              Post_Text_Block ()                                                              |
//_________________________________________________|
void Post_Text_Block
(
   string & Text_Array[][],
   color Text_Color_Param
)
{
        int Win;
        int Row, Column;
        int Array_Height;
        int Array_Width;
        int Font_Size;
        //....................................................................
#ifndef LITE_VERSION
        double Font_Size_Min = 6;
        double Font_Size_Max = 22;
        double Win_Size_Y_Min = 150;
        double Win_Size_Y_Max = 1200;
        double Font_Mult;
        double Font_Size_Scaled;
        double Window_Size_Y;
        double Win_Heights_Ratio;
        double Font_Sizes_Ratio;
        double Size_Factor;
        double Grow_Factor;
        int LTRB[4];
        int Rect_Handle;
        //....................................................................
        Rect_Handle = GetWindowRect (WindowHandle (Symbol (), Period () ), LTRB);
        if (Rect_Handle != 0)
        {
                //      Window_Size_X = LTRB[2] - LTRB[0];
                Window_Size_Y = LTRB[3] - LTRB[1];
        }
        else
        {
                //      Window_Size_X = 400.0;
                Window_Size_Y = 300.0;
        }
        //....................................................................
        Win_Heights_Ratio = Win_Size_Y_Max / Win_Size_Y_Min;
        Font_Sizes_Ratio = Font_Size_Max / Font_Size_Min;
        //....................................................................
        Size_Factor = MathMax (Window_Size_Y / Win_Size_Y_Min, 1.0);
        Grow_Factor = MathSqrt ( ( MathAbs (Win_Size_Y_Max - Window_Size_Y + Win_Size_Y_Min)
                                   / Win_Size_Y_Max ));
        Font_Mult = Size_Factor * Grow_Factor * (Font_Sizes_Ratio / Win_Heights_Ratio);
        Font_Size_Scaled = Font_Size_Min * Font_Mult;
        Font_Size_Scaled = MathMax (Font_Size_Scaled, Font_Size_Min);
        Font_Size = (int) MathMin (Font_Size_Scaled, Font_Size_Max);
#else
        Font_Size = 8;
#endif
        //..........................................................................
        Win = 0;
        Array_Height = ArrayRange (Text_Array, 0);
        Array_Width = ArrayRange (Text_Array, 1);
        for (Row = 0; Row < Array_Height; Row++)
        {
                for (Column = 0; Column < Array_Width; Column++)
                {
                        Create_Visual_From_Text_Block (Text_Array, Row, Column, Win, Font_Size, Text_Color_Param);
                }
        }
        WindowRedraw ();
        //..........................................................................
        return;
}
Files:
Share it with friends: