ui_objects.h revision 225736
1/*
2 * Author: Marc van Kempen
3 * Desc:   include file for UI-objects
4 *
5 * Copyright (c) 1995, Marc van Kempen
6 *
7 * All rights reserved.
8 *
9 * This software may be used, modified, copied, distributed, and
10 * sold, in both source and binary form provided that the above
11 * copyright and these terms are retained, verbatim, as the first
12 * lines of this file.  Under no circumstances is the author
13 * responsible for the proper functioning of this software, nor does
14 * the author assume any responsibility for damages incurred with
15 * its use.
16 *
17 */
18
19#include "dialog.h"
20#include <ncurses.h>
21
22/***********************************************************************
23 *
24 * Defines
25 *
26 ***********************************************************************/
27
28#define ctrl(a)		((a) - 'a' + 1)
29
30/* the Object types */
31#define STRINGOBJ	1
32#define LISTOBJ		2
33#define BUTTONOBJ	3
34
35/* the return signals from the selection routines */
36/* 1000 and higher should avoid conflicts with keys pressed */
37#define SEL_CR		1001	/* return was pressed */
38#define SEL_ESC		1002	/* ESC pressed */
39#define SEL_TAB		1003	/* TAB pressed */
40#define SEL_BACKTAB	1004	/* SHIFT-TAB pressed */
41#define SEL_BUTTON	1005	/* a button was pressed */
42
43/***********************************************************************
44 *
45 * Typedefs
46 *
47 ***********************************************************************/
48
49typedef struct {
50    WINDOW	*win;		/* the window it's contained in */
51    char	*title;		/* the prompt for the input field */
52    char 	*s;		/* initial value of the input field */
53    int		x, y, w, len;	/* the (y, x) position of the upperleft */
54				/* corner and the width <w> of the display */
55				/* and length <len> of the field */
56    int		attr_mask;	/* special attributes */
57} StringObj;
58
59typedef struct {
60    WINDOW	*win;		/* the windows it's contained in */
61    char	*title;		/* the title of the list */
62    char 	**name;		/* the names of the list */
63    int		*seld;		/* the currently selected names */
64    char	*elt;		/* the current element in the list list[sel] */
65    int		x, y, w, h, n;	/* dimensions of list and # of elements (n) */
66    int		scroll, sel;	/* current position in the list */
67} ListObj;
68
69typedef struct {
70    WINDOW	*win;		/* the window it's contained in */
71    char	*title;		/* title for the button */
72    int		x, y, w, h; 	/* its dimensions */
73    int		*pushed;	/* boolean that determines wether button was pushed */
74} ButtonObj;
75
76typedef struct ComposeObj {
77    int			objtype;
78    void		*obj;
79    struct ComposeObj	*next, *prev;
80} ComposeObj;
81
82/**********************************************************************
83 *
84 * Prototypes
85 *
86 **********************************************************************/
87
88void		RefreshStringObj(StringObj *so);
89StringObj 	*NewStringObj(WINDOW *win, char *title, char *s,
90			      int y, int x, int w, int len);
91int		SelectStringObj(StringObj *so);
92void		DelStringObj(StringObj *so);
93
94void		RefreshListObj(ListObj *lo);
95ListObj 	*NewListObj(WINDOW *win, char *title, char **list,
96			    char *listelt, int y, int x, int h, int w, int n);
97void		UpdateListObj(ListObj *lo, char **list, int n);
98int		SelectListObj(ListObj *lo);
99void		DelListObj(ListObj *obj);
100void            MarkCurrentListObj(ListObj *lo);
101void            MarkAllListObj(ListObj *lo);
102void            UnMarkAllListObj(ListObj *lo);
103
104void		RefreshButtonObj(ButtonObj *bo);
105ButtonObj 	*NewButtonObj(WINDOW *win, char *title, int *pushed,
106			      int y, int x);
107int		SelectButtonObj(ButtonObj *bo);
108void		DelButtonObj(ButtonObj *bo);
109void		AddObj(ComposeObj **Obj, int objtype, void *obj);
110void		FreeObj(ComposeObj *Obj);
111int		ReadObj(ComposeObj *Obj);
112int		PollObj(ComposeObj **Obj);
113void		DelObj(ComposeObj *Obj);
114
115