1 /*************************************************************************** 2 gui_edit.h - description 3 ------------------- 4 begin : Wed Oct 16 2002 5 copyright : (C) 2002 by Michael Speck 6 email : kulkanie@gmx.net 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef __GUI_EDIT_H 19 #define __GUI_EDIT_H 20 21 /* 22 ==================================================================== 23 Create a single/multi-line editable widget. By checking the 24 measurements of the standard font the number of lines and the 25 line width is determined. If the edit is single-lined height is 26 always one but edit becomes scrollable. 27 'border': between text and frame 28 'text': is copied and displayed when first shown 29 'size': limit of characters (excluding the \0) 30 Per default the edit accepts all non-whitespace characters. 31 ==================================================================== 32 */ 33 GuiWidget* gui_edit_create( 34 GuiWidget *parent, int x, int y, int width, int height, 35 void (*user_event_handler)(GuiWidget*,GuiEvent*), 36 int border, int multi_line, int size, char *text ); 37 38 /* 39 ==================================================================== 40 Resize the edit buffer and clear any text. (no update) 41 ==================================================================== 42 */ 43 void gui_edit_resize_buffer( GuiWidget *edit, int size ); 44 /* 45 ==================================================================== 46 Set the edit's text. This resets the edit cursor's position to 47 end of text and updates displayed edit if visible. 48 ==================================================================== 49 */ 50 void gui_edit_set_text( GuiWidget *edit, char *text ); 51 /* 52 ==================================================================== 53 Copy characters from 'start' to 'length' of the edit string to 54 'buffer' (at maximum limit characters including \0). If 'length' is 55 -1 the characters copied are those from 'start' to end of text. 56 ==================================================================== 57 */ 58 int gui_edit_get_text( 59 GuiWidget *edit, char *buffer, int limit, 60 int start, int length ); 61 /* 62 ==================================================================== 63 Update the blinking cursor flag (no update) of the edit and in 64 case a key is pressed call gui_edit_handle_key(). 65 ==================================================================== 66 */ 67 void gui_edit_update( GuiWidget *widget, int ms ); 68 /* 69 ==================================================================== 70 Select a character filter. 71 default: all non-whitespaces >=32 && <= 128 72 alpha: A-Z,a-z 73 numerical: -,0-9 74 alphanumerical: A-Z,a-z,0-9 75 alphanumerical2: + underscores 76 ==================================================================== 77 */ 78 enum { 79 GUI_EDIT_DEFAULT = 0, 80 GUI_EDIT_ALPHA, 81 GUI_EDIT_NUMERICAL, 82 GUI_EDIT_ALPHANUMERICAL, 83 GUI_EDIT_ALPHANUMERICAL2 84 }; 85 void gui_edit_set_filter( GuiWidget *edit, int type ); 86 87 #endif 88