コード例 #1
0
ファイル: button.c プロジェクト: Distrotech/newt
static void buttonDrawIt(newtComponent co, int active, int pushed) {
    struct button * bu = co->data;

    if (!co->isMapped) return;

    SLsmg_set_color(NEWT_COLORSET_BUTTON);

    if (bu->compact) {
	if (!active)
	    SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON);
	else if (SLtt_Use_Ansi_Colors)
	    SLsmg_set_color(NEWT_COLORSET_BUTTON);
	else
	    SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
	newtGotorc(co->top+ pushed, co->left + 1 + pushed);
	SLsmg_write_char('<');
	SLsmg_write_string(bu->text);
	SLsmg_write_char('>');
    } else {
	if (pushed) {
	    SLsmg_set_color(NEWT_COLORSET_BUTTON);
	    newtDrawBox(co->left + 1, co->top + 1, co->width - 1, 3, 0);

	    SLsmg_set_color(NEWT_COLORSET_WINDOW);
	    newtClearBox(co->left, co->top, co->width, 1);
	    newtClearBox(co->left, co->top, 1, co->height);
	} else {
	    newtDrawBox(co->left, co->top, co->width - 1, 3, 1);
	}

	buttonDrawText(co, active, pushed);
    }
    /* put cursor at beginning of text for better accessibility */
    newtGotorc(co->top + (bu->compact ? 0 : 1) + pushed, co->left + 1 + pushed + 1);
}
コード例 #2
0
static void listboxDraw(newtComponent co)
{
    struct listbox * li = co->data;
    struct items *item;
    int i, j;

    if (!co->isMapped) return ;

    newtTrashScreen();
    
    if(li->flags & NEWT_FLAG_BORDER) {
      if(li->isActive)
	  SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
      else
          SLsmg_set_color(NEWT_COLORSET_LISTBOX);

      newtDrawBox(co->left, co->top, co->width, co->height, 0);
    }

    if(li->sb)
	li->sb->ops->draw(li->sb);

    SLsmg_set_color(NEWT_COLORSET_LISTBOX);

    for(i = 0, item = li->boxItems; item != NULL && i < li->startShowItem;
	i++, item = item->next);

    j = i;

    for (i = 0; item != NULL && i < li->curHeight; i++, item = item->next) {
	if (!item->text) continue;

	newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
	if(j + i == li->currItem) {
	    if(item->isSelected)
		SLsmg_set_color(NEWT_COLORSET_ACTSELLISTBOX);
	    else
		SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
	} else if(item->isSelected)
	    SLsmg_set_color(NEWT_COLORSET_SELLISTBOX);
	else
	    SLsmg_set_color(NEWT_COLORSET_LISTBOX);

	SLsmg_write_nstring(item->text, li->curWidth);

    }
    newtGotorc(co->top + (li->currItem - li->startShowItem) + 1, co->left + 1);
}
コード例 #3
0
static void labelDraw(newtComponent co) {
    struct label * la = co->data;

    if (co->isMapped == -1) return;

    SLsmg_set_color(COLORSET_LABEL);

    newtGotorc(co->top, co->left);
    SLsmg_write_string(la->text);
}
コード例 #4
0
static void textboxDraw(newtComponent c) {
    int i;
    struct textbox * tb = c->data;
    int size;

    if (tb->sb) {
        size = tb->numLines - c->height;
        newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0);
        tb->sb->ops->draw(tb->sb);
    }

    SLsmg_set_color(NEWT_COLORSET_TEXTBOX);

    for (i = 0; (i + tb->topLine) < tb->numLines && i < c->height; i++) {
        newtGotorc(c->top + i, c->left);
        SLsmg_write_string(tb->blankline);
        newtGotorc(c->top + i, c->left);
        SLsmg_write_string(tb->lines[i + tb->topLine]);
    }
}
コード例 #5
0
ファイル: checkbox.c プロジェクト: Distrotech/newt
static void cbDraw(newtComponent c) {
    struct checkbox * cb = c->data;

    if (!c->isMapped) return;

    if (cb->flags & NEWT_FLAG_DISABLED) {
	cb->inactive = NEWT_COLORSET_DISENTRY;
	cb->active = NEWT_COLORSET_DISENTRY;
    } else {
	cb->inactive = COLORSET_CHECKBOX;
	cb->active = COLORSET_ACTCHECKBOX;
    }

    SLsmg_set_color(cb->inactive);

    newtGotorc(c->top, c->left);

    switch (cb->type) {
      case RADIO:
	SLsmg_write_string("( ) ");
	break;

      case CHECK:
	SLsmg_write_string("[ ] ");
	break;

      default:
	break;
    }

    SLsmg_write_string(cb->text);

    if (cb->hasFocus)
	SLsmg_set_color(cb->active);

    newtGotorc(c->top, c->left + 1);
    SLsmg_write_char(*cb->result);
    newtGotorc(c->top, c->left + 4);
}
コード例 #6
0
ファイル: button.c プロジェクト: Distrotech/newt
static void buttonDrawText(newtComponent co, int active, int pushed) {
    struct button * bu = co->data;

    if (pushed) pushed = 1;

    if (active)
	SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
    else
	SLsmg_set_color(NEWT_COLORSET_BUTTON);

    newtGotorc(co->top + 1 + pushed, co->left + 1 + pushed);
    SLsmg_write_char(' ');
    SLsmg_write_string(bu->text);
    SLsmg_write_char(' ');
}
コード例 #7
0
ファイル: checkbox.c プロジェクト: cyberbeat/mysql-gui-tools
void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {
    struct checkbox * cb = co->data;
    int row, col;

    cb->flags = newtSetFlags(cb->flags, flags, sense);

    if (!(cb->flags & NEWT_FLAG_DISABLED))
	co->takesFocus = 1;
    else
	co->takesFocus = 0;

    newtGetrc(&row, &col);
    cbDraw(co);
    newtGotorc(row, col);
}
コード例 #8
0
ファイル: checkbox.c プロジェクト: Distrotech/newt
void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {
    struct checkbox * cb = co->data;
    int row, col;

    cb->flags = newtSetFlags(cb->flags, flags, sense);

    // If the flag just sets a property (eg. NEWT_FLAG_RETURNEXIT),
    // don't redraw, etc. as the component might be 'hidden' and not to
    // be drawn (eg. in a scrolled list)
    if (flags == NEWT_FLAG_RETURNEXIT)
	    return;

    if (!(cb->flags & NEWT_FLAG_DISABLED))
	co->takesFocus = 1;
    else
	co->takesFocus = 0;

    newtGetrc(&row, &col);
    cbDraw(co);
    newtGotorc(row, col);
}
コード例 #9
0
ファイル: button.c プロジェクト: Distrotech/newt
/* 
 * return NULL on malloc error.
 *  FIXME: all createButton calls should check for error
 */
static newtComponent createButton(int left, int row, const char * text, int compact) {
    newtComponent co;
    struct button * bu;
    int width = wstrlen(text,-1);

    co = malloc(sizeof(*co));
    if (co == NULL) 
	return NULL;
    bu = malloc(sizeof(struct button));
    if (bu == NULL)  {
	free (co);
	return NULL;
    }
    co->data = bu;
    co->destroyCallback = NULL;

    bu->text = strdup(text);
    bu->compact = compact;
    co->ops = &buttonOps;

    if (bu->compact) {
	co->height = 1;
	co->width = width + 3;
    } else {
	co->height = 4;
	co->width = width + 5;
    }

    co->top = row;
    co->left = left;
    co->takesFocus = 1;
    co->isMapped = 0;

    newtGotorc(co->top, co->left);

    return co;

}
コード例 #10
0
ファイル: button.c プロジェクト: Distrotech/newt
static void buttonPlace(newtComponent co, int newLeft, int newTop) {
    co->top = newTop;
    co->left = newLeft;

    newtGotorc(co->top, co->left);
}