1*86d7f5d3SJohn Marino /* 2*86d7f5d3SJohn Marino * Copyright (c)2004 Cat's Eye Technologies. All rights reserved. 3*86d7f5d3SJohn Marino * 4*86d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 5*86d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 6*86d7f5d3SJohn Marino * are met: 7*86d7f5d3SJohn Marino * 8*86d7f5d3SJohn Marino * Redistributions of source code must retain the above copyright 9*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 10*86d7f5d3SJohn Marino * 11*86d7f5d3SJohn Marino * Redistributions in binary form must reproduce the above copyright 12*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in 13*86d7f5d3SJohn Marino * the documentation and/or other materials provided with the 14*86d7f5d3SJohn Marino * distribution. 15*86d7f5d3SJohn Marino * 16*86d7f5d3SJohn Marino * Neither the name of Cat's Eye Technologies nor the names of its 17*86d7f5d3SJohn Marino * contributors may be used to endorse or promote products derived 18*86d7f5d3SJohn Marino * from this software without specific prior written permission. 19*86d7f5d3SJohn Marino * 20*86d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21*86d7f5d3SJohn Marino * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*86d7f5d3SJohn Marino * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*86d7f5d3SJohn Marino * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24*86d7f5d3SJohn Marino * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25*86d7f5d3SJohn Marino * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26*86d7f5d3SJohn Marino * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27*86d7f5d3SJohn Marino * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28*86d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29*86d7f5d3SJohn Marino * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30*86d7f5d3SJohn Marino * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31*86d7f5d3SJohn Marino * OF THE POSSIBILITY OF SUCH DAMAGE. 32*86d7f5d3SJohn Marino */ 33*86d7f5d3SJohn Marino 34*86d7f5d3SJohn Marino /* 35*86d7f5d3SJohn Marino * curses_widget.h 36*86d7f5d3SJohn Marino * $Id: curses_widget.h,v 1.5 2005/02/08 07:49:03 cpressey Exp $ 37*86d7f5d3SJohn Marino */ 38*86d7f5d3SJohn Marino 39*86d7f5d3SJohn Marino #include "curses_form.h" 40*86d7f5d3SJohn Marino 41*86d7f5d3SJohn Marino #ifndef __CURSES_WIDGET_H 42*86d7f5d3SJohn Marino #define __CURSES_WIDGET_H 43*86d7f5d3SJohn Marino 44*86d7f5d3SJohn Marino typedef enum { 45*86d7f5d3SJohn Marino CURSES_LABEL, 46*86d7f5d3SJohn Marino CURSES_TEXTBOX, 47*86d7f5d3SJohn Marino CURSES_BUTTON, 48*86d7f5d3SJohn Marino CURSES_PROGRESS, 49*86d7f5d3SJohn Marino CURSES_CHECKBOX, 50*86d7f5d3SJohn Marino CURSES_LISTBOX 51*86d7f5d3SJohn Marino } widget_t; 52*86d7f5d3SJohn Marino 53*86d7f5d3SJohn Marino struct curses_widget { 54*86d7f5d3SJohn Marino struct curses_widget *next; /* chain of widgets in form */ 55*86d7f5d3SJohn Marino struct curses_widget *prev; 56*86d7f5d3SJohn Marino 57*86d7f5d3SJohn Marino struct curses_form *form; /* form in which widget lives */ 58*86d7f5d3SJohn Marino 59*86d7f5d3SJohn Marino unsigned int x; /* x pos of widget in form, 0 = left edge */ 60*86d7f5d3SJohn Marino unsigned int y; /* y pos of widget in form, 0 = top edge */ 61*86d7f5d3SJohn Marino unsigned int width; /* width of widget */ 62*86d7f5d3SJohn Marino unsigned int type; /* CURSES_* type of widget */ 63*86d7f5d3SJohn Marino char *text; /* for labels, textboxes, buttons */ 64*86d7f5d3SJohn Marino unsigned int size; /* for textboxes, allocated size of text */ 65*86d7f5d3SJohn Marino unsigned int curpos; /* for textboxes, cursor position */ 66*86d7f5d3SJohn Marino unsigned int offset; /* for textboxes, first displayed char */ 67*86d7f5d3SJohn Marino int editable; /* for textboxes, text is editable */ 68*86d7f5d3SJohn Marino int obscured; /* for textboxes, text is ****'ed out */ 69*86d7f5d3SJohn Marino int amount; /* for progress bars, sliders, checkboxes */ 70*86d7f5d3SJohn Marino int spin; /* for progress bars */ 71*86d7f5d3SJohn Marino char *tooltip; /* short help text displayed on statusbar */ 72*86d7f5d3SJohn Marino char accel; /* 'accelerator' - shortcut key */ 73*86d7f5d3SJohn Marino int flags; /* flags */ 74*86d7f5d3SJohn Marino 75*86d7f5d3SJohn Marino int user_id; /* misc integer */ 76*86d7f5d3SJohn Marino void *userdata; /* misc pointer */ 77*86d7f5d3SJohn Marino 78*86d7f5d3SJohn Marino /* callback for when widget is clicked */ 79*86d7f5d3SJohn Marino /* for buttons */ 80*86d7f5d3SJohn Marino int (*click_cb)(struct curses_widget *); 81*86d7f5d3SJohn Marino }; 82*86d7f5d3SJohn Marino 83*86d7f5d3SJohn Marino #define CURSES_WIDGET_CENTER 1 /* auto center this widget? */ 84*86d7f5d3SJohn Marino #define CURSES_WIDGET_WIDEN 2 /* auto widen this widget? */ 85*86d7f5d3SJohn Marino 86*86d7f5d3SJohn Marino struct curses_widget *curses_widget_new(unsigned int, unsigned int, 87*86d7f5d3SJohn Marino unsigned int, widget_t, 88*86d7f5d3SJohn Marino const char *, 89*86d7f5d3SJohn Marino unsigned int, unsigned int); 90*86d7f5d3SJohn Marino void curses_widget_free(struct curses_widget *); 91*86d7f5d3SJohn Marino void curses_widget_draw(struct curses_widget *); 92*86d7f5d3SJohn Marino void curses_widget_draw_tooltip(struct curses_widget *); 93*86d7f5d3SJohn Marino int curses_widget_can_take_focus(struct curses_widget *); 94*86d7f5d3SJohn Marino void curses_widget_tooltip_set(struct curses_widget *, const char *); 95*86d7f5d3SJohn Marino int curses_widget_set_click_cb(struct curses_widget *, 96*86d7f5d3SJohn Marino int (*)(struct curses_widget *)); 97*86d7f5d3SJohn Marino int curses_widget_click(struct curses_widget *); 98*86d7f5d3SJohn Marino 99*86d7f5d3SJohn Marino int curses_textbox_advance_char(struct curses_widget *); 100*86d7f5d3SJohn Marino int curses_textbox_retreat_char(struct curses_widget *); 101*86d7f5d3SJohn Marino int curses_textbox_home(struct curses_widget *); 102*86d7f5d3SJohn Marino int curses_textbox_end(struct curses_widget *); 103*86d7f5d3SJohn Marino int curses_textbox_insert_char(struct curses_widget *, char); 104*86d7f5d3SJohn Marino int curses_textbox_backspace_char(struct curses_widget *); 105*86d7f5d3SJohn Marino int curses_textbox_delete_char(struct curses_widget *); 106*86d7f5d3SJohn Marino int curses_textbox_set_text(struct curses_widget *, const char *); 107*86d7f5d3SJohn Marino 108*86d7f5d3SJohn Marino int curses_checkbox_toggle(struct curses_widget *); 109*86d7f5d3SJohn Marino 110*86d7f5d3SJohn Marino int curses_progress_spin(struct curses_widget *); 111*86d7f5d3SJohn Marino 112*86d7f5d3SJohn Marino #endif /* !__CURSES_WIDGET_H */ 113