diff options
author | jenglish <jenglish@flightlab.com> | 2009-05-17 17:20:49 (GMT) |
---|---|---|
committer | jenglish <jenglish@flightlab.com> | 2009-05-17 17:20:49 (GMT) |
commit | fedc91c632885648cba16921035074ccfe304a7a (patch) | |
tree | 53fd85601ffbc6bc683a19b557664a58ea418c61 /generic/ttk | |
parent | c265c7f85e42f687c1e3205d2f8a1c9274a42a4f (diff) | |
download | tk-fedc91c632885648cba16921035074ccfe304a7a.zip tk-fedc91c632885648cba16921035074ccfe304a7a.tar.gz tk-fedc91c632885648cba16921035074ccfe304a7a.tar.bz2 |
BUGFIX: last commit did not account for possibility of 0 tabs.
Diffstat (limited to 'generic/ttk')
-rw-r--r-- | generic/ttk/ttkNotebook.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 7ad371c..34a9c0a 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -1,4 +1,4 @@ -/* $Id: ttkNotebook.c,v 1.19 2009/05/17 17:04:48 jenglish Exp $ +/* $Id: ttkNotebook.c,v 1.20 2009/05/17 17:20:49 jenglish Exp $ * Copyright (c) 2004, Joe English */ @@ -456,25 +456,28 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) static void SqueezeTabs( Notebook *nb, int needed, int available, int minTabWidth) { - int nTabs = Ttk_NumberSlaves(nb->notebook.mgr), - difference = available - needed, - delta = difference / nTabs, - remainder = difference % nTabs; - int slack = 0; - int i; + int nTabs = Ttk_NumberSlaves(nb->notebook.mgr); - if (remainder < 0) { remainder += nTabs; --delta; } + if (nTabs > 0) { + int difference = available - needed, + delta = difference / nTabs, + remainder = difference % nTabs, + slack = 0; + int i; - for (i = 0; i < nTabs; ++i) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i); - int adj = delta + (i < remainder) + slack; + if (remainder < 0) { remainder += nTabs; --delta; } - if (tab->width + adj >= minTabWidth) { - tab->width += adj; - slack = 0; - } else { - slack = adj - (minTabWidth - tab->width); - tab->width = minTabWidth; + for (i = 0; i < nTabs; ++i) { + Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i); + int adj = delta + (i < remainder) + slack; + + if (tab->width + adj >= minTabWidth) { + tab->width += adj; + slack = 0; + } else { + slack = adj - (minTabWidth - tab->width); + tab->width = minTabWidth; + } } } } |