summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/ttk/ttkNotebook.c37
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;
+ }
}
}
}