文章 "图形界面 X: 排序、重建表格和单元格中的控件 (集成编译 11)" - 页 9

 
Anatoli Kazharski:
对齐什么?

为了显示图片,您需要在调用 AddRow 方法后对齐表格单元格 中的文本,这是您自己写给我的,在此之前我也猜到了我上面写的内容。
 
Konstantin:

要显示图片,您需要在调用 AddRow 方法后对齐表格单元格中的文本,这是您自己写的,在此之前我也猜到了我上面写的内容

默认情况下,整列的文本都是对齐的。添加行(AddRow)时,默认值保持不变。

还有这样一种方法:

CCanvasTable::TextAlign(const ENUM_ALIGN_MODE &array[])
 
Anatoli Kazharski:
默认情况下,整列的文本都是对齐的。添加行(AddRow) 时,默认值保持不变。


这样就不清楚为什么添加的行中 不显示图像:

      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);

         //--- 图片数组
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, r, _image);
      }
 
Konstantin:

顺便说一下,如果事先不知道表格中的行数,那么以后添加行数时,信息会添加到单元格中,但无法更改列与图片的对齐方式:

也许还有其他机制,请告诉我。

我制作了一个向表格中添加行的 函数:它从文件中读取关于在表格中打勾的符号的数据,并将工作符号列表(应显示在主表格中)添加到表格中:

//+------------------------------------------------------------------+
//| 在数据表中添加一行
//+------------------------------------------------------------------+
void CProgram::AddSymbolToTableMain(void){
   string img_butt0[1];    img_butt0[0]=m_img_graphic;
   string img_butt8[1];    img_butt8[0]=m_img_buy;
   string img_butt9[1];    img_butt9[0]=m_img_sell;
   string img_butt10[1];   img_butt10[0]=m_img_close;
   //---
   uint sz_used=FillingListUsedSymbols();       // 用打钩字符填充文件
   uint row=m_table_main.RowsTotal();
   string sy=m_symbol;
   for(ushort i=0; i<sz_used; i++) {
      sy=m_array_data_symbols[i].symbol_name;
      short index=IndexSymbolInTableMain(sy);   // 主表中的符号索引
      //--- 如果表中还不存在符号
      if(index==WRONG_VALUE) {               
         m_table_main.AddRow(i);                // 在表格中添加一行
         }
      //--- 设置表格列参数
      m_table_main.CellType(0,i,CELL_BUTTON);
      m_table_main.SetImages(0,i,img_butt0);
      m_table_main.CellType(8,i,CELL_BUTTON);
      m_table_main.SetImages(8,i,img_butt8);
      m_table_main.CellType(9,i,CELL_BUTTON);
      m_table_main.SetImages(9,i,img_butt9);
      m_table_main.CellType(10,i,CELL_BUTTON);
      m_table_main.SetImages(10,i,img_butt10);
      //---
      m_table_main.SetValue(0,i,sy,0);
      m_table_main.TextColor(0,i,(SymbolInfoInteger(sy,SYMBOL_TRADE_MODE)==SYMBOL_TRADE_MODE_DISABLED ? NewColor(clrRed,100,100,100) : 
                                  SymbolInfoInteger(sy,SYMBOL_TRADE_MODE)==SYMBOL_TRADE_MODE_FULL ?     NewColor(clrDimGray,0,50,0) : clrLightGray));
      for(uchar c=2; c<m_table_main.ColumnsTotal(); c++) m_table_main.TextColor(c,i,clrDimGray);
      }
   m_table_main.UpdateTable(true);
   CreateClasses();
}
//+------------------------------------------------------------------+


 
Artyom Trishkin:

我制作了一个向表中添加行的 函数:它从文件中读取有关在表中打勾的字符的数据,并将工作字符列表(应输出到主表中)添加到表中:

好例子。因为我想帮忙,但没时间。)

根据我们之前的讨论,我将添加更简单的更改表参数的方法。在接下来的更新中将会提供。

 
Artyom Trishkin:

我做了一个向表格中添加行的 函数:它从文件中读取关于工作符号列表(应显示在主表中)表中打钩符号的数据,并将它们添加到表格中:


我不明白,我也做了同样的操作,但图片没有出现,尽管所有数据都已添加和更新:

/*!
 \brief Update table values
 \param CWrapTradePair &a_pair - 包含信号数据的数组指针
 \param CCanvasTable &a_table - 表格对象
*/
void CTblSignal::UpdateTable(CWrapTradePair &a_pair,CCanvasTable &a_table) {
   MqlDateTime _date;
   ::TimeToStruct(::TimeTradeServer(), _date);

   //--- 周末检查
   if(_date.day_of_week == 0 || _date.day_of_week == 6)
      return;

   //--- 将数据分解成表格
   uint _count = 0;
   for(uint r = 0, _size = a_pair.Size(); r < _size; ++r) {
      if(!a_pair[r].coint)
         continue;

      _count++;
      //--- 如果行数不够,则添加和更新表结构
      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);

         a_table.CellType(1, r, CELL_BUTTON);

         //--- 图片数组
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                             "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                             "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, r, _image);
      }

      if(a_pair[r].event == COINT_BS_NOISE || a_pair[r].event == COINT_SB_NOISE) {
         //--- "滴答"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "信号"
         a_table.ChangeImage(1, _count - 1, 0, true);
         //--- "DF-测试"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOISE, true);
      } else if(a_pair[r].event == COINT_BS || a_pair[r].event == COINT_SB) {
         //--- "滴答"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "信号"
         a_table.ChangeImage(1, _count - 1, 1, true);
         //--- "DF-测试"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_BSSB, true);
      } else {
         //--- "滴答"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "信号"
         a_table.ChangeImage(1, _count - 1, 2, true);
         //--- "DF-测试"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOT, true);
      }
   }

//--- 检查表中是否有多余的行
   for(uint r = _count, _size = a_table.RowsTotal(); r < _size; ++r)
      a_table.DeleteRow(r, true);

//-- 更新表格
   a_table.UpdateTable();
}


请告诉我这可能是什么错误,因为所有工作都停滞不前 ))

 
Konstantin:

我什么也不明白,我也在做同样的事情,但图片没有出现,尽管所有数据都已添加和更新:


请问错误出在哪里?)

带图片的列的对齐方式在哪里设置?

应该有一个数组,其中每一列都设置了对齐方式。

 
我进行了测试,发现一切都取决于TableSize 方法预先设置的行数,我需要深入研究源代码,因为某些原因,它对图像有确切的影响。
 
Artyom Trishkin:
在哪里设置图片列的对齐方式?


我在创建表格 的方法中设置 了对齐方式,但如果我像这样添加对齐方式:

/*!
 \brief Update table values
 \param CWrapTradePair &a_pair - 包含信号数据的数组指针
 \param CCanvasTable &a_table - 表格对象
*/
void CTblSignal::UpdateTable(CWrapTradePair &a_pair,CCanvasTable &a_table) {
   //--- 将数据分解成表格
   uint _count = 0;
   for(uint r = 0, _size = a_pair.Size(); r < _size; ++r) {
      if(!a_pair[r].coint)
         continue;

      _count++;
      //--- 如果行数不够,则添加和更新表结构
      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);

         //-- 列中文本对齐方式的数组
         ENUM_ALIGN_MODE _align[TBL_COLUMNS_TOTAL];
         ::ArrayInitialize(_align, ALIGN_RIGHT);
         _align[1] = ALIGN_LEFT;
         m_table.TextAlign(_align);

         a_table.CellType(1, r, CELL_BUTTON);

         //--- 图片数组
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, r, _image);
      }

      if(a_pair[r].event == COINT_BS_NOISE || a_pair[r].event == COINT_SB_NOISE) {
         //--- "滴答"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "信号"
         a_table.ChangeImage(1, _count - 1, 0, true);
         //--- "DF-测试"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOISE, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOISE, true);
      } else if(a_pair[r].event == COINT_BS || a_pair[r].event == COINT_SB) {
         //--- "滴答"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "信号"
         a_table.ChangeImage(1, _count - 1, 1, true);
         //--- "DF-测试"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_BSSB, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_BSSB, true);
      } else {
         //--- "滴答"
         a_table.SetValue(0, _count - 1, a_pair[r].ticker[0] + "_" + a_pair[r].ticker[1]);
         a_table.TextColor(0, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "信号"
         a_table.ChangeImage(1, _count - 1, 2, true);
         //--- "DF-测试"
         a_table.SetValue(2, _count - 1, ::DoubleToString(a_pair[r].adf_pvalue, 3));
         a_table.TextColor(2, _count - 1, TBL_INFO_DATA_NOT, true);
         //--- "Delta%"
         a_table.SetValue(3, _count - 1, ::DoubleToString(a_pair[r].delta, 0));
         a_table.TextColor(3, _count - 1, TBL_INFO_DATA_NOT, true);
      }
   }

//--- 检查表中是否有多余的行
   for(uint r = _count, _size = a_table.RowsTotal(); r < _size; ++r)
      a_table.DeleteRow(r, true);

//-- 更新表格
   a_table.UpdateTable(true);
}

还是没有任何改变 ((

 

问题已经解决了,我在编制索引时犯了一个错误:

      if(a_table.RowsTotal() < _count) {
         a_table.AddRow(_count - 1, true);
         
         //--- делать дополнительно выравнивание не нужно, все сохраняется от первой строки

         a_table.CellType(1, _count - 1, CELL_BUTTON);

         //--- 图片数组
         string _image[3]= { "::Images\\EasyAndFastGUI\\Icons\\bmp16\\circle_gray.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_up.bmp",
                       "::Images\\EasyAndFastGUI\\Icons\\bmp16\\arrow_down.bmp" };
         a_table.SetImages(1, _count - 1, _image);
      }