[haiku-commits] r38632 - haiku/trunk/src/apps/charactermap

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 13 Sep 2010 16:19:41 +0200 (CEST)

Author: phoudoin
Date: 2010-09-13 16:19:41 +0200 (Mon, 13 Sep 2010)
New Revision: 38632
Changeset: http://dev.haiku-os.org/changeset/38632
Ticket: http://dev.haiku-os.org/ticket/5624

Modified:
   haiku/trunk/src/apps/charactermap/CharacterWindow.cpp
Log:
Patch by diver: selected font family is now check marked too.
Closes #5624.
Thanks!


Modified: haiku/trunk/src/apps/charactermap/CharacterWindow.cpp
===================================================================
--- haiku/trunk/src/apps/charactermap/CharacterWindow.cpp       2010-09-13 
13:37:01 UTC (rev 38631)
+++ haiku/trunk/src/apps/charactermap/CharacterWindow.cpp       2010-09-13 
14:19:41 UTC (rev 38632)
@@ -64,6 +64,7 @@
        mutable char    fText[32];
 };
 
+
 class RedirectUpAndDownFilter : public BMessageFilter {
 public:
        RedirectUpAndDownFilter(BHandler* target)
@@ -89,6 +90,7 @@
        BHandler*       fTarget;
 };
 
+
 class EscapeMessageFilter : public BMessageFilter {
 public:
        EscapeMessageFilter(uint32 command)
@@ -298,20 +300,25 @@
                case kMsgFontSelected:
                {
                        BMenuItem* item;
+
                        if (message->FindPointer("source", (void**)&item) != 
B_OK)
                                break;
 
                        fSelectedFontItem->SetMarked(false);
 
                        // If it's the family menu, just select the first style
-                       if (item->Submenu() != NULL)
+                       if (item->Submenu() != NULL) {
+                               item->SetMarked(true);
                                item = item->Submenu()->ItemAt(0);
+                       }
 
                        if (item != NULL) {
                                item->SetMarked(true);
                                fSelectedFontItem = item;
 
                                _SetFont(item->Menu()->Name(), item->Label());
+                               item = item->Menu()->Superitem();
+                               item->SetMarked(true);
                        }
                        break;
                }
@@ -467,6 +474,7 @@
 CharacterWindow::_CreateFontMenu()
 {
        BMenu* menu = new BMenu("Font");
+       BMenuItem* item;
 
        font_family currentFamily;
        font_style currentStyle;
@@ -475,6 +483,8 @@
 
        int32 numFamilies = count_font_families();
 
+       menu->SetRadioMode(true);
+
        for (int32 i = 0; i < numFamilies; i++) {
                font_family family;
                if (get_font_family(i, &family) == B_OK) {
@@ -487,8 +497,7 @@
                                font_style style;
                                uint32 flags;
                                if (get_font_style(family, j, &style, &flags) 
== B_OK) {
-                                       BMenuItem* item = new BMenuItem(style,
-                                               new BMessage(kMsgFontSelected));
+                                       item = new BMenuItem(style,     new 
BMessage(kMsgFontSelected));
                                        subMenu->AddItem(item);
 
                                        if (!strcmp(family, currentFamily)
@@ -501,5 +510,8 @@
                }
        }
 
+       item = menu->FindItem(currentFamily);
+       item->SetMarked(true);
+
        return menu;
 }


Other related posts: