summaryrefslogtreecommitdiff
path: root/src/widget
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget')
-rw-r--r--src/widget/widget_button.c11
-rw-r--r--src/widget/widget_buttonimage.c7
-rw-r--r--src/widget/widget_catchkey.c9
-rw-r--r--src/widget/widget_catchkey.h2
-rw-r--r--src/widget/widget_check.c8
-rw-r--r--src/widget/widget_choicegroup.c11
-rw-r--r--src/widget/widget_select.c20
-rw-r--r--src/widget/widget_statusbar.c7
-rw-r--r--src/widget/widget_textfield.c9
9 files changed, 37 insertions, 47 deletions
diff --git a/src/widget/widget_button.c b/src/widget/widget_button.c
index 26c153a..7e2d091 100644
--- a/src/widget/widget_button.c
+++ b/src/widget/widget_button.c
@@ -6,6 +6,7 @@
#include "interface.h"
#include "image.h"
#include "font.h"
+#include "mouse_buffer.h"
#include "widget.h"
#include "widget_button.h"
@@ -44,8 +45,7 @@ void button_draw(widget_t *widget)
g_button1 = image_add("button1.png", IMAGE_ALPHA, "button1", IMAGE_GROUP_BASE);
}
- if (x >= widget->x && x <= widget->x + WIDGET_BUTTON_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT) {
+ 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);
@@ -61,7 +61,6 @@ void button_event(widget_t *widget)
{
widget_button_t *p;
static int my_time = 0;
- int x, y;
assert(widget != NULL);
assert(widget->type == WIDGET_TYPE_BUTTON);
@@ -73,11 +72,7 @@ void button_event(widget_t *widget)
return;
}
- interface_get_mouse_position(&x, &y);
-
- if (x >= widget->x && x <= widget->x + WIDGET_BUTTON_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_BUTTON_HEIGHT &&
- interface_is_mouse_clicket()) {
+ 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_MSG(_("[Debug] Caught some button event\n"));
diff --git a/src/widget/widget_buttonimage.c b/src/widget/widget_buttonimage.c
index a22d4fe..134d34e 100644
--- a/src/widget/widget_buttonimage.c
+++ b/src/widget/widget_buttonimage.c
@@ -5,6 +5,7 @@
#include "interface.h"
#include "font.h"
#include "image.h"
+#include "mouse_buffer.h"
#include "widget.h"
#include "widget_buttonimage.h"
@@ -49,7 +50,6 @@ void button_image_event(widget_t *widget)
{
widget_buttonimage_t *p;
static int my_time = 0;
- int x, y;
assert(widget != NULL);
assert(widget->type == WIDGET_TYPE_BUTTONIMAGE);
@@ -61,10 +61,7 @@ void button_image_event(widget_t *widget)
return;
}
- interface_get_mouse_position(&x, &y);
-
- if (x >= widget->x && x <= widget->x + p->w &&
- y >= widget->y && y <= widget->y + p->h && interface_is_mouse_clicket()) {
+ 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);
diff --git a/src/widget/widget_catchkey.c b/src/widget/widget_catchkey.c
index b961012..b6290a6 100644
--- a/src/widget/widget_catchkey.c
+++ b/src/widget/widget_catchkey.c
@@ -4,6 +4,7 @@
#include "main.h"
#include "interface.h"
#include "font.h"
+#include "mouse_buffer.h"
#include "widget.h"
#include "widget_catchkey.h"
@@ -95,18 +96,14 @@ static int getPessAnyKey()
void catch_key_event(widget_t *widget)
{
widget_catchkey_t *p;
- int x, y;
assert(widget != NULL);
assert(widget->type == WIDGET_TYPE_CATCHKEY);
p = (widget_catchkey_t *) widget->private_data;
- interface_get_mouse_position(&x, &y);
-
- if (interface_is_mouse_clicket()) {
- if (x >= widget->x && x <= widget->x + WIDGET_CATCHKEY_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_CATCHKEY_HEIGHT) {
+ 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;
diff --git a/src/widget/widget_catchkey.h b/src/widget/widget_catchkey.h
index a030f6e..d922241 100644
--- a/src/widget/widget_catchkey.h
+++ b/src/widget/widget_catchkey.h
@@ -7,7 +7,7 @@
#define WIDGET_CATCHKEY_NOKEY -1
#define WIDGET_CATCHKEY_WIDTH 110
-#define WIDGET_CATCHKEY_HEIGHT 12
+#define WIDGET_CATCHKEY_HEIGHT 16
typedef struct widget_catchkey_struct {
int w, h;
diff --git a/src/widget/widget_check.c b/src/widget/widget_check.c
index 3d7814c..4aa6a29 100644
--- a/src/widget/widget_check.c
+++ b/src/widget/widget_check.c
@@ -4,6 +4,7 @@
#include "main.h"
#include "interface.h"
#include "image.h"
+#include "mouse_buffer.h"
#include "widget.h"
#include "widget_check.h"
@@ -50,7 +51,6 @@ void check_draw(widget_t *widget)
void check_event(widget_t *widget)
{
widget_check_t *p;
- int x, y;
assert(widget != NULL);
assert(widget->type == WIDGET_TYPE_CHECK);
@@ -62,11 +62,7 @@ void check_event(widget_t *widget)
return;
}
- interface_get_mouse_position(&x, &y);
-
- if (x >= widget->x && x <= widget->x + WIDGET_CHECK_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_CHECK_HEIGHT &&
- interface_is_mouse_clicket()) {
+ 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;
diff --git a/src/widget/widget_choicegroup.c b/src/widget/widget_choicegroup.c
index ee3894e..d325d1b 100644
--- a/src/widget/widget_choicegroup.c
+++ b/src/widget/widget_choicegroup.c
@@ -4,6 +4,7 @@
#include "main.h"
#include "interface.h"
#include "image.h"
+#include "mouse_buffer.h"
#include "widget.h"
#include "widget_choicegroup.h"
@@ -30,7 +31,6 @@ void choice_group_draw(widget_t *widget)
{
widget_choicegroup_t *p;
static image_t *g_choicegroup = NULL;
- int x, y;
int offset;
assert(widget != NULL);
@@ -38,8 +38,6 @@ void choice_group_draw(widget_t *widget)
p = (widget_choicegroup_t *) widget->private_data;
- interface_get_mouse_position(&x, &y);
-
if (g_choicegroup == NULL) {
g_choicegroup = image_add("choice.png", IMAGE_ALPHA, "choicegroup", IMAGE_GROUP_BASE);
}
@@ -107,7 +105,6 @@ void choiceGroup_set_status(widget_t *widget, bool_t status)
void choice_group_event(widget_t *widget)
{
widget_choicegroup_t *p;
- int x, y;
assert(widget != NULL);
assert(widget->type == WIDGET_TYPE_CHOICE);
@@ -119,11 +116,7 @@ void choice_group_event(widget_t *widget)
return;
}
- interface_get_mouse_position(&x, &y);
-
- if (x >= widget->x && x <= widget->x + WIDGET_CHOICEGROUP_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_CHOICEGROUP_HEIGHT &&
- interface_is_mouse_clicket()) {
+ if (mouse_buffer_is_on_area(widget->x, widget->y, WIDGET_CHOICEGROUP_WIDTH, WIDGET_CHOICEGROUP_HEIGHT, MOUSE_BUF_CLICK)) {
choice_group_set_active(widget);
}
}
diff --git a/src/widget/widget_select.c b/src/widget/widget_select.c
index d847113..a453ec4 100644
--- a/src/widget/widget_select.c
+++ b/src/widget/widget_select.c
@@ -4,6 +4,7 @@
#include "main.h"
#include "interface.h"
#include "font.h"
+#include "mouse_buffer.h"
#include "widget.h"
#include "widget_select.h"
@@ -92,7 +93,7 @@ void select_draw(widget_t *widget)
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);
@@ -103,6 +104,17 @@ void select_draw(widget_t *widget)
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);
+ }
+ }
+
}
}
@@ -125,12 +137,18 @@ void select_event(widget_t *widget)
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);
}
+*/
}
}
diff --git a/src/widget/widget_statusbar.c b/src/widget/widget_statusbar.c
index 0ee5cc0..0a9c9b3 100644
--- a/src/widget/widget_statusbar.c
+++ b/src/widget/widget_statusbar.c
@@ -7,6 +7,7 @@
#include "font.h"
#include "widget_statusbar.h"
#include "widget.h"
+#include "mouse_buffer.h"
typedef struct item_struct {
widget_t *widget;
@@ -107,7 +108,6 @@ void statusbar_draw(widget_t *widget)
void statusbar_event(widget_t *widget)
{
widget_statusbar_t *p;
- int x, y;
int i;
assert(widget != NULL);
@@ -115,8 +115,6 @@ void statusbar_event(widget_t *widget)
p = (widget_statusbar_t *) widget->private_data;
- interface_get_mouse_position(&x, &y);
-
p->selectElement = WIDGET_STATUSBAR_NONE_SELECT_ELEMENT;
for (i = 0 ; i < p->listElement->count; i++) {
@@ -124,8 +122,7 @@ void statusbar_event(widget_t *widget)
item = (item_t *) p->listElement->list[i];
- if (x >= item->widget->x && x <= item->widget->x + item->widget->w &&
- y >= item->widget->y && y <= item->widget->y + item->widget->h) {
+ if (mouse_buffer_is_on_area(item->widget->x, item->widget->y, item->widget->w, item->widget->h, MOUSE_BUF_MOTION)) {
p->selectElement = i;
}
}
diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c
index be0f016..1711ad9 100644
--- a/src/widget/widget_textfield.c
+++ b/src/widget/widget_textfield.c
@@ -5,6 +5,7 @@
#include "interface.h"
#include "font.h"
#include "image.h"
+#include "mouse_buffer.h"
#include "widget.h"
#include "widget_textfield.h"
@@ -300,18 +301,14 @@ static void readKey(widget_textfield_t *p)
void text_field_event(widget_t *widget)
{
widget_textfield_t *p;
- int x, y;
assert(widget != NULL);
assert(widget->type == WIDGET_TYPE_TEXTFILED);
p = (widget_textfield_t *) widget->private_data;
- interface_get_mouse_position(&x, &y);
-
- if (interface_is_mouse_clicket()) {
- if (x >= widget->x && x <= widget->x + WIDGET_TEXTFIELD_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_TEXTFIELD_HEIGHT) {
+ 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();