FontSizeMenu marks the correct item on AttachedToWindow. Fixes bug 565

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17428 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-05-11 22:21:48 +00:00
parent a73a27510a
commit f56a708cde
2 changed files with 20 additions and 15 deletions

View File

@ -6,6 +6,7 @@
class FontSizeMenu : public AutoSettingsMenu {
public:
FontSizeMenu();
virtual void AttachedToWindow();
};

View File

@ -4,55 +4,59 @@
#include <Message.h>
#include <MenuItem.h>
#include <String.h>
#include <Window.h>
FontSizeMenu::FontSizeMenu()
:AutoSettingsMenu("Font Size", B_ITEMS_IN_COLUMN)
{
menu_info info;
MenuSettings::GetInstance()->Get(info);
BMessage *msg = new BMessage(MENU_FONT_SIZE);
msg->AddFloat("size", 9);
BMenuItem *item = new BMenuItem("9", msg, 0, 0);
AddItem(item);
if (info.font_size == 9)
item->SetMarked(true);
msg = new BMessage(MENU_FONT_SIZE);
msg->AddFloat("size", 10);
item = new BMenuItem("10", msg, 0, 0);
AddItem(item);
if (info.font_size == 10)
item->SetMarked(true);
msg = new BMessage(MENU_FONT_SIZE);
msg->AddFloat("size", 11);
item = new BMenuItem("11", msg, 0, 0);
AddItem(item);
if (info.font_size == 11)
item->SetMarked(true);
msg = new BMessage(MENU_FONT_SIZE);
msg->AddFloat("size", 12);
item = new BMenuItem("12", msg, 0, 0);
AddItem(item);
if (info.font_size == 12)
item->SetMarked(true);
msg = new BMessage(MENU_FONT_SIZE);
msg->AddFloat("size", 14);
item = new BMenuItem("14", msg, 0, 0);
AddItem(item);
if (info.font_size == 14)
item->SetMarked(true);
msg = new BMessage(MENU_FONT_SIZE);
msg->AddFloat("size", 18);
item = new BMenuItem("18", msg, 0, 0);
AddItem(item);
if (info.font_size == 18)
item->SetMarked(true);
SetRadioMode(true);
}
void
FontSizeMenu::AttachedToWindow()
{
AutoSettingsMenu::AttachedToWindow();
// Mark the menuitem with the current font size
menu_info info;
MenuSettings::GetInstance()->Get(info);
BString name;
name << (int)info.font_size;
BMenuItem *item = FindItem(name.String());
if (item != NULL)
item->SetMarked(true);
}