Lines Matching refs:f
93 struct bsddialog_formitem *items, struct privateform *f)
111 f->nitems = nitems;
117 if (mbtowc(&f->securewch, conf->form.securembch, mbchsize) < 0)
121 f->securewch = btowc(conf->form.securech);
124 f->securewch = L' ';
128 f->pritems = malloc(f->nitems * sizeof(struct privateitem));
129 if (f->pritems == NULL)
131 f->hasbottomdesc = false;
132 f->h = f->w = f->minviewrows = 0;
133 for (i = 0; i < f->nitems; i++) {
134 item = &f->pritems[i];
149 f->hasbottomdesc = true;
173 item->pubwbuf[j] = f->securewch;
182 f->h = MAX(f->h, item->ylabel);
183 f->h = MAX(f->h, item->yfield);
184 f->w = MAX(f->w, item->xlabel + strcols(item->label));
185 f->w = MAX(f->w, item->xfield + item->fieldcols);
196 f->minviewrows = MAX(f->minviewrows, tmp);
198 if (f->nitems > 0) {
199 f->h = f->h + 1 - itemybeg;
200 f->w -= itemxbeg;
201 f->minviewrows += 1;
203 f->wmin = f->w;
204 for (i = 0; i < f->nitems; i++) {
205 f->pritems[i].ylabel -= itemybeg;
206 f->pritems[i].yfield -= itemybeg;
207 f->pritems[i].xlabel -= itemxbeg;
208 f->pritems[i].xfield -= itemxbeg;
358 return_values(struct bsddialog_conf *conf, struct privateform *f,
363 for (i = 0; i < f->nitems; i++) {
365 items[i].value = (char*)wcsdup(f->pritems[i].privwbuf);
367 items[i].value = alloc_wstomb(f->pritems[i].privwbuf);
377 static void set_first_with_default(struct privateform *f, int *focusitem)
381 f->sel = -1;
382 if (focusitem != NULL && *focusitem >=0 && *focusitem < (int)f->nitems)
383 if (f->pritems[*focusitem].readonly == false) {
384 f->sel = *focusitem;
387 for (i = 0 ; i < f->nitems; i++)
388 if (f->pritems[i].readonly == false) {
389 f->sel = i;
461 drawitem(struct privateform *f, int idx, bool focus)
467 item = &f->pritems[idx];
470 wattron(f->pad, t.dialog.color);
471 mvwaddstr(f->pad, item->ylabel, item->xlabel, item->label);
472 wattroff(f->pad, t.dialog.color);
481 wattron(f->pad, color);
482 mvwhline(f->pad, item->yfield, item->xfield, ' ', item->fieldcols);
491 mvwaddnwstr(f->pad, item->yfield, item->xfield,
493 wattroff(f->pad, color);
496 if (f->hasbottomdesc) {
509 wmove(f->pad, item->yfield, item->xfield + item->xcursor);
521 #define DRAWITEM_TRICK(f, idx, focus) do { \
522 drawitem(f, idx, !focus); \
523 prefresh((f)->pad, (f)->y, 0, (f)->ys, (f)->xs, (f)->ye, (f)->xe); \
524 drawitem(f, idx, focus); \
525 prefresh((f)->pad, (f)->y, 0, (f)->ys, (f)->xs, (f)->ye, (f)->xe); \
528 static void update_formbox(struct bsddialog_conf *conf, struct privateform *f)
532 getmaxyx(f->box, h, w);
533 draw_borders(conf, f->box, LOWERED);
535 if (f->viewrows < f->h) {
536 wattron(f->box, t.dialog.arrowcolor);
537 if (f->y > 0)
538 mvwhline(f->box, 0, (w / 2) - 2, UARROW(conf), 5);
540 if (f->y + f->viewrows < f->h)
541 mvwhline(f->box, h-1, (w / 2) - 2, DARROW(conf), 5);
542 wattroff(f->box, t.dialog.arrowcolor);
546 static void curriteminview(struct privateform *f, struct privateitem *item)
554 if (f->y > yup && f->y > 0)
555 f->y = yup;
556 if ((int)(f->y + f->viewrows) - 1 < (int)ydown)
557 f->y = ydown - f->viewrows + 1;
559 if (f->y > 0 && (f->h - f->y) < f->viewrows)
560 f->y = f->h - f->viewrows;
563 static int form_size_position(struct dialog *d, struct privateform *f)
571 hform = (int) f->viewrows;
572 if (f->viewrows == BSDDIALOG_AUTOSIZE)
573 hform = MAX(f->h, f->minviewrows);
577 d->text, &htext, &d->bs, hform, f->w + 4) != 0)
580 if (d->h - BORDERS - htext - HBUTTONS < 2 + (int)f->minviewrows) {
581 f->viewrows = f->minviewrows; /* for widget_checksize() */
582 } else if (f->viewrows == BSDDIALOG_AUTOSIZE) {
583 f->viewrows = MIN(d->h - BORDERS - htext - HBUTTONS, hform) - 2;
584 f->viewrows = MAX(f->viewrows, f->minviewrows);
586 f->viewrows = MIN(d->h - BORDERS - htext - HBUTTONS, hform) - 2;
590 if (f->viewrows < f->minviewrows)
592 f->viewrows, f->minviewrows);
594 2 /* borders */ + f->minviewrows, f->w + 4) != 0)
604 form_redraw(struct dialog *d, struct privateform *f, bool focusinform)
612 f->viewrows = f->formheight;
613 f->w = f->wmin;
614 if (form_size_position(d, f) != 0)
620 TEXTPAD(d, 2 /* box borders */ + f->viewrows + HBUTTONS);
622 update_box(d->conf, f->box, d->y + d->h - 5 - f->viewrows, d->x + 2,
623 f->viewrows + 2, d->w - 4, LOWERED);
625 for (i = 0; i < f->nitems; i++) {
626 fieldctl(&f->pritems[i], MOVE_CURSOR_BEGIN);
627 if (f->pritems[i].extendfield) {
628 f->w = d->w - 6;
629 f->pritems[i].fieldcols = f->w - f->pritems[i].xfield;
631 if (f->pritems[i].cursorend)
632 fieldctl(&f->pritems[i], MOVE_CURSOR_END);
635 wresize(f->pad, f->h, f->w);
636 for (i = 0; i < f->nitems; i++)
637 drawitem(f, i, false);
639 f->ys = d->y + d->h - 5 - f->viewrows + 1;
640 f->ye = d->y + d->h - 5 ;
641 if ((int)f->w >= d->w - 6) { /* left */
642 f->xs = d->x + 3;
643 f->xe = f->xs + d->w - 7;
645 f->xs = d->x + 3 + (d->w - 6)/2 - f->w/2;
646 f->xe = f->xs + d->w - 5;
649 if (f->sel != -1) { /* at least 1 writable item */
654 curriteminview(f, &f->pritems[f->sel]);
655 update_formbox(d->conf, f);
656 wnoutrefresh(f->box);
657 DRAWITEM_TRICK(f, f->sel, focusinform);
658 } else if (f->sel == -1 && f->nitems > 0) { /* all read only */
661 update_formbox(d->conf, f);
662 wnoutrefresh(f->box);
663 DRAWITEM_TRICK(f, 0, false); /* to refresh pad*/
665 wnoutrefresh(f->box);