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.
210 lines
5.0 KiB
210 lines
5.0 KiB
/***************************************************************************
|
|
* gui.h
|
|
*
|
|
* 2011-03-10
|
|
* Copyright 2011 Steffen Pohle
|
|
* steffen@gulpe.de
|
|
****************************************************************************/
|
|
|
|
/*
|
|
* 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 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program 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, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#ifndef _GUI_H_
|
|
#define _GUI_H_
|
|
|
|
#include "osmroute.h"
|
|
|
|
#define GUI_TEXTLEN 256
|
|
#define GUI_MAX_ITEM 256
|
|
|
|
enum {
|
|
EGUI_NONE,
|
|
EGUI_KEYCHAR,
|
|
EGUI_MOUSEMOVE,
|
|
EGUI_MOUSEPRESSED,
|
|
EGUI_MOUSERELEASED
|
|
};
|
|
|
|
enum {
|
|
GUI_NONE,
|
|
GUI_BUTTON,
|
|
GUI_LIST,
|
|
GUI_ENTRY,
|
|
GUI_CHECKBOX,
|
|
GUI_LABEL
|
|
};
|
|
|
|
/*
|
|
* styles for the windows..
|
|
*/
|
|
#define WGUI_S_VCENTER 0x0003
|
|
#define WGUI_S_VLEFT 0x0002
|
|
#define WGUI_S_VRIGHT 0x0001
|
|
#define WGUI_S_HCENTER 0x000C
|
|
#define WGUI_S_HTOP 0x0004
|
|
#define WGUI_S_HBOTTOM 0x0008
|
|
#define WGUI_S_NOTITLE 0x0010
|
|
// #define WGUI_S_**** 0x0080
|
|
#define WGUI_S_MODAL 0x0100
|
|
|
|
|
|
struct _GUIItem_ {
|
|
int type;
|
|
int x, y, w, h;
|
|
char data[];
|
|
} typedef GUIItem;
|
|
|
|
|
|
struct _GUIEvent_ {
|
|
int event;
|
|
uint32_t keyval; // needed for utf8 (max was 32bit?)
|
|
iPoint mousepos;
|
|
int mousebtn;
|
|
} typedef GUIEvent;
|
|
|
|
|
|
struct _GUIButton_ {
|
|
char caption[GUI_TEXTLEN];
|
|
struct color *col;
|
|
struct color *textcol;
|
|
void (*callback_clicked) (int x, int y);
|
|
void (*func_draw) (GUIItem *item);
|
|
} typedef GUIButton;
|
|
|
|
|
|
struct _GUIList_ {
|
|
char **data;
|
|
int vs; // first element to draw
|
|
int selected;
|
|
void (*callback_selectitem) (int nr);
|
|
} typedef GUIList;
|
|
|
|
|
|
struct {
|
|
char text[GUI_TEXTLEN];
|
|
struct color *textcol;
|
|
} typedef GUILabel;
|
|
|
|
|
|
struct {
|
|
char text[GUI_TEXTLEN];
|
|
int curpos;
|
|
int overwrite;
|
|
void (*callback_enter) ();
|
|
void (*callback_changed) ();
|
|
} typedef GUIEntry;
|
|
|
|
|
|
struct {
|
|
char text[GUI_TEXTLEN];
|
|
int checked;
|
|
void (*callback_changed) ();
|
|
} typedef GUICheckbox;
|
|
|
|
|
|
struct _GUIWindow_ {
|
|
void (*callback_close) ();
|
|
|
|
struct _GUIWindow_ *parent;
|
|
struct image *screen;
|
|
int screen_changed;
|
|
|
|
char title[GUI_TEXTLEN];
|
|
int x;
|
|
int y;
|
|
int w;
|
|
int h;
|
|
int style;
|
|
|
|
void (*callback_clicked) (int x, int y);
|
|
|
|
GUIItem *items[GUI_MAX_ITEM];
|
|
GUIItem *focus;
|
|
} typedef GUIWindow;
|
|
|
|
#define GUI_SOFTKEYB_X 11
|
|
#define GUI_SOFTKEYB_Y 3
|
|
enum {
|
|
GUI_SOFTKEYB_MODE_NORM = 0,
|
|
GUI_SOFTKEYB_MODE_SHIFT,
|
|
GUI_SOFTKEYB_MODE_SYMBOL,
|
|
|
|
GUI_SOFTKEYB_MODE_MAX
|
|
};
|
|
|
|
struct _GUISoftkeyboard_ {
|
|
int mode;
|
|
int enabled;
|
|
int linepos[2][4]; /* y positions of lines */
|
|
int btnpos[2][4]; /* holds position keys: Shift, Symbols, Space, Close */
|
|
struct image *screen;
|
|
char keys[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X];
|
|
} typedef GUISoftkeyboard;
|
|
|
|
extern GUIWindow *currentwin;
|
|
extern GUISoftkeyboard *softkeyb;
|
|
|
|
extern void gui_show (GUIWindow *win);
|
|
extern void gui_draw ();
|
|
extern void gui_close ();
|
|
extern int gui_event (GUIEvent event);
|
|
extern void gui_event_addmousepos (GUIEvent *event, iPoint pos, int neg);
|
|
extern void gui_set_focus (GUIItem *item);
|
|
|
|
extern void gui_window_new (GUIWindow *win, int w, int h, char *title);
|
|
extern void gui_window_close (GUIWindow *win);
|
|
extern void gui_window_item_add (GUIWindow *win, GUIItem *item);
|
|
|
|
/* softkeyboard functions. */
|
|
extern void gui_softkeyb_show (int enable);
|
|
extern void gui_softkeyb_draw ();
|
|
|
|
/* button functions */
|
|
#define GUI_BUTTON_T(_item_) ((GUIButton*)(_item_)->data)
|
|
extern void gui_button_draw (GUIItem *item);
|
|
extern void gui_button_event (GUIItem *item, GUIEvent *event);
|
|
extern GUIItem *gui_button_new (char *name, int x, int y, int w, int h);
|
|
|
|
/* label functions */
|
|
#define GUI_LABEL_T(_item_) ((GUILabel*)(_item_)->data)
|
|
extern void gui_label_draw (GUIItem *item);
|
|
extern GUIItem *gui_label_new (char *text, int x, int y);
|
|
|
|
/* entry functions */
|
|
#define GUI_ENTRY_T(_item_) ((GUIEntry*)(_item_)->data)
|
|
extern void gui_entry_draw (GUIItem *item);
|
|
extern void gui_entry_event (GUIItem *item, GUIEvent *event);
|
|
extern GUIItem *gui_entry_new (char *text, int x, int y, int w, int h);
|
|
|
|
/* list functions */
|
|
#define GUI_LIST_T(_item_) ((GUIList*)(_item_)->data)
|
|
extern void gui_list_draw (GUIItem *item);
|
|
extern void gui_list_event (GUIItem *item, GUIEvent *event);
|
|
extern void gui_list_setselect (GUIItem *item);
|
|
extern GUIItem *gui_list_new (int x, int y, int w, int h);
|
|
|
|
/**************************************************************************
|
|
* gui windows
|
|
*/
|
|
extern void gui_search_show ();
|
|
extern void gui_fav_show ();
|
|
extern void gui_mainmenu_show ();
|
|
extern void gui_buttons_show ();
|
|
extern void gui_config_show ();
|
|
extern void gpswin_show ();
|
|
|
|
#endif
|