When building the font menu, also include font styles.

Now it's possible to select bold or oblique font styles.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33946 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2009-11-08 12:22:57 +00:00
parent 57bd46cca2
commit e3b9a828db
+37 -15
View File
@@ -140,16 +140,25 @@ AppearancePrefView::MessageReceived(BMessage *msg)
switch (msg->what) { switch (msg->what) {
case MSG_HALF_FONT_CHANGED: case MSG_HALF_FONT_CHANGED:
if (strcmp( {
PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY), const char *family = NULL;
fFont->Menu()->FindMarked()->Label())) { const char *style = NULL;
msg->FindString("font_family", &family);
PrefHandler::Default()->setString(PREF_HALF_FONT_FAMILY, msg->FindString("font_style", &style);
fFont->Menu()->FindMarked()->Label());
PrefHandler *pref = PrefHandler::Default();
const char *currentFamily
= pref->getString(PREF_HALF_FONT_FAMILY);
const char *currentStyle
= pref->getString(PREF_HALF_FONT_STYLE);
if (currentFamily == NULL || strcmp(currentFamily, family)
|| currentStyle == NULL || strcmp(currentStyle, style)) {
pref->setString(PREF_HALF_FONT_FAMILY, family);
pref->setString(PREF_HALF_FONT_STYLE, style);
modified = true; modified = true;
} }
break; break;
}
case MSG_HALF_SIZE_CHANGED: case MSG_HALF_SIZE_CHANGED:
if (strcmp(PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE), if (strcmp(PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE),
fFontSize->Menu()->FindMarked()->Label())) { fFontSize->Menu()->FindMarked()->Label())) {
@@ -223,17 +232,30 @@ AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
BPopUpMenu *menu = new BPopUpMenu(""); BPopUpMenu *menu = new BPopUpMenu("");
int32 numFamilies = count_font_families(); int32 numFamilies = count_font_families();
uint32 flags; uint32 flags;
for (int32 i = 0; i < numFamilies; i++) { for (int32 i = 0; i < numFamilies; i++) {
font_family family; font_family family;
if (get_font_family(i, &family, &flags) == B_OK) { if (get_font_family(i, &family, &flags) == B_OK) {
BFont font; BFont font;
font.SetFamilyAndStyle(family, NULL); font_style style;
if (IsFontUsable(font)) { int32 numStyles = count_font_styles(family);
BMenuItem *item = new BMenuItem(family, new BMessage(command)); for (int32 j = 0; j < numStyles; j++) {
menu->AddItem(item); if (get_font_style(family, j, &style) == B_OK) {
if (!strcmp(defaultFontName, family)) font.SetFamilyAndStyle(family, style);
item->SetMarked(true); if (IsFontUsable(font)) {
BMessage *message = new BMessage(command);
message->AddString("font_family", family);
message->AddString("font_style", style);
char itemLabel[134];
snprintf(itemLabel, sizeof(itemLabel),
"%s - %s", family, style);
BMenuItem *item = new BMenuItem(itemLabel,
message);
menu->AddItem(item);
if (!strcmp(defaultFontName, family))
item->SetMarked(true);
}
}
} }
} }
} }