Jump to content

br64

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by br64

  1. Hi All,

    I am attempting to get the simple uGFX List code example to also show an image.

    Below is my code, as well as defines added to gfxconf.h.

    The list is displayed just fine, but no image in the list.

    Is there something I'm missing?

     

    I have defined the following in gfxconf.h:

    GFX_USE_GDISP

    GDISP_NEED_IMAGE

    GWIN_NEED_LIST

    GWIN_NEED_LIST_IMAGES

     

    And here's my code:

    #include <string.h>
    #include "gfx.h"

    static GListener gl;
    static GHandle   ghList1;
    static gdispImage img1;

    static void createWidgets(void) {
        GWidgetInit wi;

        // Apply some default values for GWIN
        gwinWidgetClearInit(&wi);
        wi.customDraw = 0;
        wi.customParam = 0;
        wi.customStyle = 0;
        wi.g.show = FALSE;

        // Apply the list parameters
        wi.g.width = 200;
        wi.g.height = 100;
        wi.g.y = 10;
        wi.g.x = 10;
        wi.text = "List Name";

        // Create the actual list
        ghList1 = gwinListCreate(NULL, &wi, FALSE);
    }

    int main(void) {
        uint16_t    i;
        char        item[20];
        GEvent        *pe;

        // Initialize the display
        gfxInit();

        // Set the widget defaults
        gwinSetDefaultFont(gdispOpenFont("UI2"));
        gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
        gdispClear(White);

        // Attach the mouse input
        //gwinAttachMouse(0);

        // create the widget
        createWidgets();

        // We want to listen for widget events
        geventListenerInit(&gl);
        gwinAttachListener(&gl);

        // Add some items to the list widget
        for (i = 0; i < 100; i++) {
            sprintf(item, "Item Nr.: %d", i);
            gwinListAddItem(ghList1, item, TRUE);
        }
        gdispImageOpenFile(&img1, "star16.gif");
        gwinListItemSetImage(ghList1, 0, &img1);

        // Make the list visible
        gwinSetVisible(ghList1, TRUE);

        while (1) {
            // Get an Event
            pe = geventEventWait(&gl, TIME_INFINITE);
        }

        return 0;
    }

     

    Much thanks in advance,

    br64

  2. I am new to uGFX and currently trying to learn a little about Lists.  Trying to gain access to scrolling of the demo list program via keyboard and mouse.  I have the demo program from https://wiki.ugfx.io/index.php/List setup, compiling and running in a Win10 environment using gcc.  When first setting up the demo program, was getting build errors with the line in main.c... gwinAttachMouse(0).  Read elsewhere that was no longer needed, so commented that line and got past the build errors.  However, I have not yet figured out how to get access to scrolling the list up/down using my desktop's keyboard or mouse.  Any suggestions on how to accomplish this?

    Thanks in advance for your assistance.

×
×
  • Create New...