Patch by diver: selected font family is now check marked too.

Closes #5624.
Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38632 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2010-09-13 14:19:41 +00:00
parent cf9f178538
commit 2f313958ce

View File

@ -64,6 +64,7 @@ private:
mutable char fText[32];
};
class RedirectUpAndDownFilter : public BMessageFilter {
public:
RedirectUpAndDownFilter(BHandler* target)
@ -89,6 +90,7 @@ private:
BHandler* fTarget;
};
class EscapeMessageFilter : public BMessageFilter {
public:
EscapeMessageFilter(uint32 command)
@ -298,20 +300,25 @@ CharacterWindow::MessageReceived(BMessage* message)
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 @@ BMenu*
CharacterWindow::_CreateFontMenu()
{
BMenu* menu = new BMenu("Font");
BMenuItem* item;
font_family currentFamily;
font_style currentStyle;
@ -475,6 +483,8 @@ CharacterWindow::_CreateFontMenu()
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 @@ CharacterWindow::_CreateFontMenu()
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 @@ CharacterWindow::_CreateFontMenu()
}
}
item = menu->FindItem(currentFamily);
item->SetMarked(true);
return menu;
}