int firstChar; /* first character position being shown */
newtEntryFilter filter;
void * filterData;
+ int cs;
+ int csDisabled;
};
static int previous_char(const char *buf, int pos);
en->cursorPosition = 0;
}
+ en->cs = NEWT_COLORSET_ENTRY;
+ en->csDisabled = NEWT_COLORSET_DISENTRY;
+
return co;
}
if (!co->isMapped) return;
if (en->flags & NEWT_FLAG_DISABLED)
- SLsmg_set_color(NEWT_COLORSET_DISENTRY);
+ SLsmg_set_color(en->csDisabled);
else
- SLsmg_set_color(NEWT_COLORSET_ENTRY);
+ SLsmg_set_color(en->cs);
if (en->flags & NEWT_FLAG_HIDDEN) {
newtGotorc(co->top, co->left);
newtGotorc(row, col);
}
+void newtEntrySetColors(newtComponent co, int normal, int disabled) {
+ struct entry * en = co->data;
+
+ en->cs = normal;
+ en->csDisabled = disabled;
+ entryDraw(co);
+}
+
static void entryDestroy(newtComponent co) {
struct entry * en = co->data;
struct label {
char * text;
int length;
+ int cs;
};
static void labelDraw(newtComponent co);
la->length = strlen(text);
la->text = strdup(text);
+ la->cs = COLORSET_LABEL;
return co;
}
labelDraw(co);
}
+void newtLabelSetColors(newtComponent co, int colorset) {
+ struct label * la = co->data;
+
+ la->cs = colorset;
+ labelDraw(co);
+}
+
static void labelDraw(newtComponent co) {
struct label * la = co->data;
if (!co->isMapped) return;
- SLsmg_set_color(COLORSET_LABEL);
+ SLsmg_set_color(la->cs);
newtGotorc(co->top, co->left);
SLsmg_write_string(la->text);
global:
newtRadioSetCurrent;
} NEWT_0.52.9;
+
+NEWT_0.52.13 {
+ global:
+ newtEntrySetColors;
+ newtLabelSetColors;
+ newtScaleSetColors;
+ newtScrollbarSetColors;
+ newtTextboxSetColors;
+} NEWT_0.52.11;
newtComponent newtLabel(int left, int top, const char * text);
void newtLabelSetText(newtComponent co, const char * text);
+void newtLabelSetColors(newtComponent co, int colorset);
newtComponent newtVerticalScrollbar(int left, int top, int height,
int normalColorset, int thumbColorset);
void newtScrollbarSet(newtComponent co, int where, int total);
+void newtScrollbarSetColors(newtComponent co, int normal, int thumb);
newtComponent newtListbox(int left, int top, int height, int flags);
void * newtListboxGetCurrent(newtComponent co);
void newtTextboxSetText(newtComponent co, const char * text);
void newtTextboxSetHeight(newtComponent co, int height);
int newtTextboxGetNumLines(newtComponent co);
+void newtTextboxSetColors(newtComponent co, int normal, int active);
char * newtReflowText(char * text, int width, int flexDown, int flexUp,
int * actualWidth, int * actualHeight);
void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data);
char * newtEntryGetValue(newtComponent co);
void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
+void newtEntrySetColors(newtComponent co, int normal, int disabled);
newtComponent newtScale(int left, int top, int width, long long fullValue);
void newtScaleSet(newtComponent co, unsigned long long amount);
+void newtScaleSetColors(newtComponent co, int empty, int full);
void newtComponentAddCallback(newtComponent co, newtCallback f, void * data);
void newtComponentTakesFocus(newtComponent co, int val);
long long fullValue;
int charsSet;
unsigned int percentage;
+ int csEmpty;
+ int csFull;
};
static void scaleDraw(newtComponent co);
sc->fullValue = fullValue;
sc->charsSet = 0;
sc->percentage = 0;
+ sc->csEmpty = NEWT_COLORSET_EMPTYSCALE;
+ sc->csFull = NEWT_COLORSET_FULLSCALE;
return co;
}
}
}
+void newtScaleSetColors(newtComponent co, int empty, int full) {
+ struct scale * sc = co->data;
+
+ sc->csEmpty = empty;
+ sc->csFull = full;
+ scaleDraw(co);
+}
+
static void scaleDraw(newtComponent co) {
struct scale * sc = co->data;
int i;
sprintf(percent, "%3d%%", sc->percentage);
- SLsmg_set_color(NEWT_COLORSET_FULLSCALE);
+ SLsmg_set_color(sc->csFull);
for (i = 0; i < co->width; i++) {
if (i == sc->charsSet)
- SLsmg_set_color(NEWT_COLORSET_EMPTYSCALE);
+ SLsmg_set_color(sc->csEmpty);
if (i >= xlabel && i < xlabel+4)
SLsmg_write_char(percent[i-xlabel]);
else
return co;
}
+void newtScrollbarSetColors(newtComponent co, int normal, int thumb) {
+ struct scrollbar * sb = co->data;
+
+ sb->cs = normal;
+ sb->csThumb = thumb;
+ sbDraw(co);
+}
+
static void sbDraw(newtComponent co) {
struct scrollbar * sb = co->data;
int i;
int numLines;
int linesAlloced;
int doWrap;
- newtComponent sb_act, sb;
+ newtComponent sb;
int topLine;
int textWidth;
int isActive;
+ int cs;
+ int csActive;
};
static char * expandTabs(const char * text);
co->isMapped = isMapped;
if (tb->sb) {
tb->sb->ops->mapped(tb->sb, isMapped);
- tb->sb_act->ops->mapped(tb->sb_act, isMapped);
}
}
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);
}
}
tb->topLine = 0;
tb->textWidth = width;
tb->isActive = 0;
+ tb->cs = COLORSET_TEXTBOX;
+ tb->csActive = COLORSET_ACTTEXTBOX;
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->height, tb->cs, tb->cs);
co->takesFocus = 1;
} else {
- tb->sb_act = tb->sb = NULL;
+ tb->sb = NULL;
}
return co;
}
+void newtTextboxSetColors(newtComponent co, int normal, int active) {
+ struct textbox * tb = co->data;
+
+ tb->cs = normal;
+ tb->csActive = active;
+ textboxDraw(co);
+}
+
static char * expandTabs(const char * text) {
int bufAlloced = strlen(text) + 40;
char * buf, * dest;
if (tb->sb) {
size = tb->numLines - c->height;
- 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);
- }
+ newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0);
+ newtScrollbarSetColors(tb->sb, tb->isActive ? tb->csActive :
+ tb->cs, tb->cs);
}
- SLsmg_set_color(NEWT_COLORSET_TEXTBOX);
+ SLsmg_set_color(tb->cs);
for (i = 0; (i + tb->topLine) < tb->numLines && i < c->height; i++) {
newtGotorc(c->top + i, c->left);
if (tb->sb)
tb->sb->ops->destroy(tb->sb);
- if (tb->sb_act)
- tb->sb_act->ops->destroy(tb->sb_act);
for (i = 0; i < tb->numLines; i++)
free(tb->lines[i]);
free(tb->lines);