~ubuntu-branches/ubuntu/feisty/elinks/feisty-updates

« back to all changes in this revision

Viewing changes to src/bfu/checkbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-06-30 08:57:43 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060630085743-l81fgbw9dehvl1ds
Tags: 0.11.1-1ubuntu1
* Merge to Debian unstable.
* Removed gnutls12 porting, this is upstream now.
* Only Ubuntu changes left:
  - Killed type-handling.
  - Add X-Ubuntu-Gettext-Domain to .desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Checkbox widget handlers. */
2
 
/* $Id: checkbox.c,v 1.91.4.2 2005/04/06 08:50:39 jonas Exp $ */
3
2
 
4
3
#ifdef HAVE_CONFIG_H
5
4
#include "config.h"
16
15
#include "terminal/mouse.h"
17
16
#include "terminal/terminal.h"
18
17
 
19
 
 
 
18
#define CHECKBOX_HEIGHT 1
20
19
#define CHECKBOX_LEN 3  /* "[X]" or "(X)" */
21
20
#define CHECKBOX_SPACING 1      /* "[X]" + " " + "Label" */
22
21
#define CHECKBOX_LS (CHECKBOX_LEN + CHECKBOX_SPACING)   /* "[X] " */
23
22
 
24
23
void
25
24
add_dlg_radio_do(struct dialog *dlg, unsigned char *text,
26
 
                 int groupid, int groupnum, void *data)
 
25
                 int groupid, int groupnum, int *data)
27
26
{
28
 
        struct widget *widget;
29
 
 
30
 
        widget = &dlg->widgets[dlg->number_of_widgets++];
31
 
        widget->type = WIDGET_CHECKBOX;
32
 
        widget->text = text;
33
 
        widget->info.checkbox.gid = groupid;
 
27
        struct widget *widget = &dlg->widgets[dlg->number_of_widgets++];
 
28
 
 
29
        widget->type    = WIDGET_CHECKBOX;
 
30
        widget->text    = text;
 
31
        widget->datalen = sizeof(*data);
 
32
        widget->data    = (void *) data;
 
33
 
 
34
        widget->info.checkbox.gid  = groupid;
34
35
        widget->info.checkbox.gnum = groupnum;
35
 
        widget->datalen = sizeof(int);
36
 
        widget->data = data;
37
36
}
38
37
 
39
38
void
44
43
{
45
44
        unsigned char *text = widget_data->widget->text;
46
45
 
47
 
        set_box(&widget_data->box, x, *y, CHECKBOX_LS, 1);
 
46
        set_box(&widget_data->box, x, *y, CHECKBOX_LEN, CHECKBOX_HEIGHT);
48
47
 
49
48
        if (w <= CHECKBOX_LS) return;
50
49
 
51
 
        if (rw) *rw -= CHECKBOX_LS;
52
 
        dlg_format_text_do(term, text, x + CHECKBOX_LS, y, w - CHECKBOX_LS, rw,
53
 
                        get_bfu_color(term, "dialog.checkbox-label"), align);
54
 
        if (rw) *rw += CHECKBOX_LS;
55
 
 
 
50
        if (text && *text) {
 
51
                if (rw) *rw -= CHECKBOX_LS;
 
52
                dlg_format_text_do(term, text, x + CHECKBOX_LS, y,
 
53
                                   w - CHECKBOX_LS, rw,
 
54
                                   get_bfu_color(term, "dialog.checkbox-label"),
 
55
                                   align);
 
56
                if (rw) *rw += CHECKBOX_LS;
 
57
        }
56
58
}
57
59
 
58
 
static t_handler_event_status
 
60
static widget_handler_status_T
59
61
display_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
60
62
{
61
63
        struct terminal *term = dlg_data->win->term;
86
88
        return EVENT_PROCESSED;
87
89
}
88
90
 
89
 
static t_handler_event_status
 
91
static widget_handler_status_T
90
92
init_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
91
93
{
92
94
        int *cdata = (int *) widget_data->cdata;
103
105
        return EVENT_PROCESSED;
104
106
}
105
107
 
106
 
static t_handler_event_status
 
108
static widget_handler_status_T
107
109
mouse_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
108
110
{
109
111
        struct terminal *term = dlg_data->win->term;
123
125
        return EVENT_PROCESSED;
124
126
}
125
127
 
126
 
static t_handler_event_status
 
128
static widget_handler_status_T
127
129
select_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
128
130
{
129
131