]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
Added a hack to disable checkboxes. This will go away with a generic
authormsw <msw>
Fri, 5 Feb 1999 19:30:35 +0000 (19:30 +0000)
committermsw <msw>
Fri, 5 Feb 1999 19:30:35 +0000 (19:30 +0000)
comp flag setting function later.

checkbox.c
newt.h

index 785c17f65fffd693ed9c0eef0baada5641f840dd..c7db4187ddc67ad9816ceba339a89a1b17479b1c 100644 (file)
@@ -123,11 +123,35 @@ newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
     return co;
 }
 
+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);
+}
+
 static void cbDraw(newtComponent c) {
     struct checkbox * cb = c->data;
 
     if (c->top == -1 || !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);
diff --git a/newt.h b/newt.h
index 1e408d5ee2533db850a291e5c1685e149c10ccd6..c6377fd248d1dbe7d43fd7fec6f46bc6e2fecfe7 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -124,6 +124,9 @@ newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
                           const char * seq, char * result);
 char newtCheckboxGetValue(newtComponent co);
 void newtCheckboxSetValue(newtComponent co, char value);
+void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
+
+    
 newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
                              newtComponent prevButton);
 newtComponent newtRadioGetCurrent(newtComponent setMember);
@@ -199,6 +202,7 @@ newtComponent newtEntry(int left, int top, const char * initialValue, int width,
 void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd);
 void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data);
 char * newtEntryGetValue(newtComponent co);
+void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
 
 newtComponent newtScale(int left, int top, int width, long long fullValue);
 void newtScaleSet(newtComponent co, unsigned long long amount);