From 2905062e64b7f40cbf0689476e3e4486ac40a9e4 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Mon, 21 Feb 2011 01:56:00 +0000 Subject: [PATCH] In CharacterMap: Separate the CodeView (info section at the bottom of the window) in 2 sections, one with the character itself, the other with the remaining infos (hex code, etc..) The idea behind this is that if the font in the CharacterView above is different than the default font used in that CodeView, it might happen that a glyph doesn't show in the CodeView below but was shown in the CharacterView above, or vice-versa. Fixes ticket #4020 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40589 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/charactermap/CharacterWindow.cpp | 18 +++++++++++++++--- src/apps/charactermap/CharacterWindow.h | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/apps/charactermap/CharacterWindow.cpp b/src/apps/charactermap/CharacterWindow.cpp index 39fd5395e8..feb6cb7a08 100644 --- a/src/apps/charactermap/CharacterWindow.cpp +++ b/src/apps/charactermap/CharacterWindow.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2011, Philippe Saint-Pierre, stpere@gmail.com. * Distributed under the terms of the MIT License. */ @@ -156,6 +157,10 @@ CharacterWindow::CharacterWindow() fCharacterView = new CharacterView("characters"); fCharacterView->SetTarget(this, kMsgCharacterChanged); + fGlyphView = new BStringView("glyph", ""); + fGlyphView->SetExplicitMaxSize(BSize(B_SIZE_UNSET, + fGlyphView->PreferredSize().Height())); + // TODO: have a context object shared by CharacterView/UnicodeBlockView bool show; if (settings.FindBool("show private blocks", &show) == B_OK) { @@ -210,7 +215,9 @@ CharacterWindow::CharacterWindow() .Add(BGroupLayoutBuilder(B_VERTICAL, 10) .Add(characterScroller) .Add(fFontSizeSlider) - .Add(fCodeView)) + .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) + .Add(fGlyphView) + .Add(fCodeView))) .SetInsets(10, 10, 10, 10))); // Add menu @@ -310,9 +317,13 @@ CharacterWindow::MessageReceived(BMessage* message) sizeof(utf8Hex)); char text[128]; - snprintf(text, sizeof(text), "'%s' %s: %#lx (%ld), UTF-8: %s", - utf8, B_TRANSLATE("Code"), character, character, utf8Hex); + snprintf(text, sizeof(text), " %s: %#lx (%ld), UTF-8: %s", + B_TRANSLATE("Code"), character, character, utf8Hex); + char glyph[20]; + snprintf(glyph, sizeof(glyph), "'%s'", utf8); + + fGlyphView->SetText(glyph); fCodeView->SetText(text); break; } @@ -487,6 +498,7 @@ CharacterWindow::_SetFont(const char* family, const char* style) font.SetFamilyAndStyle(family, style); fCharacterView->SetCharacterFont(font); + fGlyphView->SetFont(&font, B_FONT_FAMILY_AND_STYLE); } diff --git a/src/apps/charactermap/CharacterWindow.h b/src/apps/charactermap/CharacterWindow.h index 7d247535f3..dfc65d10da 100644 --- a/src/apps/charactermap/CharacterWindow.h +++ b/src/apps/charactermap/CharacterWindow.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2011, Philippe Saint-Pierre, stpere@gmail.com. * Distributed under the terms of the MIT License. */ #ifndef CHARACTER_WINDOW_H @@ -42,6 +43,7 @@ private: CharacterView* fCharacterView; BMenuItem* fSelectedFontItem; BSlider* fFontSizeSlider; + BStringView* fGlyphView; BStringView* fCodeView; };