• HI,

    Of course, _cbCallback and _cbDialog are just names and you can choose them freely.

    But, the callback set for a dialog receives a WM_INIT_DIALOG message after all its dialog elements are created. This gives you the chance to configure the different elements.

    A callback function set for a single window gets a WM_CREATE message giving you the chance of reacting to it and creating further child windows or set up some data.

    You can react to WM_CREATE only if the pointer to the callback function is a prameter of the create function like "cb" of the following function:

    C
    WM_HWIN WM_CreateWindowAsChild(int           x0,
                                   int           y0,
                                   int           width,
                                   int           height,
                                   WM_HWIN       hParent,
                                   U32           Style,
                                   WM_CALLBACK * cb,
                                   int           NumExtraBytes);


    With a widget it is not possible to pass a callback to its create function. Therefore we have added a message to react on setting a callback. Since emWin version 5.46 a callback gets send a WM_SET_CALLBACK message when calling WM_SetCallback().

    Regards,
    Sven

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi,

    you could overwrite the button callback function or set a custom skinning function. When it comes to drawing the button text you can display the string rotated with the function GUI_DispStringInRectEx().


    It is not possible to simply rotate the default button. The background wouldn't get rotated.

    Regards,
    Sven

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • I want to rotate the inscription on the button. What's wrong here?

    #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
    #define ID_BUTTON_0 (GUI_ID_USER + 0x01) // START
    #define ID_BUTTON_1 (GUI_ID_USER + 0x02) // STOP
    #define ID_BUTTON_2 (GUI_ID_USER + 0x03) // UP
    #define ID_BUTTON_3 (GUI_ID_USER + 0x04) // DOWN

    static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { {
    WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272,
    WM_CF_SHOW, 0 }, { BUTTON_CreateIndirect, "START",
    ID_BUTTON_0, 30, 20, 40, 232 }, { BUTTON_CreateIndirect, "STOP",
    ID_BUTTON_1, 90, 20, 40, 232 }, { BUTTON_CreateIndirect, "UP",
    ID_BUTTON_2, 150, 20, 40, 232 }, { BUTTON_CreateIndirect, "DOWN",
    ID_BUTTON_3, 210, 20, 40, 232 } };


    static void _cbCallback(WM_MESSAGE * pMsg) {


    WM_HWIN hWin;
    WM_HWIN hItem;


    int NCode;
    int Id;


    hItem = pMsg->hWin;
    switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
    WINDOW_SetBkColor(hItem, GUI_BLUE);


    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
    BUTTON_SetText(hItem, "START");
    BUTTON_SetTextColor(hItem, BUTTON_CI_PRESSED, GUI_RED);
    GUI_DispStringInRectEx("START", hItem, GUI_TA_HCENTER | GUI_TA_VCENTER,
    6, GUI_ROTATE_CCW);


    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
    BUTTON_SetText(hItem, "STOP");


    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
    BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
    BUTTON_SetText(hItem, "UP");


    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
    BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
    BUTTON_SetText(hItem, "DOWN");


    break;


    default:
    WM_DefaultProc(pMsg);
    break;
    }
    }


    WM_HWIN CreateWindow(void) {
    WM_HWIN hWin;


    hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate),
    _cbCallback, WM_HBKWIN, 0, 0);
    return hWin;
    }


    void MainTask(void) {


    CreateWindow();


    }

  • Hi,

    What is the difference between _cbButton and cbButton?

    _cbButtonTrans() is a callback function gets called by emWin if something happens related to the button this callback is set to. This allows you to react different events like touch, or WM_PAINT.

    _ButtonSkin() is callback dedicated for drawing. This gets called by the default callback function of a button and allows you to draw the single parts of a button like background and text.


    I want to rotate the inscription on the button. What's wrong here?


    You have to set either a custom skin or a custom callback for the buttons. Otherwise you can not change the drawing.

    You can not simply call a drawing function within WM_INIT_DIALOG. Draw functions should be called only within a WM_PAINT event.


    Regards,
    Sven

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi Andrzej,

    I'm not sure what you mean by converting, but if you mean custom drawing a widget then yes, you're able to custom draw all widgets.

    This is done by executing the drawing operations in a WM_PAINT case in a callback function. This function will be set to a widget using WM_SetCallback().

    Here's a small sample demonstrating how to do this:

    Best regards,

    Florian

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi

    I want to put NUMBER on position x = 250, y = 40. I have the following code. Why can't I do that? How to declare GUI_RECT?

    static void _cbCallback(WM_MESSAGE * pMsg) {
      WM_HWIN hWin;
      WM_HWIN hItem;
      int NCode;
      int Id;
    GUI_RECT Rect = {10, 10, 40, 80};


      hItem = pMsg->hWin;
      switch (pMsg->MsgId) {
      case WM_INIT_DIALOG:


      WINDOW_SetBkColor(hItem, GUI_BLUE);


      hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
      BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
      BUTTON_SetText(hItem, "START");
      BUTTON_SetSkin(hItem, _ButtonSkin);


      hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
      BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
      BUTTON_SetText(hItem, "STOP");
      BUTTON_SetSkin(hItem, _ButtonSkin);


      hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
      BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
      BUTTON_SetText(hItem, "UP");
      BUTTON_SetTextColor(hItem, BUTTON_CI_PRESSED, GUI_RED);
      BUTTON_SetSkin(hItem, _ButtonSkin);


      hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
      BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
      BUTTON_SetText(hItem, "DOWN");
      BUTTON_SetTextColor(hItem, BUTTON_CI_PRESSED, GUI_RED);
      BUTTON_SetSkin(hItem, _ButtonSkin);


      break;


      case WM_PAINT:


      GUI_DispStringInRectEx("NUMBER", &Rect,
      GUI_TA_HCENTER | GUI_TA_VCENTER, 10, GUI_ROTATE_CCW);


      break;


      default:
      WM_DefaultProc(pMsg);
      break;
      }
    }


    /*********************************************************************
     *
     * CreateWindow
     */
    WM_HWIN CreateWindow(void) {
      WM_HWIN hWin;


      hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate),
      _cbCallback, WM_HBKWIN, 0, 0);
      return hWin;
    }


    void MainTask(void) {


      GUI_Init();
      WM_MULTIBUF_Enable(1);
      CreateWindow();
      while (1) {
      GUI_Delay(100);
      }
    }

  • Hi Andrzej,

    to display the text at the position you mentioned, your rectangle should be located at that position as well:

    C
    GUI_RECT Rect = {250, 40, 250 + 40, 80};
    ...
    GUI_DispStringInRectEx("NUMBER", &Rect, GUI_TA_RIGHT, 10, GUI_ROTATE_CCW);

    Best regards,


    Florian

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi,

    It's the end position in x direction of the rectangle (x0 + 40).

    Regards,
    Sven

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi Andrzej,

    no, rotating widgets is not possible. What you might want to do instead is changing the display orientation instead of rotating each item individually.

    You can do this by changing the display driver in the file LCDConf.c. Your hardware uses the Lin driver and you can find a list of available orientation settings in the manual under "33.7.6 GUIDRV_Lin".

    Setting the display driver to GUIDRV_LIN_OSX_32 should achieve what you need, if your color depth is 32bpp.

    Best regards,

    Florian

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!