You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.4 KiB
75 lines
2.4 KiB
/* $Id: gui_button.c,v 1.3 2013/02/24 00:39:59 steffen Exp $ */
|
|
/***************************************************************************
|
|
* gui_button.c
|
|
*
|
|
* Copyright (C) 2013 Steffen Pohle
|
|
* steffen@gulpe.de
|
|
***************************************************************************
|
|
* basic windows functions
|
|
***************************************************************************/
|
|
|
|
/*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* main.c is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
|
|
#include "osmroute.h"
|
|
#include "draw.h"
|
|
#include "gui.h"
|
|
#include "system.h"
|
|
|
|
/****************************************************************************
|
|
* button
|
|
*/
|
|
void gui_button_draw (GUIButton *button) {
|
|
struct line_style ls;
|
|
|
|
ls.width = 1.0;
|
|
ls.c = ls.borderc = color[COLOR_white][3];
|
|
|
|
draw_polygonstart ();
|
|
draw_polygonadd (button->x, button->y);
|
|
draw_polygonadd (button->x, button->y + button->h);
|
|
draw_polygonadd (button->x + button->w, button->y + button->h);
|
|
draw_polygonadd (button->x + button->w, button->y);
|
|
draw_polygonfinish (currentwin->screen, ls, *button->col, 1);
|
|
gfx_draw_text (currentwin->screen, button->x + 2, button->y + 2, button->caption, button->textcol);
|
|
};
|
|
|
|
|
|
GUIButton *gui_button_new (char *caption, int x, int y, int w, int h) {
|
|
GUIButton *item = (GUIButton*) ml_malloc (sizeof (GUIButton));
|
|
|
|
if (caption == NULL) item->caption[0] = 0;
|
|
else strncpy (item->caption, caption, GUI_TEXTLEN);
|
|
item->x = x;
|
|
item->y = y;
|
|
item->w = w;
|
|
item->h = h;
|
|
item->col = &color[COLOR_white][1];
|
|
item->textcol = &color[COLOR_white][3];
|
|
item->callback_clicked = NULL;
|
|
item->callback_draw = NULL;
|
|
|
|
return item;
|
|
};
|
|
|
|
|
|
void gui_button_event (GUIButton *button, GUIEvent event) {
|
|
if (button->callback_clicked != NULL && event.event == EGUI_MOUSEPRESSED) {
|
|
button->callback_clicked (event.mousepos.x-button->x, event.mousepos.y-button->y);
|
|
}
|
|
};
|
|
|