diff options
author | nyamatongwe <devnull@localhost> | 2000-07-12 08:17:58 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-07-12 08:17:58 +0000 |
commit | e0d66e1b38fcc1de6eb131cd4b5c90f38a6aeea6 (patch) | |
tree | 5532df06e74e7b858a87d6087c946514e2813058 | |
parent | a4cde497e296ebdeedeafe2519e75a09c6fd9488 (diff) | |
download | scintilla-mirror-e0d66e1b38fcc1de6eb131cd4b5c90f38a6aeea6.tar.gz |
Fixed up infinite resize.
Made GTK+ version ListBox responsive to font choice when finding good size.
-rw-r--r-- | gtk/PlatGTK.cxx | 23 | ||||
-rw-r--r-- | include/Platform.h | 2 |
2 files changed, 16 insertions, 9 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 3e59cf6c3..32323e807 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -525,7 +525,7 @@ PRectangle Window::GetPosition() { } void Window::SetPosition(PRectangle rc) { -#if 0 +#if 1 //gtk_widget_set_uposition(id, rc.left, rc.top); GtkAllocation alloc; alloc.x = rc.left; @@ -533,9 +533,10 @@ void Window::SetPosition(PRectangle rc) { alloc.width = rc.Width(); alloc.height = rc.Height(); gtk_widget_size_allocate(id, &alloc); -#endif +#else gtk_widget_set_uposition(id, rc.left, rc.top); gtk_widget_set_usize(id, rc.right - rc.left,rc.bottom - rc.top); +#endif } void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { @@ -670,12 +671,16 @@ PRectangle ListBox::GetDesiredRect() { // Before any size allocated pretend its 100 wide so not scrolled PRectangle rc(0, 0, 100, 100); if (id) { + int rows = Length(); + if ((rows == 0) || (rows > desiredVisibleRows)) + rows = desiredVisibleRows; + GtkRequisition req; int height; // First calculate height of the clist for our desired visible row count otherwise it tries to expand to the total # of rows - height = (desired_visible_rows * GTK_CLIST(list)->row_height - + desired_visible_rows + 1 + height = (rows * GTK_CLIST(list)->row_height + + rows + 1 + 2 * (list->style->klass->ythickness + GTK_CONTAINER(list)->border_width)); gtk_widget_set_usize(GTK_WIDGET(list), -1, height); @@ -686,10 +691,12 @@ PRectangle ListBox::GetDesiredRect() { rc.bottom = req.height; gtk_widget_set_usize(GTK_WIDGET(list), -1, -1); - int width = maxItemCharacters; - if (width < 12) - width = 12; - rc.right = width * 8 + 16; + int width = maxItemCharacters; + if (width < 12) + width = 12; + rc.right = width * (aveCharWidth+aveCharWidth/3); + if (Length() > rows) + rc.right = rc.right + 16; } return rc; diff --git a/include/Platform.h b/include/Platform.h index 6fff59afa..14be5cebd 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -346,7 +346,7 @@ class ListBox : public Window { int current; #endif int desiredVisibleRows; - size_t maxItemCharacters; + unsigned int maxItemCharacters; unsigned int aveCharWidth; public: ListBox(); |