/* Copyright (c) 2000, Flarg Inc, All Rights Reserved */ /* * $Header: /usr/local/cvsroot/flarg/website/tui.h,v 1.1 2001/07/15 20:59:34 wex Exp $ * * $Log: tui.h,v $ * Revision 1.1 2001/07/15 20:59:34 wex * Added website * * Revision 1.12 2000/10/06 03:48:46 wex * Slightly better events, widget windows capture other events. * * Revision 1.11 2000/10/05 10:29:41 wex * Added labels, titles, and textports. Fixed parsing bug and radio look. * * Revision 1.10 2000/10/02 09:28:34 wex * Minor bug fixes. * * Revision 1.9 2000/10/02 05:56:00 wex * Added radio buttons, fixed minor bugs. * * Revision 1.8 2000/10/01 18:27:37 wex * Cleanups for Windows. * * Revision 1.7 2000/09/30 18:00:24 wex * Handle more visual types. Menubars resize correctly. * * Revision 1.6 2000/09/30 15:59:14 wex * Saving and loading generated header files. * * Revision 1.5 2000/09/28 16:06:27 wex * Added TUI_APPLICATION, beginning layout and code output. * * Revision 1.4 2000/09/26 16:31:38 wex * Events working under Windows. * * Revision 1.3 2000/09/25 02:35:02 wex * Creating windows and widgets in win32, events still broken. * * Revision 1.2 2000/09/24 03:13:08 wex * Initial changes to support WIN32 * * Revision 1.1.1.1 2000/09/16 23:38:08 wex * Initial revision * */ #ifndef _TUI_H_ #define _TUI_H_ #ifdef TUI_WIN32 #include #include #ifdef __cplusplus #define EXPORT extern "C" __declspec (dllexport) #else #define EXPORT __declspec (dllexport) #endif #else /* TUI_WIN32 */ #define EXPORT #endif /* TUI_XWIN -- no need to export callbacks */ #define TUI_ERR_NONE 0 #define TUI_ERR_MEMORY 1 #define TUI_ERR_DISPLAY 2 #define TUI_ERR_WINDOW 3 #define TUI_ERR_EVENT 4 #define TUI_ERR_NO_WINDOW 5 #define TUI_ERR_VISUAL 6 #define TUI_ERR_FILENAME 7 #define TUI_ERR_OPEN 8 #define TUI_ERR_VERSION 9 extern int TUI_errno; char *TUI_error_string(void); typedef struct tui TUI; typedef struct tui_widget TUI_WIDGET; typedef struct tui_application TUI_APPLICATION; typedef struct tui_widget_info { TUI_WIDGET *widget; int x, y; int state; void *user_data; } TUI_WIDGET_INFO; typedef enum { TUI_EVENT_NONE, TUI_EVENT_KEY, TUI_EVENT_BUTTON, TUI_EVENT_MOTION, } TUI_EVENT; typedef struct { TUI_WIDGET *window; TUI_WIDGET *widget; TUI_EVENT type; char key; int x; int y; int state; void *user_data; } TUI_EVENT_INFO; typedef enum { TUI_NONE, TUI_WINDOW, TUI_BUTTON, TUI_RADIO_BUTTON, TUI_LABEL, TUI_TITLE, TUI_TEXTPORT, TUI_MENUBAR, TUI_PULLDOWN, TUI_MENUITEM, TUI_OGLWINDOW, } TUI_WIDGET_TYPE; /* Call this once for your application at startup */ TUI_APPLICATION *TUI_APPLICATION_create( #ifdef TUI_WIN32 HINSTANCE hInstance #endif ); int TUI_construct(TUI_APPLICATION *app, void *app_structure, const char *layout); TUI *TUI_create(TUI_APPLICATION *app); void TUI_destroy(TUI *tui); /* Call this after creating all widgets to begin gathering events */ int TUI_mainloop(TUI *tui); TUI_WIDGET *TUI_create_window(TUI *tui, char *title, int x, int y, int width, int height); /* Buttons */ TUI_WIDGET *TUI_window_create_button(TUI_WIDGET *window, char *text, int x, int y); TUI_WIDGET *TUI_window_create_radio_button(TUI_WIDGET *window, char *text, int x, int y); TUI_WIDGET *TUI_window_create_label(TUI_WIDGET *window, char *text, int x, int y); TUI_WIDGET *TUI_window_create_title(TUI_WIDGET *window, char *text, int x, int y); TUI_WIDGET *TUI_window_create_textport(TUI_WIDGET *window, char *text, int x, int y, int width); #if 0 TUI_WIDGET *TUI_window_create_icon_button(TUI_WIDGET *window, char *bits, int x, int y); TUI_WIDGET *TUI_window_create_icon_radio_button(TUI_WIDGET *window, char *bits, int x, int y); TUI_WIDGET *TUI_window_create_icon(TUI_WIDGET *window, char *bits, int x, int y); void TUI_textport_set_text(TUI_WIDGET *textport, char *text); #endif /* Menus */ TUI_WIDGET *TUI_window_create_menubar(TUI_WIDGET *window); TUI_WIDGET *TUI_menubar_create_pulldown(TUI_WIDGET *menubar, char *text); TUI_WIDGET *TUI_pulldown_create_menuitem(TUI_WIDGET *pulldown, char *text); TUI_WIDGET *TUI_pulldown_create_separator(TUI_WIDGET *pulldown); void TUI_menuitem_set_key(TUI_WIDGET *menuitem, char key); /* The value of the radio widget is set to this when selected, making it unnecessary to use user data or text to decern radio buttons. NOTE: A value of zero is _not_ allowed. */ void TUI_radio_button_set_selected_value(TUI_WIDGET *radio, char value); /* OpenGL */ TUI_WIDGET *TUI_window_create_opengl_region(TUI_WIDGET *window, int x, int y, int width, int height); /* Return zero from the callback to process event normally, or negative one to prevent normal event handling */ void TUI_window_set_intercept_callback(TUI_WIDGET *window, int (*callback)(TUI_EVENT_INFO *info), void *user_data); /* The following functions apply to almost all widget types */ void TUI_WIDGET_set_callback(TUI_WIDGET *widget, void (*callback)(TUI_WIDGET_INFO *info), void *user_data); TUI_WIDGET *TUI_window_get_menubar(TUI_WIDGET *window); void TUI_WIDGET_destroy(TUI_WIDGET *widget); void TUI_WIDGET_set_value(TUI_WIDGET *widget, int value); int TUI_WIDGET_get_value(TUI_WIDGET *widget); TUI_WIDGET_TYPE TUI_WIDGET_get_type(TUI_WIDGET *widget); void TUI_WIDGET_set_name(TUI_WIDGET *widget, char *name); void TUI_WIDGET_set_callback_name(TUI_WIDGET *widget, char *name); void TUI_WIDGET_set_location(TUI_WIDGET *widget, int x, int y); void TUI_WIDGET_translate_coordinates(TUI_WIDGET *src_widget, TUI_WIDGET *dst_widget, int src_x, int src_y, int *dst_x, int *dst_y); /* returns previous value */ int TUI_WIDGET_set_enabled(TUI_WIDGET *widget, int state); int TUI_WIDGET_set_visible(TUI_WIDGET *widget, int state); void *TUI_WIDGET_set_user_data(TUI_WIDGET *widget, void *user_data); #ifdef TUI_XWIN #include #include #include Display *TUI_get_display(TUI *tui); Window TUI_WIDGET_get_window(TUI_WIDGET *widget); #endif /* These functions should only be used by tui_build */ int TUI_read(TUI *tui); int TUI_write(TUI *tui, char *filename); #endif /* _TUI_H_ */