summaryrefslogtreecommitdiff
path: root/src/widget
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget')
-rw-r--r--src/widget/CMakeLists.txt7
-rw-r--r--src/widget/widget.c102
-rw-r--r--src/widget/widget.h36
-rw-r--r--src/widget/widget_button.c101
-rw-r--r--src/widget/widget_button.h23
-rw-r--r--src/widget/widget_buttonimage.c82
-rw-r--r--src/widget/widget_buttonimage.h24
-rw-r--r--src/widget/widget_catchkey.c141
-rw-r--r--src/widget/widget_catchkey.h26
-rw-r--r--src/widget/widget_check.c114
-rw-r--r--src/widget/widget_check.h25
-rw-r--r--src/widget/widget_choicegroup.c143
-rw-r--r--src/widget/widget_choicegroup.h29
-rw-r--r--src/widget/widget_container.c108
-rw-r--r--src/widget/widget_container.h18
-rw-r--r--src/widget/widget_image.c51
-rw-r--r--src/widget/widget_image.h17
-rw-r--r--src/widget/widget_label.c66
-rw-r--r--src/widget/widget_label.h22
-rw-r--r--src/widget/widget_select.c168
-rw-r--r--src/widget/widget_select.h24
-rw-r--r--src/widget/widget_statusbar.c146
-rw-r--r--src/widget/widget_statusbar.h24
-rw-r--r--src/widget/widget_textfield.c284
-rw-r--r--src/widget/widget_textfield.h39
25 files changed, 0 insertions, 1820 deletions
diff --git a/src/widget/CMakeLists.txt b/src/widget/CMakeLists.txt
deleted file mode 100644
index 2e93cef..0000000
--- a/src/widget/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-###############################################################################
-# tuxanci/src/*/CMakeLists.txt
-###############################################################################
-# Generate source_code files from .c files we find in directory
-###############################################################################
-MacroAddSources()
-###############################################################################
diff --git a/src/widget/widget.c b/src/widget/widget.c
deleted file mode 100644
index 2c0651b..0000000
--- a/src/widget/widget.c
+++ /dev/null
@@ -1,102 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_buttonimage.h"
-#include "widget_textfield.h"
-#include "widget_catchkey.h"
-#include "widget_check.h"
-#include "widget_choicegroup.h"
-#include "widget_image.h"
-#include "widget_select.h"
-#include "widget_statusbar.h"
-
-widget_t *widget_new(int type, int x, int y, int w, int h, void *private_data)
-{
- widget_t *new;
-
- new = malloc(sizeof(widget_t));
- new->type = type;
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->private_data = private_data;
-
- return new;
-}
-
-void widget_set_location(widget_t *p, int x, int y)
-{
- p->x = x;
- p->y = y;
-}
-
-void widget_get_location(widget_t *p, int *x, int *y)
-{
- if (x != NULL) {
- *x = p->x;
- }
-
- if (y != NULL) {
- *y = p->y;
- }
-}
-
-void widget_get_size(widget_t *p, int w, int h)
-{
- p->w = w;
- p->h = h;
-}
-
-void widget_set_size(widget_t *p, int *w, int *h)
-{
- if (w != NULL) {
- *w = p->w;
- }
-
- if (h != NULL) {
- *h = p->h;
- }
-}
-
-void widget_draw(widget_t *p)
-{
- switch (p->type) {
- case WIDGET_TYPE_LABEL: label_draw(p); break;
- case WIDGET_TYPE_BUTTON: button_draw(p); break;
- case WIDGET_TYPE_BUTTONIMAGE: button_image_draw(p); break;
- case WIDGET_TYPE_TEXTFILED: text_field_draw(p); break;
- case WIDGET_TYPE_CATCHKEY: catch_key_draw(p); break;
- case WIDGET_TYPE_CHECK: check_draw(p); break;
- case WIDGET_TYPE_CHOICE: choice_group_draw(p); break;
- case WIDGET_TYPE_IMAGE: wid_image_draw(p); break;
- case WIDGET_TYPE_SELECT: select_draw(p); break;
- case WIDGET_TYPE_STATUSBAR: statusbar_draw(p); break;
- }
-}
-
-void widget_event(widget_t *p)
-{
- switch (p->type) {
- case WIDGET_TYPE_LABEL: label_event(p); break;
- case WIDGET_TYPE_BUTTON: button_event(p); break;
- case WIDGET_TYPE_BUTTONIMAGE: button_image_event(p); break;
- case WIDGET_TYPE_TEXTFILED: text_field_event(p); break;
- case WIDGET_TYPE_CATCHKEY: catch_key_event(p); break;
- case WIDGET_TYPE_CHECK: check_event(p); break;
- case WIDGET_TYPE_CHOICE: choice_group_event(p); break;
- case WIDGET_TYPE_IMAGE: wid_image_event(p); break;
- case WIDGET_TYPE_SELECT: select_event(p); break;
- case WIDGET_TYPE_STATUSBAR: statusbar_event(p); break;
- }
-}
-
-void widget_destroy(widget_t *p)
-{
- free(p);
-}
diff --git a/src/widget/widget.h b/src/widget/widget.h
deleted file mode 100644
index b5898c2..0000000
--- a/src/widget/widget.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef WIDGET_H
-#define WIDGET_H
-
-#include "main.h"
-
-#define WIDGET_TYPE_LABEL 1
-#define WIDGET_TYPE_BUTTON 2
-#define WIDGET_TYPE_BUTTONIMAGE 3
-#define WIDGET_TYPE_TEXTFILED 4
-#define WIDGET_TYPE_CATCHKEY 5
-#define WIDGET_TYPE_CHECK 6
-#define WIDGET_TYPE_CHOICE 7
-#define WIDGET_TYPE_IMAGE 8
-#define WIDGET_TYPE_SELECT 9
-#define WIDGET_TYPE_STATUSBAR 10
-#define WIDGET_TYPE_CONTAINER 11
-
-#define WIDGET_NONE_VALUE -1
-
-typedef struct widget_struct {
- int type;
- int x, y;
- int w, h;
- void *private_data;
-} widget_t;
-
-extern widget_t *widget_new(int type, int x, int y, int w, int h, void *private_data);
-extern void widget_set_location(widget_t *p, int x, int y);
-extern void widget_get_location(widget_t *p, int *x, int *y);
-extern void widget_get_size(widget_t *p, int w, int h);
-extern void widget_set_size(widget_t *p, int *w, int *h);
-extern void widget_draw(widget_t *p);
-extern void widget_event(widget_t *p);
-extern void widget_destroy(widget_t *p);
-
-#endif /* WIDGET_H */
diff --git a/src/widget/widget_button.c b/src/widget/widget_button.c
deleted file mode 100644
index 9d80294..0000000
--- a/src/widget/widget_button.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-
-#include "interface.h"
-#include "image.h"
-#include "font.h"
-#include "mouse_buffer.h"
-
-#include "widget.h"
-#include "widget_button.h"
-
-widget_t *button_new(char *text, int x, int y, void (*fce_event) (void *))
-{
- widget_button_t *new;
-
- new = malloc(sizeof(widget_button_t));
- new->text = strdup(text);
- new->fce_event = fce_event;
- font_text_size(text, &(new->w), &(new->h));
-
- return widget_new(WIDGET_TYPE_BUTTON, x, y,
- WIDGET_BUTTON_WIDTH, WIDGET_BUTTON_HEIGHT, new);
-}
-
-void button_draw(widget_t *widget)
-{
- widget_button_t *p;
- static image_t *g_button0 = NULL;
- static image_t *g_button1 = NULL;
- int x, y;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_BUTTON);
-
- p = (widget_button_t *) widget->private_data;
- interface_get_mouse_position(&x, &y);
-
- if (g_button0 == NULL) {
- g_button0 = image_add("button0.png", IMAGE_ALPHA, "button0", IMAGE_GROUP_BASE);
- }
-
- if (g_button1 == NULL) {
- g_button1 = image_add("button1.png", IMAGE_ALPHA, "button1", IMAGE_GROUP_BASE);
- }
-
- if (mouse_buffer_is_on_area(widget->x, widget->y, WIDGET_BUTTON_WIDTH,
- WIDGET_BUTTON_HEIGHT, MOUSE_BUF_MOTION)) {
- image_draw(g_button1, widget->x, widget->y, 0, 0,
- g_button0->w, g_button0->h);
- } else {
- image_draw(g_button0, widget->x, widget->y, 0, 0,
- g_button0->w, g_button0->h);
- }
-
- /*font_draw(p->text, p->x+WIDGET_BUTTON_WIDTH/2-p->w/2, p->y+p->h/2, COLOR_WHITE);*/
- font_draw(p->text, widget->x + WIDGET_BUTTON_WIDTH / 2 - p->w / 2,
- widget->y + WIDGET_BUTTON_HEIGHT / 2 - p->h / 2,
- COLOR_WHITE);
-}
-
-void button_event(widget_t *widget)
-{
- widget_button_t *p;
- static int my_time = 0;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_BUTTON);
-
- p = (widget_button_t *) widget->private_data;
-
- if (my_time > 0) {
- my_time--;
- return;
- }
-
- if (mouse_buffer_is_on_area(widget->x, widget->y, WIDGET_BUTTON_WIDTH,
- WIDGET_BUTTON_HEIGHT, MOUSE_BUF_CLICK)) {
- my_time = WIDGET_BUTTON_TIME;
-
- debug("Caught some button event");
-
- p->fce_event(widget);
- }
-}
-
-void button_destroy(widget_t *widget)
-{
- widget_button_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_BUTTON);
-
- p = (widget_button_t *) widget->private_data;
-
- free(p->text);
- free(p);
-
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_button.h b/src/widget/widget_button.h
deleted file mode 100644
index 2ec4ae3..0000000
--- a/src/widget/widget_button.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef WIDGET_BUTTON_H
-#define WIDGET_BUTTON_H
-
-#include "main.h"
-#include "widget.h"
-
-#define WIDGET_BUTTON_TIME 10
-
-#define WIDGET_BUTTON_WIDTH 125
-#define WIDGET_BUTTON_HEIGHT 36
-
-typedef struct widget_button {
- char *text;
- int w, h;
- void (*fce_event) (void *);
-} widget_button_t;
-
-extern widget_t *button_new(char *text, int x, int y, void (*fce_event) (void *));
-extern void button_draw(widget_t *widget);
-extern void button_event(widget_t *widget);
-extern void button_destroy(widget_t *widget);
-
-#endif /* WIDGET_BUTTON_H */
diff --git a/src/widget/widget_buttonimage.c b/src/widget/widget_buttonimage.c
deleted file mode 100644
index 134d34e..0000000
--- a/src/widget/widget_buttonimage.c
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "interface.h"
-#include "font.h"
-#include "image.h"
-#include "mouse_buffer.h"
-
-#include "widget.h"
-#include "widget_buttonimage.h"
-
-widget_t *button_image_new(image_t *image, int x, int y, void (*fce_event) (void *))
-{
- widget_buttonimage_t *new;
-
- new = malloc(sizeof(widget_buttonimage_t));
- new->image = image;
- new->w = image->w / 2;
- new->h = image->h;
- new->active = 0;
- new->fce_event = fce_event;
-
- return widget_new(WIDGET_TYPE_BUTTONIMAGE, x, y, new->w, new->h, new);
-}
-
-void button_image_set_active(widget_t *widget, bool_t active)
-{
- widget_buttonimage_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_BUTTONIMAGE);
-
- p = (widget_buttonimage_t *) widget->private_data;
- p->active = active;
-}
-
-void button_image_draw(widget_t *widget)
-{
- widget_buttonimage_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_BUTTONIMAGE);
-
- p = (widget_buttonimage_t *) widget->private_data;
- image_draw(p->image, widget->x, widget->y, p->active *p->w, 0, p->w, p->h);
-}
-
-void button_image_event(widget_t *widget)
-{
- widget_buttonimage_t *p;
- static int my_time = 0;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_BUTTONIMAGE);
-
- p = (widget_buttonimage_t *) widget->private_data;
-
- if (my_time > 0) {
- my_time--;
- return;
- }
-
- if (mouse_buffer_is_on_area(widget->x, widget->y, p->w, p->h, MOUSE_BUF_CLICK)) {
- my_time = WIDGET_BUTTONIMAGE_TIME;
- p->active = 1;
- p->fce_event(widget);
- }
-}
-
-void button_image_destroy(widget_t *widget)
-{
- widget_buttonimage_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_BUTTONIMAGE);
-
- p = (widget_buttonimage_t *) widget->private_data;
-
- free(p);
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_buttonimage.h b/src/widget/widget_buttonimage.h
deleted file mode 100644
index fff2658..0000000
--- a/src/widget/widget_buttonimage.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef WIDGET_BUTTONIMAGE_H
-#define WIDGET_BUTTONIMAGE_H
-
-#include "main.h"
-#include "image.h"
-#include "widget.h"
-
-#define WIDGET_BUTTONIMAGE_TIME 10
-
-typedef struct widget_buttonimageimage {
- int w, h;
- int active;
- image_t *image;
- void (*fce_event) (void *);
-} widget_buttonimage_t;
-
-extern widget_t *button_image_new(image_t *image, int x, int y, void (*fce_event) (void *));
-
-extern void button_image_set_active(widget_t *widget, bool_t active);
-extern void button_image_draw(widget_t *widget);
-extern void button_image_event(widget_t *widget);
-extern void button_image_destroy(widget_t *widget);
-
-#endif /* WIDGET_BUTTONIMAGE_H */
diff --git a/src/widget/widget_catchkey.c b/src/widget/widget_catchkey.c
deleted file mode 100644
index 814cfa1..0000000
--- a/src/widget/widget_catchkey.c
+++ /dev/null
@@ -1,141 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "interface.h"
-#include "font.h"
-#include "mouse_buffer.h"
-
-#include "widget.h"
-#include "widget_catchkey.h"
-
-widget_t *catch_key_new(int key, int x, int y, void *event)
-{
- widget_catchkey_t *new;
-
- new = malloc(sizeof(widget_catchkey_t));
- new->key = key;
- new->fce_event = event;
- new->active = FALSE;
-
- return widget_new(WIDGET_TYPE_CATCHKEY, x, y, WIDGET_CATCHKEY_WIDTH,
- WIDGET_CATCHKEY_HEIGHT, new);
-}
-
-int catch_key_get(widget_t *widget)
-{
- widget_catchkey_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
-
- p = (widget_catchkey_t *) widget->private_data;
-
- return p->key;
-}
-
-void catch_key_set(widget_t *widget, int key)
-{
- widget_catchkey_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
-
- p = (widget_catchkey_t *) widget->private_data;
-
- p->key = key;
-}
-
-void catch_key_draw(widget_t *widget)
-{
- widget_catchkey_t *p;
- char *name;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
-
- p = (widget_catchkey_t *) widget->private_data;
- name = NULL;
-
- if (p->key != WIDGET_CATCHKEY_NOKEY) {
- name = (char *) SDL_GetKeyName(p->key);
- }
-
- if (name == NULL) {
- name = "no key";
- }
-
- if (p->active) {
- font_draw(name, widget->x, widget->y, COLOR_RED);
- } else {
- font_draw(name, widget->x, widget->y, COLOR_WHITE);
- }
-}
-
-static int getPressAnyKey()
-{
- Uint8 *mapa;
- int i;
-
- mapa = SDL_GetKeyState(NULL);
-
- for (i = SDLK_FIRST; i <= SDLK_COMPOSE; i++) {
- if (i == SDLK_NUMLOCK || /* black key */
- i == SDLK_CAPSLOCK ||
- i == SDLK_SCROLLOCK) {
- continue;
- }
-
- if (mapa[i] == SDL_PRESSED) {
- return i;
- }
- }
-
- return WIDGET_CATCHKEY_NOKEY;
-}
-
-void catch_key_event(widget_t *widget)
-{
- widget_catchkey_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
-
- p = (widget_catchkey_t *) widget->private_data;
-
- if (mouse_buffer_is_on_area(0, 0, 0, 0, MOUSE_BUF_AREA_NONE|MOUSE_BUF_CLICK)) {
- if (mouse_buffer_is_on_area(widget->x, widget->y,
- WIDGET_CATCHKEY_WIDTH,
- WIDGET_CATCHKEY_HEIGHT,
- MOUSE_BUF_CLICK)) {
- p->active = TRUE;
- } else {
- p->active = FALSE;
- }
- }
-
- if (p->active == TRUE) {
- int key;
-
- key = getPressAnyKey();
-
- if (key != WIDGET_CATCHKEY_NOKEY) {
- p->key = key;
- p->fce_event(widget);
- p->active = FALSE;
- }
- }
-}
-
-void catch_key_destroy(widget_t *widget)
-{
- widget_catchkey_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
-
- p = (widget_catchkey_t *) widget->private_data;
-
- free(p);
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_catchkey.h b/src/widget/widget_catchkey.h
deleted file mode 100644
index d922241..0000000
--- a/src/widget/widget_catchkey.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef WIDGET_CATCHKEY_H
-#define WIDGET_CATCHKEY_H
-
-#include "main.h"
-#include "widget.h"
-
-#define WIDGET_CATCHKEY_NOKEY -1
-
-#define WIDGET_CATCHKEY_WIDTH 110
-#define WIDGET_CATCHKEY_HEIGHT 16
-
-typedef struct widget_catchkey_struct {
- int w, h;
- int key;
- bool_t active;
- void (*fce_event) (void *p);
-} widget_catchkey_t;
-
-extern widget_t *catch_key_new(int key, int x, int y, void *event);
-extern int catch_key_get(widget_t *p);
-extern void catch_key_set(widget_t *p, int key);
-extern void catch_key_draw(widget_t *p);
-extern void catch_key_event(widget_t *p);
-extern void catch_key_destroy(widget_t *p);
-
-#endif /* WIDGET_CATCHKEY_H */
diff --git a/src/widget/widget_check.c b/src/widget/widget_check.c
deleted file mode 100644
index f39c6ad..0000000
--- a/src/widget/widget_check.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "interface.h"
-#include "image.h"
-#include "mouse_buffer.h"
-
-#include "widget.h"
-#include "widget_check.h"
-
-widget_t *check_new(int x, int y, bool_t status, void (*fce_event) (void *))
-{
- widget_check_t *new;
-
- new = malloc(sizeof(widget_check_t));
- new->time = 0;
- new->status = status;
- new->fce_event = fce_event;
-
- return widget_new(WIDGET_TYPE_CHECK, x, y, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT, new);
-}
-
-void check_draw(widget_t *widget)
-{
- widget_check_t *p;
- static image_t *g_check = NULL;
- int x, y;
- int offset;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHECK);
-
- p = (widget_check_t *) widget->private_data;
-
- interface_get_mouse_position(&x, &y);
-
- if (g_check == NULL) {
- g_check = image_add("check.png", IMAGE_ALPHA, "check", IMAGE_GROUP_BASE);
- }
-
- if (p->status == TRUE) {
- offset = 0;
- } else {
- offset = WIDGET_CHECK_WIDTH;
- }
-
- image_draw(g_check, widget->x, widget->y, offset, 0, WIDGET_CHECK_WIDTH, WIDGET_CHECK_HEIGHT);
-}
-
-void check_event(widget_t *widget)
-{
- widget_check_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHECK);
-
- p = (widget_check_t *) widget->private_data;
-
- if (p->time > 0) {
- p->time--;
- return;
- }
-
- if (mouse_buffer_is_on_area(widget->x, widget->y, WIDGET_CHECK_WIDTH,
- WIDGET_CHECK_HEIGHT, MOUSE_BUF_CLICK)) {
- 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(widget);
- }
- }
-}
-
-bool_t check_get_status(widget_t *widget)
-{
- widget_check_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHECK);
-
- p = (widget_check_t *) widget->private_data;
-
- return p->status;
-}
-
-void check_set_status(widget_t *widget, bool_t status)
-{
- widget_check_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHECK);
-
- p = (widget_check_t *) widget->private_data;
- p->status = status;
-}
-
-void check_destroy(widget_t *widget)
-{
- widget_check_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHECK);
-
- p = (widget_check_t *) widget->private_data;
- free(p);
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_check.h b/src/widget/widget_check.h
deleted file mode 100644
index 3df8c23..0000000
--- a/src/widget/widget_check.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef WIDGET_CHECK_H
-#define WIDGET_CHECK_H
-
-#include "main.h"
-#include "widget.h"
-
-#define WIDGET_CHECK_TIME_SWITCH_STATUS 5
-
-#define WIDGET_CHECK_WIDTH 25
-#define WIDGET_CHECK_HEIGHT 25
-
-typedef struct widget_check {
- bool_t status;
- int time;
- void (*fce_event) (void *);
-} widget_check_t;
-
-extern widget_t *check_new(int x, int y, bool_t status, void (*fce_event) (void *));
-extern void check_draw(widget_t *widget);
-extern void check_event(widget_t *widget);
-extern bool_t check_get_status(widget_t *widget);
-extern void check_set_status(widget_t *widget, bool_t status);
-extern void check_destroy(widget_t *widget);
-
-#endif /* WIDGET_CHECK_H */
diff --git a/src/widget/widget_choicegroup.c b/src/widget/widget_choicegroup.c
deleted file mode 100644
index 2c3338f..0000000
--- a/src/widget/widget_choicegroup.c
+++ /dev/null
@@ -1,143 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "interface.h"
-#include "image.h"
-#include "mouse_buffer.h"
-
-#include "widget.h"
-#include "widget_choicegroup.h"
-
-widget_t *choice_group_new(int x, int y, bool_t status, list_t *list, void (*fce_event) (void *))
-{
- widget_choicegroup_t *new;
- widget_t *widget;
-
- new = malloc(sizeof(widget_choicegroup_t));
- new->time = 0;
- new->status = status;
- new->fce_event = fce_event;
- new->list = list;
-
- widget = widget_new(WIDGET_TYPE_CHOICE, x, y, WIDGET_CHOICEGROUP_WIDTH,
- WIDGET_CHOICEGROUP_HEIGHT, new);
-
- list_add(new->list, widget);
-
- return widget;
-}
-
-void choice_group_draw(widget_t *widget)
-{
- widget_choicegroup_t *p;
- static image_t *g_choicegroup = NULL;
- int offset;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHOICE);
-
- p = (widget_choicegroup_t *) widget->private_data;
-
- if (g_choicegroup == NULL) {
- g_choicegroup = image_add("choice.png", IMAGE_ALPHA, "choicegroup", IMAGE_GROUP_BASE);
- }
-
- if (p->status == TRUE) {
- offset = 0;
- } else {
- offset = WIDGET_CHOICEGROUP_WIDTH;
- }
-
- image_draw(g_choicegroup, widget->x, widget->y, offset, 0,
- WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT);
-}
-
-void choice_group_set_active(widget_t *widget)
-{
- widget_choicegroup_t *p;
- int i;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHOICE);
-
- p = (widget_choicegroup_t *) widget->private_data;
-
- for (i = 0; i < p->list->count; i++) {
- widget_t *this;
- widget_choicegroup_t *thisChoice;
-
- this = (widget_t *) p->list->list[i];
- thisChoice = (widget_choicegroup_t *) this->private_data;
-
- if (widget == this) {
- thisChoice->status = TRUE;
- thisChoice->time = WIDGET_CHOICEGROUP_TIME_SWITCH_STATUS;
- thisChoice->fce_event(p);
- } else {
- thisChoice->status = FALSE;
- }
- }
-}
-
-bool_t choice_group_get_status(widget_t *widget)
-{
- widget_choicegroup_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHOICE);
-
- p = (widget_choicegroup_t *) widget->private_data;
-
- return p->status;
-}
-
-void choiceGroup_set_status(widget_t *widget, bool_t status)
-{
- widget_choicegroup_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHOICE);
-
- p = (widget_choicegroup_t *) widget->private_data;
- p->status = status;
-}
-
-void choice_group_event(widget_t *widget)
-{
- widget_choicegroup_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHOICE);
-
- p = (widget_choicegroup_t *) widget->private_data;
-
- if (p->time > 0) {
- p->time--;
- return;
- }
-
- if (mouse_buffer_is_on_area(widget->x, widget->y,
- WIDGET_CHOICEGROUP_WIDTH,
- WIDGET_CHOICEGROUP_HEIGHT,
- MOUSE_BUF_CLICK)) {
- choice_group_set_active(widget);
- }
-}
-
-void choice_group_destroy(widget_t *widget)
-{
- widget_choicegroup_t *p;
- int my_index;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CHOICE);
-
- p = (widget_choicegroup_t *) widget->private_data;
- my_index = list_search(p->list, widget);
- assert(my_index != -1);
- list_del(p->list, my_index);
-
- free(p);
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_choicegroup.h b/src/widget/widget_choicegroup.h
deleted file mode 100644
index 9bdadfc..0000000
--- a/src/widget/widget_choicegroup.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef WIDGET_CHOICEGROUP_H
-#define WIDGET_CHOICEGROUP_H
-
-#include "main.h"
-#include "list.h"
-#include "widget.h"
-
-#define WIDGET_CHOICEGROUP_TIME_SWITCH_STATUS 5
-
-#define WIDGET_CHOICEGROUP_WIDTH 25
-#define WIDGET_CHOICEGROUP_HEIGHT 25
-
-typedef struct widget_choicegroup {
- bool_t status;
- int time;
- void (*fce_event) (void *);
- list_t *list;
-} widget_choicegroup_t;
-
-extern widget_t *choice_group_new(int x, int y, bool_t status, list_t *list, void (*fce_event) (void *));
-
-extern void choice_group_draw(widget_t *p);
-extern void choice_group_set_active(widget_t *widget);
-extern bool_t choice_group_get_status(widget_t *widget);
-extern void choiceGroup_set_status(widget_t *widget, bool_t status);
-extern void choice_group_event(widget_t *p);
-extern void choice_group_destroy(widget_t *p);
-
-#endif /* WIDGET_CHOICEGROUP_H */
diff --git a/src/widget/widget_container.c b/src/widget/widget_container.c
deleted file mode 100644
index 5de850c..0000000
--- a/src/widget/widget_container.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "widget.h"
-#include "widget_container.h"
-
-widget_t *widget_container_new(int x, int y, int w, int h)
-{
- widget_container_t *new;
-
- new = malloc(sizeof(widget_container_t));
- new->listWidget = list_new();
-
- return widget_new(WIDGET_TYPE_CONTAINER, x, y, w, h, new);
-}
-
-void widget_container_add(widget_t *widget, widget_t *widget_add)
-{
- widget_container_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CONTAINER);
-
- p = (widget_container_t *) widget->private_data;
- list_add(p->listWidget, widget_add);
-}
-
-void widget_set_layout_table(widget_t *widget, int countW, int countH, int w, int h)
-{
- widget_container_t *p;
- int i, j;
- int count;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CONTAINER);
-
- p = (widget_container_t *) widget->private_data;
-
- count = 0;
-
- for (i = 0; i < countH; i++) {
- for (j = 0; j < countW; j++) {
- widget_t *widget_tmp;
-
- if (count >= p->listWidget->count) {
- break;
- }
-
- widget_tmp = (widget_t *) p->listWidget->list[count];
-
- widget_set_location(widget_tmp, widget->x + j * w, widget->y + i * h);
- count++;
- }
- }
-}
-
-void widget_container_draw(widget_t *widget)
-{
- widget_container_t *p;
- int i;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CONTAINER);
-
- p = (widget_container_t *) widget->private_data;
-
- for (i = 0; i < p->listWidget->count; i++) {
- widget_t *widget;
-
- widget = (widget_t *) p->listWidget->list[i];
-
- widget_draw(widget);
- }
-}
-
-void widget_container_event(widget_t *widget)
-{
- widget_container_t *p;
- int i;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CONTAINER);
-
- p = (widget_container_t *) widget->private_data;
-
- for (i = 0; i < p->listWidget->count; i++) {
- widget_t *widget;
-
- widget = (widget_t *) p->listWidget->list[i];
-
- widget_event(widget);
- }
-}
-
-void widget_container_destroy(widget_t *widget)
-{
- widget_container_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CONTAINER);
-
- p = (widget_container_t *) widget->private_data;
- list_destroy(p->listWidget);
- free(p);
-
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_container.h b/src/widget/widget_container.h
deleted file mode 100644
index 8d9320c..0000000
--- a/src/widget/widget_container.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef WIDGET_CONTAINER_H
-#define WIDGET_CONTAINER_H
-
-#include "list.h"
-#include "widget.h"
-
-typedef struct widget_container {
- list_t *listWidget;
-} widget_container_t;
-
-extern widget_t *widget_container_new(int x, int y, int w, int h);
-extern void widget_container_add(widget_t *widget, widget_t *widget_add);
-extern void widget_set_layout_table(widget_t *widget, int countW, int countH, int w, int h);
-extern void widget_container_draw(widget_t *widget);
-extern void widget_container_event(widget_t *widget);
-extern void widget_container_destroy(widget_t *widget);
-
-#endif /* WIDGET_CONTAINER_H */
diff --git a/src/widget/widget_image.c b/src/widget/widget_image.c
deleted file mode 100644
index 51f935a..0000000
--- a/src/widget/widget_image.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include <stdlib.h>
-#include "main.h"
-#include "image.h"
-#include "interface.h"
-#include "font.h"
-
-#include "widget.h"
-#include "widget_image.h"
-
-widget_t *wid_image_new(int x, int y, image_t *image)
-{
- widget_image_t *new;
-
- new = malloc(sizeof(widget_image_t));
- new->image = image;
-
- return widget_new(WIDGET_TYPE_IMAGE, x, y, image->w, image->h, new);
-}
-
-void wid_image_draw(widget_t *widget)
-{
- widget_image_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_IMAGE);
-
- p = (widget_image_t *) widget->private_data;
- image_draw(p->image, widget->x, widget->y, 0, 0, p->image->w, p->image->h);
-}
-
-void wid_image_event(widget_t *widget)
-{
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_IMAGE);
-}
-
-void wid_image_destroy(widget_t *widget)
-{
- widget_image_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_IMAGE);
-
- p = (widget_image_t *) widget->private_data;
-
- free(p);
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_image.h b/src/widget/widget_image.h
deleted file mode 100644
index ad7104d..0000000
--- a/src/widget/widget_image.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef WIDGET_IMAGE_H
-#define WIDGET_IMAGE_H
-
-#include "main.h"
-#include "interface.h"
-#include "widget.h"
-
-typedef struct widget_image {
- image_t *image;
-} widget_image_t;
-
-extern widget_t *wid_image_new(int x, int y, image_t *image);
-extern void wid_image_draw(widget_t *p);
-extern void wid_image_event(widget_t *p);
-extern void wid_image_destroy(widget_t *p);
-
-#endif /* WIDGET_IMAGE_H */
diff --git a/src/widget/widget_label.c b/src/widget/widget_label.c
deleted file mode 100644
index b696302..0000000
--- a/src/widget/widget_label.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "interface.h"
-#include "font.h"
-#include "widget_label.h"
-#include "widget.h"
-
-widget_t *label_new(char *text, int x, int y, int bind)
-{
- widget_label_t *new;
-
- new = malloc(sizeof(widget_label_t));
- new->text = strdup(text);
- new->bind = bind;
- font_text_size(text, &(new->w), &(new->h));
-
- return widget_new(WIDGET_TYPE_LABEL, x, y, new->w, new->h, new);
-}
-
-void label_draw(widget_t *widget)
-{
- widget_label_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_LABEL);
-
- p = (widget_label_t *) widget->private_data;
-
- switch (p->bind) {
- case WIDGET_LABEL_RIGHT:
- font_draw(p->text, widget->x - p->w, widget->y + p->h / 2, COLOR_WHITE);
- break;
- case WIDGET_LABEL_LEFT:
- font_draw(p->text, widget->x, widget->y + widget->h / 2, COLOR_WHITE);
- break;
- case WIDGET_LABEL_CENTER:
- font_draw(p->text, widget->x - p->w / 2, widget->y + p->h / 2, COLOR_WHITE);
- break;
- default:
- fatal("Unknown dimension for label placement");
- break;
- }
-}
-
-void label_event(widget_t *widget)
-{
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_LABEL);
-}
-
-void label_destroy(widget_t *widget)
-{
- widget_label_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_LABEL);
-
- p = (widget_label_t *) widget->private_data;
-
- free(p->text);
- free(p);
-
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_label.h b/src/widget/widget_label.h
deleted file mode 100644
index bd1b531..0000000
--- a/src/widget/widget_label.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef WIDGET_LABEL_H
-#define WIDGET_LABEL_H
-
-#include "main.h"
-#include "widget.h"
-
-#define WIDGET_LABEL_RIGHT 1
-#define WIDGET_LABEL_LEFT 2
-#define WIDGET_LABEL_CENTER 3
-
-typedef struct widget_label {
- int w, h;
- char *text;
- int bind;
-} widget_label_t;
-
-extern widget_t *label_new(char *text, int x, int y, int bind);
-extern void label_draw(widget_t *widget);
-extern void label_event(widget_t *widget);
-extern void label_destroy(widget_t *widget);
-
-#endif /* WIDGET_LABEL_H */
diff --git a/src/widget/widget_select.c b/src/widget/widget_select.c
deleted file mode 100644
index 13ce483..0000000
--- a/src/widget/widget_select.c
+++ /dev/null
@@ -1,168 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "interface.h"
-#include "font.h"
-#include "mouse_buffer.h"
-
-#include "widget.h"
-#include "widget_select.h"
-
-widget_t *select_new(int x, int y, void (*fce_event) (void *))
-{
- widget_select_t *new;
-
- new = malloc(sizeof(widget_select_t));
- new->select = -1;
- new->fce_event = fce_event;
- new->list = list_new();
-
- return widget_new(WIDGET_TYPE_SELECT, x, y, 0, 0, new);
-}
-
-char *select_get_item(widget_t *widget)
-{
- widget_select_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- p = (widget_select_t *) widget->private_data;
-
- if (p->select == -1) {
- return NULL;
- }
-
- return (char *) p->list->list[p->select];
-}
-
-int select_get_index(widget_t *widget)
-{
- widget_select_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- p = (widget_select_t *) widget->private_data;
-
- return p->select;
-}
-
-void select_add(widget_t *widget, char *s)
-{
- widget_select_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- p = (widget_select_t *) widget->private_data;
-
- list_add(p->list, strdup(s));
-}
-
-void select_remove_all(widget_t *widget)
-{
- widget_select_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- p = (widget_select_t *) widget->private_data;
-
- while (p->list->count > 0) {
- list_del_item(p->list, 0, free);
- }
-}
-
-void select_draw(widget_t *widget)
-{
- widget_select_t *p;
- int x, y, w, h;
- int i;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- interface_get_mouse_position(&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];
-
- font_text_size(line, &w, &h);
-/*
- if (x > widget->x && y > widget->y + i * 20 &&
- x < widget->x + w && y < widget->y + i * 20 + h) {
- font_draw(line, widget->x, widget->y + i * 20, COLOR_YELLOW);
- } else {
- if (p->select == i) {
- font_draw(line, widget->x, widget->y + i * 20, COLOR_RED);
- } else {
- font_draw(line, widget->x, widget->y + i * 20, COLOR_WHITE);
- }
- }
-*/
- if (mouse_buffer_is_on_area(widget->x, widget->y + i * 20,
- w, h, MOUSE_BUF_MOTION)) {
- font_draw(line, widget->x, widget->y + i * 20, COLOR_YELLOW);
- } else {
- if (p->select == i) {
- font_draw(line, widget->x, widget->y + i * 20, COLOR_RED);
- } else {
- font_draw(line, widget->x, widget->y + i * 20, COLOR_WHITE);
- }
- }
-
- }
-}
-
-void select_event(widget_t *widget)
-{
- widget_select_t *p;
- int x, y, w, h;
- int i;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- p = (widget_select_t *) widget->private_data;
- interface_get_mouse_position(&x, &y);
-
- for (i = 0; i < p->list->count; i++) {
- char *line;
-
- line = (char *) p->list->list[i];
-
- font_text_size(line, &w, &h);
-
- if (mouse_buffer_is_on_area(widget->x, widget->y+i * 20, w, h, MOUSE_BUF_CLICK)) {
- 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 &&
- interface_is_mouse_clicket()) {
- p->select = i;
- p->fce_event(p);
- }
-*/
- }
-}
-
-void select_destroy(widget_t *widget)
-{
- widget_select_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_SELECT);
-
- p = (widget_select_t *) widget->private_data;
-
- list_destroy_item(p->list, free);
- free(p);
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_select.h b/src/widget/widget_select.h
deleted file mode 100644
index 11116a9..0000000
--- a/src/widget/widget_select.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef WIDGET_SELECT_H
-#define WIDGET_SELECT_H
-
-#include "main.h"
-#include "list.h"
-#include "widget.h"
-
-typedef struct widget_select {
- int w, h;
- list_t *list;
- int select;
- void (*fce_event) (void *);
-} widget_select_t;
-
-extern widget_t *select_new(int x, int y, void (*fce_event) (void *));
-extern char *select_get_item(widget_t *widget);
-extern int select_get_index(widget_t *widget);
-extern void select_add(widget_t *widget, char *s);
-extern void select_remove_all(widget_t *widget);
-extern void select_draw(widget_t *widget);
-extern void select_event(widget_t *widget);
-extern void select_destroy(widget_t *widget);
-
-#endif /* WIDGET_SELECT_H */
diff --git a/src/widget/widget_statusbar.c b/src/widget/widget_statusbar.c
deleted file mode 100644
index c2b48a4..0000000
--- a/src/widget/widget_statusbar.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "interface.h"
-#include "image.h"
-#include "font.h"
-#include "widget_statusbar.h"
-#include "widget.h"
-#include "mouse_buffer.h"
-
-typedef struct item_struct {
- widget_t *widget;
- list_t *text;
-} item_t;
-
-static item_t *item_new(widget_t *widget, char *text)
-{
- item_t *item;
- char *copy;
- char *s;
-
- assert(widget != NULL);
- assert(text != NULL);
-
- item = malloc(sizeof(item_t));
- item->widget = widget;
- item->text = list_new();
-
- copy = strdup(text);
-
- s = strtok(copy, "\n");
-
- while(s != NULL) {
- list_add(item->text, strdup(s));
- s = strtok(NULL, "\n");
- }
-
- free(copy);
-
- return item;
-}
-
-static void item_destroy(item_t *item)
-{
- assert(item != NULL);
-
- list_destroy_item(item->text, free);
- free(item);
-}
-
-widget_t *statusbar_new(int x, int y)
-{
- widget_statusbar_t *new;
-
- new = malloc(sizeof(widget_statusbar_t));
- new->selectElement = WIDGET_STATUSBAR_NONE_SELECT_ELEMENT;
- new->listElement = list_new();
-
- return widget_new(WIDGET_TYPE_STATUSBAR, x, y, WIDGET_STATUSBAR_WIDTH, WIDGET_STATUSBAR_HEIGHT, new);
-}
-
-void statusbar_add(widget_t *widget, widget_t *widget_catch, char *text)
-{
- widget_statusbar_t *p;
-
- assert(widget != NULL);
- assert(widget_catch != NULL);
- assert(text != NULL);
- assert(widget->type == WIDGET_TYPE_STATUSBAR);
-
- p = (widget_statusbar_t *) widget->private_data;
-
- list_add(p->listElement, item_new(widget_catch, text));
-}
-
-void statusbar_draw(widget_t *widget)
-{
- static image_t *g_image = NULL;
- widget_statusbar_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_STATUSBAR);
-
- p = (widget_statusbar_t *) widget->private_data;
-
- if (g_image == NULL) {
- g_image = image_add("frame.png", IMAGE_ALPHA, "frame", IMAGE_GROUP_BASE);
- }
-
- image_draw(g_image, widget->x, widget->y, 0, 0, g_image->w, g_image->h);
-
- if (p->selectElement != WIDGET_STATUSBAR_NONE_SELECT_ELEMENT) {
- item_t *item;
- int i;
-
- item = (item_t *) p->listElement->list[p->selectElement];
-
- for (i = 0 ; i < item->text->count; i++) {
- char *s;
-
- s = (char *) item->text->list[i];
- font_draw(s, widget->x, widget->y + i * (font_get_size() + 5), COLOR_WHITE);
- }
- }
-}
-
-void statusbar_event(widget_t *widget)
-{
- widget_statusbar_t *p;
- int i;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_STATUSBAR);
-
- p = (widget_statusbar_t *) widget->private_data;
-
- p->selectElement = WIDGET_STATUSBAR_NONE_SELECT_ELEMENT;
-
- for (i = 0 ; i < p->listElement->count; i++) {
- item_t *item;
-
- item = (item_t *) p->listElement->list[i];
-
- if (mouse_buffer_is_on_area(item->widget->x, item->widget->y,
- item->widget->w, item->widget->h,
- MOUSE_BUF_MOTION)) {
- p->selectElement = i;
- }
- }
-}
-
-void statusbar_destroy(widget_t *widget)
-{
- widget_statusbar_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_STATUSBAR);
-
- p = (widget_statusbar_t *) widget->private_data;
-
- list_destroy_item(p->listElement, item_destroy);
- free(p);
-
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_statusbar.h b/src/widget/widget_statusbar.h
deleted file mode 100644
index 217c1a5..0000000
--- a/src/widget/widget_statusbar.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef WIDGET_STATUSBAR_H
-#define WIDGET_STATUSBAR_H
-
-#include "main.h"
-#include "widget.h"
-#include "list.h"
-
-typedef struct widget_statusbar {
- list_t *listElement;
- int selectElement;
-} widget_statusbar_t;
-
-#define WIDGET_STATUSBAR_NONE_SELECT_ELEMENT -1
-
-#define WIDGET_STATUSBAR_WIDTH 250
-#define WIDGET_STATUSBAR_HEIGHT 65
-
-extern widget_t *statusbar_new(int x, int y);
-extern void statusbar_add(widget_t *widget, widget_t *widget_catch, char *text);
-extern void statusbar_draw(widget_t *widget);
-extern void statusbar_event(widget_t *widget);
-extern void statusbar_destroy(widget_t *widget);
-
-#endif /* WIDGET_STATUSBAR_H */
diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c
deleted file mode 100644
index 53d03a3..0000000
--- a/src/widget/widget_textfield.c
+++ /dev/null
@@ -1,284 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-#include <SDL_keyboard.h>
-
-#include "main.h"
-#include "interface.h"
-#include "font.h"
-#include "image.h"
-#include "mouse_buffer.h"
-
-#include "widget.h"
-#include "widget_textfield.h"
-
-#include "keyboardBuffer.h"
-
-widget_t *text_field_new(char *text, int filter, int x, int y)
-{
- widget_textfield_t *new;
-
- new = malloc(sizeof(widget_textfield_t));
- memset(new, 0, sizeof(widget_textfield_t));
-
- strcpy(new->text, text);
- new->time = 0;
- new->timeBlick = 0;
- new->atime = 0;
- new->active = FALSE;
- new->filter = filter;
- font_text_size(text, &new->w, &new->h);
-
- return widget_new(WIDGET_TYPE_TEXTFILED, x, y, WIDGET_TEXTFIELD_WIDTH, WIDGET_TEXTFIELD_HEIGHT, new);
-}
-
-static void drawBackground(widget_t *widget)
-{
- static image_t *g_textfield0 = NULL;
- static image_t *g_textfield1 = NULL;
- widget_textfield_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_TEXTFILED);
-
- p = (widget_textfield_t *) widget->private_data;
-
- if (g_textfield0 == NULL) {
- g_textfield0 = image_add("textfield0.png", IMAGE_ALPHA, "textfiled0", IMAGE_GROUP_BASE);
- }
-
- if (g_textfield1 == NULL) {
- g_textfield1 = image_add("textfield1.png", IMAGE_ALPHA, "textfiled1", IMAGE_GROUP_BASE);
- }
-
- if (p->active) {
- image_draw(g_textfield1, widget->x, widget->y, 0, 0, g_textfield1->w, g_textfield1->h);
- } else {
- image_draw(g_textfield0, widget->x, widget->y, 0, 0, g_textfield0->w, g_textfield0->h);
- }
-}
-
-static void drawText(widget_t *widget)
-{
- char str[STR_SIZE];
- widget_textfield_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_TEXTFILED);
-
- p = (widget_textfield_t *) widget->private_data;
-
- strcpy(str, p->text);
-
- if (p->timeBlick > WIDGET_TEXTFIELD_TIME_BLICK_CURSOR / 2 && p->active == TRUE) {
- strcat(str, "\f");
- }
-
- p->timeBlick++;
-
- if (p->timeBlick == WIDGET_TEXTFIELD_TIME_BLICK_CURSOR) {
- p->timeBlick = 0;
- }
-
- /*
- font_draw(str, p->x+WIDGET_TEXTFIELD_TEXT_OFFSET_X, p->y+p->h/2, COLOR_WHITE);
- printf("p->y: %d\nheight: %d\n p->h: %d\n", p->y, WIDGET_TEXTFIELD_HEIGHT, p->h);
- */
-
- font_draw(str, widget->x + WIDGET_TEXTFIELD_TEXT_OFFSET_X,
- widget->y + WIDGET_TEXTFIELD_HEIGHT / 2 - p->h / 2,
- COLOR_WHITE);
-}
-
-void text_field_draw(widget_t *widget)
-{
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_TEXTFILED);
-
- drawBackground(widget);
- drawText(widget);
-}
-
-void text_field_set_text(widget_t *widget, char *text)
-{
- widget_textfield_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_TEXTFILED);
-
- p = (widget_textfield_t *) widget->private_data;
-
- memset(p->text, 0, STR_SIZE);
- strcpy(p->text, text);
- font_text_size(text, &p->w, &p->h);
-}
-
-char *text_field_get_text(widget_t *widget)
-{
- widget_textfield_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_TEXTFILED);
-
- p = (widget_textfield_t *) widget->private_data;
- return p->text;
-}
-
-static void checkText(widget_textfield_t *p, unsigned len)
-{
- unsigned int i;
-
- for (i = 0; i < len; i++) {
- char c;
- bool_t isDel;
-
- c = p->text[i];
- isDel = TRUE;
-
- switch (p->filter) {
- case WIDGET_TEXTFIELD_FILTER_ALL:
- isDel = FALSE;
- break;
-
- case WIDGET_TEXTFIELD_FILTER_NUM:
- if (c >= '0' && c <= '9') {
- isDel = FALSE;
- }
- break;
-
- case WIDGET_TEXTFIELD_FILTER_ALPHANUM:
- if ((c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z') ||
- (c == '_' || c == '-')) {
- isDel = FALSE;
- }
- break;
-
- case WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN:
- if ((c >= '0' && c <= '9') ||
- (c == '.' || c == ':' || c == '-') ||
- (c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z')) {
- isDel = FALSE;
- }
- break;
-
- default:
- fatal("Bad text filter!");
- break;
- }
-
- if (isDel) {
- memmove(p->text + i, p->text + i + 1, len - i);
- len = strlen(p->text);
- i--;
- }
- }
-
- font_text_size(p->text, &p->w, &p->h);
-}
-
-
-static void readKey(widget_textfield_t *p)
-{
- int len;
- int i;
-
- if (p->active == FALSE) {
- return;
- }
-
- len = strlen(p->text);
-
- for (i = 0; keyboard_buffer_is_any_key(); i++) {
- SDL_keysym k = keyboard_buffer_pop();
-
- char *name = (char *) SDL_GetKeyName(k.sym);
-
- if (!name) {
- continue;
- }
-
- if (len >= STR_SIZE) {
- break;
- }
-
- if (k.sym == SDLK_RETURN) {
- break;
- }
-
- char c = '\0';
-
- switch (strlen(name)) {
- case 1:
- c = name[0];
- break;
-
- case 3:
- c = name[1];
- break;
- }
-
- if ((k.unicode & 0xFF80) == 0) {
- c = k.unicode & 0x7F;
- }
-
- if (k.sym == SDLK_SPACE || k.sym == SDLK_TAB) {
- c = ' ';
- } else if (k.sym == SDLK_BACKSPACE) {
- if (len > 0) {
- p->text[len-1] = '\0';
- checkText(p, len);
- }
-
- break;
- }
-
- if (c == '\0' || p->w > WIDGET_TEXTFIELD_WIDTH - 40) {
- continue;
- }
-
- p->text[len] = c;
-
- len++;
- checkText(p, len);
- }
-}
-
-void text_field_event(widget_t *widget)
-{
- widget_textfield_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_TEXTFILED);
-
- p = (widget_textfield_t *) widget->private_data;
-
- if (mouse_buffer_is_on_area(0, 0, 0, 0, MOUSE_BUF_AREA_NONE|MOUSE_BUF_CLICK)) {
- if (mouse_buffer_is_on_area(widget->x, widget->y,
- WIDGET_TEXTFIELD_WIDTH,
- WIDGET_TEXTFIELD_HEIGHT,
- MOUSE_BUF_MOTION)) {
- p->active = TRUE;
- interface_enable_keyboard_buffer();
- keyboard_buffer_clear();
- } else {
- p->active = FALSE;
- }
- }
-
- readKey(p);
-}
-
-void text_field_destroy(widget_t *widget)
-{
- widget_textfield_t *p;
-
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_TEXTFILED);
-
- p = (widget_textfield_t *) widget->private_data;
-
- free(p);
- widget_destroy(widget);
-}
diff --git a/src/widget/widget_textfield.h b/src/widget/widget_textfield.h
deleted file mode 100644
index ef55b5f..0000000
--- a/src/widget/widget_textfield.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef WIDGET_TEXTFIELD_H
-#define WIDGET_TEXTFIELD_H
-
-#include "main.h"
-#include "widget.h"
-
-#define WIDGET_TEXTFIELD_WIDTH 175
-#define WIDGET_TEXTFIELD_HEIGHT 36
-
-#define WIDGET_TEXTFIELD_TEXT_OFFSET_X 10
-
-#define WIDGET_TEXTFIELD_TIME_MULTIPLE 10
-#define WIDGET_TEXTFIELD_TIME_READ_KEY 2
-#define WIDGET_TEXTFIELD_TIME_BLICK_CURSOR 20
-
-#define WIDGET_TEXTFIELD_FILTER_ALL 0
-#define WIDGET_TEXTFIELD_FILTER_NUM 2
-#define WIDGET_TEXTFIELD_FILTER_ALPHANUM 3
-#define WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN 4
-
-typedef struct widget_textfield {
- int w, h;
- int canWrite;
- int timeBlick;
- int time;
- int atime;
- int filter;
- char text[STR_SIZE];
- bool_t active;
-} widget_textfield_t;
-
-extern widget_t *text_field_new(char *text, int filter, int x, int y);
-extern void text_field_set_text(widget_t *widget, char *text);
-extern char *text_field_get_text(widget_t *widget);
-extern void text_field_draw(widget_t *widget);
-extern void text_field_event(widget_t *widget);
-extern void text_field_destroy(widget_t *widget);
-
-#endif /* WIDGET_TEXTFIELD_H */