summaryrefslogtreecommitdiff
path: root/src/widget/widget_check.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_check.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_check.c')
-rw-r--r--src/widget/widget_check.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/widget/widget_check.c b/src/widget/widget_check.c
new file mode 100644
index 0000000..feb2414
--- /dev/null
+++ b/src/widget/widget_check.c
@@ -0,0 +1,84 @@
+
+#include <stdlib.h>
+#include "base/main.h"
+#include "client/interface.h"
+#include "client/image.h"
+#include "widget_check.h"
+
+widget_check_t* newWidgetCheck(int x, int y, bool_t status, void (*fce_event)(void *))
+{
+ widget_check_t *new;
+
+ new = malloc( sizeof(widget_check_t) );
+ new->x = x;
+ new->y = y;
+ new->time = 0;
+ new->status = status;
+ new->fce_event = fce_event;
+
+ return new;
+}
+
+void drawWidgetCheck(widget_check_t *p)
+{
+ static SDL_Surface *g_check = NULL;
+ int x, y;
+ int offset;
+
+ getMousePosition(&x, &y);
+
+ if( g_check == NULL )
+ {
+ g_check = addImageData("check.png", IMAGE_ALPHA, "check", IMAGE_GROUP_BASE);
+ }
+
+ if( p->status == TRUE )
+ {
+ offset = 0;
+ }
+ else
+ {
+ offset = WIDGET_CHECK_WIDTH;
+ }
+
+ drawImage(g_check, p->x, p->y, offset, 0, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT);
+}
+
+void eventWidgetCheck(widget_check_t *p)
+{
+ int x, y;
+
+ if( p->time > 0 )
+ {
+ p->time--;
+ return;
+ }
+
+ getMousePosition(&x, &y);
+
+ if( x >= p->x && x <= p->x+WIDGET_CHECK_WIDTH &&
+ y >= p->y && y <= p->y+WIDGET_CHECK_HEIGHT &&
+ isMouseClicked() )
+ {
+ if( p->status == TRUE )
+ {
+ p->status = FALSE;
+ p->time = WIDGET_CHECK_TIME_SWITCH_STATUS;
+ }
+ else
+ {
+ p->status = TRUE;
+ p->time = WIDGET_CHECK_TIME_SWITCH_STATUS;
+ }
+
+ if( p->fce_event != NULL )
+ {
+ p->fce_event(p);
+ }
+ }
+}
+
+void destroyWidgetCheck(widget_check_t *p)
+{
+ free(p);
+}