[haiku-commits] r33946 - haiku/trunk/src/apps/terminal

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 8 Nov 2009 13:22:57 +0100 (CET)

Author: jackburton
Date: 2009-11-08 13:22:57 +0100 (Sun, 08 Nov 2009)
New Revision: 33946
Changeset: http://dev.haiku-os.org/changeset/33946/haiku

Modified:
   haiku/trunk/src/apps/terminal/AppearPrefView.cpp
Log:
When building the font menu, also include font styles.
Now it's possible to select bold or oblique font styles.


Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2009-11-08 11:47:04 UTC 
(rev 33945)
+++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2009-11-08 12:22:57 UTC 
(rev 33946)
@@ -140,16 +140,25 @@
 
        switch (msg->what) {
                case MSG_HALF_FONT_CHANGED:
-                       if (strcmp(
-                                       
PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY),
-                                       fFont->Menu()->FindMarked()->Label())) {
-
-                               
PrefHandler::Default()->setString(PREF_HALF_FONT_FAMILY,
-                                       fFont->Menu()->FindMarked()->Label());
+               {
+                       const char *family = NULL;
+                       const char *style = NULL;
+                       msg->FindString("font_family", &family);
+                       msg->FindString("font_style", &style);
+                       
+                       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;
                        }
                        break;
-
+               }
                case MSG_HALF_SIZE_CHANGED:
                        if 
(strcmp(PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE),
                                        
fFontSize->Menu()->FindMarked()->Label())) {
@@ -223,17 +232,30 @@
        BPopUpMenu *menu = new BPopUpMenu("");
        int32 numFamilies = count_font_families();
        uint32 flags;
-
+       
        for (int32 i = 0; i < numFamilies; i++) {
                font_family family;
                if (get_font_family(i, &family, &flags) == B_OK) {
-                       BFont font;     
-                       font.SetFamilyAndStyle(family, NULL);
-                       if (IsFontUsable(font)) {
-                               BMenuItem *item = new BMenuItem(family, new 
BMessage(command));
-                               menu->AddItem(item);
-                               if (!strcmp(defaultFontName, family))
-                                       item->SetMarked(true);
+                       BFont font;
+                       font_style style;
+                       int32 numStyles = count_font_styles(family);
+                       for (int32 j = 0; j < numStyles; j++) {
+                               if (get_font_style(family, j, &style) == B_OK) {
+                                       font.SetFamilyAndStyle(family, style);
+                                       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);
+                                       }
+                               }
                        }
                }
        }


Other related posts:

  • » [haiku-commits] r33946 - haiku/trunk/src/apps/terminal - stefano . ceccherini