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