diff --git a/src/add-ons/screen_savers/message/Message.cpp b/src/add-ons/screen_savers/message/Message.cpp index 50e6640343..a17af0b7a9 100644 --- a/src/add-ons/screen_savers/message/Message.cpp +++ b/src/add-ons/screen_savers/message/Message.cpp @@ -88,18 +88,21 @@ class Message : public BScreenSaver void Draw(BView *view, int32 frame); void StartConfig(BView *view); status_t StartSaver(BView *view, bool preview); - + private: - BObjectList fFontFamilies; + struct font_family_wrapper { + font_family val; + }; + BObjectList fFontFamilies; float fScaleFactor; bool fPreview; }; -BScreenSaver *instantiate_screen_saver(BMessage *msg, image_id image) -{ +BScreenSaver *instantiate_screen_saver(BMessage *msg, image_id image) +{ return new Message(msg, image); -} +} Message::Message(BMessage *archive, image_id id) @@ -112,20 +115,20 @@ Message::~Message() { for (int32 i = 0; i < fFontFamilies.CountItems(); i++) { if (fFontFamilies.ItemAt(i)) - delete[] fFontFamilies.ItemAt(i); + delete fFontFamilies.ItemAt(i); } } -void -Message::StartConfig(BView *view) -{ +void +Message::StartConfig(BView *view) +{ BPrivate::BuildDefaultSettingsView(view, "Message", B_TRANSLATE("by Ryan Leavengood")); -} +} -status_t +status_t Message::StartSaver(BView *view, bool preview) { fPreview = preview; @@ -136,14 +139,14 @@ Message::StartSaver(BView *view, bool preview) // Get font families int numFamilies = count_font_families(); for (int32 i = 0; i < numFamilies; i++) { - font_family* family = new font_family[1]; + font_family_wrapper* family = new font_family_wrapper; uint32 flags; - if (get_font_family(i, family, &flags) == B_OK + if (get_font_family(i, &(family->val), &flags) == B_OK && (flags & B_IS_FIXED) == 0) { // Do not add fixed fonts fFontFamilies.AddItem(family); } else - delete[] family; + delete family; } // Seed the random number generator @@ -151,12 +154,12 @@ Message::StartSaver(BView *view, bool preview) // Set tick size to 30,000,000 microseconds = 30 seconds SetTickSize(30000000); - + return B_OK; } -void +void Message::Draw(BView *view, int32 frame) { if (view == NULL || view->Window() == NULL || !view->Window()->IsLocked()) @@ -178,7 +181,7 @@ Message::Draw(BView *view, int32 frame) // Set up the colors rgb_color base_color = {(uint8)(rand() % 25), (uint8)(rand() % 25), (uint8)(rand() % 25)}; - offscreen.SetHighColor(base_color); + offscreen.SetHighColor(base_color); offscreen.SetLowColor(tint_color(base_color, 0.815F)); offscreen.FillRect(offscreen.Bounds(), kCheckered); rgb_color colors[8] = { @@ -198,7 +201,7 @@ Message::Draw(BView *view, int32 frame) BFont font; offscreen.GetFont(&font); font.SetFace(B_BOLD_FACE); - font.SetFamilyAndStyle(*(fFontFamilies.ItemAt(rand() % fFontFamilies.CountItems())), NULL); + font.SetFamilyAndStyle(fFontFamilies.ItemAt(rand() % fFontFamilies.CountItems())->val, NULL); offscreen.SetFont(&font); // Get the message @@ -252,13 +255,13 @@ Message::Draw(BView *view, int32 frame) // if this isn't preview mode if (!fPreview) { BFont font(be_fixed_font); - font.SetSize(14.0); + font.SetSize(14.0); offscreen.SetFont(&font); font_height fontHeight; font.GetHeight(&fontHeight); float lineHeight = fontHeight.ascent + fontHeight.descent + fontHeight.leading; - + BStringList lines; int longestLine = 0; int32 count = get_lines(origMessage, lines, &longestLine);