7 : BMenu("", B_ITEMS_IN_COLUMN
)
15 { /*nothing to clean up*/}
20 int32 numFamilies
= count_font_families();
21 for ( int32 i
= 0; i
< numFamilies
; i
++ ) {
22 font_family
*family
= (font_family
*)malloc(sizeof(font_family
));
24 if ( get_font_family(i
, family
, &flags
) == B_OK
) {
25 fontStyleMenu
= new BMenu(*family
, B_ITEMS_IN_COLUMN
);
26 fontStyleMenu
->SetRadioMode(true);
27 int32 numStyles
= count_font_styles(*family
);
28 for ( int32 j
= 0; j
< numStyles
; j
++ ) {
29 font_style
*style
= (font_style
*)malloc(sizeof(font_style
));
30 if ( get_font_style(*family
, j
, style
, &flags
) == B_OK
) {
31 BMessage
*msg
= new BMessage(MENU_FONT_STYLE
);
32 msg
->AddPointer("family", family
);
33 msg
->AddPointer("style", style
);
34 fontStyleItem
= new BMenuItem(*style
, msg
, 0, 0);
35 fontStyleMenu
->AddItem(fontStyleItem
);
38 BMessage
*msg
= new BMessage(MENU_FONT_FAMILY
);
39 msg
->AddPointer("family", family
);
40 font_style
*style
= (font_style
*)malloc(sizeof(font_style
));
41 // if font family selected, we need to change style to
43 if ( get_font_style(*family
, 0, style
, &flags
) == B_OK
)
44 msg
->AddPointer("style", style
);
45 fontFamily
= new BMenuItem(fontStyleMenu
, msg
);
54 // it may be better to pull all menu prefs
55 // related stuff out of the FontMenu class
56 // so it can be easily reused in other apps
61 font
.SetFamilyAndStyle(info
.f_family
, info
.f_style
);
62 font
.SetSize(info
.font_size
);
67 for (int i
= 0; i
< CountItems(); i
++) {
68 ItemAt(i
)->Submenu()->SetFont(&font
);
71 ClearAllMarkedItems();
72 PlaceCheckMarkOnFont(info
.f_family
, info
.f_style
);
76 FontMenu::PlaceCheckMarkOnFont(font_family family
, font_style style
)
78 BMenuItem
*fontFamilyItem
;
79 BMenuItem
*fontStyleItem
;
82 fontFamilyItem
= FindItem(family
);
84 if ((fontFamilyItem
!= NULL
) && (family
!= NULL
))
86 fontFamilyItem
->SetMarked(true);
87 styleMenu
= fontFamilyItem
->Submenu();
89 if ((styleMenu
!= NULL
) && (style
!= NULL
))
91 fontStyleItem
= styleMenu
->FindItem(style
);
93 if (fontStyleItem
!= NULL
)
95 fontStyleItem
->SetMarked(true);
110 FontMenu::ClearAllMarkedItems()
112 // we need to clear all menuitems and submenuitems
113 for (int i
= 0; i
< CountItems(); i
++) {
114 ItemAt(i
)->SetMarked(false);
116 BMenu
*submenu
= ItemAt(i
)->Submenu();
117 for (int j
= 0; j
< submenu
->CountItems(); j
++) {
118 submenu
->ItemAt(j
)->SetMarked(false);