co->left = left;
co->height = 1;
co->width = width;
- co->takesFocus = 1;
co->callback = NULL;
co->ops = &entryOps;
en->bufUsed = 0;
en->bufAlloced = width + 1;
+ if (!(en->flags & NEWT_ENTRY_DISABLED))
+ co->takesFocus = 1;
+ else
+ co->takesFocus = 0;
+
if (initialValue && strlen(initialValue) > width) {
en->bufAlloced = strlen(initialValue) + 1;
}
int len;
if (co->top == -1) return;
+
+ if (en->flags & NEWT_ENTRY_DISABLED)
+ SLsmg_set_color(NEWT_COLORSET_DISENTRY);
+ else
+ SLsmg_set_color(NEWT_COLORSET_ENTRY);
if (en->flags & NEWT_ENTRY_HIDDEN) {
newtGotorc(co->top, co->left);
- SLsmg_set_color(COLORSET_ENTRY);
for (i = 0; i < co->width; i++)
SLsmg_write_char('_');
newtGotorc(co->top, co->left);
}
newtGotorc(co->top, co->left);
- SLsmg_set_color(COLORSET_ENTRY);
if (en->cursorPosition < en->firstChar) {
/* scroll to the left */
newtGotorc(co->top, co->left + (en->cursorPosition - en->firstChar));
}
+void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {
+ struct entry * en = co->data;
+ int row, col;
+
+ en->flags = newtSetFlags(en->flags, flags, sense);
+
+ if (!(en->flags & NEWT_ENTRY_DISABLED))
+ co->takesFocus = 1;
+ else
+ co->takesFocus = 0;
+
+ newtGetrc(&row, &col);
+ entryDraw(co);
+ newtGotorc(row, col);
+}
+
static void entryDestroy(newtComponent co) {
struct entry * en = co->data;
#define NEWT_COLORSET_ROOTTEXT 18
#define NEWT_COLORSET_EMPTYSCALE 19
#define NEWT_COLORSET_FULLSCALE 20
+#define NEWT_COLORSET_DISENTRY 21
+
+enum newtFlagsSense { NEWT_FLAGS_SET, NEWT_FLAGS_RESET };
struct newtColors {
char * rootFg, * rootBg;
char * helpLineFg, * helpLineBg;
char * rootTextFg, * rootTextBg;
char * emptyScale, * fullScale;
+ char * disabledEntryFg, * disabledEntryBg;
};
typedef struct newtComponent * newtComponent;
#define NEWT_ENTRY_SCROLL (1 << 0)
#define NEWT_ENTRY_HIDDEN (1 << 1)
#define NEWT_ENTRY_RETURNEXIT (1 << 2)
+#define NEWT_ENTRY_DISABLED (1 << 3)
newtComponent newtEntry(int left, int top, char * initialValue, int width,
char ** resultPtr, int flags);
void newtEntrySet(newtComponent co, char * value, int cursorAtEnd);
+void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
newtComponent newtScale(int left, int top, int width, long long fullValue);
void newtScaleSet(newtComponent co, long long amount);