aboutsummaryrefslogtreecommitdiffstats
path: root/widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'widget.c')
-rw-r--r--widget.c65
1 files changed, 60 insertions, 5 deletions
diff --git a/widget.c b/widget.c
index 2983f60..18aa8a6 100644
--- a/widget.c
+++ b/widget.c
@@ -1,9 +1,9 @@
-/* $Id: widget.c 728 2007-01-14 11:14:38Z michael $
- * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/widget.c $
+/* $Id: widget.c 996 2009-03-23 17:22:24Z volker $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/widget.c $
*
* generic widget handling
*
- * Copyright (C) 2003, 2004 Michael Reinelt <reinelt@eunet.at>
+ * Copyright (C) 2003, 2004 Michael Reinelt <michael@reinelt.co.at>
* Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
*
*/
-/*
+/*
* exported functions:
*
* int widget_junk(void)
@@ -128,6 +128,32 @@ int widget_color(const char *section, const char *name, const char *key, RGBA *
return 1;
}
+int intersect(WIDGET * w1, WIDGET * w2)
+{
+ int x1w1, y1w1, x2w1, y2w1; /* 1st rectangle */
+ int x1w2, y1w2, x2w2, y2w2; /* 2nd rectangle */
+
+ if (w1->x2 == NOCOORD || w1->y2 == NOCOORD || w2->x2 == NOCOORD || w2->y2 == NOCOORD) {
+ /* w1 or w2 is no display widget: no intersection */
+ return 0;
+ }
+ x1w1 = MIN(w1->col, w1->x2);
+ x2w1 = MAX(w1->col, w1->x2);
+ y1w1 = MIN(w1->row, w1->y2);
+ y2w1 = MAX(w1->row, w1->y2);
+ x1w2 = MIN(w2->col, w2->x2);
+ x2w2 = MAX(w2->col, w2->x2);
+ y1w2 = MIN(w2->row, w2->y2);
+ y2w2 = MAX(w2->row, w2->y2);
+
+ if (x1w2 < x2w1 && x2w2 > x1w1 && y1w2 < y2w1 && y2w2 > y1w1) {
+ /* true: Intersection */
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
int widget_add(const char *name, const int type, const int layer, const int row, const int col)
{
int i;
@@ -180,6 +206,19 @@ int widget_add(const char *name, const int type, const int layer, const int row,
/* check if widget type matches */
if (Class->type != type) {
error("widget '%s': class '%s' not applicable", name, class);
+ switch (Class->type) {
+ case WIDGET_TYPE_RC:
+ error(" Widgetclass %s is placed by Row/Column", class);
+ break;
+ case WIDGET_TYPE_XY:
+ error(" Widgetclass %s is placed by X/Y", class);
+ break;
+ case WIDGET_TYPE_GPO:
+ case WIDGET_TYPE_TIMER:
+ case WIDGET_TYPE_KEYPAD:
+ default:
+ error(" Widgetclass %s has unknown type %d", class, Class->type);
+ }
free(class);
return -1;
}
@@ -200,7 +239,7 @@ int widget_add(const char *name, const int type, const int layer, const int row,
/* another sanity check */
if (nWidgets >= MAX_WIDGETS) {
- error("internal error: widget buffer full!");
+ error("internal error: widget buffer full! Tried to allocate %d widgets (max: %d)", nWidgets, MAX_WIDGETS);
return -1;
}
@@ -231,6 +270,22 @@ int widget_add(const char *name, const int type, const int layer, const int row,
Class->init(Widget);
}
+ info(" widget '%s': Class '%s', Parent '%s', Layer %d, %s %d, %s %d (to %d,%d)",
+ name, (NULL == Class) ? "<none>" : Class->name,
+ (NULL == Parent) ? "<root>" : Parent->name,
+ layer, (WIDGET_TYPE_XY == Class->type) ? "Y" : "Row", row, (WIDGET_TYPE_XY == Class->type) ? "X" : "Col", col,
+ Widget->y2, Widget->x2);
+
+ /* sanity check: look for overlapping widgets */
+ for (i = 0; i < nWidgets - 1; i++) {
+ if (Widgets[i].layer == layer) {
+ if (intersect(&(Widgets[i]), Widget)) {
+ info("WARNING widget %s(%i,%i) intersects with %s(%i,%i) on layer %d",
+ Widgets[i].name, Widgets[i].row, Widgets[i].col, name, row, col, layer);
+ }
+ }
+ }
+
return 0;
}