MULTIPAGE_SetBitmapEx for UNSELECTED tabs

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • MULTIPAGE_SetBitmapEx for UNSELECTED tabs

      Hello.

      I want to put image to all unselected Tabs of MULTIPAGE.

      But selected Tab should not have the image.

      If I use following code:

      C Source Code

      1. MULTIPAGE_AddPage(hMultiPage, hChild, str);
      2. MULTIPAGE_SetBitmapEx(hMultiPage, &bmImage_img, 0, 0, MULTIPAGE_GetSelection(hMultiPage), MULTIPAGE_BI_UNSELECTED);
      then I have the image on ALL tabs, including currently selected Tab.

      Also, I need to move the left-aligned text to the right to the width of the image so that it begins after the image.
      How to do it?
      Best regards,
      Volodymyr.

      The post was edited 1 time, last by volodymyr ().

    • Hello,

      for aligning the text to the right after the bitmap you can increase the width of the tabs using MULTIPAGE_SetTabWidth() and then set text align to the right using MULTIPAGE_SetTextAlign().

      With regard to the bitmap, yes, looks strange. Adding a bitmap for unselected state draws it also in selected state of the tabs.

      Try to use skinning option of the widget and manually draw the bitmap in unselected state. Before doing this just comment "MULTIPAGE_SetBitmapEx()" line.

      C Source Code

      1. int _MULTIPAGE_CustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) {
      2. switch (pDrawItemInfo->Cmd) {
      3. case WIDGET_ITEM_DRAW_BACKGROUND:
      4. if (MULTIPAGE_GetSelection(pDrawItemInfo->hWin) != pDrawItemInfo->ItemIndex) {
      5. GUI_DrawBitmap(&bmImage_img, pDrawItemInfo->x0, pDrawItemInfo->y0);
      6. }
      7. else
      8. MULTIPAGE_DrawSkinFlex(pDrawItemInfo);
      9. break;
      10. default:
      11. return MULTIPAGE_DrawSkinFlex(pDrawItemInfo);
      12. break;
      13. }
      14. return 0;
      15. }
      16. ...
      17. // in initializing the widget
      18. MULTIPAGE_SetSkin(hMultiPage, _MULTIPAGE_CustomSkin);
      19. ...
      Display All
      Alex.
    • LexaGb wrote:

      With regard to the bitmap, yes, looks strange. Adding a bitmap for unselected state draws it also in selected state of the tabs.
      Nothing strange, #define MULTIPAGE_BI_SELECTED is 0, and since all three states of this function are OR-ed, that means that state MULTIPAGE_BI_SELECTED is always present.
      Segger had to define set of bits for this (like 1 << 0, 1 << 1, 1 << 2) instead values 0, 1, 2. 8)
      Best regards,
      Volodymyr.
    • I'm using STemWin 5.44, so I don't have the sources and I can't see C-code where the states are OR-ed (except if look at assembler code). Can you see where it happens?

      However, calling MULTIPAGE_SetBitmapEx() with a mask instead of index doesn't change anything on my side.

      I thought when tabs' bitmaps are drawn the parameter MULTIPAGE_BI_... must be considered as an index value not as a mask...

      Alex.
    • LexaGb wrote:

      I'm using STemWin 5.44, so I don't have the sources and I can't see C-code where the states are OR-ed (except if look at assembler code). Can you see where it happens?

      However, calling MULTIPAGE_SetBitmapEx() with a mask instead of index doesn't change anything on my side.

      I thought when tabs' bitmaps are drawn the parameter MULTIPAGE_BI_... must be considered as an index value not as a mask...

      Alex.
      See official documentation (one page - in attachment).
      Images
      • 1.png

        47.36 kB, 1,240×1,755, viewed 32 times
      Best regards,
      Volodymyr.
    • Oh, I think it is just a little bug in the documentation :) .

      “Horizontal and vertical flags” make sense in case of text align related functions, probably this was copied from such function description or whatever and then the editor didn’t notice it to delete this phrase.

      Alex.