summaryrefslogtreecommitdiff
path: root/src/widget/widget_select.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-28 16:38:35 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-28 16:38:35 +0000
commit2d776fcd61be168e1ff0ff2e4a5e71835e7cea19 (patch)
tree7cf274897bf540d5332d446f583ffd066e4e2e1d /src/widget/widget_select.c
parentb877ae23ac5d380ab3aa48d7724045cf4883b186 (diff)
- prekopanie adresarovej struktury, prva cast
git-svn-id: http://opensvn.csie.org/tuxanci_ng@77 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/widget/widget_select.c')
-rw-r--r--src/widget/widget_select.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/widget/widget_select.c b/src/widget/widget_select.c
new file mode 100644
index 0000000..f51239c
--- /dev/null
+++ b/src/widget/widget_select.c
@@ -0,0 +1,97 @@
+
+#include <stdlib.h>
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/font.h"
+#include "widget_select.h"
+
+/*
+typedef struct widget_select
+{
+ int x, y;
+ int w, h;
+ list_t *list;
+ void (*fce_event)(void *);
+} widget_select_t;
+*/
+
+widget_select_t* newWidgetSelect(int x, int y, void (*fce_event)(void *))
+{
+ widget_select_t *new;
+
+ new = malloc( sizeof(widget_select_t) );
+ new->x = x;
+ new->y = y;
+ new->select = 0;
+ new->fce_event = fce_event;
+ new->list = newList();
+
+ return new;
+}
+
+void addToWidgetSelect(widget_select_t *p, char *s)
+{
+ addList(p->list, strdup(s) );
+}
+
+void drawWidgetSelect(widget_select_t *p)
+{
+ int x, y, w, h;
+ int i;
+
+ getMousePosition(&x, &y);
+
+ for( i = 0 ; i < p->list->count ; i++ )
+ {
+ char *line;
+
+ line = (char *)p->list->list[i];
+
+ getTextSize(line, &w, &h);
+
+ if( x > p->x && y > p->y + i*20 && x < p->x+w && y < p->y + i*20 + h )
+ {
+ drawFont(line, p->x, p->y + i*20, COLOR_YELLOW);
+ }
+ else
+ {
+ if( p->select == i )
+ {
+ drawFont(line, p->x, p->y + i*20, COLOR_RED);
+ }
+ else
+ {
+ drawFont(line, p->x, p->y + i*20, COLOR_WHITE);
+ }
+ }
+ }
+}
+
+void eventWidgetSelect(widget_select_t *p)
+{
+ int x, y, w, h;
+ int i;
+
+ getMousePosition(&x, &y);
+
+ for( i = 0 ; i < p->list->count ; i++ )
+ {
+ char *line;
+
+ line = (char *)p->list->list[i];
+
+ getTextSize(line, &w, &h);
+
+ if( x > p->x && y > p->y + i*20 && x < p->x+w && y < p->y + i*20 + h && isMouseClicked() )
+ {
+ p->select = i;
+ p->fce_event(p);
+ }
+ }
+}
+
+void destroyWidgetSelect(widget_select_t *p)
+{
+ destroyListItem(p->list, free);
+ free(p);
+}