summaryrefslogtreecommitdiff
path: root/src/widget/widget_catchkey.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_catchkey.c
parentcb9deba915dd7b114eeb76601eb1c8b07c1ba90f (diff)
Changed style of the code to the K&R standard
Diffstat (limited to 'src/widget/widget_catchkey.c')
-rw-r--r--src/widget/widget_catchkey.c173
1 files changed, 82 insertions, 91 deletions
diff --git a/src/widget/widget_catchkey.c b/src/widget/widget_catchkey.c
index fd3389e..37fab55 100644
--- a/src/widget/widget_catchkey.c
+++ b/src/widget/widget_catchkey.c
@@ -9,141 +9,132 @@
#include "widget.h"
#include "widget_catchkey.h"
-widget_t *
-newWidgetCatchkey(int key, int x, int y, void *event)
+widget_t *newWidgetCatchkey(int key, int x, int y, void *event)
{
- widget_catchkey_t *new;
+ widget_catchkey_t *new;
- new = malloc(sizeof(widget_catchkey_t));
- new->key = key;
- new->fce_event = event;
- new->active = FALSE;
+ new = malloc(sizeof(widget_catchkey_t));
+ new->key = key;
+ new->fce_event = event;
+ new->active = FALSE;
- return newWidget(WIDGET_TYPE_CATCHKEY, x, y, WIDGET_CATCHKEY_WIDTH,
- WIDGET_CATCHKEY_HEIGHT, new);
+ return newWidget(WIDGET_TYPE_CATCHKEY, x, y, WIDGET_CATCHKEY_WIDTH,
+ WIDGET_CATCHKEY_HEIGHT, new);
}
-int
-getWidgetCatchKey(widget_t * widget)
+int getWidgetCatchKey(widget_t * widget)
{
- widget_catchkey_t *p;
+ widget_catchkey_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_CATCHKEY);
- p = (widget_catchkey_t *) widget->private_data;
+ p = (widget_catchkey_t *) widget->private_data;
- return p->key;
+ return p->key;
}
-void
-setWidgetCatchKey(widget_t * widget, int key)
+void setWidgetCatchKey(widget_t * widget, int key)
{
- widget_catchkey_t *p;
+ widget_catchkey_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_CATCHKEY);
- p = (widget_catchkey_t *) widget->private_data;
+ p = (widget_catchkey_t *) widget->private_data;
- p->key = key;
+ p->key = key;
}
-void
-drawWidgetCatchkey(widget_t * widget)
+void drawWidgetCatchkey(widget_t * widget)
{
- widget_catchkey_t *p;
- char *name;
+ widget_catchkey_t *p;
+ char *name;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_CATCHKEY);
- p = (widget_catchkey_t *) widget->private_data;
- name = NULL;
+ p = (widget_catchkey_t *) widget->private_data;
+ name = NULL;
- if (p->key != WIDGET_CATCHKEY_NOKEY) {
- name = (char *) SDL_GetKeyName(p->key);
- }
+ if (p->key != WIDGET_CATCHKEY_NOKEY) {
+ name = (char *) SDL_GetKeyName(p->key);
+ }
- if (name == NULL) {
- name = "no key";
- }
+ if (name == NULL) {
+ name = "no key";
+ }
- if (p->active) {
- drawFont(name, widget->x, widget->y, COLOR_RED);
- }
- else {
- drawFont(name, widget->x, widget->y, COLOR_WHITE);
- }
+ if (p->active) {
+ drawFont(name, widget->x, widget->y, COLOR_RED);
+ } else {
+ drawFont(name, widget->x, widget->y, COLOR_WHITE);
+ }
}
-static int
-getPessAnyKey()
+static int getPessAnyKey()
{
- Uint8 *mapa;
- int i;
+ Uint8 *mapa;
+ int i;
- mapa = SDL_GetKeyState(NULL);
+ 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;
- }
+ 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;
- }
- }
+ if (mapa[i] == SDL_PRESSED) {
+ return i;
+ }
+ }
- return WIDGET_CATCHKEY_NOKEY;
+ return WIDGET_CATCHKEY_NOKEY;
}
-void
-eventWidgetCatchkey(widget_t * widget)
+void eventWidgetCatchkey(widget_t * widget)
{
- widget_catchkey_t *p;
- int x, y;
+ widget_catchkey_t *p;
+ int x, y;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_CATCHKEY);
- p = (widget_catchkey_t *) widget->private_data;
+ p = (widget_catchkey_t *) widget->private_data;
- getMousePosition(&x, &y);
+ getMousePosition(&x, &y);
- if (isMouseClicked()) {
- if (x >= widget->x && x <= widget->x + WIDGET_CATCHKEY_WIDTH &&
- y >= widget->y && y <= widget->y + WIDGET_CATCHKEY_HEIGHT) {
- p->active = TRUE;
- }
- else {
- p->active = FALSE;
- }
- }
+ if (isMouseClicked()) {
+ if (x >= widget->x && x <= widget->x + WIDGET_CATCHKEY_WIDTH &&
+ y >= widget->y && y <= widget->y + WIDGET_CATCHKEY_HEIGHT) {
+ p->active = TRUE;
+ } else {
+ p->active = FALSE;
+ }
+ }
- if (p->active == TRUE) {
- int key;
+ if (p->active == TRUE) {
+ int key;
- key = getPessAnyKey();
+ key = getPessAnyKey();
- if (key != WIDGET_CATCHKEY_NOKEY) {
- p->key = key;
- p->fce_event(widget);
- }
- }
+ if (key != WIDGET_CATCHKEY_NOKEY) {
+ p->key = key;
+ p->fce_event(widget);
+ }
+ }
}
-void
-destroyWidgetCatchkey(widget_t * widget)
+void destroyWidgetCatchkey(widget_t * widget)
{
- widget_catchkey_t *p;
+ widget_catchkey_t *p;
- assert(widget != NULL);
- assert(widget->type == WIDGET_TYPE_CATCHKEY);
+ assert(widget != NULL);
+ assert(widget->type == WIDGET_TYPE_CATCHKEY);
- p = (widget_catchkey_t *) widget->private_data;
+ p = (widget_catchkey_t *) widget->private_data;
- free(p);
- destroyWidget(widget);
+ free(p);
+ destroyWidget(widget);
}