summaryrefslogtreecommitdiff
path: root/src/widget/widget_select.c
diff options
context:
space:
mode:
authorxHire <xhire@tuxportal.cz>2008-10-25 14:11:06 +0200
committerxHire <xhire@tuxportal.cz>2008-10-25 14:11:06 +0200
commitc8a9209d77a896bf49227e5aeccd54e91ccf29cc (patch)
tree6b7367406ebbc6ce3ea5e0c8668c75f6fb3f6ae9 /src/widget/widget_select.c
parentcb9deba915dd7b114eeb76601eb1c8b07c1ba90f (diff)
Changed style of the code to the K&R standard
Diffstat (limited to 'src/widget/widget_select.c')
-rw-r--r--src/widget/widget_select.c194
1 files changed, 92 insertions, 102 deletions
diff --git a/src/widget/widget_select.c b/src/widget/widget_select.c
index 78877f0..2f89fe2 100644
--- a/src/widget/widget_select.c
+++ b/src/widget/widget_select.c
@@ -9,152 +9,142 @@
#include "widget.h"
#include "widget_select.h"
-widget_t *
-newWidgetSelect(int x, int y, void (*fce_event) (void *))
+widget_t *newWidgetSelect(int x, int y, void (*fce_event) (void *))
{
- widget_select_t *new;
+ widget_select_t *new;
- new = malloc(sizeof(widget_select_t));
- new->select = -1;
- new->fce_event = fce_event;
- new->list = newList();
+ new = malloc(sizeof(widget_select_t));
+ new->select = -1;
+ new->fce_event = fce_event;
+ new->list = newList();
- return newWidget(WIDGET_TYPE_SELECT, x, y, 0, 0, new);
+ return newWidget(WIDGET_TYPE_SELECT, x, y, 0, 0, new);
}
-char *
-getWidgetSelectItem(widget_t * widget)
+char *getWidgetSelectItem(widget_t * widget)
{
- widget_select_t *p;
+ widget_select_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_SELECT);
- p = (widget_select_t *) widget->private_data;
+ p = (widget_select_t *) widget->private_data;
- if (p->select == -1) {
- return NULL;
- }
+ if (p->select == -1) {
+ return NULL;
+ }
- return (char *) p->list->list[p->select];
+ return (char *) p->list->list[p->select];
}
-int
-getWidgetSelectIndex(widget_t * widget)
+int getWidgetSelectIndex(widget_t * widget)
{
- widget_select_t *p;
+ widget_select_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_SELECT);
- p = (widget_select_t *) widget->private_data;
+ p = (widget_select_t *) widget->private_data;
- return p->select;
+ return p->select;
}
-void
-addToWidgetSelect(widget_t * widget, char *s)
+void addToWidgetSelect(widget_t * widget, char *s)
{
- widget_select_t *p;
+ widget_select_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_SELECT);
- p = (widget_select_t *) widget->private_data;
+ p = (widget_select_t *) widget->private_data;
- addList(p->list, strdup(s));
+ addList(p->list, strdup(s));
}
-void
-removeAllFromWidgetSelect(widget_t * widget)
+void removeAllFromWidgetSelect(widget_t * widget)
{
- widget_select_t *p;
+ widget_select_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_SELECT);
- p = (widget_select_t *) widget->private_data;
+ p = (widget_select_t *) widget->private_data;
- while (p->list->count > 0) {
- delListItem(p->list, 0, free);
- }
+ while (p->list->count > 0) {
+ delListItem(p->list, 0, free);
+ }
}
-void
-drawWidgetSelect(widget_t * widget)
+void drawWidgetSelect(widget_t * widget)
{
- widget_select_t *p;
- int x, y, w, h;
- int i;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- getMousePosition(&x, &y);
- p = (widget_select_t *) widget->private_data;
-
- for (i = 0; i < p->list->count; i++) {
- char *line;
-
- line = (char *) p->list->list[i];
-
- getTextSize(line, &w, &h);
-
- if (x > widget->x && y > widget->y + i * 20 && x < widget->x + w
- && y < widget->y + i * 20 + h) {
- drawFont(line, widget->x, widget->y + i * 20, COLOR_YELLOW);
- }
- else {
- if (p->select == i) {
- drawFont(line, widget->x, widget->y + i * 20, COLOR_RED);
- }
- else {
- drawFont(line, widget->x, widget->y + i * 20, COLOR_WHITE);
- }
- }
- }
+ widget_select_t *p;
+ int x, y, w, h;
+ int i;
+
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_SELECT);
+
+ getMousePosition(&x, &y);
+ p = (widget_select_t *) widget->private_data;
+
+ for (i = 0; i < p->list->count; i++) {
+ char *line;
+
+ line = (char *) p->list->list[i];
+
+ getTextSize(line, &w, &h);
+
+ if (x > widget->x && y > widget->y + i * 20 && x < widget->x + w
+ && y < widget->y + i * 20 + h) {
+ drawFont(line, widget->x, widget->y + i * 20, COLOR_YELLOW);
+ } else {
+ if (p->select == i) {
+ drawFont(line, widget->x, widget->y + i * 20, COLOR_RED);
+ } else {
+ drawFont(line, widget->x, widget->y + i * 20, COLOR_WHITE);
+ }
+ }
+ }
}
-void
-eventWidgetSelect(widget_t * widget)
+void eventWidgetSelect(widget_t * widget)
{
- widget_select_t *p;
- int x, y, w, h;
- int i;
+ widget_select_t *p;
+ int x, y, w, h;
+ int i;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_SELECT);
- p = (widget_select_t *) widget->private_data;
- getMousePosition(&x, &y);
+ p = (widget_select_t *) widget->private_data;
+ getMousePosition(&x, &y);
- for (i = 0; i < p->list->count; i++) {
- char *line;
+ for (i = 0; i < p->list->count; i++) {
+ char *line;
- line = (char *) p->list->list[i];
+ line = (char *) p->list->list[i];
- getTextSize(line, &w, &h);
+ getTextSize(line, &w, &h);
- if (x > widget->x && y > widget->y + i * 20 &&
- x < widget->x + w && y < widget->y + i * 20 + h &&
- isMouseClicked()) {
- p->select = i;
- p->fce_event(p);
- }
- }
+ if (x > widget->x && y > widget->y + i * 20 &&
+ x < widget->x + w && y < widget->y + i * 20 + h &&
+ isMouseClicked()) {
+ p->select = i;
+ p->fce_event(p);
+ }
+ }
}
-void
-destroyWidgetSelect(widget_t * widget)
+void destroyWidgetSelect(widget_t * widget)
{
- widget_select_t *p;
+ widget_select_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_SELECT);
- p = (widget_select_t *) widget->private_data;
+ p = (widget_select_t *) widget->private_data;
- destroyListItem(p->list, free);
- free(p);
- destroyWidget(widget);
+ destroyListItem(p->list, free);
+ free(p);
+ destroyWidget(widget);
}