From f7b4d19dc41e1598c6e8ae185716f2d2654e9f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 4 May 2009 19:53:12 +0000 Subject: [PATCH] * Reverted r30529 as this was pretty much bogus (sorry stpere, but the size of the window was already set with its constructor). * Fixed the actual cause of bug #3752 instead: the fCharacterHeight and fTitleHeight members were not initialized when MinSize() was called. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30629 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/charactermap/CharacterView.cpp | 21 +++++++++++++++------ src/apps/charactermap/CharacterView.h | 1 + src/apps/charactermap/CharacterWindow.cpp | 15 ++++++--------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/apps/charactermap/CharacterView.cpp b/src/apps/charactermap/CharacterView.cpp index ab0be0bd68..382a94b39a 100644 --- a/src/apps/charactermap/CharacterView.cpp +++ b/src/apps/charactermap/CharacterView.cpp @@ -33,6 +33,8 @@ CharacterView::CharacterView(const char* name) { fTitleTops = new int32[kNumUnicodeBlocks]; fCharacterFont.SetSize(fCharacterFont.Size() * 1.5f); + + _UpdateFontSize(); } @@ -479,12 +481,8 @@ CharacterView::_GetCharacterAt(BPoint point, uint32& character, BRect* _frame) void -CharacterView::_UpdateSize() +CharacterView::_UpdateFontSize() { - // Compute data rect - - BRect bounds = Bounds(); - font_height fontHeight; GetFontHeight(&fontHeight); fTitleHeight = (int32)ceilf(fontHeight.ascent + fontHeight.descent @@ -510,6 +508,17 @@ CharacterView::_UpdateSize() fCharacterHeight += fGap; fTitleGap = fGap * 3; +} + + +void +CharacterView::_UpdateSize() +{ + // Compute data rect + + BRect bounds = Bounds(); + + _UpdateFontSize(); fDataRect.right = bounds.Width(); fDataRect.bottom = 0; @@ -583,7 +592,7 @@ BRect CharacterView::_FrameFor(uint32 character) { // find block containing the character - + // TODO: could use binary search here for (uint32 i = 0; i < kNumUnicodeBlocks; i++) { diff --git a/src/apps/charactermap/CharacterView.h b/src/apps/charactermap/CharacterView.h index d54650f01c..8183efdf81 100644 --- a/src/apps/charactermap/CharacterView.h +++ b/src/apps/charactermap/CharacterView.h @@ -59,6 +59,7 @@ private: int32 _BlockAt(BPoint point); bool _GetCharacterAt(BPoint point, uint32& character, BRect* _frame = NULL); + void _UpdateFontSize(); void _UpdateSize(); bool _GetTopmostCharacter(uint32& character, int32& offset); diff --git a/src/apps/charactermap/CharacterWindow.cpp b/src/apps/charactermap/CharacterWindow.cpp index 53a3fa4f8e..99e52e378a 100644 --- a/src/apps/charactermap/CharacterWindow.cpp +++ b/src/apps/charactermap/CharacterWindow.cpp @@ -52,7 +52,7 @@ public: { SetModificationMessage(message); } - + protected: const char* UpdateText() const { @@ -126,9 +126,6 @@ CharacterWindow::CharacterWindow() if (settings.FindRect("window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); - } else { - MoveTo(BPoint(100, 100)); - ResizeTo(600, 450); } // create GUI @@ -315,7 +312,7 @@ CharacterWindow::MessageReceived(BMessage* message) fSelectedFontItem = item; _SetFont(item->Menu()->Name(), item->Label()); - } + } break; } @@ -339,7 +336,7 @@ CharacterWindow::MessageReceived(BMessage* message) if (message->FindPointer("source", (void**)&item) != B_OK || item == NULL) break; - + item->SetMarked(!item->IsMarked()); fCharacterView->ShowPrivateBlocks(item->IsMarked()); @@ -353,7 +350,7 @@ CharacterWindow::MessageReceived(BMessage* message) if (message->FindPointer("source", (void**)&item) != B_OK || item == NULL) break; - + item->SetMarked(!item->IsMarked()); fCharacterView->ShowContainedBlocksOnly(item->IsMarked()); @@ -434,11 +431,11 @@ CharacterWindow::_SaveSettings() status = settings.AddBool("show contained blocks only", fCharacterView->IsShowingContainedBlocksOnly()); } - + if (status == B_OK) { BFont font = fCharacterView->CharacterFont(); status = settings.AddInt32("font size", font.Size()); - + font_family family; font_style style; if (status == B_OK)