diff --git a/roo-e/roo-e.pro b/roo-e/roo-e.pro
index 546a58e..3c561d6 100644
--- a/roo-e/roo-e.pro
+++ b/roo-e/roo-e.pro
@@ -53,6 +53,7 @@ HEADERS += \
src/gui/image.h \
src/gui/surface.h \
src/gui/widgets/label.h \
+ src/gui/widgets/picture.h \
src/gui/wmwindow.h \
src/os.h \
src/platform/platform.h \
@@ -69,6 +70,7 @@ SOURCES += \
src/gui/image.c \
src/gui/surface.c \
src/gui/widgets/label.c \
+ src/gui/widgets/picture.c \
src/gui/wmwindow.c \
src/main.c \
src/platform/djgpp.c \
diff --git a/roo-e/src/gui/gui.c b/roo-e/src/gui/gui.c
index 6d4d631..5ed798d 100644
--- a/roo-e/src/gui/gui.c
+++ b/roo-e/src/gui/gui.c
@@ -191,9 +191,8 @@ uint8_t guiStartup(int16_t width, int16_t height, int16_t depth) {
wmStartup();
- // Register all known widgets with the GUI.
+ // Always have to have a window type.
guiRegister(windowRegister);
- guiRegister(labelRegister);
return SUCCESS;
}
diff --git a/roo-e/src/gui/widgets/picture.c b/roo-e/src/gui/widgets/picture.c
new file mode 100644
index 0000000..5ce56a5
--- /dev/null
+++ b/roo-e/src/gui/widgets/picture.c
@@ -0,0 +1,92 @@
+/*
+ * Roo/E, the Kangaroo Punch Portable GUI Toolkit
+ * Copyright (C) 2022 Scott Duensing
+ *
+ * http://kangaroopunch.com
+ *
+ *
+ * This file is part of Roo/E.
+ *
+ * Roo/E is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Affero General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Roo/E is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Roo/E. If not, see .
+ *
+ */
+
+
+#include "../image.h"
+
+#include "picture.h"
+
+
+uint8_t __MAGIC_PICTURE = 0;
+
+
+static void pictureDestroy(struct WidgetS *widget, ...);
+static void picturePaint(struct WidgetS *widget, ...);
+
+
+void pictureClickSet(PictureT *picture, ClickHandlerT handler, void *data) {
+ picture->base.reg->click = handler;
+ picture->base.data = data;
+}
+
+
+PictureT *pictureCreate(uint16_t x, uint16_t y, char *filename, ...) {
+ PictureT *p = NULL;
+
+ NEW(PictureT, p);
+ memset(p, 0, sizeof(PictureT));
+ p->picture = imageLoad(filename);
+ if (!p->picture) {
+ DEL(p);
+ return NULL;
+ }
+ guiWidgetBaseSet((WidgetT *)p, __MAGIC_PICTURE, x, y, surfaceWidthGet(p->picture), surfaceHeightGet(p->picture));
+
+ return p;
+}
+
+
+static void pictureDestroy(struct WidgetS *widget, ...) {
+ PictureT *p = (PictureT *)widget;
+
+ if (p->picture) DEL(p->picture);
+ DEL(p);
+}
+
+
+static void picturePaint(struct WidgetS *widget, ...) {
+ PictureT *p = (PictureT *)widget;
+
+ if (guiWidgetDirtyGet(widget)) {
+ guiWidgetDirtySet(widget, 0);
+ // ***TODO*** Clipping.
+ surfaceBlit(p->base.r.x, p->base.r.y, 0, 0, 0, 0, p->picture);
+ }
+}
+
+
+RegisterT *pictureRegister(uint8_t magic) {
+ static RegisterT reg = {
+ "Picture",
+ NULL, // No default on-click handler.
+ pictureDestroy,
+ picturePaint,
+ NULL // No unregister handler.
+ };
+
+ // One-time widget startup code.
+ __MAGIC_PICTURE = magic;
+
+ return ®
+}
diff --git a/roo-e/src/gui/widgets/picture.h b/roo-e/src/gui/widgets/picture.h
new file mode 100644
index 0000000..882f312
--- /dev/null
+++ b/roo-e/src/gui/widgets/picture.h
@@ -0,0 +1,47 @@
+/*
+ * Roo/E, the Kangaroo Punch Portable GUI Toolkit
+ * Copyright (C) 2022 Scott Duensing
+ *
+ * http://kangaroopunch.com
+ *
+ *
+ * This file is part of Roo/E.
+ *
+ * Roo/E is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Affero General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Roo/E is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Roo/E. If not, see .
+ *
+ */
+
+
+#ifndef PICTURE_H
+#define PICTURE_H
+
+
+#include "../gui.h"
+
+
+typedef struct PictureS {
+ WidgetT base; // Required by all widgets.
+ SurfaceT *picture; // Picture to display.
+} PictureT;
+
+
+extern uint8_t __MAGIC_PICTURE; // Magic ID assigned to us from the GUI.
+
+
+void pictureClickSet(PictureT *picture, ClickHandlerT handler, void *data);
+PictureT *pictureCreate(uint16_t x, uint16_t y, char *filename, ...);
+RegisterT *pictureRegister(uint8_t magic);
+
+
+#endif // PICTURE_H
diff --git a/roo-e/src/main.c b/roo-e/src/main.c
index 68a3849..7c4547e 100644
--- a/roo-e/src/main.c
+++ b/roo-e/src/main.c
@@ -26,6 +26,7 @@
#include "gui/gui.h"
#include "gui/wmwindow.h"
#include "gui/widgets/label.h"
+#include "gui/widgets/picture.h"
void clickHandler(WidgetT *widget, uint16_t x, uint16_t y, void *data) {
@@ -46,6 +47,11 @@ int main(int argc, char *argv[]) {
logOpenByHandle(memoryLogHandleGet());
if (guiStartup(800, 600, 16) == SUCCESS) {
+
+ // Register all desired widgets with Roo/E.
+ guiRegister(labelRegister);
+ guiRegister(pictureRegister);
+
for (i=1; i<4; i++) {
sprintf(title, "Testing %d", i);
w = windowCreate(i * 50, i * 50, 300, 200, title, WIN_STANDARD, 640, 480);