cancel
Showing results for 
Search instead for 
Did you mean: 

StemWin edit widget text selection and cursor is all black

jpopovich
Associate II
Posted on September 14, 2016 at 15:02

Hi,

I am using stemwin on my stm32f7-discovery board.  When using an Edit widget, text selection is rendered in all black so that you are not able to read the text when it is selected.  The same thing happens to the insert cursor when changing from insert to replace mode.  I expected it to reverse the colors when rendering the selected text or cursor.  

Is there any configuration setting I am missing to get the desired behavior?

I am using :

GCC,

ST_Addons.h v1.1.1,

emWin V5.28,

STM32F746G-DISCO

Thanks in advance,
3 REPLIES 3
slimen
Senior
Posted on September 15, 2016 at 16:01

Hi,

I think EDIT_SetTextColor() and EDIT_SetBkColor() 

functions 

could be used for setting the text and cursor color.

For detailed information about the 

Edit widget 

function, you can refer to this 

https://www.segger.com/emwin-widgets.html

it maybe helpful for you and the emWin manual (19.8 EDIT: Edit widget)

Regards

jpopovich
Associate II
Posted on September 15, 2016 at 17:51

Thanks for your reply.

I am using EDIT_SetTextColor() and EDIT_SetBkColor() for both EDIT_CI_ENABLED and EDIT_CI_DISABLED.  They are working correctly.  The text inside the EDIT Widget works fine normally.

My problem is that the cursor inside the edit text is completely black when in replace mode.  This means that the user cannot see the character that is behind the cursor.

Also when selecting the text with EDIT_SetSel(), the selection is all black.  The user cannot read the text.  

For both of these cases the text is supposed to be rendered in reverse video, meaning the text should be the background color and the background should be the text color.

I am now thinking that the XOR Draw mode isn't working.  Antialiasing works for fonts. Translucent and semi translucent bitmaps are drawn correctly as well.

The lcd is Rocktech RK043FN48H-CT672B (the lcd provided with the stm32f7-discovery board)

I am using the GUIDRV_LIN_32 display driver with GUICC_M8888I

jpopovich
Associate II
Posted on October 04, 2016 at 20:03

I found a solution and/or workaround for this.  The issue appears to be inside the lcd driver. I am using GUIDRV_LIN_32.  It appears that it doesn't correctly implement LCD_DEVFUNC_FILLRECT whenever (GUI_GetDrawMode() == GUI_DM_XOR).  

To work around the issue, I implemented my own XOR Fill Rect in LCDConf.c

/*************** ORIGINAL CODE *************************/

static void LCD_LL_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex) 

{

  U32 BufferSize, AddrDst;

  int xSize, ySize;

  

  if (GUI_GetDrawMode() == GUI_DM_XOR) 

  {

    LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, NULL);

    LCD_FillRect(x0, y0, x1, y1);

    LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, (void(*)(void))LCD_LL_FillRect);

  } 

  else 

  {

    xSize = x1 - x0 + 1;

    ySize = y1 - y0 + 1;

    BufferSize = GetBufferSize(LayerIndex);

    AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel;

    DMA2D_FillBuffer(LayerIndex, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, PixelIndex);

  }

}

/*************** WORK AROUND *************************/

static void draw_rect_xor(int x0, int y0, int x1, int y1)

{

  int temp;

  if (x1 < x0)

  {

    temp = x0;

    x0 = x1;

    x1 = temp;

  }

  if (y1 < y0)

  {

    temp = y0;

    y0 = y1;

    y1 = temp;

  }

  for (int y=y0; y <= y1; y++)

    for(int x=x0; x<= x1; x++)

    {

      unsigned int new_color = LCD_GetPixelIndex(x, y);

      new_color = (new_color ^ 0x00FFFFFF);

      LCD_SetPixelIndex(x, y, new_color);

    }

}

static void LCD_LL_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex) 

{

  U32 BufferSize, AddrDst;

  int xSize, ySize;

  

  if (GUI_GetDrawMode() == GUI_DM_XOR) 

  {

    draw_rect_xor(x0,y0,x1,y1);

  } 

  else 

  {

    xSize = x1 - x0 + 1;

    ySize = y1 - y0 + 1;

    BufferSize = GetBufferSize(LayerIndex);

    AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel;

    DMA2D_FillBuffer(LayerIndex, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, PixelIndex);

  }

}