kpmpgsmkii/client/src/gui/desktop.c
2021-11-11 20:19:25 -06:00

70 lines
1.8 KiB
C

/*
* Kangaroo Punch MultiPlayer Game Server Mark II
* Copyright (C) 2020-2021 Scott Duensing
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "desktop.h"
#include "window.h"
static void desktopPaint(WidgetT *desktop, RectT pos);
WidgetT *desktopInit(WidgetT *desktop) {
DesktopT *d = (DesktopT *)desktop;
d->base.magic = MAGIC_DESKTOP;
d->base.paintMethod = desktopPaint;
GUI_SET_FLAG(desktop, WIDGET_FLAG_OWNS_SURFACE);
d->base.surface = surfaceCreate(d->base.pos.w, d->base.pos.h);
if (!d->base.surface) {
free(d);
return NULL;
}
return desktop;
}
DesktopT *desktopNew(void) {
DesktopT *desktop = (DesktopT *)malloc(sizeof(DesktopT));
WidgetT *widget = NULL;
if (!desktop) return NULL;
widget = widgetInit(W(desktop), MAGIC_DESKTOP, 0, 0, vbeDisplayWidthGet(), vbeDisplayHeightGet(), 0, 0, 0, 0);
if (!widget) {
free(desktop);
return NULL;
}
desktop = (DesktopT *)desktopInit((WidgetT *)desktop);
return desktop;
}
static void desktopPaint(WidgetT *desktop, RectT pos) {
(void)pos;
if (GUI_GET_FLAG(desktop, WIDGET_FLAG_DIRTY)) {
surfaceClear(_guiColor[COLOR_DESKTOP]);
GUI_CLEAR_FLAG(desktop, WIDGET_FLAG_DIRTY);
}
}