int sbAdjust;
int curWidth;
int userHasSetWidth;
+ int isActive;
char * seq;
char * result;
};
co->width = 0;
co->isMapped = 0;
ct->curWidth = 0;
+ ct->isActive = 0;
ct->userHasSetWidth = 0;
ct->itemlist = NULL;
ct->firstItem = NULL;
while (*item && i < co->height) {
newtGotorc(co->top + i, co->left);
- if (*item == *ct->currItem) {
- SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
- currRow = co->top + i;
- } else
- SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
+ SLsmg_set_color(NEWT_COLORSET_LISTBOX);
for (j = 0; j < (*item)->depth; j++)
SLsmg_write_string(" ");
} else {
if (ct->flags & NEWT_CHECKBOXTREE_HIDE_BOX) {
if ((*item)->selected)
- SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
+ SLsmg_set_color(NEWT_COLORSET_SELLISTBOX);
SLsmg_write_string(" ");
} else {
char tmp[5];
SLsmg_write_string(tmp);
}
}
+ if (*item == *ct->currItem) {
+ SLsmg_set_color(ct->isActive ?
+ NEWT_COLORSET_ACTSELLISTBOX : NEWT_COLORSET_ACTLISTBOX);
+ currRow = co->top + i;
+ }
SLsmg_write_nstring((*item)->text, co->width - 4 -
(3 * (*item)->depth));
- SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
item++;
i++;
}
break;
case EV_FOCUS:
+ ct->isActive = 1;
ctDraw(co);
er.result = ER_SWALLOWED;
break;
case EV_UNFOCUS:
+ ct->isActive = 0;
ctDraw(co);
er.result = ER_SWALLOWED;
break;
}
}
- if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb)
+ if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb) {
+ if (form->currComp != -1) {
+ ev.event = EV_UNFOCUS;
+ sendEvent(form->elements[form->currComp].co, ev);
+ }
form->helpCb(co, form->helpTag);
+ if (form->currComp != -1) {
+ ev.event = EV_FOCUS;
+ sendEvent(form->elements[form->currComp].co, ev);
+ }
+ }
if (!done) {
ev.event = EV_KEYPRESS;
newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
if(j + i == li->currItem) {
- if(item->isSelected)
+ if(li->isActive)
SLsmg_set_color(NEWT_COLORSET_ACTSELLISTBOX);
else
SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
SLsmg_write_nstring(item->text, li->curWidth);
+ if (li->flags & NEWT_FLAG_MULTIPLE) {
+ newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
+ SLsmg_set_color(item->isSelected ?
+ NEWT_COLORSET_SELLISTBOX : NEWT_COLORSET_LISTBOX);
+ SLsmg_write_nstring(item->text, 1);
+ }
}
newtGotorc(co->top + (li->currItem - li->startShowItem) + li->bdyAdjust,
co->left + li->bdxAdjust);
char *blankline;
int linesAlloced;
int doWrap;
- newtComponent sb;
+ newtComponent sb_act, sb;
int topLine;
int textWidth;
+ int isActive;
};
static char * expandTabs(const char * text);
struct textbox * tb = co->data;
co->isMapped = isMapped;
- if (tb->sb)
+ if (tb->sb) {
tb->sb->ops->mapped(tb->sb, isMapped);
+ tb->sb_act->ops->mapped(tb->sb_act, isMapped);
+ }
}
static void textboxPlace(newtComponent co, int newLeft, int newTop) {
co->top = newTop;
co->left = newLeft;
- if (tb->sb)
+ if (tb->sb) {
tb->sb->ops->place(tb->sb, co->left + co->width - 1, co->top);
+ tb->sb_act->ops->place(tb->sb_act, co->left + co->width - 1, co->top);
+ }
}
void newtTextboxSetHeight(newtComponent co, int height) {
tb->lines = NULL;
tb->topLine = 0;
tb->textWidth = width;
+ tb->isActive = 0;
tb->blankline = malloc(width+1);
memset(tb->blankline,' ',width);
tb->blankline[width] = '\0';
if (flags & NEWT_FLAG_SCROLL) {
co->width += 2;
+ tb->sb_act = newtVerticalScrollbar(co->left + co->width - 1, co->top,
+ co->height, COLORSET_ACTTEXTBOX, COLORSET_TEXTBOX);
tb->sb = newtVerticalScrollbar(co->left + co->width - 1, co->top,
co->height, COLORSET_TEXTBOX, COLORSET_TEXTBOX);
+ co->takesFocus = 1;
} else {
- tb->sb = NULL;
+ tb->sb_act = tb->sb = NULL;
}
return co;
if (tb->sb) {
size = tb->numLines - c->height;
- newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0);
- tb->sb->ops->draw(tb->sb);
+ if (tb->isActive) {
+ newtScrollbarSet(tb->sb_act, tb->topLine, size ? size : 0);
+ tb->sb_act->ops->draw(tb->sb_act);
+ } else {
+ newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0);
+ tb->sb->ops->draw(tb->sb);
+ }
}
SLsmg_set_color(NEWT_COLORSET_TEXTBOX);
er.result = ER_IGNORED;
- if (ev.when == EV_EARLY && ev.event == EV_KEYPRESS && tb->sb) {
+ if (!tb->sb || ev.when == EV_EARLY || ev.when == EV_LATE)
+ return er;
+
+ switch(ev.event) {
+ case EV_KEYPRESS:
newtTrashScreen();
switch (ev.u.key) {
case NEWT_KEY_UP:
er.result = ER_SWALLOWED;
break;
}
- }
- if (ev.when == EV_EARLY && ev.event == EV_MOUSE && tb->sb) {
+ break;
+ case EV_MOUSE:
/* Top scroll arrow */
if (ev.u.mouse.x == co->width && ev.u.mouse.y == co->top) {
if (tb->topLine) tb->topLine--;
er.result = ER_SWALLOWED;
}
+ break;
+ case EV_FOCUS:
+ tb->isActive = 1;
+ textboxDraw(co);
+ er.result = ER_SWALLOWED;
+ break;
+ case EV_UNFOCUS:
+ tb->isActive = 0;
+ textboxDraw(co);
+ er.result = ER_SWALLOWED;
+ break;
}
return er;
}