]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
added newtEntrySetFlags(), NEWT_ENTRY_DISABLED
authorewt <ewt>
Wed, 4 Dec 1996 19:16:43 +0000 (19:16 +0000)
committerewt <ewt>
Wed, 4 Dec 1996 19:16:43 +0000 (19:16 +0000)
entry.c
newt.h

diff --git a/entry.c b/entry.c
index 5e9e54b94313b23dc4f60c5ebdedb3bd18ab57e6..7aa76d3db525ecf0c28095d3b7fe4eaa5591fef8 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -63,7 +63,6 @@ newtComponent newtEntry(int left, int top, char * initialValue, int width,
     co->left = left;
     co->height = 1;
     co->width = width;
-    co->takesFocus = 1;
     co->callback = NULL;
 
     co->ops = &entryOps;
@@ -74,6 +73,11 @@ newtComponent newtEntry(int left, int top, char * initialValue, int width,
     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;
     }
@@ -98,10 +102,14 @@ static void entryDraw(newtComponent co) {
     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);
@@ -110,7 +118,6 @@ static void entryDraw(newtComponent co) {
     }
 
     newtGotorc(co->top, co->left);
-    SLsmg_set_color(COLORSET_ENTRY);
 
     if (en->cursorPosition < en->firstChar) {
        /* scroll to the left */
@@ -140,6 +147,22 @@ static void entryDraw(newtComponent co) {
        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;
 
diff --git a/newt.h b/newt.h
index ca788469cb45db6acf4da4192ee1a1d99854b533..2f16c38bb6882e166bd1cd3da729b649f590223b 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -20,6 +20,9 @@
 #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;
@@ -40,6 +43,7 @@ struct newtColors {
     char * helpLineFg, * helpLineBg;
     char * rootTextFg, * rootTextBg;
     char * emptyScale, * fullScale;
+    char * disabledEntryFg, * disabledEntryBg;
 };
 
 typedef struct newtComponent * newtComponent;
@@ -127,10 +131,12 @@ void newtFormAddHotKey(newtComponent co, int key);
 #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);