Discussion of article "Graphical interfaces X: New features for the Rendered table (build 9)" - page 2

 
Artyom Trishkin:
Yes, it works for me too, but with old library.

Do it with new Build6,7,8 or 9 please.
 
Anatoli Kazharski:
Use MetaTrader 5. The MetaTrader 4 version is no longer supported and I cannot advise you on anything.
Thank yo for your answer. (n.b. I asked if it works with new build)

Is below OK?
//+------------------------------------------------------------------+
//| Создаёт общую площадь                                            |
//+------------------------------------------------------------------+
bool CColorPicker::CreateArea(void)
  {
//--- Формирование имени объекта
   string name=CElementBase::ProgramName()+"_color_picker_bg_"+(string)CElementBase::Id();
//--- Координаты
   int x=CElementBase::X();
   int y=CElementBase::Y();
//--- Создать объект
   if(!m_area.Create(m_chart_id,name,m_subwin,x,y,m_x_size,m_y_size))
      return(false);
//--- Свойства
   m_area.BackColor(m_area_color);
   m_area.Color(m_area_border_color);
   m_area.BorderType(BORDER_FLAT);
   m_area.Corner(m_corner);
   m_area.Selectable(false);
   m_area.Z_Order(m_area_zorder);
   m_area.Tooltip("\n");
//--- Координаты
   m_canvas.X(x);
   m_canvas.Y(y);
//--- Размеры
   m_canvas.XSize(m_x_size);
   m_canvas.YSize(m_y_size);

//--- Отступы от крайней точки
   m_area.XGap(CElement::CalculateXGap(x));
   m_area.YGap(CElement::CalculateYGap(y));
//--- Сохраним указатель объекта
   CElementBase::AddToArray(m_area);
   return(true);
  }


 
stt:
Thank yo for your answer. (n.b. I asked if it works with new build)

Is below OK?
//+------------------------------------------------------------------+
//| Создаёт общую площадь                                            |
//+------------------------------------------------------------------+
bool CColorPicker::CreateArea(void)
  {
//--- Формирование имени объекта
   string name=CElementBase::ProgramName()+"_color_picker_bg_"+(string)CElementBase::Id();
//--- Координаты
   int x=CElementBase::X();
   int y=CElementBase::Y();
//--- Создать объект
   if(!m_area.Create(m_chart_id,name,m_subwin,x,y,m_x_size,m_y_size))
      return(false);
//--- Свойства
   m_area.BackColor(m_area_color);
   m_area.Color(m_area_border_color);
   m_area.BorderType(BORDER_FLAT);
   m_area.Corner(m_corner);
   m_area.Selectable(false);
   m_area.Z_Order(m_area_zorder);
   m_area.Tooltip("\n");
//--- Координаты
   m_canvas.X(x);
   m_canvas.Y(y);
//--- Размеры
   m_canvas.XSize(m_x_size);
   m_canvas.YSize(m_y_size);

//--- Отступы от крайней точки
   m_area.XGap(CElement::CalculateXGap(x));
   m_area.YGap(CElement::CalculateYGap(y));
//--- Сохраним указатель объекта
   CElementBase::AddToArray(m_area);
   return(true);
  }


The latest versions of the library, object coordinate calculation was different. You need to either use the new rules specify coordinates of the object, or in their own methods to recalculate the coordinates in the usual you.

For example you need:

In WndEvents.mqh in public area create a new method:
   //--- Creates a colour palette for colour selection
   bool              CreateColorPicker(CColorPicker &color_picker, CWindow &wnd_pointer, int wnd_index,int x,int y);
Outside the body of the class, you create a method body:
//+------------------------------------------------------------------+
//|| Creates a colour palette for selecting a colour ||
//+------------------------------------------------------------------+
bool CWndEvents::CreateColorPicker(CColorPicker &color_picker, CWindow &wnd_pointer, int wnd_index, int x, int y)
  {
//--- recalculate the coordinates
   int x_gap=x-wnd_pointer.X();
   int y_gap=y-wnd_pointer.Y();
//--- Save the window pointer
   color_picker.WindowPointer(wnd_pointer);
//--- Creating an element
   if(!color_picker.CreateColorPicker(m_chart_id,m_subwin,x_gap,y_gap))
      return(false);
//--- Add a pointer to the element in the base
   CWndContainer::AddToElementsArray(wnd_index,color_picker);
   return(true);
  }
//+------------------------------------------------------------------+

And in CProgram.mqh, create your ColorPicker:
   //--- Color picker
   x=m_window_main.X2()+1;
   y=m_window_main.Y();
   if(!CreateColorPicker(m_color_picker,m_window_main,m_window_main_index,x,y))
      return(false);
Look at this example:


 
stt:
...
I know that You do not support MQL4 version, but I think that MQL4 is not a reason.
Please show screenshots or videos showing the problem, and attach test files (MetaTrader 5) to the message.
 
Artyom Trishkin:
The latest versions of the library, object coordinate calculation was different. You need to either use the new rules specify coordinates of the object, or in their own methods to recalculate the coordinates in the usual you.
......

Thank you for tutorial. I checked and changed coordinate calculation. ColorPicker works well in my environment but only when displayed in main window (W_MAIN).

Could you check it in W_DIALOG window please?

ColorPicker in this library is very powerfull tool for fine tuning custom colours, but I wonder if simple colour table woud be more convenient for everyday use.
 
thanks for your efforts!!! is sorting by column and deleting rows possible in this version?
 
stt:
Thank you for tutorial. I checked and changed coordinate calculation. ColorPicker works well in my environment but only when displayed in main window (W_MAIN).

Could you check it in W_DIALOG window please?

ColorPicker in this library is very powerfull tool for fine tuning custom colours, but I wonder if simple colour table woud be more convenient for everyday use.
Please. Look at this:

 
dantetemp:
thanks for your labours!!! is sorting by column and deleting rows possible in this version?
Not yet. But it will be soon.
 
dantetemp:
thanks for your labours!!! is sorting by column and deleting rows possible in this version?
@dantetemp, it is already possible. Download the latest version of the library from this article: Graphical Interfaces X: Sorting, Table Reconstruction and Cell Controls (build 11)
 

Good afternoon. I have the following question: there is an input field SpinEdit:

bool CProgram::CreateSpinEdit_TradingLot(const string text)
{
//--- Save the window pointer
   m_spin_edit_Trading_lot.WindowPointer(m_window);
   m_tabs.AddToElementsArray(1,m_spin_edit_Trading_lot);
//--- Coordinates
   int x=m_window.X()+SPINEDIT14_GAP_X;
   int y=m_window.Y()+SPINEDIT14_GAP_Y;
//--- Value
   double v=(m_spin_edit_Trading_lot.GetValue()==WRONG_VALUE) ? 0.01 : m_spin_edit_Trading_lot.GetValue();
//--- Set properties before creation
   m_spin_edit_Trading_lot.XSize(90);
   m_spin_edit_Trading_lot.YSize(18);
   m_spin_edit_Trading_lot.EditXSize(50);
   m_spin_edit_Trading_lot.MaxValue(100);
   m_spin_edit_Trading_lot.MinValue(0.01);
   m_spin_edit_Trading_lot.StepValue(0.01);
   m_spin_edit_Trading_lot.SetDigits(2);
   m_spin_edit_Trading_lot.SetValue(v);
   m_spin_edit_Trading_lot.ResetMode(false);
   m_spin_edit_Trading_lot.AreaColor(clrWhite);
//--- Create a control
   if(!m_spin_edit_Trading_lot.CreateSpinEdit(m_chart_id,m_subwin,text,x,y))
      return(false);
//--- Add the object to the common array of object groups
   CWndContainer::AddToElementsArray(0,m_spin_edit_Trading_lot);
   return(true);
}


There is an event handler:

void CProgram::OnEventSpinEdit_TradingLot(void)
{
   TradingLot = m_spin_edit_Trading_lot.GetValue();
   Print("TradingLot = " + NormalizeDouble(TradingLot,2));
}

And even after the NormalizeDouble function I get such values when I click on the increment/decrement to the right of the input field:


When entering from the keyboard, everything is correct.

What can be the reason ?