Use BObjectList instead of BList.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28586 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood
2008-11-09 22:50:26 +00:00
parent f871c6f737
commit 8a33d61123
2 changed files with 13 additions and 10 deletions
@@ -1,5 +1,8 @@
SubDir HAIKU_TOP src add-ons screen_savers message ; SubDir HAIKU_TOP src add-ons screen_savers message ;
UsePrivateHeaders shared ;
# For ObjectList
SetSubDirSupportedPlatformsBeOSCompatible ; SetSubDirSupportedPlatformsBeOSCompatible ;
ScreenSaver Message : ScreenSaver Message :
+10 -10
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2007, Haiku, Inc. All Rights Reserved. * Copyright 2007-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -9,7 +9,7 @@
#include <Bitmap.h> #include <Bitmap.h>
#include <Font.h> #include <Font.h>
#include <List.h> #include <ObjectList.h>
#include <Picture.h> #include <Picture.h>
#include <Screen.h> #include <Screen.h>
#include <ScreenSaver.h> #include <ScreenSaver.h>
@@ -97,9 +97,9 @@ class Message : public BScreenSaver
status_t StartSaver(BView *view, bool preview); status_t StartSaver(BView *view, bool preview);
private: private:
BList *fFontFamilies; BObjectList<font_family> *fFontFamilies;
float fScaleFactor; float fScaleFactor;
bool fPreview; bool fPreview;
}; };
@@ -121,7 +121,7 @@ Message::~Message()
if (fFontFamilies) { if (fFontFamilies) {
for (int32 i = 0; i < fFontFamilies->CountItems(); i++) { for (int32 i = 0; i < fFontFamilies->CountItems(); i++) {
if (fFontFamilies->ItemAt(i)) if (fFontFamilies->ItemAt(i))
delete ((font_family) fFontFamilies->ItemAt(i)); delete fFontFamilies->ItemAt(i);
} }
delete fFontFamilies; delete fFontFamilies;
} }
@@ -146,14 +146,14 @@ Message::StartSaver(BView *view, bool preview)
// Get font families // Get font families
int numFamilies = count_font_families(); int numFamilies = count_font_families();
fFontFamilies = new BList(); fFontFamilies = new BObjectList<font_family>();
for (int32 i = 0; i < numFamilies; i++) { for (int32 i = 0; i < numFamilies; i++) {
font_family *family = new font_family[1]; font_family *family = new font_family[1];
uint32 flags; uint32 flags;
if (get_font_family(i, family, &flags) == B_OK) { if (get_font_family(i, family, &flags) == B_OK) {
// Do not add fixed fonts // Do not add fixed fonts
if (!(flags & B_IS_FIXED)) if (!(flags & B_IS_FIXED))
fFontFamilies->AddItem(*family); fFontFamilies->AddItem(family);
} }
} }
@@ -199,7 +199,7 @@ Message::Draw(BView *view, int32 frame)
BFont font; BFont font;
offscreen.GetFont(&font); offscreen.GetFont(&font);
font.SetFace(B_BOLD_FACE); font.SetFace(B_BOLD_FACE);
font.SetFamilyAndStyle((font_family) fFontFamilies->ItemAt(rand() % fFontFamilies->CountItems()), NULL); font.SetFamilyAndStyle(*(fFontFamilies->ItemAt(rand() % fFontFamilies->CountItems())), NULL);
offscreen.SetFont(&font); offscreen.SetFont(&font);
// Get the message // Get the message
@@ -252,7 +252,7 @@ Message::Draw(BView *view, int32 frame)
// Now draw the full message in a nice translucent box, but only // Now draw the full message in a nice translucent box, but only
// if this isn't preview mode // if this isn't preview mode
if (!fPreview) { if (!fPreview) {
BFont font(be_fixed_font); BFont font(be_fixed_font);
font.SetSize(14.0); font.SetSize(14.0);
offscreen.SetFont(&font); offscreen.SetFont(&font);
font_height fontHeight; font_height fontHeight;