struct items ** flatList, ** currItem, ** firstItem;
int flatCount;
int flags;
- int pad;
+ int sbAdjust;
+ int curWidth;
+ int userHasSetWidth;
char * seq;
char * result;
};
static void doBuildFlatList(struct CheckboxTree * ct, struct items * item);
enum countWhat { COUNT_EXPOSED=0, COUNT_SELECTED=1 };
static int countItems(struct items * item, enum countWhat justExposed);
+static inline void updateWidth(newtComponent co, struct CheckboxTree * ct,
+ int maxField);
static struct componentOps ctOps = {
ctDraw,
ctMapped,
} ;
+static inline void updateWidth(newtComponent co, struct CheckboxTree * ct,
+ int maxField) {
+ ct->curWidth = maxField;
+ co->width = ct->curWidth + ct->sbAdjust;
+
+ if (ct->sb)
+ ct->sb->left = co->left + co->width - 1;
+}
+
static int countItems(struct items * item, enum countWhat what) {
int count = 0;
i = 4 + (3 * item->depth);
- if ((strlen(text) + i + ct->pad) > co->width) {
- co->width = strlen(text) + i + ct->pad;
+ if ((ct->userHasSetWidth == 0) && ((strlen(text) + i + ct->sbAdjust) > co->width)) {
+ updateWidth(co, ct, strlen(text) + i);
}
return 0;
}
}
+void newtCheckboxTreeSetWidth(newtComponent co, int width) {
+ struct CheckboxTree * ct = co->data;
+
+ co->width = width;
+ ct->curWidth = co->width - ct->sbAdjust;
+ ct->userHasSetWidth = 1;
+ if (ct->sb) ct->sb->left = co->width + co->left - 1;
+ ctDraw(co);
+}
+
const void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems)
{
return newtCheckboxTreeGetMultiSelection(co, numitems, 0);
co->height = height;
co->width = 0;
co->isMapped = 0;
+ ct->curWidth = 0;
+ ct->userHasSetWidth = 0;
ct->itemlist = NULL;
ct->firstItem = NULL;
ct->currItem = NULL;
if (flags & NEWT_FLAG_SCROLL) {
ct->sb = newtVerticalScrollbar(left, top, height,
COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
- ct->pad = 2;
+ ct->sbAdjust = 2;
} else {
ct->sb = NULL;
- ct->pad = 0;
+ ct->sbAdjust = 0;
}
return co;
i = 4 + (3 * item->depth);
- if ((strlen(text) + i + ct->pad) > co->width) {
- co->width = strlen(text) + i + ct->pad;
+ if ((ct->userHasSetWidth == 0) && ((strlen(text) + i + ct->sbAdjust) > co->width)) {
+ updateWidth(co, ct, strlen(text) + i);
}
ctDraw(co);
VERSION=$(awk '/^%define version/ {print $3}' newt.spec)
-VERSION=0.50.27
+VERSION=0.50.29
SONAME=0.50
AC_SUBST(VERSION)
AC_SUBST(SONAME)
int * newtCheckboxTreeFindItem(newtComponent co, void * data);
void newtCheckboxTreeSetEntry(newtComponent co, const void * data,
const char * text);
+void newtCheckboxTreeSetWidth(newtComponent co, int width);
char newtCheckboxTreeGetEntryValue(newtComponent co, const void * data);
void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data,
char value);
Summary: A development library for text mode user interfaces.
Name: newt
-%define version 0.50.28
+%define version 0.50.29
Version: %{version}
Release: 1
Copyright: LGPL
%endif
%changelog
+* Thu Jul 05 2001 Crutcher Dunnavant <crutcher@redhat.com>
+- taught CheckboxTrees about width. Whohoo! 2-D!!!
+
* Thu Jul 05 2001 Crutcher Dunnavant <crutcher@redhat.com>
- added 'hide_checkbox' and 'unselectable' options to CheckboxTrees
curr = self.w.checkboxtreeGetCurrent()
return self.key2item[curr]
- def __init__(self, height, scroll = 0, hide_checkbox = 0, unselectable = 0):
+ def __init__(self, height, width = None, scroll = 0, hide_checkbox = 0, unselectable = 0):
self.w = _snack.checkboxtree(height, scroll, hide_checkbox, unselectable)
self.key2item = {}
self.item2key = {}
+ if (width):
+ self.w.checkboxtreeSetWidth(width)
def getSelection(self):
selection = []
static PyObject * widgetCheckboxTreeGetSel(snackWidget * s, PyObject * args);
static PyObject * widgetCheckboxTreeGetCur(snackWidget * s, PyObject * args);
static PyObject * widgetCheckboxTreeSetEntry(snackWidget * s, PyObject * args);
+static PyObject * widgetCheckboxTreeSetWidth(snackWidget * s, PyObject * args);
static PyObject * widgetCheckboxTreeSetCurrent(snackWidget * s, PyObject * args);
static PyObject * widgetCheckboxTreeSetEntryValue(snackWidget * s, PyObject * args);
static PyObject * widgetCheckboxTreeGetEntryValue(snackWidget * s, PyObject * args);
METH_VARARGS, NULL },
{ "checkboxtreeSetEntry", (PyCFunction) widgetCheckboxTreeSetEntry,
METH_VARARGS, NULL },
+ { "checkboxtreeSetWidth", (PyCFunction) widgetCheckboxTreeSetWidth, METH_VARARGS, NULL },
{ "checkboxtreeSetCurrent", (PyCFunction) widgetCheckboxTreeSetCurrent,
METH_VARARGS, NULL },
{ "checkboxtreeSetEntryValue", (PyCFunction) widgetCheckboxTreeSetEntryValue,
return Py_None;
}
+static PyObject * widgetCheckboxTreeSetWidth(snackWidget * s, PyObject * args) {
+ int width;
+
+ if (!PyArg_ParseTuple(args, "i", &width))
+ return NULL;
+
+ newtCheckboxTreeSetWidth(s->co, width);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyObject * widgetCheckboxTreeSetCurrent(snackWidget * s, PyObject * args) {
int data;